akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

int const mod = 1e9 + 7;
namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b){
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 2e5 + 5;

map<string, ll>mapa;
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	for (ll i = 0; i < n; i++) {
		string s; cin >> s;
		sort(all(s)); 
		mapa[s]++;
	}
	ll ans = 0;
	for (auto p : mapa) {
		ans += (p.Y) * (p.Y - 1);
	}
	ans /= 2;
	cout << ans;
	return 0;
}
/*

*/

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <cstdio>
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, m, x, y;
    int i;
    scanf("%d%d%d%d", &n, &m, &x, &y);
    int nx[n];
    int ny[m];
    int max = -1000, min = 1000;
    for (i = 0; i < n; i++){
        scanf("%d", &nx[i]);
        if(max<=nx[i])
            max = nx[i];
    }
    for (i = 0; i < m; i++){
        scanf("%d", &ny[i]);
        if(min>=ny[i])
            min = ny[i];
    }
    if(min>x&&min<=y)
    max < min ? printf("No War\n") : printf("War\n");
    else
        printf("War\n");
    return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val H = listOfInt()
    var h = Int.MAX_VALUE
    for (n in (0 until N).reversed()) {
        if (H[n] <= h) h = H[n]
        else if (H[n] - 1 == h) h = H[n] - 1
        else {
            println("No"); return
        }
    }
    println("Yes")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

map<pll, ll> m;

ll gcd(ll a, ll b){
  if(a==1 || b==1)return 1;
  if (a < b)swap(a,b);
  if(m[{a, b}]>0)return m[{a, b}];

  m[{a, b}] = b ? gcd(b, a % b) : a;
  return m[{a, b}];
}

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

ll f(ll x){
  ll res=0;
  while(x%2==0){
    x /= 2;
    res++;
  }
  return res;
}

int main(){
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];
  rep(i, n)a[i]/=2;

  ll t = f(a[0]);
//  rep(i, t)m/=2;

  rep(i, n){
    if(f(a[i])!=t){cout<<0<<endl; return 0;}
//    rep(j, t)a[i]/=2;
  }

//cout<<t<<' '<<m<<endl;

  ll base = 1;
  rep(i, n){
    base = lcm(base, a[i]);
//cout<<base<<endl;
    if(base>m){cout<<0<<endl;return 0;}
  }

  ll result = 0;
  result = ((m/base)+1)/2;
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 1024
import math
N ,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
LL = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(D):
      LL += (X[i][k]-X[j][k])**2
    L = math.sqrt(LL)
    if LL == int(L)**2:
      ans += 1
    L = 0
    LL = 0
print(ans)

Measured memory_bytes: 3064
using System;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            if (a < 1200) Console.WriteLine("ABC");
            else if (a < 2800) Console.WriteLine("ARC");
            else Console.WriteLine("AGC");


        }

    }
}


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

int main(){
    ll a,b,c,ans;
    cin >> a >> b >> c;
    if(a == b){
        if(b != c){
          cout << "Yes";
        	return 0;
    }}
    if(a == c){
        if(b != c){ cout << "Yes";
        return 0;
    }}
    if(c == b){
        if(a != c){ cout << "Yes";
        return 0;
    }}
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,x0,y0=mii()

tmp=10**100

x,y=x0,y0
chk=min(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
chk=max(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
ans =a*x+b*y
tmp=min(ans,tmp)

ans=a*x + c*2*y
tmp=min(ans,tmp)

ans=c*2*x+b*y
tmp=min(ans,tmp)

if x>=y:
    ans=a*(x-y) + c*2*y
    tmp=min(ans,tmp)   

if x<=y:
    ans=c*2*x+b*(y-x)
    tmp=min(ans,tmp)


print(tmp)

Measured memory_bytes: 63484
package main

import "fmt"

type Dice struct {
	side [6]int
	topnum int
	rightnum, leftnum, forwardnum, backnum, bottomnum int
}
func (dice *Dice) init() {
	for i:=0; i<6; i++ {
		fmt.Scan(&(dice.side[i]))
	}
	dice.topnum, dice.rightnum, dice.leftnum, dice.forwardnum, dice.backnum, dice.bottomnum = 0, 2, 3, 4, 1, 5
}
func (dice *Dice) dtonum(d int) int {
	for i:=0; i<6; i++ {
		if dice.side[i]==d {
			return i
		}
	}
	return 0
}
func (dice *Dice) inittopback(top, back int) {

	dice.topnum, dice.rightnum, dice.leftnum, dice.forwardnum, dice.backnum, dice.bottomnum = top, 2, 3, 5-back, back, 5-top
	topbackpairs := [6][4]int{{3,1,2,4},{0,3,5,2},{0,1,5,4},{1,0,4,5},{2,5,3,0},{2,1,3,4}}
	for i:=0; i<6; i++ {
		for j:=0; j<4; j++ {
			if top==topbackpairs[i][j] && back==topbackpairs[i][(j+1)%4] {
				dice.rightnum = i
				dice.leftnum = 5-i
				break
			}
		}
	}

}
func (dice *Dice) rotate(dir string) {
	temp := dice.topnum

	switch dir {
	case "N" :	
		dice.topnum = dice.backnum
		dice.backnum = dice.bottomnum
		dice.bottomnum = dice.forwardnum
		dice.forwardnum = temp
	case "E" :
		dice.topnum = dice.leftnum
		dice.leftnum = dice.bottomnum
		dice.bottomnum = dice.rightnum
		dice.rightnum = temp
	case "W" :
		dice.topnum = dice.rightnum
		dice.rightnum = dice.bottomnum
		dice.bottomnum = dice.leftnum
		dice.leftnum = temp
	case "S" :
		dice.topnum = dice.forwardnum
		dice.forwardnum = dice.bottomnum
		dice.bottomnum = dice.backnum
		dice.backnum = temp
	}
}
func (dice1 *Dice) checksameside(dice2 Dice) bool {

	if dice1.side[dice1.topnum] == dice2.side[dice2.topnum] && dice1.side[dice1.leftnum] == dice2.side[dice2.leftnum] && dice1.side[dice1.rightnum] == dice2.side[dice2.rightnum] && dice1.side[dice1.forwardnum] == dice2.side[dice2.forwardnum] && dice1.side[dice1.backnum] == dice2.side[dice2.backnum] && dice1.side[dice1.bottomnum] == dice2.side[dice2.bottomnum] {
			
		return true
	} else {
		return false
	}
}
func (dice1 Dice) havesameside(dice2 Dice) bool {
	
	for i:=0; i<4; i++ {
		if dice1.checksameside(dice2) {
			return true
		} else {
			for j:=0; j<4; j++ {
				dice1.rotate("E")
				if dice1.checksameside(dice2) {
					return true
				}
			}
		}
		dice1.rotate("N")
	}
	dice1.rotate("E")
	for i:=0; i<4; i++ {
		if dice1.checksameside(dice2) {
			return true
		} else {
			for j:=0; j<4; j++ {
				dice1.rotate("E")
				if dice1.checksameside(dice2) {
					return true
				}
			}
		}
		dice1.rotate("N")
	}
	return false
}

func main() {

	var dice1, dice2 Dice
	dice1.init()
	dice2.init()
	
	if dice1.havesameside(dice2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	  
}


Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int i,n,arr[10000],min,max;
    long sum=0;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
    }
    min=arr[0];
    for(i=1; i<n; i++)
    {
        min=(min<arr[i])?min:arr[i];
    }
    max=arr[0];
    for(i=1; i<n; i++)
    {
        max=(max>arr[i])?max:arr[i];
    }
    for(i=0; i<n; i++)
    {
        sum=sum+arr[i];
    }
    printf("%d %d %ld\n",min,max,sum);
}



Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char a;
  cin>>a;
  if(a>='a'){
    cout<<"a"<<endl;
  }else{
    cout<<"A"<<endl;
  }
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>

using namespace std;

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

    int ans = 0;
    ans = max(ans, A + A - 1);
    ans = max(ans, A + B);
    ans = max(ans, B + B - 1);

    cout << ans << endl;
}

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

typedef long long ll;

const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}

int main()
{
  int N,K;
  scanf("%d%d",&N,&K);
  static ll P[200];
  P[0]=1ll;
  for(int i=0;i<=N;i++){
    P[i+1]=P[i]*(K+1)%mod;
  }
  static ll dp[10010][200]={0};
  ll ans=0ll;
  dp[0][N]=1;
  for(int i=N-1;i>=0;i--){
    for(int y=0;y<=N*N;y++){
      if(!dp[y][i+1])continue;
      //printf("%d %d %lld\n",i,y,dp[y][i+1]);
      for(int x=0;x<=K;x++){
	if(x<=i+1&&i+1-x<=y){
	  int p=(x+y)/(i+1);
	  ad(ans,P[i]*p%mod*dp[y][i+1]%mod);
	  ad(dp[y+p][i],dp[y][i+1]);
	}
	else{
	  ad(dp[y][i],dp[y][i+1]);
	}
      }
    }
  }
  printf("%lld\n",(K*(K+1)/2*P[N-1]%mod*N%mod+mod-ans)%mod);
  return 0;
}



Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    long ans = 0;
    if(K == 0){
        cout << (long)N*(long)N << endl;
        return 0;
    }
    for(int i = K+1; i <= N; i++){
        int m = N%i;
        int n = N/i;
        ans += n*(i-K);
        if(m >= K) ans += m-K+1;
        //cout << i << ' ' << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=998244353;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=130;
int n=128,m=62;
char c[N];
int Ask(string s){
	static int cnt=0;
	assert((++cnt)<=830);
	cout<<"? "<<s<<endl;
	fflush(stdout);
	return read();
}
void Answer(string ans){
	cout<<"! "<<ans<<endl;
	fflush(stdout);
}
int cnt[N];
string Solve(int L,int R){
	if (L==R)
		return string(cnt[L],c[L]);
	int mid=(L+R)>>1;
	string a=Solve(L,mid),b=Solve(mid+1,R),c="";
	while (a.size()>0&&b.size()>0){
		string now=c+a[0]+b;
		if (Ask(now)==n-(int)now.size())
			c+=a[0],a=a.substr(1);
		else
			c+=b[0],b=b.substr(1);
	}
	return c+a+b;
}
int main(){
	For(i,0,25)
		c[i]='a'+i,c[i+26]='A'+i;
	For(i,0,9)
		c[i+52]='0'+i;
	int s=0;
	For(i,0,m-1)
		cnt[i]=n-Ask(string(n,c[i])),s+=cnt[i];
	n=s;
	Answer(Solve(0,m-1));
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	vvl p(26);
	rep(i,n){
	    p[s[i]-'a'].push_back(i);
	}
	int ok=0, ng=5001;
	while(abs(ok-ng)>1){
	    int mid=(ok+ng)/2;
	    map<string,int> mp;
	    bool ac=false;
	    rep(i,n-mid+1){
	        string sub=s.substr(i,mid);
	        if(mp.find(sub)==mp.end()){
	            mp[sub]=i;
	        }else{
	            if(i-mp[sub]>=mid){
	                ac=true;
	                break;
	            }
	        }
	    }
	    if(ac)ok=mid;
	    else ng=mid;
	}
	puta(ok);
	return 0;
}



Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int a[3];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    if((a[0]==a[1] && a[1]!=a[2])||(a[0]!=a[1] && a[1]==a[2]))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

#define INF 100000000
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int main(){
    int n; cin >> n;
    vector<int> x1(n),x2(n);
    rep(i, n) cin >> x1[i];
    copy(x1.begin(), x1.end(), x2.begin());
    
    sort(x2.begin(), x2.end());
    
    int ans1 = x2[n/2-1], ans2 = x2[n/2];
    
    rep(i, n){
        if (x1[i] < ans2) {
            cout << ans2 << endl;
        }
        else{
            cout << ans1 << endl;
        }
    }


}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, m, q, cl[N], mark[N][15];
vector<int> v[N];
stack<iii> s;

void dfs(int x, int d, int c) {
	if(mark[x][d])
		return;
	mark[x][d] = 1;
	if(d == 0) {
		cl[x] = c;
		return;
	}
	dfs(x, d - 1, c);
	for(auto i : v[x])
		if(mark[i][d - 1] == 0)
			dfs(i, d - 1, c);
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}

	cin >> q;
	for(int i = 1; i <= q; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		s.push({{a, b}, c});
	}

	while(!s.empty()) {
		iii t = s.top();
		s.pop();
		dfs(t.fi.fi, t.fi.se, t.se);
	}
	for(int i = 1; i <= n; i++)
		cout << cl[i] << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int r = ri();
	int d = ri();
	int x = ri();
	for (int i = 0; i < 10; i++) {
		x = x * r - d;
		std::cout << x << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


vector<int> f(vector<int> a) {
	if (a.size() == 1 && a[0] == 1) {
		return a;
	}

	auto d = vector<int>(0);
	rep(i, a.size()) {
		if (a[i] > i + 1) {
			return d;
		}
	}
	rep(i, a.size()) {
		if (a[i] == i + 1) {
			vector<int> b = a;
			b.erase(b.begin() + i);
			auto c = f(b);
			if (c.size()) {
				c.push_back(i + 1);
				return c;
			}
		}
	}
	return d;
}






int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	auto e = f(a);
	if (e.size()) {
		rep(i, e.size()) {
			cout << e[i] << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    ld n;
    cin >> n;
    vector<int> e;
    rep(i,n) e.push_back(i);
    vector<ld> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ld ans=0;
    do{
        rep(i,n-1){
            ans+=sqrt((a[e[i+1]]-a[e[i]])*(a[e[i+1]]-a[e[i]])+(b[e[i+1]]-b[e[i]])*(b[e[i+1]]-b[e[i]]));
        }
    }while(next_permutation(all(e)));
    rep(i,n) ans/=(i+1);
    cout << fixed << setprecision(10) << ans << endl;
}


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

// long long power(long long a, long long b) {
//     long long ans = 1;
//     while (b) {
//         ans = ans * a;
//         b--;
//     }

//     return ans;
// }

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

//     string res = "";

//     long long temp = 1, count = 0;
//     while (temp <= n) {
//         temp += temp * 26;
//         count++;
//     }

//     cout << count << endl;
//     while (n) {
//         temp = 0;
//         long long curr = power(26, count-1), prev = 1;
//         char ch = 'a' - 1;

//         cout << "currently dealing with " << curr << endl;
//         while (temp <= n) {
//             prev = temp;
//             temp += curr;
//             ch++;
//         }
//         count--;
//         ch--;
//         n = n - prev;
//         cout << "update " << count << " " << n << " tep " << temp << " prev " << prev << endl;
//         cout << ch << endl;
//     }
//     while (count--) cout << "a";
//     cout << endl;
// }

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

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

    long long sum = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        sum += x;

        mp[x]++;
    }

    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;

        long long occ = mp[b];
        mp[b] = 0;
        mp[c] += occ;

        sum = sum - b * occ + c * occ;
        cout << sum << endl;
    }
}

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

int main(void)
{
	char n[100];
	int sum=0;
	int ans=0;
	int count=0;
	scanf("%s",n);
	
	for(int i=0;n[i]!='\0';i++){
		sum=(n[i]-'0')+sum;
		count++;
	}
	
	for(int i=count-1;i>=0;i--){
		ans=ans+(n[i]-'0')*pow(10,count-1-i);
	}
	
	if(ans%sum==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

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

using namespace std;

int main(void)
{
	int a[5];

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

	int ans=0, mx=0;

	for(int i=0; i<5; ++i){
	    ans += (a[i]+9)/10*10;
	    mx=max(mx, (a[i]+9)/10*10-a[i]);
	}

	cout << ans-mx << endl;

	return 0;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  long long k, i=0, ans;
  char s[101];
  cin >> s >> k;
  while(s[i]!='\0'){
	if(i==k-1) break;
    if(s[i]!='1') break;
    i++;
  }
  cout << s[i] <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t=0;
    for(int i=0;i<10;i++){
        int a;
        cin>>a;
        t+=a;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
static unsigned int inf = 1e9+7;
static int bn = 1e5;
int main(){
    int n;
    cin >> n;
    int b[102];
    for(int i=1;i<n;i++){
        cin >> b[i];
    }
    b[0]=1e5+1;
    b[n]=1e5+1;
    int sum = 0;
    for(int i = 1;i<=n;i++){
        sum += min(b[i-1], b[i]);
    }
    cout << sum << endl;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  bool ans = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s == t) {
      ans = 1;
      break;
    }
    s = s.back() + s.substr(0, s.size() - 1);
  }
  if(ans) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

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

string week[] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int month, day;
    while(cin >> month >> day, month+day){
        int n = 0;
        for(int i=1; i<month; i++){
            n += days[i-1];
        }
        n += day;
        n %= 7;
        cout << week[n] <<endl;
    }
    return 0;
}

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


int main()
{
    // cout << "Chokudai Contest 004" << endl;

    int A = 0;  // 何個口か
    int B = 0;  // 必要な個数

    // 入力
    scanf("%d %d", &A, &B);

    // 計算
    int N = 0;  // 結果
    double tmp = 0.0;

    tmp = (double)(B-1) / (A-1);
    N = (int)(tmp+0.99999999);
    cout << N << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    cout<<k<<endl;
    else if(k<=a+b&&k>a)
    cout<<a<<endl;
    else
    {
        long long int s=(k-(a+b));
        cout<<a-s<<endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int n, x[maxn], y[maxn], a[maxn], b[maxn];
int main() {
	cin >> n;
	for(int i = 1; i <= n; ++ i) {
		cin >> x[i] >> y[i];
		a[i] = x[i] + y[i], b[i] = y[i] - x[i];
	}
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	cout << max(a[n] - a[1], b[n] - b[1]);
	return 0;
}


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

struct eratosthenes
{
    int n;
    vector<int> f;
    vector<pair<int, int>> primes;

    eratosthenes(int n) : f(n + 1)
    {
        ll i, j;
        f[0] = f[1] = -1;
        for (i = 2; i <= n; i++)
        {
            if (!f[i])
            {
                f[i] = i;
                primes.push_back(make_pair(i, 0));
                for (j = i * i; j <= n; j += i)
                {
                    if (!f[j])
                    {
                        f[j] = i;
                    }
                }
            }
        }
    }

    vector<int> genosis(int x)
    {
        vector<int> g;

        while (x != 1)
        {
            g.push_back(f[x]);
            x /= f[x];
        }

        return g;
    }

    vector<pair<int, int>> genosiscount(int x)
    {
        vector<pair<int, int>> gc;
        vector<int> g = genosis(x);

        if (g.empty() == 1)
        {
            return {};
        }

        gc.push_back(make_pair(f[x], 0));

        for (auto &i : g)
        {
            if (gc.back().first == i)
            {
                gc.back().second++;
            }
            else
            {
                gc.push_back(make_pair(i, 1));
            }
        }

        return gc;
    }
};

ll pow(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % 1000000007;
        x = (x * x) % 1000000007;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    eratosthenes a(1e6 + 1);
    int N;
    int A[10010];
    int i, j;
    ll ans = 0, B;
    ll mul = 1;

    cin >> N;

    for (i = 0; i < N; i++)
    {
        cin >> A[i];

        for (auto &j : a.genosiscount(A[i]))
        {
            for (auto &k : a.primes)
            {
                if (j.first == k.first && j.second > k.second)
                {
                    k.second = j.second;
                }

                if (j.first < k.first)
                {
                    break;
                }
            }
        }
    }

    for (auto &x : a.primes)
    {
        B = pow(x.first, x.second);
        mul = mul * B % 1000000007;
    }

    for (i = 0; i < N; i++)
    {
        ll add = mul * pow(A[i], 1000000005) % 1000000007;
        ans = (ans + add) % 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5368
import java.util.*;

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

    while(true){
      H = sc.nextInt();
      W = sc.nextInt();

      if(H != 0 && W != 0){
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(i == 0 || j == 0 || i == H-1 || j == W-1) {
            System.out.print("#");
          } else {
            System.out.print('.');
          }
          }
        System.out.println("");
      }
      }else{
        return;
      }
        //sc.close();
        System.out.println("");
      }
  }
}



Measured memory_bytes: 35624
#include <bits/stdc++.h>
using namespace std;
int main(void){

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

if(a==b){
    cout<<"Draw"<<endl;
}

else if(a==1){
    cout<<"Alice"<<endl;
}

else if(b==1){
    cout<<"Bob"<<endl;
}

else if(a>b){
    cout<<"Alice"<<endl;
}

else if(b>a){
    cout<<"Bob"<<endl;
}
}


Measured memory_bytes: 3548
from collections import defaultdict, deque

n, m = map(int, input().split())

d = [0]*(n+1)  # カードの整数が判明したら1にする
ddict = defaultdict(list)  # リスト内のカードと関係がある
relation = [[i, 0] for i in range(1, n+1)]  # iはk枚のカードと関係がある
for _ in range(m):
    x, y, z = map(int, input().split())
    ddict[x].append(y)
    ddict[y].append(x)
    relation[x-1][1] += 1
    relation[y-1][1] += 1
    
relation.sort(reverse=True, key=lambda x: x[1])

ans = 0
for i, r in relation:
    
    if r >=1:  # 他のカードと関係がある
        if d[i] == 0:  # カードの整数は判明していない
            ans += 1
            d[i] = 1
            que = deque(ddict[i])  # 関係のあるカードの整数が判明
            while que:
                s = que.popleft()
                if d[s] == 0:
                    d[s] = 1
                    que += ddict[s]                    
                else:  # 魔法を使う前に判明済み
                    continue
        else:  #カードの整数は判明済み
            continue
            
    else:  # 他のカードと関係がない
        ans += 1
        
print(ans)

Measured memory_bytes: 42908
# -*- coding: utf-8 -*-
n = int(input())
k = int(input())
x = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if k - x[i] < x[i]:
        ans += 2 * (k - x[i])
    else:
        ans += 2 * x[i]
print(ans)


Measured memory_bytes: 2940
from pprint import pprint

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

lim = 1
for i in range(n):
    lim += wv[i][1]

dp = [[float('inf')] * lim for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(lim):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i][j - wv[i][1]] + wv[i][0], dp[i][j])
        else:
            dp[i+1][j] = min((dp[i][j], dp[i+1][j]))

for i in reversed(range(lim)):
    if dp[-1][i] <= w:
        ans = i
        break
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  map<string, int> mp;
  string prev = "";
  REP(i,n){
    string s;
    cin >> s;
    if(prev==""){
      prev=s;
      mp[s]++;
    }else{
      if(prev.back() == s.front() && mp[s]==0){
        mp[s]++;
        prev=s;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

bool isVowel(char c) { return c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'; }

void solve(int N, const vector< string >& base) {	
	for (int k=1; k<55; ++k) {
		set< string > name_set;
		for (int i=0; i<N; ++i) {
			if ((int)base[i].size() <= k) name_set.insert(base[i]);
			else name_set.insert(base[i].substr(0, k));
		}
		if ((int)name_set.size() == N) {
			cout << k << endl;
			return;
		}
	}
	puts("-1");
}

int main() {
	int N;
	while (cin >> N, N) {
		vector< string > base(N);
		for (int i=0; i<N; ++i) {
			string S;
			cin >> S;
			base[i] += S[0];
		
			int m = S.size();
			for (int j=0; j<m-1; ++j) if (isVowel(S[j])) base[i] += S[j+1];
		}
		
		solve(N, base);
	}
}


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

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

    if(S[0] == S[1] || S[1] == S[2] || S[0] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll inf = 1e18;

ll n, m;
v<ll> fact;
void factorial(ll n)
{
	fact[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = i * fact[i - 1];
		fact[i] %= M;
	}
}
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//combination
ll C(ll n, ll i)
{
	if (n < i)
		return 0;
	ll res = fact[n];
	ll div = fact[n - i] * fact[i];
	div %= M;
	// using fermat little theorum
	div = binpow(div, M - 2); // modular inverse
	return (res * div) % M;
}
int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;

	cin >> n;
	fact.resize(n + 1);
	factorial(n);
	if (n == 1)
		cout << 0;
	else {
		ll nways = 0;
		for (i = 2; i <= n; i++) {
			x = n - i;
			(nways += (binpow(8, x) % M * (binpow(2, i) - 2) % M * C(n, i) % M) % M) %= M;
		}
		cout << nways;
	}


	return 0;

}
























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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,i;cin>>n>>i;
  cout << n-i+1 << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7;
const int N=2e3+5;
struct each{
	int x,y,z;
	bool operator < (each k){
		return z<k.z;
	}
}a[N];
int n,m,f,fa[N];
long long x,_min,ans=1;
int find(int x){
	return fa[x]?fa[x]=find(fa[x]):x;
}
int main(){
	scanf("%d%d%lld",&n,&m,&x),_min=x;
	for(int i=1;i<=m;i++)	scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);

	sort(a+1,a+m+1);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++)	fa[j]=0;
		long long res=a[i].z;
		fa[a[i].x]=a[i].y;

		for(int j=1;j<=m;j++){
			int x=find(a[j].x),y=find(a[j].y);
			if(x==y)	continue;
			fa[x]=y,res+=a[j].z;
		}
		_min=min(_min,res);
		if(res>x)	ans=ans*2%P;
		else	if(res==x)	++f;
	}
	int cnt=1;
	if(_min==x)	--f;
	for(int i=1;i<=f;i++)	cnt=cnt*2%P;
	cnt=(cnt-1+P)%P;

	if(!f&&_min!=x)	puts("0");
	else	printf("%lld\n",1LL*ans*cnt%P*2%P);
	return 0;
}


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

bool checks(string s) {
	for (int i = 0;i <= s.length() - 1;i++) {
		for (int j = 0;j <= s.length() - 1;j++) {
			if (i != j) {
				if (s[i] == s[j]) return 1;
			}
		}
	}
	return 0;
}

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

	if (checks(s) == 1) cout << "no" << endl;
	if (checks(s) == 0) cout << "yes" << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 3e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int h, w, a, b;
ll fact[maxn], invfact[maxn], dp[maxn];

ll comb(int n, int r)
{
	return (fact[n] * (invfact[r] * invfact[n - r] % mod) % mod);
}

ll powmod(ll a, ll b)
{
	if (!b)
		return 1;
	ll tmp = powmod(a, b / 2);
	tmp = tmp * tmp % mod;
	if (b & 1)
		tmp = tmp * a % mod;
	return tmp;
}

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

	fact[0] = invfact[0] = 1;
	for (int i = 1; i < maxn; i++)
		fact[i] = fact[i - 1] * i % mod, invfact[i] = powmod(fact[i], mod - 2);

	scanf("%d %d %d %d", &h, &w, &a, &b);
	for (int i = 0; i < h - a; i++)
		dp[i] = comb(i + b - 1, i);

	ll ans = 0;
	for (int i = 0; i < h - a; i++)
		ans = (ans + dp[i] * comb(w - b - 1 + h - i - 1, w - b - 1) % mod) % mod;
	printf("%lld\n", ans);
}



Measured memory_bytes: 6016
def bubblesort(A,N):
    count = 0
    for j in range(N):
        for i in range(N-1):
            if A[i] > A[i+1]:
                A[i],A[i+1] = A[i+1],A[i]
                count += 1

    return A,count

def bubblesort_re(A,N):
    count = 0
    #A[i] > A[i+1]の状態がある→交換する必要がある：flag = True
    #交換する必要が無いとbreak→値の無駄な比較をしない
    flag = True
    while flag:
        flag = False
        for i in range(N-1):
            if A[i] > A[i+1]:
                A[i],A[i+1] = A[i+1],A[i]
                count += 1
                flag = True

    return A,count

if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().split()]
    ans,count = bubblesort_re(A,N)
    for i in range(N):
        if i != N - 1:
            print(ans[i],end = " ")
        else:
            print(ans[i])
    print(count)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

ll f(ll b, ll n){
    ll res = 0;
    while(n != 0){
        res += n%b;
        n /= b;
    }

    return res;
}

int main(){
    ll n, s; cin >> n >> s;
    if(n < s){
        cout << -1 << endl;
        return 0;
    }

    if(n == s){
        cout << n+1 << endl;
        return 0;
    }

    for(ll b=2; b*b<=n; b++){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }

    const ll inf = 1LL<<59;
    ll ans = inf;
    for(ll p=1; p*p<n; p++){
        if((n+p-s)%p == 0){
            ll b = (n+p-s)/p;
            if(f(b, n) == s) ans = min(ans, b);
        }
    }
    
    if(ans == inf){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

n, m = list(map(int, input().split()))

edges = [[[] for _ in range(3)] for _ in range(n + 1)]

for _ in range(m):
	u, v = list(map(int, input().split()))
	edges[u][0].append((v, 1))
	edges[u][1].append((v, 2))
	edges[u][2].append((v, 0))

s, t = list(map(int, input().split()))
visited = [[[] for _ in range(3)] for _ in range(n + 1)]

q = deque()
q.append((s, 0, 0))

while q:
	node, div, cnt = q.popleft()

	if visited[node][div] == 1:
		continue
	
	if (node, div) == (t, 0):
		print(cnt // 3)
		sys.exit()
	
	else:
		visited[node][div] = 1
		for e in edges[node][div]:
			q.append((e[0], e[1], cnt + 1))
	
print(-1)


Measured memory_bytes: 118492
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[][] dp = new long[n + 1][k + 1];
		for (int i = 0; i <= k; i++) {
			dp[0][i] = 1;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= k; j++) {
				if (i - j >= 0) {
					dp[i][j] = dp[i][j - 1] + dp[i - j][j];
					dp[i][j] %= MOD;
				} else {
					dp[i][j] = dp[i][j - 1];
				}
			}
		}
		System.out.println(dp[n][k]);
	}
}

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



Measured memory_bytes: 32528
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

class UnionFind
{
public:
    UnionFind(int size)
    :m_Size(size)
    {
        m_Parents.resize(size);
        m_Ranks.resize(size);
    }

    void Init()
    {
        for (int i = 0; i < m_Size; ++i)
        {
            m_Parents[i] = i;
            m_Ranks[i] = 0;
        }
    }

    int Root(int x)
    {
        return m_Parents[x] == x ? x : m_Parents[x] = Root(m_Parents[x]);
    }

    bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }

    void Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (m_Ranks[x] < m_Ranks[y])
        {
            m_Parents[x] = y;
        }
        else
        {
            m_Parents[y] = x;
            if (m_Ranks[x] == m_Ranks[y]) ++m_Ranks[x];
        }
    }

private:
    int m_Size = 0;
    vector<int> m_Parents;
    vector<int> m_Ranks;
};

int main()
{
    int N;
    cin >> N;
    UnionFind uf1(N), uf2(N);
    uf1.Init();
    uf2.Init();
    int K, L;
    cin >> K >> L;
    int s, d;
    REP(i, K)
    {
        cin >> s >> d;
        uf1.Unite(--s, --d);
    }
    REP(i, L)
    {
        cin >> s >> d;
        uf2.Unite(--s, --d);
    }
    map<pair<int, int>, int> M;
    REP(i, N)
    {
        ++M[make_pair(uf1.Root(i), uf2.Root(i))];
    }
    REP(i, N)
    {
        cout << M[make_pair(uf1.Root(i), uf2.Root(i))] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 15104
import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

max_len = max(len(bin(K)[2:]), len(bin(max(A))[2:]))
bit_cnt = [((A>>k)&1).sum() for k in range(max_len)]

x = 0
for i in range(max_len-1, -1, -1):
    if x+2**i <= K and bit_cnt[i] < (N+1)//2:
        x += 2**i

answer = 0
for a in A:
    answer += a^x
print(answer)


Measured memory_bytes: 27276