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

int main() {
	long long int N, W;
	cin >> N >> W;
	vector<vector<long long int>>dp( N + 1, vector<long long int>( W + 1 ) );
	dp[0][0] = 1;
	for( size_t i = 0; i < N; i++ ) {
		long long int v, w;
		cin >> v >> w;
		for( size_t j = 0; j <= W; j++ ) {
			dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] );
			if( j + w <= W&&dp[i][j] ) {
				dp[i + 1][j + w] = max( dp[i + 1][j + w], dp[i][j] + v );
			}
		}
	}
	for( size_t i = 0; i < W; i++ ) {
		dp[N][i + 1] = max( dp[N][i], dp[N][i + 1] );
	}
	cout << max( dp[N][W] - 1, 0LL ) << endl;
}

Measured memory_bytes: 10692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

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

ll N;

ll i = 1;
ll ans = 0;

int main()
{
	cin >> N;



	while (true)
	{
		if ((N - i) / i <= i) break;
		if ((N - i) % i == 0)
		{
			ans += (N - i) / i;
		}
		i++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
pad = '.' * (w + 2)
sl = []
sl.append(pad)
for i in range(h):
  s = '.' + str(input()) + '.'
  sl.append(s)
sl.append(pad)
for i in range(1, h + 1):
  strlist = list(sl[i])
  for j in range(1, w + 1):
    if sl[i][j] == '.':
      wc = 0
      for p in range(i - 1, i + 2):
        for q in range(j - 1, j + 2):
          if sl[p][q] == '#':
            wc += 1
      strlist[j] = str(wc)
  sl[i] = "".join(strlist)
for i in range(1, len(sl) - 1):
  print(sl[i][1:-1])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdint.h>
#include <utility>
#include <vector>
#include <assert.h>
#include <cmath>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

std::vector<std::pair<int, int> > solve(int k, int x, int y) {
	bool x_inv = x < 0;
	bool y_inv = y < 0;
	x = std::abs(x);
	y = std::abs(y);
	
	if (!(k & 1) && ((x + y) & 1)) return {};
	
	std::vector<std::pair<int, int> > res;
	int cur_x = 0, cur_y = 0;
	auto go = [&] () {
		int remain = k;
		if (cur_x < x) {
			int add = std::min(remain, x - cur_x);
			cur_x += add;
			remain -= add;
		}
		cur_y += remain;
		res.push_back({cur_x, cur_y});
	};
	
	for (int i = 0; i < (x + y) / k; i++) go();
	
	if (!res.size() && !((x + y) & 1)) {
		if (y <= x) {
			res.push_back({(x + y) / 2, (x + y) / 2 - k});
			res.push_back({cur_x = x, cur_y = y});
		} else {
			res.push_back({-(k - (x + y) / 2), (x + y) / 2});
			res.push_back({cur_x = x, cur_y = y});
		}
	}
	bool slide = !res.size();
	if (!res.size()) y += k, res = {{0, 0}, {cur_x = x, cur_y = k - x}};
	if (cur_x != x || cur_y != y) {
		int over = k - (x + y - cur_x - cur_y);
		if (over & 1) {
			if (cur_y) {
				int one = (y - cur_y) / 2;
				res.push_back({cur_x + k - one, cur_y + one});
			} else {
				over = (over + k) / 2;
				res.back() = {cur_x - over, cur_y - over};
				res.push_back({cur_x += k - over - over, cur_y});
			}
		} else {
			over /= 2;
			if (!cur_y) {
				cur_x -= over;
				cur_y -= over;
			} else {
				if (over > cur_y) {
					over -= cur_y;
					cur_x -= over;
					cur_y = -cur_y - over;
				} else {
					cur_x += over;
					cur_y -= over;
				}
			}
			res.back() = {cur_x, cur_y};
		}
		res.push_back({x, y});
	}
	if (slide) for (auto &i : res) i.second -= k;
	if (x_inv) for (auto &i : res) i.first = -i.first;
	if (y_inv) for (auto &i : res) i.second = -i.second;
	return res;
}

int main() {
	int k = ri();
	int x = ri();
	int y = ri();
	auto res = solve(k, x, y);
	if (!res.size()) puts("-1");
	else {
		printf("%d\n", (int) res.size());
		for (auto i : res) printf("%d %d\n", i.first, i.second);
	}
	return 0;
}


Measured memory_bytes: 3952
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	int k; cin >> k;
	cout << (e - a > k ? ":(" : "Yay!") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a,b,c,d,e,at,bt,ct,dt,et,as,bs,cs,ds,es;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    at=a-a/10*10;
    bt=b-b/10*10;
    ct=c-c/10*10;
    dt=d-d/10*10;
    et=e-e/10*10;
    if (at==0) as=a;
    else as=a/10*10+10;
    if (bt==0) bs=b;
    else bs=b/10*10+10;
    if (ct==0) cs=c;
    else cs=c/10*10+10;
    if (dt==0) ds=d;
    else ds=d/10*10+10;
    if (et==0) es=e;
    else es=e/10*10+10;
    int bubble=10;
    if (at<bubble && at>0)
        bubble=at;
    if (bt<bubble && bt>0)
        bubble=bt;
    if (ct<bubble && ct>0)
        bubble=ct;
    if (dt<bubble && dt>0)
        bubble=dt;
    if (et<bubble && et>0)
        bubble=et;
    printf("%d\n",as+bs+cs+ds+es-10+bubble);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int N,i;scanf("%d",&N);
  vector<int> a(N);
  for(i=0;i<N;i++) scanf("%d",&a[i]);
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  int ans = a.size();
  if(ans%2==0) ans--;
  printf("%d\n",ans);
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	int N,M,X; cin>>N>>M>>X;
	vector<int> mny(N);
	vvi power(N,vi(M));
	rep(i,0,N){
		int c;cin>>c;
		mny[i]=c;
		rep(j,0,M){
			int a; cin>>a;
			power.at(i).at(j)=a;
		}
	}
	ll ans=-1; 
	for (ll tmp=0;tmp<(1<<N);tmp++){
		bitset<12> s(tmp);
		vi v(M);
		ll cnt=0;
		rep(i,0,N){
			if(s.test(i)){
				cnt+=mny[i];
				rep(j,0,M){
					v[j]+=power.at(i).at(j);
				}
			}
		}
		sort(all(v));
		if(v[0]>=X && ans==-1){
			ans=cnt;
		}
		else if(v[0]>=X){
			ans = min(ans,cnt);
		}
	}
	cout<<ans;
	return 0;
					
		
	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string O,E,a;
  int o,e;
  cin >> O >> E;
  o=O.size();
  e=E.size();
  if(o==e){
    for(int i=0;i<e;i++){
      a+=O.at(i);
      a+=E.at(i);
    }
  }
  else{
     for(int i=0;i<e;i++){
      a+=O.at(i);
      a+=E.at(i);
    }
    a+=O.at(o-1);
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main{
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	String s = sc.next();
        	boolean flag = false;
        	for(int i=0;i<s.length();i++) {
        		if(s.charAt(i)=='7') {
        			System.out.println("Yes");
        			flag=true;
        			break;
        		}
        	}
        	if(flag==false) {
        		 System.out.println("No");
        	} 
    }
}


Measured memory_bytes: 35436
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b+c == a)
    cout << "Yes";
    else if (a+c == b)
        cout << "Yes";
    else if (a+b == c)
        cout << "Yes";
    else
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int, input().split()))
s = [1]*len(h)

A = []
B = []

for i in range(m):
    a, b = input().split()
    A.append(int(a))
    B.append(int(b))
    
    
for j in range(m):
    if h[A[j]-1] > h[B[j]-1]:
        s[B[j]-1] = 0
    elif h[A[j]-1] < h[B[j]-1]:
        s[A[j]-1] = 0
    elif h[A[j]-1] == h[B[j]-1]:
        s[A[j]-1] = 0
        s[B[j]-1] = 0
        
print(sum(s))

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(all(l), greater<int>());
    int sum = 0;
    for(int i = 0; i < k; i++) sum += l[i];
    cout << sum << endl;
}


Measured memory_bytes: 256
program hrn;
 var
  b:array[0..101,0..101]of char;
  a:array[1..100,1..100]of longint;
  i,j,m,n,x:longint;s:string;
 begin
  read(m,n);readln;
  for i:=1 to m do  begin
   for j:=1 to n do
    read(b[i,j]);
   readln;end;
  for i:=1 to m do
   for j:=1 to n do
    if b[i,j]='.' then begin
     if b[i,j-1]='#'  then x:=x+1;
     if b[i,j+1]='#'  then x:=x+1;
     if b[i+1,j]='#'  then x:=x+1;
     if b[i-1,j]='#'  then x:=x+1;
     if b[i-1,j-1]='#'then x:=x+1;
     if b[i+1,j-1]='#'then x:=x+1;
     if b[i-1,j+1]='#'then x:=x+1;
     if b[i+1,j+1]='#'then x:=x+1;
     a[i,j]:=x;x:=0;
    end;
  for i:=1 to m do  begin
   for j:=1 to n do
    if b[i,j]='#' then write('#')
                  else write(a[i,j]);
   writeln;
  end;
 end.


Measured memory_bytes: 128
s = input()
flag = True
while 1:
    if s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-5:] == "dream" or s[-5:] == "erase":
        s = s[:-5]
    else:
        flag = False
        break
    if s == "":
        break
if flag:
    print("YES")
else:
    print("NO")


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int a, b;
   cin >> a >> b;
   if (a > 8 || b > 8) {
      puts(":(");
   } else {
      puts("Yay!");
   }

   return 0;
}

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

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    ans+=a*(n/(a+b))+min(n%(a+b),a);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b=map(int,input().split())
    if a*b%2:
        print('Odd')
    else:
        print('Even')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int r = sc.nextInt();
    
    //円の面積を求める。(π除く)
    int rr = r*r;
      
    //半径1なので倍率は円の面積でよい。
    System.out.println(rr);
    
    }
      
 }

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

pll A[100005];

struct Data {
    ll x = 0;
    ll n = 0;
    vector<ll> y;
};

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

    ll N;
    cin >> N;
    vector<ll> X, Y;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
        X.push_back(A[i].first);
        Y.push_back(A[i].second);
    }

    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    sort(Y.begin(), Y.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());

    vector<vector<ll>> x(X.size());
    REP(i, N) {
        ll index = lower_bound(X.begin(), X.end(), A[i].first) - X.begin();
        x[index].push_back(A[i].second);
    }
    UnionFind uf(Y.size());
    REP(i, x.size()) {
        REP(j, x[i].size() - 1) {
            ll i0 = lower_bound(Y.begin(), Y.end(), x[i][j]) - Y.begin();
            ll i1 = lower_bound(Y.begin(), Y.end(), x[i][j + 1]) - Y.begin();
            uf.unit(i0, i1);
        }
    }

    vector<Data> y(Y.size());

    REP(i, x.size()) {
        ll p = uf.find(lower_bound(Y.begin(), Y.end(), x[i][0]) - Y.begin());
        y[p].x++;
        y[p].n += x[i].size();
        REP(j, x[i].size()) {
            y[p].y.push_back(x[i][j]);
        }
    }

    ll ans = 0;
    REP(i, y.size()) {
        sort(y[i].y.begin(), y[i].y.end());
        y[i].y.erase(unique(y[i].y.begin(), y[i].y.end()), y[i].y.end());
        ans += (y[i].x * y[i].y.size() - y[i].n);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10220
#include <bits/stdc++.h>
using namespace std;
// 4 buildings, 3 floors, 10 rooms.
int building[4][3][10];

int main() {

    // 1. input.
    int n;
    cin >> n;
    
    // 2. input check.
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        building[b - 1][f - 1][r - 1] += v;
        
    }
    
    // 3. output answer.
    for(int b = 0; b < 4; b++){
        for(int f = 0; f < 3; f++){
            for(int r = 0; r < 10; r++) cout << " " << building[b][f][r];
            cout << endl;
        }
        if(b < 3) cout << "####################" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    int ans = 0;
    char prev = S[0];
    int cnt = 1;
    rep(i, 1, N) {
        if (S[i] == prev) ++cnt;
        else {
            ans += cnt - 1;
            prev = S[i];
            cnt = 1;
        }
    }
    ans += cnt - 1;
    int red = 0;
    rep(i, 0, N - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') ++red;
    }
    if (S[0] == 'L') ++red;
    if (S[N - 1] == 'R') ++red;
    int X = red - 1, Y = 1;
    if (S[0] == 'L' && S[N - 1] == 'R') --X;
    else if (S[0] == 'L' || S[N - 1] == 'R') --Y;
    int x = min(X, K);
    ans += 2 * x;
    K -= x;
    int y = min(Y, K);
    ans += y;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a, a_max, a_min;
  a_max = 0; a_min = 1000;
  for(int i=0; i<n; i++){
    cin >> a;
    a_max = max(a_max, a);
    a_min = min(a_min, a);
  }
  cout << a_max - a_min << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int count = 0;

		for(int i = 0; i < 10000; i ++){
			H -= A;
			if(H <= 0){
				break;
			}
			count ++;
		}
		System.out.println(count + 1);
	}
}

Measured memory_bytes: 35740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(m), b(m);
	vector<pair<int, int>>s;
	repp(i, 0, m) {
		cin >> a[i] >> b[i];
		s.emplace_back(b[i], a[i]);//make_pairしなくてよい
	}
	int cnt = 0;
	sort(s.begin(), s.end());
	int t = 0;
	repp(i, 0, m) {
		if (t <= s[i].second) {
			++cnt;
			t = s[i].first;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}

signed main(){
	int n; cin>>n;
	VL t(n); rep(i,n) cin>>t[i];
	int m; cin>>m;
	VI p(m); VL x(m); rep(i,m) cin>>p[i]>>x[i];

	rep(i,m){
		ll ans = 0;
		rep(j,n){
			if(p[i]==j+1) ans+=x[i];
			else ans+=t[j];
		}
		cout << ans << endl;
	}

	return 0;
}


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

int N, M, K;
int A[111111];
int B[111111];
int C[111111];
int D[111111];
vector<int> fr[111111];
vector<int> bl[111111];
int label[111111];
map<int, int> label_cnt;

int dfs(int prev, int now, int l) {
	label[now] = l;

	int ret = 0;
	for (int child : fr[now]) {
		if (label[child] != 0) continue;
		ret += dfs(now, child, l) + 1;
	}

	return ret;
}

int main() {
	cin >> N >> M >> K;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
		fr[A[i]].push_back(B[i]);
		fr[B[i]].push_back(A[i]);
	}
	for (int i = 0; i < K; i++) {
		cin >> C[i] >> D[i];
		C[i]--, D[i]--;
		bl[C[i]].push_back(D[i]);
		bl[D[i]].push_back(C[i]);
	}

	int l = 1;
	for (int i = 0; i < N; i++) {
		if (label[i] != 0) continue;
		label_cnt[l] = dfs(-1, i, l);
		// cout << label_cnt[l] << endl;
		l++;
	}

	vector<int> ans;
	for (int i = 0; i < N; i++) {
		int num = label_cnt[label[i]] - fr[i].size();
		for (int b : bl[i]) { // ブロックした奴
			if (label[b] == label[i]) {
				num--;
			}
		}
		ans.push_back(num);
	}

	for (int i = 0; i < N - 1; i++) {
		cout << ans[i] << " ";
	}
	cout << ans.back() << endl;

	return 0;
}

Measured memory_bytes: 16120
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int member_num;
	int members[20];
	int i_max;
	int i,j;
	int a,b,now,min;
	while(1) {
		scanf("%d",&member_num);
		if(member_num==0)break;
		for(i=0;i<member_num;i++) {
			scanf("%d",&members[i]);
		}
		i_max=1<<(member_num-1);
		min=0x7fffffff;
		for(i=0;i<i_max;i++) {
			for(a=b=0,j=0;j<member_num;j++) {
				if(i & (1<<j))a+=members[j]; else b+=members[j];
			}
			now=abs(a-b);
			if(now<min)min=now;
		}
		printf("%d\n",min);
	}
	return 0;
}

Measured memory_bytes: 412
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
    ll n,k;
    cin >> n>>k;
    ll c = n % k;
    ll o = abs(c - k);
    ll p = min(c, o);
    ll u = min(n, p);
    cout << u;
}

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

#define HASHSIZE 100000

int asc(const void *a, const void *b){
  if(*(char *)a > *(char *)b){
    return 1;
  }else if(*(char *)a == *(char *)b){
    return 0;
  }else{
    return -1;
  }
}

long hash(char str[]){
  long i,h=0;

  for(i=0;i<strlen(str);i++){
    h=(h*17+str[i])%HASHSIZE;
  }

  return h;
}

long put_table(char str[],char hashtable[][11]){
  long i,h=hash(str),h_num;

  for(i=0;i<HASHSIZE;i++){
    h_num=(h+i)%HASHSIZE;
    if(hashtable[h_num][0]=='\0'){
      strcpy(hashtable[h_num],str);
      return h_num;
    }else if(strcmp(hashtable[h_num],str)==0){
      return h_num;
    }
  }

  return -1;
}

int main(void){
  long i,ans=0,h;
  char hashtable[HASHSIZE][11]={};
  long hash_num[HASHSIZE]={};

  long n;
  scanf("%ld\n",&n);

  for(i=0;i<n;i++){
    char str[11];
    scanf(" %s",str);
    qsort(str,strlen(str),sizeof(char),asc);
    h=put_table(str,hashtable);
    if(h!=-1){
      ans+=(hash_num[h]++);
    }
  }

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

  return 0;
}


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

string s[100],t[100];
int g[100];
int n,m;

int conv(string x){
    int a,b,c;
    char ig;
    stringstream ss(x);
    ss>>a>>ig>>b>>ig>>c;
    return a*10000+b*100+c;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string a;
        cin>>s[i]>>t[i]>>a;
        g[i]=conv(a);
    }

    cin>>m;
    bool la=false;
    while(m--){
        if(la)cout<<endl;
        else la=true;
        string a,b,c,d;
        cin>>a>>b>>c>>d;
        for(int i=0;i<n;i++){
            bool flag=true;
            if(a!="*")if(s[i].find(a)==string::npos)flag=false;
            if(b!="*")if(t[i].find(b)==string::npos)flag=false;
            if(c!="*")if(conv(c)>g[i])flag=false;
            if(d!="*")if(conv(d)<g[i])flag=false;
            if(flag)cout<<s[i]<<endl;
        }
    }

    return 0;
}

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

//create arrays outside of main()

int v[20];
int c[20];

int main(){

    int n;
    int finalOutput;
    cin >> n;

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

    for(int j=0; j<n; j++){
        cin >> c[j];
    }

    for(int k=0; k<n; k++){
        if(v[k]>c[k]){
            finalOutput += v[k]-c[k];
        }
    }

    cout << finalOutput;

    return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    if n == 1:
        print("Hello World")
    else:
        a = int(input().rstrip('\n'))
        b = int(input().rstrip('\n'))
        print(a + b)


if __name__ == '__main__':
    slove()


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

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

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

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cmath>
#include <set>
#include <cstring>
#include <queue>
using namespace std;

bool vis[3][3] = {};

int main(){
    int arr[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> arr[i][j];
        }
    }
    int n, a;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(arr[j][k] == a) vis[j][k] = 1;
            }
        }
    }
    for(int i = 0; i < 3; i++){
        bool f = 1;
        for(int j = 0; j < 3; j++){
            f &= vis[i][j];
        }
        if(f){
            cout << "Yes\n";
            return 0;
        }
    }
    for(int j = 0; j < 3; j++){
        bool f = 1;
        for(int i = 0; i < 3; i++){
            f &= vis[i][j];
        }
        if(f){
            cout << "Yes\n";
            return 0;
        }
    }
    if(
            (vis[0][0] && vis[1][1] && vis[2][2])
            || (vis[0][2] && vis[1][1] && vis[2][0])
      ){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}


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

struct Card{
 char x;
 int y;
};

bool compare_as_ints(Card i, Card j){
 return (i.y<j.y);
}

int partition(Card A[], int p, int r){
 Card c = A[r];
 int i = p-1;
 for(int j=p; j<=r-1; j++){
  if(A[j].y <= c.y){
   i = i+1;
   swap(A[i],A[j]);
  }
 }
 swap(A[i+1],A[r]);
 return i+1;
}

void quickSort(Card A[], int p, int r){
 if(p<r){
  int q = partition(A,p,r);
  quickSort(A,p,q-1);
  quickSort(A,q+1,r);
 }
}

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

 Card A[n],B[n]; //????????????????????????????????????2?????????
 for(int i=0; i<n; i++){
  cin >> A[i].x >> A[i].y;
  B[i] = A[i];
 }
 
 bool checkstable = true; //??????

 quickSort(A, 0, n-1);
 stable_sort(B, B+n, compare_as_ints);
 
 for(int i=0; i<n; i++){
  if(A[i].x != B[i].x){
   checkstable = false; //?????????
  }
 }
 if(checkstable == true){ //????????????
  cout << "Stable" << endl;
 }else{ //???????????????
  cout << "Not stable" << endl;
 }

 for(int i=0; i<n; i++){
  cout << A[i].x << ' ' << A[i].y << endl;
 }

 return 0;
}

Measured memory_bytes: 4736
Module Program
  Sub Main
    Dim s=Gets()(0)
    Dim t=Gets()(0)
    Dim ans=If(s(0)=t(2)And s(1)=t(1)And s(2)=t(0),"YES","NO")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <memory>
using namespace std;

bool compare( char& ch, int& l, string const& ans ) {
	string str = string( l, ch );
	if( ans == str )
		return true;
	else
		return false;
}

int search(int i, string const& s) {
	int cnt = 0;
	char ch = static_cast<char>( i + 'a' );
	int l = s.length();
	string ans = s;
	while( !compare(ch, l, ans )) {
		--l;
		ans.pop_back();
		for(int i = 0; i < l-1; ++i) {
			if( ans[i] == ch || ans[i+1] == ch){
				ans[i] = ch;
			}
		}
		++cnt;
	}
	return cnt;
}

int main()
{
	bool al[26] = {};

	string s;
	cin >> s;

	for(int i : s) {
		int ic =  i - 'a' ;
		al[ic] = true;
	}
	int min = 100;
	int cnt = 0;
	for(int i = 0; i < 26; ++i){
		if( al[i] ){
			cnt = search( i, s );
			if( min > cnt ){
				min = cnt;
			}
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

Measured memory_bytes: 256
N, C = map(int, input().split())
XV = []

for _ in range(N):
  x, v = map(int, input().split())
  XV.append((x, v))

#R:右回りでそこまで行くときの満足度
#Rr:右行って引き返す時の最大満足度
R = [0]
Rr = [0]
for x, v in XV:
  R.append(R[-1] + v)
  Rr.append(Rr[-1] + v)
for i, (x, v) in enumerate(XV):
  R[i+1] -= x
  Rr[i+1] -= 2*x
for i in range(N):
  Rr[i+1] = max(Rr[i+1], Rr[i])

#左バージョン
L = [0]
Lr = [0]
for x, v in reversed(XV):
  L.append(L[-1] + v)
  Lr.append(Lr[-1] + v)
for i, (x, v) in enumerate(reversed(XV)):
  L[i+1] -= (C-x)
  Lr[i+1] -= 2*(C-x)
for i in range(N):
  Lr[i+1] = max(Lr[i+1], Lr[i])

#print(R, Rr, L, Lr)
ans = 0

for i in range(1, N+1):
  temp = max(R[i], R[i] + Lr[N-i], L[N+1-i], L[N+1-i] + Rr[i-1])
  ans = max(ans, temp)

print(ans)

Measured memory_bytes: 41544
#include "bits/stdc++.h"
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define nl '\n'
#define precision(n) setprecision(n)
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() { _
    int q; cin >> q;
    vector<ll> v;
    forn(i, 0, q) {
        ll a, b; cin >> a >> b;
        if (a == b) {
            cout << (2*a-2) << nl;
        } else if (abs(a-b) == 1) {
            cout << (2*min(a,b)-2) << nl;
        } else {
            ll n = a * b;
            ll c = sqrt(n);
            if (c * c == n) c--;
            if (c*(c+1) >= n) {
                cout << (2*c-2) << nl;
            } else {
                cout << (2*c-1) << nl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_K = 1e5 + 10;
ll A[max_K];

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

	for (int i = 1; i <= K; ++i) {
		cin >> A[i];
	}

	ll minN = 2, maxN = 2;
	for (int i = K; i >= 1; --i) {
		ll L = (minN / A[i] + (minN % A[i] > 0)) * A[i];
		ll R = maxN / A[i] * A[i];
		if (L > R) {
			cout << -1 << endl;
			return 0;
		} else {
			minN = L, maxN = R + A[i] - 1;
		}
	}

	cout << minN << ' ' << maxN << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[]s=sc.next().toCharArray();
		char[]t=sc.next().toCharArray();
		for(int  i =0;i<n;i++) {
			System.out.print(s[i]);
			System.out.print(t[i]);
		}
		
	}
	  static class Scanner {
	        StringTokenizer st;
	        BufferedReader br;
	 
	        public Scanner(FileReader r) {
	            br = new BufferedReader(r);
	        }
	 
	        public Scanner(InputStream s) {
	            br = new BufferedReader(new InputStreamReader(s));
	        }
	 
	        public String next() throws IOException {
	            while (st == null || !st.hasMoreTokens())
	                st = new StringTokenizer(br.readLine());
	            return st.nextToken();
	        }
	 
	        public int nextInt() throws IOException {
	            return Integer.parseInt(next());
	        }
	 
	        public long nextLong() throws IOException {
	            return Long.parseLong(next());
	        }
	 
	        public String nextLine() throws IOException {
	            return br.readLine();
	        }
	 
	        public double nextDouble() throws IOException {
	            String x = next();
	            StringBuilder sb = new StringBuilder("0");
	            double res = 0, f = 1;
	            boolean dec = false, neg = false;
	            int start = 0;
	            if (x.charAt(0) == '-') {
	                neg = true;
	                start++;
	            }
	            for (int i = start; i < x.length(); i++)
	                if (x.charAt(i) == '.') {
	                    res = Long.parseLong(sb.toString());
	                    sb = new StringBuilder("0");
	                    dec = true;
	                } else {
	                    sb.append(x.charAt(i));
	                    if (dec)
	                        f *= 10;
	                }
	            res += Long.parseLong(sb.toString()) / f;
	            return res * (neg ? -1 : 1);
	        }
	 
	        public boolean ready() throws IOException {
	            return br.ready();
	        }
	    }
}


Measured memory_bytes: 21076
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int h,w;
    cin >> h >> w;
    vector<string> mas(h);

    rep(i,h){
        cin >> mas[i];
    }

    auto inside = [&](int y,int x){
        return (y < h && x < w && y >= 0 && x >= 0);
    };

    int maxv = 0;

    rep(i,h){
        rep(j,w){
            rep(k,h){
                rep(l,w){
                    int sy = i,sx = j,gy = k,gx = l;
                    if(mas[sy][sx] == '#' || mas[gy][gx] == '#') continue;
                    vector<vector<int> > dist(h,vector<int>(w,INF));
                    queue<pii> que;
                    dist[sy][sx] = 0;
                    que.emplace(sy,sx);
                    while(!que.empty()){
                        int y = que.front().first,x = que.front().second;
                        que.pop();
                        rep(m,4){
                            int ny = y + dy[m];
                            int nx = x + dx[m];
                            if(inside(ny,nx) && dist[y][x] + 1 < dist[ny][nx] && mas[ny][nx] != '#'){
                                que.emplace(ny,nx);
                                dist[ny][nx] = dist[y][x] + 1;
                            }
                        }
                    }
                    if(mas[gy][gx] != INF) chmax(maxv,dist[gy][gx]);
                }
            }
        }
    }

    cout << maxv << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll a, p;
    cin >> a >> p;

    cout << (3*a+p)/2 << endl;

    return 0;
}


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

#define MOD 1000000007
#define lli long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = n - 1; ~i; i--)
#define pb push_back
#define mkp make_pair
#define endl "\n"

using namespace std;

bool enable_test_case = false;
bool enable_google = false;

void solve()
{
    lli n, total_weight;
    cin >> n >> total_weight;
    lli w[n], pro[n];

    rep(i, n)
    {
        cin >> w[i] >> pro[i];
    }

    lli dp[total_weight + 1];

    for (int i = 0; i <= total_weight; i++)
        dp[i] = 0;

    for (int i = 0; i < n; i++)
    {
        int weight = w[i], profit = pro[i];
        for (int j = total_weight; j >= 1; j--)
        {
            if (weight <= j)
                dp[j] = max(dp[j], profit + dp[j - weight]);
        }
    }
    cout << dp[total_weight] << endl;
}

void google_contests(int t)
{
    cout << "Case #" << t + 1 << ": ";
}

void test_case()
{
    if (enable_test_case)
    {
        lli t;
        cin >> t;
        rep(i, t)
        {
            if (enable_google)
                google_contests(i);
            solve();
        }
    }
    else
    {
        solve();
    }
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    test_case();

    return 0;
}


Measured memory_bytes: 4436
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.nextLine();
        int n = Integer.parseInt(num.split(" ")[0]);
        int m = Integer.parseInt(num.split(" ")[1]);
        int j = 0;
        int[][] A = new int[n][m];
        String tmp;
        while (j < n) {
            tmp = scan.nextLine();
            for (int i = 0; i < m; i++) {
                A[j][i] = Integer.parseInt(tmp.split(" ")[i]);
                // System.out.println(Integer.parseInt(tmp.split(" ")[i]));
            }
            j++;
        }
        j = 0;
        int[] b = new int[m];
        while (j < m) {
            tmp = scan.nextLine();
            b[j] = Integer.parseInt(tmp);
            j++;
        }

        int[] sum = new int[n];

        for (int i = 0; i < n; i++) {
            for (int q = 0; q < m; q++) {
                sum[i] += A[i][q] * b[q];
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.println(sum[i]);
        }
    }

}



Measured memory_bytes: 65260
import java.util.Scanner;

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

        int N = scanner.nextInt();

        int count = 0;

        for (int i = 1 ; i <= N ; i++) {
            if (String.valueOf(i).length() % 2 == 1) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 41160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class D {
        static final long mod = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long n = Long.parseLong(in.next());
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            out.println((mod + mod + mod + powAndMod(2, n) - 1 - combinationAndMod(n, a) - combinationAndMod(n, b)) % mod);

        }

        static long combinationAndMod(long n, long r) {
            r = Math.min(r, n - r);
            long x = 1, y = 1;
            for (long i = 1; i <= r; i++) {
                x = x * (n - r + i) % mod;
                y = y * i % mod;
            }
            return x * powAndMod(y, mod - 2) % mod;
        }

        static long powAndMod(long a, long b) {
            long x = 1;
            while (b > 0) {
                if (b % 2 == 1) {
                    x = x * a % mod;
                    b--;
                } else {
                    a = a * a % mod;
                    b /= 2;
                }
            }
            return x;
        }

    }
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

bool is_prime (int x) {
    if (x <= 1) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main () {
    int x; cin >> x;
    int p = x;
    while(!is_prime(p))p++;
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

//Mode Value
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[101];
		int m = 0;
		while(sc.hasNext())	m = Math.max(m, ++c[sc.nextInt()]);
		for(int i=1;i<=100;i++)if(m==c[i])System.out.println(i);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  string ns(s);
  int first = 1;
  int ans = 0;
  int cnt = 0;
  char tgt = 'a';
  ns[0] = s[0];
  for(int i=1;i<n;i++) {
    if (s[i-1] != s[i] ) {
      if (tgt == 'a') {
        tgt = s[i];
      }
      if( cnt == 1 ) {
        cnt = 0;
        --k;
        if (k==0) break;
      }
      else {
        ns[i] = (tgt=='L') ? 'R' : 'L';
        cnt = 1;
      }
    } else {
      if(cnt == 1) {
        ns[i] = (tgt=='L') ? 'R' : 'L';
      }
    }
  }

  ns = "R" + ns + "L";
  for ( int i=1; i<=n; ++i) {
    if( ns[i] == 'L' ) {
      if ( ns[i-1] == 'L' ) ans++;
    } else {
      if ( ns[i+1] == 'R' ) ans++;
    }
  } 
  
//  cout << ns << endl;
  cout << ans << endl;

}


Measured memory_bytes: 512
n = int(input())
p = list(map(float, input().split()))

dp = [[.0 for _ in range(n+1)] for _ in range(n+1)]
dp[0][0] = 1.0

for i in range(n):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1-p[i])

ans = sum(dp[-1][n//2+1:])

#print(dp)
print(ans)

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

int main() {
  long long A, B, K; cin >> A >> B >> K;
  A -= K;
  if (A < 0) {
    B += A;
    A = 0;
  }

  if (B < 0) B = 0;

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    aset = list(set(A))

    memo = [0] * (10 ** 6 + 1)

    for a in aset:
        for i in range(2, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            memo[a * i] += 1

    ans = 0
    c = collections.Counter(A)
    for a in A:
        # 同じ数が複数入っていた場合もカウントしない
        if memo[a] == 0 and c[a] == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 155492
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        idx=bisect.bisect_left(l,a+b)
        t=idx-j-1
        if t>0:
            ans+=t
print(ans)

Measured memory_bytes: 46064
#include <stdio.h>

int main(void)
{
	int i=0,j=1;
	while (1){
		scanf("%d", &j);
		if (j == 0){
			break;
		}
		printf("Case %d: %d\n", i + 1, j);
		i++;
	}
	return 0;

}

Measured memory_bytes: 600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	LL x;
	while(~scanf("%lld",&x)){
		printf("%lld\n",x <= 6 ? 1 : (x / 11 * 2 + (x % 11 == 0 ? 0 : (x % 11 <= 6 ? 1 : 2))));
	}
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li x[100100];
li pos[2][100100];

int main() {
    li n, k;
    cin >> n >> k;
    vector<li> pos;
    vector<li> neg;
    pos.pb(0);
    neg.pb(0);
    rin{
        cin >> x[i];
        if (x[i] == 0) {
            k--;
        } else if (x[i] < 0) {
            neg.pb(-x[i]);
        } else {
            pos.pb(x[i]);
        }
        neg.pb(INF);
        pos.pb(INF);
    }
    sort(allof(neg));
    sort(allof(pos));

    li res = INF;
    rep(i, min(k + 1, sz(neg))) {
        res = min(res, neg[i] + pos[k - i] + min(neg[i], pos[k - i]));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5360