akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

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

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    vector<vector<ll>> c(51, vector<ll>(51));
    for(int i = 0; i <= 50; i++) c[i][0] = 1, c[i][i] = 1;
    for(int i = 1; i <= 50; i++){
        for(int j = 1; j < i; j++){
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }


    int n, a, b;
    cin >> n >> a >> b;

    vector<ll> v(n);
    map<ll, int> cnt;
    for(int i = 0; i < n; i++) cin >> v[i], cnt[v[i]]++;
    gsort(v);

    if(v[0] != v[a - 1]){
        ld sum = 0;
        for(int i = 0; i < a; i++) sum += v[i];
        cout << fixed << setprecision(20) << sum / a << "\n";
        int tmp = 0;
        for(int i = 0; i < a; i++) if(v[i] == v[a - 1]) tmp++;
        cout << c[cnt[v[a - 1]]][tmp] << "\n";
    }
    else{
        cout << v[0] << "\n";
        ll ans = 0;
        for(int i = a; i <= b; i++) ans += c[cnt[v[a - 1]]][i];
        cout << ans << "\n";
    }

    return 0;
}

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, readline().split())
m = map(int,read().split())
fb = list(zip(m,m))

AB = fb[:M]
CD = fb[M:]
uf = UnionFind(N+1)
friends = [[] for i in range(N+1)]
for a, b in AB:
    uf.union(a, b)
    friends[a].append(b)
    friends[b].append(a)

blocks = [[] for i in range(N+1)]
for c, d in CD:
    blocks[c].append(d)
    blocks[d].append(c)

ans = []
for i in range(1, N+1):
    same_tree_size = uf.size(i)
    same_tree_block = 0
    for x in blocks[i]:
        same_tree_block += uf.same(i, x)
    n_friends = len(friends[i])
    # 「同じグループに所属する人の数」 には、iと直接友達の人、
    # iがブロックしている人i本人も含まれている
    # よって、以下でiの友達候補の人数が分かる
    # 同じグループに所属する人の数 - 同じグループ内にいるiがブロックしている人の数
    #   - 友達の数 - 1(自分)
    ans.append(str(same_tree_size - same_tree_block - n_friends - 1))

print(' '.join(ans))

Measured memory_bytes: 64604
#include <stdio.h>
int main(){
  int w,h,n,i;
  scanf("%d %d %d",&w,&h,&n);
  int x[n],y[n],a[n];
  int max1=0,min2=w,max3=0,min4=h;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&x[i],&y[i],&a[i]);
  }
  for(i=0;i<n;i++){
    switch(a[i]){
    case 1: if(max1<x[i]){
        max1=x[i];
      }
      break;
    case 2: if(min2>x[i]){
        min2=x[i];
      }
      break;
    case 3: if(max3<y[i]){
        max3=y[i];
      }
      break;
    case 4: if(min4>y[i]){
        min4=y[i];
      }
      break;
    }
  }
    h=min2-max1;
    w=min4-max3;
    int s=h*w;
    if(h<0||w<0){
      printf("%d\n",0);
    }else{
      printf("%d\n",s);
    }
   return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
		a[x+1]++;
		a[x+2]++;
	}
	sort(a,a+100005);
	cout<<a[100004];
	return 0;
}

Measured memory_bytes: 640
from bisect import bisect_right
n = input()
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(len(l)-2):
  for j in range(i+1, len(l)-1):
    ind = bisect_right(l, l[i] + l[j] - 1)
    s += max(ind - j - 1, 0)
print(s)

Measured memory_bytes: 3188
n = gets.to_i
n.times do
    b = Array.new
    while b.length < 9
        b += gets.split.map{|e| e.to_i(16)}
    end
    key = 0
    32.times do |i|
        s = 0
        8.times do |k|
            s += b[k]
        end
        if (s & (1 << i) != b[8] & (1 << i))
            key |= 1 << i
        end
        9.times do |j|
            b[j] ^= (key & 1 << i)
        end
    end
    puts key.to_s(16)
end

Measured memory_bytes: 6116
#include <cstdio>
#include <algorithm>
#define MAX_N 1000
#define MAX_W 1000
using namespace std;
int W;
int N; 

int w[MAX_N]; 
int v[MAX_N]; 
int dp[MAX_N + 1][MAX_W + 1];
bool input() 
{
  scanf("%d", &W);
  if(!W) return false;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) 
  {
    scanf("%d,%d", &v[i], &w[i]);
  }
  return true;
}
void solve() 
{

  for (int i = 0; i < N; i++) 
  {
    for (int j = 0; j <= W; j++) 
    {
      if (j < w[i])
      {
        dp[i + 1][j] = dp[i][j];
      } 
      else 
      {
        dp[i + 1][j] = (short)max((int)dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
}

int main() 
{

  int cnt = 0;

  while (input())
  {
    solve();
    int i;
    for (i = W; i >= 0; i--) 
    {
      if (dp[N][W] != dp[N][i]) break;
    }
    printf("Case %d:\n", ++cnt);
    printf("%d\n", dp[N][W]);
    printf("%d\n", i + 1);
  }

  return 0;
}

Measured memory_bytes: 4948
#include<bits/stdc++.h>
//clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 2333333
	typedef long long ll;
	typedef double db;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
//	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
//	void file()
//	{
//		#ifndef ONLINE_JUDGE
//		freopen("a.in","r",stdin);
//		#endif
//	}
//	inline void chktime()
//	{
//		#ifndef ONLINE_JUDGE
//		cout<<(clock()-t)/1000.0<<'\n';
//		#endif
//	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;
ll a[sz],top;
ll f[sz];
ll ans[sz];

void calc(int cur,ll p,ll w)
{
	while (233)
	{
		if (a[1]>p) { ans[1]+=w,ans[p+1]-=w; return; }
		int pos=upper_bound(a+1,a+cur,p)-a-1;
		f[pos]+=(p/a[pos])*w;
		p%=a[pos];cur=pos;
	}
}

int main()
{
//	file();
	read(n),read(m);
	a[top=1]=n;
	ll x;
	rep(i,1,m)
	{
		read(x);
		while (top&&a[top]>=x) --top;
		a[++top]=x;
	}
	m=top;
	f[m]=1;
	drep(i,m-1,1)
	{
		f[i]+=f[i+1]*(a[i+1]/a[i]);
		ll p=a[i+1]%a[i];
		calc(i,p,f[i+1]);
	}
	rep(i,1,a[1]) ans[i]+=ans[i-1];
	rep(i,1,a[1]) printf("%lld\n",ans[i]+f[1]);rep(i,a[1]+1,n) puts("0");
	return 0;
}

Measured memory_bytes: 12672
#include <stdio.h>

int main(void) {
	int N, L[2000];
	scanf("%d", &N);
	for (int i=0; i<N; i++) scanf("%d", &L[i]);
	int count = 0;
	for (int i=0; i<N; i++) for (int j=0; j<i; j++) for (int k=0; k<j; k++) {
		if (L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]) ++count;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int H,W,h,w;
  1<=H<=20;
  1<=W<=20;
  1<=h<=H;
  1<=w<=W;
  scanf("%d",&H);
  scanf("%d",&W);
  scanf("%d",&h);
  scanf("%d",&w);
  printf("%d",(H-h)*(W-w));
  return 0;
}
  

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")


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


typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000007;



int solve( ){

int n,k;
cin>>n>>k;
if(k==1)
cout<<0;
else 
cout<<n-k;


return 0;
}


signed main()
{  int t=1;

 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    


  clock_t time_req;

    // Without using pow function
                                                                                                                   
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
  }


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

    public static void swap(int x, int y) {
        int tmp = x;
        x = y;
        y = tmp;
    }

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

        String w = sc.next();
        int ans = 0;
        while (true) {
            String t = sc.next();
            if (t.equals("END_OF_TEXT")) {
                break;
            }
            if (t.equalsIgnoreCase(w)) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}


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

int main() {
    int N;
    cin>>N;
    int F[N][10];
    long P[N][11];
    for(int i=0;i<N;++i){
        for(int j=0;j<10;++j){
            cin>>F[i][j];
        }
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<11;++j){
            cin>>P[i][j];
        }
    }

    long ans;
    long tmpans;  

    // bit全探索
    for(int bit=1;bit<(1<<10);++bit){
        tmpans = 0;
        vector<int> S;
        for(int i=0;i<10;++i){
            if(bit & (1<<i)) S.push_back(i);
        }
        /**
        for(int i=0;i<S.size();++i){
            cout<<S[i]<<" ";;
        }
        cout<<endl;
        **/
        int num[N];
        for(int i=0;i<N;++i){
            num[i] = 0;
        }
        for(int i=0;i<N;++i){
            for(int j=0;j<S.size();++j){
                num[i] += F[i][S[j]];
            }
        }
        /**
        for(int i=0;i<N;++i){
            cout<<num[i]<<" ";
        }
        cout<<endl;
        **/
        for(int i=0;i<N;++i){
            tmpans += P[i][num[i]];
        }
        if(bit==1) ans = tmpans;
        if(ans < tmpans) ans = tmpans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

cnt = 0
ans = 0
for i in range(len(a)):
    if i % 2 == 1:
        ans += a[i]
        cnt += 1
    if cnt == n:
        break
print(ans)


Measured memory_bytes: 37084
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 3e5 + 5;
ll a, b, c;
ll k;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    if(!(k & 1LL)){
        cout << a - b << endl;
    }
    else{
        cout << b - a << endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	int x,a;
	ll ans=0;
	cin>>x>>a;
	if(x<a)
		cout<<0<<endl;
	else
		cout<<10<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);*/

	int n;
	cin >> n;
	cout << 0 << endl;
	int left = 0, right = n, mid;
	string t;
	cin >> t;
	vector<int> check(n);
	if (t == "Vacant") return 0;
	if (t == "Male") check[0] = 0;
	else check[0] = 1;
	rep(_, 30) {
		mid = (left + right) / 2;
		cout << mid << endl;
		string s;
		cin >> s;
		if (s == "Vacant") return 0;
		if (s == "Male") {
			if (check[left] == 0 && (left + mid) & 1) right = mid;
			else if (check[left] == 1 && !((left + mid) & 1)) right = mid;
			else left = mid;
			check[mid] = 0;
		}
		else {
			if (check[left] == 1 && (left + mid) & 1) right = mid;
			else if (check[left] == 0 && !((left + mid) & 1)) right = mid;
			else left = mid;
			check[mid] = 1;
		}
	}
}

Measured memory_bytes: 1236
#include<iostream>
#include<map>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
  int n,a,a2;
  std::cin >> n;
  std::map<int, int> ch;

  for (int i = 0; i < n; i++) {
    std::cin >> a;
    ch[a]=i;
  }
  for (int i = 1; i <= n; i++) {
    std::cout <<(ch.find(i)->second)+1<<" ";
  }
  std::cout << '\n';


return 0;
}


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

using namespace std;
using ll = unsigned long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    int n; string s;
    cin >> n >>  s;
    for(int i = 0; i < s.size(); ++i){
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}



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;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
 
int main(){
  string x;
  cin >> x;
  ll n = x.size();
  ll y=0;
  rep(i,n){
    y+=x[i]-'0';
  }
  string ans="No";
  if(y%9==0) ans="Yes";
  cout << ans;
  return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define ri register int 
#define il inline
#define pairint pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define LL long long
#define gc getchar
template<class T>il void in(T &x)
{
    x=0;bool f=0;char c=gc();
    while(c<'0'||c>'9') 
    {
        if(c=='-') f=1;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=gc();
    if(f) x=-x;
} 
#undef gc
#define N 100005
#define M N<<1
int n,m;
int val[N];
int v[M],nx[M];
int head[N],cnte=1;
il void adde(int uu,int vv)
{
	v[++cnte]=vv,nx[cnte]=head[uu];
	head[uu]=cnte;
}
bool vis[N];
int cnt;
priority_queue<int,vector<int>,greater<int> > q[N];
void dfs(int x)
{
	q[cnt].push(val[x]);
	vis[x]=1;
	for(ri i=head[x];i;i=nx[i])
		if(!vis[v[i]]) dfs(v[i]);
}
signed main()
{
#ifdef M207
    freopen("in.in","r",stdin);
#endif
	in(n),in(m);
	for(ri i=1;i<=n;++i) in(val[i]);
	for(ri i=1,a,b;i<=m;++i)
	{
		in(a),in(b); ++a,++b;
		adde(a,b);adde(b,a);
	}
	for(ri i=1;i<=n;++i)
		if(!vis[i])
		{
			++cnt;
			dfs(i);
		}
	if(cnt==1)
	{
		puts("0");
		return 0;
	}
	LL ans=0;
	for(ri i=1;i<=cnt;++i)
	{
		ans+=q[i].top();
		q[i].pop();
		while(!q[i].empty()) q[0].push(q[i].top()),q[i].pop();
	}
	cnt-=2;
	if((int)q[0].size()<cnt) 
	{
		puts("Impossible");
		return 0;
	}
	while(cnt--) ans+=q[0].top(),q[0].pop();
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 7808
from functools import reduce
from math import gcd
def main():   
    n = int(input())
    A = list(map(int, input().split()))
    C = [0] * 1000001
    for a in A: C[a] += 1
    if reduce(gcd, A) != 1:
        print('not coprime')
    elif all(sum(C[i::i]) <= 1 for i in range(2, 1000001)):
        print('pairwise coprime')
    else:
        print('setwise coprime')

if __name__ == '__main__':
    main()



Measured memory_bytes: 127780
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_D
  * Array - Matrix Vector Multiplication
  */
object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, m) = io.StdIn.readLine().split(" ").map(_.toInt)
    val matrix = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n)
      .map(_.split(" ").map(_.toInt))
      .toVector // (.toSeq returns a lazy Stream)
    val vector = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(m)
      .map(_.toInt)
      .toVector
    matrix.map(_.zip(vector).foldLeft(0)((acc, x) => acc + (x._1 * x._2)))
      .foreach(println)
  }
}

Measured memory_bytes: 47420
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;

const int N = 100000;
inline void eratosthenes(bool prime[N]){
    REP(i, N) {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    REP(i, N) {
        if (prime[i]) {
            for (int j = i + i; j < N; j += i) {
                prime[j] = 0;
            }
        }
    }
}

int main() {
    bool prime[N];
    eratosthenes(prime);
    VI X;
    for (LL i = 3; i < N; i += 2) {
        if (prime[i] && prime[(i + 1) / 2]) {
            X.PB(i);
        }
    }
    VI S(N + 1);
    LL index = 0;
    FOR(i, 1, N + 1) {
        if (index < SZ(X) && i == X[index]) {
            S[i] = S[i - 1] + 1;
            index++;
        } else {
            S[i] = S[i - 1];
        }
    }
    LL Q;
    cin >> Q;
    REP(i, Q) {
        LL l, r;
        cin >> l >> r;
        cout << S[r] - S[l - 1] << endl;
    }
	
    return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = map(int, input().split())
a,b = map(int, input().split())
p = list(map(int, input().split()))

bottom=0
middle=0
upper=0
for pi in p:
  if pi <= a:
    bottom=bottom+1
  elif pi <= b:
    middle=middle+1
  else:
    upper=upper+1
print(min(bottom,min(middle,upper)))
  
  


Measured memory_bytes: 3060
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#include <sstream>
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)
using namespace std;
string getstring(char a)
{
       string s(1,a);
       return s;
}

int main()
        { 
        int c=0,m=0;
        bool t= true;
        char s[10];
        cin>>s;
        for(int i=0;s[i]!='\0';i++)
        {
        if((s[i]=='A' || s[i]=='C' ||s[i]=='G' ||s[i]=='T') && t)
        {
        c++;
        t=true;
        }
        else
        {
        m=max(c,m);
        c=0;
        }
        }
        m=max(c,m);
        cout<<m; 
        //system("pause");
        return 0;
        } 
        
        





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

using namespace std;
using ll = long long;

ll cutsToLEQ(vector<int> &arr, ll x) {
	ll ans = 0;
	for (int k : arr) ans += k / x + (k % x == 0 ? -1 : 0);
//	printf("%lld cuts to %lld\n", ans, x);
	return ans;
}

int main() {
	int n, k; scanf("%d %d", &n, &k);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
	ll lo = 1, hi = 1000000000;
	while (lo < hi) {
//		printf("%lld %lld\n", lo, hi);
		ll mid = (lo + hi) / 2;
		if (cutsToLEQ(arr, mid) <= k) hi = mid;
		else lo = mid + 1;
//		printf("%lld %lld\n", lo, hi);
	}
	printf("%lld\n", lo);
	return 0;
}


Measured memory_bytes: 4040
import java.io.*;
import java.nio.file.WatchEvent;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
    private static int HEIGHT;
    private static int WIDTH;
    private static int h, w;

    private static int solver() {

        return (HEIGHT * WIDTH)
                - (h*WIDTH)
                - (w*HEIGHT)
                + (h*w);

    }


    public static void main(String[] args) {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        try {
            String[] inputArray = br.readLine().split(" ");
            HEIGHT = Integer.parseInt(inputArray[0]);
            WIDTH = Integer.parseInt(inputArray[1]);
            inputArray = br.readLine().split(" ");
            h = Integer.parseInt(inputArray[0]);
            w = Integer.parseInt(inputArray[1]);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(solver());

    }
}

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

int N, C, A[6], bc[1 << 5];
int P[333], Q[333], M[1 << 5][1 << 5], V;
long long prv[333][333];
long long nxt[333][333];

int main()
{
	scanf("%d %d", &N, &C);
	int L = N * C;
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);

	int b = (1 << (N - 1));
	prv[0][A[N - 1] * N] = nxt[0][A[N - 1] * N] = 1;
	for (int i = 1; i < b; i++) bc[i] = bc[i - (i&(-i))] + 1;
	for (int i = 0; i < b; i++) for (int j = 0; j < b; j++) if (bc[i] == bc[j]) {
		P[V] = i; Q[V] = j;
		M[i][j] = V++;
	}
	for (int t = 0; t < L; t++) {
		int d = t % N - 1;
		if (d >= 0) for (int i = 0; i < V; i++) {
			int p = P[i], q = Q[i];
			if (q & (1 << d)) continue;
			for (int k = t; k <= L; k++) if (prv[i][k]) {
				for (int j = 0; j < N - 1; j++) if (~p & (1 << j)) {
					int x = min(L, max(k, t + A[j] * N));
					nxt[M[p + (1 << j)][q + (1 << d)]][x] += prv[i][k];
				}
			}
		}
		for (int i = 0; i < V; i++) for (int k = t+1; k <= L; k++) prv[i][k] = nxt[i][k];
	}

	double ans = prv[V - 1][L];
	for (int i = 1; i < N; i++) {
		ans /= i;
		ans /= C;
	}

	printf("%.16lf\n", ans);

	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair


using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c; cin>>a>>b>>c;
    cout<<min(c , b / a);

}


Measured memory_bytes: 256
n = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
a = []
ans = 0
saitekionndo = 1000000000000
for i in range(n):
    a.append([abs((T-H[i]*0.006)-A)])
    if abs((T-H[i]*0.006)-A)<saitekionndo:
        saitekionndo = abs((T-H[i]*0.006)-A)
        ans = i+1
print(ans)


Measured memory_bytes: 3188
import sys

dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]

def repaint(x, y):
    if S[x][y] == ".":
        T[x][y] = 1
    if S[x][y] == "#":
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0<= ny < W and S[nx][ny] == "#":
                T[x][y] = 1



H, W = map(int, sys.stdin.readline().split())
S = [list(sys.stdin.readline().rstrip()) for i in range(H)]
T = [[0] * W for i in range(H)]

for i in range(H):
    for j in range(W):
        repaint(i, j)
        if T[i][j] == 0:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3064
n, m, c = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
a = []
for i in range(0, n):
    a.append([int(j) for j in input().split(" ")])

count = 0
for i in range(0, n):
    if sum([a[i][j] * b[j] for j in range(0, m)]) + c > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

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

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

void modsum(ll &a,ll b,ll m){
  a+=b;
  a%=m;
}

void modsub(ll &a,ll b,ll m){
  a-=b;
  a+=m;
  a%=m;
}

void modmul(ll &a,ll b,ll m){
  a*=b;
  a%=m;
}

void modquo(ll &a,ll b,ll m){
  a*=modinv(b,m);
  a%=m;
}

ll ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main(){

  ll n;
  cin >> n;

  ll ans=0;

  queue<ll> q;
  q.push(3);
  q.push(5);
  q.push(7);

  vec v={3,5,7};
  while(!q.empty()){
    ll a=q.front();
    q.pop();
    for(ll i=3;i<=7;i+=2){
      if(a*10+i<=1000000000){
        v.push_back(a*10+i);
        q.push(a*10+i);
      }
    }
  }

  vec u;
  for(ll i=0;i<v.size();i++){
    ll a[13]={};
    string s=to_string(v[i]);
    for(ll j=0;j<s.size();j++){
      a[ctoi(s[j])]++;
    }
    if(a[3]>0 && a[5]>0 && a[7]>0)u.push_back(v[i]);
  }

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

  ans=upper_bound(u.begin(),u.end(),n)-u.begin();

  cout << ans << endl;




}

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

int main(){

    int a,b,x;
    cin >> x >>a >>b;

    x-=a;
    cout << x%b << endl;

    return 0;
}

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

int main() {
  int N, x, f=0;
  cin >> N;
  x = N;
  while (N > 0){
  	f += N % 10;
    N /= 10;
  }
  if (x % f == 0)
  	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	char ch=getchar();int o=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') o=(o<<3)+(o<<1)+(ch^48),ch=getchar();
	return f*o;
}
int n,m,a[100],b,c;
int main(){
	n=read();
	for(register int i=1;i<=n;i++) a[i]=read();
	for(register int i=1;i<n;i++){
		for(register int j=i+1;j<=n;j++){
			m+=a[i]*a[j];
		}
	} 
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> road;
    vector<int> count(n + 1, -1);
    int tail = 0;
    int loop = 1;

    int v = 1;
    while (count[v] == -1) {
        count[v] = road.size();
        road.push_back(v);
        v = a[v - 1];
    }
    tail = count[v];
    loop = road.size() - tail;

    if (k < tail) cout << road[k] << '\n';
    else {
        k -= tail;
        k %= loop;
        cout << road[tail + k] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5892
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, head, tail, q[MAXN];
LL c, h[MAXN], f[MAXN];

double k(int x, int y)
{
	return 1.0*(f[x]-f[y]+h[x]*h[x]-h[y]*h[y])/(h[x]-h[y]);
}

int main()
{
	scanf("%d%lld", &n, &c);
	for(rint i=1; i<=n; ++i) scanf("%lld", &h[i]);
	q[++head]=1;
	for(rint i=2; i<=n; ++i)
	{
		while(tail<head && k(q[tail], q[tail+1])<=h[i]*2) tail++;
		f[i]=f[q[tail]]+(h[i]-h[q[tail]])*(h[i]-h[q[tail]])+c;
		//printf("%d %d!!!\n", i, tail);
		while(tail<head && k(q[head], q[head-1])>k(i, q[head])) head--;
		q[++head]=i;
	}
	printf("%lld\n", f[n]);
	return 0;
}

Measured memory_bytes: 4096
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
root=-1
l=-1
for i in range(n):
    if len(edges[i])>l:
        root=i
        l=len(edges[i])
C=[[] for _ in range(n)]

def fill_C(v,par):
    for c in edges[v]:
        if c==par:
            continue
        C[v].append(c)
        fill_C(c,v)
fill_C(root,-1)

DP=[[-1,-1] for _ in range(n)]

def white(v):
    if DP[v][0]!=-1:
        return DP[v][0]
    res=1
    for c in C[v]:
        res*=white(c)+black(c)
        res%=mod
    DP[v][0]=res
    return res
def black(v):
    if DP[v][1]!=-1:
        return DP[v][1]
    res=1
    for c in C[v]:
        res*=white(c)
        res%=mod
    DP[v][1]=res
    return res

print((black(root)+white(root))%mod)

Measured memory_bytes: 121964
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

score = 0

for n in range(N):
    b_index = A[n]-1
    score = score + B[b_index]

    if n -1 != -1:
        if A[n-1]+1 == A[n]:

            score += C[A[n]-2]

print(score)


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

def main():
	n = int(input().strip())
	a = []
	a.append(0)
	a.extend(list(map(int, input().strip().split())))
	s = [0] * (n+1)
	for i in reversed(range(1, n+1)):
		j = 1
		d = 0
		while i * j <= n:
			d += s[i*j]
			j += 1
		s[i] = (d+a[i]) % 2
	M = sum(s)
	print(M)
	for i in range(n+1):
		if s[i] == 1:
			print("{} ".format(i), end="")
	print("")

if __name__ == '__main__':
	main()


Measured memory_bytes: 66652
#include <stdio.h>
#include <algorithm>
using namespace std;
int score;
int use(int money, int coin){
	int ans = money / coin;
	score += ans;
	return ans;
}

int main(){
	while (1){
		score = 0;
		int money;
		scanf("%d", &money);
		if (money == 0) return 0;
		money = 1000 - money;
		money -= use(money, 500) * 500;
		money -= use(money, 100) * 100;
		money -= use(money, 50) * 50;
		money -= use(money, 10) * 10;
		money -= use(money, 5) * 5;
		money -= use(money, 1) * 1;
		printf("%d\n", score);
	}
}

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

#define  fastIO  ios_base::sync_with_stdio(0); cin.tie(0);
#define  int long long int 
#define  endl '\n'

void solveTestCase()
{
	
	int a, b, c;
	cin >> a >> b >> c;

	int k;
	cin >> k;

	if(a<b and b<c) {
		cout << "Yes\n";
		return;
	}

	while(k>0 and a>=b) {
		b *= 2;
		k -= 1;
	}

	while(k>0 and b>=c) {
		c *= 2;
		k -= 1;
	}

	if(a<b and b<c) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}


}

int32_t main()
{

	fastIO

	solveTestCase();

	return 0;

}

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

int main()
{
    int H,W;
    cin >> H >> W;
    string Sharps,T;
    for(int i =0; i < W+2; i++)
    {
        Sharps.push_back('#');
    } 
    cout << Sharps << endl;

    for(int i =0; i < H; i++)
    {
        cin >> T;
        cout << "#" << T << "#" << endl;
    }

    cout << Sharps << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b , c , d;
  cin >> a >> b >> c;
  d = max ( a, max ( b,c)) ;
  cout << ( d==b ? a+10*b+c : d==a ?10*a + b + c : a+b+10*c ) <<endl;
}

Measured memory_bytes: 3484
def main():
     n=int(input())
     task=[list(map(int,input().split())) for i in range(n)]
     task.sort(key=lambda x:x[1])
     now=0
     flag=0
     for task_i in task:
          now+=task_i[0]
          if now>task_i[1]:
               print("No")
               flag=1
               break
     if flag==0:
          print("Yes")
          
     
if __name__=='__main__':
     main()

Measured memory_bytes: 89768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    if(n==0)
    {
        cout<<"";
        return 0;
    }
   
    if(s[n-1]=='s')
    {
         
         s=s+"es";
    }
    else
    s=s+'s';
    cout<<s;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;

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

    ll a, b, c;
    cin >> a >> b >> c;

    bool answer = false;
    for (ll i = 1; i <= 100; i++)
        if ((i*a - c) % b == 0) {
            answer = true;
            break;
        }

    cout << (answer ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define ld long double
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
double p[310][310][310],e[310][310][310];
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	int cnt[4]={0};
	fr(i,1,n)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	p[cnt[1]][cnt[2]][cnt[3]]=1.0;
	for(int c=n;c>=0;c--)
	{
		for(int b=n;b>=0;b--)
		{
			for(int a=n;a>=0;a--)
			{
				if(a+b+c>n)
				continue;
				if(a==0&&b==0&&c==0)
				continue;
				
				double pw=(double) (n-a-b-c)/n;
				double ew=pw/(1-pw) +1;
				
				e[a][b][c]+=ew*p[a][b][c];
				//e[a][b][c]++;
				if(a!=0)
				{
					double pt=(double) a/(a+b+c); 
					p[a-1][b][c]+=p[a][b][c]*pt;
					e[a-1][b][c]+=e[a][b][c]*pt;
				}
				if(b!=0)
				{
					double pt=(double) b/(a+b+c);
					p[a+1][b-1][c]+=p[a][b][c]*pt;
					e[a+1][b-1][c]+=e[a][b][c]*pt;
				}
				if(c!=0)
				{
					double pt=(double) c/(a+b+c);
					p[a][b+1][c-1]+=p[a][b][c]*pt;
					e[a][b+1][c-1]+=e[a][b][c]*pt;
				}
			}
		}
	}
	cout<<fixed<<setprecision(10);
	cout<<e[0][0][0];
	return 0;
}





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

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<40;

int N, K;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> K;
    vector<long long> maxd(N, -INF), vals; // それぞれのネタで最大のおいしさ、すべての寿司のおいしさ
    multiset<long long> se; // 食べる寿司の多重集合
    for (int i = 0; i < N; ++i) {
        int s;
        long long v;
        cin >> s >> v;
        --s;
        chmax(maxd[s], v);
        vals.push_back(v);
    }
    sort(vals.begin(), vals.end(), greater<long long>());
    sort(maxd.begin(), maxd.end(), greater<long long>());
    long long sum = 0;
    // とりあえず貪欲においしい順に食べるものとする
    for (int i = 0; i < K; ++i) {
        sum += vals[i];
        se.insert(vals[i]);
    }
    
    long long res = 0;
    long long tmp = sum;
    for (long long x = 1; x <= K; ++x) {
        long long add = maxd[x-1];
        long long back = *se.begin();
        tmp += add;
        if (back > add) {
            se.erase(se.begin());
            tmp -= back;
        } else {
            se.erase(se.find(add));
            tmp -= add;
        }
        chmax(res, tmp + x * x);        
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 6260
n=gets.to_i
a=$<.map{|e|e.to_i}.sort
c=0
cc=false
t=a[0]
a.each do |e|
  if t != e
    c+=1 if cc
    t=e
    cc=true
  else
    cc = !cc
  end
end
c+=1 if cc
p c


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

ll arr[2][100010];
int main(void){
	int n;
	cin >> n;
	FOR(i,n){
		cin >> arr[0][i] >> arr[1][i];
	}

	ll tot = 0;

	for(int i = n-1;i>=0;i--){
		ll cur = tot + arr[0][i];
		ll need = cur % arr[1][i];
		if(need == 0)continue;
		tot += arr[1][i] - need;
	}
	cout << tot << endl;
    return 0;
}




Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cassert>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <limits.h>
#include <fstream>
#include <unordered_map>
#include <array>

#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define pll pair <ll, ll>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
#define uint unsigned int

string y;
string x;

int dp[130][130];

int go(int a, int b) {
	if (dp[a][b] != -1) {
		return dp[a][b];
	}

	if (a == (int)x.size()) {
		return dp[a][b] = (int)y.size() - b;
	}

	if (b == (int)y.size()) {
		return dp[a][b] = (int)x.size() - a;
	}

	int res = go(a + 1, b);
	res = min(res, go(a, b + 1));

	if (x[a] != y[b]) {
		res = min(res, go(a + 1, b + 1));
	}

	res++;

	if (x[a] == y[b]) {
		res = min(res, go(a + 1, b + 1));
	}

	return dp[a][b] = res;
}

int numb = 0;

int ask(string s) {
	numb++;
	cout << "? " << s << endl;
	/*y = s;
	memset(dp, -1, sizeof dp);

	return go(0, 0);
	*/
	int ans;
	cin >> ans;
	return ans;
}

char get_ch(int x) {
	if (x < 26) {
		return 'a' + x;
	}

	x -= 26;
	if (x < 26) {
		return 'A' + x;
	}

	x -= 26;
	return x + '0';
}

vector <int> h;

int getnum(char c) {
	string s;

	for (int i = 0; i < 128; i++) {
		s.push_back(c);
	}

	return 128 - ask(s);
}

int main() {
	//cin >> x;

	/*for (int i = 0; i < 128; i++) {
		int f = rand() % 62;
		x.push_back(get_ch(f));
	}*/

	set <pair <int, string > > s;

	int tot = 0;

	for (int i = 0; i < 62; i++) {
		int x = getnum(get_ch(i));
		string f;

		for (int j = 0; j < x; j++) {
			f.push_back(get_ch(i));
		}

		s.insert(mp(x, f));
		tot += x;
	}

	int len = tot;

	while ((int)s.size() > 1) {
		string a = s.begin()->second;
		s.erase(s.begin());
		string b = s.begin()->second;
		s.erase(s.begin());

		string cur = "";

		int pos = 0;

		swap(a, b);

		for (int i = 0; i < (int)b.size(); i++) {
			cur.push_back(b[i]);

			for (int j = pos; j < (int)a.size(); j++) {
				cur.push_back(a[j]);
			}

			if (ask(cur) == len - (int)cur.size()) {
				for (int j = pos; j < (int)a.size(); j++) {
					cur.pop_back();
				}
			}
			else {
				for (int j = pos; j < (int)a.size(); j++) {
					cur.pop_back();
				}

				cur.pop_back();
				cur.push_back(a[pos++]);
				i--;
			}
		}

		while (pos < (int)a.size()) {
			cur.push_back(a[pos++]);
		}

		s.insert(mp(cur.size(), cur));
	}

	//cout << numb << endl;

	cout << "! " << s.begin()->second << endl;
}


Measured memory_bytes: 3804
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=2e5+5,Mo=1e9+7;

int n,c[N],sum[N],f[N];
vector<int> vec[N];

int main() {
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&c[i]);
		//if (c[i]!=c[i-1]) vec[c[i]].pb(i);
	}
	f[0]=1;sum[c[1]]=1;
	fo(i,1,n) {
		f[i]=sum[c[i]];
		if (c[i]!=c[i+1]) (sum[c[i+1]]+=f[i])%=Mo;
	}
	printf("%d\n",f[n]);
	return 0;
}

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

int main(){
    long N,M;
    cin >> N >> M;
    long height[N];
    long road[M][2];
    long judge[N];
    long count=0;
    for(int i=0; i<N; i++){
        cin >> height[i];
        judge[i]=1;
    }
    for(int i=0; i<M; i++){
        cin >> road[i][0] >> road[i][1];
        road[i][0]--;
        road[i][1]--;
    }
    for(int i=0; i<M; i++){
        if(height[road[i][0]]>height[road[i][1]]){
            judge[road[i][1]]=0;
        }
        else if(height[road[i][0]]==height[road[i][1]]){
            judge[road[i][1]]=0;
            judge[road[i][0]]=0;
        }
        else if(height[road[i][0]]<height[road[i][1]]){
            judge[road[i][0]]=0;
        }
    }
    for(int i=0; i<N; i++){
        if(judge[i]==1){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 6724
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

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

#define EPS 1e-6

using namespace std;

int main(){

	int n;
	cin >> n;

	rep(i,n){

	string a,b;
	cin >> a >> b;

	int sa=a.size(); int sb=b.size(); int p=max(sa,sb);
	vector<char>s;

	if(sa>80 || sb>80)
	cout << "overflow" << endl;
	else{

	string z;
	if(sa>sb){
	rep(j,sa-sb)
	z+='0';
	b=z+b;
	}
	if(sb>sa){
	rep(j,sb-sa)
	z+='0';
	a=z+a;
	}

    int c=0;
	rep(j,p){

	c+=(a[p-1-j]-'0')+(b[p-1-j]-'0');

	s.push_back(c%10+'0');
	c=c/10;

	}

    if(c==1) s.push_back(c%10+'0');

    if(s.size()<=80){
    rep(k,s.size()) cout << s[s.size()-1-k];
    cout << endl;
    }
    else
    cout << "overflow" << endl;

    s.clear();

	}

	}

	return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		String alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for(int i = 0; i < h; i++){
			String[] s = br.readLine().split(" ");
			for(int j = 0; j < w; j++){
				if(s[j].equals("snuke")){
					sb.append(alp.substring(j,j+1)).append(i+1);
					System.out.println(sb);
				}
			}
		}
	}
}

Measured memory_bytes: 8276