akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>


using namespace std;
const int MOD = 1000000009; // check!!!
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

bool b[21][21];

int main(){

	int n;
	while(cin>>n,n){
		memset(b,0,sizeof(b));
		FOR(i,n){
			int x,y; cin>>x>>y;
			b[y][x] = true;
		}
		int sx = 10,sy = 10;
		int m; cin>>m;
		FOR(i,m){
			string s;int p; cin>>s>>p;
			static int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};
			int dir;
			if(s[0] == 'N') dir = 0;
			else if(s[0] == 'E') dir = 1;
			else if(s[0] == 'S') dir = 2;
			else dir = 3;
			if(b[sy][sx]) b[sy][sx] = false,n--;
			FOR(i,p){
				sx += dx[dir],sy += dy[dir];
				if(b[sy][sx]) b[sy][sx] = false,n--;
			}
		}
		puts(n==0?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
using namespace std;
#define LL long long
#define MAX 100005
int n, maxn;
int res[MAX];
LL ans;
int main()
{
    while(~scanf("%d%d", &n, &maxn)){
        ans=0;
        for(int i=1;i<=n;i++)scanf("%d", &res[i]);
        for(int i=2;i<=n;i++){
            int t=res[i]+res[i-1];
            if(t>maxn){
                t-=maxn;
                ans+=t;
                if(res[i]<t){
                    res[i-1]-=t-res[i];
                    res[i]=0;
                }
                else{
                    res[i]-=t;
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();

            Console.WriteLine(s=="ARC"?"ABC":"ARC");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25884
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int N,L;
	scanf("%d %d",&N,&L);

	int* table = new int[N+1];
	int* DEQ = new int[N+1];
	for(int i = 1; i <= N; i++)scanf("%d",&table[i]);

	int left  = 0;
	int right = 0;

	DEQ[0] = 0;
	table[0] = BIG_NUM;

	for(int i = 1;i <= L-1; i++){
		while(right >= 0 && table[i] <= table[DEQ[right]])right--;
		DEQ[right+1] = i;
		right++;
	}

	while(right >= left && table[L] <= table[DEQ[right]])right--;
	DEQ[right+1] = L;
	right++;
	printf("%d",table[DEQ[left]]);

	for(int i = L+1; i <= N; i++){
		if(i-DEQ[left]+1 > L)left++;
		while(right >= left && table[i] <= table[DEQ[right]])right--;
		DEQ[right+1] = i;
		right++;
		printf(" %d",table[DEQ[left]]);
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int a,b;cin >> a >> b;
  int n = b-a;
  int n_sum = n*(n+1)/2;
  cout << n_sum - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a;
    int b;
    int x;
    int y;
    int s;
    int t;
    
    scanf("%d %d", &a, &b);
    
    if(b<0){
        
        x = a - b;
        y = a * b;
        
        // printf("%d\n", x); //debug
        
        if(x>y){
            
            printf("%d", x);
            return 0;
            
        } else {
            
            printf("%d", y);
            return 0;
            
        }
        
    } else {
        
        s = a + b;
        t = a * b;
        
        if(s>t){
            
            printf("%d", s);
            return 0;
            
        } else {
            
            printf("%d", t);
            return 0;
            
        }
        
    }
    
    
}


Measured memory_bytes: 128
i,v,s[5000],m,*p;main(n){for(;~scanf("%d",&n);n&&printf("%d\n",m))for(memset(s,i=0,m=2e4),m=-1e5;i++<n;)for(scanf("%d",&v),p=s+i;p---s;m=*p>m?*p:m)*p+=v;}

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

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

  cout << fixed << setprecision(9) << W * H / 2.0;
  cout << " " << (x + x == W && y + y == H ? 1 : 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,dp[1002][1002],mod=1000000007;
string s;
char g[1002][1002];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(c=1; c<=a; c++){
		cin>>s;
		for(d=0; d<s.size(); d++){
			g[c][d+1]=s[d];
		}
	}
	dp[1][1]=1;
	for(c=1; c<=a; c++){
		for(d=1; d<=b; d++){
			if(c==1&&d==1) continue;
			if(g[c][d]=='#') continue;
			dp[c][d]=dp[c][d-1]+dp[c-1][d];
			dp[c][d]%=mod;
		}
	}
	cout<<dp[a][b];
	return 0;
}

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

typedef long long ll;
const int maxn = 310;
ll dp[maxn][maxn], res;
bool used[maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> dp[i][j];
            used[i][j] = true;
        }
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (dp[i][j] == dp[i][k] + dp[k][j] && i != k && j != k) {
                    used[i][j] = false;
                } else if (dp[i][k] + dp[k][j] < dp[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (used[i][j]) {
                res += dp[i][j];
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[100001];
int qq[100001];
vector<int> a[100001],check;
vector<pair<int,int> >dig;
#define mk make_pair
map<vector<int>,int>visited;
int n,q,x,y;
void digda(int val,int dep){
  if(!dep)qq[dep]=0;
  else if(s[dep]=="T=T|X")qq[dep]=val|x;
  else if(s[dep]=="T=T|Y")qq[dep]=val|y;
  else if(s[dep]=="T=T^X")qq[dep]=val^x;
  else if(s[dep]=="T=T^Y")qq[dep]=val^y;
  else if(s[dep]=="T=T&X")qq[dep]=val&x;
  else if(s[dep]=="T=T&Y")qq[dep]=val&y;
  r(i,a[dep].size())
    digda(qq[dep],a[dep][i]);
}
void digging(){
  dig.push_back(mk(0,1));
  dig.push_back(mk(x,2));
  dig.push_back(mk(y,3));
  dig.push_back(mk(x^y,4));
  dig.push_back(mk(x&y,5));
  dig.push_back(mk(x|y,6));
  dig.push_back(mk(x^(x&y),7));
  dig.push_back(mk(y^(x&y),8));
}
int diggame(int pl,int turn){
  if(a[pl].size()==0)return qq[pl];
  int res;
  if(turn%2){
    res=1e9;
    r(i,a[pl].size())
      res=min(res,diggame(a[pl][i],turn+1));
  }
  else{
    res=0;
    r(i,a[pl].size())
      res=max(res,diggame(a[pl][i],turn+1));
  }
  return res;
}
int main(){
  cin>>n>>q;
  r(i,n-1)cin>>s[i+1];
  r(i,n-1){
    scanf("%d%d",&x,&y);
    a[x].push_back(y);
  }
  while(q--){
    scanf("%d%d",&x,&y);
    dig.clear();
    check.clear();
    memset(qq,0,sizeof(qq));
    digging();
    sort(dig.begin(),dig.end());
    r(i,8)check.push_back(dig[i].second);
    if(visited[check]){
      int di=visited[check];
      if(di==1)cout<<0<<endl;
      else if(di==2)cout<<x<<endl;
      else if(di==3)cout<<y<<endl;
      else if(di==4)cout<<(x^y)<<endl;
      else if(di==5)cout<<(x&y)<<endl;
      else if(di==6)cout<<(x|y)<<endl;
      else if(di==7)cout<<(x^(x&y))<<endl;
      else if(di==8)cout<<(y^(x&y))<<endl;
    }
    else{
      digda(0,0);
      int p=diggame(0,0);
      cout<<p<<endl;
      r(i,8)if(dig[i].first==p)
        visited[check]=dig[i].second;
    }
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
Int dp[1000010][2][2];
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        dp[i+1][0][0] = dp[i][0][0] * 8 % MOD;
        dp[i+1][1][0] = (dp[i][0][0] + dp[i][1][0] * 9) % MOD;
        dp[i+1][0][1] = (dp[i][0][0] + dp[i][0][1] * 9) % MOD;
        dp[i+1][1][1] = (dp[i][1][0] + dp[i][0][1] + dp[i][1][1] * 10) % MOD;
    }
    cout << dp[N][1][1] << endl;
    return 0;
}

Measured memory_bytes: 38180
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/02 21:17:40 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
// int		f(int n, int d)
// {
// 	if (n == 1)
// 		return (0)
// 	else
// 		return ()
// }

void	Main()
{
	int	k, a, b;
	cin >> k >> a >> b;

	if (k == 1)
	{
		cout << "OK" << endl;
		return;
	}
	if ((a - 1) / k < b / k)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3652
n, l = list(map(int, input().split(' ')))

taste = [l + i for i in range(n)]

idx_eaten = -1
if taste[0] <= 0:
    if taste[n-1] < 0:
        idx_eaten = n - 1
    else:
        idx_eaten = -taste[0]
else:
    idx_eaten = 0
    
result = 0
for i in range(n):
    if i == idx_eaten:
        continue
    result += taste[i]
    
print(result)
        
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=105,S=N<<1,M=N*N<<1,inf=2e9;
int b[N][N],c[N][N],col[N*N]; 
struct flow{
	int tot=1,head[S],nxt[M],adj[M],w[M],s,t,dep[S],cur[S],q[S],vis[M];
	inline void addedge(ri x,ri y,ri z){
		nxt[++tot]=head[x];
		adj[head[x]=tot]=y;
		w[tot]=z;
	}
	inline void add(ri x,ri y,ri z){
		addedge(x,y,z);
		addedge(y,x,0);
	}
	inline bool bfs(){
		ri l,r,x,i,y;
		for(i=s;i<=t;++i) dep[i]=0,cur[i]=head[i];
		q[l=r=1]=s;
		dep[s]=1;
		while(l<=r){
			x=q[l++];
			for(i=head[x];i;i=nxt[i]){
				if(!vis[i]&&w[i]&&!dep[y=adj[i]])
					dep[y]=dep[x]+1,
					q[++r]=y;
			}
		}
		return dep[t];
	}
	inline int dfs(ri x,ri now){
		if(x==t) return now;
		ri y,tmp,res=0;
		for(int &i=cur[x];i;i=nxt[i])
			if(!vis[i]&&w[i]&&dep[y=adj[i]]==dep[x]+1&&(tmp=dfs(y,min(now,w[i])))){
				w[i]-=tmp;
				w[i^1]+=tmp;
				res+=tmp;
				if(!(now-=tmp)) return res; 
			}
		return res;
	}
	inline void maxflow(){
		while(bfs())
			dfs(s,inf);
	}
}flow;
vector<int> v[N][N];
int main(){
	ri n,m,i,j,x;
	gi(n);gi(m);
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			gi(x),
			col[x]=(x-1)/m+1,
			v[i][col[x]].push_back(x),
			flow.add(i,n+col[x],1);
	flow.s=0;
	flow.t=n<<1|1;
	for(i=1;i<=n;++i)
		flow.add(flow.s,i,1),
		flow.add(n+i,flow.t,1);
	for(j=1;j<=m;++j){
		for(i=flow.head[flow.s];i;i=flow.nxt[i])
			flow.w[i]=1,flow.w[i^1]=0;
		for(i=flow.head[flow.t];i;i=flow.nxt[i])
			flow.w[i]=0,flow.w[i^1]=1;
		flow.maxflow();
		for(x=1;x<=n;++x)
			for(i=flow.head[x];i;i=flow.nxt[i])
				if(!flow.w[i]&&flow.adj[i]>n&&!flow.vis[i]){
					b[x][j]=v[x][flow.adj[i]-n].back();
					v[x][flow.adj[i]-n].pop_back();
					flow.vis[i]=flow.vis[i^1]=1;
				}
	}
	for(j=1;j<=m;++j)
		for(i=1;i<=n;++i) c[col[b[i][j]]][j]=b[i][j];
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
			print(b[i][j]),putc(' ');
		putc('\n');
	}
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
			print(c[i][j]),putc(' ');
		putc('\n');
	}
	return 0;
}

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

int main() {
  int n,i;
  scanf("%d",&n);
  int t[n+1],x[n+1],y[n+1];
  x[0] = 0;
  y[0] = 0;
  t[0] = 0;
  for (i=0;i<n;i++) {
    scanf("%d %d %d",&t[i+1],&x[i+1],&y[i+1]);
  }
  int mint,chk;
  chk = 0;
  for(i=0;i<n;i++) {
    mint = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(mint > (t[i+1]-t[i])) {
      chk = 1;
      goto LAB;
    } else {
      if ((t[i+1]-t[i]-mint)%2 == 0) {
        chk = 0;
      } else {
        chk = 1;
        goto LAB;
      }
    }
  }
  LAB:
  if(chk==0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


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

bool P[200001];

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

	for (int i = 2; i <= 200000; i++)
	{
		if(P[i])continue;

		for (int j = 2*i; j <= 200000; j += i)
		{
			P[j] = true;
		}
	}

	for (int i = X; i <= 200000; i++)
	{
		if (P[i] == false)
		{
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int INF = 1145141919;

int main() {
	int N, K, V[50];
	long long ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> V[i];
	static long long DPL[110][60][2] = {}, DPR[110][60][2] = {};
	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 60; j++) {
			DPL[i][j][0] = -INF;
			DPL[i][j][1] = -INF;
		}
	}
	DPL[0][0][1] = 0;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N; j++) {
			DPL[i + 1][j][1] = max(DPL[i + 1][j][1], DPL[i][j][0] - V[j - 1]);
			if (j < N) DPL[i + 1][j + 1][0] = max(DPL[i + 1][j + 1][0], DPL[i][j][0] + V[j]);
			if (j < N) DPL[i + 1][j + 1][0] = max(DPL[i + 1][j + 1][0], DPL[i][j][1] + V[j]);
		}
	}
	reverse(V, V + N);
	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 60; j++) {
			DPR[i][j][0] = -INF;
			DPR[i][j][1] = -INF;
		}
	}
	DPR[0][0][1] = 0;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N; j++) {
			DPR[i + 1][j][1] = max(DPR[i + 1][j][1], DPR[i][j][0] - V[j - 1]);
			if (j < N) DPR[i + 1][j + 1][0] = max(DPR[i + 1][j + 1][0], DPR[i][j][0] + V[j]);
			if (j < N) DPR[i + 1][j + 1][0] = max(DPR[i + 1][j + 1][0], DPR[i][j][1] + V[j]);
		}
	}
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= K - i; k++) {
				for (int l = 0; l <= N - j; l++) {
					ans = max(ans, max(DPL[i][j][0], DPL[i][j][1]) + max(DPR[k][l][0], DPR[k][l][1]));
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
object Main extends App{
  override def main(args:Array[String])={
   var S = readLine
   var T = readLine
   var res = true
   if(S.length!=T.length) res= false
   if(res) res = find(S,T)
   if(res) println("Yes")
   else println("No")
  }
  
  
  
  def find(s:String,t:String):Boolean={
    if(s.equals(t)) return true
    var ss = s
    var len = ss.length
    for(i <- 0 until len){
      ss = ss.charAt(len-1) + ss.substring(0,len-1)
      if(ss.equals(t)) return true
    }
    false
  }
}




Measured memory_bytes: 25520
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>

using namespace std;
typedef pair<int, int> P;
typedef vector<P> pairs;
#define ll long long

int main(){
    ll X,Y;
    int N, M, a, b, x, ans = 0;
    cin >> X >> Y;
    while(X <= Y){
        X = 2 * X;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int a[4],b[4];
    int i;
    for(i=0; i<4; i++) {
        scanf("%d", &a[i]);
    }
    for(i=0; i<4; i++) {
        scanf("%d", &b[i]);
    }
    int min=INF;
    int j,k;
    for(i=0; i<=100; i++) {
        for(j=0; j<=100; j++) {
            for(k=0; k<=100; k++) {
                int mm = n - i*b[0]-j*b[1]-k*b[2];
                int plus = (mm>0? (mm+b[3]-1)/b[3]: 0);
                int val = i*a[0]+j*a[1]+k*a[2]+plus*a[3];
                min=MIN(min,val);
                if(plus==0) break;
            }
        }
    }
    printf("%d\n", min);

    return 0;
}




Measured memory_bytes: 2764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
int n,x,k;
string s,a,b,c,d,e;
int main(){
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++) a +='z';
	for(int i=0;i<len;i++) b +='z';
	for(int i=0;i<len;i++) c +='z';
	for(int i=0;i<len;i++) d +='z';
	for(int i=0;i<len;i++) e +='z';
	for(int i=0;i<len;i++){
		x=0;
		string h = "";
		h += s[i];
		if(h<a){
			e=d;
			d=c;
			c=b;
			b=c;
			a=h;
		}
		else if(h>a&&h<b){
			e=d;
			d=c;
			c=b;
			b=h;
		}
		else if(h>b&&h<c){
			e=d;
			d=c;
			c=h;
		}
		else if(h>c&&h<d){
			e=d;
			d=h;
		}
		else if(h>d&&h<e){
			e=h;
		}
		for(int j=i+1;j<len;j++){
			h+=s[j];
			if(h<a){
				e=d;
				d=c;
				c=b;
				b=c;
				a=h;
			}
			else if(h>a&&h<b){
				e=d;
				d=c;
				c=b;
				b=h;
			}
			else if(h>b&&h<c){
				e=d;
				d=c;
				c=h;
			}
			else if(h>c&&h<d){
				e=d;
				d=h;
			}
			else if(h>d&&h<e){
				e=h;
			}
		}
	}
	scanf("%d",&k);
	if(k==1) cout<<a<<endl;
	else if(k==2) cout<<b<<endl;
	else if(k==3) cout<<c<<endl;
	else if(k==4) cout<<d<<endl;
	else if(k==5) cout<<e<<endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  double r = 0;
  for (int i = 1; i <= n; i++) {
    int j = 0;
    for (int d = i; d < k; d *= 2) j++;
    r += pow(0.5, j);
  }
  r /= n;
  cout << fixed << setprecision(9);
  cout << r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int pow(int a, int b);

int main(void)
{
    int n, k, i;

    scanf("%d %d", &n, &k);
    for(i=0; i<n; i++)
        if( n/pow(k, i)<1 )
            break;
    printf("%d", i);

    return 0;
}
int pow(int a, int b)
{
    int ans = 1;
    int base = a;

    while(b)
    {
        if( b&1 )
            ans *= base;
        base *= base;
        b >>= 1;
    }
    return ans;
}


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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    int a, b;
    in(a);
    in(b);
    floop1(i, 3)
    {
        if (i != a && i != b)
        {
            out(i);
        }
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  int n;
  cin >> n;
  vector<int> v(3*n);
  REP(i,3*n)cin >> v[i];
  sort(ALL(v));
  ll res = 0;
  for(int i = n;i < 3*n;i+=2){
    res += v[i];
  }
  cout << res << endl;



  return 0;
}


Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	ans := make(map[int]int, n)
	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				nn := x*x + y*y + z*z + x*y + y*z + z*x
				if nn <= n {
					ans[nn]++
				}
			}
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Fprintln(stdout, ans[i])
	}
}


Measured memory_bytes: 2152
#include <iostream>
#define MOD (int)(1e9+7)
using namespace std;

int main(){
  long power = 1;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++) power = power * (i+1) % MOD;
  cout << power << endl;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

hq, hmod = divmod(h, 2)
wq, wmod = divmod(w, 2)

if(h == 1 or w == 1):
  ans = 1
else:
  ans = hq * w + hmod * (wq + wmod)
  
print(ans)

Measured memory_bytes: 2940
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    while (true) {
        $arr = str_split($line);
        $line = '';
        for ($i = 0, $len = count($arr); $i < $len - 1; $i++) {
            $line = substr($arr[$i] + $arr[$i + 1], -1) . $line;
        }
        if (strlen($line) === 1) {
            echo $line, PHP_EOL;
            break;
        }
    }
}

Measured memory_bytes: 6612
#include<bits/stdc++.h>
using namespace std;
void chkmax(int &x,int y){
	x=x>y?x:y;
}
int dp[310][310][310];
int n,m;
char str[310];
int main(){
//	freopen("D.in","r",stdin);
	scanf("%s",str+1);
	n=strlen(str+1);
	scanf("%d",&m);
	for(int i=1;i<n;i++){
		if(str[i]==str[i+1])
			dp[i][i+1][0]=2;
		else{
			dp[i][i+1][0]=0;
			dp[i][i+1][1]=2;
		}
	}
	for(int i=1;i<=n;i++)
		dp[i][i][0]=1;
	for(int k=0;k<=m;k++){
		for(int l=0;l<n;l++){
			for(int i=1;i+l<=n;i++){
				int j=i+l;
				chkmax(dp[i][j][k+1],dp[i][j][k]);
				if(i>1)
					chkmax(dp[i-1][j][k],dp[i][j][k]);
				if(j<n)
					chkmax(dp[i][j+1][k],dp[i][j][k]);
				if(i>1&&j<n){
					if(str[i-1]==str[j+1])
						chkmax(dp[i-1][j+1][k],dp[i][j][k]+2);
					else
						chkmax(dp[i-1][j+1][k+1],dp[i][j][k]+2);
				}
			}
		}
	}
	printf("%d\n",dp[1][n][m]);
	return 0;
}


Measured memory_bytes: 114560
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int n; cin >> n;
	map<int, int> even, odd;
	rep(i, 0, n / 2) {
		int tmp_e, tmp_o; cin >> tmp_e >> tmp_o;
		even[tmp_e]++; odd[tmp_o]++;
	}
	int key_e, key_o;
	vector<int> max_e(2, 0), max_o(2, 0);
	map<int, int>::iterator e, o;
	for (e = even.begin(); e != even.end(); e++) {
		if (e->second > max_e[0]) {
			max_e[1] = max_e[0];
			max_e[0] = e->second;
			key_e = e->first;
		}
		else if(e->second > max_e[1])max_e[1] = e->second;
	}
	//cout << max_e[0] << " " << max_e[1] << endl;
	for (o = odd.begin(); o != odd.end(); o++) {
		if (o->second > max_o[0]) {
			max_o[1] = max_o[0];
			max_o[0] = o->second;
			key_o = o->first;
		}
		else if (o->second > max_o[1])max_o[1] = o->second;
	}
	//cout << max_o[0] << " " << max_o[1] << endl;
	if (key_e != key_o) {
		cout << (n - max_o[0] - max_e[0]) << endl;
	}
	else {
		cout << (n - max(max_e[0] + max_o[1], max_o[0] + max_e[1])) << endl;
	}


	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
 
using namespace std;
 
void solve()
{
    string s;
    cin >> s;
    int max_level = 0;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'J')
        {
            int countJ = 1;
            int pos = i + 1;
            while(pos < s.size() && s[pos] == 'J')
            {
                ++pos;
                ++countJ;
            }
            if(countJ <= max_level)
            {
                i = pos - 1;
                continue;
            }
            int countO = 0;
            while(pos < s.size() && s[pos] == 'O')
            {
                ++pos;
				++countO;
            }
            if(countJ < countO || countO <= max_level)
            {
                i = pos - 1;
                continue;
            }
            int countI = 0;
            while(pos < s.size() && s[pos] == 'I')
            {
				++pos;
                ++countI;
            }
			i = pos - 1;
            if(countI >= countO)
            {
                max_level = countO;
            }
        }
    }
    cout << max_level << endl;
}
 
int main()
{
    solve();
    return(0);
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a[51],n;
bool check(long long x1,long long x2)
{
    for(long long x=x1;x<=x2;++x)
    {
        long long ans=0;
        for(long long i=1;i<=n;++i)
            ans+=ceil(1.0L*(a[i]+x-n+1)/(n+1));
        if(ans<=x) return true;
    }
    return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    long long l=0,r=1e16+100,mid;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(check(mid*n,mid*n+n-1))
            r=mid-1;
        else
            l=mid+1;
    }
    for(long long i=l*n;i<=l*n+n-1;++i)
        if(check(i,i)) 
        {
            cout<<i<<endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 2e5 + 1;

int n;
int h[MAXN], a[MAXN];
ll T[MAXN];
ll sol;

ll query(int i){
    ll ret = 0;
    while (i > 0){
        ret = max(ret, T[i]);
        i -= i&-i;
    }
    return ret;
}

void add(int i, ll x){
    while (i < MAXN){
        T[i] = max(T[i], x);
        i += i&-i;
    }
}

int main(){

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++){
        ll curr = a[i] + query(h[i]);
        sol = max(sol, curr);
        add(h[i], curr);
    }

    cout << sol;

    return 0;

}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	if (y == 0)return abs(x - y);
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

int main() {
	int k; cin >> k;
	queue<ll>q;
	for (int i = 1; i <= 9; ++i) {
		q.push(i);
	}
	int cnt = 0;
	while (!q.empty()) {
		cnt++;
		ll x = q.front();
		q.pop();
		if (cnt == k) {
			cout << x << endl;
			return 0;
		}
		int key = x%10;
		if (key != 0) {
			q.push(x * 10 + key - 1);
		}
		q.push(x * 10 + key);
		if (key != 9) {
			q.push(10 * x + key+1);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ds := make([]int, n)

	for i := 0; i < n; i++ {
		ds[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ds)))

	c := 0
	last := ds[0] + 1
	for _, d := range ds {
		if d < last {
			last = d
			c++
		}
	}
	fmt.Println(c)
}

func nextInt() int {
	i, err := strconv.Atoi(nextWord())
	pnc(err)
	return i
}

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1776
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 255050

ll n,m,k;
ll a[N],x[N];

vec G[N];
main(){
    n=in();
    ll x=in(),y=in();
    cout<<min(x,y)<<" "<<max(x+y-n,0ll);
}

Measured memory_bytes: 6400
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

ll dp[200005];

void solve()
{
	string s;
	cin >> s;
	ll l = s.length(), ans = 0, base = 0, k = 1;
	ll f[200005] = {1};
	for (ll i = l - 1; i >= 0; --i)
	{
		ll num = s[i] - '0';
		base = (base + k * num) % 2019;
		ans += f[base];
		k = (k * 10) % 2019;
		f[base]++;
	}
	cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("../input.txt", "r", stdin);
	freopen("../output.txt", "w", stdout);
#endif
	fast
	ll t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

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

int main()
{
    int n;
    long long  a[200005];
    while(cin>>n)
    {
        long long  sum=0,lsum=0,rsum,Min=10000000000;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            sum+=a[i];
        }

        for(int i=0; i<n-1; i++)
        {
            lsum+=a[i];
            rsum=sum-lsum;
            if(Min>abs(lsum-rsum))
                Min=abs(lsum-rsum);
        }
        cout<<Min<<endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;
    int sum = a*b;

    if (sum%2 == 0) {
        cout << "Even" << endl;
    }
    else if (sum%2 == 1) {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    A, B = map(int, input().split())
    if 1 <= A <= 9 and 1 <= B <= 9:
        print(A * B)
    else:
        print(-1)


sol()

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int h,w;cin>>h>>w;
    string s[h+2]={""};
    char ans[h][w]={'#'};
    rep1(i,h){string tmp;s[i].push_back('p');cin>>tmp;s[i].append(tmp);s[i].push_back('p');}
    rep(i,s[1].size()){s[0].push_back('p');s[h+1].push_back('p');}
    rep1(i,h)rep1(j,w){
        if(s[i][j]=='.'){
            char sum = '0';
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(s[i+k][j+l]=='#')sum++;
                }
            }
            ans[i-1][j-1]=sum;
        }
        else ans[i-1][j-1]='#';
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int N,ans=0;
  cin>>N;
  vector<int>A(1000010,0);
  rep(i,N){
    int x;
    cin>>x;
    A[x]++;
  }
  for(int i=1;i<=1000000;i++){
    if(A[i]==1){
      ans++;
      int aa;
      aa=i;
      while(aa<1000010){
        A[aa]=0;
        aa+=i;
      }
    }
    else if(A[i]!=0){
      int aa;
      aa=i;
      while(aa<1000010){
        A[aa]=0;
        aa+=i;
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 7216
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n; cin >> n;
	string s; cin >> s;
	string ans;

	ll t = 0;
	rep(i, 0, s.size()) {
		ans += s[i];
		if (s[i] == '(') {
			t++;
		}
		else if (s[i] == ')') {
			t--;
		}

		if (t < 0) {
			ans = '(' + ans;
			t++;
		}
	}
	while (t--) {
		ans += ')';
	}
	cout << ans << endl;
	return 0;
}

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

main(){

  int n,i,j,v,k,h;
  int *m;

  scanf("%d",&n);
  m = malloc(sizeof(int) * n);
  
  for(i = 0 ; i <= n-1 ; i++){
    scanf("%d",&m[i]);
  }
  
  for( i = 0 ; i <= n - 1 ; i++){
    
    v = m[i];
    j = i - 1;
    while(j >= 0 && m[j] > v){
      m[j+1] = m[j];
      j--;
    }
    m[j+1] = v;

    for(h = 0 ; h < n-1 ; h++){
      printf("%d ",m[h]);
    }
    printf("%d\n",m[h]);
  } 
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, ans = 0;
  cin >> N;
  for (int i = 1; i <= N; i++)
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  cout << ans << endl;
}

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

int64_t F[100001];
int N,M;
int64_t L;

int64_t f(int a, int b){
    return (F[b+1]-F[a])/L;
}

int main(){
    cin>>N>>M>>L;
    vector<int64_t> K(N),S(M);
    for(auto &k:K)cin>>k;
    for(auto &s:S)cin>>s;
    for(int i=0;i<M;i++){
        F[i+1]=F[i]+S[i];//(a,b)????????????=(F[b+1]-F[a])/L
    }
    sort(K.begin(), K.end());
    for(auto &k:K)k--;
    int64_t DP[2][N];
    fill(DP[0],DP[2],1000000000000);
    DP[0][0]=0;
    DP[1][0]=f(K[0],K[1]);
    for(int i=1;i<N;i++){
        for(int j=0;j<i-1;j++){
            DP[i&1][j]=DP[i&1^1][j]+f(K[i-1],K[i]);
        }
        for(int k=0;k<i-1;k++){
            DP[i&1][i-1]=min(DP[i&1][i-1],DP[i&1^1][k]+f(K[k],K[i]));
        }
    }
    int64_t ans = 1000000000000;
    for(int i=0;i<N-1;i++){
        ans=min(ans,DP[N&1^1][i]+f(K[i],K[N-1]));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4412
while true    #loop でも使える
m,f,r=gets.split(" ").map(&:to_i)
break if m==-1 && f==-1 && r==-1        #全て欠席[－１]の場合動かない

grade="F"           #グレード化にする
if m == -1 or f == -1   #m or f どっちか　－１の場合(||でもつかえる)

elsif m + f >=80            #値を選べる
    grade= "A"
elsif m + f >=65
    grade= "B"
elsif m + f>=50
    grade="C"
elsif m + f>=30
    if r >= 50               #mとfが３０より大きい場合またｒが５０より大きければ
        grade= "C"          #Cにもどる
    else
        grade= "D"          #じゃなければ　D
    end
end
puts grade                  #最後で結果
end







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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    ll n;
    cin >> n;
    if (n == 1) {
        RET('a');
    }
    string ans;
    while (n > 0) {
        if (n % 26 == 0) {
            ans += 'z';
            n -= 26;
            n /= 26;
        } else {
            ans += char('a' + (n % 26) - 1);
            n /= 26;
        }
    }
    reverse(all(ans));
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
VEC<int> typenum(string s) {
  int n = s.length();
  map<char, int> m;
  REP(i, 0, n) { m[s[i]]++; }
  VEC<int> ans;
  for (char c = 'a'; c <= 'z'; c++) {
    if (m[c] != 0)
      ans.push_back(m[c]);
  }
  return ans;
}
bool vecequ(VEC<int> s, VEC<int> t) {
  REP(i, 0,s.size()) {
    if (s[i] != t[i])
      return 0;
  }
  return 1;
}

int main() {
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << "Yes" << endl;
    return 0;
  }
  int n = s.length();
  VEC<int> st(n, 0), tt(n, 0);
  map<char, int> sm, tm;
  int sc = 0, tc = 0;
  REP(i, 0, n) {
    if (sm[s[i]] == 0) {
      sc++;
      sm[s[i]] = sc;
      st[i] = sm[s[i]];
    }else{
      st[i] = sm[s[i]];
    }
    if (tm[t[i]] == 0) {
      tc++;
      tm[t[i]] = tc;
      tt[i] = tm[t[i]];
    }else{
      tt[i] = tm[t[i]];
    }
  }
  //DUMP(st, tt);
  //sort(ALL(st));
  //sort(ALL(tt));
  Yes(vecequ(st, tt));

  return 0;
}


Measured memory_bytes: 3848