akhauriyash/Code-Regression huggingface dataset:
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt","r",stdin);
 //    freopen("output.txt","w",stdout);
 //    #endif
    
    
    int n=II();
    rep(i,14) {
        rep(j,25) {
            if (4 * i + 7 * j == n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
	
	return 0;
}



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

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define rpt(i,x) for (int i = 0; i < x; i++)
#define fti(i,f,t) for (int i = f; i <= t; i++)
#define fte(i,f,t) for (int i = f; i < t; i++)
#define rptws(i,x,s) for (int i = 0; i < x; i += s)
#define llrpt(i,x) for (long long i = 0; i < x; i++)
#define llfti(i,f,t) for (long long i = f; i <= t; i++)
#define llfte(i,f,t) for (long long i = f; i < t; i++)


int main () {
    string s1,s2;

    getline(cin, s1);
    getline(cin, s2);

    int rst = 0;
    rpt (i, s1.size()) {
        if (s1[i] != s2[i]) rst++;
    }

    cout<<rst;
    return 0;
}

Measured memory_bytes: 3924
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  ll N, M;
  cin >> N >> M;

  ll ans = 0;

  ans += min(N, M/2);
  N -= ans;
  M -= ans * 2;

  ans += M / 4;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (char a = '0'; a <= '9'; a++) {
    int i = S.find(a);
    if (i == string::npos) continue;
    for (int b = '0'; b <= '9'; b++) {
      int j = S.find(b, i + 1);
      if (j == string::npos) continue;
      for (int c = '0'; c <= '9'; c++) {
        int k = S.find(c, j + 1);
        if (k != string::npos) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
} 
 
int s,w;
int main()
{ init();
    
 cin >>s >>w;
 if(s>w) cout<<"safe"<<endl;
 if(w>=s) cout<<"unsafe"<<endl;

}

 
 

Measured memory_bytes: 3612
#include<stdio.h>

int main()
{
  int S,h,m,s;
  scanf("%d",&S);
  h = S/3600;
  m = (S - (h*3600) ) / 60;
  s = S % 60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}



Measured memory_bytes: 2088
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		int a=0,b=0,c=0;
		for(int i=0;i<s.Length;i++){
			if(s[i]=='a'){a++;}
			else if(s[i]=='b'){b++;}
			else{c++;}
		}
		if(Math.Abs(a-b)<2&&Math.Abs(a-c)<2&&Math.Abs(c-b)<2){Console.WriteLine("YES");}
		else{Console.WriteLine("NO"); }
	}
}

Measured memory_bytes: 11232
#include <bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define all(v) (v).begin() , (v).end()
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef long long   ll;

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

bool vis[10];

int main()
{
    int n , k;
    cin>> n >> k;
    for(int i=0;i<k;++i){
        int num;
        cin>>num;
        vis[num] = 1;
    }
    for(int i=n;true;++i){
        int tmp = i;
        bool valid = true;
        while(tmp){
            if(vis[tmp%10]){
                valid = false;
                break;
            }
            tmp /= 10;
        }
        if(valid){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class  Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder aans = new StringBuilder("");
        StringBuilder bans = new StringBuilder("");
        for(int i=0; i<a; i++){
            aans.append(b+"");
        }
        for(int i=0; i<b; i++){
            bans.append(a+"");
        }
        if(aans.toString().compareTo(bans.toString()) >= 0)
            System.out.println(bans);
        else
            System.out.println(aans);
    }
}

Measured memory_bytes: 22228
#include <stdio.h>
int main(){
    int H,W;
    for(;;){
        scanf("%d %d", &H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if((i % 2 == 0 && j % 2 == 1) || (j % 2 == 0 && i % 2 == 1)){
                    printf(".");
                } else {
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
  int K,N;
  cin >> N>> K;
  vector <int> price(N);
  for (int i=0; i<N; i++) {
    cin >> price.at(i);
  }
  sort (price.begin(),price.end());
  
 int sum=0;
  for(int i=0;i<K;i++) {
    sum+=price.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <map>

using namespace std;

int main() {
	string list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	map<char, int> m;
	for (int i = 0; i < list.size(); ++i) m[list[i]] = i;

	int n;
	while ( cin >> n, n ) {
		int key[100];
		for (int i = 0; i < n; ++i) cin >> key[i];
		string str; cin >> str;
		string ans = "";
		for (int i = 0; i < str.size(); ++i) {
			ans += list[(m[str[i]] - key[i % n] + list.size()) % list.size()];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1216
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define Di 3.1415926
#include<math.h>
#define INF 0x3f3f3f3f
using namespace std;
ll  gcd(ll a,ll b)
{
    return a%b? gcd(b,a%b):b;
}

int main()
{


   int n,sum=0;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       sum+=i;

   }

    cout<<sum<<endl;



 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REPF(i, a, n) for (int i = a; i < (n); i++)
#define REP(i, n) REPF(i, 0, n)
#define FORE(x, s) for (auto& x : s)
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
template<class T> bool chmax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    int N;
    cin >> N;
    vector<string> w(N);
    REP(i, N) cin >> w[i];
    vector<vector<int>> idx(26);
    vector<int> num(N);
    REP(i, N) {
        int ch = w[i][0] - 'a';
        num[i] = SZ(idx[ch]);
        idx[ch].push_back(i);
    }

    vector<int> dp(N + 1);
    int mx = 0;
    REP(i, N) {
        int ch = w[i][0] - 'a';
        chmax(mx, dp[i]);
        dp[i] = mx;
        // cerr << "i = " << i << ", dp[i] = " << dp[i] << endl;
        if (num[i] + 1 < SZ(idx[ch])) {
            chmax(dp[idx[ch][num[i] + 1]], dp[i] + (idx[ch][num[i] + 1] - idx[ch][num[i]]));
        }
    }
    cout << N - mx << endl;
    return 0;
}


Measured memory_bytes: 11992
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;




int main()
{
		
	fast;
	
	ll n,k;
	cin>>n>>k;
	ll p[n];
	ll i;
	rep(i,n)
	{
		cin>>p[i];
	}
	sort(p,p+n);
	ll ans=0;
	for(i=0;i<k;i++)
	{
		ans+=p[i];
	}
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll m=max(a*c,b*d);
    m=max(m,a*d);
    m=max(m,b*c);
    cout << m << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void del(map<ll,ll> &mp, ll val){
  mp[val]--;
  if(mp[val] == 0){ mp.erase(val);}
}

int main(){
  ll N; cin >> N; map<ll,ll> mp;
  ll ans = 0;
  vector<ll> A(N); 
  for(ll i = 0; i < N; i++){ 
    cin >> A[i]; mp[-A[i]]++;}
  
  for(ll i = 0; i < N && !mp.empty(); i++){
    ll a = -mp.begin()->first;
    del(mp,-a);
    ll p = 1;
    while( p <= a){ p *= 2;}
    ll rem = a-p;
    if(mp.count(rem)){
      ans++;
      del(mp,rem);}
  }
  
  cout << ans << endl;
  return 0;}
      

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,B,pos=0,neg=0;cin>>N;ll A[N];
  REP(i,N)cin>>A[i];
  REP(i,N){
    cin>>B;A[i]-=B;
    if(A[i]>0)pos+=A[i];
    else neg+=-A[i]/2;
  }
  if(pos<=neg)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi v(n);
	rep(i, n) cin >> v[i];
	sort(all(v));
	int ans = 0;
	for(int i = 1, j = 0; i <= 100; i++){
		while(j < n && v[j] < i) j++;
		if(n - j >= i) ans = max(ans, i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3216
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

typedef long long ll;


int main(){
	int N;
	string s;
	cin >> N >> s;
	
	string comtemp; 

	int length = s.length();
	rep(i,length){
		int difference  = s[i] - 'A';
		int move = (difference + N)%26;
		comtemp.push_back((char)('A' + move));
	}

	cout << comtemp << endl;


	// int ans = 'B' - 'A';
	// int ansa = 'C' - 'A';
	// int ansb = 'D' - 'A';

	// cout << ans << endl;
	// cout << ansa << endl;
	// cout << ansb << endl;
}


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

int dp[101][4][4][4];
int MOD = 1000000007;

int main() {
    int n;
    cin >> n;

    dp[0][3][3][3] = 1;

    for(int len = 0; len < n; len++)
    {
        for(int c1 = 0; c1 < 4; c1++)
        {
            for(int c2 = 0; c2 < 4; c2++)
            {
                for(int c3 = 0; c3 < 4; c3++)
                {
                    if (dp[len][c1][c2][c3] == 0) continue;
                    for(int a = 0; a < 4; a++)
                    {
                        if (a == 1 && c1 == 2 && c2 == 0) continue;
                        if (a == 1 && c1 == 0 && c2 == 2) continue;
                        if (a == 2 && c1 == 1 && c2 == 0) continue;
                        if (a == 1 && c1 == 2 && c3 == 0) continue;
                        if (a == 1 && c2 == 2 && c3 == 0) continue;

                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= MOD;
                    }
                    
                }
                
            }
            
        }
        
    }

    int ans = 0;
    
    for(int c1 = 0; c1 < 4; c1++)
    {
        for(int c2 = 0; c2 < 4; c2++)
        {
            for(int c3 = 0; c3 < 4; c3++)
            {
                ans += dp[n][c1][c2][c3];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

def solve():
    n = int(stdin.readline())
    A = [int(stdin.readline()) for i in range(n)]

    inf = 10**9 + 1
    dp = [inf] * n

    for a in A:
        j = nibutan(dp, a)
        dp[j] = a

    for i, v in enumerate(dp):
        if v == inf:
            print(i)
            return

    print(n)

def nibutan(dp, a):
    btm = -1
    top = len(dp)

    while top - btm > 1:
        mid = (top + btm) // 2
        if dp[mid] >= a:
            top = mid
        else:
            btm = mid

    assert 0 <= top < len(dp)
    return top

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 12576
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,s,t) for(int i=s ; i<t ; i++)
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  int n;  cin >> n;
  vector<int> v(n);
  rep(i,0,n){
    cin >> v[i];
    v[i]--;
  }
  int cnt = 0;
  int ans = 0;
  rep(i,0,n-1){
    if(v[i]==i){
      swap(v[i],v[i+1]);
      ans++;
    }
  }
  if(v[n-1]==n-1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string s, t;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s >> t;
	vector<string> v;
	FOR(i, s.size()-t.size()+1) {
		if (s[i]==t[0] || s[i]=='?') {
			bool ok = true;
			FOR(j, t.size()) {
				if (s[i+j]!='?' && s[i+j]!=t[j]) ok = false;
			}
			if (ok) {
				string _s = s;
				FOR(j, t.size()) _s[i+j] = t[j];
				FOR(j, _s.size()) if (_s[j]=='?') _s[j] = 'a';
				v.push_back(_s);
			}
		}
	}
	if (v.empty()) cout << "UNRESTORABLE" << endl;
	else {
		sort(ALL(v));
		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
mass = np.array([(0, 0) for _ in range(num + 1)])
mp = np.zeros(num+1)
for i in range(1, h+1):
    for j, a in enumerate(map(int, input().split())):
        mass[a] = [i, j+1]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(int(mp[r]-mp[l]))


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

signed main(){

    
    string str , ans;
    cin >> str;
    
    if(str == "Cloudy"){
        ans  = "Rainy";
    }else if (str == "Rainy"){
        ans = "Sunny";
    }else if(str == "Sunny"){
        ans = "Cloudy";
    }
    cout << ans <<endl;
}


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

using namespace std;

string input;
int pos;

int fact();
int term();
int expr();

int fact() {
	int result = 0;
	if (input[pos] == '(') {
		pos++;
		result = expr();
		pos++;
	} else {
		while (isdigit(input[pos])) {
			result = result * 10 + input[pos] - '0';
			pos++;
		}
	}
//	cout << "fact: " << result << endl;
	return result;
}

int term() {
	int result = fact();
	while (input[pos] == '*' || input[pos] == '/') {
		if (input[pos] == '*') {
			pos++;
			result *= fact();
		} else {
			pos++;
			result /= fact();
		}
	}
//	cout << "term: " << result << endl;
	return result;
}

int expr() {
	int result = term();
	while (input[pos] == '+' || input[pos] == '-') {
		if (input[pos] == '+') {
			pos++;
			result += term();
		} else {
			pos++;
			result -= term();
		}
	}
//	cout << "expr: " << result << endl;
	return result;
}

int main() {
	int n; cin >> n;
	while (n--) {
		cin >> input;
		pos = 0;
		cout << expr() << endl;
	}
	return 0;
}

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

int main(){
    double a,b;
    cin>>a>>b;
    if( (a+b)/2 == (int)((a+b)/2) ){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<(int)((a+b)/2+1)<<endl;
    }
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (((bit >> i) & 1) > 0)

typedef long long LL;
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a, Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}    // C++14
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };


using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    map<LL, LL> m;
    FOR(i, 0, N) {
        LL A;
        cin >> A;
        m[A]++;
    }

    FOR(i, 0, M) {
        LL B, C;
        cin >> B >> C;
        m[C] += B;
    }

    LL ans = 0;
    LL now = 0;
    auto i = m.rbegin();
    for (; i != m.rend(); ++i) {
        LL C = i->first;
        LL num = i->second;

        LL r = min(N - now, num);
        ans += C * r;
        now += r;
    }
    print(ans);

    return 0;


    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    llong n, k, s;
    cin >> n >> k >> s;

    if (k > 0) cout << s;
    REP(i, k - 1){
        cout << " " << s;
    }
    for (int i = 0; i < n - k; i++){
        if (s != 1e9){
            if (k == 0 && i == 0) cout << s + 1;
            else cout << " " << s + 1;
        }else{
            if (k == 0 && i == 0) cout << s - 1;
            else cout << " " << s - 1;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
N = int(input())
judge = []
for s in range(N):
    judge.append(input())

print("AC x " + str(judge.count("AC")))
print("WA x " + str(judge.count("WA")))
print("TLE x " + str(judge.count("TLE")))
print("RE x " + str(judge.count("RE")))

Measured memory_bytes: 16276
#include<stdio.h>


int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int count = 0;
    for(int i=a;i<=b;i++){
        if(c % i == 0)
            count++;
    }
    printf("%d\n",count);
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    long n;
    scanf("%ld", &n);
    long* a = calloc(n + 1, sizeof(long));
    for (long i = 0; i < n + 1; i++) {
        scanf("%ld", &a[i]);
    }
    long* b = calloc(n, sizeof(long));
    for (long i = 0; i < n; i++) {
        scanf("%ld", &b[i]);
    }

    long count = 0;

    for (long i = n - 1; i >= 0; i--) {
        if (a[i + 1] - b[i] >= 0) {
            a[i + 1] -= b[i];
            count += b[i];
            b[i] = 0;
        } else {
            count += a[i + 1];
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }

        if (a[i] - b[i] >= 0) {
            a[i] -= b[i];
            count += b[i];
            b[i] = 0;
        } else {
            count += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
    }

    printf("%ld\n", count);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> m;
  priority_queue<ll> pq;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(m[a.at(i)]==1){
        pq.push(a.at(i));
        m[a.at(i)]=0;
    }
    else
    m[a.at(i)]=1;
  }
  ll max=0;
  ll next=0;
  if(pq.size()==0 || pq.size()==1){
    cout << 0 << endl;
    return 0;
  }
  max=pq.top();
  pq.pop();
  next=pq.top();
  cout << max*next << endl;
}

Measured memory_bytes: 10320
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[100002];
    ll x = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        x ^= a[i];
    }
    ll r = 0;
    for(int j = 0; j < 60; j++){
        if((x >> j) & 1){
            r += (1ll << j);
            for(int i = 0; i < n; i++) a[i] &= (1ll << 60) - 1 - (1ll << j);
        }
    }
    ll b[100002] {0};
    for(int i = 0; i < n; i++){
        for(int j = 59; j >= 0; j--) if((a[i] >> j) & 1) a[i] ^= b[j];
        for(int j = 59; j >= 0; j--)
            if((a[i] >> j) & 1){
                b[j] = a[i];
                break;
            }
    }
    for(int j = 0; j < 60; j++){
        for(int k = j + 1; k < 60; k++) if((b[k] >> j) & 1) b[k] ^= b[j];
    }
    ll s = 0;
    for(int j = 0; j < 60; j++) s ^= b[j];
    cout << r + s * 2 << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int a, p;
  cin >> a >> p;
  int total = a * 3 + p;
  cout << total / 2 << endl;
}


Measured memory_bytes: 256
from queue import deque
H,W = map(int,input().split())
CH,CW = map(int,input().split())
DH,DW = map(int,input().split())
DH,DW = DH-1,DW-1
S=[]
for i in range(H):
    S.append(list(map(lambda x:0 if x=='.' else -1, input().strip())))

def walk(h,w,n):
    r = []
    q = deque([(h,w)])
    while q:
        x = q.pop()
        r.append(x)
        h,w = x
        if h == DH and w == DW:
            print(n-1)
            exit()
        if h > 0 and S[h-1][w] == 0:
            S[h-1][w] = n
            q.append((h-1,w))
        if h < H-1 and S[h+1][w] == 0:
            S[h+1][w] = n
            q.append((h+1,w))
        if w > 0 and S[h][w-1] == 0:
            S[h][w-1] = n
            q.append((h,w-1))
        if w < W-1 and S[h][w+1] == 0:
            S[h][w+1] = n
            q.append((h,w+1))
    return r

warp = 1
q = deque([(CH-1,CW-1)])
while len(q) > 0:
    n = []
    while len(q) > 0:
        h,w = q.pop()
        n+=walk(h,w,warp)
    warp += 1
    if len(n) == 0:
        break
    for h,w in n:
        for ah in range(max(0,h-2),min(H,h+3)):
            for aw in range(max(0,w-2),min(W,w+3)):
                if ah == DH and aw == DW:
                    print(warp-1)
                    exit()
                if S[ah][aw] == 0:
                    S[ah][aw] = warp
                    q.append((ah,aw))

print(-1)


Measured memory_bytes: 93196
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0
using namespace std;

int a, b, c, d;

int Go() {

  scanf("%d %d %d %d", &a, &b, &c, &d);

  int is = 1;

  while(true){
    if(is){
      c -= b;
      if(c <= 0) break;
    }else{
      a -= d;
      if(a <= 0) break;
    }
    is ^= 1;
  }

  puts(is ? "Yes" : "No");

  return 0;
}


int main() {


  int t;
  if (TESTCASES) scanf("%d", &t);
  else           t = 1;

  while (t--) Go();
}

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

using namespace std;

int main(void)
{
        string c1;
        string c2;
        cin >> c1 >> c2;

        if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0])
                cout << "YES" << endl;
        else cout << "NO" << endl;

        return 0;
}

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

int main() {
	int N; cin>>N;
	string ret;
	while(N) {
		if(N%2) N--, ret+='1';
		else ret+='0';
		N/=-2;
	}
	reverse(ret.begin(),ret.end());
	cout<<(ret.empty()?"0":ret)<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
alphabets = ['A','B','C','D','E',
            'F','G','H','I','J',
            'K','L','M','N','O',
            'P','Q','R','S','T',
            'U','V','W','X','Y','Z']
out = ''

for i in range(len(s)):
  for j in range(26):
    if s[i] == alphabets[j]:
      out += alphabets[(j+n)%26]
      break

print(out)

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

int main() {
  while (1) {
    int N;
    cin >> N;
    if (N == 0) break;

    vector<int> table(86450, 0);
    for (int i = 0; i < N; i++) {
      string D;
      string A;
      cin >> D >> A;

      int DH = stoi(D.substr(0, 2)) * 3600;
      int DM = stoi(D.substr(3, 2)) * 60;
      int DS = stoi(D.substr(6, 2));
      int d = DH + DM + DS;

      int AH = stoi(A.substr(0, 2)) * 3600;
      int AM = stoi(A.substr(3, 2)) * 60;
      int AS = stoi(A.substr(6, 2));
      int a = AH + AM + AS;
      table.at(d)++;
      table.at(a)--;
    }

    for (int i = 0; i <= 86400; i++) {
      if (0 < i) table[i] += table[i - 1];
    }

    int M = 0;
    for (int i = 0; i <= 86400; i++) {
      if (M < table[i]) M = table[i];
    }

    cout << M << endl;
  }
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	string ss[] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
	if(s=="SUN"){
		cout << 7 << "\n";
		return 0;
	}
	for(int i=0;i<7;i++){
		if(s==ss[i]){
			cout << (6-i) << "\n";
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Stack;
import java.util.Scanner;
import java.util.Queue;

/**
 * @author yoshikyoto
 */



class Main{
	static final boolean DEBUG = false;
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String args[]) throws Exception{
		String line;
		while((line = readLine()) != null){
			int[] n = parseInt(line.split(" "));
			p(digit(n[0] + n[1]));
		}
	}

	public static String readLine() throws IOException{return br.readLine();}
	public static int readInt(){return sc.nextInt();}
	public static void pa(Object[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(int[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(double[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(boolean[] arr){System.out.println(Arrays.toString(arr));}
	public static void p(Object o){System.out.println(o.toString());}
	public static void d(Object o){if(DEBUG)System.out.println(o.toString());}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static int parseInt(Object o){return Integer.parseInt(o.toString());}
	public static int digit(int n){return String.valueOf(n).length();}
}

class MyHashMap<E> extends HashMap<E, Integer>{
	ArrayList<E> keyArray = new ArrayList<E>();
	public void add(E key){add(key, 1);}
	public void add(E key, Integer value){
		if(containsKey(key)){
			value += get(key);
		}else{
			keyArray.add(key);
		}
		put(key, value);
	}
}

Measured memory_bytes: 17268
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<long long, long long>
// #define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define f first
#define s second
#define sd(x) scanf("%d", &x)
#define sd2(x, y) scanf("%d%d", &x, &y)
#define sd3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sdl(x) scanf("%lld", &x)
#define sdl2(x, y) scanf("%lld%lld", &x, &y)
#define sdl3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pb(x) push_back(x)
#define LET(x, a) __typeof(a) x(a)
#define foreach(it, v) for (LET(it, v.begin()); it != v.end(); it++)
#define Forp(i, s, e) for (ll i = s; i <= e; i++)
#define Forn(i, s, e) for (ll i = s; i >= e; i--)
#define modfix(a, mod) ((((a) % (mod)) + (mod)) % (mod))
#define mod_sum(a, b, mod) modfix(((a) + (b)), (mod))
#define mod_sub(a, b, mod) modfix(((a) - (b)), (mod))
#define mod_mul(a, b, mod) modfix(((ll)(a) * (ll)(b)), (mod))

#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define __                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

#define tr(...)                                       \
    cout << __FUNCTION__ << ' ' << __LINE__ << " = "; \
    trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

template <typename S, typename T>
ostream &operator<<(ostream &out, pair<S, T> const &p)
{
    out << p.f << " " << p.s;
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, vector<T> const &v)
{
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++)
        out << v[i] << ' ';
    if (l > 0)
        out << v[l - 1];
    return out;
}

template <typename T>
void trace(const char *name, T &&arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args>
void trace(const char *names, T &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    trace(comma + 1, args...);
}
// typedef long long int;
#define For(i,n) for(ll i = 0 ; i < n ; i++)
vll adj[100001];
const ll mod = 1e9+7;
ll c = 0;
ll dp[100001][2];
void dfs(ll s, ll p){
    for(auto &e : adj[s]){
        if(e != p) dfs(e,s),c++;
    }
    if(c == 0){
        dp[s][0] = 1;
        dp[s][1] = 1;
    }
    else{
        dp[s][0] = 1;
        dp[s][1] = 1;
        for(auto &e : adj[s]){
            if(e != p){
                dp[s][0] = (dp[s][0]*dp[e][1])%mod;
                dp[s][1] = dp[s][1]*(dp[e][0]+dp[e][1])%mod;
            }

        }
    }
    
}
int main()
{
    _ 
    ll n;
    cin >> n;
    for(ll i = 0 ; i < n-1 ; i++){
        ll u,v;
        cin >>u >> v;
        adj[u].pb(v);
        adj[v].pb(u);

    }
    dfs(1,0);
    cout << (dp[1][0] + dp[1][1])%mod << endl;

    return 0;
}




Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;




void Main(){
  ll N, M = 1000005, ans=0, Amax;

  cin >> N;

  VI A(N);

  rep(i, N){
    cin >> A[i];
  }
  sort(all(A));
  Amax = A[N-1];
  vector<int> x(Amax + 1, 1);

  for (auto p: A) {
    if(x[p] == 0) continue;
    if(x[p] == 2) {
      x[p] = 0;
      continue;
    }
    x[p] = 2;
    ll i = p*2;
    while(i <= Amax){
      x[i] = 0;
      i += p;
    }
  }

  for(auto p: A){
    if(x[p]) ans++;
  }

  cout << ans << endl;

}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,D;cin>>N>>D;
  int cnt=0;
  REP(i,0,INF){
    if(i*(2*D+1)>=N){
      print(i)
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const int MOD = 1e9+7;


inline void sieve()
{
	ll mx = 1e6 + 9;
	bool isPrime[mx];
	memset(isPrime , true , mx);
	isPrime[0] = isPrime[1] = false;
	for (ll i = 2; i * i < mx; ++i)
	{
		if(isPrime[i])
		{
			for(ll j = i*i; j < mx; j += i)
				isPrime[j] = false;
		}
	}
}



int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
#endif
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";



}


Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {
    public void main() {
        Scanner sc = new Scanner(System.in);

        String a = String.format("%101s", sc.nextLine());
        String b = String.format("%101s", sc.nextLine());

        int res = a.compareTo(b);

        if (res == 0) {
            println("EQUAL");
        } else if (res > 0) {
            println("GREATER");
        } else {
            println("LESS");
        }

        sc.close();
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        new Main().main();
    }
}


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

int w, z[1100][2] = {}, map[1100][1100] = {}, n, min_w = 20000000, max_v = 0;



int main(){
	int k = 1;
	while(cin >> w >> n){
		if (w == 0) break;
		min_w = 20000000;
		max_v = -1;
		for(int i = 1;i<=n;i++){
			char cmp;
			cin >> z[i][0] >> cmp >> z[i][1];
		}
		for(int i = 1;i<=n;i++){
			for(int j = 1;j<=w;j++){
				if (z[i][1] > j) {
					map[i][j] = map[i - 1][j];
					continue;
				}
				map[i][j] = max(map[i - 1][j], map[i - 1][j - z[i][1]] + z[i][0]);
			}
		}
		for(int i = w;i>0;i--){
			if (max_v <= map[n][i]) {
				max_v = map[n][i];
				min_w = i;
			}
		}
		cout << "Case " << k << ":" << endl
			<< max_v << endl
			<< min_w << endl;
		k++;
	}
	return 0;
}

Measured memory_bytes: 7304
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = sum(a)

count = [0] * 100000
for i in range(n):
    count[a[i] - 1] += 1
    
for i in range(q):
    o = list(map(int, input().split()))
    s += (o[1] - o[0]) * count[o[0] - 1]
    count[o[1] - 1] += count[o[0] - 1]
    count[o[0] - 1] = 0
    print(s)

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

int dp[22][100010];

int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    int l; scanf("%d",&l);
    rep(i,0,n)dp[0][i]=lower_bound(ALL(a),a[i]+l+1)-a.begin()-1;
    rep(i,0,20)rep(j,0,n)dp[i+1][j]=dp[i][dp[i][j]];
    int q,ans; scanf("%d",&q);
    rep(rot,0,q){
        int l,r; scanf("%d%d",&l,&r); l--; r--;
        if(l>r)swap(l,r);
        ans=1; rrep(i,19,-1)if(dp[i][l]<r)l=dp[i][l],ans+=1<<i; 
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for(int i=0; i<(n); i++)
    using ll = long long;
    using P = pair<int,int>;
    const int mod = 1000000007;
    ll fact[1000000];
    ll inv_fact[1000000];
    // a^n mod を計算する
    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main()
    {
        ll n,k;
        cin >> n >> k;
        fact[0] = 1;
        inv_fact[0] = 1;
        rep(i,n+3){
            if(i == 0)continue;
            fact[i] = fact[i-1]*i%mod;
        }
        inv_fact[n] = modpow(fact[n],mod-2,mod);
        for(int i = n;i >=1;--i)inv_fact[i-1] = inv_fact[i]*i%mod;
        ll ans = 0;
        k = min(k,n-1);
        rep(i,k+1){
            ans += (((fact[n]*inv_fact[i]%mod)*inv_fact[n-i]%mod)*((fact[n-1]*inv_fact[i]%mod)*inv_fact[n-1-i]%mod))%mod;
            ans %= mod;
        }
        cout << ans << endl;

        
        return 0;
    }


Measured memory_bytes: 5888
import collections

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

Dc = collections.Counter(D)
Tc = collections.Counter(T)

for Tkey,Tval in Tc.items():
    Dval = Dc[Tkey]
    if Dval < Tval:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 57268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

struct Segtree {
	int a[N_SIZE];
	int seg[N_SIZE * 2];
	int lazy[N_SIZE * 2];
	int gt;
	void init(int n) {
		gt = 1;
		while (n > gt)gt *= 2;
		REP(i, n)a[i] = (1LL << 31) - 1;
		REP(i, N_SIZE) {
			seg[i] = (1LL << 31) - 1;
			lazy[i] = NIL;
		}
		REP(i, n)seg[i + gt - 1] = a[i];
	}

	void lazy_evaluate(int k) {
		seg[k] = lazy[k];
		if (gt > k) {
			lazy[2 * k + 1] = lazy[k];
			lazy[2 * k + 2] = lazy[k];
		}
		lazy[k] = NIL;
	}

	//[a,b)
	void update(int a, int b, int x) { update(a, b, 0, 0, gt, x); }
	void update(int a, int b, int k, int l, int r, int x) {
		if (r <= a || b <= l) {
			if (lazy[k] != NIL)seg[k] = lazy[k];
			return;
		}
		if (a <= l&&r <= b) {
			lazy[k] = x;
			seg[k] = x;
		}
		else {
			if (lazy[k] != NIL)lazy_evaluate(k);
			update(a, b, 2 * k + 1, l, (l + r) / 2, x);
			update(a, b, 2 * k + 2, (l + r) / 2, r, x);
			if (gt > k)seg[k] = min(seg[2 * k + 1], seg[2 * k + 2]);
		}
	}

	//[a,b)??????
	ll query(int a, int b) { return query(a, b, 0, 0, gt); }
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return (1LL << 31) - 1;
		if (a <= l&&r <= b) {
			if (lazy[k] != NIL)seg[k] = lazy[k];
			return seg[k];
		}
		else {
			if (lazy[k] != NIL)lazy_evaluate(k);
			return min(query(a, b, 2 * k + 1, l, (l + r) / 2),
				query(a, b, 2 * k + 2, (l + r) / 2, r));
		}
	}

	void print() {
		REP(i, gt * 2)cout << "!" << i << " " << seg[i] << " " << lazy[i] << endl;
	}
};

int n, q;
Segtree tr;

int main() {
	cin >> n >> q;
	tr.init(n);
	REP(i, q) {
		bool f;
		int a, b, c;
		cin >> f;
		if (!f) {
			cin >> a >> b >> c;
			tr.update(a, b + 1, c);
		}
		else {
			cin >> a >> b;
			cout << tr.query(a, b + 1) << endl;
		}
		//tr.print();
	}
}

Measured memory_bytes: 11708
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > x(10,std::vector<int>(10,0));
	for(int i=1;i<=n;i++) {
		int a = i%10;
		int l=i;
		int b=a;
		while(l/10>0) b=(l/=10)%10;
		debug(i,a,b);
		x[a][b]++;
	}
	debug(x);
	int count = 0;
	for(int i=1;i<10;i++) 
		for(int j=1;j<10;j++) 
			count+=x[i][j]*x[j][i];
	print(count);

	return 0;
}


Measured memory_bytes: 256