akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

// 深さ優先探索

void dfs(vector<bool> &seen, graph2 &G, vector<int> &d, int a) {
    seen[a]= true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for(auto next_v: G[a]){
        if(seen[next_v.first]==true)continue;
        d[next_v.first]=(d[a]+next_v.second)%2;
        dfs(seen, G, d, next_v.first);
    }
}

int main() {
    int N;
    cin>>N;
    int u, v, w;
    graph2 G(N);
    rep(i, N-1){
        cin>>u>>v>>w;
        G[u-1].push_back(make_pair(v-1, w%2));
        G[v-1].push_back(make_pair(u-1, w%2));
    }
    vector<bool> seen(N);
    rep(i, N){
        seen[i]=false;
    }
    vector<int> d(N);
    d[0]=0;
    dfs(seen, G, d, 0);
    rep(i, N){
        cout<<d[i]<<endl;
    }
}

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

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

#define K 2
#define LIMIT 200010

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

int cnt[LIMIT] = {0};
int main() {
  int N;
  cin >> N;

  vector<int> v(N, 0);
  int maxV = 0;
  for(int i = 0; i < N; i++) {
    cin >> v.at(i);
    maxV = max(maxV, v.at(i));
    cnt[v.at(i)]++;
  }

  ll sum = 0;
  for(int i = 0; i <= maxV; ++i) {
    sum += max(cnt[i]*(cnt[i]-1LL)/K, 0LL);
  }

  for(auto i = v.begin(); i != v.end(); ++i) {
    cout << sum - ( max(cnt[*i]*(cnt[*i]-1LL)/K, 0LL) - max((cnt[*i]-1LL)*(cnt[*i]-2LL)/K, 0LL)) << endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll n;
    cin >> n;
    ll sum[n+1];
    sum[0] = 0;
    rep(i, 0, n) {
        ll a;
        cin >> a;
        sum[i+1] = sum[i] + a;
    }

    ll ans = INF;
    rep(i, 0, n-1) {
        chmin(ans, abs(sum[i+1] - sum[n] + sum[i+1]));
    }
    cout << ans << endl;
}

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

#pragma warning(disable:4996)
using namespace std;
using ld =long double;

string st;
int a=0;
struct game {
	shared_ptr<game>l;
	shared_ptr<game>r;

	char name;

	game(char a) :name(a){

	}
	game():name('A') {

	}
};

game get_game() {
	game now_game;
	if (st[a] == '[') {
		a++;
		auto l_game=make_shared<game>(get_game());
		assert(st[a]=='-');
		a++;
		auto r_game=make_shared<game>(get_game());
		assert(st[a]==']');
		a++;
		now_game.l=l_game;
		now_game.r=r_game;
		return now_game;
	}
	else {
		now_game.name=st[a];
		a++;
		return now_game;
	}
}

int dfs(game g,const map<char,int>&mp) {
	if (g.name == 'A') {
		auto l=dfs(*g.l,mp);
		auto r=dfs(*g.r,mp);

		if (l == 0 && r) {
			return r-1;
		}
		else if (r == 0 && l) {
			return l-1;
		}
		else {
			return 100;
		}
	}
	else {
		if ((mp.find(g.name))->second==0) {
			return 0;
		}
		else {
			auto x=mp.find(g.name);
			
			return mp.find(g.name)->second;
		}
	}
}

vector<int>get_prime() {
	vector<int>is_primes(1e5,true);
	is_primes[0]=false;
	is_primes[1]=false;
	for (int x = 2; x < 1e5; ++x) {
		if (is_primes[x]) {
			for (int j = x*2; j < 1e5; j += x) {
				is_primes[j] = false;
			}
		}
	}
	vector<int>primes;
	for (int i = 0; i < 1e5; ++i) {
		if(is_primes[i])primes.push_back(i);
	}
	return primes;

}
int main() {
	long long int l,r;cin>>l>>r;r++;
	vector<int>primes;
	primes=get_prime();

	vector<int>nums(r-l+1);
	iota(nums.begin(),nums.end(),l);
	vector<int>anss(r-l+1);
	for (auto prime : primes) {
		for (long long int c = prime; c <= 1e9; c *= prime) {
			for (long long int x = l%c==0 ? l/c*c : l/c*c+c; x < r; x += c) {
				long long int place=x-l;
				nums[place]/=prime;
				anss[place]++;
			}
		}
	}
	for (int i = 0; i < r - l + 1; ++i) {
		if (nums[i] != 1) {
			anss[i]++;
		}
	}
	int sum=0;
	for (int i = 0; i < r - l + 1; ++i) {
		if (binary_search(primes.begin(), primes.end(), anss[i])) {
			sum++;
		}
	}
	cout<<sum<<endl;
 	return 0;
}


Measured memory_bytes: 10776
D, N =  map(int, input().split())

def cal(x: int):
    count  = 0
    while True:
        q, r = divmod(x, pow(100, count+1))
        if q == 0:
            return count
        else:
            count += 1

for i in [1, 100, 10000]:
    if cal(i) == D:
        if N == 100:
            N += 1
        print(i*N)
        break

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	public static void main(String[] args){

		solve_abc161_c();
	}
  	public static void solve_abc161_c(){

		FastScanner sc = new FastScanner(System.in);

		long n = sc.nextLong();
		long k = sc.nextLong();
		
		long n2 = n % k;
		
		long ans = Math.abs(n2 - k);
		
		System.out.println(Math.min(ans, n2));
		
		

	}
}

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

struct Node {
  int ParIdx, ParDepth, Deep; // Deep: HeavyEdge?????§?????±???
  int Size;
};
typedef vector< vector< int > > Graph;

int N, Q;
Graph graph;
int treesz[100000], sz;
Node nodes[100000];
vector< int > Nodes[100000];
int nowtreeIdx[100000], nowtreeDepth[100000]; 

int sizeDFS(int idx, int prev) {
  treesz[idx] = 1;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) treesz[idx] += sizeDFS(graph[idx][i], idx);
  }
  return(treesz[idx]);
}
void makeDFS(int idx, int prev, int treeIdx, int treeDepth, int ParDepth) {
  nodes[treeIdx].Size++;
  Nodes[treeIdx].push_back(idx);
  nowtreeIdx[idx] = treeIdx;
  nowtreeDepth[idx] = treeDepth;
  int ret = 0;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) ret = max(ret, treesz[graph[idx][i]]);
  }
  bool done = false;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) {
      if(!done && treesz[graph[idx][i]] == ret && !done++) {
        makeDFS(graph[idx][i], idx, treeIdx, treeDepth + 1, ParDepth);
      } else {
        nodes[sz++] = (Node){ treeIdx, treeDepth, ParDepth + 1, 0};
        makeDFS(graph[idx][i], idx, sz - 1, 0, ParDepth + 1);
      }
    }
  }
}
void HL() { // ??????????§£
  sizeDFS(0, -1);
  sz = 0;
  nodes[sz++] = (Node){ -1, -1, 0, 0};
  makeDFS(0, -1, 0, 0, 0);
}
int main() {
  int N, Q;
  scanf("%d", &N);
  graph.resize(N);
  for(int i = 0; i < N; i++) {
    int k;
    scanf("%d", &k);
    for(int j = 0; j < k; j++) {
      int c;
      scanf("%d", &c);
      graph[i].push_back(c);
    }
  }
  HL();
  scanf("%d", &Q);
  for(int i = 0; i < Q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);

    int TreeIdxA = nowtreeIdx[u], TreeDepthA = nowtreeDepth[u];
    int TreeIdxB = nowtreeIdx[v], TreeDepthB = nowtreeDepth[v];
    while(TreeIdxA != TreeIdxB) {
      if(nodes[TreeIdxA].Deep > nodes[TreeIdxB].Deep) {
        TreeDepthA = nodes[TreeIdxA].ParDepth;
        TreeIdxA   = nodes[TreeIdxA].ParIdx;
      } else {
        TreeDepthB = nodes[TreeIdxB].ParDepth;
        TreeIdxB   = nodes[TreeIdxB].ParIdx;
      }
    }
    if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
    cout << Nodes[TreeIdxA][TreeDepthA] << endl;
  }
}

Measured memory_bytes: 19316
#include<iostream>

using namespace std;
int H, W, ans;
char map[100][100];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int y, int x, char item){
        if(map[y][x] != item) return;
        map[y][x] = '.';
        int xx, yy;
        for(int i = 0; i < 4; i++){
                xx = x + dx[i];
                yy = y + dy[i];
                if(xx >= 0 && xx < W && yy >= 0 && yy < H){
                        dfs(yy, xx, item);
                }
        }
}

void solve(){
        ans = 0;
        for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                        cin >> map[i][j];
                }
        }

        for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                        if(map[i][j] != '.'){
                                dfs(i, j, map[i][j]);
                                ans++;
                        }
                }
        }

}
int main(){
        ios_base::sync_with_stdio(false);
        while(cin >> H >> W && H > 0 && W > 0){
                solve();
                cout << ans << endl;
        }
        return 0;
}


Measured memory_bytes: 3592
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let (n, k) = {
        let mut ws = s.split_whitespace();
        let n: i64 = ws.next().unwrap().parse().unwrap();
        let k: i64 = ws.next().unwrap().parse().unwrap();
        (n, k)
    };

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let h: Vec<i64> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    // println!("{:?}", h)

    let count = h.into_iter().filter(|&a| a >= k).count();
    println!("{}", count)
}


Measured memory_bytes: 6396
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

ll mini(ll a, ll b) {
	if (a < b) return a;
	return b;
}
void testcase() {
    ll n, x , y;

    cin >> n >> x >> y;

    if (x > y) swap(x, y);


    vector<int> res(n+1, 0);
    res[1] = n-1;

    rep (i, 1, n) {
    	rep (j, i+2, n) {
    		
    		int val = j - i;
    		val = mini (val, abs(i-x) + 1 + (abs(y-j)));
    		val = mini (val, abs(i-y) + 1 + (abs(x-j))); 

    		// db2(i, j);
    		// db1(mat[i][j]);
    		res[val]++;
    	} 
    }

    rep (k, 1, n-1) cout << res[k] << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

using namespace std;
int bingo[13];
int main()
{
    int arr[4][4];
    int b[112];
    memset(b,-1,sizeof(int)*112);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> arr[i][j];
            b[arr[i][j]] = i*3+j;
        }
    }
    int n;
    cin >> n;
    int t=0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(b[a]>-1){
            bingo[b[a]]=1;
            t++;
        }
    }
   
    if(t>=3){
       for(int i=0;i<9;i+=3){
           if(bingo[i] == bingo[i+1] && bingo[i+1]==bingo[i+2] && bingo[i]){
               cout << "Yes" << endl;
                return 0;
           }
       }
       for(int i =0;i<3;i+=1){
           if (bingo[i] == bingo[i + 3] && bingo[i + 3] == bingo[i + 6] && bingo[i])
           {
               cout << "Yes" << endl;
               return 0;
           }
       }
       if(((bingo[0] == bingo[4] && bingo[4] == bingo[8] && bingo[0]) || (bingo[2] == bingo[4] && bingo[4] == bingo[6] && bingo[2]))){
           cout << "Yes" << endl;
           return 0;
       }
       cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#define N 100

#include <stdio.h>

int main() {

  int i,j,a=0;
  int  A[N],flag;
  int p,n,minj;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<=n-1;i++){
    minj=i;
    flag=0;
    for(j=i; j<=n-1; j++){
      if(A[j]<A[minj]){
	minj=j;
	flag=1;
      }
    }
    if(flag==1){
      p=A[i];
      A[i]=A[minj];
      A[minj]=p;
      a++;
    }
  }
  for(i = 0; i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)  printf(" ");
  }
  printf("\n%d\n",a);
  return 0;
}



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

using namespace std;

const int MAXN = 3007;

int a[MAXN];

signed main() {
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

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

	int ans = 0;
	for (int i = 0; i < n; ++i) ans += a[i] - 1;

	cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a,b = map(int,input().split())
  print(int((b-a) * (b-a+1)/2 - b))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b;
    else if(a>=6&&a<=12)
        cout<<b/2;
    else
        cout<<'0';
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, m; cin >> n >> m;
	vector<bool>v(n + 1, false);
	vector<int>ans, given;
	rep(i, 0, m) {
		int a; cin >> a; given.push_back(a);
	}
	rrep(i, 0, m) {
		if (v[given[i]] == false) {
			ans.push_back(given[i]);
			v[given[i]] = true;
		}
	}
	rep(i, 1, n + 1) {
		if (v[i] == false) {
			ans.push_back(i);
			v[i] = true;
		}
	}

	rep(i, 0, n)cout << ans[i] << endl;
	return 0;
}

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

int main(){
  string S;
  int N;
  cin >> N >> S;
  string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  for(int i=0; i<S.size(); i++){
    for(int j=0; j<26; j++){
      if (S.at(i) == a.at(j)){
        cout << a.at((j+N)%26);
        if (i == S.size()){
          cout << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
def load_input_int():
    return map(int, input().split())
    
N, X = load_input_int()
Ls = load_input_int()

cur_position = 0
ret = None
for idx, l in enumerate(Ls):
    cur_position += l
    if cur_position > X:
        ret = idx + 1
        break
print(ret if ret is not None else N+1)

Measured memory_bytes: 3060
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if ccc==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Measured memory_bytes: 10948
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)

int main() {
	int n;
	cin >> n;
	vint a(n), b(n), c(n);
	int sum = 0;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n - 1)cin >> c[i];
	rep(i, n) {
		sum += b[i];
		if (i != (n-1)) {
			if (a[i]+1==a[i+1]) {
				sum += c[a[i]-1];
			}
		}
	}
	cout << sum << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, substring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
#include <stdio.h>

/*

i-1番目まで調べて、物質aがAグラム、bがBグラムのときの最低価格をp[i][A][B]と置く。
A,Bは0から400まで、iは0から41まで

p[i][A][B] = 5000と置いておけば十分。

漸化式は、
p[i][A][B] = min(p[i-1][A-a[i-1]][B-b[i-1]] + c[i-1] , p[i-1][A][B])

p[0][0][0] = 0, 残りはp[0][A][B] = 5000。

*/
int a[40], b[40], c[40];

int p[41][401][401];
int memo[41][401][401];

int min(int i, int j){
	if(i<j){return i;}else{return j;}
}

int dp(int i,int A,int B){
	int PP;
	
	if(A<0){return 5000;}
	if(B<0){return 5000;}
	if(memo[i][A][B] == 1){
		return p[i][A][B];
	}
	PP = min(dp(i-1,A-a[i-1],B-b[i-1]) + c[i-1] , dp(i-1,A,B));
	memo[i][A][B] = 1;
	p[i][A][B] = PP;
	return PP;
}


int main() {
	int N,Ma,Mb,i,j,k,ans;
	scanf("%d %d %d",&N,&Ma,&Mb);
	for(i=0;i<N;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}

	for(i=0;i<41;i++){
		for(j=0;j<401;j++){
			for(k=0;k<401;k++){
				memo[i][j][k] = 0;
				p[i][j][k] = 5000;
			}
		}
	}
	for(j=0;j<401;j++){
		for(k=0;k<401;k++){
			memo[0][j][k] = 1;
		}
	}
	p[0][0][0] = 0;

	ans = 5000;
	for(i=1;(i*Ma<=400) && (i*Mb<=400); i++){
		ans = min(ans, dp(N,Ma*i,Mb*i));
	}

	if(ans==5000){
		printf("-1\n");
	}else{
		printf("%d\n",ans);
	}
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(x<k-x) ans += 2*x;
        else ans += 2*(k-x);
    }
    cout << ans << endl;
}

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

using namespace std;

int cards[100001];
int dp[1000001];

int main(){
	while(true){
		int n, k;
		cin >> n >> k;
		if(n == 0 && k == 0){ break; }
		int hasWhite = 0;
		for(int i = 0; i < k; i++){
			int tmp;
			cin >> tmp;
			if(tmp == 0){
				hasWhite = 1;
			}else{
				cards[i - hasWhite] = tmp;
			}
		}
		if(hasWhite){ k--; }
		sort(cards, cards + k, less<int>());
		cards[k] = -1;
		int answer = 0, front = 0;
		dp[0] = 1;
		for(int i = 1; i <= k; i++){
			if(cards[i] == cards[i - 1] + 1){
				dp[i] = dp[i - 1] + 1;
			}else{
				if(hasWhite == 0 || front <= 0 || (cards[front - 1] + 2 != cards[front])){
					answer = max(answer, dp[i - 1]);
				}else{
					answer = max(answer, dp[i - 1] + dp[front - 1] + 1);
				}
				front = i;
				dp[i] = 1;
			}
		}
		printf("%d\n", answer);
	}
}

Measured memory_bytes: 1192
from collections import deque
from enum import Enum

class Bfs(object):
    """ Breadth First Search """
    class Status(Enum):
        """ ?????????????¨??????¶??? """
        white = 1  # ????¨????
        gray = 2  # ?¨???????
        black = 3  #?¨???????

    def __init__(self, data):
        num_of_nodes = len(data)+1
        self.color = [Bfs.Status.white] * (num_of_nodes + 1)  # ????????????????¨??????¶???
        self.Q = deque()  # ?¨???????????????????????????¨????????\???
        self.M = self._make_matrix(data)  # data????????????????????£??\??????
        self.D = [-1] * (len(data) + 1)  # ????????????????????¢ (-1????????????????????°????????????)

    def _make_matrix(self, data):
        """ data(??£??\?????????)???????????£??\??????????????? (M[i][j]?????¢??§??????????????????+1??????????????????????????????) """
        num = len(data)
        graph_table = [[0] * (num+1) for _ in range(num+1)]
        for d in data:
            node_id = d[0]
            num_of_e = d[1]
            for e in d[2:]:
                graph_table[node_id][e] = 1
        return graph_table

    def search(self, start):
        """ start????????????????????????????????°??????????????? """
        self.Q.append(start)
        self.color[start] = Bfs.Status.gray
        self.D[start] = 0  # ???????????§????????¢???0

        while self.Q:
            u = self.Q.popleft()  # ?????¨?¨????????????????????????°??????
            edges = self.M[u]
            for i in range(1, len(edges)):
                if edges[i] == 1 and self.color[i] == Bfs.Status.white:
                    self.color[i] = Bfs.Status.gray
                    if self.D[i] == -1:
                        self.D[i] = self.D[u] + 1
                        self.Q.append(i)  # ?¨??????????????????????????¬??????????????????? ???????????????????????????self.S[-1]?????????????????????


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????????
    # data[]????????????????????????1?????????????????£??\?????????????????????????´?????????????????????¨????????????????????????(??´???????????£??????????????????????????????)
    d = Bfs(data)
    d.search(1)

    # ???????????????
    for i in range(1, num+1):
        print('{0} {1}'.format(i, d.D[i]))

Measured memory_bytes: 8160
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tem = 0;
        for (int j = 0; j < n; j++) {
            if (j < i) {
                tem += a[0][j];
            } else if (j == i) {
                tem += a[0][j] + a[1][j];
            } else {
                tem += a[1][j];
            }
        }

        ans = max(ans, tem);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

cnt = 0
for i in range(N-1, -1, -1):
    diff = (B[i] - ((A[i] + cnt) % B[i])) % B[i]
    cnt += diff

print(cnt)

Measured memory_bytes: 10868
import java.util.Scanner;

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

        long a = sc.nextLong();
        // 1 double b = sc.nextDouble();
        String b = sc.next();

        // 1 long ans = (long)(a*b);

        // 2 long b0 = b.charAt(0) - '0';
        // 2 long b1 = b.charAt(2) - '0';
        // 2 long b2 = b.charAt(3) - '0';

        // 2 long ans = a * b0 + a * b1 / 10 + a * b2 / 100;

        long b0 = (b.charAt(0) - '0') * 100;
        long b1 = (b.charAt(2) - '0') * 10;
        long b2 = b.charAt(3) - '0';

        long ans = (a * b0 + a * b1 + a * b2) / 100;

        System.out.println(ans);
    }
}

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

int main() {
    int n, k; 
    scanf("%d%d", &n, &k);

    constexpr int kMod = 1'000'000'000 + 7;
    vector<int> dp(n * n + 1);
    dp[0] = 1;
    for (int i = n; i > 0; --i) {
        vector<int> nxt(n * n + 1);
        for (int j = 0; j <= n * n; ++j) {
            if (dp[j] == 0) continue;
            for (int g = 0; g <= k; ++g) {
                if (g > i || i - g > j) {
                    nxt[j] += dp[j];
                    if (nxt[j] >= kMod) nxt[j] -= kMod;
                    continue;
                }
                int nd = (j - (i - g)) / i + 1;
                nxt[j + nd] += dp[j];
                if (nxt[j + nd] >= kMod) nxt[j + nd] -= kMod;
            }
        }
        dp = nxt;
    }
    int sum = 0;
    for (int i = 0; i <= n * n; ++i) {
        sum += 1LL * i * dp[i] % kMod;
        if (sum >= kMod) sum -= kMod;
    }
    int res = kMod - sum;
    vector<int> pw(n + 1, 1);
    for (int i = 1; i <= n; ++i) pw[i] = 1LL * pw[i - 1] * (k + 1) % kMod;
    for (int i = 0; i <= k; ++i) {
        res += 1LL * i * n * pw[n - 1] % kMod;
        if (res >= kMod) res -= kMod;
    }
    printf("%d\n", res);
}


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

int main(){
  string S;
  cin >> S;
  
  int count=0;
  
  if ( S == "RRR" )
    cout << "3" << endl;
  else if ( S == "RRS" || S == "SRR" )
    cout << "2" << endl;
  else if ( S == "SSS")
    cout << "0" << endl;
  else
    cout << "1" << endl;
}

Measured memory_bytes: 3620
// AOJ 0372: Three Meals
// 2017.11.14 bal4u@uu
// 2017.11.16

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

typedef struct { long long b; int n, t; } T;
T tbl[3][1440]; int sz[3];
long long a[3][1440];

int bitcount64(long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAALL) >>  1) + (x & 0x55555555555555LL);
	x = ((x & 0xCCCCCCCCCCCCCCLL) >>  2) + (x & 0x33333333333333LL);
	x = ((x & 0xF0F0F0F0F0F0F0LL) >>  4) + (x & 0x0F0F0F0F0F0F0FLL);
	x = ((x & 0x00FF00FF00FF00LL) >>  8) + (x & 0xFF00FF00FF00FFLL);
	x = ((x & 0xFF0000FFFF0000LL) >> 16) + (x & 0x00FFFF0000FFFFLL);
	x = ((x & 0xFFFFFF00000000LL) >> 32) + (x & 0x000000FFFFFFFFLL);
	return (int)x;
}

int cmp(T *a, T *b) { if (b->n - a->n) return b->n - a->n; return b->t - a->t; }

int main()
{
	int n, i, j, f, ans;
	long long b, bb;
	T *ap, *hp, *bp;
	
	scanf("%d", &n);
	for (b = 1, i = 0; i < n; i++, b <<= 1) for (j = 0; j < 3; j++) {
		int sh, sm, eh, em, t;
		scanf("%d%d%d%d", &sh, &sm, &eh, &em);
		sh = sh*60+sm, eh = eh*60+em;
		for (t = sh; t <= eh; t++) a[j][t] |= b;
	}
	for (j = 0; j < 3; j++) {
		T *tp;
		for (tp = tbl[j], i = 0; i < 1440; i++) if ((b = a[j][i]) > 0) {
			tp->b = b, tp->n = bitcount64(b), tp->t = i, tp++;
		}
		sz[j] = tp - tbl[j];
		qsort(tbl[j], sz[j], sizeof(T), cmp);
	}
//	tbl[1][sz[1]].n = tbl[2][sz[2]].n = 0; 

	ans = 0;
	b  = tbl[0][0].b, n = tbl[0][0].n;
	b &= tbl[1][0].b; if (tbl[1][0].n < n) n = tbl[1][0].n;
	b &= tbl[2][0].b; if (tbl[2][0].n < n) n = tbl[2][0].n;
	if (bitcount64(b) == n &&
		tbl[0][0].t < tbl[1][0].t && tbl[1][0].t < tbl[2][0].t) {
		ans = n; goto done;
	}

	for (ap = tbl[0]; ap->n > ans; ap++) for (hp = tbl[1]; hp->n > ans; hp++) {
		if (hp->t <= ap->t) continue;
		bb = ap->b & hp->b;
		if (bitcount64(bb) <= ans) continue;
		for (bp = tbl[2]; bp->n > ans; bp++) {
			if (bp->t <= hp->t) continue;
			if ((f = bitcount64(bb & bp->b)) > ans) {
				ans = f; if (ans == ap->n) goto done;
			}
		}
	}
done:
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1892
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    bool f[1000001];fill(f,f+1000001,true);
    f[0]=f[1]=false;
    for(int i=0;i<1000001;i++){
        if(!f[i])continue;
        for(int j=i+i;j<1000001;j+=i){
            f[j]=false;
        }
    }
    int a,d,n;
    while(scanf("%d%d%d",&a,&d,&n),a||d||n){
        int cnt=0;
        for(int i=a;i<=1000000;i+=d){
            if(f[i]){
                cnt++;
                if(cnt==n){
                    printf("%d\n",i);
                    break;
                }
            }
        }

    }
    return 0;
}

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

s = int(input())


def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return int(3 * n + 1)


a = [s]
while True:
    a.append(f(a[-1]))
    if a[-1] in a[:-1]:
        print(len(a))
        exit()


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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<int>> map(h+2,vector<int>(w+2));

  for(int i=0;i<h;i++){
    string line;
    cin>>line;
    for(int j=0;j<w;j++){
      if(line.at(j)=='#'){
        map.at(i+1).at(j+1)=-10;
        for(int x=0;x<3;x++){
          for(int y=0;y<3;y++){
            map.at(i+x).at(j+y)+=1;
          }
        }
      }
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(map.at(i).at(j)<0){
        cout<<'#';
      }else{
        cout<<map.at(i).at(j);
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  var n = 0
  val b = new ArrayBuffer[Int]
  while({n=readInt;n} != 0){
    val s = readLine.split(" ").map(_.toInt).sum
    b += s/(n-1)
  }
  println(b.mkString("\n"))
}

Measured memory_bytes: 55320
# ボールAとボールBをN個の箱に入れる
# A,Bを1つずつ同じ箱に入れることがあってもよい。
# まずAをN個の箱に1つずつ入れる
# その上で、BをN個の箱に1つずつ入れる（すでにAが入っているかどうか、区別する必要がない）
# AとBの個数の組み合わせを列挙し、そのすべてについて(N C (Aの個数)) * (N C (Bの個数))を計算した和が答え

import sys
readline = sys.stdin.readline

N,A,B,K = map(int,readline().split())

DIV = 998244353
n = (10 ** 6) * 2 # PyPyじゃないと通らない。 * 5が限界くらい
g1 = [1] * 2 + [0] * (n - 2) # 元テーブル
g2 = [1] * 2 + [0] * (n - 2) #逆元テーブル
inverse = [0, 1] + [0] * (n - 2) #逆元テーブル計算用テーブル

for i in range(2, n):
  g1[i] = (g1[i - 1] * i) % DIV
  inverse[i] = (-inverse[DIV % i] * (DIV // i)) % DIV
  g2[i] = (g2[i - 1] * inverse[i]) % DIV

def nCr(n, r, DIV):
  if (r < 0 or r > n):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % DIV

# AとBを足してKになる組み合わせを探索する
ans = 0
for a in range(N + 1):
  b = K - a * A
  if b < 0:
    break # a * Aの時点で負の数。これ以上の探索も不要。
  if b % B != 0:
    continue # 組み合わせを作れない
  if (b // B) > N:
    continue # 箱に入れられない
  # この時点で、Aがa個とBがb個で作れることが確定する
  # (N C (Aの個数)) * (N C (Bの個数))
  ans += (nCr(N, a, DIV) * nCr(N, b // B, DIV)) % DIV
  ans %= DIV
  
print(ans)

Measured memory_bytes: 171768
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
mind = float('inf')
i = 1
while i*i <= n:
    if n%i == 0:
        if i == n//i:
            mind = min(mind, len(str(i)))
        else:
            maxd = max(len(str(i)), len(str(n//i)))
            mind = min(mind, maxd)
    i += 1
print(mind)


Measured memory_bytes: 10484
#include<iostream>

using namespace std;
int main(){
  int a,b,c,k;
  cin >>a>>b>>c>>k;
  int ans = 0;
  if(a >= k){
    ans = 1*k;
  }
  else if(a + b >= k){
    ans = 1*a;
  }
  else {
    ans = 1 * a - 1 * (k - a - b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

h = 'A'
k = A[0] #最初の１枚を抜く
xa += 1

while True:

    if k == 'a':
        h = 'A'
        if xa < len(A):
            k = A[xa]
            xa += 1
        else:
            break
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = B[xb]
            xb += 1
        else:
            break
    elif k == 'c':
        h = 'C'
        xc += 1
        if xc < len(C):
            k = C[xc]
            xc += 1
        else:
            break

print(h)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Grid BFS
//-------------------------------------------------

template<typename T>
::std::vector<::std::vector<int> > gBFS(int si, int sj, ::std::vector<::std::vector<T> > &field)
{
    int dx[]={0,1,0,-1};
    int dy[]={1,0,-1,0};
    int h = field.size();
    int w = field[0].size();
    using P = ::std::pair<int,int>;
    ::std::queue<P> que;
    que.emplace(si,sj);
    ::std::vector<::std::vector<int> > dist(h,::std::vector<int>(w,-1));
    dist[si][sj] = 0;
    while(que.size()){
        int x,y;
        tie(y,x) = que.front(); que.pop();
        for(int i=0; i<4; i++){
            int tx = x+dx[i];
            int ty = y+dy[i];
            if (!(0<=tx&&tx<w&&0<=ty&&ty<h)) continue;
            if (dist[ty][tx]!=-1) continue;
            // 壁の条件(任意に書き換える)
            if (field[ty][tx]=='#') continue;
            dist[ty][tx] = dist[y][x]+1;
            que.emplace(ty,tx);
        }
    }
    return dist;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<vector<char> > t(h, vector<char>(w));
    int cnt=0;
    rep(i,h)rep(j,w){
        cin>>t[i][j];
        if (t[i][j]=='#') cnt++;
    }
    auto dist = gBFS<char>(0,0,t);
    if (dist[h-1][w-1]==-1){
        cout<<"-1\n";
    }else{
        cout<<h*w-(dist[h-1][w-1]+1)-cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



signed main(){
  string s;
  cin>>s;
  for(int i=s.size()-1;i>=0;i--){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3172
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 1e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;
//int s, t;
//
//struct edge {
//	int from, to, flow, cap;
//};
//
//vector<edge> e;
//
//void add_edge(int u, int v, int w)
//{
//	edge e1 = { u, v, 0, w };
//	edge e2 = { v, u, 0, 0 };
//
//	vertices[u].pb(e.size());
//	e.pb(e1);
//	vertices[v].pb(e.size());
//	e.pb(e2);
//}
//
//int d[sze], ptr[sze];
//
//bool bfs()
//{
//	queue<int> q;
//	q.push(s);
//
//	fill(d, d + n + 10, -1);
//	d[s] = 0;
//
//	while (!q.empty() && d[t] == -1)
//	{
//		int v = q.front();
//		q.pop();
//
//		for (auto id : vertices[v])
//		{
//			int to = e[id].to;
//
//			if (d[to] == -1 && e[id].cap > e[id].flow)
//			{
//				q.push(to);
//				d[to] = d[v] + 1;
//			}
//		}
//	}
//
//	return d[t] != -1;
//}
//
//int dfs(int v, int flow)
//{
//	if (!flow)
//		return 0;
//
//	if (v == t && flow != oo)
//		return flow;
//
//	for (; ptr[v] < vertices[v].size(); ptr[v] ++)
//	{
//		int id = vertices[v][ptr[v]];
//		int to = e[id].to;
//
//		if (d[to] != d[v] + 1) continue;
//
//		int pushed = dfs(to, min(flow, e[id].cap - e[id].flow));
//
//		if (pushed)
//		{
//			e[id].flow += pushed;
//			e[id ^ 1].flow -= pushed;
//			return pushed;
//		}
//	}
//
//	return 0;
//}
//
//
//int dinic()
//{
//	int flow = 0;
//
//	while (bfs())
//	{
//		fill(ptr, ptr + n + 10, 0);
//		while (int pushed = dfs(s, oo))
//		{
//			flow += pushed;
//		}
//	}
//
//	return flow;
//}
//
//bool from[sze], to[sze];


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

	cin >> n >> k;

	cnt = (n + 1) / 2;

	if (cnt >= k)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	
	return 0;
}



Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int count = 0;
        count = B/A;
        if (count > C) {
            count = C;
        }

        System.out.println(count);

    }

}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

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

    vi num(N, 1);
    vector<bool> red(N, false);
    red[0] = true;

    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        x--;
        y--;
        num[x]--;
        num[y]++;
        if (red[x]) red[y] = true;
        if (num[x] == 0) red[x] = false;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (red[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

H, W = list(map(int, sys.stdin.buffer.readline().split()))
S = [list(sys.stdin.buffer.readline().decode().rstrip()) for _ in range(H)]

S = np.array(S, dtype='U1')
ans = []
for s in S:
    if '#' in s:
        ans.append(s)
S = np.array(ans, dtype='U1')
ans = []
for s in S.T:
    if '#' in s:
        ans.append(s)
ans = np.array(ans, dtype='U1').T
for r in ans:
    print(''.join(r))


Measured memory_bytes: 13768
#include <iostream>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e15)

using namespace std;

int N;
int A[200005];
int sum[200005];

signed main()
{
    cin >> N;
    REPS(i, N) cin >> A[i];
    REPS(i, N) sum[i] = A[i] + sum[i-1];

    int ans = INF;
    REPS(i, N-1)
    {
        ans = min(ans, abs(sum[i] - (sum[N] - sum[i])));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

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

	int cnt;
	if(n==1) {
		cout << m/2 << endl;
		return 0;
	}
	for(int i=0; i<=n/2; i++) {
		cout << 0 << ' ';
		cnt++;
	}
	for(int i=cnt; i<n-1; i++)
		cout << m << ' ';
	if(cnt < n) cout << m;
	cout << endl;

	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in).useDelimiter("(,|\r\n|\r|\n)");
		int[] c = new int[14];
		int[] n = new int[5];
		while (sc.hasNextInt()) {
			for (int i = 0; i < 14; i++)
				c[i] = 0;
			for (int i = 0; i < 5; i++)
				n[i] = 0;
			for (int i = 0; i < 5; i++) {
				int a = sc.nextInt();
				c[a - 1]++;
			}
			for (int i = 0; i < 13; i++)
				n[c[i]]++;
			c[13] = c[0];
			int j = 0;

			while (j < 10) {
				if (c[j] > 0 && c[j + 1] > 0 && c[j + 2] > 0 && c[j + 3] > 0 && c[j + 4] > 0) {
					break;
				}
				j++;
			}
			if (n[4] > 0) {
				System.out.println("four card");
			} else if (n[3] > 0 && n[2] > 0) {
				System.out.println("full house");
			} else if (j < 10) {
				System.out.println("straight");
			} else if (n[3] > 0) {
				System.out.println("three card");
			} else if (n[2] > 1) {
				System.out.println("two pair");
			} else if (n[2] > 0) {
				System.out.println("one pair");
			} else {
				System.out.println("null");
			}
		}
	}
}

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

int main()
{
  double n,m,s[1000],bun;

  while(cin>>n && n){
    m=0;bun=0;
    for(int i=0;i<n;i++){
      cin>>s[i];
      m+=s[i];
    }
    m/=n;
    for(int i=0;i<n;i++){
      bun+=(s[i]-m)*(s[i]-m);
    }
    bun/=n;
    printf("%.8f\n",sqrt(bun));
  }
  return 0;
}
      

Measured memory_bytes: 1244
#!/usr/bin/env python3
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
ans = [[0] * w for _ in range(h)]
now = 1
for i in range(h):
    if '#' not in s[i]:
        continue
    cnt = 0
    for j in range(w):
        cnt += (s[i][j] == '#')
        ans[i][j] = now + max(0, cnt - 1)
    now += max(0, cnt - 1) + 1

for j in range(w):
    for i in range(h - 1):
        if ans[i + 1][j] == 0:
            ans[i + 1][j] = ans[i][j]
    for i in range(h - 1)[::-1]:
        if ans[i][j] == 0:
            ans[i][j] = ans[i + 1][j]

for i in range(h):
    print(*ans[i], sep=' ')


Measured memory_bytes: 7588
using System;
using System.Collections.Generic;

namespace AOJ
{
    class Queue
    {
        private class ProcInfo
        {
            public string Name { get; set; }
            public int Time { get; set; }

            public ProcInfo(string n, int t)
            {
                this.Name = n;
                this.Time = t;
            }
        }

        public static void Main(string[] args)
        {
            var info = Console.ReadLine().Trim().Split(' ');
            int proc_cnt = int.Parse(info[0]);
            int quantum = int.Parse(info[1]);

            var que = new Queue<ProcInfo>();
            for (int i = 0; i < proc_cnt; i++)
            {
                info = Console.ReadLine().Trim().Split(' ');
                que.Enqueue(new ProcInfo(info[0], int.Parse(info[1])));
            }

            int summary = 0;
            while (que.Count > 0)
            {
                var proc = que.Dequeue();
                summary += Math.Min(proc.Time, quantum);
                proc.Time -= quantum;
                if (proc.Time > 0) { que.Enqueue(proc); }
                else { Console.WriteLine(string.Format("{0} {1}", proc.Name, summary)); }
            }
        }
    }
}

Measured memory_bytes: 18152