akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<u32>();
    let h = v[0];
    let _w = v[1];

    for _i in 0..h {
        let s = read::<String>();
        /*
        let new_s = s.chars().map(|c| {
            let mut a = c.to_string();
            a.push(c);
            a
        }).collect::<String>();
        */
        println!("{}", s);
        println!("{}", s);
    }
}


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

struct tree {
	vector<int> children;
	int depth;
	int parent;
	string type; // root, leef, internal node
};

tree trees[100000];

int calc_depth(int n) {
	for (vector<int>::iterator i = trees[n].children.begin(); i < trees[n].children.end(); i++) {
		trees[*i].depth = trees[n].depth + 1;
		calc_depth(*i);
	}
}

int main(void) {
	// ??\????????°
	int num;

	cin >> num;

	for (int i = 0; i < num; i++) {
		trees[i].parent = -1;
		trees[i].depth = 0;
	}

	// ?????¨?????????????????\??????
	for (int i = 0; i < num; i++) {
		int node, children;
		cin >> node >> children;
			for (int j = 0; j < children; j++) {
				int child;
				cin >> child;
				trees[node].children.push_back(child);
				trees[child].parent = node;
		}
	}

	// depth????±???????
	for (int i = 0; i < num; i++) {
		if (trees[i].parent == -1) {
			calc_depth(i);
		}
	}

	for (int i = 0; i < num; i++) {
		cout << "node " << i << ": parent = " << trees[i].parent;
		cout << ", depth = " << trees[i].depth << ", ";
		if (trees[i].parent == -1) {
			cout << "root";
		} else if (trees[i].children.size() == 0) {
			cout << "leaf";
		} else {
			cout << "internal node";
		}
		cout << ", [";
		for (int j = 0; j < trees[i].children.size(); j++) {
			cout << trees[i].children[j];
			if (j != trees[i].children.size() - 1) {
				cout << ", ";
			}
		}
		cout << "]" << endl;
	}
	return 0;
}

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

int main (void){
        int n, k;
        cin >> n >> k;
        ll h[n + 5];
        for (int i = 0; i < n;i++){
                cin >> h[i];
        }
        sort(h, h + n);
        ll min = inf;
        ll s[n + 5];
        for (int i = 0; i < n - k+1;i++){
                if(min>h[i+k-1]-h[i]){
                        min =  h[i + k-1] - h[i];
                }

        }

        cout << min << endl;
        return 0;
}

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

int main ()
{
  ll q,h,s,d,n,x,ans=0;
  cin>>q>>h>>s>>d>>n;
  if(n%2==0)
  {
    x=d*(n/2);
  }
  else
  {
      x=d*(n/2)+min(s,min(4*q,2*h));
  }
  ans=min(4*n*q,min(2*n*h,min(n*s,x)));
  cout<<ans;
   return 0;
}


Measured memory_bytes: 256
data = [input().split(" ") for i in range(2)]
lake = data[0]
house = data[1]
housedata = house[0]
houseend = house[int(lake[1])-1]
result = []
result.append(int(housedata)+int(lake[0])-int(houseend))
for detail in house:
  if detail!=housedata:  
    aida = int(detail) - int(housedata)
    result.append(int(aida))
    housedata=detail
max = max(result)
print(int(lake[0])-max)

Measured memory_bytes: 20148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  queue<long>que;
  set<long>s;
  for(int i=1;i<=9;i++){
    que.push(i);
    s.insert(i);
  }
  while(!que.empty()){
    long tmp = que.front();
    que.pop();
    if(tmp < 1e10){
      int fir = tmp % 10;
      if(fir != 9){
        que.push(tmp*10 + fir + 1);
        s.insert(tmp*10 + fir + 1);
      }

      if(fir != 0){
        que.push(tmp*10 + fir - 1);
        s.insert(tmp*10 + fir - 1);
      }

      que.push(tmp*10 + fir);
      s.insert(tmp*10 + fir);
    }
  }

  auto it = s.begin();
  for(int i=0;i<k-1;i++)it++;
  cout << *it << endl;
}


Measured memory_bytes: 30592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

bool exist[128];

int main(){
  int N,M,i;
  map<char,char> mp;

  for(;;){
    scanf("%d\n",&N);
    if(N == 0) break;
    mp.clear();
    rep(i,1<<7) exist[i] = false;

    rep(i,N){
      char a,b;
      scanf("%c %c\n",&a,&b);
      exist[a] = true;
      mp[a] = b;
    }

    scanf("%d\n",&M);
    string res;
    rep(i,M){
      char a;
      scanf("%c\n",&a);
      if(exist[a]) res += mp[a];
      else res += a;
    }

    cout << res << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
	string x;
	int n,m;
    vector<int> p, a;
	p.push_back(0);
	a.push_back(0);
	getline(cin, x);
	while(n=x.find("peach", p.back() + 5), ~n)
		p.push_back(n);
	while(m=x.find("apple", a.back() + 5), ~m)
		a.push_back(m);
	for(int i = 1; i < p.size(); i++)
		x.replace(p[i], 5, "apple");
	for(int j = 1; j < a.size(); j++)
		x.replace(a[j], 5, "peach");
	cout<< x <<endl;
	return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n,k;cin>>n>>k;
    vector<long long> a(n,0); for(int i=0;i<n;i++) cin>>a[i];
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k]) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

int cti(const char c) {
  return c - '0';
}

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

  string n;
  cin >> n;
  int k;
  cin >> k;
  VVL dp1(101, VL(k + 2, 0)), dp2(101, VL(k + 2, 0));

  int digit = n.size();
  dp1[0][0] = 1;
  dp1[0][1] = cti(n[0]) - 1;
  dp2[0][1] = 1;
  rep(i, digit - 1) {
    rep(j, k + 1) {
      ll num = cti(n[i + 1]);
      if (num == 0) {
        dp1[i + 1][j] += dp1[i][j];
        dp1[i + 1][j + 1] += dp1[i][j] * 9;
        dp2[i + 1][j] += dp2[i][j];
        dp2[i + 1][j + 1] += 0;
      }
      else {
        dp1[i + 1][j] += dp1[i][j] + dp2[i][j];
        dp1[i + 1][j + 1] = dp1[i][j] * 9 + dp2[i][j] * (num - 1);
        dp2[i + 1][j] += 0;
        dp2[i + 1][j + 1] += dp2[i][j];
      }
    }
  }

  out(dp1[digit - 1][k] + dp2[digit - 1][k]);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

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

    cout << (n - 2) * 180 << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

string s;

int main(){
	cin >> s;
	
	s.erase(std::unique(s.begin(), s.end()), s.end());
	cout << s.size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20 bal4u@uu
// 2017.11.5 retry

#include <stdio.h>

#define MAX 10000
#define MAX2 500000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];

char buf[100002], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

void pr(int n)
{
	int i;
	char t[12];

	if (!n) { *p++ = '0'; return; }
	i = 0;
	while (n) {
		t[i++] = '0' + (n % 10);
		n /= 10;
	}
	while (i) *p++ = t[--i];
}

int main()
{
	int N, M, L, i, j, k, ans;
	WAK *w;

	fgets(p=buf, 20, stdin), N = getint(), p++, M = getint();
	while (fgets(p=buf, 30, stdin) && *p != '0') {
		w = wak + getint(), p++, lnk[used].t = getint(), p++, lnk[used].e = getint();
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	fgets(p=buf, 10, stdin), L = getint();
	while (L--) {
		fgets(p=buf, 100000, stdin);
		for (i = 1; i <= M; i++) b[i] = getint(), p++;
		p = buf;
		for (w = wak+1, i = 1; i <= N; i++, w++) {
			if (i > 1) *p++ = ' ';
			if (w->n == 0) { *p++ = '0'; continue; }
			for (ans = 0, k = w->nxt, j = w->n; j > 0; j--, k = lnk[k].nxt)
				ans += lnk[k].e * b[lnk[k].t];
			pr(ans);
		}
		*p = 0,	puts(buf);
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<vector<int>> h(n, vector<int>(3));
  rep(i,n){
    rep(j,3){
      cin >> h.at(i).at(j);
    }
  }
  vector<vector<int>> dp(n, vector<int>(3,0));
  
  
  rep(i,n){
    
    if (i == 0){
      rep(l,3){dp.at(0).at(l) = h.at(0).at(l);}
      continue;
    }
    
    rep(j,3){
      rep(k,3){
        
      if(k != j){
        dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(k)+h.at(i).at(j));
      }
      
      }
    }
  }
    
    int ans = 0;
    rep(i,3){
    ans = max(ans, dp.at(n-1).at(i));
    }
    
    cout << ans << endl;
    
  }

Measured memory_bytes: 11136
K,S= input().split()
intK = int(K)
intS = int(S)
sum = 0
for X in range(intK+1):
    for Y in range(intK+1):
        Z = intS - (X+Y)
        if (Z < 0) or Z > intK:
            continue
        sum += 1
print(sum)

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

signed main() {
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	for (int i = 0; i < n; ++i) {
		if (v[i] - c[i] > 0) {
			cnt += v[i] - c[i];
		}
	}
	cout << cnt << endl;
}


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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

ll l1,r1,u1,d1,l2,r2,u2,d2;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

ll h,w,n,i;
ll x,y;
string one,two;
cin>>h>>w>>n;
cin>>x>>y;
cin>>one>>two;

ll l=0,r=0,u=0,d=0;
ll xx=x,yy=y;
ll fl=0;
for(i=0;i<n;i++)
{
  if(one[i]=='R')yy++;
  if(yy>w)fl=1;
   
  if(yy>1 && two[i]=='L')yy--;
  
 

}

 xx=x,yy=y;
for(i=0;i<n;i++)
{
  if(one[i]=='D')xx++;
  if(xx>h)fl=1;
   
  if(xx>1 && two[i]=='U')xx--;
  
 

}

 xx=x,yy=y;
for(i=0;i<n;i++)
{
  if(one[i]=='L')yy--;
  if(yy<1)fl=1;
   
  if(yy<w && two[i]=='R')yy++;
  
 

}
 xx=x,yy=y;
for(i=0;i<n;i++)
{
  if(one[i]=='U')xx--;
  if(xx<1)fl=1;
   
  if(xx<h && two[i]=='D')xx++;
  
 

}

if(fl)cout<<"NO";
else cout<<"YES";





  return 0;
 }

Measured memory_bytes: 920
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{


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

map<ll,ll> m;
ll ans=0;
for(int i=n-1;i>=0;i--)
{
	ll val=m[a[i]+i];
	ans+=val;
	m[i-a[i]]++;
	
	
}

cout<<ans;



}return 0;}


Measured memory_bytes: 27812
# -*- coding: utf-8 -*-
import sys

#tmp= int(input())
#tmp = input().split()
#W,H,x,y,r = list(map(lambda a: int(a), tmp))


for i in range(0,10000):
    tmp = input().split()
    x,y = list(map(lambda a: int(a), tmp))
    if((x==0)and(y==0)):
        sys.exit()

    if(x>y):
        print(y,x)
    else:
        print(x,y)




Measured memory_bytes: 5624
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;

typedef pair<int, int> P;

int a[100000];
P card[100000];

int max(int a,int b){return a > b ? a : b;}

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

    for(int i = 0; i < n; i++)scanf("%d", &a[i]);
    for(int i = 0; i < m; i++) {
        int c, b;
        scanf("%d %d", &c, &b);
        card[i] = P(b, c);
    }

    sort(a, a + n);
    sort(card, card + m);
    reverse(card, card + m);

    int t = 0;
    for(int i = 0; i < m; i++) {
        P p = card[i];
        int b = p.first;
        int c = p.second;
        for(int j = 0; j < c; j++) {
            a[t] = max(a[t], b);
            t++;

            if(t == n) break;
        }

        if (t == n) break;
    }

    long long s = 0;
    for(int i = 0; i < n; i++) s += a[i];
    printf("%lld\n", s);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for( int i = a; i <= b; ++i ) {
        if( i / 10000 % 10 == i % 10 && i / 1000 % 10 == i / 10 % 10 ) ++cnt;
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define vll vector<ll>
#define sz size()
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
const int N = 100005;

int main()
{
   string s;
   cin>>s;
   if(s=="SUN")
   cout<<"7";
   else if(s=="MON")
   cout<<"6";
   else if(s=="TUE")
   cout<<"5";
   else if(s=="WED")
   cout<<"4";
   else if(s=="THU")
   cout<<"3";
   else if(s=="FRI")
   cout<<"2";
   else 
   cout<<"1";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, num1, num2, num3, ans;
    scanf("%d", &a);
    
    if(a/100 == 1)
        num1 = 1;
    else
        num1 = 0;
    if(a%2 == 1)
        num3 = 1;
    else
        num3 = 0;
    
    b = a%100;
    num2 = b/10;
    
    ans = num1 + num2 + num3;
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 128
n = int(input())
array = list(map(int, input().split()))

bob = []
alice = []
for i in range(1, n+1):
    max_value = max(array)
    if i % 2 == 1:
        alice.append(max_value)
    else:
        bob.append(max_value)
    array.remove(max_value)

print(sum(alice)-sum(bob))


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

int n;
vector<vector<int>> G;
vector<int> ans;

void dfs(int u, int p=-1) {
    for (int v : G[u]) {
        if (v==p) continue;
        ans[v] += ans[u];
        dfs(v,u);
    }
}

int main() {
    int q;
    cin>>n>>q;
    G.resize(n); ans.resize(n);
    rep(i,n-1) {
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q) {
        int p,x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 24360
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H;
    
    while(1){
        cin>>H>>W;
        if(H==0  && W==0) break;
        
         for(int k=1; k<=W; k++){
                cout << '#' << flush;
            }
        cout<<'\n';
        for(int i=2; i<H; i++){
         cout<<'#';
            for(int j=2; j<W; j++){
                cout << '.' << flush;
            }
        cout<<'#';
        cout<<'\n';
        }
        for(int l=1; l<=W; l++){
                cout << '#' << flush;
            }
        cout<<'\n'<<'\n';
        }
    
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    ll ma = -1;  // aの中で絶対値が最大の数の絶対値
    ll id = -1;  // aの中で絶対値が最大の数のindex
    rep(i, n) {
        cin >> a[i];
        if(ma < abs(a[i])) {
            ma = abs(a[i]);
            id = i+1;
        }
    }

    out(2*(n-1));
    // aの中で絶対値が最大の数を他の数に足しまくる
    exrep(i, 1, n) {
        if(i == id) {
            continue;
        }
        cout << id << " " << i << "\n";
    }

    if(a[id-1] > 0) {  // a[id]を足した後のaの要素が全て正のとき
        // 左から累積和
        exrep(i, 1, n-1) {
            cout << i << " " << i+1 << "\n";
        }
    }
    else {  // a[id]を足した後のaの要素が全て0以下のとき
        // 右から累積和
        for(ll i = n-1; i >= 1; i--) {
            cout << i+1 << " " << i << "\n";
        }
    }

    re0;
}

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

using namespace std;

int main()
{
    vector<long long> a;
    int n;
    cin>>n;
    long long k;
    set <long long, greater <long long> > b;
    for(int i=0; i<n; i++)
    {
        cin>>k;
        a.push_back(k);
        b.insert(k);
    }
    if(a.size()==b.size())
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 11120
# input
W, H, x, y = map(int, input().split())

# check
ans = (W * H) / 2

if W % 2 == 0 and H % 2 == 0 and W // 2 == x and H // 2 == y:
    print(ans, 1, sep=" ")
else:
    print(ans, 0, sep=" ")


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
 
int main(){
    char str[1000][50], max[50], strtemp[50], mfstr[50];
    int len = 0, len1 = 0, n=0, cnt = 0, mfreq = 0, i = 0, j = 0;

    while(scanf("%s", str[n]) != EOF){
        len = strlen(str[n]);
        if(len1 < len){
            len1 = len;
            strcpy(max, str[n]);
        }
        n++;
    }
    for(i=0; i < n; i++){
        cnt = 0;
        strcpy(strtemp, str[i]);
        for(j=0; j < n; j++){
            if(strcmp(str[j], strtemp) == 0) cnt++;
        }   
        if(mfreq < cnt){
            mfreq = cnt;
            strcpy(mfstr, strtemp);
        }
    }
     
    printf("%s %s\n", mfstr, max);
     
    return 0;
}

Measured memory_bytes: 576
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,C;
int D[35][35];
int c[505][505];
int memo[3][30];
signed main(){
    scanf("%lld %lld",&N,&C);
    rep(i,C)rep(j,C)scanf("%lld",&D[i][j]);
    rep(k,3)rep(i,C)memo[k][i]=0;
    rep(i,N)rep(j,N){
        scanf("%lld",&c[i][j]);c[i][j]--;
        int k=(i+j)%3;
        rep(color,C){
            memo[k][color]+=D[c[i][j]][color];
        }
    }
    vector<int> anss;
    int ans=LLINF;
    rep(i,C){
        rep(j,C){
            if(i==j)continue;
            rep(k,C){
                if(k==i||k==j)continue;
                anss.pb(memo[0][i]+memo[1][j]+memo[2][k]);
            }
        }
    }
    rep(i,anss.size()){
        ans=min(ans,anss[i]);
    }
    printf("%lld\n",ans);
}

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

const int INF = 1e9+5;

// based on expectation -- prob&stats indirectly

void print(std::vector<std::vector<long long> > A){
	for(int i = 0; i<A.size(); i++){
		for(int j = 0; j<A[i].size(); j++){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
}

void print(std::vector<int> V){
	for(auto v: V)
		cout<<v<<" ";
	cout<<endl;
}

using ll = long long;
const int nax = 305;

double p[nax][nax][nax], ev[nax][nax][nax];
// ev[a][b][c] - the expected no of operations 
// so far to get state abc
// 

int main(){
	//left for next time
	int n;
	scanf("%d", &n);
	std::vector<int> cnt(4);

	for(int i = 0; i<n; i++){
		int x;
		scanf("%d", &x);
		++cnt[x];
	}

	p[cnt[1]][cnt[2]][cnt[3]] = 1;
	for(int c = n; c>=0; --c){
		for(int b = n; b>=0; --b){
			for(int a = n; a>=0; --a){
				if(a == 0 && b == 0 && c == 0){
					continue;
				}
				if(a+b+c > n){
					continue;
				}

				double p_waste = (double)(n-(a+b+c))/n;
				double ev_waste = p_waste/(1-p_waste)+1;
				ev[a][b][c] += ev_waste*p[a][b][c];

				if(a!=0){
					double p_go = (double) a / (a + b + c);
					p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
				}
				if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }

			}
		}
	}
	printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
	
}

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

int main() {
    int n, tr = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                tr++;
                break;
            }
        }
    }

    if(tr == 0){
        puts("APPROVED");
    }else{
        puts("DENIED");
    }


    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	long int n = 0,count = 0,ans = 0;
	long int a[200010];

	scanf("%ld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}

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

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

	return 0;
}

Measured memory_bytes: 1664
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n,m,k = map(int, input().split())
for i in range(n + 1):
  for j in range(m + 1):
    if n * j + m * i - 2 * i * j == k:
      print('Yes')
      exit(0)
print('No')


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

bool judge(int dt, int d){
  if(d<=dt && d%2==dt%2)
    return true;
  else
    return false;
}

bool run(){
  int N;
  cin >> N;

  int t[N],x[N],y[N];
  for(int i=0;i<N;i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  if(!judge(t[0],abs(x[0])+abs(y[0])))
    return false;

  for(int i=0;i<N-1;i++){
    if(!judge(t[i+1]-t[i],abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))
      return false;
  }

  return true;
}

int main(){
  if(run())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  bool poor = (a == b && c != a) ||
              (a == c && b != a) ||
              (b == c && a != b);
  string ans = poor ? "Yes" : "No";
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
HW = input().split()
H, W = int(HW[0]), int(HW[1])
C = input().split()
Ch, Cw = int(C[0]), int(C[1])
D = input().split()
Dh, Dw = int(D[0]), int(D[1])
route = []
for h in range(H):
    route.append(input())

visited = [[False]*W for x in range(H)]
kouho = deque()
kouho.append([Ch-1, Cw-1])
warpkouho = deque()

def check_walk(a, b):
    if 0 <= a <= H-1 and 0 <= b <= W-1: 
        if visited[a][b] == False and route[a][b] == ".":
            kouho.append([a, b])
def check_warp(a, b, cwarp):
    if 0 <= a <= H-1 and 0 <= b <= W-1:
        if visited[a][b] == False and route[a][b] == ".":
            warpkouho.append([a, b, cwarp+1])

def wizard():
    warp = 1
    while True:
        if len(kouho) != 0:
            tmp = kouho.popleft()
        elif len(warpkouho) != 0:
            tmp = warpkouho.popleft()
            warp = tmp[2]
        else:
            break
        h = tmp[0]
        w = tmp[1]
        if visited[h][w] == False:
            visited[h][w] = warp
            check_walk(h-1, w)
            check_walk(h+1, w)
            check_walk(h, w-1)
            check_walk(h, w+1)
            for n in range(5):
                for m in range(5):
                  check_warp(h-2+n, w-2+m, warp)
        if h == Dh-1 and w == Dw-1:
            print(visited[h][w]-1)
            return
    print(-1)
wizard()
        
        


Measured memory_bytes: 235524
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String []Current=new String[]{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        String []Future=new String[]{"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"};
        String st=sc.next();
        for(int i = 0;i < st.length(); i++) {
            for(int j = 0; j < Current.length; j++) {
                if(st.charAt(i) == Future[j].charAt(0)) {
                    System.out.print(Current[j]);
                    break;
                }
            }
        }
        System.out.println();
    }

}

Measured memory_bytes: 18440
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
int num[200005];
int a[200005];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> num[i];
        a[i] = num[i];
    }
    sort(num+1, num+1+n);
    int k1 = num[n/2];
    int k2 = num[n/2+1];
    for(int i = 1; i <= n; i++)
    {
        if(a[i] < k2)cout << k2 << endl;
        else cout << k1 << endl;
    }
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 3712
import sys
import math

a, b, h, m = map(int, input().split())
h = (h+m/60)/12*2*math.pi
m = m/60*2*math.pi
p1 = [a*math.cos(h), a*math.sin(h)]
p2 = [b*math.cos(m), b*math.sin(m)]
print(((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5)

Measured memory_bytes: 62436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = sc.nextInt() - 1;
            }
            int pos = 0;
            int ans = -1;
            for (int i = 0; i < N; i++) {
                if (pos == 1) {
                    ans = i;
                    break;
                }
                pos = a[pos];
            }

            System.out.println(ans);
        }
    }
}


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

int main() {
  int n, k, q;

  cin >> n >> k >> q;

  vector<int> a(n);

  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    a.at(tmp - 1)++;
  }

  for (int i = 0; i < n; i++) {
    if (k + a.at(i) > q)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int paper;
int ans;
int main() {
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++) {
		if(!paper) {
			if(s[i]=='p') ans--;
			paper++;
			continue;
		}
		if(s[i]=='p') paper--;
		if(s[i]=='g') ans++,paper--;
	}
	printf("%d\n",ans);
}///////////////

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

typedef struct {
	int id;
	int time;
} team_t;

int compare(const void* x,const void* y) {
	team_t* a;
	team_t* b;
	a=(team_t*)x;
	b=(team_t*)y;
	if(a->time>b->time)return 1;
	if(a->time<b->time)return -1;
	return 0;
}

int main(void) {
	team_t team[1000000];
	int teamnum;
	int i,j;
	int m,s;
	while(1) {
		scanf("%d",&teamnum);
		if(teamnum==0)break;
		for(i=0;i<teamnum;i++) {
			scanf("%d",&team[i].id);
			team[i].time=0;
			for(j=0;j<4;j++) {
				scanf("%d %d",&m,&s);
				team[i].time+=m*60+s;
			}
		}
		qsort(team,teamnum,sizeof(team_t),compare);
		printf("%d\n",team[0]);
		printf("%d\n",team[1]);
		printf("%d\n",team[teamnum-2]);
	}
	return 0;
}

Measured memory_bytes: 0
N,K,Q=map(int,input().split())
A=[]
point=[0 for _ in range(N)]
for _ in range(Q):
    winner=int(input())
    point[winner-1]+=1
    #A.append(int(input()))

for i in range(N):
    if point[i]-(Q-K)<=0:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll r,D,x;
  cin>>r>>D>>x;
  rep(i,10){
    x=r*x-D;
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    public static void main(String[] args) {
        int N = sc.nextInt();
        for (int i = 1; i <= 9; i++) {
            if (N % i == 0 && N / i <= 9) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[r]%mod)*(fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)*(fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod) % mod)%mod; 
}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}



void solve(){
    ll n;
    cin >> n;

    string ans;
    while(n>=1){
        ll cur=n%26;
        if(cur==0){
            cur=25;
            n--;
        }
        else cur--;
        ans+=('a'+cur);
        n=n/26;
    }

    reverse(all(ans));
    cout << ans << endl;

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

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

int main() {
  int K,X;
  cin >> K >> X ;
  
  int N = 2*K-1;
  vector<int> vec(N,0);
  vec = vector<int>(N, X+(K-1));
  
  for (int i= X-(K-1); i < X+(K-1); i++) {
    i;
  }
  
  sort(vec.begin(), vec.end());
 
    for (int i = X-(K-1); i <= X+(K-1); i++) {
        cout << i << endl;  
 }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin>>c1>>c5>>c10>>c50>>c100>>c500;
    if (c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
        cout<<1<<endl;
    }else if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500<=1000){
    cout<<0<<endl;
    
    
    }
  
}


Measured memory_bytes: 3096
#include<cstdio>
int main(){
	int x,count=0,MSprime[40000];
	bool isMSprime[300000]={};
	for(int i=6;;i+=5){
		if(isMSprime[i]==false){
			for(int k=2;i*k<300000;k++){
				isMSprime[i*k]=true;
			}
			MSprime[count++]=i;
		}
		i+=2;
		if(i>=300000)break;
		if(isMSprime[i]==false){
			for(int k=2;i*k<300000;k++){
				isMSprime[i*k]=true;
			}
			MSprime[count++]=i;
		}
	}
	MSprime[count]=300000;

	while(1){
		scanf("%d",&x);
		if(x==1)break;
		printf("%d:",x);
		for(int i=0;MSprime[i]<=x;i++){
			if(x%MSprime[i]==0){
				printf(" %d",MSprime[i]);
			}
		}
		putchar('\n');

	}

	return 0;
}

Measured memory_bytes: 1476
#include <stdio.h>

int main(void)
{
	char 	s[100001];
	int		blue = 0;
	int		red = 0;
	int		i = 0;

	scanf("%s", s);
	while (s[i])
	{
		if (s[i++] == '0')
			red++;
		else
			blue++;
	}
	printf("%d\n", red < blue ? red * 2 : blue * 2);
	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long  int N,K,ans;
  cin >>N >> K;
  vector<long long int>monsters(N);
  for(int i=0; i<N ;i++){
  cin >> monsters.at(i);
  }
  sort(monsters.begin(), monsters.end());
  if(N<=K){ans=0; cout <<ans <<endl;
  }
  else{
  	for(int i=0;i<N-K;i++){
	ans+= monsters.at(i);
    } cout <<ans <<endl;
  }
 
}


Measured memory_bytes: 1792
import sys
from collections import deque

dic={'o':lambda s:1-(s[1]^s[0]), 'x':lambda s:s[1]^s[0]}
def mknseq(ox,ld):
    for x in ld:
        x.append(dic[ox]((x[-2],x[-1])))
def main():
    N=int(sys.stdin.readline().strip())
    s=list(sys.stdin.readline().strip())
    # ans=[deque([x,y]) for x in range(2) for y in range(2)]
    ans=[[x,y] for x in range(2) for y in range(2)]
    for x in range(N):
        mknseq(s[x],ans)
    # print(ans)
    for x in ans:
        if x[0]==x[-2] and x[1]==x[-1]:
            return print(''.join([['W','S'][i] for i in x])[1:-1])
    print(-1)

if __name__=='__main__':
    main()


Measured memory_bytes: 14292
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
 
int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n){cin >> a.at(i);}
 
  int odd = 0;
  rep(i,n){
    if(a.at(i) % 2 == 1) odd++;
  }
 
  if(odd % 2 == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 640
import math

N, H = map(int, input().split())
a = []
b = []
for i in range(N):
	ip = list(map(int, input().split()))
	a.append(ip[0])
	b.append(ip[1])

a.sort()
a.reverse()
b.sort()
b.reverse()
ptr = 0
cnt = 0

while(ptr < N and a[0] <= b[ptr]):
	H -= b[ptr]
	ptr+=1
	cnt+=1
	if H <= 0: break

if H > 0: cnt += math.ceil(H / a[0])
print(cnt)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s;
    cin >> s;
    ll count = 0;
    ll l = 0, r = s.size() - 1;
    while(r - l > 0) {
        if(s[l] != s[r]) {
            count++;
            if(s[l] == 'x') {
                l++;
            } else if(s[r] == 'x') {
                r--;
            } else {
                cout << -1 << endl;
                return 0;
            }
        } else {
            l++; r--;
        }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

const int MAX = 10000001;
ll cnt[MAX + 1];
bitset < MAX + 1 > marked;

void sieve() {
    fill(cnt, cnt + MAX + 1, 1);
    marked[0] = marked[1] = true;
    for (int i = 2; i <= MAX; i++) if (!marked[i]) {
            cnt[i]++;
            for (int j = i * 2; j <= MAX ; j += i) {
                int n = j, c = 1;
                while (n % i == 0) n /= i, c++;
                cnt[j] *= c;
                marked[j] = true;
            }
        }
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    sieve();
    int n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++)ans += cnt[i] * i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82948
using System;

namespace B___Red_or_Blue
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var s = Console.ReadLine ();
            var rCount = 0;
            foreach (var p in s)
            {
                if (p == 'R')
                    rCount++;
            }
            if (rCount > n - rCount)
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;

struct seg {
  ll x, y1, y2; // [y1, y2) open
  bool end;
  bool operator<(const seg &other) const { return x < other.x; }
};

struct interval {
  ll start, end;
  bool operator<(const interval &other) const { return start < other.start; }
  bool operator==(const interval &other) const {
    return start == other.start and end == other.end;
  }
};

int main() {
  int n;
  cin >> n;
  vector<ll> ys;
  map<interval, int> M;
  vector<seg> segs;

  for (int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;) {
    segs.push_back({x1, y1, y2, 0});
    segs.push_back({x2, y1, y2, 1});
    ys.push_back(y1);
    ys.push_back(y2);
  }

  sort(ys.begin(), ys.end());
  sort(segs.begin(), segs.end());
  ys.resize(distance(ys.begin(), unique(ys.begin(), ys.end())));

  for (int i = 0; i < ys.size() - 1; ++i)
    M[{ys[i], ys[i + 1]}] = 0;

  interval i;
  int ct = 0;
  ll dx = 0, lastx = segs[0].x;
  ll area = 0;
  for (auto &s : segs) {
    dx = s.x - lastx;
    lastx = s.x;
    for (auto &kv : M) {
      tie(i, ct) = kv;
      if (s.x == segs[0].x) {
        if (s.y1 <= i.start and s.y2 >= i.end)
          M[i]++;
      } else {
        if (ct) {
          area += dx * (i.end - i.start);
        }
        if (s.y1 <= i.start and s.y2 >= i.end) {
          if (s.end) {
            M[i]--;
          } else {
            M[i]++;
          }
        }
      }
    }
  }
  cout << area << endl;
}



Measured memory_bytes: 3388