akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  deque<int> que;
  for(int i = 0; i < n; i++){
    string  order;
    int value;
    cin >> order;
    if(order == "deleteFirst" || order == "deleteLast"){
      if(order == "deleteFirst") que.pop_front();
      else  que.pop_back();
      continue;
    }
    cin >> value;
    if(order == "insert"){
      que.push_front(value);
    }else{
      for(auto itr = que.begin(); itr != que.end(); ++itr){
        if(*itr == value){
          que.erase(itr);
          break;
        }
      }
    }
  }

  for(auto itr = que.begin(); itr < que.end() - 1; itr++){
    cout << *itr << " ";
  } cout << que.back() << endl;
  return 0;
}

Measured memory_bytes: 7140
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>

typedef long long ll;

using namespace std;

int main(){
  int n,m;
  ll ans=0;
  int p[100000],a[100000],b[100000],c[100000],s[100001]={0};

  scanf("%d%d",&n,&m);

  for(int i=0;i<m;i++){
    scanf("%d",&p[i]);
    p[i]--;
  }

  for(int i=0;i<n-1;i++)
    scanf("%d%d%d",&a[i],&b[i],&c[i]);

  for(int i=0;i<m-1;i++){
    s[min(p[i],p[i+1])]++;
    s[max(p[i],p[i+1])]--;
  }

  for(int i=0;i<n-1;i++){
    s[i+1]+=s[i];
  }

  for(int i=0;i<n-1;i++){
    if((ll)a[i]*s[i]<(ll)b[i]*s[i]+c[i])
      ans+=(ll)a[i]*s[i];
    else
      ans+=(ll)b[i]*s[i]+c[i];
  }

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

  return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct UnionFind{
    vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }
};

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    //b - a + 2a - 2b
    if(abs(b - a) > 1000000000000000000){
        cout << "unfair" << endl;
    }else{
        if(k % 2 == 1){
            cout << b - a << endl;
        }else{
            cout << a - b << endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char  S[3],T[3];
    int result=0;
    scanf("%s",&S);
    scanf("%s",&T);
    for(int i=0;i<3;i++){
        if(S[i]==T[i]){
            result++;
        }
    }
    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      cout << '9';
    else
      cout << '1';
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <algorithm>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100000];

int solve() {
	int eor = 0;
	inc(i, n) { eor ^= a[i]; }
	
	decID(i, 1, 30) {
		if(eor & (1 << i)) { eor ^= (1 << i) - 1; }
	}
	
	int ans = 0;
	inc(i, 30) { if(eor & (1 << i)) {
		bool f2 = false;
		inc(j, n) {
			if(a[j] % (1 << i) == 0 && a[j] % (1 << (i + 1)) != 0) { f2 = true; break; }
		}
		if(f2) { ans++; } else { return -1; }
	} }
	
	return ans;
}

int main() {
	scanf("%d", &n);
	inc(i, n) { scanf("%d", &a[i]); }
	
	printf("%d\n", solve());
	
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	int n, i, a_i;
	char n_s[7];

	fgets(n_s, sizeof(n_s), stdin);
	n = atoi(n_s);

	int min = 1000000;
	int max = -1000000;
	long long int sum = 0;

	int sl = 9 * 10000;
	char str[sl], *ch;

	fgets(str, sizeof(str), stdin);

	ch = strtok(str, " \n");

	for (i = 0; i < n; i++) {
		if (ch == NULL) {
			break;
		} else {
			a_i = atoi(ch);
		}
		if (a_i < min) min = atoi(ch);
		if (a_i > max) max = atoi(ch);
		sum += a_i;
		ch = strtok(NULL, " \n");
	}

	printf("%d %d %lld\n", min, max , sum);

	return 0;
}

Measured memory_bytes: 616
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), d = sc.nextInt(),x = sc.nextInt();
        int[] a = new int[n];
        x += n;
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i =0;i<n;i++){
            for(int j=1;j<=d;j++){
                if(j*a[i]+1<=d){
                    x ++;
                } else {
                    break;
                }
            }
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include <utility>
#include<vector>
#include <iostream>
#include<queue>
 
using namespace std;
 
const int N = 2e5 + 5;
 
typedef vector<int>::iterator vi;
typedef pair<int, int> pairii;
vector<int> G[N];
queue<int> que;
 
int lev[N];
int vis[N];
 
pairii bfs(int s)
{
    que.push(s);
    memset(vis, 0, sizeof(vis));
    lev[s] = 1;
    int maxlev = 1;
    int v = s;
    while(!que.empty())
    {
        int cur = que.front();
        if(lev[cur] > maxlev) maxlev = lev[cur], v = cur;
        que.pop();
        vis[cur] = 1;
        for(vi i = G[cur].begin(); i != G[cur].end(); i++)
        {
            if(!vis[*i])
            {
                lev[*i] = lev[cur] + 1;
                que.push(*i);
            }
        }
    }
    pairii ret = make_pair(v, maxlev);
    return ret;
}
 
 
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        
        for(int i = 1; i <= n; i++) G[i].clear();
        for(int i = 1; i < n; i++)
        {
            int a, b;
            scanf("%d%d", &a, &b);
            G[a].push_back(b);
            G[b].push_back(a);
        }
        pairii t1 = bfs(1);
        pairii t2 = bfs(t1.first);

        int diameter = t2.second;
        diameter --;
        // printf("diameter: %d\n", diameter);
        if( (diameter % 3) != 1) printf("First\n");
        else printf("Second\n");
    }
 
    return 0;
 
}

Measured memory_bytes: 14324
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 100000000
#define eps (1e-12)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPointSS(Segment s1,Segment s2){
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return (s1.p1+(s1.p2-s1.p1)*t);
}

int main()
{
  int n,a,b,c,d;
  vector<Segment> S;

  while(1){
    cin>>n;
    if(n==0)break;
    S.clear();
    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>d;
      Segment s(Point(a,b),Point(c,d));
      S.push_back(s);
    }

    int ans=2;
    for(int i=1;i<n;i++){
      int sum=0;
      set<Point> sp; 
      for(int j=i-1;j>=0;j--){
	if(intersect(S[i],S[j])){
	  Point p=getCrossPointSS(S[i],S[j]);
	  if(equals(p.x,100) || equals(p.x,-100))continue;
	  if(equals(p.y,100) || equals(p.y,-100))continue;
	  if(sp.find(p)==sp.end()){
	    sp.insert(p);
	    sum++;
	  }
	}
      }
      ans+=(sum+1);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    int a;
    int count = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        while(1){
            if(a % 2 == 0){
                a /= 2;
                count++;
            }else{
                break;
            }
        }
    }
    cout << count;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define F first
#define S second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;

void solve()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==b)
    {
        cout<<0<<endl;
        return;
    }
    ll d=abs(a-b)-1;
    if(d&(ll)1)
    {
        cout<<d/2+1<<endl;
    }
    else
    {
        ll mi=min(a,b);
        ll ma=max(a,b);ll ans=0;
        if(n-ma<mi-1)
        {
            ans+=n-ma;
            mi+=n-ma;
            ma=n;
        }
        else
        {
            ans+=mi-1;
            ma-=(mi-1);
            mi=1;
        }
        d=ma-mi-1;
        if(d==0)
        cout<<ans+1<<endl;
        else
        {
            d++;
            cout<<ans+d/2+1<<endl;
        }
    }
}
int main()
{
    FASTIO;
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string N;
  cin >> N;
  ll cand1 = N[0] - '0';
  for (int i = 1; i < N.length(); i++) {
    cand1 += N[i] - '0';
  }
  ll cand2 = max(N[0] - '0' - 1, 0);
  for (int i = 1; i < N.length(); i++) {
    cand2 += 9;
  }
  cout << max(cand1, cand2) << endl;
  return 0;
}

Measured memory_bytes: 256
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add	 	accumulate
  #define ll 	 	long long int
  #define ff	 	first
  #define ss 	 	second
  #define pb 	 	push_back
  #define pob		pop_back
  #define pf 	 	push_front
  #define pof		pop_front
  #define mp 	 	make_pair
  #define vll 	 	vector<ll>
  #define lb 	 	lower_bound
  #define ub     		upper_bound
  #define pll 	 	pair<ll,ll>
  #define vpll   		vector<pll>
  #define all(v) 		v.begin(), v.end()
  #define llmax		numeric_limits<ll>::max()
  #define rep(i,k,n)    for(int i=k;i<n;i++)
  #define hs            ios_base::sync_with_stdio(false);cin.tie(NULL);
  template <class C> void setmin(C &a,C b){if(a>b)a=b;}
  template <class C> void setmax(C &a,C b){if(a<b)a=b;}
  const ll mod=1e9+7;
  const ll MAX=20000000000;
  //
  //
  	void solve(){
  		ll n,m,A,B;
  		cin>>n>>m>>A>>B;
  		rep(i,0,n){
  			rep(j,0,m)
  				if((i<(n-B))^(j<A))
  					cout<<"0";
  				else
  					cout<<"1";
  			cout<<'\n';
  		}
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 	

Measured memory_bytes: 1280
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 11;
int no_of_bulbs, no_of_switches;
vector <int> switches_connected_to[MAX_N];
vector <int> state_for_bulb_to_be_on(MAX_N, 0), switch_on(MAX_N, 0);

int is_bit_set(int n, int bit)
{
    return ( ( n & (1 << bit) ) != 0);
}

int all_bulbs_on()
{
    for(int i = 1; i <= no_of_bulbs; i++)
    {
        int no_of_on_switches = 0;

        for(int j = 0; j < switches_connected_to[i].size(); j++)
        {
            int current_switch = switches_connected_to[i][j];

            no_of_on_switches += switch_on[current_switch];
        } //cout << "Blub " << i << " No of ON = " << no_of_on_switches << " State = " << state_for_bulb_to_be_on[i] << endl;

        if(no_of_on_switches%2 != state_for_bulb_to_be_on[i])
            return false;
    }

    return true;
}

int main()
{
    cin >> no_of_switches >> no_of_bulbs;

    for(int i = 1; i <= no_of_bulbs; i++)
    {
        int no_of_switches_here;
        cin >> no_of_switches_here;

        for(int j = 1; j <= no_of_switches_here; j++)
        {
            int switch_here;
            cin >> switch_here;

            switches_connected_to[i].push_back(switch_here);
        }
    }

    for(int i = 1; i <= no_of_bulbs; i++)
        cin >> state_for_bulb_to_be_on[i];

    int no_of_combinations = 0;

    const int MAX_MASK = (1 << no_of_switches);
    for(int mask = 0; mask < MAX_MASK; mask++)
    {   //cout << "M = " << mask << endl;
        for(int i = 0; i < no_of_switches; i++)
        {
            switch_on[i + 1] = (is_bit_set(mask, i) ? true : false);
        }

        if(all_bulbs_on())
            no_of_combinations++;// cout << " C = " << no_of_combinations << endl;
    }

    cout << no_of_combinations;
    return 0;
}


Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: c.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int a[300010],g[300010];
void fuck(int n,int k){
	if(n==1){
		for(int i=1;i<=(k+1)>>1;++i)printf("1 ");
		return;
	}
	g[0]=1;
	for(int i=1;i<=k;++i)g[i]=g[i-1]*n+1;
	int s=k,t=0,tt=0;
	while(s){
		a[++t]=(n+1)>>1;

		--s;
		if(s && s&1)++tt;
	}

	while(tt){
		t=k;
		while(g[k-t]*(a[t]-1)<=tt){
			if(g[k-t]*(a[t]-1)<tt){
				tt-=g[k-t]*(a[t]-1);
				a[t]=0;
				if(tt==1){
					tt=0;
					break;
				}else --tt;
				--t;
			}
			else if(g[k-t]*(a[t]-1)==tt){
				a[t]=1;
				tt=0;
				break;
			}
		}
		if(tt){
			s=tt/g[k-t];
			tt-=s*g[k-t];
			if(!tt){
				a[t]-=s;	
				break;
			}

			else --tt;
			if(t<k)
				a[t]-=s+1;
			else a[t]-=s;

			while(++t<=k){
				a[t]=n;
			}
		}
	}
	t=k;
	while(!a[t])--t;

	for(int i=1;i<=t;++i)printf("%d%c",a[i],i==t?'\n':' ');
}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n,k;
	scanf("%d%d",&n,&k);
	if(!(n&1)){
		printf("%d",n/2);
		for(int i=1;i<k;++i)printf(" %d",n);
	}
	else fuck(n,k);
	return 0;
}



Measured memory_bytes: 4608
const main = (str) => {
    const k = str.split('\n')[0];
    const [a,b] = str.split('\n')[1].split(' ');
    if(a%k == 0 || b%k === 0){
        console.log('OK');
    }else if( Math.floor(b/k) - Math.floor(a/k) > 0){
        console.log('OK');
    }else{
        console.log('NG');
    }
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  auto dp=vec(n+1,5,0LL);
  rep(i,0,n){
    rep(j,0,5){
      ll minbuf=INF;
      rep(o,j,5)chmin(minbuf,dp[i][o]);
      if(j==2){
        minbuf+=(a[i]%2==0);
      }
      else if(j==1||j==3){
        if(a[i]==0)minbuf+=2;
        else minbuf+=(a[i]&1);
      }
      else{
        minbuf+=a[i];
      }
      dp[i+1][j]=minbuf;
    }
  }
  rep(i,0,5){
    chmin(res1,dp[n][i]);
  }
  //debug(dp,n+1,5);
  cout<<res1<<endl;
  return 0;
}

Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] c = br.readLine().split(" ");

		int[] a = new int[n];

		for(int i=0; i<n; i++) {
			a[i] = Integer.parseInt(c[i]);
		}

		int counter=0;
		while(true) {
			Boolean b = true;
			for (int i = 0; i < a.length; i++) {
				if(a[i] % 2 != 0) {
					b = false;
				}
			}

			if (!b) {
				break;
			}

			for (int j = 0; j < a.length; j++) {
				a[j] = a[j] / 2;
			}
			counter++;
		}

		System.out.println(counter);


	}



}

Measured memory_bytes: 21204
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a[10];
    int b;
    int c;
    int d;
    c=1;
    d=0;
    scanf("%d",&b);
    for(int i=1;i<=b;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=b;i++){
        if(a[c]<a[i]){
            c=i;
        }
    }
    for(int i=1;i<=b;i++){
        d=d+a[i];
    }
    d=d-a[c];
    if(d<=a[c]){
        printf("No");
    }
    else {
      printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int a;
    while(cin>>a){
        if(a==0){
            break;
        }
        int Z=0,Y=0,X=0,z=0,y=0,m=10000000;
        for(z=0;pow(z,3)<=a;z++){
            Z=pow(z,3);
            for(y=0;pow(y,2)<=a-Z;y++){
                Y=pow(y,2);
            }
            X=a-Y-Z;
            if(X+y+z-2<m){
                m=X+y+z-1;
            }
        }
        cout<<m<<endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#!/usr/bin/env python3
import sys


def solve(X: int):
    Y = 0
    Y += 1000 * (X // 500)
    Y += 5 * ((X % 500) // 5)
    print(Y)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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


int main() {
  ll h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  P now=make_pair(0,0);
  queue <P>q;
  int dist[h][w];
  ll white=0;

  rep(i,h)rep(j,w){
    dist[i][j]=INF;
    if (s[i][j]=='.')white++;
  }
  dist[0][0]=0;
  q.push(now);

  while(!q.empty()){
    P t=q.front();
    q.pop();
    int tx=t.first;
    int ty=t.second;
  //  cout<<tx<<' '<<ty<<endl;
  //  if (dist[tx][ty]!=INF) continue;
    if (tx>0){
      if (s[tx-1][ty]=='.' and dist[tx-1][ty]==INF){
        q.push(make_pair(tx-1,ty));
        dist[tx-1][ty]=dist[tx][ty]+1;
      }

    }
    if (tx<h-1){
        if (s[tx+1][ty]=='.' and dist[tx+1][ty]==INF){
          q.push(make_pair(tx+1,ty));
          dist[tx+1][ty]=dist[tx][ty]+1;
    }
    }
    if (ty>0){
        if (s[tx][ty-1]=='.' and dist[tx][ty-1]==INF){
          q.push(make_pair(tx,ty-1));
          dist[tx][ty-1]=dist[tx][ty]+1;
        }
    }
    if (ty<w-1){
        if (s[tx][ty+1]=='.' and dist[tx][ty+1]==INF){
          q.push(make_pair(tx,ty+1));
          dist[tx][ty+1]=dist[tx][ty]+1;
        }
    }
  }
  if (dist[h-1][w-1]==INF){
    cout<<-1;
    return 0;
  }
  else{
    int temp=dist[h-1][w-1]+1;
    int ans=white-temp;
    cout<<ans;
  }

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[]=new int[3];
		a[0]=sc.nextInt();
		a[1]=sc.nextInt();
		a[2]=sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[2]==a[0]&&a[0]==a[1]?"Yes":"No");
	}
}

Measured memory_bytes: 23636
#include<cstdio>

int main(){
    int a, b, c;
    char s[256];
    scanf("%d%d", &a, &b);
    getchar();
    bool ans = true;
    for(int i = 0; i < a; i++){
        c = getchar();
        if(c < 48 || c > 57) {
            ans = false;
        }
    }
    c = getchar();
    if(c != 45) ans = false;
    for(int i = 0; i < b; i++){
        c = getchar();
        if(c < 48 || c > 57) {
            ans = false;
        }
    }
    if(ans) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
//#include <string.h>
using namespace std;
int main(){
	char alpha[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
	string str;
	while( 1 ){
		if( getline( cin, str ).eof() ) break;
		for( int a = 0; a < 26; a++ ){
			for( size_t i = 0; i < str.length(); i++ ){
				for( size_t j = 0; j < sizeof(alpha); j++ ){
					if( str[i] == alpha[j] ){
						str[i] = alpha[j + 1];
						break;
					}
				}
			}
			if( str.find("the") != string::npos || str.find("this") != string::npos || str.find("that") != string::npos ){
				break;
			}
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 1180
N = int(input())
A = list(map(int, input().split()))

r = 0
r_min = 1000000000
m_c = 0

for i in A:
    ia = abs(i)
    if i<0:
        m_c+=1
    if r_min > ia:
        r_min = ia
    r+=ia

if m_c%2==0 :
    print(r)
else:
    print(r-r_min*2)


Measured memory_bytes: 14284
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int h,w,i,j;
  char s='#';
  while(1){
    cin>>h>>w;
    if(h==0&&w==0) break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout<<s;
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3036
inf = pow(10, 9) + 7

def solve(m, x, bag):

    p = [0]*(m+1)

    for i in range(len(bag)):
        for j in range(m+1):
            p[j] += bag[i][j]

    for i in range(1,m+1):
        if p[i] < x:
            return inf
    else:
        return p[0]

if __name__ == '__main__':

    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(n)]

    mini = inf

    for i in range(2**n):
        bag = []
        #print("p{} : ".format(i), end="")

        for j in range(n):
            if((i >> j) & 1):
                bag.append(l[j])
        #print(bag)
        r = solve(m, x, bag)
        if mini > r:
            mini = r

    if mini == inf:
        print(-1)
    else:
        print(mini)


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    int N;
    cin >> N;
    ll res = 0;
    FOR(i, 1, N + 1) {
        if (i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        res += i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 200005;

long long a[N],b[N];
long long c[N],d[N];

bool f[35];

int main()
{
	int n;
	
	scanf("%d",&n);
	
	for (int i = 0;i < n;i++)
	{
		scanf("%lld",&a[i]);
	}
	
	for (int i = 0;i < n;i++)
	{
		scanf("%lld",&b[i]);
	}
	
	for (int i = 0;i <= 30;i++)
	{
		long long t = ((long long)1 << i);
		
		for (int j = 0;j < n;j++)
		{
			c[j] = a[j] % (2 * t);
			d[j] = b[j] % (2 * t);
		}
		
		sort(d,d+n);
		
		int cnt = 0;
		
		for (int j = 0;j < n;j++)
		{
			long long y = 2 * t - c[j];
			long long x = t - c[j];
			
			
			
			cnt += lower_bound(d,d+n,y) - lower_bound(d,d+n,x);
			cnt += lower_bound(d,d+n,4 * t - c[j]) - lower_bound(d,d+n,3*t - c[j]);
		}
		
		if (cnt % 2) f[i] = 1;
	}
	
	long long ans = 0;
	
	for (int i = 0;i <= 30;i++)
	{
		if (f[i]) ans |= ((long long)1 << i);
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 6400
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i = 1; i < 1000; i++) {
            if (a <= (k * i) && (k * i) <= b){
                System.out.println("OK");
                return;
            }
            else if (b < (k * i)){
                System.out.println("NG");
                return;
            }
		}
		System.out.println("NG");
    }
}

Measured memory_bytes: 35804
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toDouble()}
    var ans : Double = 0.0
    a.forEach{
        ans += 1 / it
    }
    ans = 1 / ans
    println("%.10f".format(ans))
}


Measured memory_bytes: 35984
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

s1 = s()
s2 = s()
s3 = s()
print(s1[0]+s2[1]+s3[2])

Measured memory_bytes: 9868
def integer_str?(str)
  Integer(str)
  true
rescue ArgumentError
  false
end

a, b = gets.chomp.split.map(&:to_i)
s = gets.chomp
len = s.length

if s[a] == '-' && len == (a + b + 1) && integer_str?(s[0..(a - 1)]) && integer_str?(s[(a + 1)..(a + b)])
  puts 'Yes'
else
  puts 'No'
end

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


using namespace std;

int main(){
  int N;
  cin>>N;
  char S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  int ans=0;
  int temp=0;
  for(int i=0;i<N;i++){
    int left[26]={0};
    int right[26]={0};
    for(int j=0;j<i;j++){
      left[S[j]-0x61]=1;
    }
    for(int j=i;j<N;j++){
      right[S[j]-0x61]=1;
    }
    temp=0;
    for(int j=0;j<26;j++){
      if(right[j]&left[j])temp+=1;
    }
    if(ans<temp)ans=temp;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int i,j,k,n,m;
string s;

int getDigitNum(const int num, const int digit) {
  int pd = digit + 1;
  int dp1 = (int)pow(10, (float)pd);
  int dn0 = (int)pow(10, (float)digit);
  int t = num % dp1;
  return t/dn0;
}

bool isIn(int x, int start, int end) {
  // cal sum of num each digits
  int sum = 0;
  for (i=0; i<5;++i) sum += getDigitNum(x,i);
  bool out=false;
  if (sum >= start && sum <= end) out=true;
  return out;
}

int main() {
  int a,b; cin >> n >> a >> b;
  int sum=0;
  for (j=0; j < n+1;++j) {
    if (isIn(j, a, b)) sum +=j;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e15;

inline int sum(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

inline int mult(int a, int b) {
	return (1LL * a * b) % mod;
}

int n, m, dp[N][2], S, T;
ll dist[N][2];
vector <pii> adj[N];
vector <pair <pii, int> > edge;

inline void dijkstra(int src, int id) {
	for (int i = 0; i < n; i++)
		dist[i][id] = inf;
	dp[src][id] = 1;
	dist[src][id] = 0;
	set <pair <ll, int>> s;
	s.insert({0, src});
	while(!s.empty()) {
		pair <ll, int> p = (*s.begin());
		s.erase(p);
		int v = p.second;
		for (auto e : adj[v]) {
			int u = e.first, w = e.second;
			if(dist[u][id] > dist[v][id] + w) {
				s.erase({dist[u][id], u});
				dist[u][id] = dist[v][id] + w;
				s.insert({dist[u][id], u});
				dp[u][id] = dp[v][id];
			}
			else if(dist[u][id] == dist[v][id] + w)
				dp[u][id] = sum(dp[u][id], dp[v][id]);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n >> m >> S >> T;
	S--, T--;
	for (int i = 0; i < m; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		v--, u--;
		adj[v].push_back({u, w});
		adj[u].push_back({v, w});
		edge.push_back({{u, v}, w});
	}
	dijkstra(S, 0);
	dijkstra(T, 1);
	int ans = mult(dp[S][1], dp[T][0]);
	for (int i = 0; i < n; i++) {
		if(dist[i][0] == dist[i][1]) {
			ans = sum(ans, - mult(mult(dp[i][0], dp[i][0]), mult(dp[i][1], dp[i][1])));
		}
	}
//*
	for (auto e : edge) {
		int vv = e.first.first, uu = e.first.second, w = e.second;
		for (auto x : {make_pair(vv, uu), make_pair(uu, vv)}) {
			int v = x.first, u = x.second;
			if(dist[v][0] < (dist[S][1] / 2) && dist[u][1] < (dist[S][1] / 2) && dist[v][0] + dist[u][1] + w == dist[S][1]) {
				ans = sum(ans, -mult(mult(dp[v][0], dp[u][1]), mult(dp[v][0], dp[u][1])));
			}
		}
	}
//*/
	cout << ans << "\n";

}


Measured memory_bytes: 22100
A, B = [int(_) for _ in input().split()]

def f(a, b):
    if a > 0:
        return f(0, a - 1) ^ f(0, b)
    if b % 2 == 1:
        return (b + 1) // 2 % 2
    else:
        return b ^ f(0, b - 1)

result = f(A, B)

print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, n) for(int i(0); i<(int)(n);i++)

int n, h, mh = -1, ans = 0;

int main() {
    cin >> n;
    REP(i, n) {
        cin >> h;
        ans += h >= mh;
        mh = max(mh, h);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

d = {'A' : 'T', 'T':'A', 'C' : 'G', 'G' : 'C'}
s = raw_input()
print d[s]

Measured memory_bytes: 28396
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long r1 = long.Parse(str[0]);
		long c1 = long.Parse(str[1]);
		long r2 = long.Parse(str[2]);
		long c2 = long.Parse(str[3]);
		long mod = 1000000007;
		long A = 1;
		long B4 = 0;
		for(var i=0;i<=r1-1;i++){
			A = A * (i+c1-1+1) % mod * Mpow(i+1,mod-2,mod) % mod;
			B4 = (B4 + A) % mod;
		}
		long B3 = B4;
		for(var i=r1;i<=r2;i++){
			A = A * (i+c1-1+1) % mod * Mpow(i+1,mod-2,mod) % mod;
			B3 = (B3 + A) % mod;
		}
		A = 1;
		long B2 = 0;
		for(var i=0;i<=r1-1;i++){
			A = A * (i+c2+1) % mod * Mpow(i+1,mod-2,mod) % mod;
			B2 = (B2 + A) % mod;
		}
		long B = B2;
		for(var i=r1;i<=r2;i++){
			A = A * (i+c2+1) % mod * Mpow(i+1,mod-2,mod) % mod;
			B = (B + A) % mod;
		}
		Console.WriteLine((B-B2-B3+B4+mod+mod)%mod);
	}
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long

const int N = 1e9 + 5;
const int MOD = 1e9 + 7;


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s; cin >> s;
    int mx = 0, ans = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'S')
            ans = 0;
        else {
            ans += 1;
        }
        mx = max(mx, ans);
    }
    cout << mx << endl;
}

Measured memory_bytes: 3544
;; E - Balanced Path

(defun main ()
  (let* ((H (read))
         (W (read))
         (A (loop repeat H collect (loop repeat W collect (read))))
         (B (loop repeat H collect (loop repeat W collect (read)))))
    (print (solve H W A B))
    (fresh-line)))

(defmacro table-add (table i j elem)
  `(setf (aref ,table ,i ,j ,elem) 1))
(defmacro table-contains (table i j elem)
  `(plusp (aref ,table ,i ,j ,elem)))

(defun solve (H W A B)
  (let* ((maxdiff (* 80 (+ W H)))
         (D (make-array (list H W) :initial-contents
              (mapcar #'(lambda (a b) (mapcar #'- a b)) A B)))
         (table (make-array (list H W maxdiff) :element-type 'bit
                  :initial-element 0)))

    ; table[0, 0]を初期化
    (table-add table 0 0 (abs (aref D 0 0)))

    ; table[i, j]を計算
    (loop for i below H do
      (loop for j below W
            for diff = (aref D i j) do
        (loop for prev below maxdiff
          when (or (and (plusp j) (table-contains table i (1- j) prev))
                   (and (plusp i) (table-contains table (1- i) j prev)))
          do (table-add table i j (abs (+ prev diff)))
             (table-add table i j (abs (- prev diff))))))

    ; table[H-1, W-1]の最小値
    (loop for d from 0
      when (table-contains table (1- H) (1- W) d)
      return d)))

(main)


Measured memory_bytes: 48488
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
int dp[3003][3003];
string s,t;
int resolve(int i, int j){
	if(i>=s.size() or j>=t.size()){
		return 0;
	}
	int &x=dp[i][j];
	if(x!=-1)
		return x;
	x=0;
	if(s[i]==t[j]){
		x=max(x,resolve(i+1,j+1)+1);
	}
	x=max(x,resolve(i+1,j));
	x=max(x,resolve(i,j+1));
	return x;
}
void solve(){
	memset(dp,-1,sizeof(dp));
	cin>>s>>t;
	int res=resolve(0,0);
	if(res==0){
		cout<<endl;
		return;
	}
	int i=0,j=0;
	string ans="";
	while(i<s.size() and j<t.size() and dp[i][j]>0){
		if(dp[i+1][j]!=dp[i][j] and dp[i+1][j+1]!=dp[i][j] and dp[i][j+1]!=dp[i][j]){
			ans+=s[i];
			i++;
			j++;
		}else{
			 if(dp[i+1][j+1]==dp[i][j]){
			 	i++;
			 	j++;
			 }else if(dp[i+1][j]==dp[i][j]){
			 	i++;
			 }else{
			 	j++;
			 }
		}
	}
	cout<<ans<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 74456
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 1;
		for(int i=0; i<N; i++) {
			long t = sc.nextLong();
			ans = lcm(ans, t);
		}
		sc.close();
		System.out.println(ans);
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}

}


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

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

    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(ll i = 0;i<n;++i)
#define repc(bit,k,n) for (ll bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
const ll MOD = 1000000007;
ll dp[1000001][4];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;cin>>n;

  dp[0][0] = 1;
  rep(i,n){
    dp[i+1][0] = (dp[i][0]*8)%MOD;
    dp[i+1][1] = (dp[i][0]+(dp[i][1]*9)%MOD)%MOD;
    dp[i+1][2] = (dp[i][0]+(dp[i][2]*9)%MOD)%MOD;
    dp[i+1][3] = ((dp[i][1]+dp[i][2])%MOD+(dp[i][3]*10)%MOD)%MOD;
  }
  cout<<dp[n][3]<<endl;

  return 0;
}

Measured memory_bytes: 34764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int isCoffee(char*string){
    return (string[2]==string[3] && string[4]==string[5]);
}
int main(){
    char*s=(char*)calloc(10,sizeof(char));
    scanf("%s",s);
    if(isCoffee(s)){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define mod 	1000000007
#define rep(i,n)	for(int i=1;i<=n;i++)
#define pb 		push_back
int main()
{
	I_O;
	int k;	cin>>k;
	string s,st;	cin>>s;
	if(s.size()>k)
	{
		for(int i=0;i<=k-1;i++)
			st.pb(s[i]);
		st.pb('.');
		st.pb('.');
		st.pb('.');
		cout<<st;
	}
	else	cout<<s;
}

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

using namespace std;
int main(){
  string c;
  cin>>c;
  if(c=="a"||c=="e"||c=="i"||c=="o"||c=="u"){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }


  return 0;
}



Measured memory_bytes: 256
while True:
  m,f,r=map(int,input().split())
  if(m==-1 and f==-1 and r==-1):
    break
  if(m==-1 or f==-1):
    print("F")
  elif(m+f>=80):
    print("A")
  elif(m+f>=65):
    print("B")
  elif(m+f>=50):
    print("C")
  elif(m+f>=30):
    if(r>=50):
      print("C")
    else:
      print("D")
  else:
    print("F")



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

using namespace std;

#define up(i,j,n)	for(int i=j;i<=n;i++)

int N,tag=0;
deque<int>S;

int main(){
//	freopen("input.in","r",stdin);
	scanf("%d",&N);
	up(i,1,N){
		int x;
		scanf("%d",&x);
		if(tag)S.push_back(x);
		else S.push_front(x);
		tag^=1;
	}
	if(!tag){
		while(!S.empty()){
			printf("%d ",S.back());
			S.pop_back();
		}
	}else {
		while(!S.empty()){
			printf("%d ",S.front());
			S.pop_front();
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 2944
<?php
while ($iline = trim(fgets(STDIN))) {
    $len = strlen($iline);
    $i = 0;
    while ($i <= $len-1) {
        if ($iline[$i] == '@') {
            if ($i <= $len-3) {
                $l = $iline[$i+1];
                for ($j = 0; $j < $l; $j++) { echo $iline[$i+2]; }
            }
            $i+=3;
        }
        else {
            echo $iline[$i++];
        }
    }
    echo PHP_EOL;
}

?>


Measured memory_bytes: 9236
from operator import itemgetter

N,M=map(int,input().split())
req=[list(map(int,input().split())) for i in range(M) ]

req.sort(key=itemgetter(1))

max=0
ans=0

for i in range(M):
    if not req[i][0]<=max<req[i][1]:
        max=req[i][1]-1
        ans+=1
        
print(ans)

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

using namespace std;

typedef long long int ll;

const ll MAXN = 55556;

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

  string s;
  cin >> s;
  vector < vector < ll > > v(26, vector < ll > ());
  ll n = s.length();
  for(int i = 0; i < n; i++){
    v[s[i] - 'a'].push_back(i);
  }

  ll ans = (n * (n - 1)) / 2;
  for(int i = 0; i < n; i++){
    ll idx = s[i] - 'a';
    ans -= v[idx].end() - upper_bound(v[idx].begin(), v[idx].end(), i);
  }

  cout << ans + 1 << '\n';
}


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

template <typename T>
class avl_tree {
	struct node {
		T val;
		int dep;
		node *ch[2];
		node() : node(0) {}
		node(T v, node* l = nullptr, node* r = nullptr)
			: val(v), dep(1), ch{ l, r } {}
		void *operator new(size_t) {
			static const int pmax = 2e5; // number of nodes
			static int p = 0;
			static node pool[pmax];
			return pool + p++;
		}
	};
	int depth(node *t) { return !t ? 0 : t->dep; }
	node *update(node *t) {
		t->dep = max(depth(t->ch[0]), depth(t->ch[1])) + 1;
		return t;
	}
	node *rotate(node *t, int b) {
		node *s = t->ch[!b];
		t->ch[!b] = s->ch[b];
		s->ch[b] = t;
		update(t);
		return update(s);
	}
	node *fix(node *t) {
		if (!t) return t;
		int dd = depth(t->ch[0]) - depth(t->ch[1]);
		if (abs(dd) < 2) return t;
		int b = dd < 0;
		if (depth(t->ch[b]->ch[!b]) > depth(t->ch[b]->ch[b])) {
			t->ch[b] = rotate(t->ch[b], b);
		}
		return rotate(t, !b);
	}
	node *insert(node *t, T val) {
		if (!t) {
			++cnt;
			return new node(val);
		}
		if (val == t->val) return t;
		int b = val > t->val;
		t->ch[b] = insert(t->ch[b], val);
		return fix(update(t));
	}
	T minimum(node *t) {
		while (t->ch[0]) t = t->ch[0];
		return t->val;
	}
	node *erase(node *t) {
		if (!t) return t;
		if (!t->ch[0]) return t->ch[1];
		if (!t->ch[1]) return t->ch[0];
		T mini = minimum(t->ch[1]);
		++cnt;
		return fix(update(new node(mini, t->ch[0], erase(t->ch[1], mini))));
	}
	node *erase(node *t, T val) {
		if (!t) return t;
		if (val == t->val) {
			--cnt;
			return fix(erase(t));
		}
		int b = val > t->val;
		t->ch[b] = erase(t->ch[b], val);
		return fix(update(t));
	}
	node *root;
	int cnt;
public:
	avl_tree() : root(nullptr), cnt(0) {}
	int size() {
		return cnt;
	}
	void insert(T val) {
		root = insert(root, val);
	}
	void erase(T val) {
		root = erase(root, val);
	}
	bool count(T val) {
		node *t = root;
		while (t) {
			if (t->val == val) return true;
			t = t->ch[val > t->val];
		}
		return false;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int q;
	cin >> q;
	avl_tree<int> st;
	for (int i = 0; i < q; ++i) {
		int t, x;
		cin >> t >> x;
		switch (t) {
		case 0:
			st.insert(x);
			cout << st.size() << endl;
			break;
		case 1:
			cout << st.count(x) << endl;
			break;
		default:
			st.erase(x);
		}
	}
	return 0;
}



Measured memory_bytes: 7888
int main(void){
  int a[3],i,j,tmp;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<=1;i++){
    for(j=1;j<=2;j++){
      if(a[i]>a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2] );
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 10000;
int n;
int dat;

int main()
{
  while((cin >> n) && n){
    ll res = 0LL;
    vector<ll> w;
    rep(i, n){
      cin >> dat;
      w.pb(dat);
    }

    sort(ALL(w));

    rep(i, n) res += w[i] * (n - i - 1LL);

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1340