akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<math.h>
using namespace std;

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	// keisan
	int mark = 1;
	for(int i=0;i<n;i++){
		if(a[mark-1] == 2){
			cout << i+1;
			break;
		}
		if(i == n-1){
			cout << "-1";
			break;
		}
		mark = a[mark-1];
	}
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if ((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int day = sc.nextInt();
		int rest = sc.nextInt();
		
		int sum = 0;
		
		int st[] = new int[a];
		
		for(int i=0;i<a;i++){
			st[i] = sc.nextInt();
		}
		
		for(int i=0;i<a;i++){
			sum += ((day-1) / st[i] ) + 1;
		}
		sum += rest;
		System.out.println(sum);
	}
}

Measured memory_bytes: 22996
N,M=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M) ]
Lmin=1
Rmin=N
for i in range(M):
  l=LR[i][0]
  r=LR[i][1]
  if Lmin<l:
    Lmin=l
  if Rmin>r:
    Rmin=r
    
print(max(Rmin-Lmin+1,0))

Measured memory_bytes: 59992
#include<stdio.h>
#define limit 256

int array[limit], size = 0;

void push(int n) {
	array[size++] = n;
}

int pop() {
	return array[--size];
}

int main() {
	char input;
	int num = -1;
	while (scanf("%c", &input) != EOF) {

		//convert string into int
		if ('0' <= input && input <= '9') {
			num = (num < 0 ? input - '0' : 10 * num + input - '0');
		}

		//push to array
		if (input == ' ') {
			if (num >= 0) push(num);
			num = -1;
		}

		if (input == '+') {
			push(pop() + pop());
		}

		if (input == '-') {
			int a = pop(), b = pop();
			push(b - a);
		}

		if (input == '*') {
			push(pop() * pop());
		}
	}
	printf("%d\n", pop());
	return 0;
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
int arr[15];

int main() {
    int a,b,n,T,k,cas=0;
    cin>>n>>k;
    for(int i=0;i<k;++i) {
        cin>>a;
        arr[a] = 1;
    }
    for(int i=n;;++i) {
        int x = i;
        int ok = 1;
        while(x) {
            if(arr[x%10]) {
                ok = 0;
                break;
            }
            x/=10;
        }
        if(ok) {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int p = min(a, b);
    int q = min(c, d);
    cout  << p + q << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;

lint MOD = 1e9 + 7;
vector<P> X;

int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        X.push_back(P(a, 1));
    }
    for(int i=0;i<n;i++){
        int b; cin >> b;
        X.push_back(P(b, 0));
    }

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

    int c1 = 0, c2 = 0;
    lint ans = 1;
    for(int i=0;i<2*n;i++){
        if(X[i].second){
            if(c2) ans = (ans*c2) % MOD, c2--;
            else c1++;
        }else{
            if(c1) ans = (ans*c1) % MOD, c1--;
            else c2++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
n,k=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 10 ** 9 + 7
N = 2 * (10**5)  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
ans=0
if(k<n-1):
    for i in range(1,k+1):
        k=cmb(n,i,p)*cmb(n-1,i,p)% p
        ans=ans+k
        ans=ans % p
    ans+=1 % p
else:
    for i in range(1,n):
        k=cmb(n,i,p)*cmb(n-1,i,p)% p
        ans=ans+k
        ans=ans % p
    ans+=1 % p
print(ans)


Measured memory_bytes: 27052
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll A, B;
    scanf("%lld %lld", &A, &B);

    printf("%lld", A * B);
}


Measured memory_bytes: 3736
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#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++)

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

struct cmp {
  bool operator()(PL x, PL y) const {
    if (x.first <= y.first && x.second <= y.second) {
      return x != y;
    }
    if (x.first >= y.first && x.second >= y.second) {
      return false;
    }
    bool flip = false;
    if (x > y) {
      swap(x, y);
      flip = true;
    }
    bool ans = false;
    // x.0 <= y.0, x.1 >= y.1
    if (x.first >= y.second) {
      ans = false;
    } else {
      ans = true;
    }
    if (flip) ans = !ans;
    return ans;
  }
};

const ll inf = 1e16;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL h(n), p(n);
  vector<PL> pool;
  vector<VL> dp(n + 1, VL(n + 1, inf));
  REP(i, 0, n) {
    cin >> h[i] >> p[i];
    pool.push_back(PL(h[i]+p[i], p[i]));
  }
  sort(pool.begin(), pool.end());
  dp[0][0] = 0;
  REP(i, 0, n) {
    ll y = pool[i].second;
    ll x = pool[i].first - y;
    REP(j, 0, i + 2) {
      dp[i + 1][j] = dp[i][j];
      if (j >= 1 && dp[i][j - 1] <= x) {
	dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 1] + y);
      }
    }
  }
  int ma = 0;
  REP(i, 0, n + 1) {
    if (dp[n][i] < inf) {
      ma = max(ma, i);
    }
  }
  cout << ma << "\n";
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
bool is_prime(int n){
  if (n == 1){
    return false;
  }
  for (int i = 2; i * i <= n; i++){
    if (n % i == 0){
      return false;
    }
  }
  return true;
}
int main(){
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  S--;
  T--;
  vector<vector<int>> E(N * 2);
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a * 2].push_back(b * 2 + 1);
    E[a * 2 + 1].push_back(b * 2);
    E[b * 2].push_back(a * 2 + 1);
    E[b * 2 + 1].push_back(a * 2);
  }
  vector<int> d(N * 2, INF);
  d[S * 2] = 0;
  queue<int> Q;
  Q.push(S * 2);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      if (d[w] == INF){
        d[w] = d[v] + 1;
        Q.push(w);
      }
    }
  }
  if (d[T * 2] == 2){
    cout << 2 << endl;
  } else if (d[T * 2 + 1] == INF){
    cout << -1 << endl;
  } else {
    int p = d[T * 2 + 1];
    while (!is_prime(p)){
      p += 2;
    }
    cout << p << endl;
  }
}


Measured memory_bytes: 14504
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/17 19:59:47
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n=read();
	n=n%10;
	if(n==3) printf("bon");
	else if(n==0 || n==1 || n==6 || n==8) printf("pon");
	else printf("hon");
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 256;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int ts[MAX], vs[MAX], tacc[MAX], maxi[MAX*MAX];

void solve(void){
    //input
    int N;
    scanf("%d\n", &N);
    rep(N, i) {
        scanf("%d", &ts[i]);
        tacc[i+1] = ts[i] + tacc[i];
    }
    rep(N, i) scanf("%d", &vs[i]);

    //init
    int r = 2*tacc[N];
    Rep(0, r, t) maxi[t] = min(t, r-t);

    rep(N, n) {
        Rep(0, r, t) {
            if (t < 2*tacc[n]) maxi[t] = min(maxi[t], (2*tacc[n]-t)+2*vs[n]);
            else if (t > 2*tacc[n+1]) maxi[t] = min(maxi[t], abs(2*tacc[n+1]-t)+2*vs[n]);
            else maxi[t] = min(maxi[t], 2*vs[n]);
        }
    }
    double ans = 0.;
    Rep(0, r-1, t) ans += (double)(maxi[t+1] + maxi[t])/2/4;

    printf("%.6lf\n", ans);
}

int main(void){
  solve();
  return 0;
}


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

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

    string S;
    cin >> S;

    int accR[N] = {}, accG[N] = {}, accB[N] = {};
    rep(i, N) {
        if (S[i] == 'R') accR[i]++;
        if (S[i] == 'G') accG[i]++;
        if (S[i] == 'B') accB[i]++;

        if (i>0) {
            accR[i] += accR[i-1];
            accG[i] += accG[i-1];
            accB[i] += accB[i-1];
        }
    }

    ll ans = 0;
    for (int s=0; s<N-3; s++) for (int e=s+3; e<N; e++) {
        if (S[s] == S[e]) continue;
        if (S[s]=='R' && S[e]=='G') {
            ans += accB[e] - accB[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='B') ans--;
        }
        if (S[s]=='R' && S[e]=='B') {
            ans += accG[e] - accG[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='G') ans--;
        }
        if (S[s]=='G' && S[e]=='R') {
            ans += accB[e] - accB[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='B') ans--;
        }
        if (S[s]=='G' && S[e]=='B') {
            ans += accR[e] - accR[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='R') ans--;
        }
        if (S[s]=='B' && S[e]=='R') {
            ans += accG[e] - accG[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='G') ans--;
        }
        if (S[s]=='B' && S[e]=='G') {
            ans += accR[e] - accR[s];
            if ((s+e)%2==0 && S[(s+e)/2]=='R') ans--;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3656
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL mx = 0;
		LL n = -1, k = -1, sum = 0;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<LL> p(n);
		for (LL i = 0; i < n; ++i) {
			cin >> p[i];
			++p[i];
			if (i >= k) {
				sum -= p[i - k];
			}
			sum += p[i];
			mx = max(mx, sum);
		}
		double ans = (double)mx * 0.5;
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int N; cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int num_minus = 0;
    long long mi = 1LL << 60;
    long long sum = 0;
    for(int i = 0; i < N; i++){
        if(a[i]<0)num_minus++;
        mi = min(mi,abs(a[i]));
        sum += abs(a[i]);
    }
    if(num_minus % 2 == 0)cout << sum << endl;
    else cout << sum - mi*2 << endl;
    
}


Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		String s = sc.next();
		int[] c = new int[N];
		for (int i = 0; i < N; ++i) {
			c[i] = 1 << "JOI".indexOf(s.charAt(i));
		}
		int[][] dp = new int[1 << 3][N + 1];
		dp[1][0] = 1;
		int MOD = 10007;
		for (int i = 0; i < N; ++i) {
			for (int j = 1; j < (1 << 3); ++j) {
				if ((j & c[i]) == 0) continue;
				for (int k = 1; k < (1 << 3); ++k) {
					if ((j & k) == 0) continue;
					dp[j][i + 1] += dp[k][i];
					if (dp[j][i + 1] >= MOD) dp[j][i + 1] -= MOD;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < (1 << 3); ++i) {
			ans += dp[i][N];
		}
		System.out.println(ans % MOD);
	}
}

Measured memory_bytes: 18064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *P = map(int, read().split())

    ans = 0
    for i in range(N - 1):
        if P[i] == i + 1:
            P[i], P[i + 1] = P[i + 1], P[i]
            ans += 1

    if P[N - 1] == N:
        ans += 1

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20524
#include <bits/stdc++.h>
using namespace std;
struct jer {
  int ahi, alo, curhi, curlo;
  bool asc;
};
int r[100005];
jer changes[100005];
int main() {
  int x, k;
  scanf("%d %d", &x, &k);
  jer lastchange = {x, 0, x, 0, false};
  changes[0] = lastchange;
  int last = 0;
  for (int i = 1; i <= k + 1; i++) {
    if (i == k + 1) {
      r[i] = 1000000001;
    } else {
      scanf("%d", &r[i]);
    }
    int dt = r[i] - last;
    last = r[i];
    if (i % 2 == 1) {
      changes[i].ahi = lastchange.ahi;
      changes[i].curhi = max(0, lastchange.curhi - dt);
      changes[i].curlo = max(0, lastchange.curlo - dt);
      changes[i].alo = changes[i].ahi - (changes[i].curhi - changes[i].curlo);
      changes[i].asc = true;
    } else {
      changes[i].alo = lastchange.alo;
      changes[i].curhi = min(x, lastchange.curhi + dt);
      changes[i].curlo = min(x, lastchange.curlo + dt);
      changes[i].ahi = changes[i].alo + (changes[i].curhi - changes[i].curlo);
      changes[i].asc = false;
    }
    lastchange = changes[i];
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int t, a;
    scanf("%d %d", &t, &a);
    int offset = upper_bound(r, r + k + 2, t) - r - 1;
    int p = 0;
    if (a > changes[offset].ahi) {
      p = changes[offset].curhi;
    } else if (a < changes[offset].alo) {
      p = changes[offset].curlo;
    } else {
      p = changes[offset].curlo + a - changes[offset].alo;
    }
    p += (changes[offset].asc ? 1 : -1) * (t - r[offset]);
    p = min(x, p);
    p = max(0, p);
    printf("%d\n", p);
  }
  return 0;
}


Measured memory_bytes: 3584
program asakatsu318A
    implicit none
    integer(8)::A,B,K,i
    read*,A,B,K
    do i=1,K
        if(mod(i,2)==1)then
            if(mod(A,2)==1)A=A-1
            B=B+A/2
            A=A/2
        else if(mod(i,2)==0)then
            if(mod(B,2)==1)B=B-1
            A=A+B/2
            B=B/2
        end if
    end do
    print'(i0,1x,i0)',A,B
end program asakatsu318A

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

const int MX = 5e5 + 100;



void solve(){
	string s;
	cin >> s;
	llint n = 0;
	for(auto c : s) n += c - '0';
	cout << (n % 9 ? "No" : "Yes"); 
}




int main() {
	fast_io;
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}
int main() {
	string s; cin >> s;
	int n = s.size();
	bool res = true;
	if (s[0] != 'A') res = false;
	int cnt = 0;
	UPTO(i,2,n-2) if (s[i] == 'C') cnt++;
	if (cnt != 1) res = false;
	cnt = 0;
	FOR(i,n) if (s[i] < 'a' || s[i] > 'z') cnt++;
	if (cnt != 2) res = false;
	cout << (res?"AC":"WA") << endl;  
    return 0;
}


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

void solve() {
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    a[n + 1] = 0;
    int sum = 0;
    int r = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum+= abs(r - a[i]);
        r = a[i];
    }
    sum += abs(r - 0);
    for (int i = 1; i <= n; i++) {
        cout << sum + abs(a[i - 1] - a[i + 1]) - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]);
        cout << endl;
    }

}

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


Measured memory_bytes: 3700
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n,ans=0;cin>>n;
   vector<int> p(n);
   rep(i,n)cin>>p.at(i);
   rep(i,n-2){
   if((p.at(i)<p.at(i+1))+(p.at(i+1)>p.at(i+2))==1)ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] a){
		Scanner scanner = new Scanner(System.in);
		int num = 0;
		
		while(scanner.hasNext()) {
			num = scanner.nextInt() + scanner.nextInt();
			System.out.println((num + "").length());
		}
		
		scanner.close();
    }
}


Measured memory_bytes: 26460
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
#define INF  0x7f7f7f7f//7f7f7f7f
#define M 2000010
#define N 100010
const ll mod = 1e9 + 7;
ll a[M],dp[M],sum[M],n;
int main(void){
	scanf("%lld",&n);
	for(ll i = 1;i <= n;i++){
		scanf("%lld",&a[i]);
		if(i%2)
		sum[i] =sum[i-1]+a[i];
		else
		sum[i] =sum[i-1];
	}
	for(ll i = 2;i <= n;i++){
		if(i%2)
		dp[i] =max(dp[i-2]+a[i],dp[i-1]);
		else
		dp[i] =max(dp[i-2]+a[i],sum[i-1]);
	}
	printf("%lld\n",dp[n]);
	return 0;
}

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

bool c[5000+2][5000+2];

bool t(int x,int y){
	if(x<0)return false;
	if(x>5000)return false;
	if(y<0)return false;
	if(y>5000)return false;
	return c[x][y];
}

int main(){
	while(1){
		int n,ans=0;
		pair<int,int> p[3002];
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<5002;i++)for(int j=0;j<5002;j++)c[i][j]=false;
		for(int i=0;i<n;i++){
			scanf("%d%d",&p[i].first,&p[i].second);
			c[p[i].first][p[i].second]=true;
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(t(p[i].first+p[i].second-p[j].second,p[i].second+p[j].first-p[i].first)&&t(p[j].first+p[i].second-p[j].second,p[j].second+p[j].first-p[i].first))ans=max(ans,(p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));
				if(t(p[i].first-p[i].second+p[j].second,p[i].second-p[j].first+p[i].first)&&t(p[j].first-p[i].second+p[j].second,p[j].second-p[j].first+p[i].first))ans=max(ans,(p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 25628
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	double p[6];
	for(int i=0;i<6;i++){
		cin >>p[i];
	}
    p[2]-=p[0]; p[4]-=p[0];p[0]-=p[0];
	p[3]-=p[1]; p[5]-=p[1];p[1]-=p[1];
	double s=p[2]*p[5]-p[3]*p[4];
	if(s<0)s*=-1;
	double a=hypot(p[2],p[3]);
	double b=hypot(p[4],p[5]);
	double c=hypot(p[4]-p[2],p[5]-p[3]);
	double hmi=s/max(a,max(b,c));
	double ans=s/(a+b+c+2*hmi);
	printf("%.10f\n",ans);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
	var input = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var x = input[0];
    var y = input[1];
    var lake = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var road = new int[y];
    
    for(var i = 0;i < y-1;i++){
       var t = lake[i+1]-lake[i];
    	road[i] = t;
    }
    
    road[y-1] = lake[0] + x -lake[y-1];
    
    var z = road.Max();
    
    Write(x-z);
    
  }
}

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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << "Line " << __LINE__ <<": " << x << nl
#define nl "\n"
#define sp " "

#define fastio() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)

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

const int N = 1e5+5;

int tc = 1;

int x, n, y, ara[105];

int main(){

   	//file();

    fastio();

    //cin >> tc;

    while(tc--){

    	cin >> x >> n;

    	for(int i = 0; i < n; i++){
    		cin >> y;
    		ara[y] = 1;
    	}

    	for(int i = 0; ; i++){

    		y = x - i;

    		if(!ara[y])
    			break;

    		y = x + i;

    		if(!ara[y])
    			break;
    	}

    	cout << y << nl;
    	
    	
    }

    return 0;
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
void dfs(string S,int N,vector<string> &v){
  if(S.size() == N) return;
  if(S.size() == N-1){
  v.push_back(S+'A');
  v.push_back(S+'B');
  v.push_back(S+'C');
  v.push_back(S+'x');
  }
  dfs(S+'A',N,v);
  dfs(S+'B',N,v);
  dfs(S+'C',N,v);
  dfs(S+'x',N,v);
}


int main(){
  ll K,N;
  cin >> K >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll ans = 800000000000;
  rep(i,N){
    if(i == N-1 || i == 0) continue;
    ll d1 = A[i] - A[0] + A[0] + K - A[N-1] + A[N-1] - A[i+1];
    ll d2 = A[N-1] - A[i] + A[0] + K - A[N-1] + A[i-1] - A[0];
    ans = min(ans,min(d1,d2));
  }
  ll d1N = A[N-1] - A[0];
  ll d2N = A[0] + K - A[N-1] + A[N-2] - A[0];
  ans = min(ans,min(d1N,d2N));

  ll d10 = A[N-1] - A[0];
  ll d20 = A[0] + K - A[N-1] + A[N-1] - A[1];
  ans = min(ans,min(d10,d20));

  cout << ans << endl;
  
 }

Measured memory_bytes: 1792
def solve():
    I = input()
    N = list(map(int, list(I)))

    res = sum(N)

    for i in range(len(N)):
        tmp = 0
        for j in range(len(N)):
            if j <= i-1:
                tmp += N[j]
            elif j==i:
                tmp += N[j]-1
            else:
                tmp += 9
        res = max(res, tmp)

    print(res)


if __name__ == "__main__":
    solve()




Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
int ans[510][510];

signed main() {
	cin >> n;
	int cnt = 0;
	for (int i = 2; i < 2 * n; i *= 2) {
		cnt++;
		for (int j = 1; j <= n; j++) {
			for (int k = j + i / 2; k <= n; k += i) {
				ans[j][k] = cnt;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

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

int main(void)
{
    int n, m;
    cin >> n >> m;
    int a[m] = {0}, b[m] = {0};

    int ans[n] = {0};
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }

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

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum > n) cout << -1 << endl;
    else cout << n - sum << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100000
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
int main()
{
    char ch,arr[3];
    bool f = false;
    for(int i=0;i<3;i++){
        scanf("%c",&ch);
        arr[i]=ch;
        if(i>0 && arr[i]!=arr[i-1])
        f = true;

        }
        if(f)
            printf("Yes\n");
            else
                printf("No\n");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

char c;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>c;

for(ll i=0; i<300000000; i++){
	int x=0;
	int y=1;
	x++; y++;
}

if(c=='a'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='e'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='i'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='o'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='u'){
	cout<<"vowel"<<endl;
	return 0;
}

cout<<"consonant"<<endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) cout << "error" << endl;
  else cout << a + b << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N, H;
    cin >> N >> H;
    vector<int> a(N), a_sorted(N), b(N), b_sorted(N);
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
        a_sorted[i]=a[i];
        b_sorted[i]=b[i];
    }
    sort(a_sorted.begin(), a_sorted.end(), greater<int> ());
    sort(b_sorted.begin(), b_sorted.end(), greater<int> ());

    int ans=0;
    for(int i=0; i<N; i++){
        if(b_sorted[i]<a_sorted[0]) break;
        if(H<=0) break;
        ans++;
        H-=b_sorted[i];
    }
    if(H>0){
        if(H%a_sorted[0]!=0) H+=a_sorted[0];
        ans+=H/a_sorted[0];
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll inv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

template <class T>
void chmax(T &a, T b) {
    if (b > a) a = b;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    int m = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        chmax(m, a[i]);
    }

    vector<int> b(m + 1, 0);

    vector<int> q(m + 1, 0);
    for (int i = 2; i * i <= m; i++) {
        if (q[i]) continue;
        for (int j = i * i; j <= m; j += i) {
            if (!q[j]) q[j] = i;
        }
    }

    for (int i = 0; i < n; i++) {
        int t = a[i], p = -1, x = 0;
        for (;;) {
            if (q[t] == p || t == p) {
                x++;
            } else {
                if (p > 0) chmax(b[p], x);
                if (t == 1) break;
                x = 1;
                p = q[t] ? q[t] : t;
            }
            t /= p;
        }
    }

    ll l = 1;
    for (int i = 2; i <= m; i++) {
        for (int j = 0; j < b[i]; j++) {
            l = l * i % P;
        }
    }

    ll r = 0;
    for (int i = 0; i < n; i++) {
        r += l * inv(a[i]) % P;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

void init() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    return;
}

int main() {
    init();

    int n; cin >> n;
    map<char, int> mp;
    string tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp[0] == 'M' || tmp[0] == 'A' || tmp[0] == 'R' || tmp[0] == 'C' || tmp[0] == 'H') {
            ++mp[tmp[0]];
        }
    }

    long long res = 0;
    int kinds = mp.size();
    vector<int> moji;
    // mapをvectorみたいにfor文使う苦肉の策
    for (auto x : mp) {
        moji.push_back(x.second);
    }

    // 文字が3種類以上なかったら処理しない
    if (moji.size() >= 3) {
        for (size_t i = 0; i < moji.size() - 2; i++) {
            for (int j = i + 1; j < moji.size(); j++) {
                for (int z = j + 1; z < moji.size(); z++) {
                    res += moji[i] * moji[j] * moji[z];
                }
            }
        }
    }
    cout << res << endl;

 	return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;

ll fac[maxn], inv[maxn];

ll modPow(ll a, ll b){
	if(b == 0){return 1;}
	else{
		if(b % 2 == 1){return a*modPow(a,b-1)%mod;}
		else{
			ll temp = modPow(a,b/2);
			return temp*temp%mod;
		}
	}
}

ll c(int a, int b){
	ll bil = fac[a]*inv[b];
	bil %= mod;
	return bil*inv[a-b]%mod;
}

int main(){
	int i,j;
	fac[0] = inv[0] = 1;
	for(i=1;i<maxn;i++){
		fac[i] = (ll)i*fac[i-1];
		fac[i] %= mod;
		inv[i] = modPow(fac[i], mod-2);
	}
	int n,k;
	int a[maxn];
	scanf("%d %d",&n,&k);
	ll ans = 0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		int sisa = n - i - 1;
		if(sisa >= (k-1)){
			ll banyak = c(sisa, k-1);
			ll tot = a[i]*banyak;
			ans -= tot; ans %= mod;
			if(ans < 0){ans += mod;}
		}
	}
	for(i=0;i<n;i++){
		int sisa = i;
		if(sisa >= (k-1)){
			ll banyak = c(sisa, k-1);
			ll tot = a[i]*banyak;
			ans += tot; ans %= mod;
		}	
	}
	printf("%lld\n",ans);
	return 0;
};

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int n = sc.nextInt();
            int[] d = new int[n];
            for (int i = 0; i < n; i++) {
                d[i] = sc.nextInt();
            }
            Arrays.sort(d);

            int count = 0;

            System.out.println(d[n/2] - d[n/2-1]);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 34588
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
 int a, b, c, i;

 cin >> a >> b;

 i = a % b;
 if (i == 0) {
	 c = a / b;
	 cout << c;
	}
 else {

	 c = a / b + 1;

	 cout << c;
	}
}

Measured memory_bytes: 256
N = int(input())
S = input()
WL = 0
WR = 0
BL = 0
BR = 0

for i in range(N):
    if S[i] == '#':
        BR += 1
    else:
        WR += 1

ans = BL+WR

for i in range(N):
    if S[i] == '#':
        BR -= 1
        BL += 1
    else:
        WR -= 1
        WL += 1
    ans = min(ans,BL+WR)
print(ans)


Measured memory_bytes: 3500
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
		long mod = 1000000000 + 7;
		this.xList = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long yoko = 0;
        for (int i = 1; i < xList.Length; i++) {
            yoko += (xList[i] - xList[i - 1]) % mod * i % mod * (xList.Length - i) % mod;
            yoko = yoko % mod;
        }
        this.yList = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long tate = 0;
        for (int i = 1; i < yList.Length; i++)
		{
            tate += (yList[i] - yList[i - 1]) % mod * i % mod * (yList.Length - i) % mod;
            tate = tate % mod;
		}

        long ans = yoko * tate % mod;
        Console.WriteLine(ans);
    }

    private long[] xList;
    private long[] yList;


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


3 3
1 3 4
1 3 6



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 37964
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k, mask = 0;
    cin >> n >> k;
    while (k--)
    {
        int x;
        cin >> x;
        mask |= 1 << x;
    }
    akari<seika> ans;
    for (int s = mask;; s = (s - 1) & mask)
    {
        stringstream ss;
        ss << s << ':';
        for (int i = 0; i < n; i++)
        {
            if (s >> i & 1)
            {
                ss << ' ' << i;
            }
        }
        ss << '\n';
        ans.push_back(ss.str());
        if (s == 0)
        {
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    for (auto &s : ans)
    {
        cout << s;
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 23840
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int b;
    vector<int> v;
    vector<int> ans;
    for(int i=0;i<n;i++){
        cin>>b;
        v.pb(b);
    }
    int niko=v.size();
    for(int i=0;i<niko;i++){
        for(int j=v.size()-1;j>=0;j--){
            if(j+1==v[j]){
                ans.pb(j+1);
                v.erase(v.begin()+j);
                j=0;
            }
            else if(j==0){
                cout << -1<<endl;
                return 0;
            }
        }
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout << ans[i]<<endl;
    }

    return 0;
}





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

vector<int> prime_vector(int n) {
    vector<int> p;
    vector<char> q(n);
    int m = (int)sqrt(n - 1);

    for (int i = 2; i <= m; i++) {
        if (q[i] != 0) continue;
        for (int j = i * i; j < n; j += i) {
            q[j] = 1;
        }
    }
    for (int i = 2; i < n; i++) {
        if (q[i] == 0) p.push_back(i);
    }
    return p;
}

int main() {
    int64_t n, n0;
    cin >> n;
    n0 = n;

    auto p = prime_vector(100000);
    vector<pair<int64_t, int>> q;
    for (int i : p) {
        int k = 0;
        while (n % i == 0) n /= i, k++;
        if (k > 0) q.push_back({ i, k });
    }
    if (n != 1) q.push_back({ n, 1 });

    int64_t r = n0;
    int m = 1;
    for (auto u : q) m *= u.second + 1;
    for (int i = 0; i < m; i++) {
        int64_t t = 1;
        int i1 = i;
        for (auto u : q) {
            int k = i1 % (u.second + 1);
            for (int j = 0; j < k; j++) t *= u.first;
            i1 /= u.second + 1;
        }
        r = min(r, max(t, n0 / t));
    }
    int64_t t = 1;
    for (int i = 1; i < 12; i++) {
        t *= 10;
        if (r < t) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;
vvi a,b;

int main(){
	cin>>h>>w;
	a=b=vvi(h,vi(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
	if(w==1){
		int res=0;
		for(int i=0;i<h;i++) res+=a[i][0];
		cout<<res<<endl;
		return 0;
	}
	for(int i=0;i<h;i++){
		int t=0;
		for(int j=0;j<w;j++){
			t+=a[i][j];
			if(j&&i+1<h) t-=a[i+1][j-1];
			b[i][j]=t;
		}
	}
	vvi dp(w,vi(w,-inf));
	for(int i=1;i<w;i++) dp[0][i]=b[0][i];
	for(int i=1;i<h;i++){
		vvi DP(w,vi(w));
		for(int j=0;j<w;j++) for(int k=0;k<w;k++){
			if(j) dp[j][k]=max(dp[j-1][k],dp[j][k]);
		}
		for(int j=0;j<w;j++){
			int mx=-inf;
			for(int k=j+1;k<w;k++){
				mx=max(mx,dp[j][k]);
				DP[j][k]=mx+b[i][j]+b[i][k];
			}
		}
		dp=DP;
	}
	int res=0;
	for(int i=0;i<w;i++) for(int j=0;j<w;j++) res=max(res,dp[i][j]);
	cout<<res<<endl;
}

Measured memory_bytes: 960
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        int a[] = new int[t];
        for (int i = 0; i < t; i++)
            a[i] = sc.nextInt();

        Arrays.sort(a);
        System.out.println(Math.max(0, a[t - 1] - 1 - (k - a[t - 1])));
    }
}

Measured memory_bytes: 21204