akhauriyash/Code-Regression huggingface dataset:
<?php
    fscanf(STDIN, "%d %d", $n, $k);
    $s = fgets(STDIN);
    $array = str_split($s);
    $repNum = $k - 1;
    if($array[$repNum] === 'A'){
        $array[$repNum] = 'a';
    }elseif($array[$repNum] === 'B'){
        $array[$repNum] = 'b';
    }elseif($array[$repNum] === 'C'){
        $array[$repNum] = 'c';
    }
    echo implode($array);
?>

Measured memory_bytes: 4984
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int sum = 0;
	int x;
	cin >> x;
	int cur = 1;
	while (1) {
		sum += cur;
		if (sum >= x) {
			cout << cur << endl;
			break;
		}
		cur++;
	}

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 256
h, w, kk = [int(i) for i in input().split()]
s = [input() for _ in range(h)]

ans = 10 ** 9
for i in range(2 ** (h - 1)):
    aa = 0
    for j in range(h - 1):
        if (i >> j) & 1 == 1:
            aa += 1
    c = aa
    b = [0] * (c + 1)
    ook = True
    for j in range(w):
        k = 0
        for l in range(h):
            if s[l][j] == "1":
                b[k] += 1
            if (i >> l) & 1 == 1:
                k += 1

        ok = True
        for l in b:
            if l > kk:
                ok = False

        if not ok:
            aa += 1
            b = [0] * (c + 1)

            k = 0
            for l in range(h):
                if s[l][j] == "1":
                    b[k] += 1
                if (i >> l) & 1 == 1:
                    k += 1

            ok = True
            for l in b:
                if l > kk:
                    ok = False
            if not ok:
                ook = False
                break
    if ook:
        ans = min(ans, aa)

print(ans)


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

int main(){
  int N,M;
  cin>>N>>M;
  
  //球の数b
  vector<int> b(N,1);
  //赤玉がある可能性p
  vector<int> p(N,0);
  p[0]=1;
  
  for(int i=0;i<M;++i){
    int x,y;
    cin>>x>>y;
    --x,--y;
    --b[x],++b[y];
    if(p[x]==1) p[y]=1;
    if(b[x]==0) p[x]=0;
  }
  
  
  int ans=0;
  for(int i=0;i<N;++i) ans += p[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[a[i]-1] = i+1;
    }
    for(int i = 0; i < n; i++){
        cout << b[i] << ' ';
    }
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cctype>
#include <cstring>
#define R register ll
const int inf=0x3f3f3f3f;

namespace quick {
#define tp template<typename Type>
	namespace in {
		inline char getc() {
			static char buf[1<<21],*p1=buf,*p2=buf;
			return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
		}
		inline int read(char *s) {
			*s=getc();
			while(isspace(*s)) {*s=getc();if(*s==EOF) return 0;}
			while(!isspace(*s)&&*s!=EOF) {s++;*s=getc();}
			*s='\0'; return 1;
		}
		tp inline int read(Type &x) {
			x=0;bool k=false;char c=getc();
			while(!isdigit(c)) {k|=(c=='-');c=getc();if(c==EOF) return 0;}
			while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getc();}
			x*=(k?-1:1); return 1;
		}
		template <typename Type,typename... Args>
		inline int read(Type &t,Args &...args) {
			int res=0;
			res+=read(t);res+=read(args...);
			return res;
		}
	}
	using in::read;
	namespace out {
		char buf[1<<21];int p1=-1;const int p2=(1<<21)-1;
		inline void flush() {
			fwrite(buf,1,p1+1,stdout);
			p1=-1;
		}
		inline void putc(const char &c) {
			if(p1==p2) flush();
			buf[++p1]=c;
		}
		inline void write(char *s) {
			while(*s!='\0') putc(*s),s++;
		}
		tp inline void write(Type x) {
			static char buf[30];int p=-1;
			if(x<0) {putc('-');x=-x;}
			if(x==0) putc('0');
			else for(;x;x/=10) buf[++p]=x%10+48;
			for(;p!=-1;p--) putc(buf[p]);
		}
		inline void write(char c) {putc(c);}
		template <typename Type,typename... Args>
		inline void write(Type t,Args ...args) {
			write(t);write(args...);
		}
	}
	using out::write;
	using out::flush;
	tp inline Type max(const Type a,const Type b) {
		if(a<b) return b;
		return a;
	}
	tp inline Type min(const Type a,const Type b) {
		if(a<b) return a;
		return b;
	}
	tp inline void swap(Type &a,Type &b) {
		a^=b^=a^=b;
	}
	tp inline Type abs(const Type a) {
		return a>=0?a:-a;
	}
#undef tp
}
using namespace quick;

typedef long long ll;
const ll maxn=300000+50,mod=1e9+7;
ll n;
char s[maxn];
ll f[maxn][3][3];//表示dp到第i位,栈中有j个0,k个1的方案数

inline void transfer(ll i,ll j,ll k,ll tp) {
	if(tp) {//压1
		if(j) (f[i][j-1][k]+=f[i-1][j][k])%=mod;//有0消一个0
		else if(k==2) (f[i][j][2]+=f[i-1][j][k])%=mod;//两个1,变成一个
		else (f[i][j][k+1]+=f[i-1][j][k])%=mod;//1的个数为0,1增加一个
	}
	else {//压0
		if(j<2) (f[i][j+1][k]+=f[i-1][j][k])%=mod;//0的个数小于两个
		else if(j==2) (f[i][1][k]+=f[i-1][j][k])%=mod;//0有两个
	}
}
int main(void) {
	read(s+1);n=strlen(s+1);
	f[0][0][0]=1;
	for(R i(1);i<=n;i++)
		for(R j(0);j<3;j++)
			for(R k(0);k<3;k++) {
				if(s[i]=='?') {
					transfer(i,j,k,0);
					transfer(i,j,k,1);
				}
				else transfer(i,j,k,s[i]-'0');
			}
	ll ans=0;
	for(R i(0);i<3;i++)
		for(R j(0);j<=i;j++)
			(ans+=f[n][j][i])%=mod;
	write(ans,'\n');
	flush();
	return 0;
}

Measured memory_bytes: 24704
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
#define rep(i, n) for(int i=0;i<n;i++)

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-12;

char in[1005];
int main() {
	scanf("%s", in);
	int L = (int)strlen(in) - 8, i;
	for (i = 0; i < L; i++) printf("%c", in[i]);
	return !printf("\n");
}

Measured memory_bytes: 256
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")
#define pi acos(-1)

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	ll a;
	double b;
	cin >> a >> b;
	b *= 100;
	cout << ll((a * (ll)(round(b ))) / 100) << "\n";
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

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

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    string s;
    cin>>s;
    int c1=0,c2=0,c3=0;
    for(int x=0;x<n;x++){
        if(s[x]=='R'){
            c1++;
        }else{
            if(s[x]=='G'){
                c2++;
            }else{
                c3++;
            }
        }
    }
    
    int ans=c1*c2*c3;
    for(int x=0;x<n;x++){
        for(int w=1;w<n;w++){
            if(x+w>=n||x+2*w>=n){
                break;
            }
            if(s[x]!=s[x+w]&&s[x+w]!=s[x+2*w]&s[x]!=s[x+2*w]){
                ans--;
            }
        }
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define pi M_PI

int main(){
  int n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  REP(i, n){
    cin >> a[i];
    sum += a[i];
  }
  SORT(a, n);
  cout << a[0] << " " << a[n - 1] << " " << sum << endl;
}



Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] c = new int[10][10];
		int[][] A = new int[h][w];
		for(int i = 0 ; i < 10 ; i++) {
			for(int j = 0 ; j < 10 ; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for(int k = 0 ; k < 10 ; k++) {
			for(int i = 0 ; i < 10 ; i++) {
				for(int j = 0 ; j < 10 ; j++) {
					c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}
		int ans = 0;
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				if(A[i][j] == -1 || A[i][j] == 1) continue;
				ans += c[A[i][j]][1];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 47148
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn counting_sort(a: &Vec<usize>) -> Vec<usize> {
    let mut count = vec![0; 10001];
    for &index in a.iter() {
        count[index] += 1;
    }

    for index in 1..count.len() {
        count[index] += count[index - 1]
    }

    let mut b = vec![0; a.len()];
    for &index in a.iter().rev() {
        b[count[index] -1] = index;
        count[index] -= 1;
    }

    return b;
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n)
        .map(|_| {
            let number: usize = read();
            number
        })
        .collect();
    let b = counting_sort(&a);
    for (index, number) in b.iter().enumerate() {
        if (index + 1) != b.len() {
            print!("{} ", number);
        } else {
            println!("{}", number);
        }
    }
}



Measured memory_bytes: 37796
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e15
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// ビット数を取得 
ll bitcount(ll bitPtn)
{
	ll res = 0;
	for (ll i = 0; i < 60; ++i)
	if (bitPtn & ((ll)1 << i)) {
		++res;
	}
	return res;
}

int main()
{
	ll A, B, N;
	cin >> A >> B >> N;

	N = min(B - 1, N);
	ll ans = A * N / B;

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,L,R;
  string Left,Balanced,Right;
  cin>>A>>B>>C>>D;
  L=A+B;
  R=C+D;
  if(L>R){
    cout<<"Left"<<endl;
  }
  if(L==R){
    cout<<"Balanced"<<endl;
  }
  if(L<R){
    cout<<"Right"<<endl;
  }
}


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

using namespace std;
int n, k, A[N], F[100005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i];
    for(int i=0; i<=k; i++)
    {
        F[i]=0;
        for(int j=1; j<=n; j++)
        {
            if(i<A[j]) break;
            if(F[i-A[j]]==0)
            {
                F[i]=1;
                break;
            }
        }
    }
    if(F[k]==1) return cout<<"First", 0;
    cout<<"Second";
    return 0;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int sum_func(vector<int> a){
  int sum=0;
  for(int i=0;i<a.size();i++){
    sum+=a[i];
  }
  return sum;
}

void output(vector<int> a,vector<int> b){
  int avg=(sum_func(a)+sum_func(b))/2;
  int a_sum=sum_func(a);
  for(int i=0;i<a.size();i++){
    for(int j=0;j<b.size();j++){
      if(a_sum-a[i]+b[j]==avg){
        cout<<a[i]<<" "<<b[j]<<endl;
        return;
      }
    }
  }
  cout<<-1<<endl;
  return;
}
int main(){
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    vector<int> a(n),b(m),c(n+m);
    for(int i=0;i<n;i++){
      cin>>a[i];
      c[i]=a[i];
    }
    for(int i=0;i<m;i++){
      cin>>b[i];
      c[n+i]=b[i];
    }
    int sum=sum_func(c);
    if(sum%2!=0){
      cout<<-1<<endl;
      continue;
    }
    sort(a.begin(),a.end());
    int avg=sum/2;
    output(a,b);
  }
  return 0;
}



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int dp[n+2];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    //cout<<"dp[1] is "<<dp[1]<<endl;
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
import bisect

keys=[]

q=int(input())
d={}

def find(x):
    index=bisect.bisect_left(keys,x)
    if index==len(keys):
        return -1
    if keys[index]==x:
        return index
    else:
        return -1


for _ in range(q):
    query=input().split(" ")
    if query[0]=="0":
        if find(query[1])!=-1:
            item=d[query[1]]
        else:
            bisect.insort_left(keys, query[1])
            item=[]
        item.append(query[2])
        d[query[1]]=item
    elif query[0]=="1":
        if find(query[1])!=-1:
            for item in d[query[1]]:
                print(item)
    elif query[0]=="2":
        while find(query[1])>=0:
            keys.pop(find(query[1]))
    else:
        L,R=query[1],query[2]
        indL=bisect.bisect_left(keys,L)
        indR=bisect.bisect_right(keys,R)
        for s in keys[indL:indR]:
            for item in d[s]:
                print(s,item)



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
    string ss, t;

    cin >> ss >> t;

    for(int i = ss.size() - t.size(); i >= 0; i--){
        int count = 0;
        REP(j,t.size()){
            if(ss[i+j] == '?' || ss[i+j] == t[j]){
                count++;
            }
        }
        if(count == t.size()){
            ss.replace(i, t.size(), t);
            replace(ss.begin(),ss.end(), '?', 'a');
            cout << ss << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, q; 
vector<vector<int>> G;
vector<ll> a, V;

void dfs(int v, int from) {
    V[v] = a[v] + V[from];
    for (const auto nv: G[v]) {
        if(nv == from) continue;
        dfs(nv, v);
    }
    return;
}

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

    cin >> n >> q;
    G.resize(n);
    V.assign(n, 0);
    rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    a.resize(n, 0);
    rep(i, q) {
        ll x, y; cin >> x >> y;
        x--;
        a[x] += y;
    }

    dfs(0, 0ll);

    for(const auto& v: V) cout << v << " ";
    cout << endl;
}


Measured memory_bytes: 25856
n,a,b = map(int, input().split())
p = 7 + 10**9


def permMOD(MOD, N, R=-1):
    from functools import reduce as r
    if R==-1: R=N
    return r(lambda x,y: x*y%MOD, range(N, N-R, -1))


def combMOD(MOD, N, R):
    return permMOD(MOD, N, R) * pow(permMOD(MOD, R), MOD-2, MOD) % MOD


print((pow(2,n,p) - combMOD(p,n,a) - combMOD(p,n,b) - 1) % p)

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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = INF;
    rep(i,n) cin >> a[i];
    for(int i = -100;i <= 100;i++){
        int sum = 0;
        rep(j,n){
            sum += (a[j] - i)*(a[j] - i);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		var list = enum_div(B);
		list.Sort();
		long ans = 1;
		for(var i=0;i<list.Count;i++){
			if(list[list.Count-1-i] <= B / A){
				ans = list[list.Count-1-i];
				break;
			}
		}
		Console.WriteLine(ans);
	}
	
	public static List<long> enum_div(long n){
		var list = new List<long>();
		for(var i=1;i*i<=n;i++){
			if(n%i==0){
				list.Add(i);
				if(i*i!=n){
					list.Add(n/i);
				}
			}
		}
		return list;
	}
}

Measured memory_bytes: 13396
N, M = map(int, input().split())

ans = 0

# 最初からある「S」を使って作れるだけ「Scc」を作る
# 「c」の1/2より「S」の方が多い場合、作れるだけ「Scc」を作って終わり
if N > M/2:
    ans += M//2
    N -= M//2
    M = M % 2
    print(ans)
    exit(0)

# 「c」の方が多い時
# 「S」を使い切る
ans += N
M -= N*2
N = 0

# 残った「c」から作れるだけ「Scc」を作る
ans += M//4
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool check(ll y){
    ll x=sqrt(y);
    for(ll i=x-1;i<=x+1;i++){
        if(i*i == y)
            return true;
        }
        return false;
}   
int main()
{
    ll n,a,b,d,i,j,k,x;
    cin>>n>>d;
    int v[200][200];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            cin>>v[i][j];
        }
        
    }
    ll sum=0,cnt=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            ll sum=0;
            for(k=0;k<d;k++){
                sum = sum+ ((v[i][k]-v[j][k])*(v[i][k]-v[j][k]));
                
            }
            if(check(sum))
                    cnt++;
                    
        }
    }
    cout<<cnt;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int extgcd(int a,int b,int&x,int&y){
    int d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;
        y=0;
    }
    return d;
}
int mod_div(int a,int b){
    int x,y;
    extgcd(b,mod,x,y);
    int inv=(mod+x%mod)%mod;
    return a*inv%mod;
}
vector<int>G[200000];
int n,ans[200000],dp[200000],cnt[200000],fact[200000];
void dfs1(int idx,int par){
    dp[idx]=1;
    for(int&to:G[idx]){
        if(to==par)
            continue;
        dfs1(to,idx);
        (dp[idx]*=mod_div(fact[cnt[to]],dp[to]))%=mod;
        cnt[idx]+=cnt[to];
    }
    dp[idx]=mod_div(fact[cnt[idx]],dp[idx]);
    cnt[idx]++;
}
void dfs2(int idx,int c_par,int d_par,int par){
    ans[idx]=1;
    for(int&to:G[idx]){
        if(to==par)
            (ans[idx]*=mod_div(fact[c_par],d_par))%=mod;
        else
            (ans[idx]*=mod_div(fact[cnt[to]],dp[to]))%=mod;
    }
    for(int&to:G[idx]){
        if(to==par)
            continue;
        dfs2(to,n-cnt[to],mod_div(fact[n-1-cnt[to]],ans[idx])*mod_div(fact[cnt[to]],dp[to]%mod),idx);
    }
    ans[idx]=mod_div(fact[n-1],ans[idx]);
}
signed main(){
    int a,b;
    cin>>n;
    while(cin>>a>>b){
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(n==2){
        cout<<1<<endl<<1<<endl;
        return 0;
    }
    fact[0]=1;
    for(int i=1;i<n;i++)
        fact[i]=fact[i-1]*i%mod;
    int root=0;
    for(int i=0;i<n;i++)
        if(G[i].size()>=2)
            root=i;
    dfs1(root,-1);
    dfs2(root,1333,1333,-1);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

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


  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll pu=0;
  ll mi=0;
  //  ll nibeki[n];
  //  nibeki[0]=1;
  //  rep1(i,n-1) nibeki[i] = mu(nibeki[i-1],2);

  ll kai[n+1];
  kai[0]=1;
  rep1(i,n) kai[i]=mu(kai[i-1],i);
  ll inv[n+1];
  rep(i,n+1) inv[i] = dv(1,kai[i]);
    
  rep(i,n){
    if(i>=k-1)pu = ad(pu,mu(a[i],mu(mu(kai[i],inv[k-1]),inv[i-k+1] )));
    if(n-1-i>=k-1)mi = ad(mi,mu(a[i],mu(mu(kai[n-1-i],inv[k-1]),inv[n-i-k])));
    //    cout << "pu mi " << pu << " " << mi << endl;
    //    cout << "kai[i]* inv[k-1] " << mu(kai[i],inv[k-1]) << endl;
    //    cout << "kai[i]* inv[k-1] " << kai[i]<<" " <<inv[k-1] << endl;
  }

  ll ans = (pu - mi + mod)%mod;
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>

#define X first
#define Y second

using namespace std;

const int MAX = 450;
const double EPS = 1e-9;

typedef pair<int,int> P;
vector<P> V;
bool come[MAX];


double dot(P a, P b){
  return a.X*b.X+a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y-a.Y*b.X;
}

double getLength(P pre, P nex){
  return sqrt((pre.X-nex.X)*(pre.X-nex.X)+(pre.Y-nex.Y)*(pre.Y-nex.Y));
}

double getAngle(P pre, P nex){
  return acos(dot(pre,nex)/(getLength(pre,P(0,0))*getLength(nex,P(0,0))));
}

bool ccw(P p0, P p1, P p2){
  P a = P(p1.first-p0.first,p1.second-p0.second);
  P b = P(p2.first-p0.first,p2.second-p0.second);
  return (cross(a,b) > EPS);
}


P Pminus(P a, P b){
  a.first -= b.first;
  a.second -= b.second;
  return a;
}


void solve(){

  sort(V.begin(),V.end());

  double ans = getLength(P(0,0),V[0]);

  P pre = P(0,0);
  P now = V[0];

  int roop = V.size()-1;

  while(roop--){
    int nex = -1;
    double nexTheta;

    for(int i = 1; i < V.size(); i++){
      if(come[i]) continue;
   
      //  if(ccw(pre,now,V[i])) continue;
   
      if(nex == -1){
	nex = i;
	nexTheta = getAngle(Pminus(V[i],now),Pminus(now,pre));
	continue;
      }


      double theta = getAngle(Pminus(now,pre),Pminus(V[i],now));
      
      if(fabs(nexTheta-theta) > EPS && nexTheta > theta){
	  nex = i;
	  nexTheta = theta;
      } 
      if(fabs(nexTheta-theta) < EPS && getLength(now,V[nex]) > getLength(now,V[i])){
	nex = i;
	nexTheta = theta;
      }
    }

    //cout << nex << endl;

    //  cout <<nex << " " <<  V[nex].X << " " << V[nex].Y << endl;
    come[nex] = true;

    ans += getLength(now,V[nex]);
    pre = now;
    now = V[nex];
  }
  printf("%.1f\n",ans);
}

int main(){

  int n;
  while(cin >> n && n){
    memset(come,false,sizeof(come));
    V.resize(n);
    for(int i = 0; i < n; i++) cin >> V[i].X >> V[i].Y;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1304
N=int(input())
pn=list(map(int,input().split()[:N]))
an=list(range(1,N+1))

con=[(x-y)!=0 for (x,y) in zip(pn,an)].count(True)
if con==2 or con ==0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_T 50
#define WIDTH 20000
pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH];
vector<vector<int>>X;
int hantei(vector<vector<int>>a) {
	int sum = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			int Num = (a[i][j] + 15) % 16; if (a[i][j] == 0)continue;
			sum += abs(i - (Num / 4)) + abs(j - (Num % 4));
		}
	}
	return sum;
}
int main() {
	for (int i = 0; i < 4; i++) {
		vector<int>FF; for (int j = 0; j < 4; j++) { int p; cin >> p; FF.push_back(p); }
		X.push_back(FF);
	}
	E[0][0] = make_pair(hantei(X), X);
	for (int i = 0; i < MAX_T; i++) {
		int CNT = 0;
		if (E[i][0].first == 0) { cout << i << endl; break; }
		for (int j = 0; j < WIDTH; j++) {
			if (E[i][j].second.size() == 0)break;
			int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
			vector<vector<int>>H = E[i][j].second; int I = E[i][j].first;
			int C = 0;
			for (int k = 0; k < 16; k++) {
				if (H[k / 4][k % 4] == 0) {
					C = k;
				}
			}
			for (int k = 0; k < 4; k++) {
				vector<vector<int>>J = H;
				int Ex = (C / 4) + dx[k], Ey = (C % 4) + dy[k];
				if (Ex < 0 || Ex > 3 || Ey < 0 || Ey > 3)continue;
				swap(J[C / 4][C % 4], J[Ex][Ey]);
				D[CNT] = make_pair(hantei(J), J); CNT++;
			}
		}
		sort(D, D + CNT); E[i + 1][0] = D[0]; int cnt2 = 1;
		for (int k = 1; k < CNT; k++) {
			if (D[k - 1] == D[k])continue;
			E[i + 1][cnt2] = D[k]; cnt2++;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26,K=23;

int d;
int c[A],s[D][A],last[A];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*min(K,d-i)>
               s[i][best]+c[best]*(i-last[best])*min(K,d-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
    int n,m; cin >> n >> m;
    int a[50]={0}; int b[50]={0};
    rep(i,m) cin >> a[i] >> b[i];
    int cnt[51]={0};
    rep(i, m){
        cnt[a[i]--]++;
        cnt[b[i]--]++;
    }
    for(int i=1;i<=n;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}


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

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}

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

from collections import deque
import heapq
import math
import bisect


def main():
    N, K = map(int, input().split())
    dp = [0] * 200005

    for i in range(K-1, 0, -1):
        if 2 * i >= K:
            dp[i] = 0.5
        else:
            dp[i] = 0.5 * dp[2*i]

    ans = max(0, N-K+1) / N
    for i in range(1, min(N+1, K)):
        ans += dp[i] / N

    print("{:.10f}".format(ans))


if __name__ == '__main__':
    main()


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, u, v;
  cin >> n >> u >> v;
  --u, --v;
  vector< vector<int> > g(n);
  for (int _ = n - 1; _--; ) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> d(n), par(n);
  auto dfs = [&](auto&& self, int v, int p) -> void {
    par[v] = p;
    for (int u : g[v]) {
      if (u != p) {
        d[u] = d[v] + 1;
        self(self, u, v);
      }
    }
  };
  dfs(dfs, v, -1);
  int x = (d[u] - 1) / 2;
  while (x--) {
    u = par[u];
  }
  int mx = 0;
  {
    auto dfs = [&](auto&& self, int v, int p) -> void {
      mx = max(mx, d[v]);
      for (int u : g[v]) {
        if (u != p) {
          self(self, u, v);
        }
      }
    };
    dfs(dfs, u, par[u]);
  }
  cout << mx - 1 << '\n';
}


Measured memory_bytes: 9216
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b){
    ll t = gcd(a, b);
    return (a / t * b);
}

int main(){

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

    int N; cin >> N;
    ll ans = 1LL;
    for (int i = 0; i < N; ++i) {
        ll t;
        cin >> t;
        ans = lcm(ans,t);
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
n,m = (input().split())
n,m = int(n),int(m)
X = [int(x) for x in input().split()]

X.sort()
difX = [abs(i-j) for i,j in zip(X[1:],X[:-1])]
difX.sort()
if n == 1:
    ans = sum(difX)
else:
    ans = sum(difX[:-(n-1)])
print(ans)

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

int main() {
  vector<char>S(3);
  for(int i=0; i<3; i++){
    cin>>S.at(i);
  }
  if(S.at(0)!=S.at(1)&&S.at(0)!=S.at(2)&&S.at(1)!=S.at(2))
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    double s = 0;
    rep(i, N - 1) {
        for (int j = i + 1; j < N; j++) {
            s += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    cout << setprecision(20) << s * 2 / N << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
 
    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
 
    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
 
    return true;
}
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >>n>> x;
    vint(A, n);
    SORT(A);
    REP(i,n){
        if (x - A[i]>=0){
            x -= A[i];
          a=i+1;
        }else break;
    }if(a!=n)cout << a<<endl;
  else  if(a==n&&x==0)cout << a<<endl;
  else cout << a-1<<endl;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main() {
    string s;
    cin >> s;
    int first = stoi(s.substr(0,2));
    int second = stoi(s.substr(2,4));
    auto ok = [&](int x) {
        return (x >= 1 && x <= 12);
    };
    if (ok(first) && ok(second))
        cout << "AMBIGUOUS" << endl;
    else if (ok(first) && !ok(second))
        cout << "MMYY" << endl;
    else if (!ok(first) && ok(second))
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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



int cnt[MAXN];
bool flag = true;
int main() {
    int n;
    cin >> n;
    int tmp;
    rep(i, n) {
        cin >> tmp;
        ++cnt[tmp];
    }

    if (n%2 == 1) {
        for(int i=2; i<n; i+=2) {
            if (cnt[i] != 2) {
                flag = false;
                break;
            }
        }
        if (cnt[0] != 1) flag = false;

    } else {
        for(int i=1; i<n; i+=2) {
            if (cnt[i] != 2) {
                flag = false;
                break;
            }
        }
    }

    ll ans = 1;

    if (flag) {
        for(int i=0; i<(n/2); ++i) {
            ans *= 2;
            ans %= mod;
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1;i < N + 1;i++){
        int cnt = 0;
        if(i % 2 == 1){
            for(int j = 1;j < N + 1;j++){
                if(j % 2 == 1){
                    if(i % j == 0 && i >= j){
                        cnt++;
                    }
                }
            }
            if(cnt == 8) ans++;
        }
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

char fi[100][100];

int main(){
    int a,b; cin >> a >> b;
    cout << 100 << " " << 100 << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(i<50)fi[i][j]='#';
            else fi[i][j]='.';
        }
    }
    a--; b--;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if(a==0)break;
            if(i%2==0&&j%2==0){
                fi[i][j]='.';
                a--;
            }
        }
        if(a==0)break;
    }
    for(int i=51;i<100;i++){
        for(int j=0;j<100;j++){
            if(b==0)break;
            if(i%2==0&&j%2==0){
                fi[i][j]='#';
                b--;
            }
        }
        if(b==0)break;
    }
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << fi[i][j];
        }
        cout << endl;
    }
}

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

int main() {
  stack<long>st;
  while(true){
    string t;
    int a;
    cin >> t;
    if(t.size() == 0) break;
    if(t != "+" &&(t != "-" && t != "*")){
      a = stoi(t);
      st.push(a);
    }
    else{
      if(t == "+"){
        int sum;
        sum = st.top();
        st.pop();
        sum += st.top();
        st.pop();
        st.push(sum);
      }
      if(t == "-"){
        int sum;
        sum = -1*st.top();
        st.pop();
        sum += st.top();
        st.pop();
        st.push(sum);
      }
      if(t == "*"){
        int sum;
        sum = st.top();
        st.pop();
        sum *= st.top();
        st.pop();
        st.push(sum);
      }
    }
  }
  cout << st.top() << endl;
}



Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {

  char x;

  scanf("%c", &x);

  if (x == 'a' || x == 'i' || x == 'e' || x == 'o' || x == 'u')
    printf("vowel\n");
  else
    printf("consonant\n");

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll K;
    cin >> K;
    for (ll i = 0; i < K; i++) {
        cout << "ACL"; 
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Point{double x,y;};
struct Vec{double x,y; Vec(Point p1,Point p2) {x=p2.x-p1.x; y=p2.y-p1.y;}};
double dot(Vec v1,Vec v2) {return v1.x*v2.x+v1.y*v2.y;}
double len(Vec v) {return sqrt(dot(v,v));}
double cos(Vec v1,Vec v2) {return dot(v1,v2)/(len(v1)*len(v2));}
Point operator+(Point p,Vec v) {p.x+=v.x; p.y+=v.y; return p;}
double dist(Point p1,Point p2) {return len(Vec(p1,p2));}
Vec operator*(Vec v,double i) {v.x*=i; v.y*=i; return v;}
int main(){
  Point p1,p2; cin>>p1.x>>p1.y>>p2.x>>p2.y;
  ll q; cin>>q;
  REP(i,q){
    Point p; cin>>p.x>>p.y;
    Vec a(p1,p), b(p1,p2);
    Point ans=p1+b*(dot(a,b)/dot(b,b));
    printf("%.12f %.12f\n",ans.x,ans.y);
  }
}

Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	while (true)
	{
		double a1, b1, c1, a2, b2, c2;
		cin >> a1>> b1 >> c1 >> a2 >> b2 >> c2;
		if (cin.fail())
			break;
		double D = a1 * b2 - a2 * b1;
		double D1 = c1 * b2 - c2 * b1;
		double D2 = a1 * c2 - a2 * c1;
		double x = D1 / D;
		double y = D2 / D;
		if (x == 0) x = 0;
		if (y == 0) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
}


Measured memory_bytes: 3056
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			for(int i=0;i<3;i++){
				char s[] = sc.next().toCharArray();
				if(s[0] == '0') return;

				int a=0, b=0;
				for(int j=1;j<s.length;j++){
					if(s[j] == 'A') a++;
					else b++;
				}
				if(a > b) a++; else b++;
				System.out.println(a + " " + b);
			}
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<lli,lli> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){__
int k;
    int arreglo[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>k;
    cout<<arreglo[k-1]<<endl;
}

Measured memory_bytes: 256
#line 1 "dinic.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A"
#line 1 "/workspaces/compro/lib/flow/dinic.hpp"

#include <functional>
#include <limits>
#include <queue>
#include <vector>

#ifndef DINIC
#define DINIC

template <typename T> struct Edge {
  int to;
  T cap;
  int rev; // 逆向きの辺のidx
};

template <typename T> class Dinic {
private:
  int n;
  std::vector<std::vector<Edge<T>>> g;
  std::vector<int> distance; // 辺の重みを1としたときの距離
  std::vector<int> next_idx; // 各頂点から出る辺についてどこまでチェックしたか

public:
  Dinic(int n) : n(n), g(n), distance(n), next_idx(n) {}

  void add_edge(int from, int to, T cap) {
    g[from].push_back({to, cap, static_cast<int>(g[to].size())});
    g[to].push_back({from, 0, static_cast<int>(g[from].size()) - 1});
  }

  // sからtへの最大流を計算する
  T calc(int s, int t) {
    T ans(0);
    for (int i = 0; i < n; i++) {
      bfs(s);
      if (distance[t] < 0)
        return ans;
      for (auto &el : next_idx) {
        el = 0;
      }
      while (true) {
        T f = dfs(s, t, std::numeric_limits<T>::max());
        if (f <= 0)
          break;
        ans += f;
      }
    }
    return ans;
  }

private:
  void bfs(int s) {
    for (int i = 0; i < n; i++) {
      distance[i] = -1;
    }

    std::queue<int> q;
    distance[s] = 0;
    q.push(s);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (const auto &ne : g[v]) {
        if (ne.cap > 0 && distance[ne.to] < 0) {
          distance[ne.to] = distance[v] + 1;
          q.push(ne.to);
        }
      }
    }
  }

  // vからtに向かう際に流せる量を調べる
  T dfs(int v, int t, T f) {
    if (v == t)
      return f;
    for (int i = next_idx[v]; i < static_cast<int>(g[v].size()); i++) {
      auto &edge = g[v][i];
      if (edge.cap > 0 && distance[v] < distance[edge.to]) {
        T d = dfs(edge.to, t, std::min(f, edge.cap));
        if (d > 0) {
          edge.cap -= d;
          g[edge.to][edge.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
};

#endif
#line 3 "dinic.test.cpp"
#include <iostream>

int main() {
  int v, e;
  std::cin >> v >> e;
  Dinic<int> dinic(v);
  for (int i = 0; i < e; i++) {
    int u, v, c;
    std::cin >> u >> v >> c;
    dinic.add_edge(u, v, c);
  }

  std::cout << dinic.calc(0, v - 1) << std::endl;

  return 0;
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vl p,b;
ll bfs(ll n,ll x){ //パティの数を返す
  if(x == 0)return 0;
  else if(n == 0)return 1;
  else if(x == 1)return 0;
  else if(x < (1 + b[n-1]) )return bfs(n-1, x-1);
  else if(x == (1 + b[n-1]) )return p[n-1];
  else if(x == (2 + b[n-1]) )return p[n-1]+1;
  else if(x < (2*b[n-1] + 3) )return (p[n-1] + 1 + bfs(n-1,x-b[n-1]-2) );
  else if(x == (2*b[n-1] + 3) )return 2*p[n-1]+1;
  else return 0;
}
signed main()
{
  gearup;
  ll n,x; cin >> n >> x;

  p.resize(n+1);
  b.resize(n+1);
  p[0] = 1;
  b[0] = 1;
  rep(i,n)p[i+1] = p[i]*2 + 1;
  rep(i,n)b[i+1] = b[i]*2 + 3;
  ll res = bfs(n,x);
  out(res);
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	long long n,m;
	cin>>n>>m;
	
	if(n==1&&m==1)
		cout<<1<<endl;
	else if(n==1||m==1)
		cout<<n*m-2<<endl;
	else
		cout<<(n-2)*(m-2)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int x, y; scanf("%d %d", &x, &y);
    int tmp;
    
    while ( y != 0) { /* (x, y) を (y, x%y) で置き換える．y=0 になるまで */
        tmp = y;
        y = x%y;
        x = tmp;
    }
    printf("%d\n", x);
    
    return 0;
}


Measured memory_bytes: 2104