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

int a[21], n;

int search(int m, int i) {
  if (m == 0) return 1;
  if (i >= n)  return 0;
  int cont = search(m, i + 1) || search(m - a[i], i + 1);
  return cont;
}

int main() {
  int q, i, num;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &num);
    if (search(num, 0)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 1968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n;cin>>n;
    ll k=((1<<31)-1);
    vi a(n),b(n*2),c(n*2),ok(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)b[i+n]=b[i];
    rep(i,n*2)c[i]=k^b[i];
    for(ll i=30;i>=0;i--){
        ll x=0,y=0,z=0;
        rep(j,n){
            x+=a[j]>>i&1;
            y+=b[j]>>i&1;
            z+=c[j]>>i&1;
            if(j!=n-1){
                x*=2;
                y*=2;
                z*=2;
            }
            x%=mod;
            y%=mod;
            z%=mod;
        }
        rep(j,n){
            if(x==y||x==z)ok[j]++;
            y-=(b[j]>>i&1)*modpow(2,n-1);
            y=(y+mod)%mod;
            y*=2;
            y+=b[j+n]>>i&1;
            y%=mod;
            z-=(c[j]>>i&1)*modpow(2,n-1);
            z=(z+mod)%mod;
            z*=2;
            z+=c[j+n]>>i&1;
            z%=mod;
        }
    }
    vector<P> ans;
    rep(i,n){
        if(ok[i]==31){
            ans.eb((n-i)%n,a[0]^b[i]);
        }
    }
    sort(all(ans));
    for(P t:ans)cout<<t.fi<<' '<<t.se<<endl;
}

Measured memory_bytes: 16492
fn a() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();

    let line: Vec<char> = input.chars().collect();
    if line[2] == line[3] && line[4] == line[5] {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn main() {
    a();
}


Measured memory_bytes: 4352
/*
				C++
				encoding: UTF-8
				Modified: <27/Jul/2019 05:37:00 PM>

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettyprint.hpp>
#endif

using namespace std;

// clang-format off

#define         ll                     long long
#define         mod                    1000000007
#define         ve                     vector
#define         pb                     push_back
#define         endl                   "\n";
#define         ff                     first
#define         ss                     second
#define         pii                    pair<int, int>
#define         len(v)                 int(v.size())
#define         all(v)                 v.begin(), v.end()
#define         reset(a, b)            memset(a, b, sizeof(a));
#define         fr(i, s, n)            for (ll i = s ; i < n ; ++i)
#define         dfr(i, s, n)           for (ll i = s ; i > n ; --i)

void print (string sep = "\n") {
    cout << sep;
}

template < typename T, typename... TAIL > void print (const T& t, TAIL... tail) {
    cout << t << " ";
    print (tail...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int cnt = 0;
	fr (i, 1, n + 1) {
		int x;
		cin >> x;
		if (x != i) cnt++;
	}
	if (cnt == 0 or cnt == 2)
		print ("YES");
	else
		print ("NO");
	return 0;
}


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

#define sp ' '
using namespace std;

int H, W, x, y;
bool b;
string A[8];

int main(){
	cin >> H >> W;
	for (int i = 0; i != H; ++i)
		cin >> A[i];
	b = true;
	if (A[0][0] == '.') {
		cout << "Impossible" << endl;
		return 0;
	}
	A[0][0] = '.';
	while (b) {
		b = false;
		if (x != H-1) {
			if (A[x + 1][y] == '#') {
				++x;
				A[x][y] = '.';
				b = true;
				continue;
			}
			if (y != W-1) {
				if (A[x][y + 1] == '#') {
					++y;
					A[x][y] = '.';
					b = true;
					continue;
				}
			}
		}
		if (y != W-1) {
			if (A[x][y + 1] == '#') {
				++y;
				A[x][y] = '.';
				b = true;
				continue;
			}
		}
	}
	b = true;
	if (x != H-1 || y != W-1)
		b = false;
	for (int i = 0; i != H; ++i) {
		for (int j = 0; j != W; ++j) {
			if (A[i][j] == '#') {
				b = false;
			}
		}
	}
	if (b) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum)%MOD;
        sum = (sum * sum) % MOD;
        b >>= 1;
    }
    return res;
}


int main(){
    int H, W;
    cin >> H >> W;
    string squ[H];
    REP(i, H)cin>>squ[i];
    vector<vector<char> > ansr(H, vector<char>(W, '.')), ansb(H, vector<char>(W, '.'));
    REP(i, W){
        ansr[0][i]='#';
        ansb[H-1][i]='#';
        REP(j, H){
            if(squ[j][i]=='.')continue;
            ansr[j][i]='#';
            ansb[j][i]='#';
        }
    }
    for(int i = 0;i<W;i+=2){
        REP(j, H-1){
            ansr[j][i]='#';
        }
    }
    for(int i = 1;i<W;i+=2){
        for(int j = H-1;j>0;--j){
            ansb[j][i]='#';
        }
    }
    REP(i, H){
        REP(j, W){
            cout << ansr[i][j];
        }
        cout << endl;
    }
    cout << endl;
    REP(i, H){
        REP(j, W){
            cout << ansb[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

int N, P, A[105];
long long dp[55][2];

int main() {
	scanf("%d%d", &N, &P);
	for (int i = 0; i<N;i++) scanf("%d", &A[i]);
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] += dp[i - 1][j];
			dp[i][j] += dp[i - 1][j ^ (A[i] % 2)];
		}
	}
	printf("%lld\n", dp[N][P]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
    cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
int main()
{
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(B<=C || D<=A)printf("0\n");
	else printf("%d\n",std::min(B,D)-std::max(A,C));
	return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main(){
  double a,b,c,d,e,f,x,y;
  
  while(cin>>a>>b>>c>>d>>e>>f){
    if(b==0){
      x=c/a;
      y=(f-d*x)/e;
    }
    else{
      x=(c*e-b*f)/(a*e-b*d);
      y=(c-a*x)/b;
    }
    
    x=round(x*1000)/1000;
    y=round(y*1000)/1000;
    
    if(x==-0.000) x=0.000;
    if(y==-0.000) y=0.000;
    
    cout<< fixed << setprecision(3) << x <<" "<< y << endl;
  }
    
  return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
 
int main() {
  int d,n;
  cin >> d >> n;
  int s = pow(100,d);
  if(n <= 99){
    cout << s * n << endl;
  }
  else{
    cout << s * 101 << endl;
  } 
  return 0;
}

Measured memory_bytes: 256
while True:
  n,x = map(int,input().split())
  if n == 0 and x == 0:
    exit()
  else:
    cnt = 0
    for i in range(1,n-1):
      for j in range(i+1,n):
        for k in range(j+1,n+1):
          if i+j+k == x: cnt += 1
    print(cnt)



Measured memory_bytes: 5596
#include<stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == 5 && b == 5 && c == 7 ){
		printf("YES\n");
		}
	else if(a == 5 && b == 7 && c == 5 ){
			printf("YES\n");
			}
	else if(a == 7 && b == 5 && c == 5 ){
				printf("YES\n");
				}
	else {
		printf("NO\n");
		}
	return 0;
}

Measured memory_bytes: 128
/*
* @author:  codancer
* @createTime:  2020-09-15, 23:05:51
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=-1e18;
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

bool test(vector<int> &a, int x, int k){
	int t = 0;
	int n = a.size();
	vector<int> b(n, 0);
	for(int i=0; i < n; i++){
		b[i] = a[i] - (a[i]/x) * x;
		t += b[i];
	}
	sort(b.begin(), b.end(), greater<int>());
	int s = 0;
	for(int i=0; i < n; i++){
		t -= x;
		b[i] -= x;
		s += -b[i];
		if(t==0)break;
	}
	return s <= k;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a(n, 0);
	for(int i=0; i<n; i++)cin >> a[i];
	int s = 0;
	for(int i=0; i < n; i++)s += a[i];
	int ret = 1;
	for(int i=1; i * i <= s; i++){
		if(s % i)continue;
		if(test(a, i, k))updmax(ret, i);
		if(test(a, s/i, k))updmax(ret, s/i);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=0;i<a;i++){
    			for(int x=0;x<b;x++){
    				sb.append("#");
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

}

Measured memory_bytes: 27908
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> tri;
    vector<int> odd;
    constexpr int MAX = 1000000;
    for (int i = 1;; i++) {
        const int num = i * (i + 1) * (i + 2) / 6;
        if (num >= MAX) {
            break;
        }
        tri.push_back(num);
        if (num % 2 == 1) {
            odd.push_back(num);
        }
    }
    constexpr int INF = 1000000000;
    vector<int> num(MAX, INF);
    vector<int> oddnum(MAX, INF);
    num[0] = 0;
    oddnum[0] = 0;
    for (int i = 0; i < MAX; i++) {
        if (num[i] == INF) {
            continue;
        }
        for (const int p : tri) {
            if (i + p < MAX) {
                num[i + p] = min(num[i + p], num[i] + 1);
            }
        }
    }
    for (int i = 0; i < MAX; i++) {
        if (oddnum[i] == INF) {
            continue;
        }
        for (const int p : odd) {
            if (i + p < MAX) {
                oddnum[i + p] = min(oddnum[i + p], oddnum[i] + 1);
            }
        }
    }


    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        cout << num[n] << " " << oddnum[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 10524
import java.util.Scanner;
	public class Main{
      public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
        int a = sc.nextInt();
		if(h%a==0){
          System.out.println(h/a);
        }else {
          System.out.println(h/a+1);
        }
	}
}

Measured memory_bytes: 23764
#include<stdio.h>

#define MAX 300

int main() {
    //変数の宣言
    int h[MAX], w[MAX];
    int count = 0; //箱用
    int i, a, b; //処理用
    int flag; //偶数の時、奇数の時
    
    //入力
    while (1) {
        scanf("%d %d", &h[count], &w[count]);
        
        if (h[count] == 0 && w[count] == 0) {
            break;
        }
        
        count ++; //カウンター回す
    }
    
    for (i=0; i<count; i++) { //箱を回す
        for (a=0; a<h[i]; a++) {
            if (a%2 == 0) {
                flag = 1;
            }else{
                flag = 0;
            }
            for (b=0; b<w[i]; b++) {
                if (flag == 1) {
                    printf("#");
                    flag = 0;
                }else if (flag == 0) {
                    printf(".");
                    flag = 1;
                }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    
    
    
    //wが偶数の時に#が先頭
    
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

int to[N << 1],nex[N << 1],beg[N],deg[N],Ans[N],rest[N],A[N];
int e,ans = 0;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

inline void dfs(int x,int fa) {
	int cur = 0;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		dfs(to[i],x),cur++;
	}
	ans -= cur / 2,cur &= 1;
	if(!cur && x > 1) ans++;
}

inline int check(int Ban,int top,int val) {
	int pos = top,tot = 0;
	For(i,1,top) {
		if(i == Ban) continue;
		while(pos && (A[i] + A[pos] > val || pos == Ban)) pos--;
		if(i >= pos) break;
		tot++,pos--;
	}
	return tot;
}

inline void Dp(int x,int fa,int val) {
	int total = 0,top = 0;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		Dp(to[i],x,val);
	}
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		total += Ans[to[i]];
		A[++top] = rest[to[i]];
	}
	sort(A + 1,A + top + 1);
	while(top && A[top] >= val) top--;A[top + 1] = 0;
	int pos = top,tot = 0;
	For(i,1,top) {
		while(A[i] + A[pos] > val) pos--;
		if(i >= pos) break;
		tot++,pos--;
	}
	int l = 1,r = top + 1;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid,top,val) < tot) l = mid + 1;
		else r = mid;
	}
	rest[x] = A[l] + 1;Ans[x] = total - tot;
	if(l == top + 1 && x > 1) Ans[x]++;
}

int main() {

	int n = read();
	For(i,1,n - 1) {
		int x = read(),y = read();
		add(x,y),add(y,x);
	}
	dfs(1,0);
	int l = 1,r = n;
	while(l < r) {
		int mid = (l + r) >> 1;
		Dp(1,0,mid);
		if(Ans[1] > ans) l = mid + 1;
		else r = mid;
	}

	printf("%d %d\n",ans,l);

	return 0;
}

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

int main() {
  std::string a, b;
  std::cin >> a >> b;
  int64_t t = std::atoi((a + b).c_str());

  for (int64_t i = 1; i <= 10000; i++) {
    if (i * i == t) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  std::cout << "No" << std::endl;
  return 0;
}


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

int main(void){
    
   int N;//1~100
   cin >> N;
   
   for(int i=0;i<=25;i++){
       for(int j=0;j<=15;j++){
           if(i*4 + j*7 == N){
               cout << "Yes" <<endl;
               return 0;
           }
       }
   }
   
   cout << "No" << endl;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;

    map<string,int> ans;
    ans.insert(pair<string,int>("SUN", 7));
    ans.insert(pair<string,int>("MON", 6));
    ans.insert(pair<string,int>("TUE", 5));
    ans.insert(pair<string,int>("WED", 4));
    ans.insert(pair<string,int>("THU", 3));
    ans.insert(pair<string,int>("FRI", 2));
    ans.insert(pair<string,int>("SAT", 1));

    cout << ans.at(S) << endl;

    return 0;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest131.Questions;
using AtCoderBeginnerContest131.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest131.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nl = inputStream.ReadIntArray();
            var n = nl[0];
            var l = nl[1];

            var originalTaste = Enumerable.Range(0, n).Sum(i => l + i);

            var nearest = 1 << 30;
            for (int i = 0; i < n; i++)
            {
                var taste = Enumerable.Range(0, n).Where(m => m != i).Sum(m => l + m);
                if (Math.Abs(originalTaste - taste) < Math.Abs(originalTaste - nearest))
                {
                    nearest = taste;
                }
            }

            yield return nearest;
        }
    }
}


namespace AtCoderBeginnerContest131
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest131.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest131.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
import copy

H,W,K=list(map(int,input().split()))

C=list()
Cd=list()
for h in range(H):
    S = input()
    C.append(S)

    r=list()
    for w in range(W):
        if S[w] == '.':
            d=0
        else:
            d=1
        r.append(d)
    Cd.append(list(r))

ans=0

def check_bits(i,width):
    c = list()
    for w in range(width):
        c.append(1 & (i>>w))
    return c

ans=0
for h in range(2**H):
    check = copy.deepcopy(Cd)

    hsel = check_bits(h,H)
    # print(h, hsel)

    for i in range(H):
        if hsel[i]==1:
            check[i]=[0] * W

    # print("h=",h,"check=",check)
    for w in range(2**W):
        check_w = copy.deepcopy(check)

        wsel = check_bits(w,W)
        # print(w, wsel)

        for j in range(W):
            if wsel[j] == 1:
                for i in range(H):
                    check_w[i][j] = 0
        
        calc = 0
        for i in range(H):
            calc += sum(check_w[i])
        # print(hsel, wsel, calc)
        if calc == K:
            ans += 1
print(ans)




Measured memory_bytes: 9324
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    if (N / 100 == N % 10) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
   double N,x,ans=0;
   string u;
   cin>>N;
   for(int i=0;i<N;i++){
       cin>>x>>u;
       if(u=="BTC"){
           x*=380000;
       }
       ans+=x;
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# encoding:utf-8

import copy
import numpy as np
import random

n = int(input())

l = [int(i) for i in input().split()]

sum_all = 0
for i in range(n):
    sum_all += l[i]

answer = "Yes"
for i in range(n):
    if l[i] < sum_all-l[i]:
        pass
    else:
        answer = "No"

print(answer)


Measured memory_bytes: 23836
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int a,b,c,d,f=1;
cin>>a>>b>>c>>d;
while(1)
{
	if(f)
	{
		f=0;
		c-=b;
		if(c<=0) {
		cout<<"Yes";break;}
	}
	else
	{
		f=1;
		a-=d;
		if(a<=0)
		{
			cout<<"No";
			break;
		}
	}
}


return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,k,l[100];
int main(){
	scanf("%d%d",&n,&k);
	fo(i,1,n) scanf("%d",&l[i]);
	sort(l+1,l+n+1);
	int s=0;
	fo(i,n-k+1,n) s+=l[i];
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;
typedef pair<int, int> P;

#define MAX_W 20
#define MAX_H 20
#define MAX_M 10

int W, H;
int M;

vector<int> ans_list;

char maze[MAX_H][MAX_W];
int sx, sy;
int gx[MAX_M], gy[MAX_M];

int memo[1 << 11][15];

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

int dp[15][MAX_H][MAX_W];

void maze_solve(){

  for(int i = 0; i < 11; i++){
    for(int j = 0; j < H; j++){
      for(int k = 0; k < W; k++){
	dp[i][j][k] = INF;
      }
    }
  }

  for(int num = 0; num < M+1; num++){

    queue<P> que;
    que.push(P(gx[num], gy[num]));
    dp[num][gy[num]][gx[num]] = 0;
    while(que.size()){
      P p = que.front();
      que.pop();
      int x = p.first;
      int y = p.second;
      for(int i = 0; i < 4; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(nx >= 0 && nx < W && ny >= 0 && ny < H && dp[num][ny][nx] == INF && maze[ny][nx] != 'x'){
	  dp[num][ny][nx] = dp[num][y][x] + 1;
	  que.push(P(nx, ny));
	}
      }
    }
  }

}

int solve(int S, int v){
  
  if(memo[S][v] >= 0)
    return memo[S][v];

  else if(S == (1 << M) - 1){
    return memo[S][v] = 0;
  }

  int ret = INF;

  for(int i = 0; i < M; i++){
    if(!(S >> i & 1)){
      ret = min(ret, dp[v][gy[i]][gx[i]] + solve(S | (1 << i), i));
    }
  }
  
  return memo[S][v] = ret;
  
}

int main(){

  while(true){

    M = 0;
    memset(memo, -1, sizeof(memo));

    cin >> W >> H;
    if(W == 0 && H == 0)
      break;

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> maze[i][j];
	if(maze[i][j] == 'o'){
	  sy = i;
	  sx = j;
	}
	else if(maze[i][j] == '*'){
	  gy[M] = i;
	  gx[M] = j;
	  M++;
	}
      }
    }
    gy[M] = sy;
    gx[M] = sx;

    maze_solve();
    ans_list.push_back(solve(0, M));

  }
 
  for(int i = 0; i < ans_list.size(); i++){
    int tmp = ans_list[i];
    if(tmp >= INF)
      cout << -1 << endl;
    else
      cout << tmp << endl;
  }

  return 0;

}

Measured memory_bytes: 1364
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

string S, T;

bool isOK(int k) {
		for (int i = 0; i < T.size(); i++) {
				if (T[i] != S[i+k] && S[i+k] != '?') {
						return false;
				}
		}
		return true;
}

string construct(int k) {
		string res = S;
		for (int i = 0; i < T.size(); i++) {
				res[k+i] = T[i];
		}

		for (int i = 0; i < S.size(); i++) {
				if (res[i] == '?') {
						res[i] = 'a';
				}
		}

		return res;
}

int main() {
		cin >> S >> T;

		string ans = "~";
		for (int k = 0; k <= (int)S.size()-(int)T.size(); k++) {
				if (isOK(k) == false) continue;
				string res = construct(k);
				if (res < ans) ans = res;
		}

		if (ans == "~") cout << "UNRESTORABLE" << endl;
		else cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(N+1)] for _ in range(T+1)]
# 重さwまで品物nまででで最大になる価値

prev = [[0 for _ in range(N+1)] for _ in range(T+1)]

for n in range(N): # 品物nまでの世界で決めていく
    a, b = AB[n]
    for w in range(T):
        if a > w: # カバンに入りきらないなら入れられない
            dp[w][n+1] = dp[w][n]
            prev[w][n+1] = w
        else: #カバンに入れられる可能性があるなら
            if b+dp[w-a][n] >= dp[w][n]:
                dp[w][n+1] = dp[w-a][n] + b
                prev[w][n+1] = w - a
            else:
                dp[w][n+1] = dp[w][n]
                prev[w][n+1] = w

ans = dp[T-1][N]
used = [False]*N
c = T-1
for i in reversed(range(N)):
    if prev[c][i+1] == c - AB[i][0]:
        used[i] = True
    c = prev[c][i+1]

p = 0
for i in range(N):
    if not used[i] and AB[i][1] > p:
        p = AB[i][1]

print(ans+p)

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

int kisuu[30];
int guusu[30];
int main()
{
    string S;
    cin >> S;
    for(size_t i = 0; i < S.size(); ++i) {
        if((i+1)%2 == 0) {
            ++guusu[S[i] - 'A'];
        }
        else {
            ++kisuu[S[i] - 'A'];
        }
    }
    if(guusu['R' - 'A'] == 0 && kisuu['L' - 'A'] == 0) 
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 25

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];

void preP(int);
void inP(int);
void postP(int);

int main(){
  int i=0;
  int n=0;
  int id=0;
  int root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left!=-1)T[T[id].left].parent=id;
    if(T[id].right!=-1)T[T[id].right].parent=id;
  }

  for(i=0;i<n;i++) if(T[i].parent==-1) root=i;

  printf("Preorder\n");
  preP(root);
  printf("\n");
  printf("Inorder\n");
  inP(root);
  printf("\n");
  printf("Postorder\n");
  postP(root);
  printf("\n");

  return 0;
}


void preP(int u){
  if(u==-1) return;
  printf(" %d",u);
  preP(T[u].left);
  preP(T[u].right);
}

void inP(int u){
  if(u==-1) return;
  inP(T[u].left);
  printf(" %d",u);
  inP(T[u].right);
}

void postP(int u){
  if(u==-1) return;
  postP(T[u].left);
  postP(T[u].right);
  printf(" %d",u);
}


Measured memory_bytes: 2108
N = input()

if len(N) == 1:print(N)
elif len(N) == 2:print(9)
elif len(N) == 3:print(int(N) - 90)
elif len(N) == 4:print(909)
elif len(N) == 5:print(int(N) - 9090)
elif len(N) == 6:print(90909)


Measured memory_bytes: 3064
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 10**11#INF

# 先頭を除いたn-1個からk-1個を選んで全探索 n,kが小さいのでbit全探索する
for i in range(2**(n-1)):
  select = [0]#先頭は必ずk　の中に入る
  len_select = 1
  for j in range(n-1):
    if i >> j & 1 and len_select < k:
      select.append(j+1)#先頭を除いてj 個目を選ぶ
      len_select += 1
  # 選び終わったら、selectないの各要素に対してそれより前にselectの要素外に自身より大きいものがないか確かめる
  # 前から操作してmaxを保持すればO(n),めんどくさいのでO(n**3)でやる
  ok = 1
  #print(select,i)
  for m in select:
    for l in range(n):
      if l in select: continue
      if l < m and a[l] >= a[m]:
        #print(i,m)
        ok = 0
  if ok == 0 or len_select < k: continue
  else:
    ans_i = 0
    pre_val = a[0]#1つ前の要素の値
    for j in range(1,k):
      #print(i,a[select[j]])
      if pre_val >= a[select[j]]:
        ans_i += pre_val+1 - a[select[j]]
        pre_val += 1
      else:#元々大きい
        pre_val = a[select[j]]
  ans = min(ans,ans_i)
print(ans)

Measured memory_bytes: 44652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 500009
#define MOD 998244353
#define INF 1000000000

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

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

  COMinit();

  ll ans=0;
  ll sum=M;
  if(M>1){
    for(int i=0;i<N-1;i++){
      sum*=M-1;
      sum%=MOD;
    }
    for(ll i=0;i<=K;i++){
      ans+=sum*COM(N-1,i)%MOD;
      ans%=MOD;
      sum*=inv[M-1];
      sum%=MOD;
    }
    cout<<ans<<endl;
  }else{
    if(K==N-1){
      cout<<1<<endl;
    }else{
      cout<<0<<endl;
    }
  }
}


Measured memory_bytes: 15356
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

signed main(){
	IOS();
	ll a, b, c;
	cin >> a >> b >>c;
	if(a + b > c){
		cout << b + c << endl;
	}
	else {
		ll ans = b;
		cout << ans + min(a + b + 1, c) << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define NIL -1

struct Node
{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];
int n, A[MAX], B[MAX];

void setDepth(int u, int d)
{
  if(u == NIL)
    {
      return;
    }
  A[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u)
{
  int a = 0, b = 0;
  if(T[u].left != NIL)
    {
      a = setHeight(T[u].left) + 1;
    }
  if(T[u].right != NIL)
    {
      b = setHeight(T[u].right) + 1;
    }
  return B[u] = (a > b ? a : b);
}

int getSibling(int u)
{
  if(T[u].parent == NIL)
    {
      return NIL;
    }
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    {
      return T[T[u].parent].left;
    }
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    {
      return T[T[u].parent].right;
    }
  return NIL;
}

void print(int u)
{
  int i, c, d = 0;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  if(T[u].left != NIL)
    {
      d++;
    }
  if(T[u].right != NIL)
    {
      d++;
    }
  printf("degree = %d, ", d);
  printf("depth = %d, ", A[u]);
  printf("height = %d, ", B[u]);
  if(T[u].parent == NIL)
    {
      printf("root\n");
    }
  else if(T[u].left == NIL && T[u].right == NIL)
    {
      printf("leaf\n");
    }
  else
    {
      printf("internal node\n");
    }
}

int main()
{
  int i, root = 0, a, b, c;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      T[i].parent = NIL;
    }
  for(i = 0; i < n; i++)
    {
      scanf("%d", &a);
      scanf("%d", &b);
      scanf("%d", &c);
      T[a].left = b;
      T[a].right = c;
      if(b != NIL)
	{
	  T[b].parent = a;
	}
      if(c != NIL)
	{
	  T[c].parent = a;
	}
    }
  for(i = 0; i < n; i++)
    {
      if(T[i].parent == NIL)
	{
	  root = i;
	}
    }

  setDepth(root, 0);
  setHeight(root);
  for(i = 0; i < n; i++)
    {
      print(i);
    }
  return 0;
}



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

int main()
{
  int n, w;
  scanf("%d%d", &n, &w);
  vector<long long> dp(w + 1);
  for(int i = 0; i < n; i++)
  {
    int x, y;
    scanf("%d%d2", &x, &y);
    for(int weight = w; weight >= x; weight--)
    {
      dp[weight] = max(dp[weight], dp[weight - x] + y);
    }
  }
  cout << dp[w];
  
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int n,i,a;
  scanf("%d",&n); //社員の数
  int s[n];
  for(i=0;i<n;i++) s[i]=0;
  for(i=0;i<n-1;i++){
    scanf("%d",&a); //上司の番号
    s[a-1]+=1;
  }
  for(i=0;i<n;i++){
    printf("%d\n",s[i]);
  }
  return 0;
}

Measured memory_bytes: 2484
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <random>
#include <chrono>
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

const int INF = 2e9;
const int MOD = 1e9 + 7;
int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> h(n), dp(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1];
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,dp[100010] = {};
	cin >> n;
	dp[0] = 0;
	for(int i = 1;i <= n;i++){
		dp[i] = dp[i - 1] + 1;
		for(int j = 6;j <= i;j *= 6) chmin(dp[i],dp[i - j] + 1);
		for(int j = 9;j <= i;j *= 9) chmin(dp[i],dp[i - j] + 1);
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  for(int i = 0; i < (int)(N); i++) {
    for(int j = 0; j < i; j++) {
      for(int k = 0; k < j; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[j] + L[k] > L[i]) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int main()
{
	int n,m;
	cin>>n>>m;
	priority_queue<int>A;
	rep(i,0,n)
	{
		int a;
		cin>>a;		
		A.push(a);
	}
	while(m--)
	{
		int x=A.top();
		A.pop();
		x/=2;
		A.push(x);
	}
	ll XX=0;
	rep(i,0,n)
	{
		XX+=A.top();
		A.pop();
	}
	cout<<XX<<endl;
}


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

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

	vector<int> a(N, 0);
	for (int i = 0; i < M; i++) {
		int ai, bi;
		cin >> ai >> bi;
		a.at(ai - 1)++;
		a.at(bi - 1)++;
	}

	for (int i = 0; i < N; i++) {
		cout << a.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const double INF = 100000000;
using namespace std;

int main(){
    double d, e;
    while(cin >> d >> e,d||e){
        double diff = INF;
        rep(i,101){
            rep(j,101){
                if(i + j == d){
                    diff = min(diff, abs(sqrt(static_cast<double>(i * i + j * j)) - e));
                }
            }
        }
        cout << fixed << setprecision(4) << diff << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll h,w,n;
  cin >> h >> w >> n;
  
  ll res=0;
  ll cnt=0;
  while(res<min(h,w)&&cnt<n) res++,cnt+=max(h,w);
  
  ll x=0;
   while(cnt<n) cnt+=(min(h,w)-res),x++;
  res+=x;
  cout << res << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

const int mod = 1000000007;

int n;
int A[100001];

int fact[100002];
int ifact[100002];

int modpow(int a, int k){
  int r = 1;
  for(;k;k>>=1){
    if(k&1) r = (long long) r * a % mod;
    a = (long long) a * a % mod;
  }
  return r;
}

int binom(int n, int k){
  return (long long) fact[n] * ifact[n-k] % mod * ifact[k] % mod;
}

int main(){
  int i, a;
  fact[0] = 1;
  for(i=1;i<=100001;i++) fact[i] = (long long) i * fact[i-1] % mod;
  ifact[100001] = modpow(fact[100001], mod-2);
  for(i=100000;i>=0;i--) ifact[i] = (long long) (i+1) * ifact[i+1] % mod;

  scanf("%d", &n);
  for(i=1;i<=n+1;i++){
    int x;
    scanf("%d", &x);
    if(A[x]){
      a = i - A[x];
      break;
    }
    A[x] = i;
  }

  for(i=1;i<=n+1;i++){
    int c = binom(n+1, i);
    int d = (n-a >= i-1) ? binom(n-a, i-1) : 0;
    int r = c >= d ? c - d : c + mod - d;
    printf("%d\n", r);
  }

  return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int l = 0, r = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E')
      l++;
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E')
      l--;
    ans = min(ans, r + l);
    if (s[i] == 'W')
      r++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int X;
    cin >> X;
    int tmp = X / 200;
    cout << 10 - tmp << endl;  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  map<string, int> S;
  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[s]++;
  }

  int ans = 0;
  for (auto itr = S.begin(); itr != S.end(); itr++)
  {
    int x = itr->second;
    ans += x * (x - 1) / 2;
  }

  cout << ans << endl;
}

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

int main(){
        int n, num_imp, num_max, num_min;
        long long int num_sum;
        cin >> n;
        cin >> num_imp;
        num_max = num_imp;
        num_min = num_imp;
        num_sum = num_imp;
        while(n > 1){
                cin >> num_imp;
                num_max = max(num_max, num_imp);
                num_min = min(num_min, num_imp);
                num_sum += num_imp;
                n--;
        }
        cout << num_min << " " << num_max << " " << num_sum << endl;
}


Measured memory_bytes: 3104
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <ctime>
#include <set>
#include <map>
#include <vector>
#include <bitset>
using namespace std;

template <typename T>
T next_int() {
	T x = 0, p = 1;
	char ch;
	do { ch = getchar(); } while(ch <= ' ');
	if(ch == '-') {
		p = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	return p * x;
}
	
const int max_int = (int)1e9 + 228;
const int max_n = (int)1e6 + 227 + 1;	
const int mod = (int)1e9 + 7;

int main() {
//	freopen(".in", "r", stdin);

	int n = next_int<int>();

	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		a[i] = next_int<int>();
	}

	long long ans = 0;

	for(int i = 1; i < n; i++) {
		int temp = min(a[i], a[i - 1]);
		a[i] -= temp;
		a[i - 1] -= temp;

		if(temp && a[i - 1] % 2) {
			a[i - 1]++;
			a[i]++;
			temp--;
		}

		ans += temp;
	}

	for(int i = 0; i < n; i++) ans += a[i] / 2;

	cout << ans << "\n";
}


Measured memory_bytes: 640
"use strict";
    
const main = arg => {
  let Nums = arg.split(" ").map(n => Number(n));
  
  let member = Nums[0];
  let train = Nums[1];  
  let taxi = Nums[2];
  let ans = member*train > taxi? taxi :member*train;
  console.log(ans);
}

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


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int K;
    cin >> K;
    ll res = 0;
    FOR(a, 1, K + 1) FOR(b, 1, K + 1) FOR(c, 1, K + 1) res += gcd(a, gcd(b, c));
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n;
    cin>>n;
    
    for(int i=0; 7*i<=n; i++){
        if((n-7*i)%4==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256