akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int n;
	cin >> n;
	VI v(n), pre(n);
	int ans = 0;
	
	loop(i, n){
		cin >> v[i];
	}
	
	pre[n - 1] = v[n - 1];
	loop(i, n - 1){
		pre[n - i - 2] = v[n - i - 2];
		pre[n - i - 2] += pre[n - i - 1];
		pre[n - i - 2] %= MOD;
	}
	
	loop(i, n - 1){
		ans += v[i]*pre[i + 1];
		ans %= MOD;
	}
	
	cout << ans;
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 6364
INF = float("inf")
IINF = 10 ** 18
MOD = 998244353


def main():
    M = int(input())
    N = 0
    S = 0

    for i in range(M):
        d, c = list(map(int, input().split()))

        if d == 0 and i == 0:
            continue

        S += d * c
        N += c

    print((N - 1) + (S - 1) // 9)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44888
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0
    
    a.sort()
    if "".join(a) == '557':
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,ans;
int x[205];
int main(void){
    cin>>n;
    for(int i=0;i<n*2;i++)cin>>x[i];
    sort(x,x+2*n);
    for(int i=0;i<n;i++)ans+=x[i*2];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict

def main():
    A = list(input())
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    ans = 1
    for i in range(97,123):
        for j in range(i+1,123):
            ans += d[chr(i)] * d[chr(j)]

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 84188
#include<iostream>
#include<vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<int> map(N);
  for(int i = 0; i < N; i++) {
    cin >> H[i];
    map[i] = H[i];
  }
  
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    map[A] = max(map[A], H[B]+1);
    map[B] = max(map[B], H[A]+1);
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(map[i]==H[i]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n) cout << s[i] << t[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3556
def gcd(x,y):
    if x < y:
        x,y = y,x
    while y > 0:
        r = x % y
        x = y
        y = r
    return x


n = int(input())
l = list(map(int,(input().split())))


if n == 3:
    x = gcd(gcd(l[0],l[1]),l[2])
else:
    x = gcd(l[0],l[1])


for i in range(1,x+1):
    if x % i == 0:
        print(i)



Measured memory_bytes: 5600
#include <bits/stdc++.h>

using namespace std;

int a[9]={0,0,0,0,0,0,0,0,0};

int main()
{
    int n,k,t,i,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t);
        if(t<400)a[0]++;
        else if(t<800&&t>=400)a[1]++;
        else if(t<1200&&t>=800)a[2]++;
        else if(t<1600&&t>=1200)a[3]++;
        else if(t<2000&&t>=1600)a[4]++;
        else if(t<2400&&t>=2000)a[5]++;
        else if(t<2800&&t>=2400)a[6]++;
        else if(t<3200&&t>=2800)a[7]++;
        else a[8]++;
    }
    for(i=0;i<8;i++)
        if(a[i])ans++;
    int mmin=ans;
    ans+=a[8];
    if (mmin==0)mmin=1;
    printf("%d %d",mmin,ans);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] imp = Console.ReadLine().Split(' ');
            Array.Sort(imp);
            
            int A=int.Parse(imp[2]);
            int B=int.Parse(imp[1]);
            int C=int.Parse(imp[0]);
            Console.WriteLine(A*10+B+C);
            
            
        }
    }
}

Measured memory_bytes: 13280
N = int(input())
A = list(map(int,input().split()))
A.sort()
count = A[N-1]
i = 0
j = 0
if N == 2:
    print(A[1])
else:
    if (N-2) % 2 == 0:
        for i in range(0,(N-2)//2):
            count += 2 * A[N-2-i]
    else:
        for j in range(0,(N-2)//2):
            count += 2 * A[N-2-j]
        count += A[N-3-j]
    print(count)



Measured memory_bytes: 31680
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	ll ans = 0;
	for(int a=1;a<=n;++a){
		int cnt = 1;
		int b = a;
		while(1){
			if((n-(b*cnt))>0) ++ans;
			else break;
			++cnt;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX]; //i!%mod=fac[i]
long long finv[MAX]; //pow(i!,-1)%mod=finv[i]
long long inv[MAX]; //pow(i,-1)%mod=inv[i]

long long pow(int n,int r)
{
	if (r==0)
	{
		return 1LL;
	}
	long long a=pow(n,r/2);
	a*=a;
	a%=mod;
	if (r%2==1)
	{
		a*=n;
		a%=mod;
	}
	return a;
}

long long f(int n,int r)
{
	long long ans=1LL;
	for (int i = 0; i < r; ++i)
	{
		ans*=n-i;
		ans%=mod;
	}
	return ans;	
}

// テーブルを作る前処理
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return f(n,k) * finv[k] % mod;
}


int main(int argc, char const *argv[])
{
	cominit();
	int n,a,b;
	cin>>n>>a>>b;
	long long ans=pow(2,n),now=1;
	ans-=com(n,a);
	ans-=com(n,b);
	ans%=mod;
	--ans;
	ans+=mod;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

int parent[200000];

int treeid(int i) {
  while (parent[i] >= 0) {
    i = parent[i];
  }
  return i;
}

void merge(int i, int j) {
  int idi = treeid(i), idj = treeid(j);
  if (idi == idj) return;
  else if (parent[idi] < parent[idj]) {
    parent[idi] += parent[idj];
    parent[idj] = idi;
  } else {
    parent[idj] += parent[idi];
    parent[idi] = idj;
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) parent[i] = -1;

  rep(i, m) {
    int u, v;
    cin >> u >> v; u--; v--;
    merge(u, v);
  }

  int mini = 0;
  rep(i, n) {
    if (parent[i] < mini) mini = parent[i];
  }

  cout << -mini << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  float a[n], sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
 sort(a, a+n);
  float t=a[0];
  for(int i=1;i<n;i++){
    t=(t+a[i])/2;
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int i = 0;
    int j;
    int max = -1000000000;
    int current =-1000000000;
    
    scanf("%d",&a);
    
    int b[a];
    
    for(j = 0; j < a; j++){
        scanf("%d\n",&b[j]);
    }
    
    for(j = 0; j < a; j++){
        if(current > b[a-j-1] && i != 0){
            continue;
        }
            
        for(i = j; i < a-1; i++){
            
            if(b[a-1-j] - b[i-j] > max){
                max = b[a-1-j] - b[i-j];
                current = b[a-1-j];
                //printf("%d %d\n",b[a-1-j], max);
            }
        }
    }
    printf("%d\n",max);
    
	return 0;
}



Measured memory_bytes: 2584
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (true)
            {
                int input = int.Parse(Console.ReadLine());
                if (input != 0)
                {
                    Console.WriteLine("Case " + i + ": " + input);
                    i++;
                }
                else
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 9364
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import Counter

# 直径が分かる。中心からの距離が分かる。

N = int(input())
A = [int(x) for x in input().split()]

diag = max(A)

def solve_even():
    # 中心が1頂点
    depth = [x-diag//2 for x in A]
    if any(x < 0 for x in depth):
        return False
    counter = Counter(depth)
    if counter[0] != 1:
        return False
    for i in range(1,diag//2+1):
        if counter[i] < 2:
            return False
    return True

def solve_odd():
    # 直径の隣を深さ0と扱う
    depth = [x-(diag+1)//2 for x in A]
    if any(x < 0 for x in depth):
        return False
    counter = Counter(depth)
    if counter[0] != 2:
        return False
    for i in range((diag+1)//2):
        if counter[i] < 2:
            return False
    return True

bl = solve_odd() if diag&1 else solve_even()
answer = 'Possible' if bl else 'Impossible'
print(answer)

Measured memory_bytes: 3316
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N % 2 == 0)
        {
                cnt++;
                N /= 2;
        }
        return cnt;
}

int main()
{
        int N, X;

        cin >> N>>X;
        vector<int> m(N+1);

        rep(i, N) cin >> m[i];
        sort(m.begin(),m.begin()+N);

        int sum = 0;
        rep(i, N) sum += m[i];
        cout << N + (X - sum) / m[0] << endl;


        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

enum Info{
	A_value,
	Z_value,
	NO_value
};

int main(){

	Info pre = NO_value;
	int a_count = 0,z_count = 0,index = 0;
	char buf[21],result[21];

	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0';i++){
		if(buf[i] == 'A'){
			if(pre == NO_value){
				a_count++;
				result[index++] = 'A';
				pre = A_value;
			}else if(pre == A_value){
				//Do nothing
			}else{ //pre == Z_value
				result[index++] = 'A';
				pre = A_value;
			}
		}else if(buf[i] == 'Z'){
			if(pre == NO_value){
				//Do nothing
			}else if(pre == A_value){
				z_count++;
				result[index++] = 'Z';
				pre = Z_value;
			}else{ //pre == Z_value
				//Do nothing
			}
		}else{
			//Do nothing
		}
	}

	if(z_count == 0)printf("-1\n");
	else{
		if(result[index-1] == 'Z'){
			result[index] = '\0';
		}else{
			result[index-1] = '\0';
		}
		printf("%s\n",result);
	}


	return 0;
}

Measured memory_bytes: 2660
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;

void solve(){
    cin >> n;
    ll ans=0;
    Rep(i,1,n+1){
        if(i%3!=0 && i%5!=0){
            ans+=i;
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3640
from collections import Counter

def solve():
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]
    SC = Counter(S)
    TC = Counter(T)
    ans = 0
    for k, v in SC.items():
        ans = max(ans, v - TC.get(k, 0))
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 65664
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[][]A = new int[N][];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			int a = int.Parse(str[i]);
			A[i] = new int[2]{a,i+1};
		}
		Array.Sort(A,(x,y)=>x[0]-y[0]);
		Console.Write(A[0][1]);
		for(var i=1;i<N;i++){
			Console.Write(" "+A[i][1]);
		}
	}
}

Measured memory_bytes: 27092
#include <iostream>
#include <string>
using namespace std;

int main(){
  string s;
  cin >> s;
  int a;
  if(s[0] == '1') ++a;
  if(s[1] == '1') ++a;
  if(s[2] == '1') ++a;
  cout << a;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
R,S,P = map(int,input().split())
points = {'r':P,'s':R,'p':S}
l = list(input())
com = ['']*n
ans = 0
for i,j in enumerate(l):
  p = points[j]
  com[i] = j
  if (i-k>=0) and com[i] == com[i-k]:
    com[i] = ''
    p = 0
  ans += p
print(ans)
    

Measured memory_bytes: 10400
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    if(S.front() == S.back() ^ (S.length()%2 == 0)){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
  int t;
  cin >> t;
  rep(i,t) {
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main() {
	int X = 1;
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N;i++){
		if(X*2 < X+K) X *= 2;
		else X += K;
	}
	cout << X << endl;
	return 0;
} 

Measured memory_bytes: 504
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    char c; cin >> c;
    if (islower(c)) {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = 0;
    static int m = 0;
    static int v = 0;
    static int p = 0;
    static Long[] a = null;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        v = sc.nextInt();
        p = sc.nextInt();
        a = new Long[n];
        for(int i = 0; i < n; ++i) a[i] = sc.nextLong();

        Arrays.sort(a, Comparator.reverseOrder());
        // System.out.println(Arrays.toString(a));
        
        int ans = binaryLowerSearch() + 1;
        System.out.println(ans);
    }

    static int binaryLowerSearch() {
        int left = 0;
        int right = n;
        while(right - left > 1) {
            int mid = right - (right - left) / 2;
            // System.out.println("mid = " + mid);
            if(canMeetCondition(mid)) {
                // System.out.println("CAN MEET");
                left = mid;
            } else {
                // System.out.println("CANNOT MEET");
                right = mid;
            }
        }
        return left;
    }

    static boolean canMeetCondition(int index) {
        if(index < p) return true;
        if(a[index] + m < a[p - 1]) return false;

        long votes = 0;
        for(int i = 0; i < n; ++i) {
            if(i < p - 1) {
                votes += m;
            } else if(i < index) {
                votes += a[index] + m - a[i];
            } else {
                votes += m;
            }
        }
        return (votes >= 1L * m * v);
    }
}

Measured memory_bytes: 63292
#include<iostream>
#include <stdlib.h>
#include<string>
using namespace std;

string map[200];
int j_map[200][200];
int* ans(int* x){
	if(j_map[x[0]][x[1]]==1){
		x[0]=x[1]=-1;
		return x;
	}else{
		j_map[x[0]][x[1]]=1;
		
		if(map[x[0]][x[1]]=='v'){
			x[0]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='<'){
			x[1]--;
			return ans(x);
		}else if(map[x[0]][x[1]]=='>'){
			x[1]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='^'){
			x[0]--;
			return ans(x);
		}else{
			return x;
		}
	}
}



int main(){
	int w,h;
	while(cin>>w,cin>>h,(w!=0)&&(h!=0)){
		for(int i=0;i<w;i++){
			cin>>map[i];
		}
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				j_map[i][j]=0;
			}
		}
		
		int* x=(int *)malloc(sizeof(int)*3);
		x[0]=x[1]=0;
		x = ans(x);
		if(x[0]==-1){
			cout<<"LOOP"<<endl;
		}else{
			cout<<x[1]<<" "<<x[0]<<endl;
		}
	}
	
}

Measured memory_bytes: 1312
#include <stdio.h>
#include <algorithm>
using namespace std;

const int N = 1e5 + 10;

long long a[N];
long long dp[N][3];

void maximize(long long &x, long long y) {
  if (x < y) {
    x = y;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
  }
  dp[1][0] = a[0] + a[1];
  dp[1][1] = -(a[0] + a[1]);
  for (int i = 2; i < n; i++) {
    dp[i][0] = dp[i - 1][0] + a[i];
    maximize(dp[i][0], dp[i - 1][1] + a[i]);
    dp[i][1] = dp[i - 1][0] - a[i - 1] - a[i - 1] - a[i];
    maximize(dp[i][1], dp[i - 1][1] + a[i - 1] + a[i - 1] - a[i]);
  }
  printf("%lld\n", max(dp[n - 1][0], dp[n - 1][1]));
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int arr[8];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> v;
    ll count=0;
    for(ll i=0;i<n;i++){
        ll k;
        cin>>k;
        if(k<400){
            arr[0]+=1;
        }
        else if(k<800){
            arr[1]+=1;
        }
        else if(k<1200){
            arr[2]+=1;
        }
        else if(k<1600){
            arr[3]+=1;
        }
        else if(k<2000){
            arr[4]+=1;
        }
        else if(k<2400){
            arr[5]+=1;
        }
        else if(k<2800){
            arr[6]+=1;
        }
        else if(k<3200){
            arr[7]+=1;
        }
        if(k>=3200)
            count+=1;

        v.pb(k);
    }
    ll ans=0;
    for(int i=0;i<=7;i++){
        if(arr[i]>0){
            ans+=1;
        }
    }
    if(ans>0){
        cout<<ans<<' ';
    }
    else{
        cout<<1<<' ';
    }
    cout<<count+ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <functional>

int ans[] = {0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,3,8,8,11,11,11,11,14,14,32,32,35,35,35,35,42,42,42,42,49,49,49,49,49,49,75,75,86,86,86,86,86,86,123,123,131,131,131,131,148,148,153,153,170,170,170,170,170,170,227,227,227,227,227,227,250,250,323,323,324,324,324,324,354,354,354,354,384,384,384,384,384,391,491,491,529,529,529,529,529,529,543};

int main() {
	int n;
	std::cin >> n;
	std::cout << ans[n-1] << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}

struct edge{int u, cost;};
vector<vector<edge>> adj;
vi color;
int N;

void dfs(int v=0, int c=0){
    color[v]=c;
    for(auto e : adj[v]){
        int nv=e.u;
        if(color[nv] != -1) continue;
        if(e.cost%2 == 0) dfs(nv, c);
        else dfs(nv, c^1);
    }
    return;
}

int main(){
    cin >> N;
    adj.resize(N);
    color.assign(N, -1);
    for(int i=0; i<N-1; i++){
        int u, v, w; cin >> u >> v >> w;
        u--, v--;
        adj[u].push_back((edge){v, w});
        adj[v].push_back((edge){u, w});
    }

    dfs();
    for(int i=0; i<N; i++){
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10648
/*
t.me/ivanesipovvpered
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
typedef long long ll;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 1e6 + 3;

ll gcd(ll a, ll b){
    if (b == 0ll)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return (a / gcd(a, b) )* b;
}

bool is_prime(ll a){
    if (a == 2 || a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (a == 0)
        return 1;
    if (a % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q)  ;
    }else return (a * binpow(a, n - 1) ) ;
}





















main(){
    int n;
    cin >> n;
    vector<ll> primes;
    ll a[n][n];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            a[i][j] = 0;
        }
    }
    int fe = 2;
    while (primes.size() < n + n + 2){
        if (is_prime(fe)) primes.pb(fe);
        fe++;
    }
    int q = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if ((i + j) % 2 == 0){
                a[i][j] = primes[(i + j) / 2];
                q = max(q, (i + j) / 2);
            }
        }
    }
    for (int j = n - 1; j > -1; j--){
        for (int i = 0; i < n; i++){
            if ((i + j) % 2 == 0){
                a[i][j] *= primes[q + 1 + (i + (n - j)) / 2];
            }
        }
    }
    map<ll,bool> kek;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (a[i][j]) continue;
            int qe = 1, we = 1;
            if (i)
                qe = a[i-1][j];
            if (i < n - 1)
                qe = lcm(qe, a[i+1][j]);
            if (j)
                we = a[i][j-1];
            if (j < n-1)
                we = lcm(we,a[i][j+1]);
            int ce = lcm(qe, we);
            int flex = ce;
            while (kek[ce]){
                ce += flex;
            }
            kek[ce] = 1;
            a[i][j] = ce + 1;
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0 ; j< n; j++){
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 12928
/* Author haleyk10198 */
/* 作者:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

string str[2];

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	
	cin >> str[0] >> str[1];
	if(str[0][0] == str[1][2] && str[0][1] == str[1][1] && str[0][2] == str[1][0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = numeric_limits<ll>::max();
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> primes;
    for (int p = 2; p <= n; p++) {
        bool ok = true;
        for (int i = 2; i * i <= p; i++) {
            if (p % i == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            primes.push_back(p);
        }
    }
    unordered_map<int, int> count;
    for (int i = 1; i <= n; i++) {
        int t = i;
        for (auto p : primes) {
            while (t % p == 0) {
                t /= p;
                count[p]++;
            }
        }
    }
    ll ans = 1;
    for (auto p : count) {
        ans = (ans * (p.second + 1)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String arg = scan.next();
    int p = Integer.parseInt(arg.substring(0, 2));
    int s = Integer.parseInt(arg.substring(2));
    boolean pim = 1 <= p && p <= 12;
    boolean sim = 1 <= s && s <= 12;
    System.out.println(pim ? sim ? "AMBIGUOUS" : "MMYY" : sim ? "YYMM" : "NA");
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long max;
  int s[]={0, 3, 5, 7};
  int n[10] = {0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
  bool flg1=true;
  bool flg2=true;
  bool flg3=true;
  int cnt=0;
  cin >> max;
  long long sgs=357;
  while(sgs<=max){
    if(flg1&&flg2&&flg3){
      cnt++;
      // cout << sgs << endl;
    }
    flg1=false;
    flg2=false;
    flg3=false;
    n[9]++;
    for(int i=9;i>0;i--){
      if(n[i]==4){
        n[i-1]++;
        n[i]=1;
      }
      if(n[i]==1){
        flg1=true;
      }
      if(n[i]==2){
        flg2=true;
      }
      if(n[i]==3){
        flg3=true;
      }
    }
    if(n[0]==1){
      flg1=true;
    }
    if(n[0]==2){
      flg2=true;
    }
    if(n[0]==3){
      flg3=true;
    }
    sgs=0;
    for(int i=0;i<10;i++){
      sgs=sgs*10+s[n[i]];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while(t--)
    {
        int n,m,i,x,y,z;
        cin>>n>>m;
        vector<int> adj[n+1];
        for(i=0;i<m;i++)
        {
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        int ans[n+1];
        for(i=2;i<=n;i++)
            ans[i]=-1;
        ans[1]=1;
        queue<int> q;
        q.push(1);
        bool vis[n+1];
        memset(vis,false,sizeof(vis));
        while(q.size()>0)
        {
            z=q.front();
            q.pop();
            for(auto it: adj[z])
            {
                if(!vis[it]){
                    ans[it]=z;
                    q.push(it);
                    vis[it]=true;
                }
            }
        }
        for(i=2;i<=n;i++)
        {
            if(ans[i]==-1)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        for(i=2;i<=n;i++)
            cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 13128
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
 
 
int main() {
    int N, M, X, Y;

    cin >> N >> M >> X >> Y;

    int x_max = -100;
    int y_min =  100;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        x_max = max(x_max, x);
    }
    for (int i = 0; i < M; i++) {
        int y;
        cin >> y;
        y_min = min(y_min, y);
    }
    
    string ans = "War";
    for (int i = X+1; i <= Y; i++) {
        if (x_max < i && y_min >= i) {
            ans = "No War";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x[5];
  int ans=123;
  for(int i=0;i<5;i++){
    cin>>x[i];
    if(x[i]==0){
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3520
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1241

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N;
	while(cin >> N && N)
	{
		int MAX = sqrt(N)+1;
		int ans=0;
		rep(a,MAX){
			REP(b,a,MAX){
				REP(c,b,MAX){
					REP(d,c,MAX){
						if(a*a + b*b + c*c + d*d == N){ ans++; }
					}
				}
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    int sum = 0;
    vector<int> v(n);
    rep(i,0,n) {
        cin >> v[i];
        sum += v[i];
    }

    int m; cin >> m;
    int p, x;
    rep(i,0,m) {
        cin >> p >> x; p--;
        cout << sum - v[p] + x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int x, y, z;

int main() {
    cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int n,m;
double t[101][101],ans;
double dp[101][101];
int main(){
  while(cin>>n>>m&&n){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	cin>>t[i][j];
      }
    }
    for(int i=0;i<=100;i++)dp[0][i]=dp[1][i]=1.0;

    for(int i=2;i<=m;i++){
      for(int j=1;j<=n;j++){
	dp[i][j]=0.0;
	for(int k=1;k<=n;k++){
	  dp[i][j]=max(dp[i][j],dp[i-1][k]*t[k][j]);
	}
      }
    }

    ans=0.0;
    for(int i=1;i<=n;i++)ans=max(ans,dp[m][i]);
    printf("%.2f\n",ans);
    
    
  }
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

int dp[2005][2005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n) cin >> a[i], a[i]--;
    auto upd = [&](int x, int y, int v) {
        chmax(dp[x][y], v);
        chmax(dp[y][x], v);
        chmax(dp[x][n], v);
        chmax(dp[n][x], v);
        chmax(dp[y][n], v);
        chmax(dp[n][y], v);
        chmax(dp[n][n], v);
    };
    rep(i, 2005) rep(j, 2005) {
        dp[i][j] = -INF;
    }
    upd(a[0], a[1], 0);
    int base = 0;
    rep(ti, n-1) {
        int x = a[ti*3+2];
        int y = a[ti*3+3];
        int z = a[ti*3+4];
        if (x==y && y==z) {
            base++;
            continue;
        }
        vector<tuple<int, int, int>> q;
        rep(ri, 3) {
            {
                rep(i, n) {
                    int now = dp[i][n];
                    if (y==z) chmax(now, dp[i][y]+1);
                    q.emplace_back(i, x, now);
                }
            }
            {
                int now = dp[n][n];
                chmax(now, dp[z][z]+1);
                q.emplace_back(x, y, now);
            }
            swap(x, y); swap(y, z);
        }
        for (auto e: q) {
            int e1, e2, e3;
            tie(e1, e2, e3) = e;
            upd(e1, e2, e3);
        }
    }
    int ans = dp[n][n];
    chmax(ans, dp[a.back()][a.back()]+1);
    ans += base;
    
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
int n,m;
cin>>n>>m;
vector<int> hen[n];
int a,b;
for(int i=0;i<m;i++){
  cin>>a>>b;a--;b--;
  hen[a].push_back(b);
  hen[b].push_back(a);
}
int p[n]={};
queue<int> que;
p[0]=1;
que.push(0);int t,ans=0;
while(!que.empty()){
  t=que.front();
  que.pop();
  for(int i=0;i<hen[t].size();i++){
    if(p[hen[t][i]]==0){
      p[hen[t][i]]=-1*p[t];
      que.push(hen[t][i]);
    }
    if(p[t]==p[hen[t][i]])ans=1;
  }
}
if(ans)cout<<n*(n-1)/2 -m;
else{
  int o=0;
  for(int i=0;i<n;i++){
    if(p[i]==1)o++;
  }
  cout<<o*(n-o)-m;
}


return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c, long long d){
    if (abs(a-c) <= d) {
        cout << YES << endl;
    } else {
        if (abs(a-b) <= d and abs(b-c) <= d) {
            cout << YES << endl;
        } else {
            cout << NO << endl;
        }
    }
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector <int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    } 
    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        int maxp = max(p[i], max(p[i + 1], p[i + 2]) );
        int minp = min(p[i], min(p[i + 1], p[i + 2]) );
        if (p[i + 1] == p[i] + p[i + 1] + p[i + 2] - maxp - minp) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
class MyQueue:
    def __init__(self, max):
        self.MAX = max
        self.queue = [0] * self.MAX
        self.head = self.tail = 0
        
    def is_empty(self):
        return self.head == self.tail
        
    def is_full(self):
        return self.head == self.tail+1%self.MAX
        
    def enqueue(self, elm):
        if self.is_full():
            raise ValueError()
        
        self.queue[self.tail] = elm
        
        if self.tail+1 == self.MAX:
            self.tail = 0
        else:
            self.tail += 1
    
    def dequeue(self):
        if self.is_empty():
            raise ValueError()
        
        elm = self.queue[self.head]
        
        if self.head+1 == self.MAX:
            self.head = 0
        else:
            self.head += 1
        
        return elm

N, qt = [int(n) for n in input().split()]
queue = MyQueue(N+10)

for n in range(N):
    name, time = input().split()
    queue.enqueue([name, int(time)])

time = 0
while not queue.is_empty():
    prc = queue.dequeue()
    if prc[1] > qt:
        prc[1] -= qt
        queue.enqueue(prc)
        time += qt
    else:
        time += prc[1]
        print(prc[0], time)


        



Measured memory_bytes: 12924
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(vector<vector<T>> v) {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
}


template<typename T> void Show(vector<T> v) {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

int main() {
	string S,T;
	cin >> S;
	cin >> T;
	int L = S.length() - T.length();
	vector<string> Keys = vector<string>();
	for (int offset = 0; offset <= L; offset++) {//尺取り虫でTをずらして、嵌められる時は追加していく。
		string key=S;
		bool accept = true;
		for (int i = 0; i < T.length(); i++) {
			if (S[offset + i] != '?' && T[i] != S[offset + i]) {
				accept = false;
				break;
			}
		}
		if (accept)Keys.push_back(key.replace(offset,T.length(), T));
	}
	if (Keys.empty()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	int N = Keys.size();
	for (int i = 0; i < N; i++) {
		replace(Keys[i].begin(), Keys[i].end(), '?', 'a');
	}
	sort(Keys.begin(), Keys.end());
	cout << Keys[0] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N;
        char word[100][11];
        char a;
scanf("%d",&N);
scanf("%s",&word[0] );
for (int i = 1; i < N; i++) {
  scanf("%s",&word[i] );
  for (int j = 0; j < 10; j++) {
    if (word[i-1][j]=='\0') {
      break;
    }
    a=word[i-1][j];
  }
if (a!=word[i][0]) {
  printf("No\n" );
  return 0;
  
}
for (int j = 0; j < i; j++) {
  if (strcmp(word[i],word[j])==0) {
    printf("No\n" );
    return 0;
  }
}
}
printf("Yes\n" );

        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  if(A%3==0 || B%3==0 || (A+B)%3==0)
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class ALDS1_10_C
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int d = int.Parse(Console.ReadLine());
        for (int i = 0; i < d; i++)
        {
            string x = " " + Console.ReadLine();
            string y = " " + Console.ReadLine();
            Solve(x, y);
        }
    }

    private static void Solve(string x, string y)
    {
        List<List<int>> dp = new List<List<int>>();
        for (int i = 0; i < x.Length; i++)
        {
            dp.Add(new List<int>());
            for (int j = 0; j < y.Length; j++)
            {
                if (i == 0 || j == 0)
                {
                    dp[i].Add(0);
                }
                else
                {
                    dp[i].Add(-1);
                }
            }
        }
        for (int i = 1; i < x.Length; i++)
        {
            for (int j = 1; j < y.Length; j++)
            {
                Lcs(i, j, x, y, dp);
            }
        }
        Console.WriteLine(dp[x.Length-1][y.Length-1].ToString());
    }

    private static void Lcs(int i, int j, string x, string y, List<List<int>> dp)
    {
        if (x[i] == y[j])
        {
            dp[i][j] = dp[i - 1][j - 1] + 1;
        }
        else
        {
            dp[i][j] = Math.Max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
}



Measured memory_bytes: 40616
#include<stdio.h>

int main()
{
  int min,max,i,n,ans;
  int a[101];

  min=1000;
  max=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);

      if(a[i]<min)min=a[i];
      if(a[i]>max)max=a[i];
    }

  ans=max-min;

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128