akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct tree{
  int ki;
  struct tree *right,*left,*parent;
};

struct tree *root,*nil;

void insert(int);
void inwalk(struct tree *);
void prwalk(struct tree *);

void insert(int k)
{
  struct tree *a=root,*b=nil,*c;

  c = (struct tree *)malloc(sizeof(struct tree));
  c->ki = k;
  c->left = nil;
  c->right = nil;

  while(a!=nil) {
    b = a;
    if(c->ki < a->ki) {
      a = a->left;
    }else{
      a = a->right;
    }
  }

  c->parent = b;
  if(b == nil) {
    root = c;
  }else{
    if(c->ki < b->ki) {
      b->left = c;
    }else{
      b->right = c;
    }
  }
}

void inwalk(struct tree *x)
{
  if(x == nil)
    return;
  inwalk(x->left);
  printf(" %d",x->ki);
  inwalk(x->right);
}

void prwalk(struct tree *y)
{
  if(y == nil)
    return;
  printf(" %d",y->ki);
  prwalk(y->left);
  prwalk(y->right);
}

int main()
{
  int m,k,i;
  char ins[10];

  scanf("%d",&m);

  for(i=0;i<m;i++) {
    scanf("%s",ins);
    if(ins[0] == 'i') {
      scanf("%d",&k);
      insert(k);
    }else if(ins[0] == 'p') {
      inwalk(root);
      printf("\n");
      prwalk(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25144
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
int main()
{
    while(1)
    {
    double b;
    cin>>b;
    if (b==0)break;
    double nmaxd=2*sqrt(b);
    double nmax=ceil(nmaxd);
    ll fir, num;
    for(ll n=nmax; n>0; n--)
    {
        double f= (2*b/n-n+1)/2;
        if(f-floor(f)==0&&f>0)
        {
            fir=f;
            num=n;
            break;
        }
    }
    cout<<fir<<' '<<num<<endl;
    }
    return 0;
}



Measured memory_bytes: 3152
(defun main ()
  (let* ((n (read))
	 (d (expt (read) 2))
	 (x (make-array (list n 2)))
	 (ans 0))
    (dotimes (i n)
      (setf (aref x i 0) (read))
      (setf (aref x i 1) (read)))
    (loop for i from 0 below n
       if (>= d (+ (expt (aref x i 0) 2) (expt (aref x i 1) 2)))
	 do (incf ans))
    (format t "~a~%" ans)))
(main)


Measured memory_bytes: 80172
#include <iostream>
#include <iomanip>

using namespace std;

int f(long long x){
   int count=0;
   while(1){
      if(x % 2 == 0){
         count+=1;
         x /= 2; 
      }
      else{
          return count;
      }
   }
}

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

    int c=0;
    
    for(i=0;i<N;i++){
        c += f(a[i]);
    }

    cout << c << endl;
        
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    string x[a+5];
    for(int i=1;i<=a;i++){
        cin>>x[i];
    }
    sort(x+1,x+1+a);
    for(int i=1;i<=a;i++){
        cout<<x[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
const int N=300000;
int n,m,x,y,xb,p[N],q[N],dep[N];
bool vis[N];
vector<int> g[N];
bool dfs(int u,int fa)
{
	int s=0; vis[u]=1; dep[u]=dep[fa]+1;
	for (auto v:g[u])
		if (!vis[v])
		{
			s^=dfs(v,u);
		}
		else
			if (dep[v]>dep[u])
			{
				p[++xb]=u; q[xb]=v;
				s^=1;
			}
	if (s)
	{
	  p[++xb]=u; 
	  q[xb]=fa;
	}
	else
	{
	  p[++xb]=fa;
      q[xb]=u;
	}
	return s^1;
}

int main()
{
	cin>>n>>m;
	for (int i=1;i<=m;++i)
	{
		cin>>x>>y;
		g[x].push_back(y); g[y].push_back(x);
	}
	if (!dfs(1,0))
	{
	  cout<<"-1"<<endl;
	  return 0;
	}
	for (int i=1;i<=m;++i) 
	  cout<<p[i]<<" "<<q[i]<<endl;
	return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll d, w;
ll field[11][11];
int main() {
	while (cin >> d >> w && d > 0) {
		REP(i, 0, d) {
			REP(j, 0, w) {
				cin >> field[i][j];
			}
		}
		ll ans = 0;
		REP(y1, 0, d) REP(x1, 0, w) REP(y2, y1 + 2, d) REP(x2, x1 + 2, w) {
			ll mx = inf;
			REP(y, y1, y2 + 1) {
				mx = min(mx, field[y][x1]);
				mx = min(mx, field[y][x2]);
			}
			REP(x, x1, x2 + 1) {
				mx = min(mx, field[y1][x]);
				mx = min(mx, field[y2][x]);
			}
			ll sum = 0;
			bool ok = true;
			REP(y, y1 + 1, y2) {
				REP(x, x1 + 1, x2) {
					if (mx - field[y][x] <= 0) {
						ok = false;
						break;
					}
					sum += mx - field[y][x];
				}
				if (!ok) break;
			}
			if (ok) ans = max(ans, sum);
		}
		p(ans);
	}

	return 0;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(i64, a, b, K);
    rep(i, 0, K) {
        if (i % 2 == 0) {
            if (a & 1) --a;
            b += a / 2;
            a -= a / 2;
        } else {
            if (b & 1) --b;
            a += b / 2;
            b -= b / 2;
        }
    }

    print(a, b);

    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_7_B
class Node():
    def __init__(self, node_id, left, right):
        self.node_id    =   node_id
        self.parent     =   -1
        self.sibling    =   -1
        self.left       =   left
        self.right      =   right
        self.degree     =   0
        self.depth      =   0
        self.height     =   0
        self.typ        =   "leaf"

    def set_attr(self, node_id, parent, sibling, depth):
        if node_id == -1:
            return -1
        self.parent     =   parent
        self.sibling    =   sibling
        self.depth      =   depth
        self.degree     =   (self.left != -1) + (self.right != -1)
        if self.degree:
            self.typ    =   "internal node"
        if self.parent == -1:
            self.typ    =   "root"
        self.height     =   max(tree[self.left].set_attr(self.left, self.node_id, self.right, self.depth + 1), tree[self.right].set_attr(self.right, self.node_id, self.left, self.depth + 1)) + 1
        return self.height

n = int(input())
tree = [None for i in range(n)]
root = set(range(n))

for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = Node(node_id, left, right)
    root -= set([left, right])

root_id = root.pop()
tree[root_id].set_attr(root_id, -1, -1, 0)

for node in tree:
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.node_id, node.parent, node.sibling, node.degree, node.depth, node.height, node.typ))

Measured memory_bytes: 7820
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    string S;
    cin>>S;
    int unhappy=0;
    REP(i,N-1){
        if(S[i]=='R'&S[i+1]=='L')unhappy+=2;
    }
    int a=min(2*K,unhappy);
    unhappy-=a;
    K-=a/2;
    if(S[0]=='L')unhappy++;
    if(S[N-1]=='R')unhappy++;
    if(K>=1&S[0]=='L'&S[N-1]=='R')unhappy--;
    if(a<=2*K&S[0]=='R'&S[N-1]=='L')unhappy++;
    cout<<N-unhappy<<endl;
}


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

int main(){
  ll n,count=0;
  cin >> n;
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(),a.end());
  
  if(n==2){
    cout << a[1]-a[0] << endl;
    cout << a[1] << " " << a[0] << endl;
    return 0;
  }
  
  
  vector<ll>x(n-1),y(n-1);
  queue<ll>plus;
  queue<ll>minus;
  for(int i=0; i<n; i++){
    if(a[i]>=0)plus.push(a[i]);
    else minus.push(a[i]);
  }
    
  if(plus.size()==0){
    for(int i=0; i<n-2; i++){
      ll p = minus.front();
      minus.pop();
      minus.push(p);
    }
    ll minus1=minus.front();
    minus.pop();
    ll minus2=minus.front();
    minus.pop();
    plus.push(minus2-minus1);
    x[count]=minus2;
    y[count]=minus1;
    count++;
  }
  
  if(minus.size()==0){
    ll plus1=plus.front();
    plus.pop();
    ll plus2=plus.front();
    plus.pop();
    minus.push(plus1-plus2);
    x[count]=plus1;
    y[count]=plus2;
    count++;
  }
  
  while(plus.size()>1){
    ll P = plus.front();
    ll M = minus.front();
    plus.pop();
    minus.pop();
    minus.push(M-P);
    x[count]=M;
    y[count]=P;
    count++;
  }
  
  while(minus.size()>0){
    ll P = plus.front();
    ll M = minus.front();
    plus.pop();
    minus.pop();
    plus.push(P-M);
    x[count]=P;
    y[count]=M;
    count++;
  }
  
  ll ans = plus.front();
  cout << ans << endl;
  
  for(int i=0; i<n-1; i++) cout << x[i] << " " <<  y[i] << endl;
  
  return 0;
  
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string s,t;

    cin >> a >> b>> c;// >> d;
    //cin >> s >> t;
    cout << a+b+c-max({a,b,c});

    return 0;
}

Measured memory_bytes: 256
def isKaibun(s):
    flag = True
    n = 0
    if len(s)%2 == 0:
        n = len(s)//2
    else:
        n = (len(s)-1)//2
    for i in range(n):
        if s[i:i+1] != s[len(s)-(i+1):len(s)-i]:
            flag = False
            break
    return flag
        
s = input()
f = s[:(len(s)-1)//2]
b = s[(len(s)-1)//2+1:]

if isKaibun(f) and isKaibun(b) and isKaibun(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	
			if (s[5] == '0'&&s[6]>='5') cout << "TBD";
			else if (s[5] >= '1') cout << "TBD";
			else cout << "Heisei";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    s[i]=(s[i]-'A'+n)%26+'A';
    }
  cout << s << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], b[N], c[N];
int32_t main(){_

   cin>>n;

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

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

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

   int ans = 0;
   for (int i = 1; i+1 <= n; ++i)
   {
      ans += b[a[i]]; 
      if(a[i+1] == a[i]+1){
         ans += c[a[i]];
      }
      tr(i, b[a[i]], c[a[i]], ans);
   }

   ans += b[a[n]];

   cout<<ans;

   return 0;
}

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


int a[200005];


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a+1,a+n+1);
	long long wynik = 0;
	for (int i = 1; i <= n-k; ++i)
		wynik += a[i];

	cout << wynik << "\n";
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    rep(i,s.size()){
        char S=s[i];
        int ss=S-'0';
        ss+=n;
        if(ss>42){
            ss-=26;
        }
        char a='0'+ss;
        cout<<a;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

//int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

//////////////////////////////////////////

int N, S[210], X;
long long dp[210][100010] = {0LL};

long long MOD = 1000000007;


int main(){
    for(int i = 0;i < 210;i++){
        S[i] = 0;
    }
    scanf("%d %d\n",&N,&X);
    for(int i = 0;i < N;i++){
        scanf("%d",&S[i]);
    }
    qsort(S,N,sizeof(int),compare_int);

    for(int i = 0;i <= X;i++){
        dp[N][i] = i;
    }
    for(int i = N-1;i >= 0;i--){
        for(int j = 0;j <= X;j++){
            dp[i][j] += dp[i+1][j%S[i]];
            dp[i][j] += dp[i+1][j]*(N-i-1);
            dp[i][j] %= MOD;
        }
    }

    printf("%lld\n",dp[0][X] % MOD);
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 157824
public class Main {

	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int a = sc.nextInt();
		final int b = sc.nextInt();
		final int c = sc.nextInt();
		int res = 0;
		sc.close();
		
		for (int i = a; i <= b; ++i) {
			if (c % i == 0) {
				res += 1;
			}
		}
		out.println(res);
	}
	
	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

}

Measured memory_bytes: 26360
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,X,Y=pin()
    ans=A*X+B*Y
    if X>Y:
        ans=min(ans,A*(X-Y)+2*C*Y)
        ans=min(ans,C*2*X)
    else:
        ans=min(ans,B*(Y-X)+2*C*X)
        ans=min(ans,C*2*Y)
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 38256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

const double PI = 3.14159265358979323846;

int main() {
  int n;

  cin >> n;

  cout << 2 * PI * n << endl;

  return 0;
}

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

// 0 ~ A の xor を計算
long xorSum( long A )
{
    long ans = 0;
    // i bit目の 1 の個数を調べる
    for( int i = 0; i <= 40; ++i ){
        long period = (1L << (i+1));
        long num1 = (A+1)/period * period/2;  // 0 ~ A なので A+1 になることに注意
        num1 += max( 0L, (A+1)%period - period/2 );
        ans += ( num1%2 == 1 )? (1L << i): 0;
    }
    return ans;
}


int main()
{
    long A, B;
    cin >> A >> B;

    cout << ( xorSum(A-1) ^ xorSum(B) )  << endl;

    return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, int> pii;


int main()
{
    lli n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<lli> a(n);
    for(auto &x: a) cin >> x;
    sort(a.begin(), a.end(), greater<lli>());

    lli lo = p, hi = n-1, mid, ans = p-1;
    while(lo <= hi){
        mid = (hi+lo)/2;
        lli x = a[mid]+m;
        lli ex = (v-1)-(n-mid-1);
        lli pp = p;
        ex -= (pp-1);
        ex *= m;
        bool fl = true;
        for(lli i=pp-1; i<mid; i++){
            if(a[i] > x)fl = false;
            else{
                ex -= (x-a[i]);
            }
        }
        if(fl) fl = ex <= 0LL;
        if(fl){
            ans = mid;
            lo = mid+1;
        }
        else{
            hi = mid-1;
        }
    }
    cout << ans+1 << "\n";

    return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

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

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = a.clone();
		int c[] = new int[n - 1];

		for (int j = 0; j < n; j++) {
			a[j] = sc.nextInt();
		}

		for (int j = 0; j < n; j++) {
			b[j] = sc.nextInt();
		}

		for (int j = 0; j < n - 1; j++) {
			c[j] = sc.nextInt();
		}

		int result = Arrays.stream(b).sum();
		for (int i = 0; i < n - 1; i++) {
			result += (a[i] + 1 == a[i + 1] ? c[a[i] - 1] : 0);
		}

		System.out.println(result);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 26452
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?

		Scanner sc = new Scanner(System.in);
		
		int price = 0;
		int change = 0;
		int result = 0;
		
		while(sc.hasNextInt()) {
			price = sc.nextInt();
			if(price == 0) break;
			
			change = 1000 - price;
			int c500 = change / 500;
			change = change - 500 * c500;
			int c100 = change / 100;
			change = change - 100 * c100;
			int c50 = change / 50;
			change = change - 50 * c50;
			int c10 = change / 10;
			change = change - 10 * c10;
			int c5 = change / 5;
			change = change - 5 * c5;
			int c1 = change;
			
			result = c500 + c100 + c50 + c10 + c5 + c1;

			
			System.out.println(result);
		}
		
	}

}

Measured memory_bytes: 15332
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    int odd = 0;
    for(int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if(a % 2 == 1) odd++;
    }
    long ans = (long)Math.pow(2, N - 1);
    if(odd == 0) {
      ans = (long)Math.pow(2, N);
      if(P == 1) ans = (long)Math.pow(2, N) - ans;
    } else { 
      if(P == 1) ans = (long)Math.pow(2, N) - ans;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
ll n,a,b,s[N];
ll A[N],B[N];
ll La[N],Lb[N];

ll BS(ll key){
    ll l,r,m;
    for(l=0,r=n+1;l<r-1;){
	m=(l+r)/2;
	if(s[m]<=key)l=m;
	else r=m;
    }
    return l;
}

class CS{
private:
    ll cs[N];
public:
    void init(){
	cs[0]=0;
    }
    void set(ll i,ll x){
	cs[i+1]=(cs[i]+x)%mod;
    }
    ll sum(ll l,ll r){
	if(not(l<=r))return 0;
	ll res=(cs[r+1]-cs[l])%mod;
	if(res<0)res+=mod;
	return res;
    }
};

int main(){
    cin>>n>>a>>b; s[0]=-4e18,s[n+1]=4e18;
    lol(i,n)cin>>s[i+1];
    
    La[0]=Lb[0]=0;
    for(int i=1;i<=n+1;i++){
	if(s[i]-s[i-1]<b)La[i]=i-1;
	else La[i]=La[i-1];
	if(s[i]-s[i-1]<a)Lb[i]=i-1;
	else Lb[i]=Lb[i-1];
    }
    
    CS ca,cb;ca.init();cb.init();
    A[0]=B[0]=1;
    ca.set(0,1); cb.set(0,1);
    
    for(int i=1;i<=n;i++){
	ll Ra=BS(s[i+1]-a);if(Ra>i-1)Ra=i-1;
	ll Rb=BS(s[i+1]-b);if(Rb>i-1)Rb=i-1;
	//cout<<"#"<<Lb[i]<<" "<<Rb<<endl;
	//cout<<"%"<<La[i]<<" "<<Ra<<endl;
	
	A[i]=cb.sum(La[i],Ra);
	B[i]=ca.sum(Lb[i],Rb);
	
	ca.set(i,A[i]);
	cb.set(i,B[i]);
    }
    
    //lol(i,n+1)cout<<A[i]<<" ";cout<<endl;
    //lol(i,n+1)cout<<B[i]<<" ";cout<<endl;
    cout<<(A[n]+B[n])%mod<<endl;
    
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////




int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n][n];
    rep(i,0,n-1)dp[i][i]=a[i];
    rep(j,2,n){
        rep(i,0,n-j){
            dp[i][i+j-1]=max(a[i+j-1]-dp[i][i+j-2],a[i]-dp[i+1][i+j-1]);
            /*if((n-j)%2==0){
                dp[i][i+j-1]=max(a[i+j-1]-dp[i][i+j-2],a[i]-dp[i+1][i+j-1]);
            }else{
                dp[i][i+j-1]=min(a[i+j-1]-dp[i][i+j-2],a[i]-dp[i+1][i+j-1]);
            }*/
        }
    }
    cout<<dp[0][n-1]<<endl;
    
    return 0;
}


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

using namespace std;

#define Rep(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 ll long long

int main()
{
	int k, ans = 0;
	cin  >> k;
	for (int i = 1; i <= k; i = i + 2)
		ans += k / 2;

	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main() {
    val s = readInt()

    val ans = MutableList(2001) { 0 }

    val mod = 1000000007
    ans[0] = 1
    for (i in 1..s) {
        for (j in 0..i-3) ans[i] = (ans[i] + ans[j]) % mod
    }
    println(ans[s])
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 52216
function Main(input){
	var input= input.split(' '),
		H = input[0],
		W = input[1];
	if(H == 1 || W == 1){
		console.log(1);
	}else{
		console.log(H*W%2 == 0 ? H*W/2 : (H*W+1)/2);
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 18120
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b and b == c){
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
BLACK = "#"
WHITE = "."

H, W = gets.split.map{|i|i.to_i}
grid = Array.new(H){gets.chomp}
a = Array.new(H){Array.new(W){1000}}
a[0][0] = (grid[0][0] == BLACK ? 1 : 0)
H.times{|y|
    W.times{|x|
        m = [a[y][x]]
        if x > 0
            m << a[y][x - 1]
            if grid[y][x] != grid[y][x - 1]
                m[-1] += 1
            end
        end
        if y > 0
            m << a[y - 1][x]
            if grid[y][x] != grid[y - 1][x]
                m[-1] += 1
            end
        end
        a[y][x] = m.min
    }
}
puts (a[H - 1][W - 1] + 1) / 2


Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
typedef pair<double, int> P;
const LL MOD = 1000000007LL;
int a[5000];
int dp[5000][5000];
bool check(int N,int K,int x) {
	vector<int> v;
	rep(i, N) {
		if (i != x) v.push_back(a[i]);
	}
	fill((int*)dp, (int*)(dp + 5000), 0);
	dp[0][0] = 1;
	if (v[0] < K) dp[0][v[0]] = 1;
	REP(i, 1, N - 1) {
		rep(j, K) {
			dp[i][j] = dp[i - 1][j];
			if (v[i] <= j) dp[i][j] |= dp[i - 1][j - v[i]];
		}
	}
	bool OK = 0;
	REP(i, max(0,K - a[x]), K) {
		OK |= dp[N - 2][i];
	}
	return OK;
}
int main() {
	int N, K;
	cin >> N >> K;
	rep(i, N) cin >> a[i];
	if (N == 1) {
		if (a[0] < K) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	sort(a, a + N);
	int l = -1, r = N; //(l,r]
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(N,K,m)) r = m;
		else l = m;
	}
	if (check(N, K, r)) {
		cout << r << endl;
	}
	else {
		cout << N << endl;
	}
}

Measured memory_bytes: 97920
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
#define LINF 1e9+10
typedef long long ll;

using namespace std;

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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { //値をt乗する
    if (!t) return 1; // t == 0
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this; //*thisは元の値(t乗する対象)
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = (ans*x) % mod;
        x = (x*x) % mod;
        n = n >> 1;
    }
    return ans;
}

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n; cin >> n;
      vector<ll> a(n);
      map<ll,int> tmp;
      rep(i,n){
            cin >> a[i];
            auto mp = prime_factor(a[i]);
            for(auto& p:mp){
                  if(tmp[p.first]<mp[p.first]) tmp[p.first] = mp[p.first];
            }
      }
      sort(all(a));

      mint lcm = 1;
      for(auto& p:tmp){
            lcm *= mint(mpow(p.first,p.second));
      }
      mint ans = 0;
      rep(i,n) ans += lcm/a[i];

      cout << ans.x << endl;

      return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    string x;
    cin >> x;
    int num = 0;
    for (char c: x) {
        if (c=='1') num++;
    }
    int rem[3];
    vector<vector<ll>> dat(3, vector<ll>(n));
    rep(i, 3) {
        ll z = num-1+i;
        if (z<=0) continue;
        ll res = 0;
        ll amari = 1;
        rrep(j, n) {
            dat[i][j] = amari;
            if (x[j]=='1') {
                res += amari;
                res %= z;
            }
            amari *= 2;
            amari %= z;
        }
        rem[i] = res;
        //debug(rem[i]);
    }
    
    rep(i, n) {
        if (num==1 && x[i]=='1') {
            cout << 0 << endl;
            continue;
        }
        int ans = 0;
        ll now = 0;
        if (x[i]=='0') {
            now = rem[2] + dat[2][i];
            now %= (num+1);
        }
        else {
            now = rem[0] - dat[0][i];
            now += (num-1);
            now %= (num-1);
        }
        //debug(now);
        //debug(num);
        ans++;
        while (now>0) {
            ll p = __builtin_popcount(now);
            now %= p;
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

int main(){
  while(true){
    int a,b;
    cin >> a >> b;

    if(cin.eof())
    break;

    int g=gcd(a,b);
    cout << g << " " << a/g*b << endl;
  }

  return 0;
}



Measured memory_bytes: 2988
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define vel vector<int>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
vvel sol(vvel x,int h,int w) {
	sor(x);
	vvel y(w, vel(h));
	rep(i, w) {
		rep(j, h) {
			y[i][j] = x[j][i];
		}
	}
	sor(y);
	return y;
}
signed main(){
	int w, h; cin >> w >> h;
	vvel x(h, vel(w));
	rep(i, h) {
		rep(j, w) { cin >> x[i][j]; }
	}
	vvel a = sol(x, h, w);
	vvel y(h, vel(w));
	vvel z(h, vel(w));
	rep(i, h) {
		rep(j, w) {
			y[i][j] = (i + j) % 2;
			z[i][j] = 1 - y[i][j];
		}
	}
	y = sol(y, h, w);
	z = sol(z, h, w);
	if (a == y || a == z) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 27260
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int H, W;
	cin >> H >> W;
	int h, w;
	cin >> h >> w;
	int ans = (H - h) * (W - w);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	PRI(min(a + b, min(b + c, c + a)));
	return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstring>

using namespace std;

#define MAX 20

int main(){
  int n, m, a, b;
  bool G[MAX][MAX];

  memset(G, false, sizeof(G));

  cin >> m >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> a >> b;
    G[b-1][a-1] = true;
  }

  int rem = m;
  bool used[MAX];
  memset(used, false, sizeof(used));

  while(true){
    if(rem == 0) break;
    for(int i = 0 ; i < m ; i++){
      if(used[i]) continue;
      bool ok = true;
      for(int j = 0 ; j < m ; j++){
	if(i != j && G[i][j]){
	  ok = false;
	  break;
	}
      }
      if(ok){
	cout << i+1 << endl;
	used[i] = true;
	rem--;
	for(int j = 0 ; j < m ; j++){
	  G[j][i] = false;
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int n, m,p[10], ans = 0,a[29], b[29];
const int nmax = 8;
bool graph[nmax][nmax];
/**
 * pos個は決定済み
 * mask 残に置く数の集合を表すビット配列
 */
void dfs(int pos, int mask) {
//	cout << "pos=" << pos << ",mask=" << mask << endl;
	if (pos == n) { // posが最後までいった
//		cout << p[0] << p[1] << p[2] << endl;
		return;
	}
	REP(i, n) {
		if (mask  & (1 << i)) { // 残の中にiが残っている場合
//			cout << "mask=" << mask << ",1<<" << i << "="  << (1 << i) << "=true" << endl;
			p[pos] = i; // 配列のPOS位置を0～nまでループ
			if (p[0] != 0)continue;
			if (pos > 0 && graph[p[pos - 1]][p[pos]] == false) {
				//				cout << "pos=" << pos << "," << p[0] << p[1] << p[2] << ",graph[" << p[pos - 1] << "][" << p[pos] << "]=false" << endl;
				continue;
			}
			dfs(pos + 1, (mask ^ (1 << i))); // 配列のPOS位置を進める,排他的論理和でフラグを下ろす
		}
		else {
//			cout << "mask=" << mask << ",1<<" << i << "=" << (1 << i) << "=false" << endl;
		}
	}
}
/*int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	scanf("%d %d", &n ,&m);

	REP(i, m) {
		scanf("%d %d",&a[i], &b[i]);
		p[i] = i;
		graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
	}

	dfs(0, (1 << n) - 1);
	cout << ans << endl;
	return 0;
}*/
/**
 * v 現在の頂点
 */
int dfs(int v, int n, bool visited[]) {
	bool all_visited = true; // 全頂点を訪問済
	REP(i, n) {
		if(!visited[i])all_visited = false;
	}
	if (all_visited)return 1; //答を1増やす
	int ret = 0;
	REP(i, n) { //頂点i:頂点vに隣接、且つ、未訪問
		if (!graph[v][i])continue;
		if(visited[i])continue;

		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}
int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; ++i) {
		scanf("%d %d", &a[i], &b[i]);
		graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
	}
	
	bool visited[nmax];
	for (int i = 0; i < n; ++i) {
		visited[i] = false;
	}
	
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int n,w,W;
LL dp[100001],v;
int main(){
	cin>>n>>W;
	for(int i=0;i<n;i++){ 
		scanf("%d%lld",&w,&v);
		for(int calc=W-w;calc>=0;calc--)
			dp[calc+w]=max(dp[calc+w],dp[calc]+v);
	}
	cout<<dp[W];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
    int i, N;
    ull ans=0, tmp;
    cin >> N;

    for (i=0; i<N; i++) {
        cin >> tmp; 
        ans += tmp-1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin
def f(n,m):
    n,m=str(n),str(m)
    s1=["0"]*(6-len(n))
    s1.append(n)
    s2=["0"]*(6-len(m))
    s2.append(m)
    return "".join(s1)+"".join(s2)

def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    li=[0]*M
    for i in range(M):
        a=list(map(int,readline().split()))
        a.append(i)
        li[i]=a
    
    li.sort(key=lambda x:x[1])
    count=[1]*(N+1)
    for i in range(M):
        city_number=li[i][0]
        x=count[city_number]
        count[city_number]+=1
        li[i].append(f(city_number,x))

    li.sort(key=lambda x:x[2])
    for i in range(M):
        print(li[i][3])
        
if __name__=="__main__":
    main()

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

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

#define ps(ss, i, j, ii, jj) ss[i][j] - ss[i][jj] - ss[ii][j] + ss[ii][jj]

int main() {

    int N, K;
    cin >> N >> K;
    int K2 = 2 * K;
    vector<vector<int>> s(K2, vector<int>(K2, 0));
    vector<vector<int>> s1(K2, vector<int>(K2, 0));
    int a, b;
    char c;
    int cb = 0, cw = 0;
    REP(i, N){
        cin >> a >> b >> c;
        if (c == 'B') {s[a%K2][b%K2]++; cb++;}
        else {s1[a%K2][b%K2]++; cw++;}
    }
    vector<vector<int>> sb(K2+1, vector<int>(K2+1, 0));
    vector<vector<int>> sw(K2+1, vector<int>(K2+1, 0));
    REP(i, K2) REP(j, K2){
        sb[i+1][j+1] = s[i][j] + sb[i][j+1] + sb[i+1][j] - sb[i][j];
        sw[i+1][j+1] = s1[i][j] + sw[i][j+1] + sw[i+1][j] - sw[i][j];
    }
    int tmp, tmp1, ans = 0;
    rep(i, K + 1,  K2 + 1) rep(j, K + 1, K2 + 1){
        tmp = ps(sb, K2, j, i, j - K) + ps(sb, i, K2, i - K, j) + ps(sb, i, j - K, i - K, 0) + ps(sb, i - K, j, 0, j - K);
        tmp1 = ps(sw, K2, j, i, j - K) + ps(sw, i, K2, i - K, j) + ps(sw, i, j - K, i - K, 0) + ps(sw, i - K, j, 0, j - K);
        ans = max(ans, tmp + cw - tmp1);
        ans = max(ans, tmp1 + cb - tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 63104
#include <stdio.h>

int main(void){
  int n, result = 0;
  scanf("%d\n", &n );

  for(int i = 0; i < n; i ++ ){
    int e, is_prime = 1;
    scanf("%d\n", &e );

    for( int j = 2; j <= sqrt( e ) ; j ++ ){
      if( e % j == 0 )is_prime = 0;
    }
    //printf("[%d] is [%d]\n", e, is_prime );
    result += is_prime;
  }
  printf("%d\n", result );
  return 0;
}



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

using namespace std;

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

    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> vt;
    while (N != 0) {
        int r = N % 2;
        if (r < 0) r *= -1;
        vt.emplace_back(r);
        N = (N - r) / (-2);
    }

    reverse(vt.begin(), vt.end());
    for (int i : vt) {
        cout << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    string S;
    cin>>S;
    rep(i,S.size()) cout<<"x";
    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(input) {
    input = input.split('\n')
    const troops = input[1].split('')
    const n = troops.length
    let min, cnt = 0

    let countsE = [0]
    let countsW = [0]
    for (let i = 1; i <= n; i++) {
        countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1];
        countsE[i] = (troops[i - 1] == 'E') ? countsE[i - 1] + 1 : countsE[i - 1];
    }

    for (let i = 0; i < n; i++) {

        cnt = countsW[i] + countsE[n] - countsE[i + 1]
        min = (min < cnt) ? min : cnt
    }

    console.log(min)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32496
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int res = min(n*a, b);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,x;
    cin >> k >> x;
    for (int i=x-k+1;i<=x+k-1;i++) cout << i << " ";
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256