akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int b_s(vector<llint>& a, llint key) {
	int left = -1;
	int right = a.size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[mid] > key)right = mid;
		else left = mid;
	}
	return right;
}
int main() {
	int a, b;
	cin >> a;
	b = 1000 - a % 1000;
	if (b == 1000)b = 0;
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 3636
//cod2017_qualA_b.cpp
//Sat Nov 10 19:25:53 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int flag = 0;
	for (int i=0;i<=n;i++){
		if (flag == 1){
			break;
		}
		for (int j=0;j<=m;j++){
			if (k == i*(m-j)+(n-i)*j){
				cout << "Yes" << endl;
				flag = 1;
				break;
			}
		}
	}

	if (flag == 0){
		cout << "No" << endl;
	}

	
}

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

int n;

vector < bool > tobin (int x) {
	vector < bool > res(n, 0);
	int cur = (1 << (n - 1)), cnt = n - 1;
	while (cur) {
		if (x >= cur) {
			x -= cur;
			res[cnt] = 1;
		}
		cur >>= 1;
		--cnt;
	}
	return res;
}

void ckmax (int &x, int a) {
	x = max(x, a);
}

signed main () {
	cin >> n;
	vector < vector < int > > a(n, vector < int > (n, -1));
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int x, y;
			cin >> x >> y;
			a[i][x - 1] = y;
		}
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << n); ++mask) {
		vector < bool > knight = tobin(mask);
		bool cap = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (a[i][j] != -1) {
					if (knight[i] && knight[j] != a[i][j])
						cap = 1;
				}
			}
		}
		if (!cap)
			ckmax(ans, count(knight.begin(), knight.end(), 1));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
  int kaisu;
  int i;
  scanf("%d",&kaisu);
  for(i=0;i<kaisu;i++){
    double a,b,c,d,e,f;
	double kyori;
    scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f);
	kyori=sqrt((d-a)*(d-a)+(e-b)*(e-b));
	if(kyori<c-f)
	  puts("2");
	else if(kyori<f-c)
	  puts("-2");
	else if(kyori<=c+f)
	  puts("1");
	else
	  puts("0");
  }
  return 0;
}

Measured memory_bytes: 620
#include <iostream>

using namespace std;
 unsigned long long a[100005],b,n,i,p,x,p18;

int main()
{
    cin>>n;
  p18=1000000000000000000;


    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        if(!a[i])
        {
            cout<<0;
            return 0;
        }

    }
    p=1;
    for(i=1; i<=n; i++)
    {
        x=a[i];
        if(x>p18/p)
        {
            cout<<-1;
            return 0;
        }
        p*=x;

    }
   cout<<p;
    return 0;
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == 'R') ans++;
	}
	if (ans == 2 && s[1] == 'S') ans--;
	cout << ans << endl;
}



Measured memory_bytes: 3616
#include <stdio.h>
 
int main(void) {
	int sx, sy, tx, ty;
 
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
 
	for (int i = 0; i < tx - sx; i++)
		putchar('R');
	for (int i = 0; i < ty - sy; i++)
		putchar('U');
	for (int i = 0; i < tx - sx; i++)
		putchar('L');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('D');
	for (int i = 0; i < tx - sx + 1; i++)
		putchar('R');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('U');
	putchar('L');
	putchar('U');
	for (int i = 0; i < tx - sx + 1; i++)
		putchar('L');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('D');
	puts("R");
 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int M=(int)1e9+1,t=0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
// vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
 
// void dfs(int v){
//     vis[v]=1;
//     for(int i:adj[v]){
//         if(vis[i]){
//             t=1;
//             return ;
//         }
//             //dis[i]=1+dis[v];
//             //parent[i]=v;
//             vis[i]=1;
//             dfs(i);

//     }
//     return ;
    
// }




signed main(){
    fio;
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    int dp[n+1];
    dp[0]=dp[1]=0;
    dp[2]=abs(v[1]-v[2]);
    for(int i=3;i<=n;i++){
        dp[i]=M;
        for(int j=1;j<=k;j++){
            if(i>j) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
    


    

    
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,k,s; cin >> n >> k >> s;
    if(s != 1000000000){
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << s+1 << " ";
    }else{
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vll = vector<long long>;

int main(){
  int n; cin >> n;
  cout << n*n << endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::HashMap;

#[fastout]
fn main() {
  input! {
    n: usize,
    vals: [isize;n]
  }
  let mut result = 0;
  let mut map: HashMap<isize, isize> = HashMap::new();
  
  for i in 2..n {
    let v = vals[i];
    let i = i as isize;
    let entry = map.entry(i - v).or_insert(0);
    *entry += 1;
  }
  for i in 0..n {
    let v = vals[i];
    let i = i as isize;
    if let Some(v) = map.get(&(v+i)) {
      result += v;
    }
  }
  println!("{}", result);
}

Measured memory_bytes: 11780
#include<iostream>
#include<string>
using namespace std;
string S;
int main(){
    int count = 0;
    int flag = 0;
    cin >> S;
    if(S[0] == 'A'){
        for(int i = 2;i < S.size() - 1; i++){
            if(S[i] == 'C'){
                count++;
            }else if(S[i] <= 'Z' && S[i] >= 'A'){
                flag = 1;
            }
        }
        if((S[1] >= 'A' && S[1] <= 'Z') || (S[S.size()-1] >= 'A' && S[S.size()-1] <= 'Z')){
            flag = 1;
        }
        if(count != 1){
            flag = 1;
        }
        if(S[S.size()-1] == 'C' || S[1] == 'C'){
            flag = 1;
        }
    }else{
        flag = 1;
    }
    if(flag == 1){
        cout << "WA" << endl;
    }else{
        cout << "AC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s[1<<17];k,A,B,M;main(m){for(scanf("%*d%d",&m);~scanf("%d%d",&A,&B);){for(M=1;B/M/M;s[++M]-=k)s[M]+=k=~-A/M<B/M;for(k=B/M;k;s[M=B/k--+1]--)s[M=fmax(~-A/k+1,M)]++;}for(;k++<m;)printf("%d ",*s+=s[k]);}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int X = 0, Y = 0;
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      X = max(X, x);
    } else if (a == 2) {
      W = min(W, x);
    } else if (a == 3) {
      Y = max(Y, y);
    } else if (a == 4) {
      H = min(H, y);
    }
  }
  if ((W - X) <= 0 || (H - Y) <= 0)
    cout << 0 << endl;
  else
    cout << (W - X) * (H - Y) << endl;
}

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

typedef long long ll;

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

    int uku;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            uku = i;
            break;
        }
    }
    for(int i=uku+1;i<s.size();i++){
        if(s[i]=='F'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    ans = a[-1]
    n -= 2
    for i in range(n // 2):
        ans += a[n - i] * 2
    if n % 2 == 1:
        ans += a[n - n // 2]
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31752
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

enum Color { red, green, colorless }
alias S = Tuple!(long, "value", Color, "color");

long calc(int x, int y, long[] a, long[] b, long[] c) {
    a.sort!"a > b";
    b.sort!"a > b";
    c.sort!"a > b";

    S[] s;
    foreach (e; a.take(x).map!(e => S(e, Color.red))) s ~= e;
    foreach (e; b.take(y).map!(e => S(e, Color.green))) s ~= e;
    foreach (e; c.map!(e => S(e, Color.colorless))) s ~= e;
    s.sort!"a.value > b.value";

    long ans = 0;
    int red = 0;
    int green = 0;
    int colorless = 0;
    foreach (e; s) {
        if (red + green + colorless == x + y) break;

        ans += e.value;
        final switch (e.color) {
            case Color.red:
                if (red < x) red++;
                break;
            case Color.green:
                if (green < y) green++;
                break;
            case Color.colorless:
                colorless++;
                break;
        }
    }
    return ans;
}

void main() {
    int x, y, A, B, C; scan(x, y, A, B, C);
    auto a = reads!long;
    auto b = reads!long;
    auto c = reads!long;
    writeln(calc(x, y, a, b, c));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

int modPow(int x, int n, int mod) {
    int sum = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            sum = sum * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return sum;
}

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

    int n = s.length();

    int dp[n + 1];
    dp[n] = 0;
    dp[n - 1] = s.at(n - 1) - '0';
    for (int i = n - 2; i >= 0; i--) {
        dp[i] = (dp[i + 1] + ((modPow(10, n - i - 1, 2019) * (s.at(i) - '0')) % 2019)) % 2019;
    }

    int m[2019];
    for (int i = 0; i < 2019; i++) m[i] = 0;

    for (int i = 0; i < n + 1; i++) m[dp[i]]++;

    int ans = 0;
    for (int i = 0; i < 2019; i++) ans += m[i] * (m[i] - 1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 4512
#include <string>
#include <vector>
#include <iostream>

#pragma warning(disable : 4996)

#define mod 100000

using namespace std;

int H, W, dp[2][1 << 19][2][2]; string M[20];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) cin >> M[i];

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < (1 << (W - 1)); j++)
		{
			dp[(i ^ 1) & 1][j][0][0] = 0;
			dp[(i ^ 1) & 1][j][0][1] = 0;
			dp[(i ^ 1) & 1][j][1][0] = 0;
			dp[(i ^ 1) & 1][j][1][1] = 0;
		}

		for (int j = 0; j < (1 << (W - 1)); j++)
		{
			char c = M[(i + 1) / W][(i + 1) % W];

			int nxt = (j << 1) % (1 << (W - 1));

			int sum0 = (dp[i & 1][j][0][0] + dp[i & 1][j][1][0]) % mod;
			int sum1 = (dp[i & 1][j][0][1] + dp[i & 1][j][1][1]) % mod;

			if (c == 'J' || c == '?')
			{
				dp[(i ^ 1) & 1][nxt][0][0] += sum0;
				dp[(i ^ 1) & 1][nxt][0][1] += sum1;
			}

			if (c == 'O' || c == '?')
			{
				if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][nxt + 1][1][0] += dp[i & 1][j][0][0];
					dp[(i ^ 1) & 1][nxt + 1][1][1] += dp[i & 1][j][0][1];

					dp[(i ^ 1) & 1][nxt + 1][1][0] %= mod;
					dp[(i ^ 1) & 1][nxt + 1][1][1] %= mod;

					dp[(i ^ 1) & 1][nxt][1][0] += (sum0 - dp[i & 1][j][0][0] + mod);
					dp[(i ^ 1) & 1][nxt][1][1] += (sum1 - dp[i & 1][j][0][1] + mod);
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
					dp[(i ^ 1) & 1][nxt][1][1] += sum1;
				}
			}

			if (c == 'I' || c == '?')
			{
				if (j & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][nxt][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][nxt][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][nxt][1][0] %= mod;
			dp[(i ^ 1) & 1][nxt][1][1] %= mod;
		}
	}

	int ret = 0;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= mod;
	}

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

	return 0;
}

Measured memory_bytes: 19716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N;
  cin>>N;
  double x,sum=0;
  string u;
  rep(i,N){
    cin>>x>>u;
    if(u[0]=='J') sum+=x;
    else sum+=380000.0*x;
  }
  cout<<sum<<endl;
}

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

using namespace std;

void dfs(const vector<vector<int> >& AB, vector<int>& counter, int p, int v)
{
  if(p != -1){
    counter[v] += counter[p];
  }
  for (int i = 0; i < AB[v].size(); i++)
  {
    if(AB[v][i] == p)continue;
    dfs(AB, counter, v, AB[v][i]);
  }
}

int main()
{
  int N, Q, a, b, p, x;
  cin >> N >> Q;
  vector<vector<int>> AB(N);
  vector<int> counter(N, 0);
  for (int i = 0; i < N - 1;i++){
    cin >> a >> b;
    AB[a - 1].push_back(b - 1);
    AB[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < Q; i++)
  {
      cin >> p >> x;
      counter[p - 1] += x;
  }
  dfs(AB, counter, -1, 0);
  for (int i = 0; i < counter.size();i++){
    cout << counter[i] << endl;
  }
  return 0;
}

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

int main()
{
	int n = 0, c = 0, s = 0, f = 0;

	cin >> n;

	vector<int> t(n, 0);

	if (n > 1) {
		for (int i = 0; i < n - 1; i++) {
			cin >> c >> s >> f;
			for (int j = 0; j < i + 1; j++) {
				int u = 0;
				while (t[j] > s + u * f)
					u++;
				t[j] = c + s + u * f;
			}
		}
	}

	for (int i = 0; i < n; i++)
		cout << t[i] << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C-(A-B)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int min(int a ,int b){
    if(a>b){
        return(b);
    }else{
        return(a);
    }
}
int max(int a ,int b){
    if(a<b){
        return(b);
    }else{
        return(a);
    }
}
int main(){
    int n;
    cin>>n;
    int a[n];
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    int mm=abs(a[n-1]-a[0]-a[0]);
    for(int i=1;i<n;i++){
        if(mm>abs(a[n-1]-a[i]-a[i])){
            mm=abs(a[n-1]-a[i]-a[i]);
        }
    }
    cout<<mm<<endl;
    return(0);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
res = [[0 for i in range(2)] for j in range(N)]
ac = 0
wa = 0

for i in range(M):
  p, s = input().split()
  p = int(p)
  if res[p - 1][0] == 0:
    if s == "AC":
      ac += 1
      res[p - 1][0] = 1
    else:
      res[p - 1][1] += 1

for i in range(N):
  if res[i][0] == 1:
    wa += res[i][1]

print(ac, wa)

Measured memory_bytes: 14836
X, Y, Z = list(map(int, input().split()))
for i in range(0, 10**5+1):
  if X - (i*Y + (i+1)*Z) == 0:
    print(i)
    exit()
  if X - (i*Y + (i+1)*Z) < 0:
    print(i-1)
    exit()

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

int main() {
    ll h, n;
    cin >> h >> n;
    vector<pair<ll, ll>> magic(n);
    for (int i = 0; i < n; ++i) {
        cin >> magic[i].first >> magic[i].second;
    }
    vector<vector<ll>> dp(1010, vector<ll>(10100, 1001001001001001001));
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        ll power = magic[i].first;
        ll cost = magic[i].second;
        for (int j = 0; j <= h; ++j) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][min(h, j + power)] = min(dp[i + 1][min(h, j + power)], dp[i + 1][j] + cost);
        }
    }
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 80128
package main

import (
	"fmt"
)

func input() (int, int, int) {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	return a, b, c
}
func check(arr []int) int {
	check5 := 0
	check7 := 0
	for _, val := range arr {
		if val == 5 {
			check5 += 1
		} else if val == 7 {
			check7 += 1
		} else {
			return 0
		}
	}
	if check5 == 2 && check7 == 1 {
		return 1
	}
	return 0
}

func main() {
	a, b, c := input()
	ok := 0
	arr := []int{a, b, c}
	ok = check(arr)

	if ok == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n,x,y;
	cin>>n>>x>>y;

	int ans[n]={};
	int dis[n][n]={};
	int k=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			dis[i][j]=dis[i][j-1]+1;
		}
		for(int j=i-1;j>=0;j--){
			dis[i][j]=dis[i][j+1]+1;
		}
		if(dis[i][y-1]>dis[i][x-1]+1){
			dis[i][y-1]=dis[i][x-1]+1;
			k=y-1;
		}
		else if(dis[i][x-1]>dis[i][y-1]+1){
			dis[i][x-1]=dis[i][y-1]+1;
			k=x-1;
		}
		for(int j=k+1;j<n;j++){
			dis[i][j]=min(dis[i][j],dis[i][j-1]+1);
		}
		for(int j=k-1;j>=0;j--){
			dis[i][j]=min(dis[i][j],dis[i][j+1]+1);
		}
	}

	rep(i,n){
		rep(j,n)ans[dis[i][j]]++;
	}
	for(int i=1;i<n;i++)cout<<ans[i]/2<<endl;

	return 0;
}


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

using namespace std;

int main(void)
{
  int n,d;
  cin>>n>>d;
  d=1+2*d;
  if(d>=n) cout<<1;
  else{
    if(n%d==0) cout<<n/d;
    else{ cout<<n/d+1; }
  }
  return 0;
}

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

#define True 1
#define False 0

int primelist[1000000]={2,3,5,7};
int pcnt=4;
int pnow=7;

int expandPrimeList(int n){
	int i;
	while(pnow<n){
		pnow++;
		for(i=0;i<pcnt;i++){
			if(pnow%primelist[i]==0){
				break;
			}
			if(primelist[i]>sqrt(pnow)){
				i=pcnt;
				break;
			}
		}
		if(i==pcnt){
			primelist[pcnt]=pnow;
			pcnt++;
		}
	}
}

int primecount(int n){
	int s=0;
	expandPrimeList(n);
	for(int i=0;i<pcnt;i++){
		if(primelist[i]<=n){
			s++;
		}else{
			break;
		}
	}
	return s;
}

int main(){
	int n;
	int S;
	while(True){
		scanf("%d",&n);
		if(feof(stdin))break;
		printf("%d\n",primecount(n));
	}
	return 0;
}



Measured memory_bytes: 2152
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	double N, T, A,m=9999999999;
	ll an;
	cin >> N >> T >> A;
	rep(i, N) {
		double H;
		cin >> H;
		if (m > abs(T - 0.006 * H - A)) {
			m = abs(T - 0.006 * H - A);
			an = i + 1;
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー
int length(char* str) {
	int len = strlen(str);
	return len;
}
ll GCD(ll a,ll b)
{

    ll r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }


    return b;
}
ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int N;
    char A[100010], B[100010];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << B[i];
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> x;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        x.push_back(abs(tmp - X));
    }
    if (N == 1) {
        cout << x[0] << endl;
        return 0;
    }
    int a = x[0];
    for (int i = 1; i < N; ++i) {
        int b = x[i];
        a = gcd(a, b);
    }
    cout << a << endl;
}


Measured memory_bytes: 892
N = int(input())
t = 0
ans = 0
for i in range(N):
    a = int(input())
    if t == 1:
        ans += (a+1)//2
        t = (a+1) % 2
    else:
        ans += a//2
        t = a % 2
    if a == 0:
        t = 0
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int check (vi &arr, int k) {
	mii nums;
	vi comp(len(arr), -1);
	int n = len(arr);

	// calculating for first element 

	forn(0, min(k + 1, n), i) nums[arr[i]] += 1;
	comp[0] = distance(nums.begin(), nums.find(arr[0])) + 1;

	if (n == 1) return 1;

	nums.clear();

	// calculating for second element
	for (int i = max(0LL, 1 - k); i < min(1 + k, n); i += 1) nums[arr[i]] += 1;
	for (int i = 1; i < n; i += 1) {
		cout << i << " " << i - k << " " << i + k << endl;
		if (i + k < len(arr)) {
			nums[arr[i + k]] += 1;
		}
		if (comp[i] == -1) {
			if (nums.find(arr[i]) == nums.end()) cerr << "boo!" << endl;
			comp[i] = (distance(nums.begin(), (nums.find(arr[i])))) + 1;
		}

		if (i - k >= 0) {
			nums[arr[i - k]] -= 1;
			if (nums[arr[i - k]] == 0) nums.erase(nums.find(arr[i - k]));
		}
	}
	int s = 0;
	forn(0, n, i) {
		cerr << comp[i] << " "; 
		s += comp[i];
	}
	cerr << endl;
	return s; 
} 

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;

	int k;
	cin >> k;

	int d = 0;

	for (int i = 1; i <= n; i += 1) {
		int x;
		cin >> x;

		if (x < k - x) d += 2 * x;
		else d += 2 * (k - x);
	}

	print(d);
	end_routine;
}


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

using namespace std;

typedef long long ll;

const int MAX_HW = 500;

int main(int argc, char const *argv[]) {
  int h, w;
  cin >> h >> w;
  int a[MAX_HW][MAX_HW];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> a[i][j];
  }
  vector<int> x, y, xd, yd;
  ll n = 0;

  vector<int> aline;
  vector<pair<int,int>> xy;
  ll cnt = 0;

  for (int i = 0; i < h; i++) {
    if (cnt%2==0) {
      for (int j = 0; j < w; j++) {
        aline.push_back(a[i][j]);
        xy.push_back(make_pair(i,j));
      }
    }
    else {
      for (int j = w-1; j >= 0; j--) {
        aline.push_back(a[i][j]);
        xy.push_back(make_pair(i,j));
      }
    }
    cnt++;
  }
  for (int i = 0; i < aline.size()-1; i++) {
    if (aline[i]%2==1) {
      aline[i]--;
      aline[i+1]++;
      n++;
      x.push_back(xy[i].first);
      y.push_back(xy[i].second);
      xd.push_back(xy[i+1].first);
      yd.push_back(xy[i+1].second);
    }
  }

  cout << n << endl;
  for (int i = 0; i < x.size(); i++) {
    cout << x[i]+1 << ' ' << y[i]+1 << ' ' << xd[i]+1 << ' ' << yd[i]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 10344
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,c,d,e,g,i,j,k,t;
int A,B,C,X,Y,Z;
int MIN ,ans,mid;
float f;
char str[3];

int main()
{
	scanf("%d%d",&a,&b);
	int flag=0;
	for(i=b*10;i<=(b*10+9);i++)
	{
		f=(float)(i)*0.08;
		if((f-a)<1.0&&(f-a)>=0)
		{
			c=i;
			flag=1;
		}
		if(flag) break;
	}
	if(flag) printf("%d\n",c);
	else printf("-1\n");
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  char left[15] = {'q', 'w', 'e', 'r', 't', 'a', 's', 'd',
                   'f', 'g', 'z', 'x', 'c', 'v', 'b'};
  char right[11] = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};

  while (true) {
    string str;
    cin >> str;
    if(str == "#") break;

    bool isleft;
    REP(i, 15) if (left[i] == str[0]) isleft = true;
    REP(i, 11) if (right[i] == str[0]) isleft = false;
    /*
    if(isleft) cout << "left" << endl;
    else cout << "right" << endl;
  */
    int cnt = 0;
    FOR(i, 1, str.size()) {
      //????????????????§??????????
      if (isleft) {
        REP(j, 11) {
          // cout << right[j] << " ";
          if (right[j] == str[i]) {
            cnt++;
            isleft = false;
          }
        }
      } else {
        REP(j, 15) {
          // cout << left[j] << " ";
          if (left[j] == str[i]) {
            cnt++;
            isleft = true;
          }
        }
      }
      //cout << endl;

      // if(isleft) cout << "left " << str[i] << endl;
      // else cout << "right " << str[i] << endl;
    }

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3120
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    int x; cin>>x;
    s ss; cin>>ss;
    s l,o;
    l=ss.substr(x/2);
    o=ss.substr(0,x/2);
    if(x&1){cout<<"No";}
    else{if(l==o){cout<<"Yes";}else cout<<"No";}

























return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<50)
int N,A,B,C[100000];
bool func(int X){
  int ret=0;
  rep(i,0,N) ret+=(max(0ll,(C[i]-B*X))+A-B-1)/(A-B);
  if(ret<=X) return 1;
  return 0;
}
signed main(){
  cin>>N>>A>>B;
  int left=0,right=0;
  rep(i,0,N){
    cin>>C[i];
    right=max(right,C[i]);
  }
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)) right=mid;
    else left=mid;
  }
  int ans=right;
  if(func(left)) ans=left;
  cout<<ans<<endl;
  }



Measured memory_bytes: 1024
#include "iostream"
#include "vector"
#include "string"
#include "cstring"

using namespace std;

int main(){
    int N,sum=0;
    char str[3][100];
    char alfa[26] = {0};
    bool one=true,two=false,three=false;
    cin >> N;
    cin >> str[0];
    cin >> str[1];
    cin >> str[2];

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            switch(++alfa[str[j][i]-'a']){
                case 1:one=true;break;
                case 2:two=true;break;
                case 3:three=true;break;    
            }
        }
        if(three);
        else if(two)sum+=1;
        else sum+=2;
        one=false;two=false;three=false;
        memset(alfa,0,26);
    }
    cout << sum;

    return 0;
}



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

namespace Atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var l = inputs[0];
            var r = inputs[1];
            var d = inputs[2];
            
            var result = 0;
            for(var i = l; i <= r; i++)
            {
                if (i % d == 0)
                    result++;
            }
            Console.WriteLine(result.ToString());

        }
    }
}


Measured memory_bytes: 28140
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N, Q;
   cin >> N >> Q;
   string S;
   cin >> S;
   int AC[N + 1];
   memset(AC, 0, sizeof(AC));
   for (int i = 1; i < N; i++) {
      if (S[i - 1] == 'A' && S[i] == 'C') AC[i + 1] = AC[i] + 1;
      else AC[i + 1] = AC[i];
   }
   int l, r;
   for (int q = 0; q < Q; q++) {
      cin >> l >> r;
      cout << AC[r] - AC[l] << endl;
   }
   
   return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		System.out.println(sum(sc));
	}

	static int sum(Scanner sc){
		int a = 700;
		String s = sc.next();

		for( int i = 0 ; i < 3 ; ++i){
			if(s.charAt(i) == 'o'){
				a = a + 100;
			}
		}

		return a;
	}
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

const int MaxN=1e6+5;

ll a[MaxN];
int num[MaxN];

ll qPow(ll a,ll b){
    ll ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        b>>=1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];

    for(int i=0; i<n; i++){
        int x=a[i];
        for(int j=2; j*j<=x; j++){
            if(x % j == 0){
                int cnt = 0;
                while(x % j == 0){
                    x /= j;
                    cnt++;
                }
                num[j]=max(cnt,num[j]);
            }
        }
        if(x>1) num[x]=max(num[x],1);
    }
    
    ll tmp = 1;
    for(int i=0; i < MaxN; i++){
        for(int j=0;j<num[i];j++){
            tmp = (tmp * i) % MOD;
        }
    }

    ll ans=0;
    for(int i=0;i<n;i++) ans = (ans + tmp * qPow(a[i], MOD-2)) % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4096
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::collections::{VecDeque, BinaryHeap, BTreeMap};
use std::f32::MAX;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn main() {
    let_all!(a: usize, b: usize, c: usize);
    if (a == 1 && b == 1) || c == 1 {
        println!("Open");
    }else {
        println!("Close");
    }
}



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

signed main(void)
{
	IOS;
	// int n; cin>>n;
	// vii s(n);
	// for(int i = 0; i < n; i++) {
	// 	int x,l; cin>>x>>l;
	// 	s[i]={x-l,x+l};
	// }
	// sort(all(s));
	// priority_queue<int> pq1;
	// pq1.push(s[0].ss);
	// int cnt=n;
	// for(int i = 1; i < n; i++) {
	// 	int rr  = pq1.top();
	// 	if(rr > s[i].ff) {
	// 		if(rr >= s[i].ss) {
	// 			pq1.pop();
	// 			pq1.push(s[i].ss);
	// 			cnt--;
	// 		} else {
	// 			cnt--;
	// 		}
	// 	}
	// }
	// cout<<cnt<<endl;

	int n,k,s;
	cin>>n>>k>>s;
	vi a(n);
	for(int i = 0; i < k; i++) {
		a[i]=s;
	}
	for(int i = k; i < n; i++) {
		if(s==1e9)
			a[i]=s-1;
		else
			a[i]=s+1;
	}
	for(int i: a)
		cout<<i<<" ";
	cout<<endl;
	time();
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	
	printf("%d\n", n - k + 1);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define min(a, b) (a < b ? a : b)

#define MAX 101
#define INF 1000000000

int matChainOrder(int *p, int n) {
  int i, l, j, k, q, result = 0;
  int m[MAX][MAX];
  
  for (i = 1; i <= n; i++) {
    m[i][i] = 0;
  }

  for (l = 2; l <= n; l++) {
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      m[i][j] = INF;
      for (k = i; k <= j - 1; k++) {
	q = m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j];
	result = m[i][j] = min(m[i][j], q);
      }
    }
  }
  return result;
}


int main() {
  int i;
  int n, t, p[MAX];

  scanf("%d", &n);

  for (i = 1; i <= n; i++) {
    if (i == 1) scanf("%d %d", &p[0], &p[i]);
    else scanf("%d %d", &t, &p[i]);
  }
  printf("%d\n", matChainOrder(p,n));
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int A, B, C;
    int a, b, c;
    cin >> a >> b >> c;
    //int dpA[n];
    //int dpB[n];
    //int dpC[n];
    if (n == 1)
        cout << max({ a, b, c }) << endl;
    else
    {
        A = a;
        B = b;
        C = c;
        for (int i = 1; i < n; i++)
        {
            cin >> a >> b >> c;
            int ta = max({ B + a, C + a, A });
            int tb = max({ C + b, A + b, B });
            int tc = max({ B + c, A + c, C });
            A = ta;
            B = tb;
            C = tc;
        }
        cout << max({ A, B, C }) << endl;
    }
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int n;
    cin >> n;
    int count=0;
    char c;
    for(int i=0; i<n; i++){
        cin >> c;
        if(c=='R')count++;
    }
    cout << (count>n-count?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
B = {}
for i in range(3):
    for j, e in enumerate(input().split()):
        B[e] = (i, j)

L = []
for i in range(8):
    L.append(0)
        
N = int(input())
for i in range(N):
    b = input()
    if b in B:
        L[B[b][0] % 3] += 1
        L[(B[b][0] * 3 + B[b][1]) % 3 + 3] += 1
        if B[b][0] == B[b][1]:
            L[6] += 1
            if B[b][0] == 1:
                L[7] += 1
        elif abs(B[b][0] - B[b][1]) == 2:
            L[7] += 1
            
if 3 in L:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    string s;
    cin >> s;
    int m = (s[5] - '0') * 10 + (s[6] - '0');
    if(m >= 5){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI l(2*n);
    REP(i,2*n){
        cin >> l[i];
    }

    SORT(l);

    int ans0 = 0 ,ans1=0;
    REP(i,n){
        ans0 += min(l[2*i],l[2*i+1]);
    }
    FOR(i,1,n){
        ans1 += min(l[2*i-1],l[2*i]);
    }

    cout << max(ans0,ans1) << ENDL;

    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main() {
    int A, B, C;
    int day;
    int coin = 0;
    scanf("%d %d %d", &A, &B, &C);
    for (day = 1; coin < C; day++) {
        if (day % 7 == 0) coin += A + B;
        else coin += A;
    }
    printf("%d\n", day-1);
    return 0;
}


Measured memory_bytes: 2112
import fractions
a,b = [int(i) for i in input().split()]

l = [int(i) for i in input().split()]

l2 = [abs(i-b) for i in l]

ans = l2[0]

for i in range(len(l2)):
    ans = fractions.gcd(l2[i],ans)
    
print(ans)



Measured memory_bytes: 16276
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var nx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        a = a.OrderBy(n => n).ToArray();
        int x = nx[1];
        for (int i = 0; i < a.Length; i++)
        {
            if (x >= a[i])
            {
                x -= a[i];
                a[i] = 0;
            }
            if (i == a.Length - 1) a[i] -= x;
        }
        Console.WriteLine(a.Count(_ => _ == 0));
    }
}

Measured memory_bytes: 13396