akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final int N = 5;
        Scanner sc = new Scanner(System.in);
        int[] times = new int[N];
        for (int i = 0; i < N; i++) {
            times[i] = sc.nextInt();
        }

        int minIndex = 0;
        int min = times[0]%10;
        for (int i = 1; i < N; i++) {
            if ((times[i]%10 != 0) && (times[i]%10 < min)) {
                minIndex = i;
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (i == minIndex) {
                ans += times[i];
            }
            else if (times[i]%10 == 0) {
                ans += times[i];
            }
            else {
                ans += (times[i] + (10 - times[i]%10));
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll X;
    cin >> X;

    for (ll i = -1000; i < 1000; ++i) {
        for (ll j = -1000; j < 1000; ++j) {
            if(i*i*i*i*i - j*j*j*j*j == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3156
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>
#include <cmath>


#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007



using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double a,b,x,i,j,n,angle;
    cin>>a>>b>>x;
    
    n=(a*a*b/2);
    if(x==n){
        i=atan(b/a);
                cout<<setprecision(10)<<((i*180)/PI);
    }
    else if(x>n){
        //cout<<111;
        i=atan((2*b-(2*x)/(a*a))/a);
        //cout<<(2*b-(2*x/a))/a;
        cout<<setprecision(10)<<((i*180)/PI);
    }
    else{
      //  cout<<222;
        i=atan((b*b*a)/(2*x));
        
                cout<<setprecision(10)<<((i*180)/PI);
        
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>

using namespace std;

string s;
long long int K;
long long int E;//残り

int po(char o){
	return (int)o;
}

int main(){
	cin >> s;
	scanf("%lld",&K);
	E = K;
	for(int i=0;i<s.length();i++){
		//cout<<po('z')-po(s[i])+1<<"aaa"<<E<<endl;
		if(s[i]!='a' && E >= po('z')-po(s[i])+1){	
			E -= po('z')-po(s[i])+1;
			s[i]='a';
		}
	}

	if(E>0)s[s.length()-1]=char(po(s[s.length()-1])+E%26);
	
	cout << s << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
	vector<vector<ll>> dp(s.sz,vector<ll>(13,0));
	vector<vector<ll>> table(13,vector<ll>(13,0));

	rep(i,13){
		rep(j,13){
			ll tp=i-j*10;
			while(tp<0){
				tp+=13;
			}
			if(0<=tp%13 && tp%13<=9) table[i][j]=1;
		}
	}

	if(s[0]=='?'){
		rep(i,10) dp[0][i]=1;
	}
	else{
		char tmp=s[0]-'0';
		dp[0][tmp]=1;
	}
	
	rep1(i,s.sz-1){//dp[i][]
		if(s[i]=='?'){
			rep(j,13){
				rep(k,13){
					dp[i][j]+=dp[i-1][k]*table[j][k];
					dp[i][j]%=MOD;
				}
			}
		}
		else{
			char tmp=s[i]-'0';
			rep(j,13){
				ll tp=j*10+tmp;
				dp[i][tp%13]=dp[i-1][j];
			}
		}
	}
	cout<<dp[s.sz-1][5];
}

Measured memory_bytes: 13568
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef pair< int , int > pi;
typedef set< int > se;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define Fn 1.618033987
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin>>x;
    if(x==1)
    {
        cout<<0<<'\n';    
    }
    else
    {
        cout<<1<<'\n';
    }
    return 0; 
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
from collections import defaultdict
N,M=map(int,input().split())
X=list(map(int,input().split()))
tab=[0]*M
cnts=[defaultdict(lambda: 0) for _ in range(M)]
for x in X:
    tab[x%M]+=1
    cnts[x%M][x]+=1
    
ans=0
for i in range(M//2+1):
    if i==0 or (M%2==0 and i==M//2):
        npair = tab[i]//2
        tab[i]-= 2*npair
        ans += npair
    else:
        npair = min(tab[i],tab[M-i])
        tab[i]-= npair
        tab[M-i]-= npair
        ans += npair

for remn, d in zip(tab, cnts):
    tmp=0
    for _,n in d.items():
        tmp += (n//2)
    ans += min(tmp, remn//2)

print(ans)


Measured memory_bytes: 102124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  bool graph[4][4] = {};
  for (int i = 0; i < 3; ++i)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a][b] = graph[b][a] = true;
  }
  vector<int> v;
  for (int i = 0; i <= 3; ++i)
  {
    int cnt = 0;
    for (int j = 0; j <= 3; ++j)
    {
      if (i == j)
        continue;
      if (graph[i][j])
        cnt++;
    }
    v.push_back(cnt);
  }
  bool flag = true;
  int cnt = 0;
  for (int i = 0; i < v.size(); ++i)
  {
    if (v[i] % 2 == 1)
      cnt++;
  }
  if (cnt == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(int& x, int& y){
    int tmp;
    tmp = x;
    x = y;
    y = tmp;
}


int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(!x && !y)break;
        if(x>y)swap(x,y);
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	string s;
	cin >> s;
	rep (i, s.size()) {
		cout << 'x';
	}
	cout << endl;
}

Measured memory_bytes: 256
y,x=map(int,input().split())
info=[]
for i in range(y):
    a=list(input())
    a.insert(0,"#")
    a.append("#")
    info.append(a)
b=["#"]*(x+2)
info.insert(0,b)
info.append(b)
for i in range(y+2):
    print("".join(info[i]))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t;
    cin >> t; cin.ignore();
    string s;
    while(t--){
        getline(cin, s);
        [&](){
            for (int i = 0; i < 26; ++i) {
                for (int j = 0; j < 26; ++j) {
                    string a = s;
                    for (auto &&k : a) {
                        if(isalpha(k)) k = ((k-'a')*i+j)%26+'a';
                    }
                    if(a.find("this") != string::npos || a.find("that") != string::npos){
                        cout << a << "\n";
                        return;
                    }
                }
            }
        }();
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  long long n,k;
  cin >> n;
  long long d[n];
  
  for(int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d,d+n);

  long long low,high;
  low = d[n/2-1];
  high = d[n/2];
  cout << high - low << endl;
  return 0;
}


Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll X,Y; cin>>X>>Y;
  string ans="No";
  if(X*2<=Y&&Y<=X*4&&Y%2==0) ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vc vector<char>
map<string,int> mp;
void solve(){
    string s;
    cin>>s;
    mp[s]++;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--) solve();
    string s[]={"AC","WA","TLE","RE"};
    for(auto i :s){
        cout<<i<<" x "<<mp[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	string s;
	int n;
	map<string,vi> mp;
	vector<string> sent;

	while(cin>>s>>n){
		if(mp[s].size()==0)sent.pb(s);
		mp[s].pb(n);
	}

	sort(all(sent));
	rep(i,sent.size()){
		cout<<sent[i]<<endl;
		vi a;
		rep(j,mp[sent[i]].size()){
			a.pb(mp[sent[i]][j]);
		}
		sort(all(a));
		rep(i,a.size()){
			if(i!=0)cout<<" ";
			cout<<a[i];
		}
		cout<<endl;
	}

}

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); 
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main() {
    long long N, M; cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i], --A[i], --B[i];
    }
        
    UnionFind uf(N);
  
    long long cur = N * (N-1) / 2;
    vector<long long> res;
    for (int i = 0; i < M; ++i) {
        res.push_back(cur);
            
        int a = A[M-1-i], b = B[M-1-i];
        if (uf.issame(a, b)) continue;
        
        long long sa = uf.size(a), sb = uf.size(b);
        cur -= sa * sb;
        uf.merge(a, b);
    }
        
    reverse(res.begin(), res.end());
  
    for (int i = 0; i < res.size(); ++i)
      
      cout << res[i] <<endl;
}


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        var ans = int.MaxValue;
        var c = 0;
        for (int i = 0; i < S.Length; i++)//m:1010...
        {

            if (i % 2 == 0)
            {
                if (S[i] == '0') c++;
            }
            else
            {
                if (S[i] == '1') c++;
            }
        }
        ans = Math.Min(ans, c);
        c = 0;
        for (int i = 0; i < S.Length; i++)
        {

            if (i % 2 == 1)
            {
                if (S[i] == '0') c++;
            }
            else
            {
                if (S[i] == '1') c++;
            }
        }
        ans = Math.Min(ans, c);
        WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<cstdio>

#define LABEL_MAX 100
#define LABEL_MIN 0
#define ORDER_MAX 100
#define ORDER_MIN 0


class Dice
{
	public:
		Dice();
		int roll( int NSEW );
		int GetLabel( void );
		int PrintLabel( void );
	private:
		int top, south, east, north, west, bottom;
		int label[6];
};


Dice::Dice()
{
	top = 0;
	south = 1;
	east = 2;
	west = 3;
	north = 4;
	bottom = 5;
}


int Dice::roll( int NSEW )
{
	int cpy = top;
	
	if( NSEW == 'N' )
	{
		top = south;
		south = bottom;
		bottom = north;
		north = cpy;
	}
	else if( NSEW == 'S' )
	{
		top = north;
		north = bottom;
		bottom = south;
		south = cpy;
	}
	else if( NSEW == 'E' )
	{
		top = west;
		west = bottom;
		bottom = east;
		east = cpy;
	}
	else if( NSEW == 'W' )
	{
		top = east;
		east = bottom;
		bottom = west;
		west = cpy;
	}
	else
	{
		return -1;
	}
	
	return 0;
}


int Dice::GetLabel(void)
{
	for( int i = 0; i < 6; i++ )
	{
		scanf( "%d", &label[i] );
		if( ( label[i] > LABEL_MAX ) || ( label[i] < LABEL_MIN ) )
		{
			return -1;
		}
	}
	
	return 0;
}


int Dice::PrintLabel( void )
{
	switch( top )
	{
		case 0:
			printf("%d\n", label[0] );
			break;
		case 1:
			printf("%d\n", label[1] );
			break;
		case 2:
			printf("%d\n", label[2] );
			break;
		case 3:
			printf("%d\n", label[3] );
			break;
		case 4:
			printf("%d\n", label[4] );
			break;
		case 5:
			printf("%d\n", label[5] );
			break;
		default:
			break;
	}
	
	return 0;
}


int main(void)
{
	Dice dice;
	char c;
	
	if( dice.GetLabel() == 0 )
	{
		for(int i = 0; scanf( "%c", &c ) == 1; i++)
		{
			if( dice.roll( c ) == 0 )
			{
				if( ( i < ORDER_MIN ) || ( i > ORDER_MAX ) )
				{
					return -1;
				}
			}
		}
	}
	else
	{
		return -1;
	}
	
	dice.PrintLabel();
	
	return 0;
}

Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
#define ll long long int;
int h[100002],n,m,a[3],ans[100005],l,r,la,ra;
char s[100005][5];
int main(){
cin>>n;
for(int i=0;i<3;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>s[i];
for(int i=0;i<n;i++){
	l=s[i][0]-'A';
	r=s[i][1]-'A';
	if(a[l]==0&&a[r]==0){
		printf("No\n");
		return 0;
	}
	if(a[l]>a[r]){
		a[r]++;
		a[l]--;
		ans[i]='A'+r;
	}else if(a[0]+a[1]+a[2]==2&&a[l]==1&&a[r]==1&&i<n-1){
		la=s[i+1][0]-'A';
		ra=s[i+1][1]-'A';
		if(la==l||ra==l){
		a[l]++;
		a[r]--;
		ans[i]='A'+l;
		}else{
		ans[i]='A'+r;
		a[l]--;
		a[r]++;
		}
	}else{
		a[l]++;
		a[r]--;
		ans[i]='A'+l;
	}
}
printf("Yes\n");
for(int i=0;i<n;i++){
	cout<<(char)ans[i]<<endl;
}
}


Measured memory_bytes: 4516
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            t = 500*i + 100*j + 50*k
            if t == x:
                ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
    int X;
    cin>>X;
    if(X==3){
        cout<<"YES"<<endl;
    }
    else if(X==5){
        cout<<"YES"<<endl;
    }
    else if(X==7){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b)
        if (b < c)
            cout << a << " " << b << " " << c << endl;
        else if (a < c)
            cout << a << " " << c << " " << b << endl;
        else
            cout << c << " " << a << " " << b << endl;
    else
        if (a < c)
            cout << b << " " << a << " " << c << endl;
        else if (b < c)
            cout << b << " " << c << " " << a << endl;
        else
            cout << c << " " << b << " " << a << endl;
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fi > xed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  vector<bool> jud(n + 1, true);
  vector<int> dp(n + 1, 0);

  rep(i, 0, m) {
    int a;
    cin >> a;
    jud[a] = false;
  }

  dp[0] = 1;
  rep(i, 0, n) {
    for (int j = i + 1; j <= min(n, i + 2); ++j) {
      if (jud[j] == true) {
        dp[j] += dp[i];
        dp[j] %= mod1;
      }
    }
  }

  cout << dp[n] << '\n';
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int m, n; cin >> m >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	if (m == 2) {
		// 1,2,1,2,....
		int cnt1 = 0;
		for (int i = 0; i < n; ++i) {
			if ((i & 1) && a[i] == 1) ++cnt1;
			if (!(i & 1) && a[i] == 2) ++cnt1;
		}
		// 2,1,2,1,....
		int cnt2 = 0;
		for (int i = 0; i < n; ++i) {
			if ((i & 1) && a[i] == 2) ++cnt2;
			if (!(i & 1) && a[i] == 1) ++cnt2;
		}
		// 出力
		cout << min(cnt1, cnt2) << endl;
	}
	else {
		// 前日と同じものが出てきたら変更
		int res = 0;
		for (int i = 1; i < n; ++i)
			if (a[i - 1] == a[i])
				++res, ++i;
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3128
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C = map(int, readline().split())
    if A==B==C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


const int inf = 1e9;
const int maxd = 20;
int P[maxd], C[maxd];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int D,G;
    while (cin >> D >> G) {
        FOR(i,0,D)
            cin >> P[i] >> C[i];
        int ans = inf;
        for (int mask = 1; mask < (1<<D); mask++) {
            int cnt = 0, res = 0;
            int j = -1;
            FOR(i,0,D) if (mask & (1<<i)) {
                cnt += P[i];
                res += P[i] * 100*(i+1) + C[i];
                if (j == -1)
                    j = i;
            }
            if (res >= G) {
                ans = min(ans,cnt);
                FOR(j,0,D) if (mask & (1<<j)) {
                    int c = cnt;
                    int r = res;
                    if (r-C[j] >= G) {
                        r -= C[j];
                        FOR(_,0,P[j]) {
                            if (r - 100*(j+1) < G)
                                break;
                            c--;
                            r -= 100*(j+1);
                        }
                    }
                    ans = min(ans,c);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int red, green, blue, k;

void solve()
{
    scanf("%d%d%d%d", &red, &green, &blue, &k);
    int cnt = 0;
    while (green <= red)
        green <<= 1, cnt++;
    while (blue <= green)
        blue <<= 1, cnt++;
    if (cnt > k)
        puts("No");
    else
        puts("Yes");
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

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

using namespace std;
typedef long long int ll;

int main()
{
    ll n;

    cin>>n;


    if(n==1)    {
        cout<<1<<endl;
        return 0;
    }


    ll a=2;
    ll b=1;


    for(ll i=2;i<=n;i++)    {
        ll x=b;
        b=a+b;
        a=x;
    }

    cout<<b<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    if((a==7 && b==5 && c==5) || (a==5 && b==7 && c==5) || (a==5 && b==5 && c==7)) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
S=str(input())
if S[0]==S[1] and S[1]==S[2] and S[2]==S[3]:
  print('No')
elif S[0]==S[1] and S[2]==S[3]:
  print('Yes')
elif S[0]==S[2] and S[1]==S[3]:
  print('Yes')
elif S[0]==S[3] and S[1]==S[2]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define print(a)        for (auto x : a) cout << x << " "; cout << endl

inline void solve(){
	string s;cin>>s;
	ll sm=0;
	//int n=s.length();
	for(char ch:s){
		ll d=ch-'0';
		sm+=d;
	}
	if(sm%9)
		cout<<"No"<<"\n";
	else
		cout<<"Yes"<<"\n";
}

int main()
{
	cout<<fixed<<setprecision(12);
	fastio;ll  t=1,tc=1;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
	#endif
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 3744
import collections

N, K = map(int, raw_input().split())
A = map(int, raw_input().split())

num_A = collections.Counter(A)
res = 0
for i, (k, v) in enumerate(sorted(num_A.items(), key=lambda x: x[1])):
  if len(num_A) - K < i + 1:
    break
  res += v
print res


Measured memory_bytes: 45156
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][9-k]+c[9-k][j])
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
l=[]
for i in range(h):
    l.extend(list(map(int,input().split())))
x=0
for i in range(10):
    x+=c[i][1]*l.count(i)
print(x)

Measured memory_bytes: 3496
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,b,c; cin>>a>>b>>c;
    for(int q=0; q<10; q++){
        c=c*a-b;
        cout<<c<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    int n;
    int ac=0, wa=0, tle=0, re=0;

    scanf("%d",&n);

    char s[4];
    for(int i = 1; i<=n; i++){
        scanf("%s",s);
        if(strcmp(s,"AC")==0)   ac++;
        else if(strcmp(s,"WA")==0)   wa++;
        else if(strcmp(s,"TLE")==0)  tle++;
        else re++;

    }

    printf("AC x %d\n"  ,ac);
    printf("WA x %d\n"  ,wa);
    printf("TLE x %d\n" ,tle);
    printf("RE x %d\n"  ,re);
    return 0;
}

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


int main(){
  ll a, b ,x;
  cin >> a >> b >> x;
  if(a == 0){
    cout << b/x + 1 << endl;
  }else{
    cout << b/x - (a-1)/x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    char a, b, c;
    cin >> a >> b >> c;
    string s;
    s+=a;
    s+=b;
    s+=c;
    int d = stoi(s);
    if(d % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    long long N, K;
    cin >> N >> K;
    long long ans = N % K;
    long long ans_ = std::abs(ans - K);
    cout << std::min(ans, ans_);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
         int a,b;
         while(cin>>a>>b)
         {
               int c=a+b;
               if(c>=10)
                   cout<<"error"<<endl;
               else cout<<c<<endl;
         }
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	string a;
	cin>>a;
	bool myon=0;
	for(int i=0; i<n; i++){
		a[i]--;
		if(a[i]=='1') myon=1;
	}
	int c[1000010];
	for(int i=0; i<n; i++){
		if(((n-1)&i)==i) c[i]=1;
		else c[i]=0;
	}
	if(!myon){
		int ans=0;
		for(int i=0; i<n; i++){
			if(a[i]=='2') ans^=c[i];
		}
		if(ans) cout<<2<<endl;
		else cout<<0<<endl;
		return 0;
	}
	int ans=0;
	for(int i=0; i<n; i++){
		if(a[i]=='1') ans^=c[i];
	}
	if(ans) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 


void solve(){
	int a, b;
	cin>>a>>b;
	cout<<(a*(a-1)/2)+b*(b-1)/2<<endl;	
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

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

typedef long long int lli;


int main()
{
	lli a , b , c ,d;
	cin >> a >> b >> c >> d;

	lli m = a * c;
	lli n = a * d;
	lli o = b * c;
	lli p = b * d;

	lli maxi = max( m , n);
	maxi = max(maxi , o);
	maxi = max(maxi , p);

	cout << maxi;
		
	return 0;
}





Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	double n;
	cin >> n;
	// cout << n / 2.0 << endl;
	printf("%.8f\n", ceil(n / 2.0) / n);
}


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

namespace Frog_2
{
    class Program
    {
        private int N;
        private int K;
        private int[] h;
        private int[] costs;

        static void Main(string[] args)
        {
            Program pr = new Program();
            pr.getInput();
            pr.jumpFrog();
            Console.WriteLine(pr.costs[pr.N-1]);
            Console.ReadLine();
        }

        private void getInput()
        {
            String line1 = Console.ReadLine();
            String[] partsLine1 = line1.Split(new Char[] { ' ' });
            N = int.Parse(partsLine1[0]);
            K = int.Parse(partsLine1[1]);
            String line2 = Console.ReadLine();
            String[] partsLine2 = line2.Split(new Char[] { ' ' });
            h = new int[N];
            costs = new int[N];
            int cnt = 0;
            foreach (String part in partsLine2)
            {
                h[cnt++] = int.Parse(part);
            }
        }

        private void jumpFrog()
        {
            costs[0] = 0;
            for(int i = 1; i < N; i++)
            {
                costs[i] = int.MaxValue;
            }
            for (int i = 0; i < N - 1; i++)
            {
                try
                {
                    for (int j = 1; j <= K; j++)
                    {
                        if (Math.Abs(h[i] - h[i + j]) + costs[i] < costs[i + j])
                        {
                            costs[i + j] = Math.Abs(h[i] - h[i + j]) + costs[i];
                        }
                    }
                }
                catch (IndexOutOfRangeException e) { }
            }
        }

    }
}


Measured memory_bytes: 17248
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t
    val zero : t
    val neg_inf : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない
       2n回呼び出されるので，リストを作るのに時間がかかるならメモ化すること *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    d.(s) <- Weight.zero;
    for i = 1 to n - 1 do
      es.fold (fun (u, v, c) () ->
        let open Weight in
        (* c は u から v への辺の重さ *)
        (* d.(u) + c < d.(v) *)
        if 0 < Weight.compare d.(v) (d.(u) + c) then
          d.(v) <- d.(u) + c) ()
    done;
    (* 手動ループアンローリング *)
    for i = n to 2 * n do
      es.fold (fun (u, v, c) () ->
        let open Weight in
        if 0 < Weight.compare d.(v) (d.(u) + c) then
          (* n 回目以降に変更が起こった場合，v までの経路に負閉路が含まれている *)
          (d.(v) <- d.(u) + c; neg.(v) <- true)) ()
    done;
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end

module G = WeightedDirectedGraph (struct
  type t = int
  let inf = -123456789012345678
  let zero = 0
  let neg_inf = 123456789012345678
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abcs } 0 (n - 1) in
  if 123456789012345678 <= d
  then print_endline "inf"
  else Printf.printf "%d\n" d


Measured memory_bytes: 2944
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans += --a;
    }
    cout << ans << endl;
}

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

using vi = vector<int>;
using ll = long long;
using ld = long double;

#define rep(i,a,b) for(auto i = (a); i < (b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(a) begin(a),end(a)
#define sz(a) (int)size(a)
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 1000000007;
const int inv2 = 500000004;
auto add(auto a, auto b){return ((ll) a + b) % MOD;}
auto sub(auto a, auto b){return ((ll) a - b + MOD) % MOD;}
auto mult(auto a, auto b){return (ll) a * b % MOD;}
auto sum(auto a, auto b) { // inclusive
  auto gap = (b - a + 1);
  auto res = add(mult(gap, a), mult(mult(gap, gap - 1), inv2));
  return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    ++n; // so we can work on range [1...n]
    auto res = 0LL;
    rep(taken, k, n + 1) {
      auto lo = sum(1, 1 + taken - 1);
      auto hi = sum(n - taken + 1, n);
      auto delta = add(sub(hi, lo), 1);
      //cout << lo << " " << hi << endl;
      //cout << delta << '\n';
      res = add(res, delta);
    }
    cout << res << '\n';
        
    
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> Queue;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        Queue.push_back(x);
    }
    sort(Queue.begin(), Queue.end(), greater<int>());
    int alice = 0, bob = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 0)
            bob += Queue[i-1];
        else alice += Queue[i-1];
    }
    printf("%d\n", (alice - bob));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    string s;
    intf b,g;
    cin >>s;

    rep(i,s.size()){
        if(s[i]=='A'){
            b = i;
            break;
        }
    }

    for(int j=s.size()-1;j>-1;j--){
        if(s[j]=='Z'){
            g = j;
            break;
        }
    }

    cout << g - b +1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    string s,t ;
    cin >> s >> t ;

    int ans = t.size() ;
    for(int i=0;i<=(s.size()-t.size());++i){
        int diff = 0 ;
        for(int j=0;j<t.size();++j){
            if(t[j]!=s[i+j]){
                diff++ ;
            }
        }
        ans = min(ans,diff) ;
    }

    cout << ans << endl ;
    
    return 0 ;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
int N; cin >>N;
  vector<int> h(N);
  for(int i = 0; i < N; i++){ cin >> h[i];}
  int res = h[0];
  
  for(int i = 1; i < N; i++){
    if( h[i] > h[i-1]){ res += h[i]- h[i-1];}
  }
  
  cout << res << endl; return 0;}
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int n;

int countBingo(vector<vector<bool>> &fie,int y,int x){
	if(n==1)return 1;
	
	int c=0;
	
	bool f=true;
	rep(i,n) if(fie[y][i]==false)f=false;
	if(f)c++;
	
	f=true;
	rep(i,n) if(fie[i][x]==false)f=false;
	if(f)c++;
	
	
	if(x==y){
		f=true;
		rep(i,n) if(fie[i][i]==false)f=false;
		if(f)c++;
	}
	if(y+x == n-1){
		f=true;
		rep(i,n) if(fie[n-i-1][i]==false)f=false;
		if(f)c++;
	}
	
	return c;
}

int main(){
	int u,v,m;
	cin>>n>>u>>v>>m;
	
	
	int usac=0,nekoc=0;
	vector<vector<bool>> usa(n,vector<bool>(n,false)),neko(n,vector<bool>(n,false));
	map<int,pii> usamp,nekomp;
	
	rep(i,n)rep(j,n){
		int a;
		cin>>a;
		usamp[a] = pii(i,j);
	}
	rep(i,n)rep(j,n){
		int a;
		cin>>a;
		nekomp[a] = pii(i,j);
	}
	
	bool f=false;
	rep(i,m){
		int num;
		cin>>num;
		
		
		if(f)continue;
		if(usamp.count(num)!=0){
			pii p = usamp[num];
			usa[p.first][p.second] = true;
			usac += countBingo(usa,p.first,p.second);
		}
		
		if(nekomp.count(num)!=0){
			pii p = nekomp[num];
			neko[p.first][p.second] = true;
			nekoc += countBingo(neko,p.first,p.second);
		}
		
		if(usac>=u&&nekoc>=v){
			cout<<"DRAW"<<endl;
			f=true;
		}else if(usac>=u){
			cout<<"USAGI"<<endl;
			f=true;
		}else if(nekoc>=v){
			cout<<"NEKO"<<endl;
			f=true;
		}
	}
//	cout<<usac<<" "<<nekoc<<endl;
	if(f==false)cout<<"DRAW"<<endl;
}

Measured memory_bytes: 21152
n,m=map(int,input().split())
H=list(map(int,input().split()))

R=[1]*n

for i in range(m):
	a,b=map(int,input().split())
	p=H[a-1]
	q=H[b-1]
	if p==q:
		R[a-1]=0
		R[b-1]=0
	elif p>q:
		R[b-1]=0
	else:
		R[a-1]=0

print(sum(R))

Measured memory_bytes: 20032
r,c=map(int,input().split())
l=[]
for i in range(r):
    l.append([int(x) for x in input().split()])
    l[i].append(sum(l[i]))
l.append([0 for x in range(c+1)])
for m in range(r):
    for n in range(c+1):
        l[-1][n]+=l[m][n]
for u in l:
    print(" ".join(map(str,u)))


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

int N, A[500][500], r[500][500];

void it(int i, int j, int v) {
    if (v >= r[i][j]) return;
    if (v < 0) v = r[i][j];
    r[i][j] = v;
    v += A[i][j];
    if (i) it(i - 1, j, v);
    if (j) it(i, j - 1, v);
    if (i < N - 1) it(i + 1, j, v);
    if (j < N - 1) it(i, j + 1, v);
}

int main() {
    int t = 0, x, i, j;
    scanf("%d", &N);
    for (i = 0; i < N; ++i) for (j = 0; j < N; ++j) A[i][j] = 1, r[i][j] = min(min(i, N - i - 1), min(j, N - j - 1));
    for (i = 0; i < N * N; ++i) {
        scanf("%d", &x);
        --x;
        t += r[x / N][x % N];
        A[x / N][x % N] = 0;
        it(x / N, x % N, -1);
    }
    printf("%d", t);
    return 0;
}


Measured memory_bytes: 28324
let gr = "GREATER"
let le = "LESS"
let eq = "EQUAL"

let f a b =
  let len = String.length a in
  let rec g i =
    if i >= len then eq
    else
      let ca = Char.code a.[i] and cb = Char.code b.[i] in
      if ca > cb then gr else if cb > ca then le
      else g (succ i)
  in
  g 0

let () =
  let a = read_line () and b = read_line () in
  let lena = String.length a and lenb = String.length b in
  (if lena > lenb then gr else if lenb > lena then le
   else f a b)
  |> print_endline

Measured memory_bytes: 384