akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

const int MOD = 924844033;
const int MAXN = 800000;
const int G = 5;

inline int add(int x, int y) {return (x + y >= MOD ? x + y - MOD : x + y);}
inline int sub(int x, int y) {return (x - y < 0 ? x - y + MOD : x - y);}
inline int mul(int x, int y) {return 1LL * x * y % MOD;}

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=mul(b,b))
		if( i & 1 ) ret = mul(ret, b);
	return ret;
}

int w[21], iw[21];
int fct[MAXN + 5], ifct[MAXN + 5], inv[MAXN + 5];
int comb(int n, int m) {
	return mul(fct[n], mul(ifct[m], ifct[n-m]));
}
void init() {
	for(int i=0;i<=20;i++) {
		w[i] = pow_mod(G, (MOD - 1) / (1 << i));
		iw[i] = pow_mod(w[i], MOD - 2);
	}
	inv[1] = 1;
	for(int i=2;i<=MAXN;i++)
		inv[i] = sub(0, mul(MOD/i, inv[MOD%i]));
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = mul(fct[i-1], i);
	ifct[MAXN] = pow_mod(fct[MAXN], MOD - 2);
	for(int i=MAXN-1;i>=0;i--)
		ifct[i] = mul(ifct[i+1], i+1);
}

int length(int n) {
	int len; for(len = 1; len < n; len <<= 1);
	return len;
}
void ntt(int *A, int n, int type) {
	for(int i=0,j=0;i<n;i++) {
		if( i < j ) swap(A[i], A[j]);
		for(int k=(n>>1);(j^=k)<k;k>>=1);
	}
	for(int i=1;(1<<i)<=n;i++) {
		int s = (1 << i), t = (s >> 1);
		int u = (type == 1 ? w[i] : iw[i]);
		for(int j=0;j<n;j+=s) {
			for(int k=0,p=1;k<t;k++,p=mul(p,u)) {
				int x = A[j+k], y = mul(A[j+k+t], p);
				A[j+k] = add(x, y), A[j+k+t] = sub(x, y);
			}
		}
	}
	if( type == -1 ) {
		int iv = inv[n];
		for(int i=0;i<n;i++)
			A[i] = mul(A[i], iv);
	}
}

struct edge{
	int to; edge *nxt;
}edges[MAXN + 5], *adj[MAXN + 5], *ecnt = edges;
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	p = (++ecnt);
	p->to = u, p->nxt = adj[v], adj[v] = p;
}

int a[MAXN + 5], b[MAXN + 5], N;
int dfs(int x, int f) {
	int ret = 1;
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == f ) continue;
		int t = dfs(p->to, x);
		a[t]++, a[N - t]++, ret += t;
	}
	return ret;
}
int main() {
	init();
	scanf("%d", &N);
	for(int i=1;i<N;i++) {
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	dfs(1, 0);
	for(int i=0;i<=N;i++) a[i] = mul(a[i], fct[i]), b[i] = ifct[i];
	for(int i=1,j=N;i<j;i++,j--) swap(a[i], a[j]);
	int len = length(2*N + 1);
	ntt(a, len, 1), ntt(b, len, 1);
	for(int i=0;i<len;i++) a[i] = mul(a[i], b[i]);
	ntt(a, len, -1);
	for(int i=1,j=N;i<j;i++,j--) swap(a[i], a[j]);
	for(int i=1;i<=N;i++)
		printf("%d\n", sub(mul(comb(N, i), N), mul(a[i], ifct[i])));
}

Measured memory_bytes: 36224
// Candidates of No Shortest Paths
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,a[1000],b[1000],c[1000];
int d[110][110];
int main(){
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i==j)continue;
            d[i][j]=1e9;
        }
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<m;i++)if(d[a[i]][b[i]]!=c[i])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
V = 0
for i in range(N):
  V += L[i][1]

dp = [[float('inf')] * (V + 1) for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j - L[i][1] >= 0:
          dp[i+1][j] = min(dp[i][j], dp[i][j-L[i][1]] + L[i][0])
        else:
          dp[i+1][j] = dp[i][j]
ans = 0
for j in range(V+1):
    if  W >= dp[-1][j]:
        ans = max(ans, j)
print(ans)

Measured memory_bytes: 308296
def main():
    s = input().split()
    for i in range(2):
        if(s[i]=="A"):
            s[i]=10
        elif(s[i]=="B"):
            s[i]=11
        elif(s[i]=="C"):
            s[i]=12
        elif(s[i]=="D"):
            s[i]=13
        elif(s[i]=="E"):
            s[i]=14
        elif(s[i]=="F"):
            s[i]=15
    if(s[0]>s[1]):
        print(">")
    elif(s[0]<s[1]):
        print("<")
    else:
        print("=")
    
main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    
    int flag = 0;
    for (int i=0;i<S.size();i++) {
        int num_flag = 0;
        for (int j=0;j<S.size();j++) {
            //cout << (j+i)%S.size() << " " << j << endl;
            if (S[(j+i)%S.size()] == T[j]) {
                num_flag += 1;
            }
        }
        
        if (num_flag == S.size()) {
            flag = 1;
            cout << "Yes" << endl;
            break;
        }
    }
    
    if (flag == 0) {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <complex>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

typedef ll coord;
typedef complex<coord> P;
namespace std {
  bool operator<(const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

coord det(P a, P b) {
  return imag(conj(a) * b);
}

vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2 * n);
  // lower
  for (int i = 0; i < n; k++, i++) {
    while (k >= 2 && det(ps[i] - ch[k - 2], ch[k - 1] - ch[k - 2]) >= 0) --k;
    ch[k] = ps[i];
  }
  // upper
  for (int i = n-2, t = k+1; i >= 0; k++, i--) {
    while (k >= t && det(ps[i] - ch[k - 2], ch[k - 1] - ch[k - 2]) >= 0) --k;
    ch[k] = ps[i];
  }
  ch.resize(k-1);
  return ch;
}

int main(void) {
  double pi = acos(-1.0);
  int n;
  scanf("%d", &n);
  vector<ll> x(n), y(n);
  vector<P> pt(n);
  map<P, int> tbl;
  REP(i, 0, n) {
    scanf("%lld%lld", &x[i], &y[i]);
    pt[i] = P(x[i], y[i]);
    tbl[pt[i]] = i;
  }
  if (n == 2) {
    printf("0.5\n0.5\n");
    return 0;
  }
  vector<P> ch = convex_hull(pt);
  int m = ch.size();
  vector<double> div(m);
  REP(i, 0, m) {
    P d = (ch[(i + 1) % m] - ch[i]);
    double del = arg(complex<double>(d.real(), d.imag()));
    div[i] = del;
  }
  vector<double> ans(n);
  REP(i, 0, m) {
    int idx = tbl[ch[i]];
    double diff = div[i] - div[(i + m - 1) % m];
    if (diff < 0) {
      diff += 2 * pi;
    }
    ans[idx] = diff / (2 * pi);
  }
  REP(i, 0, n) {
    printf("%.15f\n", ans[i]);
  }
}


Measured memory_bytes: 384
n,m=map(int,input().split())
li=[]
ans=0
cnt=0
for i in range(n):
  li.append(list(map(int,input().split())))
li.sort()

for i in range(n):
  cnt+=li[i][1]
  ans+=li[i][0]*li[i][1]
  if cnt==m:
    print(ans)
    exit()
  if cnt>m:
    ans-=(cnt-m)*li[i][0]
    print(ans)
    exit()

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

int main()
{
    int H,W=0;
    cin>>H>>W;
	do
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	} while ((H != 0) || (W != 0));
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0;i < h;i++)
		cin >> s[i];
	vector<vector<int>> X(h, vector<int>(w, 0));
	vector<vector<int>> Y(h, vector<int>(w, 0));
	for (int i = 0;i < h;i++) {
		int co = 0,la=0,sc=0;
		while (co < w) {
			if (s[i][co]=='#') {
				for (int j = la;j < co;j++) {
					X[i][j] = sc;
				}
				la = co + 1;
				sc = 0;
			}
			else {
				sc++;
			}
			co++;
		}
		for (int j = la;j < co;j++) {
			X[i][j] = sc;
		}
	}
	for (int i = 0;i < w;i++) {
		int co = 0, la = 0, sc = 0;
		while (co < h) {
			if (s[co][i] == '#') {
				for (int j = la;j < co;j++) {
					Y[j][i] = sc;
				}
				la = co + 1;
				sc = 0;
			}
			else {
				sc++;
			}
			co++;
		}
		for (int j = la;j < co;j++) {
			Y[j][i] = sc;
		}
	}
	int ans = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++)
			ans = max(X[i][j] + Y[i][j], ans);
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 35712
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://atcoder.jp/img/abc054/editorial.pdf
def dfs(v):
    all_visited = True

    if False in visited:
        all_visited = False

    if all_visited:
        return 1

    count = 0

    for i in range(n):
        if graph[v][i] == 0:
            continue

        if visited[i]:
            continue

        visited[i] = True
        count += dfs(i)
        visited[i] = False
    return count


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    graph = [[0 for __ in range(n)] for _ in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x) - 1, input().split()))
        graph[a][b] = 1
        graph[b][a] = 1

    visited = [False] * n
    visited[0] = True

    print(dfs(0))


Measured memory_bytes: 3064
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
ans = 1
while as[1]
  if as[1] > as[0]
    while as[1] && as[1] >= as[0]
      as.shift
    end
    ans += 1
    as.shift
  elsif as[1] < as[0]
    while as[1] && as[1] <= as[0]
      as.shift
    end
    ans += 1
    as.shift
  else
    as.shift
  end
end
if as.empty?
  ans -= 1
end
p ans


Measured memory_bytes: 9484
r, c = map(int, input().split())

table = [[0 for j in range(c+1)] for i in range(r+1)]

for i in range(r):
    row = list(map(int, input().split()))
    table[i][-1]=sum(row)
    for j in range(c):
        table[-1][j] += row[j]
        table[i][j] = row[j]
    table[-1][-1] += sum(row)

for i in range(r+1):
    print(*table[i])


Measured memory_bytes: 6220
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;

ll Plus(ll num){
        ll count = 0;
        ll i = 2;
        while(num%2 == 0){
                if(num%2 == 0) count++;
                num /= 2;
        }
        return count;
}

int main(){
        ll N;
        cin >> N;
        ll Count = 0, a;
        for(int i=0; i<N; i++){
                cin >> a;
                Count += Plus(a);
        }
        cout << Count;
}


Measured memory_bytes: 256
DICT = [chr(i) for i in range(65, 65+26)]
C = [0] * 26

n = int(input())
s = input()

ans = [None] * len(s)

for i in range(len(s)):
    index = DICT.index(s[i])+n
    if index >= 26:
        index = index - 26
    ans[i] = DICT[index]

print(''.join(ans))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,a[10];
int main(){
	int tmp;
	for(cin>>n;n--;){
		cin >> tmp;
		if(tmp < 400) a[1] = 1;
		else if(tmp < 800) a[2] = 1;
		else if(tmp < 1200) a[3] = 1;
		else if(tmp < 1600) a[4] = 1;
		else if(tmp < 2000) a[5] = 1;
		else if(tmp < 2400) a[6] = 1;
		else if(tmp < 2800) a[7] = 1;
		else if(tmp < 3200) a[8] = 1;
		else a[9]++;
	}
	int minn = 0, maxn = a[9];
	for(int i = 1; i < 9; i ++){
		if(a[i]) minn++;
	}
	cout << max(1,minn) << ' ' << minn + maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+4;
int f[10][10];
int ans[N];
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
inline int first(int x) {
	while (x>=10) x/=10;
	return x;
}
inline int last(int x) {
	return x%10;
}
int main() {
	int n=read();
	for (int i=1;i<10;++i) {
		ans[i]=ans[i-1]+1;
		f[i][i]=1;
	}
	for (register int i=10;i<=n;++i) {
		int a=first(i);
		int b=last(i);
		if (!b) ans[i]=ans[i-1];
		else {
			ans[i]=ans[i-1]+f[b][a]*2;
			if (a==b) ++ans[i];
			++f[a][b];
		}
	}
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 4540
#include <iostream>
#include <bitset>

using namespace std;

const int INF = 1 << 30;
const int V_MAX = 15;

int V, E;
int dp[1 << V_MAX][V_MAX];
int dist[V_MAX][V_MAX];

int main() {
    fill(dp[0], dp[(1<<V_MAX)-1]+V_MAX, INF);
    fill(dist[0], dist[V_MAX-1]+V_MAX, INF);

    cin >> V >> E;
    int from, to, cost;
    for(int i=0;i<E;++i) {
        cin >> from >> to >> cost;
        dist[from][to] = cost;
    }

    dp[0][0] = 0;
    for(int bit=0;bit<(1<<V);++bit) {
        for(int i=0;i<V;++i) {
            if(dp[bit][i] == INF || (bit && !(bit & (1<<i)))) continue;
            for(int j=0;j<V;++j) {
                if((bit & (1<<j)) || dist[i][j] == INF) continue;
                if(dp[bit | (1<<j)][j] > dp[bit][i] + dist[i][j]) {
                    dp[bit | (1<<j)][j] = dp[bit][i] + dist[i][j];
                }
            }
        }
    }
    cout << (dp[(1<<V)-1][0] == INF ? -1 : dp[(1<<V)-1][0]) << endl;
}


Measured memory_bytes: 5012
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

#define MX 200002
vector<int> g[MX];

ll vis[MX];
ll dp[MX];
ll arr[MX];
set<ll> s;
unordered_map<int,int> mp;
void dfs(int u)
{
	vis[u]=1;
	ll x=arr[u];
	set<ll>::iterator it=s.lower_bound(x);
	mp[x]++;
	ll y=-1;
	if(it==s.end())
    {
        s.insert(x);
    }
    else
    { y=*it;
    mp[y]--;
        s.insert(x);
        if(mp[y]==0)
        s.erase(it);
            }
            dp[u]=s.size();
	for(ll i=0;i<g[u].size();i++)
	{int v=g[u][i];
		if(!vis[v])
	         dfs(v);


	}
	if(y!=-1)
    {
	s.insert(y);
	mp[y]+=1;
    }
	it=s.lower_bound(arr[u]);
	if(mp[arr[u]]==1)
    {
	s.erase(it);
    mp[arr[u]]-=1;
    }
	else
        mp[arr[u]]-=1;

}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;

for(int i=1;i<=n;i++)
    cin>>arr[i];
for(int i=0;i<n-1;i++)
{
    int u,v;
    cin>>u>>v;
    g[u].pb(v);
    g[v].pb(u);
}

dfs(1);
for(int i=1;i<=n;i++)
    cout<<dp[i]<<endl;



















    return 0;
}


Measured memory_bytes: 42476
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = input()
    result, count = 0, 0
    for s in S:
        if s in ('A', 'C', 'G', 'T'):
            count += 1
            result = max(result, count)
        else:
            count = 0
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

//vector<ll> ;

void answer(){
    ll n,m,k,ans=0;
    cin>>n>>m;
    ll a;
    a = n*100/8;
    ll b = n*100/7;
    //cout<<a<<" "<<b<<" ";
    for(int i=a;i<b;i++){
        if(((i*8/100) == n )&&((i/10)==m)){ cout<<i;return;}
        //cout<<i*8/100<<" "<<i/10<<endl;
    }
    cout<<-1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            String str = s.nextString();
            for (int i = 0; i < 3; i++) {
                if (str.charAt(i) == str.charAt(i + 1)) {
                    out.println("Bad");
                    return;
                }
            }
            out.println("Good");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(void){
    string T;
    cin >> T;
    
    for (int i = 0; i < T.size(); i++)
        if (T[i] == '?')
            T[i] = 'D';
    cout << T << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    int h,w,k;
    std::cin >> h>>w>>k;
    std::vector<string> a(h);
    int ans=INF;
    rep(i,h)std::cin >> a[i];
    brep(h-1){
        int dum=0;
        int cn=0;
        
        std::vector<int> p(h);
        rrep(i,1,h){
            if(bit&(1<<(i-1)))p[i]=p[i-1]+1;
            else p[i]=p[i-1];
        }
        rep(i,h-1)if(bit&(1<<i))dum++;
      //  rep(i,h)std::cout << p[i] <<' ';
        //std::cout << std::endl;
        std::vector<int> c(h);
        rep(j,w){
            rep(i,h){
                if(a[i][j]=='1')c[p[i]]++;
            }
            bool han=1;
            rep(i,h){
                if(k<c[i])han=0;
            }
       //     std::cout << c[0] << std::endl;
            if(!han){
                if(cn==0){
                    dum=INF;
                    break;
                }
                dum++;
                j--;
                rep(i,h)c[i]=0;
                cn=0;
                
            }
            else cn++;
        }
        //std::cout << dum << std::endl;
        ans=min(ans,dum);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;

template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
int i=0;
for(auto it:v){
	if(i > 0){os << ' ';}
	os << it;
	i++;
} 
return os;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12 13 14

12 1 11
13 3 10
14 5 9
15 7 8
16 2 14
17 4 13
18 6 12

1-12

11 1 10
12 3 9
13 5 8
13 6 7
14 2 12
15 4 11
*/

using ll=long long ;

int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	vector<pair<int,int>>ps(N);
	for(int i=0;i<N;++i){
		cin>>ps[i].second;
	}
	for(int i=0;i<N;++i){
		cin>>ps[i].first;
	}
	sort(ps.begin(),ps.end());
	vector<pair<int,int>>aps;
	for(int i=0;i<N;++i){
		aps.push_back(make_pair(ps[i].second,i));
	}
	sort(aps.begin(),aps.end());
	bool ok=true;
	for(int i=0;i<N;++i){
		if(aps[i].first>ps[i].first)ok=false;
	}
	WHATS(aps)
	WHATS(ps)
	vector<int>tos(N);
	for(int i=0;i<N;++i){
		tos[aps[i].second]=i;
	}
	vector<int>used(N);
	int cnt=0;
	WHATS(tos)
	{
		int now=0;
		vector<int>perms;
		while(true){
			used[now]=true;
			int next=tos[now];
			if(used[next])break;
			else{
				now=next;
			}
		}
		WHATS(used)
		WHATS(ok)
		cnt++;
		if(find(used.begin(),used.end(),false)!=used.end()){

		}else{
			bool aok=false;
			for(int i=0;i<N-1;++i){
				if(aps[i+1].first<=ps[i].first)aok=true;
			}
			if(!aok)ok=false;
		}
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int h,a;
  int count=0;
  
  cin>>h>>a;
  
  while(h>0)
  {
    h=h-a;
    count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace caddi2018b
{
    class B_AtCoderAlloy
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int H = int.Parse(input[1]);
            int W = int.Parse(input[2]);
            var lstA = new List<int>();
            var lstB = new List<int>();
            
            for (int i = 0; i < N; i++)
            {
                string[] tmp = Console.ReadLine().Split(' ');
                lstA.Add(int.Parse(tmp[0]));
                lstB.Add(int.Parse(tmp[1]));
            }

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                int cnt1 = lstA[i] / H;
                int cnt2 = lstB[i] / W;
                if (cnt1 > 0 && cnt2 > 0) ans += Math.Min(cnt1, cnt2);

            }

            //出力
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
int main()
{
	std::string in;
	std::cin >> in;

	std::vector<int>al(26);
	for(int i=0;i<26;i++) al[i] = 0;

	for(int i=0;i<in.size();i++) al[in[i]-'a']++;

	for(int i=0;i<al.size();i++){
		if(al[i]%2 != 0){
			std::cout << "No" << std::endl;
			return 0;
		}
	}

	std::cout << "Yes" << std::endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int w=0,e=0,n=0,s=0,ans=0;
  string a;
  cin>>a;
  rep(i,a.size()){
    if(a[i]=='W'){
      w=1;
    }
    if(a[i]=='E'){
      e=1;
    }
    if(a[i]=='N'){
      n=1;
    }
    if(a[i]=='S'){
      s=1;
    }
  }
  if((n+s)%2==0){
    ans++;
  }
  if((w+e)%2==0){
    ans++;
  }
  if(ans==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;
char c[100];

signed main(){
	cin>>N>>S;
	REP(i,26){
		c[i]='A'+i;
		c[i+26]='A'+i;
	}
	REP(i,S.size()){
		cout<<c[(S[i]-'A')+N];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
A=many_int()

mins=100000000000
for i in A:
    temp=i
    count=0
    while temp%2==0:
        count+=1
        temp/=2
            
    if count < mins:
        mins = count

print(mins)

Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int n,m,cnt=0,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000];
char c;
queue<int> que;
signed main(){
    cin>>n>>m>>cnt;
    for(int i=n;i<m+1;i++){
        if(i%cnt==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10476
from collections import defaultdict

H,W = map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(input())

d = defaultdict(int)
for i in range(H):
    for j in range(W):
        d[a[i][j]] += 1

c4,c2 = 0,0
for k in d.keys():
    c4 += d[k]//4
    c2 += (d[k]%4)//2

if H%2 + W%2 == 0:
    if c4 == H*W//4:
        print("Yes")
    else:
        print("No")
elif H%2 + W%2 == 1:
    if H%2 == 1:
        if c4 < (H-1)*W//4:
            print("No")
        else:
            c4 -= (H-1)*W//4
            c2 += c4*2
            if c2 == W//2:
                print("Yes")
            else:
                print("No")
    if W%2 == 1:
        if c4 < H*(W-1)//4:
            print("No")
        else:
            c4 -= H*(W-1)//4
            c2 += c4*2
            if c2 == H//2:
                print("Yes")
            else:
                print("No")
else:
    if c4 < (H-1)*(W-1)//4:
        print("No")
    else:
        c4 -= (H-1)*(W-1)//4
        c2 += c4*2
        if c2 == (H-1)//2+(W-1)//2:
            print("Yes")
        else:
            print("No")

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

int a, b;

int main() {
    cin >> a >> b;
    if(abs(((a-b)/2)-a) == abs(((a-b)/2)+b)){
        cout << abs(((a-b)/2)-a);
    } else {
        cout << "IMPOSSIBLE";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		int size = 0;
		int[] arr;
		arr = new int[10];
		int left;
		int right;
		Scanner scan = new Scanner(System.in);
		if(scan.hasNext() == true){
			size = scan.nextInt();
		}
		while(size > 0){
			i = 0;
			left = 0;
			right = 0;
			while(i < 10){
				if(scan.hasNext() ==  true){
					arr[i] = scan.nextInt();
					i++;
				}
			}
			i = 0;
			while(i < 10){
				if(arr[i] > left && arr[i] > right){
					if(left > right){
						left = arr[i];
					}
					else{
						right = arr[i];
					}
					i++;
				}
				else if(arr[i] > left){
					left = arr[i];
					i++;
				}
				else if(arr[i] > right){
					right = arr[i];
					i++;
				}
				else{
					break;
				}
			}
			if(i == 10){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
			size--;
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int H, A;
    cin >> H >> A;

    cout << CEIL(H, A) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll  n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
        
        
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
int a,b,c,d,d1,d2;
cin>>a>>b>>c>>d;
if (a>=c){if(a-c<=d) {cout<<"Yes";return 0;}}
if (c>a){if(c-a<=d) {cout<<"Yes";return 0;}}
if (a>=b) d1=a-b;
else d1=b-a;
if (b>=c) d2=b-c;
else d2=c-b;
if(d1<=d&&d2<=d) cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1000003;

ll kuri2(ll base,ll kata)
{
	ll ret=1;
	if(kata==0)
		return ret;
	else if(kata&1){
		ret*=base;
		ret%=MOD;
	}
	ret*=kuri2(base*base%MOD,(kata>>1));
	ret%=MOD;
	return ret;
}

ll kai[1000003];
ll gyaku[1000003];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	ll ans=0;
	//階乗を求める
	kai[0]=1;
	gyaku[0]=kuri2(kai[0],MOD-2);
	for(ll i=1;i<MOD;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
		gyaku[i]=kuri2(kai[i],MOD-2);
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		ll x,d,n;
		cin>>x>>d>>n;
		//例外処理
		if(x==0)
		{
			cout<<0<<endl;
			continue;
		}
		if(d==0)
		{
			cout<<kuri2(x,n)<<endl;
			continue;
		}
		//cerr<<d*kuri2(d,MOD-2)%MOD<<endl;
		ll xd=x*kuri2(d,MOD-2);//x/dを求める
		xd%=MOD;
		if(xd<0)
			xd+=MOD;
		//MODを含むなら答えは0
		if(xd+n-1>=MOD)
		{
			ans=0;
		}else{
			//そうでない場合は頑張って求める
			ans=kai[xd+n-1]*gyaku[xd-1];
			ans%=MOD;
			ans*=kuri2(d,n);
			ans%=MOD;
			if(ans<0)
				ans+=MOD;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int get(char c) {
	return c - '0';
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int t = get(s[0]) * 10 + get(s[1]);
	int t1 = get(s[2]) * 10 + get(s[3]);
	if (t >= 1 && t <= 12) {
		if (t1 >= 1 && t1 <= 12) {
			cout << "AMBIGUOUS";
		} else cout << "MMYY";
	} else {
		if (t1 >= 1 && t1 <= 12) {
			cout << "YYMM";
		} else cout << "NA";
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

	int main(void){
		int n,k;
		scanf("%d %d",&n,&k);
		long x[100000];
		long m[100001]={};
		long p[100001]={};
		m[0]=0;
		p[0]=0;
		int a=1,b=1;
		int i;
		int minus = 0;//マイナス側に置かれているろうそくの数
		int plus = 0; //プラス側に置かれているろうそくの数
		for(i=0;i<n;i++){
			scanf("%ld",&x[i]);
				if(x[i]==0){		//もしも座標0にろうそくがあったならば
					k--;
				}
			if(x[i]<0){ //minusの座標に置かれているろうそくの数をカウントする
				minus++;
			}
			if(x[i]>0){
				p[b] = x[i];//0からb本のろうそくをプラス側に火をつけるのにかかる時間はp[b]
				b++;
				plus++;
			}
		}
		//printf("plusの本数は%d\n",plus);
		//printf("minusの本数は%d\n",minus);
		//原点からプラス座標にn本火をつけるのにかかる時間をp[n]とする。
		//原点からマイナス座標にn本火をつけるのにかかる時間をm[n]とする。
		for(i=minus;i>0;i--){
			m[a]=-(x[i-1]);
			a++;
		}
		//printf("0からプラス座標に2本火をつけるのにかかる時間は%d\n",p[2]);
		//printf("0からマイナス座標に1本火をつけるのにかかる時間は%d\n",m[1]);
		//あとは原点から左にi本右からk-i本火をつけると考える
		long ans = 2*1000000000;
		long temp;
		long temp2;
		if(k==0){
			ans=0;
			printf("%ld",ans);
			return 0;
		}
		for(i=0;i<=k;i++){
			if( (k-i)>plus){
				continue;
			}
			if( i>minus){
				continue;
			}
			temp = 2*m[i]+p[k-i];
			temp2= m[i]+2*p[k-i];
			if( ans > temp){
				ans = temp;
			}
			if(ans > temp2){
				ans =temp2;
			}
		}
		printf("%ld",ans);
		return 0;
	}


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

int main()
{
	int n, a[4][3][100] = { 0 }, b, c, d, e, i, j, k;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> b >> c >> d >> e;
		a[b - 1][c - 1][d - 1] += e;
	}
	for(k = 0;k < 4;k++)
	{ 
		if (k) cout << "####################" << endl;
		for (j = 0; j < 3; j++)
		{
			for (i = 0; i < 10; i++)
			{
				if (a[k][j][i] > 9)a[k][j][i] = 9;
				else if (a[k][j][i] < 0)a[k][j][i] = 0;
				cout << " " << a[k][j][i];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int n,tmp;
int visited[200005];

signed main()
{
	cin>>n;
	for (int i=2;i<=n;i++)
	{
		cin>>tmp;
		visited[tmp]++;
	}
	for (int i=1;i<=n;i++)  cout<<visited[i]<<endl;
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    for (int i = 0; i < n - 1; i++) std::cin >> c[i];
    int ans = accumulate(b.begin(), b.end(), 0);
    for (int i = 0; i < n - 1; i++) {
        if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
    }
    std::cout << ans << std::endl;
    return 0;
}


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

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

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

using namespace std;
const int MAX = 100000 + 5;
int color[MAX]={};
vector<pair<int, int>> list[MAX];

void dfs(int i)
{
    for (int j = 0; j < list[i].size(); j++)
    {
        int v = list[i][j].first;
        int w = list[i][j].second;
        if(color[v] == -1)
        {
            if(w%2==0)
            {
                color[v] = color[i];
            }
            else
            {
                color[v] = 1 - color[i];
            }
            dfs(v);
        }
        
    }
    return;
}

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < MAX; i++)
    {
        color[i] = -1;
    }

    for (int i = 1; i < n; i++)
    {
        int a, b, w;
        cin >> a >> b >> w;
        list[a].push_back(make_pair(b, w));
        list[b].push_back(make_pair(a, w));
    }
    color[1] = 0;
    dfs(1);

        for (int i = 1; i < n+1; i++)
    {
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8448
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] a = in.ii(N);
        int two = 0;
        int four = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] % 4 == 0) {
                four++;
            } else if (a[i] % 2 == 0) {
                two++;
            }
        }
        String ans = N <= 2 * four + Math.max(1, two) ? "Yes" : "No";
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int S, W;
    cin >> S >> W;
    if(W>=S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int a[200009];
int vis[200009];
int counter[200009];
int main()
{
	int i, n;
	scanf("%d", &n);
	for(i = 1 ; i <= n ; i++)
	{
		scanf("%d", &a[i]);
		vis[a[i]] = i;
		counter[i] = 1;
	}
	for(i = n ; i >= 1 ; i--)
	{
		if(vis[a[i] - 1] < vis[a[i]])
		{
			counter[a[i] - 1] = counter[a[i]] + 1;
		}
	}
	sort(counter + 1 , counter + 1 + n);
	printf("%d\n", n - counter[n]);
	return 0;
}

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

using namespace std;

int main(){
	string s;
	int a = 0, z = 0;
	cin >> s;
	int m = int(s.size());
	for(int i = 0; i < m; i++){
		if(s[i] == 'A'){
			break;
		} else {
			a++;
		}
	}
	for(int i = m - 1; i >= 0; i--){
		if(s[i] == 'Z'){
			break;
		} else {
			z++;
		}
	}
	cout << m - (a + z);
	return 0;
}

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

int main(){
  ll N;
  cin>>N;
  for(ll h=1;h<=3501;h++){
    for(ll n=1;n<=3501;n++){
      ll B=4*n*h-N*n-N*h;
      ll A=n*h*N;
      
      if(B>0&&A%B==0){
        cout<<h<<' '<<n<<' '<<A/B<<endl;
        return 0;
      }

    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+205;
void solve(){
	string s;
	cin>>s; 
	if(s=="Sunny")cout<<"Cloudy"<<endl;
	if(s=="Cloudy")cout<<"Rainy"<<endl;
	if(s=="Rainy")cout<<"Sunny"<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
    int N, m = 0, s = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s += A[i];
        chmax(m, A[i]);
    }
    
    s -= m;
    cout << ((m < s) ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
	int N;
	long long value = 100000;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		value = value * 1.05;
		if (value % 1000 != 0)value = value - (value % 1000) + 1000;
	}
	printf("%lld\n", value);
	return 0;
}



Measured memory_bytes: 1976
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

	vector<int> h;
	h.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		int hn;
		cin >> hn;
		h.emplace_back(hn);
	}

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

	long long sum = 0;
	for (int i = 0; i < n - k; ++i)
	{
		sum += h.at(i);
	}
	cout << sum << endl;
}



Measured memory_bytes: 1024
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

def ceil(x, y):
  return (x -1 ) // y + 1

addNum = 0
for i, j in reversed(AB):
#  print(i+addNum, j, addNum)
  addNum += ceil(addNum + i,j) * j - (addNum + i)

print(addNum)

Measured memory_bytes: 27380
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n+1); rank.resize(n+1); diff_weight.resize(n+1);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<int> p(n);
    rep(i, 0, n) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind<int> uf(n);
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.merge(x, y);
    }
    int ans = 0;
    rep(i, 0, n) {
        if (uf.issame(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;

  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] ;
  }
  sort(A.rbegin(), A.rend());

  int index = 0;
  bool flg = true;
  ll ans = 0;
  for(int i = 0; i < N; i++){
    if(i == 0) continue;
    if(i == 1) {
      ans += A[0];
      index++;
    } else { 
      if(flg){
        ans += A[index];
        flg = false;
      } else { 
        ans += A[index];
        flg = true;
        index++;
      }
    }
    cerr << "i: " << i << " index: " << index << " A: " << A[index] << endl;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 9308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

int main(){
    int N; cin >> N;
    vector<int> A(N),B(N),C(N);

    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(),A.end());
    for(int i = 0; i < N; i++) cin >> B[i];

    for(int i = 0; i < N; i++) cin >> C[i];
    sort(C.begin(),C.end());

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll countL = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll countR = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
        ans += countL * (N - countR);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1408