akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const Mod = int(1e9 + 7)

var dp [101][4][4][4]int

func main() {
	var N int
	fmt.Scan(&N)
	dp[0][3][3][3] = 1
	for n := 0; n < N; n++ {
		for c1 := 0; c1 < 4; c1++ {
			for c2 := 0; c2 < 4; c2++ {
				for c3 := 0; c3 < 4; c3++ {
					if dp[n][c1][c2][c3] == 0 {
						continue
					}
					// 追加する文字
					for a := 0; a < 4; a++ {
						if a == 2 && c1 == 1 && c2 == 0 {
							continue
						}
						if a == 2 && c1 == 0 && c2 == 1 {
							continue
						}
						if a == 1 && c1 == 2 && c2 == 0 {
							continue
						}
						if a == 2 && c1 == 1 && c3 == 0 {
							continue
						}
						if a == 2 && c2 == 1 && c3 == 0 {
							continue
						}
						// ダメな条件を抜けたらaを足した文字列が作れる
						// now  = ...... c3 c2 c1
						// next = ...... c3 c2 c1 a
						dp[n+1][a][c1][c2] += dp[n][c1][c2][c3]
						dp[n+1][a][c1][c2] %= Mod
					}
				}
			}
		}
	}
	ans := 0
	for c1 := 0; c1 < 4; c1++ {
		for c2 := 0; c2 < 4; c2++ {
			for c3 := 0; c3 < 4; c3++ {
				ans += dp[N][c1][c2][c3]
				ans %= Mod
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1884
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int pre[N],suf[N],d[N];
int main()
{
	int n=gi(),i,m;
	pre[1]=gi();
	for (i=1;i<=n;i++) d[i]=gi();
	for (i=1;i<n;i++)
		pre[i+1]=min(pre[i],abs(pre[i]-d[i]));
	suf[n]=1;
	for (i=n;i>1;i--)
		suf[i-1]=(suf[i]<<1)<=d[i]?suf[i]:d[i]+suf[i];
	m=gi();
	while (m--) {
		i=gi();
		puts(pre[i]>=suf[i]?"YES":"NO");
	}
	return 0;
}


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

int main(){
    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    if((x1<x2&&y1<=y2)||(x1<=x2&&y1<y2)){
        x3=x2-abs(y2-y1);
        y3=y2+abs(x2-x1);
        x4=x3-abs(x2-x1);
        y4=y3-abs(y2-y1);
    }else if(x1>x2&&y1<=y2){
        x3=x2-abs(y2-y1);
        y3=y2-abs(x2-x1);
        x4=x3+abs(x2-x1);
        y4=y3-abs(y2-y1);
    }else if(x1<=x2&&y1>y2){
        x3=x2+abs(y2-y1);
        y3=y2+abs(x2-x1);
        x4=x3-abs(x2-x1);
        y4=y3+abs(y2-y1);
    }else{
        x3=x2+abs(y2-y1);
        y3=y2-abs(x2-x1);
        x4=x3+abs(x2-x1);
        y4=y3+abs(y2-y1);
    }
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
num=[0 for _ in range(n)]
for i in range(m):
    s,c=map(int,input().split())
    if num[s-1]!=0:
        if num[s-1]!=c:
            print(-1)
            exit(0)
        else:
            pass
    elif s==1 and c==0 and n!=1:
        print(-1)
        exit(0)
    else:
        num[s-1]=c
if n!=1 and num[0]==0:
    num[0]=1
elif n==1 and num[0]==0:
    print(0)
    exit(0) 
print(*num,sep="")

Measured memory_bytes: 3064
/*
 ============================================================================
 Name        : selectionsort.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>


int selectionSort(int a[100],int n){
	int kaisuu=0;
	int j,i;
	int minj;
	int tmp;
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
			}
		}
		tmp=a[i];
		a[i]=a[minj];
		a[minj]=tmp;
		if(i!=minj){kaisuu++;
		}}
	return kaisuu;
}

int main(void) {

	int n;
	int koukankaisuu=0;
	int a[100];
	scanf("%d",&n);
	int i=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	koukankaisuu=selectionSort(a,n);

	printf("%d",a[0]);
	for(i=1;i<n;i++){
		printf(" %d",a[i]);
	}
	printf("\n%d\n",koukankaisuu);

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B; cin >> A >> B;

	int res = -INF;
	res = max(res, A + B);
	res = max(res, A - B);
	res = max(res, A * B);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

ll powll(ll n,ll k){ ll ret=1; while(k){ if(k&1)ret=ret*n; n=n*n; k>>=1; } return ret; }


int main(){
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1){
    cin >> a[i];
  }
  if(n==0 && a[0]==1){ cout << 1 << endl; return 0; }
  if(n==0 && a[0]!=1){ cout << -1 << endl; return 0; }
  if(a[0]!=0){ cout << -1 << endl; return 0; }

  vector<ll> b(n+1,longinf); //limit
  b[0]=1;
  REP(i,1,n+1){
    if(b[i-1]<1e17){
      b[i] = b[i-1]*2 - a[i];
      if(b[i]<0){ cout << -1 << endl; return 0; }
    }
  }

  ll ans = a[n];
  ll pre = a[n];
  for(int i=n-1; i>=0; i--){
    if(pre>b[i]){
      ans += b[i]+a[i];
      pre = b[i]+a[i];
    } else {
      ans += pre+a[i];
      pre += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
const int maxn=2e5+5;
ll t,n,a[maxn],b[maxn],ans;
signed main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
    ans=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=n; i>=1; i--)
    {
        b[i]=(b[i+1]+a[i])%mod;
    }
    for(int i=1; i<=n-1; i++)
    {
        //cout<<a[i]<<' '<<b[i+1]<<endl;
        ans=(ans+(a[i]*b[i+1])%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 6724
#include <iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a > b){
    cout << '0' << endl;
  }else if(b / a > c){
    cout << c << endl;
  }else{
    int ans = b / a;
    cout << ans << endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()	
{
    showoff;
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << 2*3.141592653589793238*r;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3804
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, ans=0, tmp1=0, tmp2=0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++) {
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a, a+n);
    if(n%2==1) {
        for(i=0; i<n; i++)
            ans += abs(a[i]-a[(n-1)/2]);
    }else {
        for(i=0; i<n; i++) {
            tmp1 += abs(a[i]-a[n/2]);
            tmp2 += abs(a[i]-a[n/2-1]);
        }
        ans = min(tmp1, tmp2);
    }
    cout << ans << endl;
}


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

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll d = (c-a-b);
    bool e = (4*a*b < d*d);

    if(e && d>0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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 fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m; cin>>n>>m;
	priority_queue<double> pq;
	double t;
	For(i,0,n-1){
		cin>>t;
		pq.push(t);
	}
	For(i,0,m-1){
		pq.push(pq.top()/2.0);
		pq.pop();
	}
	int ans=0;
	while(!pq.empty()){
		ans+=int(pq.top());
		pq.pop();
	}
	cout<<ans<<"\n";
	return 0;
}





























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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

const int MAX_V = 10e4;

struct edge{int to,cap,rev;};

std::vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]= true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow =0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow += f;
  }
}

int gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}

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

  while(true){
  for(int i=0;i<MAX_V;i++) {
    G[i].erase(G[i].begin(), G[i].end());
    used[i]=false;
  }
  int m,n;
  cin >> m >> n;
  if(m==0 && n==0) break;
  bool can[1000][1000];//can[i][j]:b[i]???r[j]?????????????????????
  int b[1000],r[1000];
  for(int i=1;i<=m;i++) cin >> b[i];
  for(int i=1;i<=n;i++) cin >> r[i];
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      can[i][j] = (gcd(b[i],r[j])>1);
    }
  }
  int s=m+n+1,t=s+1;

  for(int i=1;i<=m;i++){
    add_edge(s,i,1);
  }

  for(int i=1;i<=n;i++){
    add_edge(m+i,t,1);
  }

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(can[i][j]){
        add_edge(i,m+j,1);
      }
    }
  }
  cout << max_flow(s,t) << endl;
}
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,k;
    cin>>n>>k;
    vi d(k);
    vvi a(k);
    rep(i,k){
        cin>>d[i];
        rep(j,d[i]){
            int tmp;
            cin>>tmp;
            a[i].push_back(tmp);
        }
    }

    vi sunuke(n);

    rep(i,k){
       rep(j,d[i]){
           sunuke[a[i][j]-1]++;
       }
    }

    int ans=0;
    rep(i,n){
        if(sunuke[i]==0)ans++;
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var tmp = N;
            var sum = 0;

            while (tmp > 0)
            {
                sum += tmp % 10;
                tmp /= 10;
            }
            Console.WriteLine(N%sum==0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const ll N = 1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

int main(){
    ll r;
    cin>>r;
    printf("%.20lf\n",2*r*pi);
}


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

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; }

using ll = long long;

int pow(int x, int y) {
    if (y == 0) return 1;
    int X = 1;
    for (int i = 0; i < y; i++) {
        X *= x;
    }
    return X;
}

bool memo[10];

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(N);
  bool can = true;
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    if(!memo[x-1]){
      memo[x-1] = true;
      v.at(x-1) = y;
    }
    else if(memo[x-1] && y != v.at(x-1)) {
      can = false;
      break;
    }
  }
  if(can && !memo[0] && N!=1) v.at(0) = 1;
  if(v.size() != 1 && v.at(0) == 0)can = false;
  if(!can) cout << -1 << endl;
  else if(can){
    int ans=0;
    for(int i = 0; i < N; i++) {
      ans += pow(10, N-i-1) * v.at(i);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#1
s = input()
t = input()

if len(s)<=10 and len(t)<=11 and (len(s)+1) == len(t):
    flag = True
    for i,j in zip(s,t[:-1]):
        if i != j:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9140
from collections import deque

def solve(S, N, H, W, Ch, Cw, Dh, Dw):
    d = deque()
    
    d.append((Ch, Cw))
    count = 0
    uplr = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    while d:
        tmp = deque()

        while d:
            h, w = d.pop()
            N[h][w] = count
            if h == Dh and w == Dw:
                return count

            for (dh, dw) in uplr:
                if S[h+dh][w+dw] == '.' and N[h+dh][w+dw] == -1:
                    d.append((h+dh, w+dw))
            
            tmp.append((h, w))
        # print(d, tmp)

        while tmp:
            h, w = tmp.pop()
            for dh in range(-2, 3):
                if dh+h < 1 or dh+h > H:
                    continue
                for dw in range(-2, 3):
                    if dw+w < 1 or dw+w > W:
                        continue
                    if S[h+dh][w+dw] == '.' and N[h+dh][w+dw] == -1:
                        d.append((h+dh, w+dw))

        # print(*S, sep='\n')
        # print(*N, sep='\n')
        # print(d, tmp)

        count += 1
    return -1

def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    wall = '#' * (W+2)
    S = [wall] + ['#' + input() + '#' for i in range(H)] + [wall]

    N = [[-1] * (W+2) for i in range(H+2)]
    # print(*S, sep='\n')
    # print(*N, sep='\n')
    # print(H, W, Ch, Cw, Dh, Dw)
    print(solve(S, N, H, W, Ch, Cw, Dh, Dw))

if __name__ == '__main__':
    main()

Measured memory_bytes: 147608
#include<stdio.h>

int main()
{
  int N,A,B,n,n5,n4,n3,n2,n1,X,count;
  
  scanf("%d %d %d",&N,&A,&B);
  
  count=0;
  
  for(n=1;n<N+1;n++)
  {
    n5=n/10000;
    n4=(n-n5*10000)/1000;
    n3=(n-n5*10000-n4*1000)/100;
    n2=(n-n5*10000-n4*1000-n3*100)/10;
    n1=n-n5*10000-n4*1000-n3*100-n2*10;

    X=n1+n2+n3+n4+n5;

    if(X>=A && X<=B)
    {
      count+=n;
    }
  }
  
  printf("%d",count);
  
  return 0;
}

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

using namespace std;

typedef long long ll;

int h, w, n, a[10001], b[100][100];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> h >> w >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int col = 1;
	for(int i = 0; i < h; i++)
		if(i % 2)
			for(int j = w - 1; j >= 0; j--) {
				b[i][j] = col;
				a[col]--;
				if(a[col] == 0) col++;
			}
		else
			for(int j = 0; j < w; j++) {
				b[i][j] = col;
				a[col]--;
				if(a[col] == 0) col++;
			}
	for(int i = 0; i < h; i++, cout << '\n')
		for(int j = 0; j < w; j++)
			cout << b[i][j] << ' ';
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.front() == s.back()) {
        cout << (s.size() % 2 == 0 ? "First" : "Second") << endl;
    } else {
        cout << (s.size() % 2 == 1 ? "First" : "Second") << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

ll calc(string s){
  int n = s.size();
  ll ans = 0;
  rep(i,n){
    int tmp = s[i] - '0';
    ans += tmp*pow(10,i);
  }
  return ans;
}

ll ans(string s){
  reverse(s);
  s.push_back('+');
  int n = s.size();
  string t;
  ll m = 0;
  rep(i,n){
    if(s[i] != '+') t.push_back(s[i]);
    else{
      m += calc(t);
      t = "";
    }
  }
  return m;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int m = pow(2,n-1);
  vector<string> t(m,"");
  rep(i,m){
    rep(j,n){
      t[i].push_back(s[j]);
      bool bit = (i>>j)&1;
      if(bit) t[i].push_back('+');
    }
  }
  ll final_ans = 0;
  for(auto p : t) final_ans += ans(p);
  cout << final_ans << endl;
}

Measured memory_bytes: 256
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return((list(sys.stdin.readline()))[:-1])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,M = LI()
    A = [-1*int(x) for x in sys.stdin.readline().split()]


    heapq.heapify(A)

    for _ in range(M):
        cost = heapq.heappop(A)
        heapq.heappush(A,-1 * ((-1 * cost)//2))

    return(-1 * sum(A))



if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68248
#include<stdio.h>
#include<math.h>
int main(){
  int r;
  double d;
  if (scanf("%d", &r) == 1) {
    d=2*r*M_PI;
    printf("%lf",d);
  }
  else
    printf("Failed to read integer.\n");
  return 0;
}


Measured memory_bytes: 1748
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    int N, K;
    cin >> N >> K;
    int R, S, P;
    cin >> R>> S>> P;
    string T;
    cin >> T;
    vector<bool> ans(N, true);
    rep(i, K) {
        rep(j, N/K + 100) {
            if (j * K + i + K > N-1) break;
            if (T[j*K+i] == T[(j+1)*K+i]) {
                ans[(j + 1) * K + i] = false;
                j++;
            }
        }
    }
    int sum = 0;
    rep(i, N) {
        if (ans[i]) {
            if (T[i] == 'r')sum += P;
            else if (T[i] == 's')sum += R;
            else if (T[i] == 'p')sum += S;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 512
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	A, V := getInt(), getInt()
	B, W := getInt(), getInt()
	T := getInt()

	d := abs(A - B)
	if d == 0 {
		out("YES")
		return
	}
	s := V - W
	if s <= 0 {
		out("NO")
		return
	}
	if d/s == T && d%s != 0 {
		out("NO")
		return
	}
	if d/s > T {
		out("NO")
		return
	}
	out("YES")
}


Measured memory_bytes: 1756
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll t[4];
    t[0] = a * c;
    t[1] = a * d;
    t[2] = b * c;
    t[3] = b * d;
    ll ans = numeric_limits<ll>::min();
    for(auto ta : t)
    {
        ans = max(ans, ta);
    }
    cout << ans << endl;
    return 0;
}


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

int H, W;
string S[50];
int dx[8] = { -1,0,1,-1,1,-1,0,1 };
int dy[8] = { 1,1,1,0,0,-1,-1,-1 };

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}

	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (S[y][x] == '.') {
				int n = 0;
				for (int i = 0; i < 8; i++) {
					int nx = x + dx[i], ny = y + dy[i];
					if (0 <= nx && nx < W && 0 <= ny && ny < H) {
						if (S[ny][nx] == '#') n++;
					}
				}
				S[y][x] = '0' + n;
			}
		}
	}

	for (int i = 0; i < H; i++)cout << S[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t h;
    cin >> h;
    int64_t order = 0;
    rep(i,100000000){
        h /= 2;
        if(h==0){
            break;
        }
        order++;
    }
    int64_t res = 1;
    rep(i,order+1) res *= 2;
    cout << res-1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
        if(n%i==0){
            int t=i,l=n/i,s=1;
            while(l>=10) s++,l/=10;
            return cout<<s<<endl,0;
        }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

int n,a;
scanf("%d %d",&n,&a);

int min=a;
int max=a;
long sum=a;

for(int i=1;i<n;i++){
scanf("%d",&a);
if(min>a){
min=a;
}else if(max<a){
max=a;
}
sum=sum+a;
}

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

return 0;
}






Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
void solve(long long N, long long K, std::vector<long long> h)
{
    vec dp(N, 1e+18);
    dp[0] = 0;
    for (ll i = 0; i < N; i++)
    {
        for (ll k = 1; i + k < N and k <= K; k++)
        {
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << dp[N - 1] << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
ll N;
vector<ll> vec;

//解法
void solve() {

	vector<ll> vec2 = vec;

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

	ll border = (vec2[N / 2] + vec2[N / 2 - 1]) / 2;

	rep(i, N) {

		if (vec[i] <= border) {
			cout << vec2[N / 2] << endl;
		}
		else {
			cout << vec2[N / 2 - 1] << endl;
		}

	}

	return;
}

int main() {
	//入力
	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];
	solve();
	//cout << endl;
	return 0;
}


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

using namespace std;

int main() {
  int N, count = 100;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, c = 0;
    cin >> a;
    while (true) {
      if (a % 2 == 0) {
        c += 1;
        a = a / 2;
      } else {
        break;
      }
    }
    if (c < count) {
      count = c;
    }
  }
  cout << count;
}


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

int main(void){
  int d;
  int sum;
  int x_now;
  cin >> d;
  while(!cin.eof()){
    sum = 0;
    x_now = 0;
    for(int i=600;i!=0;){
      sum += x_now*x_now*d;
      i -= d;
      x_now += d;
    }
    cout << sum << endl;
    cin >> d;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum=0;
//vector<ll> sl;
ll dp[100000];
ll func(ll a[],ll n,ll size,ll k)
{
	ll s;
	if(dp[n]>=0)
	return dp[n];
	else
	{
     ll mini=INT_MAX;
     for(ll i=1;i<=k;i++)
     {
     	if(n>=i)
     	{
		 
     s=dp[n-i]+abs(a[n]-a[n-i]);
     //cout<<"\nghj\n"<<s<<endl;
     if(s<mini)
     mini=s;
     }
     else 
     break;
	 }

	dp[n]=mini;
	if(n+1==size)
	return dp[n];
	else
	return func(a,n+1,size,k);
    }
}
main()
{
	ll n,a[100000],b[100000],k;
	cin>>n>>k;
	memset (dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	
	if(n>2)
	cout<<func(a,2,n,k)<<endl/*5 3
10 30 40 50 20*/;
	else
	cout<<dp[n-1]<<endl;
	/*for(ll i=0;i<n;i++)
	cout<<dp[i]<<"  ";*/
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,v[10000001];
long long ans;

int main(){
	cin >> n;
	for(int i = 2 ; i <= 10000000 ; i += 1){
		for(int j = i ; j <= 10000000 ; j += i){
			v[j] += 1;
		}
	}
	for(int i = 1 ; i <= n ; i += 1){
		ans += (long long)i*(v[i]+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 42704
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long A, long long B, long long C, long long K){
    vector<int> num(3);
    num[0] = A;
    num[1] = B;
    num[2] = C;
    sort(num.begin(), num.end());
    REP(i, K) num[2] *= 2;
    cout << num[0] + num[1] + num[2] << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??°?????????
		while(true){
			//??????????????????
			int H = sc.nextInt();
			//?¨????????????????
			int W = sc.nextInt();
			//?????¶??? ????????¨???0?????´?????????
			if(H == 0 && W ==0){
				break;
			}
			//?¨?????????°?????????
			for(int i = 0; i < H; i++){
				//???????????°?????????
				for(int j = 0; j < W; j++){
					//?????¶??? ??????????????¶??°?????´?????? ?\???°?????´??????
					if((i + j) % 2 == 0){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35136
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D):
    ans = -INF
    ans = max(ans, A * C)
    ans = max(ans, A * D)
    ans = max(ans, B * C)
    ans = max(ans, B * D)


    return ans


def main():
    A, B, C, D = read_int_n()
    print(slv(A, B, C, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78516
#include <bits/stdc++.h>
using namespace std;
int main() {
  int num,ans_a,ans_b,count;
  count=1;
  ans_b=ans_a=0;
  vector<int> v_a,v_b;
  cin>>num;
  vector<int> nums(num);
  for(int i=0;i<num;i++){
  	int tmp=0;
  	cin>>tmp;
  	v_a.push_back(tmp);
  }
  for(int i=0;i<num;i++){
  	int tmp=0;
  	cin>>tmp;
  	v_b.push_back(tmp);
  }
  if(v_a==v_b){
    ans_b=ans_a=0;
  }else{
    iota(nums.begin(), nums.end(), 1);
    if(v_a==nums){
    	ans_a=1;
    }
    if(v_b==nums){
    	ans_b=1;
    }
    while (next_permutation(nums.begin(), nums.end())){
      count++;
      if(v_a==nums&&ans_a==0){
        ans_a=count;
      }
      if(v_b==nums&&ans_b==0){
        ans_b=count;
      }
    }
  }
  cout<<abs(ans_b-ans_a)<<endl;
}

Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0
(0..A).each{|i|
  break if 500*i > X
  (0..B).each{|j|
    break if 500*i + 100*j > X
    (0..C).each{|k|
      wk = 500*i + 100*j + 50*k
      break if wk > X
      (ans += 1; break) if wk == X
    }
  }
}

puts ans


Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int x[100000];
int main(){
    for(int i=1;i <= 10000;i++){
        cin>>x[i];
        if(x[i] == 0){
            break;
        }
        cout << "Case" << " " << i << ": " << x[i] << endl;
        
    }
    return 0;
}


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

int main() {
  int n,m;
  string s;
  cin >> n;
  vector<string> word(200,"");
  vector<int> count(200,0);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for(int j = 0; j < 200; j++) {
      if (s == word.at(j)) {
        count.at(j) += 1;
        break;
      } else if (word.at(j) == "") {
        word.at(j) = s;
        count.at(j) += 1;
        break;
      }
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s;
    for (int j = 0; j < 200; j++) {
      if (s == word.at(j)) {
        count.at(j) -= 1;
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 200; i++) {
    if (ans < count.at(i)) {
      ans = count.at(i);
    }
    //cout << word.at(i) << " " << count.at(i) << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3544
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
from collections import *
from bisect import *
mod = 10**9+7

N = int(input())
b = [int(x) for x in input().split()]
a = [b[0], b[-1]]
for i in range(N-2):
    a.append(min(b[i], b[i+1]))
print(sum(a))


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

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

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

int main() {
    int n;
    while(cin >> n, n){
        vector<pair<int, int>> v;
        for (int i = 0; i < n; ++i) {
            int x, y = 0;
            cin >> x;
            for (int j = 0; j < 4; ++j) {
                int a, b;
                scanf("%d %d", &a, &b);
                y += a*60+b;
            }
            v.emplace_back(y, x);
        }
        sort(v.begin(),v.end());
        printf("%d\n%d\n%d\n", v[0].second, v[1].second, v.end()[-2].second);
    }

    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define ll long long int

int a[]={1,-1,0,0};
int b[]={0,0,1,-1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int h,w,x,y,ans=0;
    cin>>h>>w;
    int adjmat[h*w+2][h*w+2];//adjacency matrix
    char mat[h+2][w+2];//actual graph
    memset(mat,'#',sizeof(mat));//assume nowhere is safe on graph
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            cin>>mat[i][j];
        }

    }//input
    for(int i=0;i<h*w+2;i++)
    {
        for(int j=0;j<h*w+2;j++)
            adjmat[i][j]=9999;
    }//fill adjmat with inf value
    for(int i=0;i<=h*w+1;i++) adjmat[i][i]=0;//fill same vertex distance as 0;
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            for(int p=0;p<4;p++)
            {
                y=j+a[p];
                x=i+b[p];
                if(mat[i][j]=='.' && mat[x][y]=='.') adjmat[(i-1)*w+j][(x-1)*w+y]=1;//convert to adjacency matrix
            }
        }
    }
    for(int k=1;k<h*w+1;k++)
    {
        for(int i=1;i<h*w+1;i++)
        {
            for(int j=1;j<h*w+1;j++)
            {
                adjmat[i][j]=min(adjmat[i][j] , adjmat[i][k]+adjmat[k][j]);//Floyd-Warshall
            }
        }
    }
    for(int i=1;i<h*w+1;i++)
        {
            for(int j=1;j<h*w+1;j++)
            {
                if(adjmat[i][j]!=9999)
                    ans=max(ans,adjmat[i][j]);
            }
        }
    cout<<ans;
}


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

using namespace std;

map<int,vector<int>> matrix;
map<int,int> dp;
set<int> vertices;

int lp(int i)
{
    if(dp[i] != 0)
        return dp[i];
    else{
        dp[i] = 0;
        for(int j = 0; j < matrix[i].size(); j++){
            dp[i] = max(dp[i], lp(matrix[i][j]) + 1);
        }
        return dp[i];
    }
}


void a()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    a();

    int n, m, x, y, ans = 0;
    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> x >> y;
        vertices.insert(x);
        matrix[x].push_back(y);
    }

    set<int> :: iterator itr;
    for(itr = vertices.begin(); itr != vertices.end(); ++itr){
       ans = max(ans, lp(*itr));
    }

    cout << ans;
}


Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    if (B==C) cout << A << "\n";
    else if (A==C) cout << B << "\n";
    else cout << C << "\n";
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n;
	cin >> n;
	int a = n, b = 0;
	while (a) {
		b += a % 10;
		a /= 10;
	}
	if (n%b == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

typedef map<string,vector<int> > P;

int main()
{
    P p;
    string str;
    int t = 0;
    while (cin >> str >> t)
        p[str].push_back(t);
    for (auto it = p.begin(); it != p.end(); it++) {
        sort(it->second.begin(), it->second.end());
        cout << it->first  << endl << it->second[0];
        for (int j = 1; j < it->second.size(); j++)
            cout << " " << it->second[j];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1236
using System;

namespace AtCoder.ABC113
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            
            Console.WriteLine((a + (b / 2)));
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC113.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
struct BIT {
	vector<ll> bit;
	int n;
	BIT(int n) :n(n) {
		bit = vector<ll>(n + 1, 0);
	}
	ll sum(int i) {
		i++;
		ll s = 0;
		while (i > 0) {
			(s += bit[i]) %= MOD;
			i -= i & -i;
		}
		return s;
	}
	ll get(int i) {
		ll ret = sum(i);
		if (i > 0) ret -= sum(i - 1);
		return ret;
	}
	void add(int i, ll x) {
		i++;
		while (i <= n) {
			(bit[i] += x) %= MOD;
			i += i & -i;
		}
	}
};
ll S[100000];
int main() {
	int N;
	ll A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> S[i];
	set<int> addX, addY;
	BIT dpX(N + 1);
	BIT dpY(N + 1);
	dpX.add(0, 1);
	dpY.add(0, 1);
	addX.insert(0);
	addY.insert(0);
	for (int i = 0; i + 1 < N; i++) {
		int j = upper_bound(S, S + (i + 1), S[i + 1] - B) - S;
		ll x = dpX.sum(j);
		int k = upper_bound(S, S + (i + 1), S[i + 1] - A) - S;
		ll y = dpY.sum(k);
		if (S[i + 1] - S[i] < A) {
			for (int elem : addX) {
				ll t = dpX.get(elem);
				dpX.add(elem, -t);
			}
			addX.clear();
		}
		if (S[i + 1] - S[i] < B) {
			for (int elem : addY) {
				ll t = dpY.get(elem);
				dpY.add(elem, -t);
			}
			addY.clear();
		}
		if (x > 0) {
			dpY.add(i + 1, x);
			addY.insert(i + 1);
		}
		if (y > 0) {
			dpX.add(i + 1, y);
			addX.insert(i + 1);
		}
	}
	ll ans = dpX.sum(N);
	(ans += dpY.sum(N)) %= MOD;
	cout << ans << endl;
}

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

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int> t(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    sort(t.begin(),t.end());
    int ans=0;
    for(int i=0;i<n;i++){
        int j=i,cnt=0;
        while(j<n&&t[i]+k>=t[j]&&cnt<c) j++,cnt++;
        i=j-1;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3756
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();            
            var r = true;

            if(s[0] != 'A'){
                r = false;
            }

            var count = 0;
            for(var i = 1; i < s.Length; i++){
                if(char.IsUpper(s[i])){
                    if(s[i] == 'C'){
                        if((i >= 2 && i <= s.Length - 2)){
                            count++;
                        }else{
                            r = false;
                        }
                    }else{
                        r = false;
                    }
                }                
            }
            r = count != 1 ? false : r;

            Console.WriteLine(r ? "AC" : "WA");
        }
    }
}


Measured memory_bytes: 11092
n, x, y = map(int, input().split())
x = x-1
y = y-1
from collections import deque
que = deque()

INF = 10**5
seen = [[INF] * n for _ in range(n)]
#import numpy as np
for i in range(n):
    que.append(i)
    seen[i][i] = 0
    #print('---', i)
    while len(que) > 0:
        t = que.popleft()
        step = [t-1, t+1]
        if t == x:
            step.append(y)
        if t == y:
            step.append(x)
        for ti in step:
            #print(ti)
            if ti < 0 or ti >= n:
                continue
            if seen[i][ti] == INF:
                que.append(ti)
            seen[i][ti] = min(seen[i][t] + 1, seen[i][ti])
    #print(np.array(seen))
#print(np.array(seen))

ans = [0] * n
for i in range(n):
    for j in range(i, n):
        ans[int(seen[i][j])] += 1

for i in range(1, n):
    print(ans[i])


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

/*
  ll n , m ;
  cin >> n >> m ;
  ll a , b , c ;
  cin >> a >> b >> c ;
  vector<ll> A(n) ;
  cout << "Yes" << endl ;
  cout << "No"  << endl ;
*/

int main(){
    ll n ;
    cin >> n  ;
    if(n >= 30 ) cout << "Yes" << endl ;
    else cout << "No"  << endl ;
}


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

int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (auto iter = begin(n); iter < end(n); iter++) {
        sum += *iter - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  ll a, b, c; cin >> a >> b >> c;
  if (c-a-b > 0 && c*c+a*a+b*b-2*a*b-2*a*c-2*b*c > 0) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

// K <= 7なので、全探索
int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    for (int b = 0; b <= K; ++b) {
        for (int c = 0; b + c <= K; ++c) {
            if (A < (B << b) && (B << b) < (C << c)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a+n,greater<int>());
    int sa = 0, sb= 0;
    rep(i, n){
        if (i%2 == 0) sa+=a[i];
        else if (i%2 == 1) sb+=a[i];
    }
    cout << sa - sb << endl;

}

Measured memory_bytes: 3540