akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100000
#define SEN 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[N / 2+2],R[N / 2 +2];

void merge(struct Card A[], int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value=R[n2].value=SEN;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

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

int main(){
  int n,i,v;
  struct Card A[N],B[N];
  char S[10];
  int stable =1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
  }

  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4200
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int n;
  cin >> n;
  vi dp(n);
  dp[0] = 1;
  Lrep(i,1,100) dp[i] = dp[i-1] + i + 1;
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 3424
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int N,A,B,b=0,c=0;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  for(int i=0; i<N; i++){
    if(S[i]=='a' && c<A+B){ cout << "Yes" << endl; c+=1; }
    else if(S[i]=='b' && c<A+B && b<B){ cout << "Yes" << endl; b+=1; c+=1; }
    else{ cout << "No" << endl;}
  }
}

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

int main()
{
    int m;
    cin >> m;
    cout << 48-m;
    
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=[]

  for i in range(n):
    l.append(LI())

  if n==1:
    return 1

  l2=[]
  for i in range(n):
    l3=[]
    for j in range(n):
      if i!=j:
        l3.append([l[j][0]-l[i][0],l[j][1]-l[i][1]])
    l2.append(l3)

  mx=0
  for i in range(n):
    _x=l2[i]

    for x in _x:
      sm=0
      for j in range(n):
        if i!=j:
          _y=l2[j]
          for y in _y:
            if x==y:
              sm+=1
      mx=max(mx,sm)

  return n-mx-1

print(main())


Measured memory_bytes: 5920
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
//#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair< PI, int> PII;
#define pb push_back
#define Key_value ch[ch[root][1]][0]
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define MS(x,y) memset(x,y,sizeof(x))
const double eps = 1e-6;
const double pi = acos (-1.0);
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int M = 300005;

int a[100050];

int main()
{
    int n;
    cin >> n;
    int aa = 0, bb = INF;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if(a[i] > aa) aa = a[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i)
    {
        if(a[i] == aa) cnt++;
        if(a[i] < aa - 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    if(cnt == n && aa + 1 == n)
    {
        cout << "Yes" << endl;
        return 0;
    }
    
    //cerr << aa << "  " << bb << endl;

    if(cnt == 1)
    {
        cout << "No" << endl;
        return 0;
    }

    int l = (n - cnt) + 1;
    int r = (n - cnt) + cnt / 2;
    if(l <= aa && aa <= r)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>

int find(std::vector<int>& a, int x) {
  int upper = std::upper_bound(a.begin(), a.end(), x) - a.begin();
  int lower = std::lower_bound(a.begin(), a.end(), x) - a.begin();
  if (upper - lower > 0) return lower;
  return -1;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  std::sort(a.begin(), a.end());
  std::vector<std::vector<int>> used(n, std::vector<int>(n, 0));
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (used[i][j]) continue;
      used[i][j] = true;
      int d = a[j] - a[i];
      int len = 2;
      int x = a[j];
      int k = j;
      while (true) {
        int next = find(a, x + d);
        if (next < 0) break;
        used[k][next] = true;
        k = next;
        ++len;
        x += d;
      }
      ans = std::max(ans, len);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 100804
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

    int d,n;
    cin >> d >> n;

    int k = 1;
    rep(i,d){
        k = k * 100;
    }

    if(n != 100){
        cout << k * n << endl;
    }else{
        cout << k * n + k << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<int>>;

int main()
{
    int n;
    cin >> n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        if (s.at(0) == 'A')
        {
            ac++;
        }
        if (s.at(0) == 'W')
        {
            wa++;
        }
        if (s.at(0) == 'R')
        {
            re++;
        }
        if (s.at(0) == 'T')
        {
            tle++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N=1050;
int d[5],p[3][N][N],col[5][5],n;
int main(){
	cin>>n>>d[0]>>d[1];
	for(int i=0;i<2;i++){
		int a=0,b=0;
		for(int l=0;l<=1000;l++){
			for(int r=0;r<=1000;r++){
				if(l*l+r*r==d[i]){
					a=l,b=r;
					break;
				}
			}
		}
		//cerr<<a<<" "<<b<<endl;
		if(!a)continue;
		int cnt=1,op=0;
		while(a%2==0&&b%2==0){
			a/=2,b/=2,cnt*=2;
		}
		if((a&1)&&(b&1))op=1;
		else op=2;
		//cerr<<op<<" "<<cnt<<endl;
		for(int l=0;l<2*n;l++){
			for(int r=0;r<2*n;r++){
				int x=l/cnt,y=r/cnt;
				if(op==2){
					if((x+y)%2==0)p[i][l][r]=1;
					else p[i][l][r]=0;
				}
				else{
					if(x%2==0)p[i][l][r]=1;
					else p[i][l][r]=0;
				}
			}
		}
	}
	for(int i=0;i<2*n;i++){
		for(int j=0;j<2*n;j++){
			col[p[0][i][j]][p[1][i][j]]++;
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			if(col[i][j]>=n*n){
				int cnt=n*n;
				for(int l=0;l<2*n;l++){
					for(int r=0;r<2*n;r++){
						if(p[0][l][r]==i&&p[1][l][r]==j){
							printf("%d %d\n",l,r);
							--cnt;
							if(cnt==0)exit(0);
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 9088
a = input()

hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
if int(a[-1]) in hon:
    print("hon")
    exit()

if int(a[-1]) in pon:
    print("pon")
    exit()

if int(a[-1]) in bon:
    print("bon")
    exit()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int x, y;
        cin >> x >>y;
        if(x==0 && y==0) break;
        if(x>y) swap(x, y);
        cout << x << " " << y <<endl;
    }
    return 0;
}


Measured memory_bytes: 3016
import fractions

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
# print(N, X, x)

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd_value = fractions.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = abs(fractions.gcd(gcd_value, x[i]))
    # print(gcd)
print(gcd_value)


Measured memory_bytes: 16276
import java.util.Scanner;

class Main {
  static public void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long gcd = gcd(A, B);
    int counter = 1;
    for(int i = 2; i <= Math.sqrt(gcd); i++) {
      if(gcd % i == 0) {
        counter++;
      }
      while(gcd % i == 0) {
        gcd /= i;
      }
    }
    if (gcd > 1) {
      counter++;
    }
    System.out.println(counter);
    return;
  }

  private static long gcd(long m, long n) {

    if(n == 0) {
      return m;
    }
    return gcd(n, m % n);
  }
}


Measured memory_bytes: 23764
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21648
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ ) {
    if ( ch =='\\' ) S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while ( S2.size() > 0 && S2.top().first > j ) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;

class vec {
public:
  double x;
  double y;
  vec(double nx, double ny) :x{nx}, y{ny} {}
};

class segment {
public:
  vec start;
  vec end;
  segment(vec start, vec end) :start{start}, end{end} {}
};

vec operator+(vec v1, vec v2) {
  return vec(v1.x+v2.x, v1.y+v2.y);
}

vec operator-(vec v1, vec v2) {
  return vec(v1.x-v2.x, v1.y-v2.y);
}

vec operator*(double a, vec v) {
  return vec(a*v.x, a*v.y);
}

vec operator*(vec v, double a) {
  return a*v;
}

vec rot90ccw(vec v) {
  return vec(-1.*v.y, v.x);
}

// post: splits the segment `s` into four resulting segments
// and enqueues them, in increasing Koch curve order, into
// `dest`
void split_and_add(segment& s, queue<segment>& dest)
{
  vec mid1 = (2./3)*(s.start) + (1./3)*(s.end);
  vec mid2 = (1./3)*s.start + (2./3)*s.end;
  vec triangle_top = rot90ccw((mid2-mid1)*0.5*sqrt(3.)) + 0.5*(mid1 + mid2);
  dest.push(segment(s.start, mid1));
  dest.push(segment(mid1, triangle_top));
  dest.push(segment(triangle_top, mid2));
  dest.push(segment(mid2, s.end));
}

int main()
{
  int n; cin >> n; // number of iterations
  queue<segment> q;
  q.push(segment(vec(0,0), vec(100,0)));
  for (int i = 0; i < n; ++i) {
    queue<segment> q2;
    while (!q.empty()) {
      segment &s = q.front();
      split_and_add(s, q2);
      q.pop();
    }
    q = move(q2);
  }
  cout << fixed;
  cout << q.front().start.x << " " << q.front().start.y << endl;
  while (!q.empty()) {
    segment &s = q.front();
    cout << s.end.x << " " << s.end.y << endl;
    q.pop();
  }
}


Measured memory_bytes: 3364
#include <iostream>
using namespace std;
#define ll long long

ll x,y,a,b;

int main(){
    cin>>x>>y;
    b=(y-2*x)/2;
    a=x-b;
    //cout<<a<<" "<<b<<endl;
    if(a*2+4*b==y && b+a==x && a>=0 && b>=0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll lp[10000001];

void prime()
{
    repf(i,1,10000001) lp[i]=i;
    repf(i,2,10000001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<10000001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
}

void solve(ll tt) {
    ll a;
    string s;
    cin>>a>>s;
    ll b=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    ll ans=a*b;
    ans/=100;
    cout<<ans<<endl;
    
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r;
	cin>>l>>r;
	int a=l/2019;
	a*=2019;
	if(a<l) a+=2019;
	if(a<=r)
	{
		cout<<0<<endl;
		return 0;
	}
	int ans=4019;
	for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
		{
			int x=i%2019,y=j%2019;
			ans=min(ans,x*y%2019);
		}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  bool judge = false;
  for(int i=1; i<10; i++){
    for(int j=i; j<10; j++){
      if(i*j == n){
        judge = true;
      }
    }
  }
  if(judge == true) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;
}

Measured memory_bytes: 888
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

N, M, K = getNM()

# グループ分けをして解いていく
U = UnionFind(N)

friendlist = [getList() for i in range(M)]
blockedlist = [getList() for i in range(K)]
# friendlist内のa, bを繋いでいく
for a, b in friendlist:
    U.union(a - 1, b - 1)

friends = [0] * (N + 1)
blocks = [0] * (N + 1)

# 「同じグループ内に」友達、ブロックが何人いるか
for a, b in friendlist:
    if U.same(a - 1, b - 1):
        friends[a - 1] += 1
        friends[b - 1] += 1
for a, b in blockedlist:
    if U.same(a - 1, b - 1):
        blocks[a - 1] += 1
        blocks[b - 1] += 1

ans = []
for i in range(N):
    # U.size: グループの大きさ
    cnt = U.size(i) - friends[i] - blocks[i] - 1
    ans.append(cnt)
print(*ans)

Measured memory_bytes: 122200
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s[2];
    cin >> s;
    if('a' <= s[0] && s[0] <='z'){
        s[0]='a';
    }
    else s[0]='A';
    cout << s[0] <<endl;
    return 0;
}



Measured memory_bytes: 3604
from collections import deque
N, K = map(int, input().split())
memo = [-1]*(N+1)
junban = deque()
A = [0]+list(map(int, input().split()))
i = 0
x = 1
while memo[x] < 0:
  junban.append(x)
  memo[x] = i
  x = A[x]
  i += 1
T = i-memo[x]
if K < i:
  print(junban[K])
else:
  print(list(junban)[memo[x]:][(K-memo[x])%T])


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

int main(){
    ll h; cin >> h;

    ll ans = 0, num = 1;
    while(h > 0){
        ans += num;
        h /= 2;
        num *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
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();
        String conpare;
        if (a < b) {
            conpare = " < ";
        } else if (a > b) {
            conpare = " > ";
        } else {
            conpare = " == ";
        }

        System.out.println("a" + conpare + "b");
    }
}


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

using namespace std;



int main() {
	
	long long n, a[5];
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	long long minn=(long long)pow(10,15);

	for (int i = 0; i < 5; i++) {
		minn = min(minn, a[i]);
	}

	long long bunkatu = 0;
	if (n%minn == 0) {
		bunkatu = n / minn;
	}
	else {
		bunkatu = (long long)(n / minn) + 1;
	}

	cout << 5 + bunkatu - 1 << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
h,w = list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))

index = np.argsort(a)[::-1]+1
a_sorted = np.sort(a)[::-1]

ans = np.zeros((h,w)).astype(dtype='int')

row,col,color = 0,0,index[0]
a_index = 0
col_direction = 1
cnt = 0
for i in range(h*w):
    ans[row][col] = color
    col += col_direction
    if(col == w):
        col_direction = -1
        col -= 1
        row += 1
    elif(col == -1):
        col_direction = 1
        row += 1
        col += 1
    cnt += 1
    if(cnt == a_sorted[a_index]):
        #print(a_index,color)
        cnt = 0
        a_index += 1
        if(a_index == len(a)):
            a_index = len(a)-1
        color = index[a_index]
        #print(a_index,color)

anslist = ans.tolist()
for i in range(h):
    for j in range(w):
        print(ans[i][j],end='')
        if(j != w-1):
            print(' ',end='')
    print('')

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

vector<ll> ans;
vector<ll> memo;

void dfs(const vector<vector<int>> &G, int v, int p){
  if(v==0){
    ans[v]=memo[v];
  }
  else{
    ans[v]=memo[v]+ans[p];
  }
  for(auto nv:G[v]){
    if(nv==p) continue;
    dfs(G,nv,v);
  }
}

int main() {
  int n,q;
  cin>>n>>q;
  vector<vector<int>> G(n);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  memo.assign(n,0);
  for(int i=0;i<q;i++){
    int p,x;
    cin>>p>>x;
    p--;
    memo[p]+=x;
  }
  ans.assign(n,0);
  dfs(G,0,-1);
  for(int i=0;i<n;i++){
    cout<<ans[i];
    if(i!=n-1) cout<<' ';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 26656
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<ll> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }   

    ll cnt = 0;
    REP(i, N){
        if(a[i] > b[i]){
            cnt += a[i] - b[i];
        }else if(a[i] < b[i]){
            cnt -= (b[i] - a[i]) / 2;
        }
    }

    Yes(cnt <= 0);
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back

using namespace std;

const int N = 1e6+69, mod = 1e9+9;

ll n,m,x,y,a,b,c,d,t,k,ans=1e18,cur,l,r,mx;

ll A[N],sum[N];

int main() {
    
   cin>>n;
   for(int i=1;i<=n;i++)
   cin>>A[i],A[i] -= i;
   
   sort(A+1,A+n+1);
   for(int i=1;i<=n;i++)
   sum[i] = sum[i-1] + A[i];
   
   for(int i=1;i<=n;i++){
       b = A[i];
       ans = min(ans,b*i-sum[i]+sum[n]-sum[i]-b*(n-i));
   }
   
   cout<<ans<<endl;
}


Measured memory_bytes: 5888
from bisect import bisect_left
import math
def divisors(n, sort=True, reverse=False):
    sqn = math.sqrt(n)
    sqn_int = int(sqn)
    div_list = []
    if sqn == sqn_int:
        div_list.append(sqn_int)
        loop = range(1,sqn_int)
    else:
        loop = range(1,sqn_int + 1)
    for i in loop:
        if n % i == 0:
            div_list.append(i)
            div_list.append(n//i)
    if sort:
        div_list.sort(reverse=reverse)
    return div_list

N = int(input())
div_list = divisors(N)
i = bisect_left(div_list, int(math.sqrt(N)))
a = div_list[i]
b = N//a
print(a+b-2)

Measured memory_bytes: 38768
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();

        if(a>x){
            System.out.println("NO");
        }
        else if(x-a <= b){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#define LEN 200000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head = 1, tail=1, n;

void enqueue(P x){
  Q[tail] = x;
  tail++;
}

P dequeue(){
  head++;
  return Q[head-1];
}


int main(){
  int elaps = 0, remain = 0, time = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail = i+1;
  }

  for(i = 1; n > 0; i++){
    time+=q;
    remain = Q[i].t - q;
    if(remain <= 0){
      u = dequeue();
      printf("%s %d\n", u.name, time = time+remain);
      n--;
    }else{
      Q[i].t = remain;
      enqueue(Q[i]);
      dequeue();
    }
    
  }
  return 0;
}



Measured memory_bytes: 20940
//{{{
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

const int N = 3e3 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

int s;
int n = 3000;
LL c[N][N];

LL cal(int nn)
{
    int x = s - 2 * nn;
    return c[x - 1][nn - 1];
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    c[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++)
        {
            c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
            c[i][j] %= mod;
        }
    }

    while (cin >> s)
    {
        LL ans = 0;
        for (int l = 1; l <= s; l++)
        {
            if (3 * l > s) continue;

            LL v = cal(l);
            ans = (ans + v) % mod;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 49812
#include<stdio.h>
int main(void)
{
  int num1,num2,ans;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d%d",&num1,&num2);
  
  ans = num1*num2;
  
  if(ans%2 == 0)
  {
    puts("Even");
  }else
  {
    puts("Odd");
  }
  
  return 0;
}

  
  

Measured memory_bytes: 128
import java.util.*;

public class Main{
    
    static final int MAX = (int)1e3*5;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];
        int[] imo = new int[MAX];
        for(int i=0; i<n; i++){
            l[i] = Integer.parseInt(sc.next());
            imo[l[i]]++;
        }
        
        for(int i=0; i+1<MAX; i++){
            imo[i+1] += imo[i];
        }
        
        long ans = 0;
        for(int i=0; i<n;i++){
            int a = l[i];
            for(int j=i+1; j<n; j++){
                int b = l[j];
                int cmax = a+b-1;
                int cmin = Math.max(a-b+1, b-a+1);
                ans += imo[cmax] - imo[cmin-1];
                if(cmin<=a && a<=cmax) ans--;
                if(cmin<=b && b<=cmax) ans--;
            }
        }
        
        System.out.println(ans/3);
    }
}


Measured memory_bytes: 26584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n-1; i++) {
    cin >> a;
    x[a-1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << x[i] << endl;
  }
  
  
}

Measured memory_bytes: 4036
# https://atcoder.jp/contests/abc126/tasks/abc126_c
n, k = map(int, input().split())

ans = 0
for i in range(1, n + 1):
    c = 0
    while i < k:
        i *= 2
        c += 1
    ans += (0.5 ** c) / n
print(ans)

Measured memory_bytes: 38896
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s; cin >> s;
    Yes(s != "AAA" && s != "BBB");
}



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

int main() {
  int a, b; cin >> a >> b;
  if(a == b) cout << "Draw";
  else if(a == 1 && b != 1) cout << "Alice";
  else if(a != 1 && b == 1) cout << "Bob";
  else{
  if(a>b) cout << "Alice";
  else if(a<b) cout << "Bob";
  }
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

signed main(){
	int x, y, n;
	scanf("%d %d %d", &y, &x, &n);
	
	if(n == 0){
		printf("%lld\n", (ll)(x-2) * (ll)(y-2));
		rep(9) printf("%d\n", 0);
		return 0;
	}
	
	map< P, ll > a;
	map<ll, ll> ans;
	ans[0] = (ll)(x-2) * (ll)(y-2);
	rep(n){
		int xx, yy;
		scanf("%d %d", &yy, &xx);
		
		reppp(di, max(1, yy-2), min(yy, y-2)){
			reppp(dj, max(1, xx-2), min(xx, x-2)){
				ll tmp = a[P(di, dj)];
				a[P(di, dj)]++;
				ans[tmp]--;
				ans[tmp+1]++;
			}
		}
	}
	
	
	rep(10){
		printf("%lld\n", ans[i]);
	}
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()



def getScore(a, b):
    score = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            score += 1
    return score

D = len(S) - len(T) + 1

minScore = 100000000000
for i in range(D):
    Sa = S[i:i+len(T)]
    score = getScore(Sa, T)
    
    if score <= minScore:
        minScore = score
print(minScore)


Measured memory_bytes: 9056
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int A,B,M;
int a[100004];
int b[100004];
int x[100004];
int y[100004];
int c[100004];
int ans,am,bm;
int main(){FAST;xRand;
cin>>A>>B>>M;
am=bm=lmax;
for(int i=1;i<=A;i++){
	cin>>a[i];
	am=min(a[i],am);
}
for(int i=1;i<=B;i++){
	cin>>b[i];
	bm=min(b[i],bm);
}
ans=lmax;
for(int i=1;i<=M;i++){
	cin>>x[i]>>y[i]>>c[i];
	ans=min(a[x[i]]+b[y[i]]-c[i],ans);
}
cout<<min(ans,am+bm)<<endl;

	// you should actually read the stuff at the bottom
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), slow multiset operations
	* do smth instead of nothing and stay organized
	* unordered_map, hash_map, scanf, calculate answer instead of ans*K
*/
/*


                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/




Measured memory_bytes: 2176
// Problem : A - Sheep and Wolves
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int s,w;
	cin>>w>>s;
	if(s < w)
	{
		cout<<"safe";
	}
	else
	{
		cout<<"unsafe";
	}
	return 0;
}

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

int main() {
  int N, K, total=0, x;
  cin >> N >> K;
  for (int i = 0; i<N; i++){
    cin >> x;
    total += (x < (K-x))? x: (K-x);
  }
  cout << total * 2 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    cout << a - (b < a) << endl;
}

Measured memory_bytes: 256
import sys

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


def main():
    H, A = map(int, read().split())

    print((H + A - 1) // A)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};



int n,m,k,a,b,c,d,x,y,arr[N];
string s;
void solve()
{
    cin>>n;
    forn(i,1,n)cin>>arr[i];
    arr[n+1]=-MOD;
    int f=0;

    int i=1;
    vi A;
    while(1)
    {

        if(f==0)
        {
            while(arr[i]>=arr[i+1])
            {
                i++;
                if(i==n+1)
                {    
                    //i=n;
                    break;
                }
            }
            A.pb(arr[i]);
            f^=1;
        }
        else
        {
            while(arr[i]<=arr[i+1])
            {
                i++;
                if(i==n+1)
                {
                    //i=n;
                    break;
                }
            }
            A.pb(arr[i]);
            f^=1;
        }

        if(i==n+1)break;
    }

   // for(auto i : A)cout<<i<<" ";nl;

    int money=1000,stocks=0;
    f=0;
    int ans=1000;
    for(auto i : A)
    {
        if(f==0)
        {
            stocks=money/i;
            money=money%i;
        }
        else
        {
            money+=i*stocks;
            ans=max(ans,money);
        }
        f^=1;   
    }

    cout<<ans;




}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int n;
  cin>>n;
  
    cout<<n/2 + n%2<<endl;

    

  return 0;
}

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

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

    int have[N]={0};
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int A;
            cin >> A;
            have[A-1]=1;
        }
    }

    int sum=0;
    rep(i, N) if(have[i]==0) sum++;
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << abs(min(n - a - b, 0ll)) << endl;
}

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

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

  int n = s.size();

  int flag = 0;
  
  //reverse(s.begin(),s.end());
  
  rep(i,s.size()/2){
    if(s.at(i)!=s.at(n-i-1))
    flag++;
  }

  cout << flag;
  
  //cout << flag;

}


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

int main()
{
  int tmp,tmp2;
  cin>>tmp;
  string s;
  for(;cin>>s,s!="=";)
    {
      cin>>tmp2;
      if(s=="+")
	tmp+=tmp2;
      else if(s=="-")
	tmp-=tmp2;
      else if(s=="*")
	tmp*=tmp2;
      else if(s=="/")
	tmp/=tmp2;
    }
  cout<<tmp<<endl;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	ll sum = a + b;

	if (sum % 2 == 0) {
		cout << sum / 2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
}


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

int main() {
    string s;
    cin >> s;
    
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    {
        cout << "Yes" << endl;
    }
    else if (s[0] == s[2] && s[1] == s[3]&& s[0] != s[1])
    {
        cout << "Yes" << endl;
    }
    else if (s[0] == s[3] && s[1] == s[2]&& s[0] != s[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int e;
  while (cin >> e && e) {
    int m = 1 << 30;
    for (int y = 0; y <= 1000; y++) {
      for (int z = 0; z <= 100; z++) {
        int x = e - y * y - z * z * z;
        if (x >= 0)
          m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 868
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    String t = in.readLine();
    int cnt = 0;
    if(s.substring(0,1).equals(t.substring(0,1)))
      cnt += 1;
    if (s.substring(1,2).equals(t.substring(1,2)))
      cnt += 1;
    if (s.substring(2,3).equals(t.substring(2,3)))
      cnt += 1;
    System.out.println(cnt);
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll t[n], d[n];
    rep(i, n) cin >> t[i] >> d[i];

    vector<pll> all_v;
    rep(i, n) all_v.push_back(MP(d[i], t[i]));
    sort(all(all_v));
    reverse(all(all_v));
    bool top_used[limit] = {};
    priority_queue<ll> each_top, others;
    for (auto p : all_v) {
        if (!top_used[p.second]) {
            top_used[p.second] = true;
            each_top.push(p.first);
        } else {
            others.push(p.first);
        }
    }

    ll each_top_sum[limit], others_sum[limit]; //1-indexed
    fill(each_top_sum, each_top_sum + limit, -LINF);
    fill(others_sum, others_sum + limit, -LINF);
    each_top_sum[0] = others_sum[0] = 0;
    int index = 1;
    while (!each_top.empty()) {
        each_top_sum[index] = each_top_sum[index - 1] + each_top.top();
        each_top.pop();
        index++;
    }
    index = 1;
    while (!others.empty()) {
        others_sum[index] = others_sum[index - 1] + others.top();
        others.pop();
        index++;
    }

    ll Max = 0;
    for (ll kind = 1; kind <= k; ++kind) {
        ll point = kind * kind;
        int remainder = k - kind;
        point += each_top_sum[kind];
        point += others_sum[remainder];
        Max = max(Max, point);
    }
    cout << Max << endl;
    return 0;
}

Measured memory_bytes: 6896
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int SIZE=102*102;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    bool poss[SIZE];
    fill(poss, poss+SIZE, false);
    poss[0] = true;
    F(i,n) {
        int a; cin>>a;
        //D(a);
        DEC(j,SIZE) if (j-a >= 0 && poss[j-a]) {
            poss[j] = true;
        }
    }
    int best=0;
    F(i,SIZE) {
        //if (poss[i]) D(i);
        if (i%10 && poss[i])
            best = i;
    }
    P(best);
}

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

int main() {
	int n, a[1000];
	cin >> n ;
	for (int x = 0; x < n; ++x)cin >> a[x];
	sort(a,a + n);
	cout << (a[(n - 1)]-a[0]) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	static int n,ans;
	static int A,B;
	static int a[];
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			n=in.nextInt(); //n<=20
			if(n==0)
				return;
			a=new int[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			ans=1000000;
			A=0;
			B=0;
			dfs(0,A,B);
			System.out.println(ans);
		}
	}

	static void dfs(int i,int A,int B)
	{
		if(i==n)
		{
			int dif=Math.abs(A-B);
			ans=Math.min(ans,dif);
		}
		else
		{
			dfs(i+1,A+a[i],B);
			dfs(i+1,A,B+a[i]);
		}
	}

	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20908
#include<stdio.h>
int main(void){
  int w,n,k,tmp;
  scanf("%d",&w);
  scanf("%d",&n);
  int num[w]; //1????????????
  for(k=1;k<=w;k++){
    num[k-1]=k;
  }
  int a,b;
  for(k=1;k<=n;k++){
    scanf("%d",&a);
    scanf(",");
    scanf("%d",&b);
    tmp=num[a-1];
    num[a-1]=num[b-1];
    num[b-1]=tmp;
  }
  for(k=1;k<=w;k++){
    printf("%d\n",num[k-1]);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    ll x;
    cin >> x;
    ll count = 0, now=100;
    while(x>now){
        now += (ll)(now*0.01);
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  value = 1
  skips = {}
  prev = -1

  for _ in range(int(input())):
    n = int(input())

    if n == prev:
      continue

    prev = n

    if n in skips:
      value += skips[n]

    skips[n] = value

  print(value % int(1e+9 + 7), flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 27104