akhauriyash/Code-Regression huggingface dataset:
/*
 *created by Kraken on 12-04-2020 at 17:13
 */
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String s = String.valueOf(sc.nextInt());
        System.out.println(s.contains("7") ? "Yes" : "No");
    }

    static class FastReader {

        BufferedReader br;

        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 32660
#include <iostream>

using namespace std;
int main(){
  int n,i;
  cin>>n;
  int h[n],dp[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M 924844033
ll n,k,dp[2005][2005][2],h[2005],ans,r[2005],p[4005];
void up(ll &x,ll y){x=(x+y)%M;}
int main(void){
    scanf("%lld%lld",&n,&k);
    r[0]=1;
    for(ll i=1;i<=n;i++)r[i]=r[i-1]*i%M;
    for(int i=0;i<min(n,k*2);i++){
		dp[i][0][0]=1;
		if(i>=k)dp[i][1][0]=1;
		if(i+k<n)dp[i][1][1]=1;
	}
	for(int i=0;i<n-k*2;i++){
		for(int j=0;j<=(n+k*2-1)/(k*2);j++){
			up(dp[i+k*2][j][0],dp[i][j][0]+dp[i][j][1]);
			up(dp[i+k*2][j+1][0],dp[i][j][0]);
			if(i+k*3<n)up(dp[i+k*2][j+1][1],dp[i][j][0]+dp[i][j][1]);
		}
	}
	h[0]=1;
	for(int i=max(n-k*2,0LL);i<n;i++){
		for(int j=0;j<4000;j++)p[j]=0;
		for(int j=0;j<=(n+k*2-1)/(k*2);j++){
			ll x=(dp[i][j][0]+dp[i][j][1])%M;
			for(int l=0;l<=n;l++)p[l+j]=(p[l+j]+x*h[l]%M)%M;
		}
		for(int j=0;j<=n;j++)h[j]=p[j];
	}
	for(int i=0;i<=n;i++){
		if(i%2)ans=(ans+M-r[n-i]*h[i]%M)%M;
		else ans=(ans+r[n-i]*h[i])%M;
	}
	printf("%lld\n",ans);
}


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

using namespace std;

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

int main(){
    ll n;
    cin >> n;
    ll a[200005];
    ll b[200005];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+n);
    for(ll i = 0; i < n; i++){
        if(a[i] != b[n-1])cout << b[n-1] << endl;
        else cout << b[n-2] << endl;
    }
    
    return 0;
}

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

int main() {
  int n,m;
  map<string,int> ma;
  cin>>n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin>>s;
    ma[s]++;
  }
  cin>>m;
  for (int i = 0; i < m; ++i) {
    string s;
    cin>>s;
    ma[s]--;
  }
  int mx=0;
  for (const auto &p : ma) {
    mx=max(p.second,mx);
  }
  cout<<mx<<endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 1e9

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a1(n), a2(n);
    REP(i, n)
    cin >> a1[i];
    REP(i, n)
    cin >> a2[i];
    ll res = 0;
    REP(i, n)
    {
        vector<ll> sub1(a1.begin(), a1.begin() + i + 1);
        vector<ll> sub2(a2.begin() + i, a2.end());
        res = max(res, (ll)(accumulate(sub1.begin(), sub1.end(), 0) + accumulate(sub2.begin(), sub2.end(), 0)));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 768
import itertools

N = int(input())

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

D = [[0]*N for i in range(N)]

for i in range(N):
    for j in range(N):
        D[i][j]=((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**0.5

Nn = 1
for i in range(1,N+1):
    Nn*=i

total = 0
for it in itertools.permutations(range(N)):
    s = 0
    for i in range(1,N):
        s+=D[it[i-1]][it[i]]
    total+=s

print(total/Nn)

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

int main() {
    int n;
    int a;
    int minA=0xfffffff, maxA=-0xfffffff;
    long sumA = 0;
    cin >> n;
    
    for (int i = 0; i < n; ++i) {
        cin >> a;
        minA = a < minA ? a : minA;
        maxA = a > maxA ? a : maxA;
        sumA+=a;
    }
    cout << minA << ' ' << maxA << ' ' << sumA << endl;
    
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

int dist[100000];
int a[100000];
vi al[100000];
int N,K;
int r;

int dfs(int i=0,int p=-1) {
	int M=0;
	for (int j:al[i]) if (j!=p) {
		M=max(M,dfs(j,i)+1);
	}
	if (i==0) return 0;
	if (M==K-1 && a[i]!=0) {
		r++;
		a[i]=0;
	}
	if (a[i]==0) M=INT_MIN;
	return M;
}


int main() {
	ios::sync_with_stdio(0);
	cin >> N >> K;
	for (int i=0;i<N;i++) {
		cin >> a[i];a[i]--;
		if (i==0) {
			if (a[i]!=i) {
				r++;
				a[i]=i;
			}
		}
		else {
			al[a[i]].push_back(i);
		}
	}

	dfs();
	cout << r << endl;
}

Measured memory_bytes: 12416
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c = Counter()
for x in a: c[x] += 1
cv = Counter()
for v in c.values(): cv[v] += 1
#print(cv)

def check(x, K):
  t = 0
  for k, v in cv.items(): t += min(k, x) * v
  return t >= K * x

res = [N] * (N + 1)
for K in range(1, N):
  ok = 0
  ng = res[K] + 1
  while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m, K + 1): ok = m
    else: ng = m
  res[K + 1] = ok

for r in res[1: ]: print(r)

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

ll N, M;
vector<ll> A;

int main() {
    cin >> N >> M;
    A.resize(N);
    rep(i, N) cin >> A[i];

    vector<ll> sum(N + 1);
    sum[0] = 0;
    rep(i, N) sum[i + 1] = (sum[i] + A[i]) % M;

    ll ans = 0;
    map<ll, ll> mp;
    rep(i, N + 1) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
        // cout << sum[i] << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
s = input()
n = len(s)

chars = [chr(i) for i in range(97, 97+26)]

res = 1 << 30
for c in chars:
	cnt = 0
	t = s
	while len(set(list(t))) > 1:
		u = []
		for i in range(len(t) - 1):
			if t[i] == c or t[i + 1] == c:
				u.append(c)
			else:
				u.append(t[i])
		cnt += 1
		t = ''.join(u)
	res = min(res, cnt)

print(res)


Measured memory_bytes: 42092
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7<<endl;
    }
    else if(s=="MON"){
        cout<<6<<endl;
    }
    else if(s=="TUE"){
        cout<<5<<endl;
    }
    else if(s=="WED"){
        cout<<4<<endl;
    }
    else if(s=="THU"){
        cout<<3<<endl;
    }
    else if(s=="FRI"){
        cout<<2<<endl;
    }
    else if(s=="SAT"){
        cout<<1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    vector<vector<int> > g;
    int n;
    cin >> n;
    g.resize(n);
    for(int i=0;i<n;i++){
        int v, k;
        cin >> v >> k;
        v--;
        for(int j=0;j<k;j++){
            int u;
            cin >> u;
            u--;
            g[v].push_back(u);
        }
    }
    vector<int> d(n, IINF);
    queue<int> que;
    que.push(0);
    d[0] = 0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto u : g[v]){
            if(d[u] == IINF){
                d[u] = d[v]+1;
                que.push(u);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << i+1 << " " << (d[i] < IINF ? d[i] : -1) << endl;
    }
    return 0;
}



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


int main() {

    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) cout << 'A' << endl;
    else cout << 'B' << endl;
    return 0;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2180

#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int N;
double L;

double X[86400];

bool ok(double M) {
  double hikaku[2];
  double now = L;
  for (int j=0;j<2;j++) {
    for (int i=0;i<86400;i++) { // 単位時間ごとに愚直にたし引き。少しだけ簡単にできるから後で書き直す。
      now = now - X[i] + M;
      if (now > L) {
	now = L;
      } else if (now <= 0) {
	return false;
      }
    }
    hikaku[j] = now;
  }
  if (hikaku[0] <= hikaku[1]) { // 水かさが増えていくなら、
    return true; // 繰り返すたびに溜まっていく。つまり安定。
  } else { // ちょっとでも減っていくなら、
    return false; // やがて枯渇する運命。
  } // どうせ小数点第6位までしか関係ないから、この評価できっと大丈夫。
}

int main() {
  while(scanf("%d%lf",&N,&L) && N) {
    for (int i=0;i<86400;i++) {
      X[i] = 0;
    }
    for (int i=0;i<N;i++) {
      int s,t;
      double u;
      scanf("%d%d%lf",&s,&t,&u);
      for (int i=s;i<t;i++) {
	X[i] = u;
      }
    }
    double lo = 0, hi = 1e6; // sumを求めていなかったから、0からにした。
    while (hi - lo >1e-6) {
      double m = (hi + lo)/2.0;
      if (ok(m)) {
	hi = m;
      } else {
	lo = m;
      }
    }
    printf("%.10f\n",lo);
  }
}

// とりあえずアクセプトされました。

Measured memory_bytes: 1900
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int r;
    cin>>r;
    double c=2*pi*r;
    cout<<fixed<<setprecision(2)<<c<<endl;
    // ()?cout<<""<<endl:cout<<""<<endl;
    
    return 0;
}

Measured memory_bytes: 3760
import sys
readline = sys.stdin.buffer.readline

from collections import deque
import copy

def myinput():
    return map(int,readline().split())

def mycol(data,col):
    return [ row[col] for row in data ]

h,w = myinput()

maze = [ list(input()) for _ in range(h) ]
# print(maze)

white = 0
black = 0
for i in range(h):
    for j in range(w):
        s = maze[i][j]
        if s==".":
            white += 1
        elif s=="#":
            black += 1
        else:
            pass
# print(white)
# print(black)

def bfs(sy,sx):
    q = deque()
    q.append([sy,sx])
    d = [ [float("inf")]*w for _ in range(h) ]
    d[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y==(h-1) and x==(w-1):
            break
        else:
            for i,j in ([0,1],[1,0],[-1,0],[0,-1]):
                ny = y + i
                nx = x + j
                if ny==-1 or nx==-1 or ny==h or nx==w:
                    pass
                elif maze[ny][nx]=="#":
                    pass
                elif d[ny][nx]!=float("inf"):
                    pass
                else:
                    d[ny][nx] = d[y][x] + 1
                    q.append([ny,nx])
    return d[h-1][w-1]

path = bfs(0,0)
# print(path)

if path==float("inf"):
    print(-1)
    exit()
else:
    ans = white - ( path + 1 )
    print(ans)
    exit()

Measured memory_bytes: 40816
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
const int N=200010;
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int a[N],n,sB,sD;
long long ans=(1ll<<60),sum[N];
long long s[5];
long long find2(long long d,int L,int R,long long t){
	int mid;
	while(L<R){
		mid=(L+R)>>1;
		if(sum[mid]-d>t-sum[mid])R=mid;
		else L=mid+1;
	}
	return min(sum[L]-d,t-sum[L-1]);
}
int main()
{
	n=(int)read();
	for(int i=1;i<=n;i++)
	a[i]=read(),sum[i]=sum[i-1]+(long long)a[i];
	for(int mid=2;mid<=n-2;mid++){
		s[1]=find2(0,1,mid,sum[mid]);
		s[2]=sum[mid]-s[1];
		s[3]=find2(sum[mid],mid+1,n,sum[n]);
		s[4]=sum[n]-sum[mid]-s[3];
		sort(s+1,s+5);
		ans=min(ans,s[4]-s[1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>

int main (void) {
    int D, N;
    int result, test;
    scanf("%d%d", &D, &N);

    result = N * pow(100, D);
    test = pow(100, D + 1);
    if ((result % test) == 0) {
        result += pow(100, D);
    }

    printf ("%d", result);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int p[n];
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int count = 0;
    for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i]&&p[i]<=p[i+1]) count++;
        else if(p[i+1]<p[i]&&p[i]<=p[i-1]) count++;
        else if(p[i+1]<p[i]&&p[i+1]==p[i-1]) count++;
    }
    printf("%d",count);
    return 0;
}

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

const int INF = 1e+9;
typedef pair<int, int> P;
typedef pair<int, P> pp;

int N, M;
int DP[1 << 17];

int main() {
	while(cin >> N && N){
		for(int i = 0; i < (1 << N); ++i)
			DP[i] = INF;
		
		int t[32][32];
		for(int i = 0; i < N; ++i){
			scanf("%d", &t[i][0]);
			DP[1 << i] = t[i][0];
			for(int j = 1; j <= N; ++j){
				scanf("%d", &t[i][j]);
			}
		}
		//DP[0] = 0;
		for(int i = 0; i < (1 << N) - 1; ++i){
			for(int j = 0; j < N; ++j){
				if(!((i >> j) & 1)){
					for(int k = 0; k < N; ++k){
						if((i >> k) & 1)
							DP[i | (1 << j)] = min(DP[i | (1 << j)], DP[i] + t[j][k + 1]);
					}
					DP[i | (1 << j)] = min(DP[i | (1 << j)], DP[i] + t[j][0]);
				}
			}
		}
		cout << DP[(1 << N) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1504
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

struct tip1{
    int nod,index;
};

vector <tip1> v[100005];
unordered_set<int> fol[100005];
bool viz[100005];
int col[100005];
int n,k;

void dfs(int nod){
    int j=1;
    for(int i=0;i<v[nod].size();++i){
        if(!viz[v[nod][i].nod]){
            if(col[v[nod][i].index]==0){
                while(fol[v[nod][i].nod].find(j)!=fol[v[nod][i].nod].end() || fol[nod].find(j)!=fol[nod].end())
                    ++j;
                fol[v[nod][i].nod].insert(j);
                fol[nod].insert(j);
                col[v[nod][i].index]=j;
            }
            viz[v[nod][i].nod]=1;
            dfs(v[nod][i].nod);
        }
    }
}

tip1 x;
int i,a,b,nmax;

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<n;++i){
        cin>>a>>b;
        x.nod=b;
        x.index=i;
        v[a].push_back(x);
        x.nod=a;
        v[b].push_back(x);
    }
    for(i=1;i<=n;++i){
        if(v[i].size()>k){
            nmax=i;
            k=v[i].size();
        }
    }
    dfs(nmax);
    cout<<k<<'\n';
    for(i=1;i<n;++i){
        cout<<col[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 22912
#include<stdio.h>
int main(void){
    int a[3],b;
    int i=0;
    scanf("%d",&b);
    a[0]=b/100;
    a[1]=(b-a[0]*100)/10;
    a[2]=(b-a[0]*100-a[1]*10);
    if(a[0]==a[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
   int r,D,x;
   cin >> r >> D >> x;

   for(int i = 0;i < 10;i++){
     x = r*x-D;
     cout << x << endl;
   }
   
 return 0;
}



Measured memory_bytes: 256
import math

X = float(input())

p = 0+0j
d = 1+0j
ans = 0
while True:
  d *= math.cos(X/180.*math.pi)+math.sin(X/180.*math.pi)*1j
  p += d
  ans += 1
  if abs(p)<0.0001:
    break
print(ans)


Measured memory_bytes: 9356
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int V){init(V);}

  void init(int V){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    for(int i=0;i<(int)M.size();i++) M[i].clear();
    M.clear();
    level.clear();
    iter.clear();
    G.resize(V);
    M.resize(V);
    level.resize(V);
    iter.resize(V);
  }
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap>0&&level[e.to]<0){
	  level[e.to]=level[v]+1;
	  que.push(e.to);
	}
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
	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 lim){
    int flow=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return flow;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
	flow+=f;
	lim-=f;
      }
    }
  }

  int max_flow(int s,int t){
    return max_flow(s,t,INF);
  }

//cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
	if(e.cap==0&&max_flow(from,to,1)==0) {
	  max_flow(from,s,1);
	  max_flow(t,to,1);
	  return 1;
	}
      }
    }
    return 0;
  }
};
//END CUT HERE

signed main(){
  int V,E;
  cin>>V>>E;
  Dinic dinic(V);
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    dinic.add_edge(u,v,c);
  }
  cout<<dinic.max_flow(0,V-1)<<endl;
  return 0;
}

/*
verified on 2017/04/22
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/

Measured memory_bytes: 3308
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	String s = "ABC";
 		
      	if(n >= 1000) s = "ABD";
          
      	System.out.println(s);
        
	}
}


Measured memory_bytes: 35772
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 55
int n;
string s[MN];
int t[MN];
string x;

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

    cin >> n;
    F0R(i, n){
        cin >> s[i] >> t[i];
    }
    cin >> x;
    bool ok = false;
    int sm = 0;
    F0R(i, n){
        if(ok == true) sm += t[i];
        if(s[i] == x){
            ok = true;
        }
    }
    cout << sm << "\n";

    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, sz(s)) {
        if (s[i] != t[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
string name(uint64_t n) {
  ostringstream oss;
  const uint64_t B = 26ULL;
  while (n) {
    n--;
    uint64_t d = n % B;
    oss << static_cast<char>(d + 'a');
    n /= B;
  }
  string s = oss.str();
  reverse(begin(s), end(s));
  return s;
}
int main() {
  uint64_t n; cin >> n;
  cout << name(n) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

const int N = 3e3;
int n;
double p;
double dp[N];

int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    memset(dp, 0, sizeof dp);
    dp[0] = 1;

    for (int i = 0; i < n; ++i)
    {
    	cin >> p;
    	for (int j = i + 1; j >= 0; --j)
    		dp[j] = (j == 0 ? 0 : dp[j - 1] * p) + dp[j] * (1 - p);
    }


    double ans = 0;

    for (int i = 0; i <= n; ++i)
    	if (n - i < i)
    		ans += dp[i];

    cout << fixed << setprecision(10) << ans << "\n";

    return 0;
}


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

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> h;
	for (int i=0; i<N;i++) {
		int tmp;
		cin >> tmp ;
		h.push_back(tmp);
	}
	sort(h.begin(), h.end());
	int dh = h[N-1]-h[0]; 
	for (int i=0; i<N-K+1; i++) {
		if (dh>(h[i+K-1]-h[i])) dh = h[i+K-1]-h[i];
	}
	cout << dh << endl;

	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int N, R;
  scanf("%lld%lld", &N, &R);

  std::cerr << "Answer: " << std::endl;
  if(N >= 10){
    std::cout << R << std::endl;
  }
  else{
    std::cout << R + 100*(10-N) << std::endl;
  }

  return 0;
  
  
}


Measured memory_bytes: 256
#include	<iostream>
#include	<deque>
#include	<string>
#include	<algorithm>
#include	<utility>

using namespace std;

typedef pair<int, int>		StartAndArea;

int main()
{
	string			str;
	getline(cin, str);

	deque<int>		st;
	deque<StartAndArea>		areas;
	int				pos = 0;

	for (auto it : str)
	{
		switch (it)
		{
		case '/':
			if (st.size() != 0)
			{
				int		spos = st.front();
				st.pop_front();

				int		area = pos - spos;

				int		cnt = 0;

				for (auto i = 0u; i < areas.size(); i++)
				{
					if (areas[i].first >= spos)
					{
						area += areas[i].second;
						cnt++;
					}
				}

				for (int i = 0; i < cnt; i++)
				{
					areas.pop_front();
				}

				areas.push_front(make_pair(spos, area));
			}
			break;
		case '\\':
			st.push_front(pos);
			break;
		default:
			break;
		}

		pos++;
	}

	int		AnsSum = 0;
	for (auto it : areas)
	{
		AnsSum += it.second;
	}

	cout << AnsSum << "\n";
	cout << areas.size();
	for (int i = static_cast<int>(areas.size() - 1); i >= 0; i--)
	{
		cout << " ";
		cout << areas[i].second;
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    int r = A.end() - lower_bound(A.begin(), A.end(), X);
    int l = A.size() - r;
    cout << min(l, r) << endl;
}

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

template <typename T>
void print(const T &v);

int main()
{
    string s, t;
    cin >> s >> t;
    int s_size = s.size();
    int t_size = t.size();
    vector<vector<int>> dp(s_size + 1, vector<int>(t_size + 1, 0));
    for (int i = 0; i < s_size; i++)
    {
        for (int j = 0; j < t_size; j++)
        {
            int before_maxi = max(dp[i + 1][j], dp[i][j + 1]);

            if (s[i] == t[j])
            {
                if (dp[i][j] + 1 > before_maxi)
                {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                }
                else
                {
                    dp[i + 1][j + 1] = before_maxi;
                }
            }
            else
            {
                dp[i + 1][j + 1] = before_maxi;
            }
        }
    }
    // for (auto line : dp)
    // {
    //     print(line);
    // }
    int len = 0;
    string ans = "";
    int i = s_size;
    int j = t_size;
    while (i > 0 && j > 0)
    {
        if (dp[i][j] == dp[i - 1][j])
        {
            --i;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            --j;
        }
        else
        {
            ans = s[i - 1] + ans;
            --i;
            --j;
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 38904
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

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

  vll as;
  ll now = 1;
  ll cnt = 0;
  rep(i, n) {
    if (s[i] - '0' != now) {
      as.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    } else
      cnt++;
  }  // i
  if (cnt > 0) as.push_back(cnt);
  if (as.size() % 2 == 1) as.push_back(0);

  ll ans = 0;
  ll sum = 0;
  ll add = 2 * k + 1;

  ll left = 0;
  ll right = 0;
  for (ll i = 0; i < (ll)as.size(); i += 2) {
    ll nextleft = i;
    ll nextright = min(nextleft + add, (ll)as.size());
    while (left < nextleft) {
      sum -= as[left];
      left++;
    }
    while (right < nextright) {
      sum += as[right];
      right++;
    }
    chmax(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1528
import fractions
A, B, C, D = map(int, input().split())

gcd = fractions.gcd(C, D)
lcm = C * D // gcd
a_c = (A-1) // C
a_d = (A-1) // D
b_c = B // C
b_d = B // D
a_lcm = (A-1) // lcm
b_lcm = B // lcm
count = (B - A + 1) - ((b_c - a_c) + (b_d - a_d) - (b_lcm - a_lcm))
print(int(count))

Measured memory_bytes: 5048
using System;

class Program
{
    static int N, M, Q = new int();

    static int[,] sum = new int[N + 1, N + 1];

    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        N = int.Parse(array[0]);
        M = int.Parse(array[1]);
        Q = int.Parse(array[2]);

        int[] L = new int[M];
        int[] R = new int[M];

        for (int i = 0; i < M; i++)
        {
            array = Console.ReadLine().Split(' ');
            L[i] = int.Parse(array[0]);
            R[i] = int.Parse(array[1]);
        }

        int[] p = new int[Q];
        int[] q = new int[Q];

        for (int i = 0; i < Q; i++)
        {
            array = Console.ReadLine().Split(' ');
            p[i] = int.Parse(array[0]);
            q[i] = int.Parse(array[1]);
        }

        BuildSumTable(L, R);

        for (int i = 0; i < Q; i++)
        {
            int ans = GetSumRange(p[i], q[i]);
            Console.WriteLine(ans);
        }
    }

    static void BuildSumTable(int[] L, int[] R)
    {
        sum = new int[N + 1, N + 1];

        for (int i = 0; i < M; i++)
        {
            sum[L[i], R[i]]++;
        }

        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                sum[i, j] += sum[i - 1, j];
                sum[i, j] += sum[i, j - 1];
                sum[i, j] -= sum[i - 1, j - 1];
            }
        }
    }

    static int GetSumRange(int L, int R)
    {
        int ans = sum[R, R] - sum[R, L - 1] - sum[L - 1, R] + sum[L - 1, L - 1];
        return ans;
    }
}

Measured memory_bytes: 19096
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>

int main(void)
{

  int n, ans;

  scanf("%d", &n);

  if(n <= 1000) ans = 1000 - n;
  else if(n <= 2000) ans = 2000 - n;
  else if(n <= 3000) ans = 3000 - n;
  else if(n <= 4000) ans = 4000 - n;
  else if(n <= 5000) ans = 5000 - n;
  else if(n <= 6000) ans = 6000 - n;
  else if(n <= 7000) ans = 7000 - n;
  else if(n <= 8000) ans = 8000 - n;
  else if(n <= 9000) ans = 9000 - n;
  else if(n <= 10000) ans = 10000 - n;

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

  return 0;

}


Measured memory_bytes: 1728
/*
	0555:Ring
*/
#include	<iostream>
#include	<string>

using namespace std;

int main(void) {
	string mask;
	int n, c = 0;
	
	cin >> mask >> n;
	for(int i = 0; i < n; i++) {
		string buf;
		
		cin >> buf;
		buf += buf;
		if(buf.find(mask) != string::npos) {
			c++;
		}
	}
	cout << c << endl;
	
	return 0;
}

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

int main(){
  vector<int> A(9);
  for(int i=0; i<9; i++){
    cin >> A.at(i);
  }
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  vector<int> P(9, 0);
  for(int i=0; i<9; i++){
    for(int j=0; j<N; j++){
      if(A.at(i)==B.at(j)){
        P.at(i)=1;
      }
    }
  }
  int Ans=0;
  for(int i=0; i<3; i++){
    if(P.at(3*i)*P.at(3*i+1)*P.at(3*i+2)!=0){
      Ans=1;
    }
    if(P.at(i)*P.at(i+3)*P.at(i+6)!=0){
      Ans=1;
    }
  }
  if(P.at(0)*P.at(4)*P.at(8)!=0 || P.at(2)*P.at(4)*P.at(6)!=0){
    Ans=1;
  }
  if(Ans==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; i++)
		cin >> x[i];

	vector<int> ways(N);
	
	for (int j = 0; j < N; j++)
		ways[j] = 0;
		
	ways[0] = 2;

	long long start = 0;
	for (int i = 2; i < N; i++)
	{
		if (i - (x[i - 1] + 1) / 2 > start)
			start++;
		ways[start]++;
	}

	for (int i = 1; i < N; i++)
		ways[i] += ways[i-1];

	long long result = ways[0];
	for (int j = 1; j < N; j++)
		result = (result * (ways[j] - j)) % 1000000007;

	cout << result;

	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
x = gets.chomp.split(" ").map(&:to_i)
y = x.sort
b = y[n/2-1..n/2]
n.times do |i|
  if x[i] <= b[0]
    puts b[1]
  else x[i] >= b[1]
    puts b[0]
  end
end

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   string S;
   cin >> S;
   vector<int> A;
   for (char c : S) A.emplace_back(c - '0');
   reverse(A.begin(), A.end());
   {
      vector<int> B;
      int rm = 0;
      for (int i = 0; i < A.size(); ++i) {
         int cur = rm + A[i] * 9;
         rm = (cur / 10);
         B.emplace_back(cur % 10);
      }
      if (rm) B.emplace_back(rm);
      A = B;
   }
   int add = 0;
   int sum = 0;
   for (int v : A) sum += v;
   while (add < sum) {
      ++add;
      for (int i = 0; ; ++i) {
         if (i >= int(A.size())) {
            A.emplace_back();
         }
         if (A[i] == 9) {
            sum -= 9;
            A[i] = 0;
         } else {
            ++A[i]; ++sum; break;
         }
      }
   }
   cout << (add + 8) / 9 << "\n";
   return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    map<char, int> used;
    int M = S[0].size();
    rep(i, M) {
        char t = S[0][i];
        int cnt = used[t];
        cnt++;
        bool ok = true;
        rep2(j, 1, N) {
            string s = S[j];
            int c = 0;
            rep(k, s.size()) {
                if (s[k] == t) c ++;
            }
            if (cnt > c) {
                ok = false;
            }
        }
        if (ok) {
            used[t] = cnt;
        }
    }
    string ans = "";
    for (auto x : used) {
        rep(i, x.second) {
            ans += x.first;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		String S = scan.next();
		String T = scan.next();
		scan.close();
		if(S.charAt(0) != T.charAt(0)) {
			System.out.println(-1);
			System.exit(0);
		}
		if(N == M) {
			if(S.equals(T)) {
				System.out.println(N);
			}else {
				System.out.println(-1);
			}
			System.exit(0);
		}
		long l = lcm((long)N, (long)M);
		long g = gcd((long)N, (long)M);
		if(g == 1) {
			System.out.println(l);
			System.exit(0);
		}
		int L = (int)l;
		Map<Integer, Integer> map1 = new HashMap<Integer, Integer>();
		Map<Integer, Integer> map2 = new HashMap<Integer, Integer>();
		for(int i = 1; i < N; i++) {
			int t = i * (L / N) + 1;
			map1.put(t, i);
		}
		for(int i = 1; i < M; i++) {
			int t = i * (L / M) + 1;
			map2.put(t, i);
		}


		for(int k : map1.keySet()) {
			if(map2.containsKey(k)) {
				int t1 = map1.get(k);
				int t2 = map2.get(k);
				if(S.charAt(t1) != T.charAt(t2)) {
					System.out.println(-1);
					System.exit(0);
				}
			}
		}
		for(int k : map2.keySet()) {
			if(map1.containsKey(k)) {
				int t1 = map1.get(k);
				int t2 = map2.get(k);
				if(S.charAt(t1) != T.charAt(t2)) {
					System.out.println(-1);
					System.exit(0);
				}
			}
		}
		System.out.println(L);
//		int k1 = (M - 1) * L / M + 1;
//		int k2 = (N - 1) * L / N + 1;
//		if(k1 > L || k2 > L) {
//			System.out.println(2 * L);
//		}else {
//			System.out.println(L);
//		}

	}
	static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
}

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

int main(){
  int a;
  scanf("%d",&a);
  int b[a];
  for(int i=0; i<a;i++){
    scanf("%d",&b[i]);
  }
  
  int max = b[0];
  for(int j=1;j<a;j++){
    if(max<b[j]) max=b[j];
  }
  
  int sum = 0;
  for(int k=0;k<a;k++){
    sum += b[k];
  }
  
  if(2*max < sum){
    printf("Yes");
  }else{
    printf("No");
  }
}

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

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	int B[M];
	int A[N][M];
	for(int i = 0; i < M; i++) cin >> B[i];
	for(int i = 0; i < N; i++) for(int j = 0; j < M; j++){
		cin >> A[i][j];
	}
	int res = 0;
	int sum;
	for(int i = 0; i < N; i++){
		sum = 0;
		for(int j = 0; j < M; j++){
			sum += A[i][j] * B[j];
		}
		sum += C;
		if(sum > 0) res++;
	}
	cout << res << endl;
}


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

signed main() {
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a == b and b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;

    ll c = gcd(n, m);
    if(c == 1)
    {
        if(s[0] == t[0]) cout << n * m << endl;
        else cout << -1 << endl;
    }
    else
    {
        ll ans = n * m / c;
        ll x = ans / n;
        ll y = ans / m;
        while(true)
        {
            if(y >= n || x >= m) break;
            if(s[y] != t[x])
            {
                cout << -1 << endl;
                return 0;
            }
            x += ans / n;
            y += ans / m;
        }
        cout << ans << endl;
    }
}



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

int main()
{
	int N;
	cin >> N;
	int bricks = 0;
	int current = 1;
	for (int i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		if (a == current)
			current++;
		else
			bricks++;
	}
	
	if (bricks == N)
		cout << -1 << '\n';
	else
		cout << bricks << '\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string x,str,stri,strin;
    int m,h;
    while(1){
      cin>>x;
      if (x == "-") break;
      cin>>m;
      for(int i = 0;i<m;i++){
          cin>>h;
          str = x.substr(0,h);
          stri = x.erase(0,h);
          x = stri + str;
      }
      cout<<x<<endl;
    }

}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
    string s,t;cin>>s>>t;
    if(s.length()+1==t.length()){
    	for(int i=0;i<s.length();i++){
    		if(s[i]!=t[i]){
    			cout<<"No"<<endl;return 0;
			}
		}
		
		cout<<"Yes"<<endl;return 0;
	}
    
    cout<<"No"<<endl;
	return 0;
}

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

void solve();

int k, s;

int main() {
  cin >> k >> s;

  solve();

  return 0;
}

void solve() {
  int cnt = 0;

  for(int x=0; x<=k; ++x) {
    for(int y=0; y<=k; ++y) {
      int z = s-x-y;
      if(z<=k && z>=0) cnt += 1;
    }
  }

  cout << cnt << endl;

}

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

int main() {

	char input;
	
	cin >> input;
	
	if(isupper(input)) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}
	
	return 0;

}


Measured memory_bytes: 3556
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EOrand {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k, s, t;  cin >> n >> k >> s >> t;
      vector<ll> v;
      rep(i, n) {
        ll a; cin >> a;
        if ((a&s) == s && (a|t) == t) {
          v.push_back(a);
        }
      }

      int vs = v.size();
      vector<vector<ll>> comb(vs+1, vector<ll>(vs+1));
      comb[0][0] = 1;
      rep(i, vs) {
        rep(j, vs) {
          comb[i+1][j] += comb[i][j];
          comb[i+1][j+1] += comb[i][j];
        }
      }

      int r = 1<<18;
      int u = s^t;

      vector<int> dp(r);
      vector<int> used;

      ll ans = 0;
      rep(i, r) {
        if ((i&u) != i || (i|u) != u) continue;

        for(auto e: v) {
          dp[e&i]++;
          used.push_back(e&i);
        }

        ll ng = 0;
        for(auto e: used) {
          int d = dp[e]; dp[e] = 0;
          for(int j=1; j<=min(d, k); j++) {
            ng += comb[d][j];
          }
        }
        used.clear();

        int cnt = __builtin_popcount(i);
        if (cnt%2 == 0) {
          ans += ng;
        } else {
          ans -= ng;
        }
      }

      cout << ans << endl;
    }
};

signed main() {
  EOrand solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	string s;
	cin >> n >> s;
	if(n%2==1) cout << "No" << endl;
	else{
		int k=n/2;
		if(s.substr(0, k)==s.substr(k, k)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
#define int long long
int a,b,ma;
vector <int> vec;
signed main(){
	a = read(); b = read();
	for(int i = 1; i <= sqrt(b); i++)
	{
		if(b % i == 0)
		{
			vec.push_back(i);
			vec.push_back(b / i);
		}
	}
	for(int i = 0; i < vec.size(); i++)
		if(a * vec[i] <= b && vec[i] > ma)
			ma = vec[i];
	cout << ma;
}

Measured memory_bytes: 256
s=input()
flg=True
if s[0]!="A":
    flg=False
cnt=0

for i in s[2:-1]:
    if i=="C":
        cnt+=1
#print(cnt)
if cnt!=1:
    flg=False
cnt=0
for i in s:
    if i.isupper():
        cnt+=1
if cnt!=2:
    flg=False
if flg:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 38384
import heapq
import sys
input = sys.stdin.readline
def main():
    N,C,K = map(int,input().split())
    pas = []
    for _ in range(N):
        pas.append(int(input()))
    heapq.heapify(pas)
    bus = []
    num = 1
    m = min(pas)
    while pas:
        a = heapq.heappop(pas)
        if len(bus) == C or a-m > K:
            num += 1
            bus = []
            bus.append(a)
            m = a
        else:
            bus.append(a)

    print(num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7116
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int dif = b - a;
        int height = 0;
        for(int i = 1; i <= dif; i++){
            height += i;
        }
        int ans = height - b;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <memory.h>
int main(void){
	int n,m,a,h,p,q,amida[1000][100],i,j,maxh,ans;
	while(1){
		scanf("%d %d %d",&n,&m,&a);
		if(!n){
			break;
		}
		ans=a-1;
		memset(amida,0,sizeof(amida));
		maxh=0;
		for(i=0;i<m;i++){
			scanf("%d %d %d",&h,&p,&q);
			if(maxh<h){
				maxh=h;
			}
			amida[h-1][p-1]=q;
			amida[h-1][q-1]=p;
		}
		for(i=maxh-1;i>=0;i--){
			if(amida[i][ans]){
				ans=amida[i][ans]-1;
			}
		}
		printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 1000