akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
s=0
c=0
while s==0:
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]/2
        else:
            s=1
    if s==0:
        c+=1

print(c)
    


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
	int A, B, T;
	cin >> A >> B >> T;
	int time_now = 0;
	int num      = 0;
	while (time_now < T) {
		time_now++;
		if (time_now % A == 0) {
			num += B;
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 256
while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        break
    
    for i in range(a):
        if i == 0 or i == a-1:
            print("#"*b)
        else:
            for j in range(b):
                if j == 0 or j == b-1:
                    print("#", end="")
                else:
                    print(".", end="")
            print("")
    print("")


Measured memory_bytes: 7012
H, W = map(int, input().split())

c = [list(map(int, input().split())) for _ in range(10)]

from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

G = csgraph_from_dense(c, null_value=0)

l = []
for i in range(10):
    d = dijkstra(G, indices=i)
    l.append(d[1])
ans = 0
for _ in range(H):
    A = list(map(int, input().split()))
    for a in A:
        if a != -1 and a != 1:
            ans += l[a]

print(int(ans))


Measured memory_bytes: 26856
#include <iostream>
#include <string>
#include <iso646.h>
using namespace std;



int main() {
	int H, W;
	cin >> H >> W;

	string board[50];

	for (int i = 0; i < H; ++i) cin >> board[i];

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

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; j++) {
			if (board[i][j] == '#') continue;

			int num = 0;
			for (int k = 0; k < 8; ++k) {
				const int ni = i + dy[k];
				const int nj = j + dx[k];

				if (ni < 0 or H <= ni) continue;
				if (nj < 0 or W <= nj) continue;
				if (board[ni][nj] == '#') num++;
			}

			board[i][j] = char(num + '0');
		}
	}

	for (int i = 0; i < H; ++i) cout << board[i] << endl;

	return 0;
}

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


int main(void){
    //nCr=n!/((n-r)!r!)
    //ナイーブにはn^2 comb = n^4
    //隣り合うnCrを求められないか
    //ai=2*ajのときが最適ではないのか
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    // index=番号-1
    auto maxitr=max_element(a.begin(),a.end());
    int dis=(maxitr-a.begin());
    int max=*maxitr;
    double mid=(double)max/2.0;
    vector<double> af(n);
    rep(i,n)af[i]=abs((double)a[i]-mid);
    auto minitr=min_element(af.begin(),af.end());
    double min=*minitr;
    dis=(minitr-af.begin());
    if(a[dis]==max){
        af.erase(af.begin()+dis);
        auto minitr=min_element(af.begin(),af.end());
        double min=*minitr;
        dis=(minitr-af.begin());
        if(a[dis+1]>mid)cout<<max<<" "<<(int)(min+mid)<<endl;
        else cout<<max<<" "<<(int)(mid-min)<<endl;
    }
    else{
        if(a[dis]>mid)cout<<max<<" "<<(int)(min+mid)<<endl;
        else cout<<max<<" "<<(int)(mid-min)<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

void solve() {
  string s, t = "";
  cin >> s;
  int n = s.size();
  loop(i,0,n) {
    if (s[i] == '0') t+= '0';
    else if (s[i] == '1') t += '1';
    else if (t.size()>0) t.pop_back();
  }
  cout << t << endl;
}


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


int main() {
  int N;
  cin >>N;
  
  vector<long long> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  long long sum =vec.at(0);
  
  if(N%2==1){
    for (int i = 1; i < (N-1)/2; i++) {
      sum +=vec.at(i)*2;
    }
    sum +=vec.at((N-1)/2);
  }
  else{
    for (int i = 1; i < N/2; i++) {
      sum +=vec.at(i)*2;
    }
  }
  
  cout << sum <<endl;
}


Measured memory_bytes: 4764
#include <iostream>
#include <memory>
#include <memory.h>
using namespace std;

bool tree[1000][1000];
int s[1000][1000];

int main(){
  int n, w, h;
  int x, y, S, T;
  while(cin >> n && n){
    memset(s, 0, sizeof(s));
    memset(tree, false, sizeof(tree));
    cin >> w >> h;
    for(int i = 0; i < n; i++){
      cin >> x >> y;
      tree[x][y] = true;
    }
    cin >> S >> T; 
    for(int i = 1; i <= w; i++){
      for(int j = 1; j <= h; j++){
	s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1];
	if(tree[i][j]) s[i][j]++;
      }
    }
    int res = 0;
    for(int i = 1; i <= w - S + 1; i++){
      for(int j = 1; j <= h - T + 1; j++){
	int num = s[i+S-1][j+T-1] - s[i-1][j+T-1] - s[i+S-1][j-1] + s[i-1][j-1];
	res = max(num, res);
      }
    }
    cout << res << endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 5748
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << x << '\n'
#define ddebug(x , y)  cout << x << ' ' << y << '\n'
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2e5 + 5 ;
const int maxm = 30 ;
const ll mod = 1e9 + 7 ;
int n , in[maxn] ;
int main()
{
	r(n) ;
	mem0(in) ;
	rep(i , 1 , n - 1)
	{
		int x ;
		r(x) ;
		in[x] ++ ;
	}
	rep(i , 1 , n)  w(in[i]) , en() ;
	return 0 ;
}


Measured memory_bytes: 4544
A, B, C = map(int, input().split())
K = int(input())

for _ in range(K):
    if C <= B or C <= A:
        C = C * 2
        continue
    if B <= A:
        B = B * 2
    else:
        C = C * 2

if A < B and B < C:
    print('Yes')
else:
    print('No')


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

ll power(ll x,ll y) 
{   
    x%=mod;
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
}
int main()
{
  IOS
  ll n,p;
  cin>>n>>p;
  ll c=0;
  while(p%2==0)
  {
    c++;
    p/=2;
  }

  c/=n;
  ll ans=pow(2,c);
  for(ll i=3;i<=sqrt(p);i+=2)
  { 
    ll c=0;
    while(p%i==0)
    {
      p/=i;
      c++;
    }
    c/=n;
    ans=ans*pow(i,c);
  }
  if(p>2)
  {
    if(n==1)
    {
      ans*=p;
    }
  }

  cout<<ans<<endl;



    

}




    

    
 
    
    


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ret = (1LL << 60);
	for (int i = 0; i <= max(x, y); i++) {
		ll curc = i;
		ll cura = max(x - curc, 0LL);
		ll curb = max(y - curc, 0LL);
		ll cur = 2 * curc * c + cura * a + curb * b;
		ret = min(ret, cur);
	}
	cout << ret << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

typedef pair<pii,int> ppii;

int N,R;
//bitset<10001*100001> field;
int field[2][10011];
vector<ppii> rangeSet[10010];
int line[10010];
const int dy[]={-1,0,0,1};
const int dx[]={0,-1,1,0};
const int INF=1000000000;
int main(){
  fast_stream();
  while(cin>>N>>R&&(N|R)){
    int miny,minx,maxy,maxx;
    miny=minx=INF;
    maxx=maxy=-INF;
    for(int i=0;i<10001;i++)rangeSet[i].clear();
    memset(line,0,sizeof(line));
    memset(field,0,sizeof(field));
    for(int i=0;i<N;i++){
      int x1,y1,x2,y2;
      cin>>x1>>y1>>x2>>y2;
      rangeSet[y1].push_back(make_pair(pii(x1,x2),1));
      rangeSet[y2].push_back(make_pair(pii(x1,x2),-1));
      maxy=max(y2+1,maxy);
      maxx=max(x2,maxx);
      miny=min(y1,miny);
      minx=min(x1,minx);
    }
    int S=0;
    int E=0;
    for(int y=miny;y<maxy;y++){
      int cur=y%2;
      int prv=cur^1;
      memset(field[cur],0,sizeof(field[cur]));
      for(int i=0;i<(int)rangeSet[y].size();i++){
	int sx=rangeSet[y][i].first.first;
	int ex=rangeSet[y][i].first.second;
	int a=rangeSet[y][i].second;
	for(int j=sx;j<ex;j++)line[j]+=a;
      }
      for(int x=minx;x<maxx;x++){
	if(line[x]>0){
	  S++;
	  field[cur][x]=1;
	}
      }
      for(int x=minx;x<maxx;x++){
	if(field[prv][x]^field[cur][x])E++;
	if(field[cur][x]==1){
	  if(x-1<0||field[cur][x-1]==0)E++;
	  if(field[cur][x+1]==0)E++;
	}
      }
      //if(y==maxy-2)cout<<E<<endl;
    }
    //int S=field.count();
    cout<<S<<endl;
    if(R==2)cout<<E<<endl;
  }
  return 0;
}

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

int main(){
    int n,a[100],max,min;
    cin >> n;
    cin >> a[0];
    max = a[0],min = a[0];
    for(int i=1;i<n;i++){
        cin >> a[i];
        if(a[i] > max) max = a[i];
        if(a[i] < min) min = a[i];
    }
    cout << max-min << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    
    if(a>=b){
        put("delicious");
    }else if(a+x>=b){
        put("safe");
    }else{
        put("dangerous");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    unsigned long long X, Y;
    unsigned long long res = 0;

    scanf ("%llu%llu", &X, &Y);

    for (unsigned long long i = X; i<= Y; i+=i)
    {
        res++;
    }

    printf("%llu", res);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

string s;
vector<char> chars;

signed main() {
    cin >> s;
    for (auto &c:s) chars.push_back(c);

    sort(chars.begin(), chars.end());
    chars.erase(unique(chars.begin(), chars.end()), chars.end());

    cout << (chars.size() == 2 ? "Yes" : "No") << endl;
}

// 配列

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
ll mo=1000000007;
ll dp[4];
int N;
int L[101010][4];
int R[101010][4];
ll p3[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	N=S.size();
	p3[0]=1;
	FOR(i,N) p3[i+1]=p3[i]*3%mo;
	
	FOR(i,N) {
		FOR(j,4) L[i+1][j]=L[i][j];
		if(S[i]=='A') L[i+1][0]++;
		if(S[i]=='B') L[i+1][1]++;
		if(S[i]=='C') L[i+1][2]++;
		if(S[i]=='?') L[i+1][3]++;
	}
	for(i=N-1;i>=0;i--) {
		FOR(j,4) R[i+1][j]=R[i+2][j];
		if(S[i]=='A') R[i+1][0]++;
		if(S[i]=='B') R[i+1][1]++;
		if(S[i]=='C') R[i+1][2]++;
		if(S[i]=='?') R[i+1][3]++;
	}
	
	ll ret=0;
	for(i=2;i<=N-1;i++) if(S[i-1]=='B' || S[i-1]=='?') {
		ll lef=L[i-1][0]*p3[L[i-1][3]]%mo;
		if(L[i-1][3]) lef+=L[i-1][3]*p3[L[i-1][3]-1]%mo;
		ll ri=R[i+1][2]*p3[R[i+1][3]]%mo;
		if(R[i+1][3]) ri+=R[i+1][3]*p3[R[i+1][3]-1]%mo;
		(ret+=lef*ri)%=mo;
	}
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4432
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Aの合計時間 (最初はN冊全部)
sum_a = sum(A)
# Bの合計時間 (最初は0冊)
sum_b = 0
# Bの冊数=Bの次の一冊のインデックス (最初は0冊)
b_next_ind = 0
# A,B合計冊数の最大値
ans = 0

# Aは上からi冊使う; i=N,...,1,0
for i in reversed(range(N + 1)):
	# KからAの合計を除いたのがBに使える時間
	sum_b_max = K - sum_a
	# それが負だったら何もしない
	if sum_b_max >= 0:
		# !!! 前回のBの状態 (sum_b, b_next_ind) から調べ始める !!!
		# まだBに残りがあって、
		# 今の合計に次の一冊を足してもまだsum_b_max以内なら読む
		# それを可能な限り繰り返す
		while b_next_ind < M and sum_b + B[b_next_ind] <= sum_b_max:
			sum_b += B[b_next_ind]
			b_next_ind += 1
		# Aの冊数=i
		# Bの冊数=b_next_ind
		# この和が解の候補、最大値が答え
		ans = max(ans, i + b_next_ind)
	# 次のループのため、Aの一番下を消す
	# 最後の一回(i=0)では消すものが無いため何もしない
	# (実はpythonは A[-1] は後ろから1番目の意味になるため範囲外エラーは起こさないが。。)
	if i > 0:
		sum_a -= A[i - 1]

print(ans)


Measured memory_bytes: 40556
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_H 201
#define MAX_W 201
#define N 10
using namespace std;
typedef long long ll;
const ll INF  = 1000000000000;
ll d[N][N];
ll wall[MAX_H][MAX_W];
ll H, W;

void warshall_floyd() {
  for(int k = 0; k < N; k++)
    for(int i = 0; i < N; i++) 
      for(int j = 0; j < N; j++) 
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

    cin >> H >> W;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
	cin >> d[i][j];
      }
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
	cin >> wall[i][j];
      }
    }

    warshall_floyd();
    
    ll ans = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
	if (wall[i][j] == -1) continue;
	else ans += d[ wall[i][j] ][1];
      }
    }

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


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

const int MAXN = 1 << 18;

int n;
vector<int> e[MAXN];
int cnt[MAXN];
vector<int> vct;
int frst;

void dfs(int v, int pr) {
    cnt[v] = 1;
    vct.push_back(v);

    if (v == n - 1) {
        frst = vct[((int)vct.size() + 1) / 2];
    }
    for (int to : e[v]) {
        if (to == pr) continue;
        dfs(to, v);
        cnt[v] += cnt[to];
    }
    vct.pop_back();
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif


    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; i++) {
            e[i].clear();
        }
        for (int i = 0; i < n - 1; i++) {
            int u, v;
            scanf("%d%d", &u, &v);
            --u; --v;
            e[u].push_back(v);
            e[v].push_back(u);
        }
        frst = -1;
        dfs(0, 0);
        bool win = cnt[frst] * 2 < n;
        string ans = win ? "Fennec" : "Snuke";
        cout << ans << endl;
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 16632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    int X;
    vector<int> vs;
    for (int i = 0; i < N; ++i) {
        cin >> X;
        vs.push_back(X);
    }

    int l = vs[0];
    int r = vs[0];
    for (int i = 1; i < N; ++i) {
        l = min(l, vs[i]);
        r = max(r, vs[i]);
    }


    int m = 1000000000;

    for (int i = l; i <= r; ++i) {
        int tmpSum = 0;
        for (int j = 0; j < N; ++j) {
            tmpSum += (vs[j] - i) * (vs[j] - i);
        }
        m = min(tmpSum, m);
    }

    cout << m << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
int a,b;
cin>>a>>b;
if(a>=6&&a<=12){
	cout<<b/2;
	return 0;
}
if(a<=5){
	cout<<0;
	return 0;
}
else {
	cout<<b;
	return 0;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n;
  cin >> n;
  string a,b;
  int A=0,B=0;
  REP(i,n) {
    cin >> a >> b;
    if(a>b) {
      A+=3;
    } else if(a<b) {
      B+=3;
    } else {
      A+=1;
      B+=1;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll MOD= 1000000007;
#define pb push_back
#define mpr make_pair
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n;
	cin>>n;
	string s,r;
	cin>>s>>r;
	ll j=0,k=0;
	for(ll i=0;i<2*n;i++)
	{
		if(i%2==0)
		{
			cout<<s[j];
			j++;
		}
		else
		{
			cout<<r[k];
			k++;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(ll N, ll T, vector<ll> &t, ll &ans){

    for(int i = 0; i != N-1; ++i){
        ll t_dif = t.at(i+1) - t.at(i);
        
        if(t_dif <= T) ans += t_dif;
        else ans += T;
    }
    ans += T;

    return;
}

int main(){

    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    for(auto iter = t.begin(); iter != t.end(); ++iter) cin >> *iter; 

    ll ans{};
    solver(N, T, t, ans);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4788
<?php
    fscanf(STDIN, "%s", $s);
    $result = '';
    if($s === 'Sunny'){
        $result = 'Cloudy';
    }else if($s === 'Cloudy'){
        $result =  'Rainy';
    }else if($s === 'Rainy'){
        $result = 'Sunny';
    }
    echo $result;
  ?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;


int main(void) {
  int n;
  cin >> n;
  double res = 0.0;
  for(int i = 0;i < n;++i) {
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY") {
      res += x;
    } else {
      res += x * 380000.0;
    }
  }
  cout << setprecision(15) << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	int l_mx = 0, r_mn = 2147483647;
	
	scanf("%d %d", &N, &M);

	for (int i = 0; i < M; ++i)
	{
		int l, r;

		scanf("%d %d", &l, &r);
		if (l > l_mx) l_mx = l;
		if (r < r_mn) r_mn = r;
	}

	printf("%d\n", max(0, r_mn - l_mx + 1));

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int A1[100001];
char A2[100001];
int input1[100001];
char input2[100001];

void swap1(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void swap2(char* a, char* b){
  char tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int p, int r){
  int x = A1[r];
  int i = p - 1, j;
  for(j=p;j<r;j++){
    if(A1[j] <= x){
      i++;
      swap1(&A1[i], &A1[j]);
      swap2(&A2[i], &A2[j]);
    }
  }
  swap1(&A1[i+1], &A1[r]);
  swap2(&A2[i+1], &A2[r]);
  return i+1;
}

void quic_sort(int p, int r){
  if(p < r){
    int q = partition(p, r);
    quic_sort(p, q-1);
    quic_sort(q+1, r);
  }
}

int check(int n){
  int i, j;
  for(i=1;i<n;i++){
    if(A1[i-1] == A1[i]){
      int a, b;
      for(j=0;j<n;j++){
        if(A1[i-1] == input1[j] && A2[i-1] == input2[j]) a = j;
        if(A1[i] == input1[j] && A2[i] == input2[j]) b = j;
      }
      if(a > b) return 0;
    }
  }
  return 1;
}

main(){
  int n, i;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    getchar();
    scanf("%c%d", &A2[i], &A1[i]);
  }
  for(i=0;i<n;i++){
    input1[i] = A1[i];
    input2[i] = A2[i];
  }
  quic_sort(0, n-1);
  printf("%s\n", (check(n) ? "Stable" : "Not stable"));
  for(i=0;i<n;i++) printf("%c %d\n", A2[i], A1[i]);
  return 0;
}


Measured memory_bytes: 2780
# ABC 076
def getInt(): return int(input())
def zeros(n): return [0]*n
def genBit(n): # n個の0/1のリストを生成　[0]から変化
    blist = zeros(n)
    for i in range(2**n):
        for k in range(n):
            blist[k] = i%2
            i //= 2
        yield blist
def db(x): 
    global debug
    if debug: print(x)
debug = False

N = getInt()
K = getInt()
minD = 0
for b in genBit(N):
    d = 1
    for i in range(N):
        if b[i]==0: d*=2
        if b[i]==1: d+=K
    if minD==0: minD = d
    elif d<minD: minD = d
    db(minD)
print(minD)



Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a[] = new int[1000];
        Arrays.fill(a, 0);
        for (int i = 0; i < 4; i++) {
            a[s.charAt(i)]++;
        }
        int cnt = 0;
        for (int i = 0; i < 1000; i++) {

            if (a[i] == 2) {
                cnt++;
            }
        }
        if (cnt == 2) {
            System.out.println(("Yes"));
        } else {
            System.out.println(("No"));
        }
        sc.close();
    }
}


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

int k;
string s;
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> k >> s;
    int a = s.length();
    for(int i = 0; i < min(k, a); ++i) cout << s[i];
    if (k < a) cout << "...";
    cout << '\n';
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    int yama[1002][200]={0};
    for(int i=0;i<200;i++)yama[0][i]=i;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int com;
        cin>>com;
        if(com){
            for(int j=0;j<N*2;j++)yama[i+1][j]=yama[i][(j+com)%(N*2)];
        }
        else{
            for(int j=0;j<N;j++)yama[i+1][j*2]=yama[i][j];
            for(int j=0;j<N;j++)yama[i+1][j*2+1]=yama[i][N+j];
        }
    }
    for(int i=0;i<N*2;i++)cout<<yama[M][i]+1<<endl;
    return 0;
}

Measured memory_bytes: 1948
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int N;

signed main(){

    in(N);
    out((int)pow(N,3));

    return 0;
}



Measured memory_bytes: 3280
use itertools::iproduct;
use itertools::Itertools as _;
use num::integer::gcd;
use proconio::input;

fn main() {
    input! {
        k: u64,
    }
    let ans = iproduct!(1..=k, 1..=k, 1..=k)
        .map(|(a, b, c)| gcd(gcd(a, b), c))
        .sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 2160
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut v:Vec<i32> = procon_read();
	v.sort();
	let mut alice = 0;
	let mut bob = 0;
	for i in 0..n {
		if i%2 == 0 {
			alice += v[(n - 1 - i) as usize];
		}else{
			bob += v[(n - 1 - i) as usize]
		}
	}
	println!("{}", alice - bob);
}

Measured memory_bytes: 4352
from collections import deque

INF=1001001001

h,w=map(int,input().split())
maze=[]

for i in range(h):
  maze.append(list(input()))


def bfs(y,x):
  #global maze
  #print("y,x",y,x)
  dx=[1,0,-1,0]
  dy=[0,-1,0,1]
  dist=[[INF for i in range(w)] for j in range(h)]
  dist[y][x]=0
  que=deque()
  que.append([y,x])
  mxd=0
  while que:
    v,u=que.popleft()
    #print("v,u",v,u)
    for i in range(4):
      ny=v+dy[i]
      nx=u+dx[i]
      #print("ny,nx",ny,nx)
      if 0<=ny<h and 0<=nx<w and maze[ny][nx]=="." and dist[ny][nx]==INF:
        que.append([ny,nx])
        dist[ny][nx]=dist[v][u]+1
        mxd=max(mxd,dist[ny][nx])
  return mxd

ans=0
for i in range(w):
  for j in range(h):
    if maze[j][i]=="#":
      continue
    d=bfs(j,i)
    #print("j,i,d",j,i,d)
    ans=max(ans,d)
print(ans)


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

const int N = 16;
const int M = (1 << N) + 10;
const int mod = 1e9 + 7;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int frac[M], inv[M];

inline int C(int n, int r) {
    if (r < 0 || r > n) return 0;
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

int fucked[17], dp[17][1 << N];

int main() {
    int n, m; scanf("%d%d", &n, &m), frac[0] = inv[0] = 1;
    for (int i = 1; i <= 1 << n; i++) 
        frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    for (int i = 1; i <= m; i++) scanf("%d", &fucked[i]);
    sort(fucked + 1, fucked + m + 1, [](int a, int b){return a > b;}), dp[0][0] = 1;
    for (int i = 1; i <= m; i++)
        for (int j = 0; j < 1 << n; j++)
            if (dp[i - 1][j]) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                int upper = (1 << n) - fucked[i] - j;
                if (upper < 0) continue;
                for (int k = 1; k <= n; k++)
                    if (!(j & (1 << k - 1))) 
                        dp[i][j | (1 << k - 1)] = (dp[i][j | (1 << k - 1)] + (LL)dp[i - 1][j] * C(upper, (1 << k - 1) - 1)
                            % mod * frac[1 << k - 1]) % mod;
            }
    int res = 0;
    for (int s = 0; s < 1 << n; s++) {
        int tmp = (LL)dp[m][s] * frac[(1 << n) - s - 1] % mod;
        if (__builtin_popcount(s) & 1) res = (res - tmp + mod) % mod;
        else res = (res + tmp) % mod;
    }
    printf("%d\n", (LL)res * (1 << n) % mod);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define MAXN 1000001 
using namespace std;
void solve() {
	ll n;
	cin>>n;
	while(n>0){
		ll a=n%10;
		if(a==7)
		{
			cout << "Yes\n";
			return;
		}
		n=n/10;
	}
	cout <<"No\n";
	return;
}

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

	// ll t;
	// cin >> t;
	// while(t--)
		solve();

}

Measured memory_bytes: 3688
# -*- coding: utf-8 -*-


def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        a = list(map(int, input().split()))
        total = c

        for j in range(m):
            total += a[j] * b[j]

        if total > 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {

	//入力
	int A, B, C;
	cin >> A >> B >> C;

	//処理
	int ans = B / A;
	if (ans > C) ans = C;

	//出力
	cout << ans << endl;

}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.29 19:57:27
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << '\n';

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define boost ios::sync_with_stdio(false);

const int N = 1e5 + 10;
int dp[N];
int inDegree[N];
vector<int> v[N];
int n,m;
void dfs(int s){

	for(int it : v[s]){

		dp[it] = max(dp[it],dp[s]+1);
		--inDegree[it];

		if(inDegree[it]==0)
			dfs(it);
	}
}
int main(){
  	
  	boost
	cin>>n>>m;
	while(m--){

		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		inDegree[y]++;
	}
	dp[0] = -1;
	for(int i = 1 ; i<= n ; ++i){

		if(dp[i]==0 && inDegree[i]==0){

			dfs(i);
		}
	}

	int ans = 0;
	for(int i = 0; i <= n ; ++i)
		ans = max(ans,dp[i]);

	cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;

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

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long

int main() {
    int N, M, A[105] = {}, sum = 0, cnt = 0;
    double check_num = 0;
    cin >> N >> M;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    check_num = (double)sum / (4 * M);
    rep(i, N) {
        if (A[i] >= check_num) {
            cnt++;
        }
    }
    if (cnt >= M) {
        Yes;
    } else {
        No;
    }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    a.append(1+i*n)
    b.append(n*(n-i-1)+1)
for i in range(n):
    a[p[i]-1] += i
for s in a:
    print(s,end=" ")
print()
for s in b:
    print(s,end=" ")

Measured memory_bytes: 6004
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["#" for x in range(20)]))


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

ll log(ll number, ll base){
   return (ll)log2(number)/(ll)log2(base); 
}

ll power(ll x, ll y){
    return (ll)(pow(x, y) + EPS);
}

int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int t;
    cin >> t;
string s;
cin >> s;

if (s.size() <= t){
    cout << s << endl;
}

else{
    cout << s.substr(0, t) << "..." << endl;

}
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
int main(){
    ll k;
    string s;
    cin>>s>>k;
    ll sum=0;
    char ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            sum++;
        }
        if(sum==k){
            ans='1';
            break;
        }
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
        //cout<<s[i]<<endl;
    }
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
int a[1000],cnt;
int main(){
	ll n,k;
	cin>>n>>k;
	ll s=n%k;
	ll c=abs(k-s);
	cout<<min(s,c);
}

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

def solve():
    l, r = map(int, input().split())
    if r - l >= 2019:
        print(0)
        return
    ans = 2019
    for i in range(l, r + 1):
        for j in range(l, r + 1):
            if i == j:
                continue
            ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
    print(ans)

if __name__=="__main__":
    solve()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    int n;
    ll w;
    cin >> n >> w;
    vector<vector<ll> > v(4);
    ll wei, val;
    cin >> wei >> val;
    v[0].push_back(val);
    for (int i = 0; i < n - 1; i++) {
        ll a, b;
        cin >> a >> b;
        v[a - wei].push_back(b);
    }
    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
    }

    vector<vector<ll> > sum(4);
    for (int i = 0; i < 4; i++) {
        sum[i].assign(v[i].size() + 1, 0);
        for (int j = 0; j < v[i].size(); j++) {
            sum[i][j + 1] = v[i][j] + sum[i][j];
        }
    }
    for (int i = 0; i <= v[0].size(); i++) {
        for (int j = 0; j <= v[1].size(); j++) {
            for (int k = 0; k <= v[2].size(); k++) {
                for (int l = 0; l <= v[3].size(); l++) {
                    if (i * wei + j * (wei + 1) + k * (wei + 2) + l * (wei + 3) <= w) {
                        ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a;
	string s;
	stringstream ss;
	vector<int>v;
	cin>>s;
	for(int i=0;i<s.length()-2;i++)
	{
		ss<<s.substr(i,3);
		ss>>a;
		v.push_back(max(753,a)-min(753,a));
		ss.clear();
	}
	sort(v.begin(),v.end());
	cout<<v[0]<<endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    ll n;
    cin >> n;
    ll ans = (n)*(n-1)/2;
    COUT(ans);
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var xy = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int x = cin.Int();
				int y = cin.Int();
				xy[i] = new Tuple<int, int>(x, y);
			}

			double sum = 0;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					var t1 = xy[i];
					var t2 = xy[j];

					sum += Math.Sqrt(
						(t1.Item1 - t2.Item1) * (t1.Item1 - t2.Item1)
						+ (t1.Item2 - t2.Item2) * (t1.Item2 - t2.Item2));
				}
			}

			double ans = 2 * sum / n;
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13268
import numpy as np 
s = input()
fis = s[0]
n = len(s)
k = n
temp = s[0]
for i in range(n):
    if temp!=s[i]:
        temp = s[i]
        k = np.min((k, np.max( (i, n-i) ) ))
print("{}".format(int(k)))

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

int main(){
  string S;
  int K;
  cin >> K;
  cin >> S;
  int a = S.size();
  if(a>K){
    S.erase(K);
    S += "...";
  }
  cout << S << endl; 
  return 0;
}

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

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

    int x;
    cin >> x;
    if( x >= 30 ){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define npos std::string::npos
typedef long long ll;
using namespace std;
int main()
{
	int a, b;
  	cin >> a >> b;
  	if (a < 6){
    	cout << '0' << endl;
    } else if (a <= 12) {
    	cout << b / 2 << endl;
    } else {
    	cout << b << endl;
    }
}



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

int main() {
	int group[] = { 1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;
	if (group[x - 1] == group[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, K; cin >> n >> K;
    using Elem = tuple<int, int>;
    vector<Elem> ab(n); for(auto& e : ab) {int a, b; cin >> a >> b; e = Elem(a, b);}
    sort(_all(ab));

    int res = 0;
    rep(j, n){
        int a, b; tie(a, b) = ab[j];
        bool ok = true;
        rep(k, 30){
            if(((a >> k) & 1) and not ((K >> k) & 1)){
                ok = false;
                break;
            }
        }
        if(ok){
            res += b;
        }
    }
    int mask = 0;
    rep(i, 31){
        if(i >= 1) mask <<= 1, mask += 1;
        if(((K >> i) & 1) == 0 or i == 0){
            continue;
        }
        int uk = (K >> (i + 1)), lk = (K & mask);
        int cur = 0;
        rep(j, n){
            int a, b; tie(a, b) = ab[j];
            int ua = (a >> (i + 1)), la = (a & mask);
            if((a >> i) & 1) continue;
            bool ok = true;
            rep(k, 31){
                if(((ua >> k) & 1) and not ((uk >> k) & 1)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cur += b;
            }
        }
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792