akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int h,w; cin >> h >> w;
    
    int a[h][w];
    rep(i,h) rep(j,w) cin >> a[i][j];
    
    int cnt = 0;
    vi x1,y1,x2,y2;
    
    rep(i,h){
        rep(j,w){
            if(a[i][j]%2 != 0){
                
                if(j<w-1){
                    a[i][j+1]++;
                    x1.push_back(j+1);
                    x2.push_back(j+2);
                    y1.push_back(i+1);
                    y2.push_back(i+1);
                    cnt++;
                }else if(j == w-1 and i != h-1){
                    a[i+1][j]++;
                    x1.push_back(j+1);
                    x2.push_back(j+1);
                    y1.push_back(i+1);
                    y2.push_back(i+2);
                    cnt++;
                }
                
                
                a[i][j]--;
            }
        }
    }
    
    cout << cnt << endl;
    
    rep(i,cnt){
        printf("%d %d %d %d\n",y1[i],x1[i],y2[i],x2[i]);
    }
}






Measured memory_bytes: 5220
#include<stdio.h>
 
int main(void){
  
  int ht,at,ha,aa;
  
  scanf("%d",&ht);
  scanf("%d",&at);
  scanf("%d",&ha);  
  scanf("%d",&aa);
   
  while(1){
     ha=ha-at;
       if(ha<=0){
         puts("Yes");
         break;}
     
     
     ht=ht-aa;
       if(ht<=0){
         puts("No");
         break;}
   }
 
  
  return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n>=s.size())cout << s << endl;
  else{
    s.erase(n);
    s+="...";
    cout << s << endl;
  }
}


Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
#include<algorithm>
const int INF=1e9;
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
string S; cin >> S;
VS de = {"dream", "dreamer", "erase", "eraser"};

if (S.size() <= 4) {
    cout << "NO" << "\n";
    return 0;
}

reverse(ALL(S));
rep(i, 0 , 4) reverse(ALL(de[i]));

bool can;
string dei;
for (int i = 0; i < S.size();) {
    can = false;
    rep(j, 0, 4){
        dei = de[j];
        if (S.substr(i, dei.size()) == dei) {
            can = true;
            i += dei.size();
            break;
        } 
    }
    if (!can) { 
        cout << "NO" << "\n";
        return 0;
    }
}

cout << "YES" << "\n";

return 0;
}

// 境界，出力文字列 チェック


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
using namespace std;
 
int bit[1000000],bit_n;
int sum(int i){
  int s=0;
  while(i){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}
void add(int i,int x){
  while(i<=bit_n){
    bit[i]+=x;
    i+=i&-i;
  }
}
 
struct data{
  int time,type,l,r;
  bool operator < (const data &p)const{
    return (time==p.time?type<p.type:time<p.time);
  }
};
// 1 | add
// 2 - check
// 3 | delete
 
int n;
vector<data> t;
vector<int> X;
map<int,int> mapx;
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    X.push_back(a);
    X.push_back(c);
    if(a==c){
      t.push_back((data){min(b,d),1,a,a});
      t.push_back((data){max(b,d),3,a,a});
    }else{
      t.push_back((data){b,2,min(a,c),max(a,c)});
    }
  }
  sort(t.begin(),t.end());
  sort(X.begin(),X.end());
  int c=2;
  for(int i=0;i<(int)X.size();i++)
    if(i==0||X[i]!=X[i-1])
      mapx[X[i]]=c++;
   
  bit_n=n*2+1;
  long long ans = 0;
  for(int i=0;i<(int)t.size();i++){
    data d=t[i];
    d.l=mapx[d.l],d.r=mapx[d.r];
    if(d.type==1){
      add(d.l,1);
    }else if(d.type==2){
      long long A=sum(d.r)-sum(d.l-1);
      ans+=A;
    }else if(d.type==3){
      add(d.l,-1);
    }
  }
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 9804
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #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 a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        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;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------


signed main(){
string s;
	cin>>s;
	
	int g=0,p=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='g') g++;
		else p++;
	}
	int l=s.length();
	int gg=(l+1)/2,pp=l/2;
	cout<<max(0ll,pp-p)<<endl;
		
	
	return 0;
}

//printf("%.10f\n",ans);


Measured memory_bytes: 512
#include <stdio.h>
using namespace std;
int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}
struct node {
	node *left=NULL,*right=NULL,*parent=NULL;
	int key=-1;
};

node *root = NULL;

void insert(node *z) {
	node *y =NULL;
	node *x = root;
	while (x != NULL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;

	if (y == NULL) {
		root = z;
	}
	else if(z->key < y->key){
		y->left = z;
	}
	else y->right = z;
}

void preprint(node* n) {
	cout << " " << n->key;
	if (n->left != NULL)preprint(n->left);
	if (n->right != NULL)preprint(n->right);
}

void inoprint(node* n) {
	if (n->left != NULL)inoprint(n->left);
	cout << " " << n->key;
	if (n->right != NULL)inoprint(n->right);
}


int main(){
	int n,in;
	string s;
	cin >> n;
	vector<node> zz(n);
	rep(i, n) {
		cin >> s;
		if (s == "insert") {
			cin >> in;
			zz[i].key = in;
			zz[i].left = NULL;
			zz[i].right = NULL;
			zz[i].parent= NULL;
			insert(&zz[i]);
		}
		else {
			inoprint(root);
			cout << endl;
			preprint(root);
			cout << endl;

		}
	}
}


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

int main(void)
{
    using namespace std;
    string S;
    cin >> S;

    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 256
from collections import deque


def bfs(g, source):
    n = len(g)
    d = [float('inf') for _ in range(n)]
    d[0] = 0
    queue = deque()
    queue.append(0)
    while len(queue) > 0:
        cur = queue.popleft()
        for next in g[cur]:
            if d[cur] + 1 < d[next]:
                d[next] = d[cur] + 1
                queue.append(next)
    return d


def main():
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n):
        inp = list(map(int, input().split()))
        m = inp[0] - 1
        k = inp[1]
        for i in range(k):
            g[m].append(inp[i+2] - 1)
    d = bfs(g, 0)
    for i in range(n):
        if d[i] == float('inf'):
            d[i] = -1
        print(i+1, d[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 6048
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    int a_max = 0;
    int a_min = INF;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
        a_max = max(a_max,a[i]);
        a_min = min(a_min,a[i]);
    }
    
    cout << a_max-a_min;
    
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,t;
	long long p,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld %lld",&a,&b);
		p=a*b;
		t=(int)sqrt(p);
		if((long long)t*t==p)
		{
			if(a==b)
				printf("%lld\n",((long long)t-1)*2);
			else
				printf("%lld\n",((long long)t-1)*2-1);
		}
		else
		{
			if((long long)t*(t+1)<p)
				printf("%lld\n",(long long)t*2-1);
			else
				printf("%lld\n",(long long)t*2-2);
		}
	}
	return 0;
}

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

int main(){

string a,b;
	cin >>a>>b;
int x,y;
  	cin>>x>>y;
string temp;
  cin>>temp;
if(temp==a)
  x--;
  else
    y--;
  
  cout<<x <<" "<<y;
  
  
  
}


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

long long ara[200008];

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sm=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lld %lld",&n,&k);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&ara[i]);


        }

        q=1;  mp[1]=3; nq[1]=0;

        while(1)
        {
            p=ara[q];

            if(mp[p]!=0)
            {
                sm++; //cout<<mp[p]<<"   "<<sm<<"   "<<nq[p]<<endl;

                b=sm-nq[p];  c=nq[p];

                qr[sm]=p;  break;


            }

             mp[p]=3;
            sm++; qr[sm]=p;

            nq[p]=sm;

            q=p;

        }


        //cout<<b<<"    "<<c<<endl;

        if(k<=c)printf("%lld\n",qr[k]);
        else
        {

            d=k-c;  e=d%b;  if(e==0)e=b;   e=e+c;   printf("%lld\n",qr[e]);

        }









    return 0;
}





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

int main() {
  int n;
  cin>>n;
  map<string,int> a;
  vector<string> c;
  rep(i,0,n){
    string s;
    cin>>s;
    if(!a.count(s)) c.push_back(s);
    a[s]++;
  }
  int m;
  cin>>m;
  map<string,int> b;
  rep(i,0,m){
    string s;
    cin>>s;
    b[s]++;
  }
  
  int ans=0;
  rep(i,0,c.size()) ans=max(ans,a[c[i]]-b[c[i]]);  
  cout<<ans<<endl;
}


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

ll dp[102][100005],w[101],v[101],n,cap;
ll M = 2e10;

ll knapSack(int i, int rem)
{
    if(rem==0) return 0;

    if(i>=n) return M;

    if(dp[i][rem]!=-1) return dp[i][rem];

    ll pro1=M,pro2=M;

    if(rem-v[i]>=0) pro1 = w[i]+knapSack(i+1,rem-v[i]);

    pro2 = knapSack(i+1,rem);

    dp[i][rem] = min(pro1,pro2);

    return dp[i][rem];

}

int main()
{
    memset(dp,-1,sizeof(dp));

    cin >> n >> cap;

    for(int i=0;i<n;++i) cin >> w[i] >> v[i];

    for(int i=100000;i>=0;i--)
    {
        if(knapSack(0,i)<= cap) {cout << i ; break;}
    }

    return 0;
}


Measured memory_bytes: 80000
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int lim = 100000000, N = 200005 ;
const double BY_delta = M_PI * 10.0 - 20.0 ;
const double FY_delta = M_PI * 5.0 - 20.0 ;
using namespace std ; 

int n ; 
struct poi {
	int x, y ; 
} s, t, a[N] ;

bool cmpx(poi a, poi b) {
	return a.x < b.x ;
}

bool cmpy(poi a, poi b) {
	return a.y < b.y ;
}

inline double SUCCESS() {
	return 100.0 * (t.x - s.x + t.y - s.y) + BY_delta + FY_delta * (t.x - s.x) ;
}

int bit[N], d[N] ;

int find(int x) {
	int l = 1, r = d[0] ;
	for ( ; l <= r ; ) {
		int mid = (l + r) / 2 ;
		if (d[mid] == x) return mid ;
		if (x < d[mid]) r = mid - 1 ;
			else l = mid + 1 ;
	}
	return 0 ;
}

void pre() {
	d[0] = 0 ;
	d[++ d[0]] = s.x ;
	d[++ d[0]] = t.x ;
	rep(i, 1, n) {
		d[++ d[0]] = a[i].x ;
	}
	sort(d + 1, d + d[0] + 1) ;
	d[0] = unique(d + 1, d + d[0] + 1) - (d + 1) ;
	s.x = find(s.x) ;
	t.x = find(t.x) ;
	rep(i, 1, n) {
		a[i].x = find(a[i].x) ;
	}
}

void put(int x, int y) {
	for ( ; x <= d[0] ; x += x & (- x)) {
		bit[x] = max(bit[x], y) ;
	}
}

int get(int x) {
	int res = 0 ;
	for ( ; x; x -= x & (- x)) {
		res = max(res, bit[x]) ;
	}
	return res ;
}

inline double FAILED() {
	pre() ;
	sort(a + 1, a + n + 1, cmpy) ;
	put(s.x, 1) ;
	int res = 0 ;
	rep(i, 1, n) {
		if (a[i].y < s.y) continue ;
		int tmp = get(a[i].x) ;
		if (!tmp) continue ;
		put(a[i].x, tmp + 1) ;
		if (a[i].y <= t.y && a[i].x <= t.x) res = max(res, tmp) ;
	}
	return 100.0 * (d[t.x] - d[s.x] + t.y - s.y) + FY_delta * res ;
}

double solve() {
	int k = 0 ;
	sort(a + 1, a + n + 1, cmpx) ;
	rep(i, 1, n) if (a[i].x == s.x && a[i].y >= s.y && a[i].y <= t.y) {
		k = i ;
		break ;
	}
	if (!k) return FAILED() ;
	if (a[n].x < t.x) return FAILED() ;
	if (s.x == t.x) return SUCCESS() ;
	rep(i, k + 1, n) {
		if (a[i].x != s.x + i - k) return FAILED() ;
		if (a[i].y < a[i - 1].y || a[i].y > t.y) return FAILED() ;
		if (i - k == t.x - s.x) break ;
	}
	return SUCCESS() ;
}

int main() {
	scanf("%d%d%d%d%d", &s.x, &s.y, &t.x, &t.y, &n) ;
	rep(i, 1, n) {
		scanf("%d%d", &a[i].x, &a[i].y) ;
	}
	if (s.x > t.x) swap(s, t) ;
	if (s.y > t.y) {
		s.y = lim - s.y ;
		t.y = lim - t.y ;
		rep(i, 1, n) a[i].y = lim - a[i].y ;
	}
	if (t.x - s.x > t.y - s.y) {
		swap(s.x, s.y) ;
		swap(t.x, t.y) ;
		rep(i, 1, n) swap(a[i].x, a[i].y) ;
	}
	printf("%.15lf\n", solve()) ;
	return 0 ; 
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> v(505,vector<int>(505));
    for(int i=0;i<m;++i){
        int l,r;
        cin>>l>>r;
        v[l][r]++;
    }
    for(int i=0;i<=500;++i)for(int j=0;j<=500;++j)v[i][j+1] += v[i][j];
    for(int i=0;i<q;++i){
        int l,r;
        cin>>l>>r;
        int count = 0;
        for(int i=l;i<=r;++i){
            count += v[i][r] - v[i][l-1];
        }
        cout << count << endl;
    }
    
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N;
  while(cin >> N){
    i64 ans = 0;
    FORE(i,1,N){
      if(i % 3 != 0 and i % 5 != 0){
        ans += i;
      }
    }

    pout(ans);
  }


  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
int H[MAX_N];
bool good[MAX_N];

int main(){
	int N,M;	scanf("%d%d",&N,&M);
	for (int i = 0; i < N; ++i)	good[i] = true;

	for (int i = 0; i < N; ++i)	scanf("%d",H+i);

	for (int i = 0; i < M; ++i){
		int A, B;	scanf("%d%d",&A,&B);	--A, --B;

		if(H[A] == H[B]){
			good[A] = false;
			good[B] = false;
		}

		if(H[A] > H[B])	swap(A,B);
		good[A] = false;
	}
	int cnt = 0;
	for (int i = 0; i < N; ++i)
		if(good[i])
			++cnt;
	printf("%d\n",cnt);





}

Measured memory_bytes: 2184
int main(void)
{
	int cards[4][13];
	int n;
	char mark;
	int num;
	
	int i,j;
	
	for(i = 0;i < 13;i++){
		cards[0][i] = i + 1;
		cards[1][i] = i + 1;
		cards[2][i] = i + 1;
		cards[3][i] = i + 1;
	}
	
	scanf("%d\n",&n);
	
	for(i = 0;i < n;i++){
		if(i != n-1)scanf("%c %d\n",&mark,&num);
		else scanf("%c %d",&mark,&num);
		switch(mark){
			case 'S':
				cards[0][num-1] = 0;
				break;
			case 'H':
				cards[1][num-1] = 0;
				break;
			case 'C':
				cards[2][num-1] = 0;
				break;
			case 'D':
				cards[3][num-1] = 0;
				break;
		}
	}
	
	for(i = 0;i < 4;i++){
		for(j = 0;j < 13;j++){
			if(cards[i][j] != 0){
				switch(i){
					case 0:
						printf("S %d\n",cards[i][j]);
						break;
					case 1:
						printf("H %d\n",cards[i][j]);
						break;
					case 2:
						printf("C %d\n",cards[i][j]);					
						break;
					case 3:
						printf("D %d\n",cards[i][j]);
						break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if (A > 12) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
i = 0
c = 0
x = 0
y = 0 
while i < len(a) - 1:
	if a[i] == a[i+1] and c == 0:
		x = a[i]
		i += 2
		c += 1
		continue
	if a[i] == a[i+1] and c == 1:
		y = a[i]
		break
	i += 1
if x != 0 and y != 0:
	print(x*y)
else:
	print(0)

Measured memory_bytes: 19892
import java.io.IOException;
import java.util.Scanner;


public class Main {
	public static void main(String[] aegs) throws IOException{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();

		long[] A = new long[N+1];
		long[] B = new long[M+1];

		A[0]= 0 ;
		B[0]= 0 ;

		for(int i=1;i<N+1;i++)A[i]=sc.nextLong()+A[i-1];
		for(int i=1;i<M+1;i++)B[i]=sc.nextLong()+B[i-1];

		int j = M;
		int count = 0;

		for(int i=0;i<N+1;i++) {
			if(A[i]>K) break;
            while (B[j] > K - A[i]) {
                j -= 1;
            }
			count=Math.max(count,i+j);
		}
		System.out.println(count);

	}
}

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

Measured memory_bytes: 54176
#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 MAN_N = 100005;
vector<P> A;

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		int a;
		cin >> a;
		A.push_back(P(a,i+1));
	}

	sort(A.begin(),A.end());

	rep(i,N)
	{
		if (i != 0) cout << " ";
		cout << A[i].second;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a, b;
    while (scanf("%d %d",&a,&b)!=EOF) {
        a+=b;
        int ans=0;
        while (a>0) {
            a/=10;
            ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a, b,k;
int d[100005];

int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b)
{
	return a / gcd(a, b)*b;

}

int main(){
	int n; int x;
	cin >> n >> x;
	int xxx; int tmp = 0;
	int ans = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++) {
		cin >> xxx; 
		d[i] = abs(xxx - x);
		if (i == 1)tmp = d[i];
		ans = min(gcd(tmp, d[i]), ans);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, A, P=0;
  cin >> N >>M;
  for(int i=0;i<M;i++){
    cin >> A;
    P+=A;
  }
  if(P<=N){
    cout << N-P;
  }
  else{
    cout << -1;
  }
}


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x <= 0 || y <= 0) {
		cout << "No" << endl;
		return 0;
	}

	bool left, right, up, down;
	left = (x - r) >= 0;
	right = (x + r) <= W;
	up = (y + r) <= H;
	down = (y - r) >= 0;

	if (left & right & up & down) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int a[2000];
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a+n);
    int nSum = 0;
    for(int i=0; i<k; i++) {
        nSum += a[i];
    }
    printf("%d\n", nSum);
    return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  int b=N;
  int answer=0;
  vector<int> a(N);
  rep(i,N){
    cin>>a[i];
    if(a[i]<=b){
      answer++;
      b=a[i];
    }
  }
  cout<<answer;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

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

int main() {

    int k,s ;
    cin >> k >> s  ;
    int ans = 0 ;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
        //   for()
            int z = s-i-j ;
            if(z>=0 && z<=k)ans++ ;
        }
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main() {
    int a,b,t;
    do{
        cin >> a>>b;
        if (a>b){
            t=a;
            a=b;
            b=t;
        }
        if ((a==b)&&(a==0)){
            break;
        }
        cout << a << ' ' << b << endl;
    }
    while (!((a==b)&&(a==0)));
    return 0;
}


Measured memory_bytes: 3084
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
#2 ** n はだめ
n_max = pow(2, n, mod) - 1


def comb_mod(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num = (num * (n - i)) % mod
        den = (den * (i + 1)) % mod
    den_r = pow(den, mod - 2, mod)
    return (num * den_r) % mod


ans = (n_max - comb_mod(n, a, mod) - comb_mod(n, b, mod)) % mod
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int INF=pow(10,9)+7;
int main()
{
int n,k;
cin>>n;
cin>>k;
vector <int> v(n);
int i,j;
for (i=0;i<n;i++)
{
    cin>>v[i];
}
vector <int> ans(n,INF);
int maxmin=10001;
ans[0]=0;

for (i=1;i<n;i++)
{
    for (j=max(i-k,0);j<i;j++)
    {
        
        ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
    }
        
}
cout<<ans[n-1];
}


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

int main(){
    int one[3][10] = {0};
    int two[3][10] = {0};
    int three[3][10] = {0};
    int four[3][10] = {0};
    int n, b, f, r, v;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        if (b == 1) one[f-1][r-1] += v;
        if (b == 2) two[f-1][r-1] += v;
        if (b == 3) three[f-1][r-1] += v;
        if (b == 4) four[f-1][r-1] += v;
    }

    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            cout << " " << one[i][j] << "";
        }
        cout << "" << endl;
    }
    cout << "####################" << endl;

    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            cout << " " << two[i][j] << ""; 
        }
        cout << "" << endl;
    }
    cout << "####################" << endl;
    
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            cout << " " << three[i][j] << "";
        }
        cout << "" << endl;
    }
    cout << "####################" << endl;

    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            cout << " " << four[i][j] << "";
        }
        cout << "" << endl;
    }    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i=0;i<n;i++) cin >> a[i];
  
  vector<int> b;
  
  b = a;
  
  sort(b.rbegin(),b.rend());
  for(int i=0;i<n;i++){
    if(a[i]==b[0]){
      cout << b[1] << endl;
      continue;
    }
    cout << b[0] << endl;
  }
}
  


Measured memory_bytes: 3200
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,m; 
int main(){
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n, m, k;
	cin >> n >> m >> k;
	ll pa[n+1], pb[m+1];
	pa[0] = 0; pb[0] = 0;
	for (int i=1; i<=n; i++) {
		int x;
		cin >> x;
		pa[i] = pa[i-1] + x;
	}
	for (int i=1; i<=m; i++) {
		int x;
		cin >> x;
		pb[i] = pb[i-1] + x;
	}
	ll ans = 0;
	for (int i=0; i<=n; i++) {
		if (pa[i] > k) break;
		ll cnt = upper_bound(pb, pb+m+1, k-pa[i]) - pb - 1;
		ans = max(ans, cnt + i);
	}
	cout << ans << '\n';
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int A4=0;
	int A2=0;
	int A1=0;
	for (int i=0; i<N; i++) {
		int a;
		cin >>a;
		if (0==a%4)
			A4++;
		else if (0==a%2)
			A2++;
		else
			A1++;
	}
	if (A4>=N/2) {
		cout <<"Yes" <<endl;
		return 0;
	}
	if (0==A2) {
		if (A1<=A4+1) {
			cout <<"Yes" <<endl;
			return 0;
		}
	}
	if (A1<=A4) {
		cout <<"Yes" <<endl;
			return 0;
	}
	cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
def readinput():
    h,w=map(int,input().split())
    smat=[]
    for _ in range(h):
        smat.append(input())
    return h,w,smat

def main(h,w,smat):
    tmat=[]
    for _ in range(h):
        t=[0 for tt in range(w)]
        tmat.append(t)
    #print(tmat)
    for i in range(h):
        s=smat[i]
        l=0
        r=s.find('#',l)
        #print(i,l,r)
        while(r>=0):
            for k in range(l,r):
                tmat[i][k]=r-l
            l=r+1
            if (l>=w):
                break
            r=s.find('#',l)
            #print(i,l,r)
        else:
            for k in range(l,w):
                tmat[i][k]=w-l
        #print(tmat[i])
    maxt=0
    for j in range(w):
        u=0
        b=u
        while b<h:
            #print(b,j)
            while b<h and smat[b][j]=='.':
                b+=1
            for k in range(u,b):
                maxt=max(maxt, tmat[k][j]+b-u-1)
            u=b+1
            b=u

    return maxt

if __name__=='__main__':
    h,w,smat=readinput()
    ans=main(h,w,smat)
    print(ans)


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

bool isInt(float a)
{
    if(ceil(a) - floor(a) == 0)
        return true;
        
    else
        return false;
}
bool CranesAndTurtles(int n, int tl)
{
    // x+y=n
    // 2*x+4*y=tl
    float x = 0, y = 0;
    x = (4 * n - tl) / 2;
    y = (tl - 2 * n) / 2;
    if(x < 0 || y < 0)
        return false;
    if(!(x + y == n))
        return false;
    if(isInt(x) && isInt(y))
        return true;
        
    return false;
}

int main()
{
    int n, tl;
    cin >> n >> tl;
    if(CranesAndTurtles(n, tl))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	constexpr int num = 26;
	int D;
	vector<int> c(num);
	vector<int> t;
	vector<vector<int>> s; 
	
	cin>>D;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 1);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
	}
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
		}
	}
	
	for(int i = 0; i < D; i++){
		cout<<t[i]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3768
N, M = map(int, input().split())
k_s = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

res = 0
def dfs(i, now):
    global res
    if i == N:
        for j in range(M):
            cnt = 0
            for s in range(k_s[j][0]):
                cnt += now[k_s[j][s+1]-1]
            if cnt % 2 != p[j]:
                break
            if j == M - 1:
                res += 1
    else:
        dfs(i+1, now + [0])
        dfs(i+1, now + [1])

dfs(0, [])

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 

int main() {
   int n; cin >> n;
   vector<int> w(n);
   rep(i,n) cin >> w[i];
   int ans=inf;
   rrep(i,n){
      int l=0,r=0;
      for(int j=0; j<i; j++) l+=w[j];
      for(int j=i; j<n; j++) r+=w[j];
      ans=min(ans,abs(l-r));
   }
   cout << ans << endl;
}



Measured memory_bytes: 256
def gcd(a,b):
    if(a%b==0):
        return b
    else:
        return gcd(b,a%b)
 
k = int(input())
val = [[0]*(k+1) for i in range(k+1)]
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        if(val[i][j] == 0):
            val[i][j] = gcd(i,j)
        for l in range(1,k+1):
            if(val[val[i][j]][l] == 0):
                val[val[i][j]][l] = gcd(val[i][j],l)
            sum = sum + val[val[i][j]][l]
 
print(sum)

Measured memory_bytes: 71144
s = input()
if s == 'SUN':
  s = 7
elif s == 'MON':
  s = 6
elif s == 'TUE':
  s = 5
elif s == 'WED':
  s = 4
elif s =='THU':
  s = 3
elif s == 'FRI':
  s = 2
elif s == 'SAT':
  s = 1
print(s)

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

typedef unsigned long long ll;

ll calc()
{
  ll a, b, x;
  ll ad, am, bd;
  std::cin >> a >> b >> x;

  ad = a / x;
  am = a % x;
  bd = b / x;

  if (am == 0)
    return bd - ad + 1;
  else
    return bd - ad;
}

int main(void)
{
  std::cout << calc() << std::endl;
  return 0;
}


Measured memory_bytes: 256
def miller_rabin(n):
    """ primality Test
        if n < 3,825,123,056,546,413,051, it is enough to test
        a = 2, 3, 5, 7, 11, 13, 17, 19, and 23.
        Complexity: O(log^3 n)
    """
    assert(n >= 1)
    if n == 2:
        return True
    if n <= 1 or not n & 1:
        return False

    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]

    d = n - 1
    s = 0
    while not d & 1:
        d >>= 1
        s += 1

    for prime in primes:
        if prime >= n:
            continue
        x = pow(prime, d, n)
        if x == 1:
            continue
        for r in range(s):
            if x == n - 1:
                break
            if r + 1 == s:
                return False
            x = x * x % n
    return True


X = int(input())
while True:
    if miller_rabin(X):
        print(X)
        break
    X += 1


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		double c=1.0*a/b;
		System.out.println(a/b+" "+a%b+" "+String.format("%.5f",c));
	}
}

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

using namespace std;

const int NS = (int)1e5 + 4;
int N, k;

int main(){
    scanf("%d %d", &N, &k);
    int ans = 0;
    while(N--){
        int num; scanf("%d", &num);
        ans += num >= k;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_b
//B - Different Distribution
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N; cin>>N;
    vector<pair<ll,ll>> abn(N);
    for(auto&& ab:abn){
        cin>>ab.first>>ab.second;
    }
    sort(abn.begin(),abn.end());
    auto b=*(abn.end()-1);
    cout<<(b.first+b.second)<<endl;
    return 0;
}

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

using namespace std;
#define ll long long

int main() {
  int N, M;
  cin >> N >> M;
  
  bool broken[N+1] = {false}; // 壊れていたらtrue, そうでなければfalse 
  
  // 壊れているところをtrueにへんこうする
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    broken[x] = true;
  }
  
  
  vector<ll> dp(N+1, 0);
  dp[0] = 1;
  dp[1] = 1;
  if (broken[1]) {
    dp[1] = 0; // dp[0], dp[1]: 初期値設定
  }
  for (int i = 1; i < N; i++) {
    if (broken[i+1]) {
      dp[i+1] = 0;
      continue;
    }
    dp[i+1] = (dp[i] + dp[i-1]) % 1000000007;
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1152
n=int(input())
A=list(map(int,input().split()))
#dpテーブルの初期化
#最小化問題
dp=[10*18]*n
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):

    ans1=dp[i-2]+abs(A[i]-A[i-2])
    ans2=dp[i-1]+abs(A[i]-A[i-1])

    dp[i]=min(ans1,ans2)

print(dp[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i,j;
    int m,f,r,sum;
    int a[100][3] ={0};

    /* 成績の読み込み */
    for(i=0;;i++){
        scanf("%d %d %d",&m,&f,&r);

        if(m == -1 && f == -1 && r == -1)
        {
            break;
        }
        else
        {
            a[i][0] = m;
            a[i][1] = f;
            a[i][2] = r;
        }
    }

    /* 結果の出力 */
    for(j=0;j<i;j++){

        m = a[j][0];
        f = a[j][1];
        r = a[j][2];
        sum = m + f;

        /* 中間試験、期末試験のいずれかを欠席 */
        if(m == -1 || f == -1){
            printf("F\n");
        }

        else if(sum >= 80){
            printf("A\n");
        }

        else if(sum >= 65){
            printf("B\n");
        }

        else if(sum >= 50){
            printf("C\n");
        }

        else if(sum >= 30){
            if(r >= 50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }

        else{
            printf("F\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2676
let _ = Scanf.sscanf (read_line ()) "%d %d" (fun a b ->
  match a with
  | a when a > 9 -> print_endline "-1"
  | _ -> 
    match b with
    | b when b > 9 -> print_endline "-1"
    | _ -> print_endline (string_of_int (a * b))
)

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int count = 0;
    while(1)
    {
        bool flag = true;
        for(int i = 0; i < N; i++)
        {
            if (A[i] % 2 != 0)
            {
                flag = false;
                break;
            }
        }
       if (flag == false)
            break;

        for (int i = 0; i < N; i++)
        {
            A[i] = A[i] / 2;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/*
 * Created by SharpDevelop.
 * User: michiyo
 * Date: 2013/08/02
 * Time: 12:13
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sets = int.Parse(Console.ReadLine());
			foreach(var i in Enumerable.Range(1, sets))
			{
				int a = 0;
				int b = 0;
				var arr = Console.ReadLine().Split(' ').Select(j => int.Parse(j));
				bool success = true;
				foreach(var ball in arr)
				{
					if(ball > a || ball > b)
					{
						int aa = ball - a;
						int bb = ball - b;
						if(aa < 0)
							aa = int.MaxValue;
						if(bb < 0)
							bb = int.MaxValue;
						if(aa <= bb)
						{
							a = ball;
						}
						else
						{
							b = ball;
						}
					}
					else
					{
						success = false;
						break;
					}
				}
				Console.WriteLine(success ? "YES" : "NO");
			}
		}
	}
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      int nm = -1, gm = -1;
      while(cin >> s){
            if(nm < (int)s.length()){
                  nm = (int)s.length();
                  nmax = s;
            }
            if(m.count(s))m[s]++;
            else m[s] = 0;
      }
      for(auto it = m.begin(); it != m.end(); it++){
            if(gm < it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}



Measured memory_bytes: 3132
//
// Created by yamunaku on 2020/05/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    }else if(k <= a + b){
        cout << a << endl;
    }else{
        cout << a - (k - a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 2005;
const int MM = 1000000007;

int A[MX][MX], B[MX][MX], C[MX][MX];
int main()
{
	int N, M, Q;
	scanf("%d%d%d", &N, &M, &Q);
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++) scanf("%1d", C[i]+j);
	}
	for(int i = 1; i+1 <= N; i++){
		for(int j = 1; j <= M; j++){
			if( C[i][j] && C[i][j] == C[i+1][j] ) A[i][j] = 1;
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j+1 <= M; j++){
			if( C[i][j] && C[i][j] == C[i][j+1] ) B[i][j] = 1;
		}
	}

	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			A[i][j] += A[i][j-1] + A[i-1][j] - A[i-1][j-1];
			B[i][j] += B[i][j-1] + B[i-1][j] - B[i-1][j-1];
			C[i][j] += C[i][j-1] + C[i-1][j] - C[i-1][j-1];
		}
	}

	for(int t = 1; t <= Q; t++){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int x = C[c][d] - C[c][b-1] - C[a-1][d] + C[a-1][b-1];
		int y = A[c-1][d] - A[c-1][b-1] - A[a-1][d] + A[a-1][b-1];
		int z = B[c][d-1] - B[c][b-1] - B[a-1][d-1] + B[a-1][b-1];

//		printf("%d %d %d\n", x, y, z);

		printf("%d\n", x - y - z);
	}
}


Measured memory_bytes: 48896
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s1: chars,
        s2: chars,
        s3: chars
    }
    println!("{}{}{}", plus(&s1), plus(&s2), plus(&s3));
}

fn plus(s: &[char]) -> char {
    let d = b'a' - b'A';
    (s[0] as u8 - d) as char
}

Measured memory_bytes: 4352