akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mid (l+r)/2
using namespace std;
const int maxn=1e5+5;
int n,q,cnt=0,tol=0;
int to[maxn*2],col[maxn*2],wi[maxn*2],nex[maxn*2];
int head[maxn],f[maxn][22],depth[maxn],T[maxn],dis[maxn];
int L[maxn*40],R[maxn*40],sum[maxn*40],tot[maxn*40];
void add(int u,int v,int c,int d)
{
    to[++tol]=v,col[tol]=c,wi[tol]=d,nex[tol]=head[u],head[u]=tol;
}
int update(int pre,int l,int r,int col,int wei)
{
    int rt=++cnt;
    if(l==r) {sum[rt]=sum[pre]+wei;tot[rt]=tot[pre]+1;return rt;}
    L[rt]=L[pre],R[rt]=R[pre];
    if(l<r)
    {
        if(col<=mid) L[rt]=update(L[pre],l,mid,col,wei);
        else R[rt]=update(R[pre],mid+1,r,col,wei);
    }
    return rt;
}
void dfs(int u,int fa)
{
    depth[u]=depth[fa]+1;
    f[u][0]=fa;
    for(int i=1;(1<<i)<=depth[u];i++)
    {
        f[u][i]=f[f[u][i-1]][i-1];
    }
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        T[v]=update(T[u],1,n,col[i],wi[i]);
        dis[v]=dis[u]+wi[i];
        dfs(v,u);
    }
}
int lca(int x,int y)
{
    if(depth[x]<depth[y]) swap(x,y);
    for(int i=20;i>=0;i--)
    {
        if(depth[y]>depth[x]-(1<<i))
            continue;
        else
            x=f[x][i];
    }
    if(x==y)
        return x;
    for(int i=20;i>=0;i--)
    {
        if(f[x][i]==f[y][i])
            continue;
        else
        {
            x=f[x][i];
            y=f[y][i];
        }
    }
    return f[x][0];
}
int build(int l,int r)
{
    int rt=++cnt;
    if(l<r)
    {
        L[rt]=build(l,mid);
        R[rt]=build(mid+1,r);
    }
    return rt;
}
pair<int,int> query(int l,int r,int now,int pre,int color)
{
    if(l==r) return {tot[now]-tot[pre],sum[now]-sum[pre]};
    if(color<=mid) query(l,mid,L[now],L[pre],color);
    else query(mid+1,r,R[now],R[pre],color);
}
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<n;i++)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        add(a,b,c,d);
        add(b,a,c,d);
    }
    T[1]=build(1,n);
    dfs(1,0);
    while(q--)
    {
        int x,y,u,v;
        scanf("%d%d%d%d",&x,&y,&u,&v);
        int t=lca(u,v);
        int ans=dis[u]+dis[v]-2*dis[t];
        pair<int,int>p1=query(1,n,T[u],T[t],x);
        pair<int,int>p2=query(1,n,T[v],T[t],x);
        ans=ans+p1.first*y+p2.first*y-p1.second-p2.second;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 54784
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int opt=0;
        ArrayList<Integer> B = new ArrayList<>();
        for(int a=0;a<M;a++) B.add(sc.nextInt());
        for(int a=0;a<N;a++){
            int num = 0;
            for(int b=0;b<M;b++){
                int num2 = sc.nextInt();
                num+=num2*B.get(b);
            }
            num+=C;
            if(num>0)opt++;
        }
        System.out.println(opt);

    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int n;
  cin >> n;
  map<int, int> mpo, mpe;
  rep(i, n/2){
    int a, b;
    cin >> a >> b;
    mpo[a]++;
    mpe[b]++;
  }
  P omax = P(-1, 0), osndmax = P(-1, 0), emax = P(0, 0), esndmax = P(0, 0);
  for(P x : mpo){
    if(x.second >= omax.second){
      osndmax = omax;
      omax = x;
    }else if(x.second > osndmax.second){
      osndmax = x;
    }
  }
  for(P x : mpe){
    if(x.second >= emax.second){
      esndmax = emax;
      emax = x;
    }else if(x.second > esndmax.second){
      esndmax = x;
    }
  }
  int ans = 0;
  if(omax.first == emax.first){
    ans = min(n - omax.second - esndmax.second, n - emax.second - osndmax.second);
  }else{
    ans = n - omax.second - emax.second;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 8256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> h(n);
    int res=0;
    rep(i,0,n) cin >> h[i];
    while(1){
        //最高の高さが0だったらEND
        if(*max_element(h.begin(),h.end())==0)break;
        //区間分割する
        int i=0;
        while(i < n){
            if(h[i] == 0)i++;//0なら何もせずに進む
            else{
                res++; //区間の始まり
                while(i<n&&h[i]>0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
bool fl[30] = {};

string ss, sss;

int main() {


	cin >> a >> b >> N;

	c = 0;
	if (N % 500 != 0) {
		c++;
	}
	c += N / 500;

	d = min(a, b * 2);

	e = d * (c / 2);

	if (c % 2 == 1) {
		d = min(a, b);
		e += d;
	}

	cout << e << endl;

	return 0;

}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define NIL -1
int n;
struct node{int p,l,r;};
node tree[26];

/*先行順巡回*/
void Preorder(int u){
  if(u==NIL) return; //左がないので戻る
  cout<<" "<<u;
  Preorder(tree[u].l);
  Preorder(tree[u].r);   
}

/*中間順巡回*/
void Inorder(int u){
  if(u==NIL) return;
  Inorder(tree[u].l);
  cout<<" "<<u;
  Inorder(tree[u].r);
}

/*後順巡回*/
void Postorder(int u){
  if(u==NIL) return ;
  Postorder(tree[u].l);
  Postorder(tree[u].r);
  cout<<" "<<u;
}
int main(){
  int v,l,r,root;
    cin>>n;
  for(int i=0;i<n;i++){
    tree[i].p=NIL;
  }
  for(int i=0;i<n;i++){
    cin>>v>>l>>r;
    tree[v].l=l;
    tree[v].r=r;
    if(l!=NIL) tree[l].p=v;
    if(r!=NIL) tree[r].p=v;
  }
  for(int i=0;i<n;i++){
    if(tree[i].p==NIL) root = i;
  }
  cout<<"Preorder"<<endl;
  Preorder(root);
  cout<<endl;
  cout<<"Inorder"<<endl;
  Inorder(root);
  cout<<endl;
  cout<<"Postorder"<<endl;
  Postorder(root);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  rep(i,s.size() ){
    if(s[i]=='R') cnt++;
  }
  if(cnt > n/2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int W, H, N;
    int x, y, a;
    static bool paint[110][110];

    cin >> W >> H >> N;
    REP(i,N) {
        cin >> x >> y >> a;
        if (a == 1) {
            for (int tx=1; tx<=x; tx++) {
                for (int ty=1; ty<=H; ty++) {
                    paint[ty][tx] = true;
                }
            }
        } else if (a == 2) {
            for (int tx=x+1; tx<=W; tx++) {
                for (int ty=1; ty<=H; ty++) {
                    paint[ty][tx] = true;
                }
            }
        } else if (a == 3) {
            for (int tx=1; tx<=W; tx++) {
                for (int ty=1; ty<=y; ty++) {
                    paint[ty][tx] = true;
                }
            }
        } else {
            for (int tx=1; tx<=W; tx++) {
                for (int ty=y+1; ty<=H; ty++) {
                    paint[ty][tx] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int tx=1; tx<=W; tx++) {
        for (int ty=1; ty<=H; ty++) {
            if (!paint[ty][tx]) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>

int main(void) {
  long n;
  scanf("%ld", &n);
  for (int i = sqrt(n); i >= 1; --i) {
    if(n % i == 0) {
      printf("%ld\n", i + n / i - 2);
      break;
    }
  }
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		char[] n = String.valueOf(scanner.nextInt()).toCharArray();
		int ans = 0;
		for(int i = 0; i < n.length; i++) {
			if(n[0] == '1' && n[1] == '0' && i == 0 ) {
				ans += (n[i] - '0') * 10;
			}else {
				ans += n[i] - '0';
			}
		}		
		System.out.println(ans);
	
	}

}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10000)

def solve(i,wa,use):
    global ct,s,n
    if wa==s and use==n:
        ct+=1
        return
    if use>=n or i==10 or wa>s:
        return
    solve(i+1,wa,use)
    solve(i+1,wa+i,use+1)

while 1:
    n,s=map(int,raw_input().split())
    if n==0 and s==0:
        break
    ct=0
    wa=0
    solve(0,0,0)
    print ct

Measured memory_bytes: 6432
a, b, c, x, y = map(int, input().split())

if (a + b) // 2 >= c:
    min_price = 'c'
else:
    min_price = 'other'

if min_price == 'c':
    if x >= y:
        price = min(2 * x * c, 2 * y * c + (x - y) * a)

    else:
        price = min(2 * x * c + (y - x) * b,  2 * y * c)
else:
    price = a * x + b * y

print(price)

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

#define mod 1000000007
#define ll long long int


int main()
{
  ll n;
  cin>>n;
  ll arr[n];
  for(ll i=0;i<n;i++)cin>>arr[i];
  ll maxx=0;
  for(ll i=0;i<n;i++)
  {
    for(ll j=i+1;j<n;j++)
    {
      maxx=max(maxx,abs(arr[i]-arr[j]));
    }
  }
  cout<<maxx;
}


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


void solve(long long Q, long long H, long long S, long long D, long long N){
  vector<long long> vec({Q*4, H*2, S});
  long long mymin = *min_element(vec.begin(), vec.end());

  if((mymin*2) > D) {
    cout << (D*(N/2))+((N%2)*mymin) << endl;
  }
  else {
    cout << mymin * N << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long Q;
  scanf("%lld",&Q);
  long long H;
  scanf("%lld",&H);
  long long S;
  scanf("%lld",&S);
  long long D;
  scanf("%lld",&D);
  long long N;
  scanf("%lld",&N);
    solve(Q, H, S, D, N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int const N = 1001;
int main(){
    char str[N][50];
    int num[N],i=0,max=0,l=0;
    while(cin >> str[i]){//????????????
        i++;
    }
    for(int j=0;j<i;j++){//????????????????????????????????§????????????????§£???????????????????????????
        num[j]=0;
    }
    for(int j=0;j<i;j++){
        for(int k=0;k<i;k++){
            if(strcmp(str[j],str[k])==0)
			num[j]++;
		}
        if(num[max] < num[j])
            max = j;
        if(strlen(str[l]) < strlen(str[j]))
            l=j;
    }
    cout << str[max] << " " << str[l] << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> x >> y;
	ll ans = 0;
	for(ll i=0;i<=x;i++) {
		for(ll j=0;j<=x;j++) {
			if(i+j <= y && (y - i - j) <= x) ans++;
		}
	}
	cout<<ans;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



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

int main() {
	int paper[10][10] = {0};
	int paint[][2] = { {0,-1}, {-1,0},{0,0},{1,0},{0,1},{-1,-1},{1,-1},{-1,1},{1,1},{0,-2},{-2,0},{2,0},{0,2}};
	int size[]={ 0,5,9,13 };
	int x, y, z;
	char dommy;
	int time;
	while (cin >> x >> dommy >> y >> dommy >> z) {
		for (int i = 0; i < size[z]; ++i) {
			if (x + paint[i][0] >= 0 && x + paint[i][0] < 10 && y + paint[i][1] >= 0 && y + paint[i][1] < 10) {
				++paper[x + paint[i][0]][y + paint[i][1]];
			}
		}
	}
	int answer=0, max=0;
	for (int i = 0; i < 10; ++i) {
		for (int i2 = 0; i2 < 10; ++i2) {
			if (paper[i][i2] == 0)++answer;
			else if (max < paper[i][i2]) {
				max = paper[i][i2];
			}
		}
	}
	cout << answer << endl << max << endl;
	return 0;
}

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

int main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if(n <= k) cout << n * x << "\n";
	else cout << k * x + (n-k) * y << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    S = [list(map(int, readline().strip())) for j in range(H)]

    white = 0
    for line in S:
        white += sum(line)

    if white <= K:
        print(0)
        exit()

    # 横線の決め方を全探索
    ans = 10**5
    for pattern in range(2**(H-1)):
        # 初期化
        impossible = False
        x = 0
        ly = bin(pattern).count("1")
        y = [[0]*W]*(ly + 1)
        line = 0
        for i in range(H):
            y[line] = [y[line][j] + S[i][j] for j in range(W)]
            if (pattern >> i) & 1:
                line += 1

        # 各列の値を加算していく
        count = [0]*(ly + 1) 
        for col in zip(*y):
            # Kより大きい値を加算する場合は不成立
            if any(a > K for a in col):
                impossible = True
                break
            for i, a in enumerate(col):
                count[i] += a
                # 和がKより大きければカット数を増やす
                if count[i] > K:
                    x += 1
                    count = list(col) 
                    break
            if x + ly > ans:
                impossible = True
                break
        if impossible:
            x = 10**6

        ans = min(ans, x + ly)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a;
	while(getline(cin,a)){
	int k=0;
	int check=0;
	while(true){
		if(k>52)
			break;
		for(int j=0;j<a.size();j++){
			if(isalpha(a[j])!=0)
				if(a[j]=='z')
					a[j]='a';
				else
				    a[j]++;
		}
		for(int i=0;i<a.size()-2;i++){
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='e'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='i'&&a[i+3]=='s'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='a'&&a[i+3]=='t'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
		}
		k++;
	}
	}
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int k,n;
  cin>>k>>n;
  int a[200000];
  rep(i,0,n) cin>>a[i];

  int ans=-1*inf;
  rep(i,0,n-1){
    if(a[i+1]-a[i]>ans)  ans=a[i+1]-a[i];
  }
  if((k-a[n-1]+a[0])>ans) ans=k-a[n-1]+a[0];

  cout<<k-ans<<endl;


}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a;
    cin >> b;
    cin >> h;

    cout << (a + b) * h / 2 << endl;

    return 0;
}


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

int n, k;
bool ng[10] = {false};

int main() {
	int i, j;
	
	cin >> n >> k;
	for (i = 0; i < k; i++) { int d; cin >> d; ng[d] = true; }
	
	for (i = n; ; i++) {
		for (j = 1000000; i / j == 0; j /= 10);
		for (; j > 0; j /= 10) {
			int digit = (i / j) % 10;
			if (ng[digit]) break;
		}
		if (j == 0) {
			break;
		}
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MIN(x,y)	((x)<(y)?(x):(y))

//各桁の和
int digsum(int n){
	int sum=0;
  	while (n > 0){
      	sum += n % 10;
      	n   /=     10;
    }
  	return sum;
}
//
int main(){
	int n,min=999999;
	scanf("%d",&n);
	for(int i=1; i<n; i++){
      	int sum=0;
      	sum += digsum(i);
      	sum += digsum(n-i);
      	min = MIN(min, sum);
    }
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 1692
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
#include <cmath>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

const double PI = 3.14159265358979323846;

int main(void)
{
	double a, b, x;
	cin >> a >> b >> x;
	auto t = a* a* b / 2;
	cout << std::setprecision(15);
	if (t >= x) {
		auto c = x / (a * b) * 2;
		auto d = atan2(c, b) / PI * 180;
		cout << (90 - d) << endl;
		return 0;
	}
	else {
		auto r = x - t;
		auto c = r / (a * a) * 2;
		auto d = atan2(b - c, a) / PI * 180;
		cout << d << endl;
		return 0;
	}
}

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

int N, P;
vector<int> biscuits;
long dp[50][2];

long choose(int now, int mod_2){
	if(now == N){
		return mod_2 == P;
	}else if(dp[now][mod_2] != -1){
		return dp[now][mod_2];
	}else{
		return dp[now][mod_2] = choose(now + 1, (mod_2 + biscuits[now]) % 2) + choose(now + 1, mod_2);
	}
}
 
int main(){
	cin >> N >> P;
	for(int i = 0; i < N; i++){
		int input;
		cin >> input;
		biscuits.push_back(input);
	}
	for(int i = 0; i < 50; i++){
		dp[i][0] = -1;
		dp[i][1] = -1;
	}
	cout << choose(0, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
//using namespace __gnu_pbds;
//template <typename T>
//using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll N = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    int a[3];
    loop(i,0,3)cin >> a[i];
    sort(a,a+3);
    if((a[0] == a[1] && a[1] != a[2])||(a[0] != a[1] && a[1] == a[2]))cout << "Yes\n";
    else cout << "No\n";
return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> C(H);
  for(int i=0;i<H;i++){
    cin >> C[i];
  }
  int ans=0;
  for(int i=0;i<(1<<H);i++){
    for(int j=0;j<(1<<W);j++){
      int count=0;
      for(int k=0;k<H;k++){
        for(int l=0;l<W;l++){
          if(i&(1<<k) || j&(1<<l)){
            continue;
          }
          if(C[k][l]=='#'){
            count++;
          }
        }
      }
      if(count==K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

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

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 main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int64_t n,k;cin >> n >> k;
    vector<int64_t> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    int64_t ans = 0;
    rep(i,k)ans += a[i];
    cout << ans << '\n';

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

char func(ll n){
  ll tmp = ((n%26) == 0 ? 25 : (n%26)-1);
  return (char)('a'+tmp);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  string ans;
  while(N > 0){
    ans.push_back(func(N));
    int tmp = N%26;
    N /= 26;
    if(tmp == 0) N--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3652
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);


int[] num={0,1,3,1,2,1,2,1,1,2,1,2,1};

//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



if(num[A]==num[B]){
//double res=Math.ceil((AB)/2);

System.out.println("Yes");
//}else if((C-B)<A){
//System.out.println("safe");

}else{
System.out.println("No");

}




	}
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double doublel;
#define f first
#define s second
 
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e17;	

set<pair<ll, ll>> s;
int par[N], cnt[N];
ll h[N];
vector<pair<int, int>> ans;
vector<int> adj[N];


void dfs(int u)
{
	for(auto x : adj[u])
	{
		h[x] = h[u] + 1;
		dfs(x);
	}
}



int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		ll w;
		cin >> w;
		s.insert({-w, i});
		cnt[i] = 1;
		par[i] = i; 
		
	}
	
	bool fl = true;
	
	while(s.size() != 1)
	{
		ll w = -s.begin()->f;
		int x = s.begin()->s;
		ll w2 = w-n+2*cnt[x];
		s.erase(s.begin());


		//cout << x+1 << ' '  << w << ' ' << w2 << ' ' << fl << endl; 


		auto it = s.lower_bound({-w2, -1});
		if(it == s.end() || it->f != -w2)
			fl = false;
		else
		{
			int y = it->s;
			par[x] = y;
			cnt[y] += cnt[x];
		}		
		
	}
	
	
	
	
	for(int i = 0; i < n; i++)
	{
		if(i == par[i])
			continue;
		ans.push_back({min(i, par[i]), max(i, par[i])});
		
		adj[par[i]].push_back(i);
		
	}
	
	
	int r = s.begin()->s;
	dfs(r);
	
	ll sum = 0;
	for(int i = 0; i < n; i++)
		sum += h[i];
	
	if(sum != -s.begin()->f)
	{
		fl = false;
	}
		
	



	if(!fl)
	{
		cout << -1 << endl;
		return 0;
	}
	
	sort(ans.begin(), ans.end());
	
	for(auto e : ans)
		cout << e.f + 1 << ' ' << e.s + 1<< endl; 
	
	
	
	
	
	
	
	
	
    return 0;
}

 
 	
 	




 





Measured memory_bytes: 37148
#include<iostream>
#include<cstring>
using namespace std;
bool f=false,c=false;
int main()
{
	string s;
	getline(cin,s);
	for(int i=0;i<=s.length();i++){
		if(s[i]=='C')c=true;
		if(c&&s[i]=='F')f=true;
	}
	if(f)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
program test
implicit none
integer(8) :: i,j,k,m,n,nn,ans(1000)=0,ii
character :: ans2(1000)

read(*,*) n
nn = n
i = 1
ii = 1

do
if(nn == 0) then
	goto 100
else
	if(mod(nn,-2*ii) == 0) then
		continue
	else
		ans(i) = 1
		nn = nn - ii
	endif
endif
i=i+1
ii = ii * (-2)
enddo

100 continue
if(n == 0) then
write(*,*) 0
else

write(*,'(1000(I0))') ans(i-1:1:-1)



endif


end program

Measured memory_bytes: 768
import bisect

X = int(input())

ex = [1]
for i in range(2,33):
    x = i*i
    while x <= 1000:
        ex.append(x)
        x = x*i

ex = list(set(ex))
ex.sort()
        
print(ex[bisect.bisect_right(ex, X)-1])

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a!=b&&b!=c&&a!=c)
	{
		printf("3\n");
	}
	else if(a==b&&b!=c)
	{
		printf("2\n");
	}
	else if(a==c&&a!=b)
	{
		printf("2\n");
	}
	else if(b==c&&c!=a)
	{
		printf("2\n");
	}
	else if(a==b&&b==c)
	{
		printf("1\n");
	}
	return 0;
}

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


int main() {

    int n1,n2,n3,n4;
    cin>>n1>>n2>>n3>>n4;

    int cnt1=0,cnt9=0,cnt7=0,cnt4=0;

   if(n1==1)
      cnt1++;
    else if(n1==9)
      cnt9++;
    else if(n1==7)
      cnt7++;
    else if(n1==4)
      cnt4++;

   if(n2==1)
      cnt1++;
    else if(n2==9)
      cnt9++;
    else if(n2==7)
      cnt7++;
    else if(n2==4)
      cnt4++;

   if(n3==1)
      cnt1++;
    else if(n3==9)
      cnt9++;
    else if(n3==7)
      cnt7++;
    else if(n3==4)
      cnt4++;

   if(n4==1)
      cnt1++;
    else if(n4==9)
      cnt9++;
    else if(n4==7)
      cnt7++;
    else if(n4==4)
      cnt4++;

  if(cnt1==1&&cnt9==1&&cnt7==1&&cnt4==1)
    cout<<"YES"<<endl;
  else
  {
    cout<<"NO"<<endl;
  }
  


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
char c[MAXN];
int n,pre[MAXN],nx[MAXN],ans[MAXN]; 
int main () {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (int i=1;i<=n;i++) {pre[i]=(c[i-1]=='R'?i-1:pre[i-1]);}
	for (int i=n;i>=1;i--) {nx[i]=(c[i+1]=='L'?i+1:nx[i+1]);}
	for (int i=1;i<=n;i++) {
		if (c[i]=='R') {
			if ((nx[i]-i)%2) {ans[nx[i]-1]++;}
			else {ans[nx[i]]++;}
		} else {
			if ((i-pre[i])%2) {ans[pre[i]+1]++;}
			else {ans[pre[i]]++;}
		}
	}
	for (int i=1;i<=n;i++) {
		printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
S = list(input())

MOD = 10 ** 9 + 7

from collections import Counter

Scnt = Counter(S)

# 任意の文字列について、
# どれかを取り出す or どれも取り出さない

ans = 1
for cnt in Scnt.values():
    ans = (ans * (cnt + 1)) % MOD

ans -= 1

print(ans)

Measured memory_bytes: 4140
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 2e3 + 10;
ll n, m, k, ans = 1e17;
ll pos[23], num[23];
char C[23][MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j ++){
            cin >> C[i][j];
		}
    }
    for(int mask = 0; mask < (1LL << (n - 1)); mask ++){
		ll pc = __builtin_popcount(mask) + 1, res = pc - 1, now = 0;
		memset(num, 0, sizeof num);
		for(int j = 1; j < n; j ++){
			if((mask >> (j - 1)) & 1LL) now ++;
			pos[j] = now;
		}
		bool f = 1, ok;
		for(int j = 0; j < m; j ++){
			for(int h = 0; h < n; h ++){
                if(C[h][j] == '1') num[pos[h]] ++;
			}
			ok = 1;
			for(int h = 0; h < pc; h ++){
                if(num[h] > k) ok = 0;
			}
			if(ok) continue;
			memset(num, 0, sizeof num), res ++;
			for(int h = 0; h < n; h ++){
                if(C[h][j] == '1') num[pos[h]]++;
			}
			ok = 1;
			for(int h = 0; h < pc; h ++){
                if(num[h] > k) ok = 0;
			}
			if(ok) continue;
			f = 0;
			break;
		}
		ans = min(ans, (f ? res : (ll)1e18));
	}
	cout << ans;
    return 0;
}
/*!
    Be careful who you share your weaknesses with.
    Some people can't wait for the opportunity to use them against you!!
*/
//! N.N


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

int main(){
 while(true){
  int m, n_min, n_max;
  cin >> m >> n_min >> n_max;
  if(m==0 && n_min==0 && n_max==0) break;

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

  int gap = -1;
  int n = -1;
 
  for(int i=n_min; i<=n_max; i++){
   int g = P[i-1]-P[i];
   if(gap<=g){
    gap = g;
    n = i;
   }
  }
  
  cout << n << endl;
 }

 return 0;
}
   


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

using namespace std;

int main(void)
{
	int n,t;
	int Max = -1;
	int Min = 1001; 

	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		Max = max(Max,t);
		Min = min(Min,t);
	}

	cout << Max-Min << '\n';
	return 0;
}

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

using namespace std;

#define pb push_back
#define NL endl
#define pi 2.0*acos(0.0)
#define mod 1e9+7
#define FOR(i,j,n)    for(ll i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

set<ll>cset[30];

int main(){
    fastIO;
    ll n,q,a,b,c,pos,ans = 0;
    string s;
    char d,curr;
    cin>>n>>s>>q;
    FOR(i,0,n){
        cset[s[i] - 'a'].insert(i+1);
    }
    FOR(i,0,26){
        cset[i].insert(1e18);
    }
    while(q--){
        cin>>a;
        if(a == 1){
            cin>>b>>d;
            curr = s[b-1];
            cset[curr - 'a'].erase(b);
            cset[d - 'a'].insert(b);
            s[b - 1] = d;
        }
        else{
            cin>>b>>c;
            ans = 0;
            FOR(i,0,26){
                if(cset[i].size()){
                    auto lower = cset[i].lower_bound(b);
                    if(*lower == 1e18){}
                    else{
                        ll val = *lower;
                        if(val >= b && val <= c) ans++;
                    }
                }
            }
            cout<<ans<<endl;
        }
    }
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, X) for (auto itr = X.begin(); itr != X.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int MOD = 1000000007;
const int INF = 1000000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC";
    else cout << "ABC";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;

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

    int sum=0;

    for(int i=1;i<10000;i++){
        sum += a;
        if(sum % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a[10], b[10], d[10], e[10], c, i, cnt = 0;

	for (i = 1; i <= 6; i++) {
		scanf("%d", &b[i]);
		a[i] = b[i];
	}

	for (i = 1; i <= 6; i++) {
		scanf("%d", &e[i]);
		d[i] = e[i];
	}

	for (i = 1; i <= 5; i++) {
		if (a[i] > a[i + 1]) {
			c = a[i + 1];
			a[i + 1] = a[i];
			a[i] = c;
		}
		if (d[i] > d[i + 1]) {
			c = d[i + 1];
			d[i + 1] = d[i];
			d[i] = c;
		}
	}

	for (i = 1; i <= 6; i++) {
		if (a[i] == d[i])
			cnt++;
	}
	if ((cnt == 6) && (a[1] == a[2]) && (a[2] == a[3]) && (a[3] == a[4]) && (a[4] == a[5])) {
		printf("Yes\n");
		return 0;
	}

	for (i = 0; i < 4; i++) {	/*縦移動*/
		if (b[1] == e[1])
			break;
		c = b[1];
		b[1] = b[2];
		b[2] = b[6];
		b[6] = b[5];
		b[5] = c;
	}

	for (i = 0; i < 4; i++) {	/*縦移動(1が横にあるとき)*/
		if (b[1] == e[1])
			break;
		c = b[1];
		b[1] = b[3];
		b[3] = b[6];
		b[6] = b[4];
		b[4] = c;
	}

	for (i = 0; i < 4; i++) {	/*横移動*/
		if (b[2] == e[2])
			break;
		c = b[2];
		b[2] = b[3];
		b[3] = b[5];
		b[5] = b[4];
		b[4] = c;
	}

	for (i = 2; i <= 6; i++) {
		if (b[i] != e[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define int uint64_t


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int n;
  cin>>n;
  int arr[n][2];
  int a,b;int cnt=0;
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      arr[i][0]=a;
      arr[i][1]=b;
      
  }
  int flag=0;
  for(int i=0;i<n;i++)
  {
      if(arr[i][0]==arr[i][1])
        cnt++;
        else
          cnt=0;

        if(cnt>=3)
        {
            flag=1;
            break;
        }  
  }
  if(flag==1)
  cout<<"Yes";
else
  cout<<"No";
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int D = Integer.parseInt(sc.next());
    
    if(D==25) {
      System.out.println("Christmas");
    }else if(D==24) {
      System.out.println("Christmas Eve");
    }else if(D==23) {
      System.out.println("Christmas Eve Eve");
    }else {
      System.out.println("Christmas Eve Eve Eve");
    }
  }
}

Measured memory_bytes: 21332
from collections import deque
n,m = map(int, input().split())
V = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)
ans = [-1]*(n+1)
q = deque()
q.append(1)
while q:
    p = q.popleft()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.append(c)
print('Yes')
for i in range(2,n+1): print(ans[i])


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


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w[n];
    int e[n];
    for(int i = 0; i < n; i++){
        w[i] = 0;
        e[i] = 0;
    }
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            w[i] = 1;
        }else{
            e[i] = 1;
        }
    }
    for(int i = 0; i < n-1; i++){
        w[i+1] += w[i];
        e[i+1] += e[i];
    }
    int ans = INT_MAX;
    for(int i = 0; i < n; i++){
        int k = w[i];
        int l = e[n-1] - e[i];
        if(s[i] == 'W'){
            k--;
        }
        ans = min(ans,k+l);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Maxn=2e5+15;
const int INF=0x3f3f3f3f;
int n,k,a[Maxn],cnt[Maxn];
priority_queue<int,vector<int>,greater<int>>qu;
int main()
{
    int ans=0,Mx=-1;
    memset(cnt,0,sizeof(cnt));
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),cnt[a[i]]++,Mx=max(a[i],Mx);
    for(int i=1;i<=Mx;i++)
        if(cnt[i])
        {
            //printf("%d %d\n",i,cnt[i]);
            qu.push(cnt[i]);
        }
    while(qu.size()>k)
    {
        ans+=qu.top();
        qu.pop();
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 2936
program prob6
    implicit none
    integer(8)::n, i, j, t, ans
    integer(8)::c(200005), dp(0:200005), last(0:200005)
    integer, parameter::mod2 = 1000000007
    c = 0
    dp = 0
    last = 0
    read(*,*) n
    do i = 1, n
        read(*,*) t
        c(t) = c(t) + 1
        dp(i) = dp(i-1) + dp(last(t))
        if(i - last(t) == 1) dp(i) = dp(i) - dp(i-1)
        dp(i) = mod(dp(i),mod2)
        dp(1) = 1
        last(t) = i
        !write(*,*) dp(i)
    end do
    write(*,*) dp(n)
    stop
end program

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

int gcd(int a,int b,int c) {
  int kouyaku;  
  for (int i = min(a,min(b,c)); i > 0; i--) {
        if (a % i == 0 && b % i == 0 && c % i == 0) {
            kouyaku = i;
            break;
        }
    }
    return kouyaku;
}

int main() {
    int k, sum = 0;
    cin >> k;

    for (int i = 1; i < k + 1; i++) {
        for (int j = 1; j < k + 1; j++) {
            for (int l = 1; l < k + 1; l++) {
                sum += gcd(i, j, l);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3188
import copy
N = int(input())

moji = ["a","b","c","d","e","f","g","h","i","j"]
start = ["a"]
ll = [[] for i in range(11)] #0個目は使わない

def syurui(l):
    return len(set(l))

ll[1].append(["a"])

for i in range(2,N+1):
    for j in range(len(ll[i-1])):
        for k in range(syurui(ll[i-1][j])+1):
            tmp = copy.copy(ll[i-1][j])
            ll[i-1][j].append(moji[k])
            ll[i].append(ll[i-1][j])
            ll[i-1][j] = tmp

for i in range(len(ll[N])):
    kotae ="".join(ll[N][i])
    print(kotae)

Measured memory_bytes: 74332
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    string str;
    cin >> str;
    if((str[0] == str[str.size() - 1]) ^ (str.size() % 2 == 1)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a>b) {
				for(int i=0;i<a;i++) {
					System.out.print(b);
				}
			}else {
				for(int i=0;i<b;i++) {
					System.out.print(a);
				}
			}
			
	    }
				
	}
	


Measured memory_bytes: 35800
//Moh_K_Imar .......
//22/08/2020  ... 11,54 .
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a;
    cin>>a;
    ll counter=0;
    for(int i=0;i<a.size();i++){
        if(a[2]==a[3]&&a[4]==a[5]){
            counter++;
        }
    }
    if(counter!=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



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

int main(){
    string s;
    cin >> s;
    ll N = s.size();
    vector<char> ss;
    rep(i,N-1){
        if(s[i] == 'B' && s[i+1] == 'C'){
            ss.push_back('D');
            i++;
            continue;
        }
        ss.push_back(s[i]);
    }
    if(ss.size() > 0){
        if(ss[ss.size()-1] != 'D'){
            ss.push_back(s[N-1]);
        }
    }
    ll M = ss.size();
    ll cnt = 0, tmp = 0;
    bool flagA = false;
    /*rep(i,ss.size()){
        cout << ss[i];
    }
    cout << endl;*/
    rep(i,M){
        if(ss[i] == 'A'){
            flagA = true;
            tmp++;
            continue;
        }else if(ss[i] == 'D' && flagA){
            cnt += tmp;
        }else{
            flagA = false;
            tmp = 0;
        }
    }
    cout << cnt << endl;
    //ll cnt = 0;
    /*
    bool flag = true;;
    while(flag){
        flag = false;
        rep(i,N-2){
            if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
                s[i] = 'B';
                s[i+1] = 'C';
                s[i+2] = 'A';
                flag = true;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    */
}


Measured memory_bytes: 772
n,k,q=list(map(int,input().split()))
a=list(map(int,input().split()))
ans=10**9
for i in a:
    A=[]
    l=[]
    ln=0
    for j in a+[-1]:
      if i>j:
        if ln-k+1>=0:
          l.sort()
          A+=l[:ln-k+1]
        l=[]
        ln=0
      else:
        l.append(j)
        ln+=1
    if len(A)<q:
      continue
    else:
      A.sort()
      ans=min(ans,A[q-1]-i)
print(ans)

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

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

	for (char c = 'a'; c <= 'z'; c++)
	{
		if (find(s.begin(), s.end(), c) == s.end())
		{
			cout << c << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	if(n&1){
		if((n+1)/2>=k){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else{
		if(n/2>=k){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}
		

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

int main(){
    int n,a = 0;
    cin >> n;
    vector<int> l(n),r(n);
    for(int i = 0;i < n;i++)cin >> l[i] >> r[i];
    for(int i = 0;i < n;i++){
        a += r[i] - l[i] + 1;
    }
    cout << a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] tree = new int[N+1];
        for(int i = 1; i < N+1; i++){
        	tree[i] = sc.nextInt();
        }
        
        for(int i=1; i < N+1; i++){
        	System.out.print("node " + (i) + ": key = " + tree[i] + ", ");
        	int parent = parent(i);	if(0     < parent     ){System.out.print("parent key = " + tree[parent] + ", ");}
        	int left   = left(i);   if(left  < tree.length){System.out.print("left key = "   + tree[left]   + ", ");}
        	int right  = right(i);  if(right < tree.length){System.out.print("right key = "  + tree[right]  + ", ");}
        	System.out.println();
        }
    }

    private static int parent(int i){
    	return i / 2;
    }
    
    private static int left(int i){
    	return 2 * i;
    }
    
    private static int right(int i){
    	return 2 * i + 1;
    }
}

Measured memory_bytes: 21448
#include<stdio.h>
int main(void)
{
	char s[4];
	int i,n;
	n=700;
	scanf("%s",&s);
	for(i=0;i<=2;i++){
	if(s[i]=='o'){
	n=n+100;
	}}
	printf("%d\n",n);
	return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; h++)
    {
        for (ll n = 1; n <= 3500; n++)
        {
            ll w = N * h * n;
            if (4 * h * n - N * n - N * h <= 0)
                continue;
            if (w % (4 * h * n - N * n - N * h) == 0)
            {
                cout << w / (4 * h * n - N * n - N * h) << " " << h << " " << n << endl;
                return 0;
            }
        }
    }
}


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

int main(){
  int N; cin>>N;
  double ans = 0;
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u == "BTC") x *= 380000;
    ans += x;
  }
  printf("%.7lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    int count=0,i,j,len,diff=1;
    char str[26];

    scanf("%s",str);

len=strlen(str);

for(i=0;i<len;i++){
    for(j=i+1;j<len;j++){
        if(str[i]==str[j]){
            diff=0;
            break;
        }
    }
}

if(diff==1)printf("yes\n");
else printf("no\n");

return 0;
}

Measured memory_bytes: 128
import java.util.*
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
 
    val s = HashSet<Int>()
    (1..9).forEach { x ->
        (1..9).forEach { y ->
            s.add(x * y)
        }
    }
 
    if (s.contains(a)) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 32032