akhauriyash/Code-Regression huggingface dataset:
<?php

function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$s = input('strval');

$diffs = array_map(function($start) use ($s) {
    return abs((int)substr($s, $start, 3) - 753);
}, range(0, strlen($s) - 3));

echo min($diffs) . "\n";

Measured memory_bytes: 4856
#include<iostream>
using namespace std;
void check(int x);
int a[20];
int b,c;
int n;
int least = 1000000;
int main(){

    while(cin>>n,n){
        least = 1000000;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        check(0);
        cout<<least<<endl;
    }

    return 0;
}
void check(int x){
    if(x==n){
        int an = b - c;
        if(an<0)an*=-1;
        if(an<least)least = an;
        return;
    }
    b+=a[x];
    check(x+1);
    b-=a[x];
    c+=a[x];
    check(x+1);
    c-=a[x];

}

Measured memory_bytes: 1160
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[]
SA=sum(A)
SB=sum(B)
S=SA-SB
cnt=0
ns=0
if SB>SA:
    print(-1)
    exit()
for a,b in zip(A,B):
    if a>b:
        C.append(a-b)
    elif a<b:
        ns+=b-a
        cnt+=1
C.sort(reverse=True)
for i in range(len(C)):
    if ns>0:
        cnt+=1
        ns-=C[i]
    else:break
print(cnt)

Measured memory_bytes: 24428
from string import ascii_lowercase
alp=ascii_lowercase
s=input()
k=int(input())
lst=set()
p=-1
while len(lst)<=k-1:
    p+=1
    for i in range(len(s)):
        if s[i]==alp[p]:
            for j in range(k):
                if i+j<len(s):
                    lst.add(s[i:i+j+1])
lst=sorted(lst)
print(lst[k-1])

Measured memory_bytes: 74916
#include <stdio.h>

int main(void) {
	double tmp;
	double sum;
	int i;
	int itr_time = 10;

	while (~scanf("%lf",&tmp)) {
		sum = tmp;
		for (i = 1;i < itr_time;++i) {
			sum += (tmp = i%2 == 0 ? tmp/3.0 : tmp*2.0);
		}
		printf("%.8lf\n",sum);
	}
	return 0;
}

Measured memory_bytes: 652
def resolve():

    N,M=map(int,input().split())
    A=sorted(list(map(int,input().split())),reverse=True)

    val=sum(A)/(4*M)
    cnt=0
    for i in A:
        if i >=val:
            cnt+=1

    if cnt>=M:
        print('Yes')
    else:
        print('No')




resolve()

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

int mn1[100010],mn2[100010],mx1[100010],mx2[100010];
int l[100010],r[100010],h[100010],n,m;
bool bo[100010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool cmp(const int &x,const int &y) { return (l[x]!=l[y])?(l[x]<l[y]):(r[x]>r[y]); }

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) l[i]=rd(),r[i]=rd();
	for (int i=1;i<=n;i++) h[i]=i;
	int ans=0;
	for (int i=1;i<=n;i++) ans=max(ans,r[i]-l[i]+1);
	sort(h+1,h+n+1,cmp);
	int mn=inf;
	for (int i=n;i;i--)
	{
		if (mn<=r[h[i]]) bo[h[i]]=false;
		else bo[h[i]]=true;
		mn=min(mn,r[h[i]]);
	}
	int tt=0;
	for (int i=1;i<=n;i++) if (bo[i]) h[++tt]=i;
	int mx=0;
	for (int i=1;i<=n;i++) if (!bo[i]) mx=max(mx,r[i]-l[i]+1);
	sort(h+1,h+tt+1,cmp);
	mn1[0]=inf;
	for (int i=1;i<=tt;i++)
	{
		mn1[i]=min(mn1[i-1],r[h[i]]);
		mx1[i]=max(mx1[i-1],l[h[i]]);
	}
	mn2[tt+1]=inf;
	for (int i=tt;i;i--)
	{
		mn2[i]=min(mn2[i+1],r[h[i]]);
		mx2[i]=max(mx2[i+1],l[h[i]]);
	}
	for (int i=1;i<tt;i++)
	{
		int h1=max(mn1[i]-mx1[i]+1,0),h2=(i<tt)?max(mn2[i+1]-mx2[i+1]+1,0):0;
		ans=max(ans,h1+h2);
	}
	ans=max(ans,max(mn1[tt]-mx1[tt]+1,0)+mx);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int kazu,i,j,cnt=0,hz;
		Scanner sca = new Scanner(System.in);
		kazu=sca.nextInt();
		int hai[]=new int[kazu];
		for(i=0;i<kazu;i++){
			hai[i]=sca.nextInt();
		}
       for(i=0;i<kazu-1;i++){
    	   for(j=kazu-1;j>0;j--){
    		   if(hai[j]<hai[j-1]){
    			   hz=hai[j];
    			   hai[j]=hai[j-1];
    			   hai[j-1]=hz;
    			   cnt++;
    		   }
    	   }
	}
     for(i=0;i<kazu;i++){
    if(i!=kazu-1){	 
     System.out.print(hai[i]+" ");
     }else{
    	 System.out.println(hai[i]);
     }
     }
     System.out.println(cnt);

}
}


Measured memory_bytes: 26300
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 1000000
#define MAX 500000
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
vector <vi> adj(MAX);
vi col;
 ll n;
 vi dfs_num,dfs_parent,dfs_low,vertex;
int dfsnumcnt=0,dfsRoot,rootChildren=0;
void apoint(int u)
{
  dfs_num[u]=dfs_low[u]=dfsnumcnt++;
  for(ll i=0;i<adj[u].size();i++)
  {
    ll v=adj[u][i];
    if(dfs_num[v]==INF)
    {
      dfs_parent[v]=u;
      if(u==dfsRoot) rootChildren++;
      apoint(v);
      if(dfs_low[v]>=dfs_num[u])
        vertex[u]=1;
      dfs_low[u]=min(dfs_low[u],dfs_low[v]);
    }
    else if(v!=dfs_parent[u])
    dfs_low[u]=min(dfs_low[u],dfs_num[v]);
 }
}
int main()
{
  // freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll n;
cin>>n;
ll ans=n*800-(n/15)*200;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 11904
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(c-a<=d&&c-a>=0){
		cout<<"Yes"<<endl;
	}
	else if(a-c<=d&&a-c>=0){
		cout<<"Yes"<<endl;
	}
	else if(b-a<=d&&b-c<=d&&b-a>=0&&b-c>=0){
		cout<<"Yes"<<endl;
	}
	else if(a-b<=d&&c-b<=d&&a-b>=0&&c-b>=0){
		cout<<"Yes"<<endl;
	}
	else if(b-a<=d&&c-b<=d&&b-a>=0&&c-b>=0){
		cout<<"Yes"<<endl;
	}	
	else if(a-b<=d&&b-c<=d&&a-b>=0&&b-c>=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }   
    int max = 1;
    int min = 1000000000;
    for (int i = 0; i < n; i++) {
        if (max < a[i])
            max = a[i];
        if (min > a[i])
            min = a[i];
    }   
    cout << max - min;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int>graph[maxn];
bool visit[maxn];
int dist[maxn];
int in_degree[maxn];
void dfs(int u)
{
    visit[u] = true;
    for(auto v: graph[u]){
        dist[v] = max(dist[v], dist[u] + 1);
        --in_degree[v];
        if(in_degree[v] == 0)dfs(v);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    while(m--){
        int x,y;
        cin >> x >> y;
        graph[x].push_back(y);
        in_degree[y]++;
    }

    for(int i = 1; i <= n; i++){
        if(!visit[i] && in_degree[i] == 0)dfs(i);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	if (S[5] >= '1' || S[6] > '4')
	{
		cout << "TBD";
	}
	else
	{
		cout << "Heisei";
	}

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll N, M;
    cin >> N >> M;
    ll A[100000];
    for(int i=0;i<N;i++) cin >> A[i];
    ll S[100001];
    S[0] = 0;
    map<ll,ll> ptn;
    for(int i=1;i<=N;i++){
        S[i] = (S[i-1] + A[i-1]) % M;
        ptn[S[i]]++;
    }
    ll ans = ptn[0];
    for(auto x:ptn){
        ans += x.second*(x.second-1)/2;
    }

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

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    map<string,ll> mp;
    REP(i,N){
        string s;cin>>s;
        sort(s.begin(),s.end());

        mp[s]++;
    }
    ll ans = 0;
    for(auto x:mp){
        if(x.second >= 2) ans += (x.second * (x.second - 1))/2LL;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11264
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;

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

ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = (res * x) % MODU;
		x = (x*x)%MODU;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * mod_pow(b, MODU - 2)) % MODU;
}


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

	vector<pii> ab(m);
	vector<int> c(m);

	REP(i,m){
		cin >> ab[i].first >> ab[i].second;
		int mask = 0;
		REP(j,ab[i].second){
			int temp;
			cin >> temp;
			bitset(mask, temp-1);
		}
		c[i] = mask;
	} 

	int dp[1<<13] = {};
	Fill(dp, INT_MAX);
	dp[0] = 0;

	REP(i, 1 << n){
		if(dp[i] == INT_MAX) continue;
		REP(j, m){
			int next = i | c[j];
			dp[next] = min(dp[next], dp[i] + ab[j].first);
		}
	}

	if(dp[(1 << n) - 1] == INT_MAX) dp[(1 << n) - 1] = -1;
	cout << dp[(1 << n) - 1] << endl;

	return 0;
} 

Measured memory_bytes: 256
def myAnswer(H:int,W:int,A:list)-> None:
   for h in range(H+2):
      if(h == 0 or h == H+1):
         print("#"*(W+2))
      else:
         for w in range(W+2):
            if(w == 0):
               print("#",end="")
            elif(w == W+1):
               print("#")
            else:
               print(A[h-1][w-1],end="")


def modelAnswer():
   tmp=1
def main():
   H,W =map(int,input().split())
   A = []
   for i in range(H):
      A.append(list(input()))
   myAnswer(H,W,A)

if __name__ == '__main__':
   main()

Measured memory_bytes: 4596
n = int(input())
s = [input() for _ in range(n)]

a = 0
b = 0
ab = 0
c = 0

for i in range(n):
  if s[i][0:1] == 'B':
    b += 1
  if s[i][-1:] == 'A':
    a += 1
  if s[i][0:1] == 'B' and s[i][-1:] == 'A':
    ab += 1

  c += s[i].count('AB')

c2 = min(min(a, b), n-1)

if ab == a and ab == b and ab < n and c2 > 0:
  c2 -= 1

print(c+c2)


Measured memory_bytes: 3700
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n , m ; cin >> n >> m ; 
if(n == m)cout << "Yes" ;
else cout<< "No" ;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int fnc(ll a){
    int res = 0;
    while(a>0){
        a /= 10;
        res++;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> a;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            a.push_back(make_pair(i,n/i));
        }
    }
    int ans = INF;
    rep(i,a.size()){
        ans = min(ans,max(fnc(a[i].first),fnc(a[i].second)));
    }
    cout << ans << endl;
}

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

string A,B;
int M;

const LL MOD = 10000;

LL dp[555][10][555][2][2];
//S以下の0modMなジグザグ数の個数を求める
LL solve(string&S){
	int N=S.size();
	int firstdig=S[0]-'0';
	if(N==1){
		return firstdig/M;
	}
	memset(dp,0,sizeof(dp));
	for(int i=1;i<firstdig;++i){
		dp[0][i][i%M][0][0]=1;
		dp[0][i][i%M][1][0]=1;
	}
	dp[0][firstdig][firstdig%M][0][1]=1;
	dp[0][firstdig][firstdig%M][1][1]=1;
	auto addrem=[](LL& ins,LL plr){
		ins+=plr;
		ins%=MOD;
	};
	for(int d=0;d<N-1;++d){
		for(int v=0;v<10;++v){
			for(int r=0;r<M;++r){
				for(int f=0;f<2;++f){
					for(int n=0;n<2;++n){
						LL now=dp[d][v][r][f][n];
						if(n==0){
							if(f){
								for(int nv=v+1;nv<10;++nv){
									addrem(
									dp[d+1][nv][(r*10+nv)%M][!f][n],now
									);
								}
							}else{
								for(int nv=0;nv<v;++nv){
									addrem(
									dp[d+1][nv][(r*10+nv)%M][!f][n],now
									);
								}
							}
						}else{
							int lim=S[d+1]-'0';
							if(f){
								for(int nv=v+1;nv<=lim;++nv){
									addrem(
									dp[d+1][nv][(r*10+nv)%M][!f][(nv==lim)],now
									);
								}
							}else{
								for(int nv=0;nv<min(lim+1,v);++nv){
									addrem(
									dp[d+1][nv][(r*10+nv)%M][!f][(nv==lim)],now
									);
								}
							}
						}
					}
				}
			}
		}
		for(int i=1;i<10;++i){
			addrem(dp[d+1][i][i%M][0][0],1);
			addrem(dp[d+1][i][i%M][1][0],1);
		}
	}
	LL res=0;
	for(int v=0;v<10;++v){
		for(int f=0;f<2;++f){
			for(int n=0;n<2;++n){
				addrem(
				res,dp[N-1][v][0][f][n]
				);
			}
		}
	}
	res -= 9 / M;
	return res;
}

int main(){
	cin>>A;
	cin>>B;
	cin>>M;
	LL L=solve(A);
	LL R=solve(B);
	bool Azig=true;
	if(A.size()>1){
		vector<int>vec;
		for(int i=1;i<A.size();++i){
			if(A[i-1]<A[i]){
				vec.push_back(1);
			}else if(A[i-1]>A[i]){
				vec.push_back(0);
			}else{
				Azig=false;
				break;
			}
		}
		if(Azig){
			for(int j=1;j<vec.size();++j){
				if(vec[j]==vec[j-1]){
					Azig=false;
					break;
				}
			}
		}
	}
	LL ans=R-L;
	if(Azig)ans++;
	ans+=MOD;
	ans%=MOD;
	//cerr<<L<<" "<<R<<endl;
	cout<<ans<<endl;
	return 0;
}



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

int main(){
  int n;cin>>n;
  vector<pair<int,int>> p(n);
  REP(i,n){
    int a,b;cin>>a>>b;
    p.at(i)=make_pair(b,a);
  }
  sort(p.begin(),p.end());

  ll time=0;bool f=true;
  REP(i,n){
    time+=p.at(i).second;
    if(time>p.at(i).first) f=false;
  }

  cout<<(f?"Yes":"No");
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MAXN 200005
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, z;

lint arr[MAXN], x, y;

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	y = 0;
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		y += arr[i];
	}
	x = 0;
	lint ans = INF;
	for (int i = 0; i < N-1; i++) {
		x += arr[i];
		y -= arr[i];
		ans = min(ans, abs(x-y));
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s, t;
    cin >> s >> t;
    if(t.substr(0, s.length()) == s)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3652
n,k = map(int,input().split())
s = list(input())

l = 0
r = 0
count = 0
hcount = 0
score = 0
def sccount(s):
    l = 0
    r = 0
    count = 0
    score = 0
    for i in range(n):
        if s[i] == 'R':
            if r == 1:
                score += 1
            l = 0
            r = 1
        else:
            if l == 1:
                score += 1
            l = 1
            r = 0
    l = 0
    r = 0
    return score

if s[0] == 'L':
    for i in range(n):
        if s[i] == 'L':
            if r == 1 :
                count += 1
            l = 1
            r = 0
        else:
            l = 0
            r = 1
    if s[-1] == 'R':
        hcount = 1
else:
    for i in range(n):
        if s[i] == 'R':
            if l == 1 :
                count += 1
            l = 0
            r = 1
        else:
            l = 1
            r = 0
    if s[-1] == 'L':
        hcount = 1
score = sccount(s)
if count >= k:
    ans = score + k*2
elif count < k:
    ans = score + count*2 + hcount
print(ans)
# print(score,count,hcount)


Measured memory_bytes: 4084
//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

const int N = 15;

char s1[N], s2[N], s3[N];

int main() {
  scanf("%s %s %s", s1, s2, s3);
  putchar(s1[0] - 'a' + 'A'); putchar(s2[0] - 'a' + 'A'); putchar(s3[0] - 'a' + 'A');
  return 0;
}

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

int main(void){
    int n,i;
    scanf("%d",&n);
    int A[n+1],ans[n+1];
    A[0] = 0;
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
        ans[i] = 0;
    }
    
    //i-1 : i-2とi  iとi+1
    //i   : i-2とi-1 i-1とi+1
    
    ans[1] = abs(A[0]-A[2]);
    
    //printf("%d\n",ans[1]);
    
    for(i=2;i<n;i++){
        ans[1] += abs(A[i]-A[i+1]);
    }
    
    ans[1] += abs(A[n]);
    
    for(i=2;i<=n;i++){
        ans[i] = ans[i-1] - abs(A[i-2]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-2]-A[i-1]) + abs(A[i-1]-A[i+1]);
        if(i==n){
            ans[i] = ans[i-1] - abs(A[i-2]-A[i]) - abs(A[n]) + abs(A[i-2]-A[i-1]) + abs(A[n-1]); 
        }
    }
    
    for(i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    
    return 0;
}


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

bool ok(deque<int> v,ll x){
	bitset<32000> cur;
	cur[16000] = 1;
	for(int i = 0 ; i < v.size() ; i++){
		cur = (cur << v[i]) | (cur >> v[i]);
	}
	return cur[16000 + x];
}
void solve(string s, ll x, ll y){
	s += "T";
	deque<int> v[2];
	int c = 0;
	int t = 0;
	for(int i = 0 ; i < s.size() ; i++){
		if( s[i] == 'T' ) v[t].push_back(c), c = 0, t ^= 1;
		else if( s[i] == 'F' ) c++;
	}
	x -= v[0][0];
	if( v[0].size() >= 1 ) v[0].pop_front();

	cout << (ok(v[0], x) && ok(v[1], y) ? "Yes" : "No") << endl;
}

int main(){	
	ll y;
	string s;
	ll x;
	cin >> s;
	scanf("%lld",&x);
	scanf("%lld",&y);
	solve(s, x, y);
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    int n, q;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    cin >> q;
    int t[q];
    rep(i, q) cin >> t[i];
    sort(s, s + n);
    int c = 0;
    rep(i, q) {
        //cout << *lower_bound(s, s + n, t[i]) << endl;
        if (*lower_bound(s, s + n, t[i]) == t[i]) {
            c++;
        }
    }
    cout << c << endl;
}



Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if(A == B) {
        cout << "Draw" << endl;
    }
    else if(A == 1 && B != 1) {
        cout << "Alice" << endl;
    }
    else if(B == 1 && A != 1) {
        cout << "Bob" << endl;
    }
    else if(A > B) {
        cout << "Alice" << endl;
    }
    else if(B > A) {
        cout << "Bob" << endl;
    }
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s >> t;
  rep(i, Size(s)) {
    if (s[i] == t[i]) continue;
    Cout("No");
    return 0;
  }
  Cout("Yes");
  return 0;
}

Measured memory_bytes: 3616
//AtCoder Beginner Contest 063 A
#include <iostream>
using namespace std;

int main() {

	int a, b;
	int sum = 0;
	cin >> a >> b;

	sum = a + b;
	if (sum >= 10) cout << "error" << endl;
	else cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
double ax[100],ay[100],bx[100],by[100];
double dx[4]={1e-6,0,-1e-6,0},dy[4]={0,1e-6,0,-1e-6},eps=1e-9;
int N,M;
bool solve(){
	rep(i,N) cin>>ax[i]>>ay[i];
	rep(i,M) cin>>bx[i]>>by[i];
	rep(i,N) rep(j,M){
		double xx=ax[i]-bx[j],yy=ay[i]-by[j];
		rep(d,4){
			double x=xx+dx[d],y=yy+dy[d];
			double amn=1e50,amx=-1e50,bmn=1e50,bmx=-1e50;
			rep(k,N){
				double z=ay[k]*x-ax[k]*y;
				chmin(amn,z);
				chmax(amx,z);
			}
			rep(k,M){
				double z=by[k]*x-bx[k]*y;
				chmin(bmn,z);
				chmax(bmx,z);
			}
			if(amx+eps<bmn||bmx+eps<amn) return 1;
		}
	}
	return 0;
}
int main(){
	while(true){
		cin>>N>>M;
		if(N==0) break;
		if(solve()) puts("YES");
		else puts("NO");
	}
}

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

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;
	for(int i = n; i >= 0; i--){
		int ok = 1;
		for(int k = 0; k < i; k++){
			if(t[k] != s[k+n-i]) ok = 0;
		}
		if(ok){
			cout << 2*n-i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
const int MAX = 3030;
using M = Mint<int>;
M dp[2][MAX][MAX]={};
signed main(){
  int n,m;
  cin>>n>>m;

  for(int r=0;r<=n;r++)
    dp[r==0][0][r]=M(1);

  for(int i=0;i<m;i++){
    for(int f=0;f<2;f++){
      for(int r=0;r<=n;r++){
        int b=n-r;
        // red red
        if(r){
          int nf=f||(r==1);
          int nr=r-1+1-1;
          dp[nf][i+1][nr]+=dp[f][i][r];
        }
        // red blue
        if(r){
          int nf=f||(r==1);
          int nr=r-1+1;
          dp[nf][i+1][nr]+=dp[f][i][r];
        }
        // blue red
        if(b){
          int nf=f;
          int nr=r+1-1;
          dp[nf][i+1][nr]+=dp[f][i][r];
        }
        // blue blue
        if(b){
          int nf=f;
          int nr=r+1;
          dp[nf][i+1][nr]+=dp[f][i][r];
        }
      }
    }
  }

  M ans{0};
  for(int j=0;j<=n;j++)
    ans+=dp[1][m][j];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 71936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		 Scanner sc = new Scanner(System.in);
	        int A = sc.nextInt();
	        int B = sc.nextInt();
	        int C = sc.nextInt();
	        int X = sc.nextInt();
	        
		int sum = 0;
		int count = 0;
		
		for(int i=0; i<=A; i++) {
			sum = 500*i;
			if(sum==X) {
				count++;
			}else if(sum<X) {
				for(int j=0; j<=B; j++) {
					int sum2 = sum;
					sum2 = sum2 + (100*j);
					if(sum2==X) {
						count++;
					}else if(sum2<X) {
						for(int h=0; h<=C; h++) {
							int sum3 = sum2;
							sum3 = sum3 + (50*h);
							if(sum3== X ) {
								count++;
							}
						}
					}
				}
			}
		}

     System.out.println(count);
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

#define MOD 1000000007

int main(void){
    int N;
    scanf("%d",&N);

    //前3文字だけで文字列を決定する
    //dp[i]は、長さi文字の文字列の数
    long dp[N+1][64];

    //初期値
    for(int i=0;i<64;i++) dp[3][i]=1;
    dp[3][6]  = 0; //AGC
    dp[3][9]  = 0; //ACG
    dp[3][18] = 0; //GAC

    //dpの中を埋める
    for(int i=4;i<=N;i++){
        for(int j=0;j<64;j++){
            dp[i][j]=0;

            if(j==6 || j==9 ||j==18) continue; //末尾がAGC,ACG,GACになるものはdp=0のまま

            //dp[i][j]にどんなdp[i-1][k]を足せばいいのか
            for(int k=0;k<64;k++){
                if( j%4==2 && k%16==1 )         continue; //*AG(k%16=1)にCを足そうとする(j%4=2)のはだめ
                if( j%4==1 && k%16==2 )         continue; //*AC(k%16=2)にGを足そうとする(j%4=1)のはだめ
                if (j%4==2 && k%16==4)          continue; //*GAにCを足そうとするのはだめ
				if (j%4==2 && k>>2==1)          continue; //AG*にCを足そうとするのはだめ
				if (j%4==2 && k>>4==0 && k%4==1)continue; // A*B + C

                //上記以外で、kの末尾2文字とjの頭2文字が一致しているなら、足す
                if((j>>2)==(k%16)) dp[i][j]=(dp[i][j]+dp[i-1][k])%MOD;
            }
        }
    }


    long ans=0;
    for(int i=0;i<64;i++) ans=(ans+dp[N][i])%MOD;
    printf("%ld\n",ans);

    return 0;
}

/*
0 AAA  4 AGA  8 ACA  12 ATA
1 AAG  5 AGG  9 ACG  13 ATG
2 AAC  6 AGC 10 ACC  14 ATC
3 AAT  7 AGT 11 ACT  15 ATT
頭文字G +16
頭文字C +32
頭文字T +48
*/

Measured memory_bytes: 256
#include<iostream>
#define m long long
using namespace std;
#define d(s,i,n) for(int i=s;i<n;i++)
m l[90],r[90],e[90][90],f[90][90];
signed main(){m n;cin>>n;l[0]=1;r[0]=1;d(1,i,90)l[i]=r[i-1],r[i]=l[i-1]+r[i-1];d(0,i,89){e[i][0]=1,f[i][0]=1;d(1,j,90){if(i+1==j)e[i][j]=f[i][j-1],f[i][j]=f[i][j-1]*2+e[i][j-1];else e[i][j]=f[i][j-1],f[i][j]=f[i][j-1]+e[i][j-1];}}d(0,i,n){m c,d;cin>>c>>d;m a=max(c,d);m b=min(c,d);m k=0;d(0,j,90)if(a>=r[j]&&b>=l[j])k=j;m g;if(k==0)k=1,g=1;else if(k==1)if(b==1)g=a;else g=4;else{g=1;if(b>=r[k]&&a>=l[k]&&l[k]<r[k])g++;d(0,j,k)if(f[j][k]<=a&&e[j][k]<=b)g+=1+(a-f[j][k])/e[j][k];d(0,j,k)if(f[j][k]<=b&&e[j][k]<=a)g+=1+(b-f[j][k])/e[j][k];}cout<<k<<" "<<g%1000000007<<endl;}}	

Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template<class T>
T gcd(T n,T m){
    if(n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n),n);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n,x,d,g,K;
    in>>n>>x>>d;
    g=gcd(abs(x),abs(d));
    if(x<0) d=-d,x=-x;
    if(d==0){
        if(x==0) return cout<<1<<endl,0;
        return cout<<n+1<<endl,0;
    }
    K=abs(d/g);
    ll ans{};
    //cout<<"!"<<K<<endl;
    vector<vector<pair<ll,ll>>> v(min(K,n+1));
    fr(k,n+1){
        //cout<<"!"<<k<<endl;
        ll B,A,C;
        A=k*(k-1)/2+k*x/d;
        C=k*(2*n-k-1)/2+k*x/d;
        v[k%K].emplace_back(A,C);
    }
    fr(k,min(K,n+1)){
        //cout<<k<<endl;
        sort(v[k].begin(),v[k].end());
        ll s=LLONG_MIN+1,t=LLONG_MIN;
        for(auto&p:v[k]){
            if(t<p.first){
                ans+=t-s+1;
                tie(s,t)=p;
            }
            else{
                t=max(t,p.second);
            }
        }
        ans+=t-s+1;
    }
    cout<<ans<<endl;
}

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

const int MOD = 1e9 + 7;

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

template < typename T >
void printMatrix (const vector < vector < T > > & mat) {
	for (const vector < T > vec : mat) {
		printVector (vec);
	}
	cout << endl;
}

const ll INF = 1e18L + 5;

template < typename T >
void min_self (T& a, T b) {
	a = min (a, b);
}

template < typename T >
void max_self (T& a, T b) {
	a = max (a, b);
}

template < typename T >
void add_self (T & a, T b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

template < typename T >
void sub_self (T & a, T b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}

ll mul (int a, int b) {
	return ((ll) a * b) % MOD;
}

int main() {
	int n;
	scanf ("%d", &n);
	vector < int > h (n), a (n);
	for (int & x : h) scanf ("%d", & x);
	for (int & x : a) scanf ("%d", & x);
	int base = 1;
	while (base <= n) {
		base <<= 1;
	}
	vector < ll > tree (2 * base);
	vector < ll > dp (n + 1);
	for (int i = 0; i < n; i++) {
		// max dp[j] for j in [0, h[i] - 1]
		// query segment tree
		int x = h[i] + base;
		ll best = 0;
		while (x > 1) {
			if (x % 2) {
				max_self (best, tree[x - 1]);
			}
			x >>= 1;
		}
		dp[h[i]] = best + a[i];
		// update segment tree
		for (int j = base + h[i]; j >= 1; j >>= 1) {
			max_self (tree[j], dp[h[i]]);
		}

		// for (int height = 0; height < h[i]; height++) {
		// 	max_self (dp[h[i]], dp[height] + a[i]);
		// }
	}
	ll answer = 0;
	for (ll x : dp) max_self (answer, x);
	printf ("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 7424
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;

int main() {
	ll n, a, b;
	cin >> a >> b >> n;
	if (b <= n)
		cout << a * (b - 1) / b << endl;
	else
		cout << a * n / b - a * (n / b) << endl;
	
	return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
#ABC67 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

que = deque()
que.append((0,0))
c1 = [False]*n
dist1 = [float('inf')]*n
while que:
    d,v = que.popleft()
    dist1[v] = min(dist1[v],d)
    if not c1[v]:
        c1[v] = True
        for u in g[v]:
            que.append((d+1,u))
que = deque()
que.append((0,n-1))
c2 = [False]*n
dist2 = [float('inf')]*n
while que:
    d,v = que.popleft()
    dist2[v] = min(dist2[v],d)
    if not c2[v]:
        c2[v] = True
        for u in g[v]:
            que.append((d+1,u))

w,b = 0,0
for i in range(n):
    if dist1[i] <= dist2[i]:
        b += 1
    else:
        w += 1
if w < b:
    print('Fennec')
else:
    print('Snuke')


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

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

    int n; cin >> n;
    int a,b,c;
    int ans = 0;

    for(int a = 1;a < 1000001;a ++){
        for(int b = a;a * b < n;b ++){
            if(a == b) ans ++;
            else ans += 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    int N;
    int minans=1000000000;
    cin>>N;
    vector<int> b(N,0),w(N,0);
    

    string S;
    cin>>S;
    if(S[0]=='.'){
            w[0]=1;
        }
        else{
            b[0]=1;
        }
    for(int i=1;i<N;i++){
        if(S[i]=='.'){
            b[i]=b[i-1];
            w[i]=w[i-1]+1;
        }
        else{
            b[i]=b[i-1]+1;
            w[i]=w[i-1];
        }
    }
    minans=w[N-1];
    for(int i=1;i<N+1;i++){
        minans=min(minans,b[i-1]+w[N-1]-w[i-1]);
    }
    cout<<minans<<endl;
    return 0;
}

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

using namespace std;

void solve() {
	long double r;
	cin>>r;
	cout<<6.283185*r<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	solve();
    return 0;
}

Measured memory_bytes: 3744
N,*A = $<.read.split.map(&:to_i)
M = 10**9+7

bc = 60.times.map{|b|
	A.count{|a| a[b]==1 }
}
p 60.times.inject(0){|s,b|
	(s + bc[b]*(N-bc[b])*(1<<b)) % M
}


Measured memory_bytes: 39164
def main():
    n,a,b,k=map(int,input().split())
    fact=[1]
    mod=998244353
    for i in range(1,n+1):fact.append(fact[-1]*i%mod)
    def inv_n(n):return pow(n,mod-2,mod)
    def nCr(n,r):return inv_n(fact[n-r]*fact[r]%mod)*fact[n]%mod
    ans=0
    ans_list=[]
    for i in range(n+1):
        j=(k-a*i)//b
        if i*a+j*b==k:
            if 0<=j<=n:
                ans_list.append([i,j])
    for p,q in ans_list:
        ans=(ans+nCr(n,p)*nCr(n,q))%mod
    print(ans)
main()

Measured memory_bytes: 68828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[801][801];
int h,w,k;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

bool isvalid(int x, int y)
{
	return (x>=0&&x<h&&y>=0&&y<w);
}

bool isexit(int x, int y)
{
	return (x==0||x==h-1||y==0||y==w-1);
}

int dist[801][801];
const int INF = int(1e9);

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w>>k;
	ii s;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S') s=mp(i,j);
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dist[i][j]=INF;
		}
	}
	queue<ii> q;
	q.push(s);
	dist[s.fi][s.se]=0;
	while(!q.empty())
	{
		ii tmp=q.front(); q.pop();
		for(int i=0;i<4;i++)
		{
			int x=tmp.fi+dx[i]; int y=tmp.se+dy[i];
			if(isvalid(x,y))
			{
				if(a[x][y]=='#') continue;
				if(dist[x][y]>=INF)
				{
					dist[x][y]=dist[tmp.fi][tmp.se]+1;
					q.push(mp(x,y));
				}
			}
		}
	}
	int ans=INF;
	vector<ii> vec;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(isexit(i,j)) ans=min(ans,dist[i][j]);
			if(dist[i][j]<=k)
			{
				vec.pb(mp(i,j));
			}
		}
	}
	if(ans<=k)
	{
		cout<<1<<'\n';
		return 0;
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dist[i][j]=INF;
			if(isexit(i,j))
			{
				dist[i][j]=0;
				q.push(mp(i,j));
			}
		}
	}
	while(!q.empty())
	{
		ii tmp=q.front(); q.pop();
		for(int i=0;i<4;i++)
		{
			int x=tmp.fi+dx[i]; int y=tmp.se+dy[i];
			if(isvalid(x,y))
			{
				if(dist[x][y]>=INF)
				{
					dist[x][y]=dist[tmp.fi][tmp.se]+1;
					q.push(mp(x,y));
				}
			}
		}
	}
	for(int i=0;i<vec.size();i++)
	{
		ans=min(ans,dist[vec[i].fi][vec[i].se]);
	}
	cout<<(ans+k-1)/k+1<<'\n';
}


Measured memory_bytes: 12268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=2e6+7;
ll a[MAXN],b[MAXN],n,sum,minn=1e9+7;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		sum+=a[i];
		if(a[i]>b[i]) if(minn>b[i]) minn=b[i];
	}
	if(minn==1e9+7) cout<<0<<endl;
	else cout<<sum-minn;
}

Measured memory_bytes: 2432
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
        printf("1\n");
    else if(n>=64)
        printf("64\n");
   else  if(n>=32)
        printf("32\n");
  else  if(n>=16)
        printf("16\n");
   else if(n>=8)
        printf("8\n");
   else if(n>=4)
        printf("4\n");
   else if(n>=2)
        printf("2\n");
   else if(n==0)
        printf("0\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin>>s;
    char tmp;

	if(s.length()==3){
        tmp=s[2];
        s[2]=s[0];
        s[0]=tmp;
    }


    cout << s << endl;

	return 0;
}




Measured memory_bytes: 256
from sys import stdin

n, k = (int(x) for x in stdin.readline().rstrip().split())
p = [int(x) for x in stdin.readline().rstrip().split()]
ev = [(i+1)/2 for i in p]
s = [ev[0]]
for i in range(1, n):
    s.append(s[i-1] + ev[i])

m = s[k-1]
for j in range(n-k):
    a = s[j+k] - s[j]
    if m < a:
        m = a

print(m)

Measured memory_bytes: 24648
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        while (in.hasNext()) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt(), e = in.nextInt(),
                    f = in.nextInt();
            double x, y;
            x = (double) (c * e - b * f) / (double) (a * e - b * d);
            y = (double) (c - (a * x)) / (double) (b);

            System.out.println(String.format("%.3f", x + 0.0) + " " + String.format("%.3f", y + 0.0));
        }
    }
}

Measured memory_bytes: 26120
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,k;
    cin>>n>>k;
    n=n%k;
    cout<<min(abs(n-k),n)<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, X;
  cin >> N >> X;
  int sum, Xmin, K;
  sum = 0;
  Xmin = 1000000;
  rep(i, N) {
    cin >> K;
    sum += K;
    Xmin = min(Xmin, K);
  }
  cout << N + (X - sum) / Xmin << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long X, K, D;

    cin >> X >> K >> D;
    long abs_X = abs(X);

    long amari = abs_X % D;
    long shou = (abs_X - amari) / D;

    if (shou >= K) {
        cout << abs_X - K * D << endl;
    } else {
        if (shou % 2 == K % 2) {
            cout << amari << endl;
        } else {
            cout << abs(amari - D) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3652
//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,k,m,n,q;
	double x,y,z,r,t;
	for(;scanf("%d",&n),n;){
		vector<vector<double> >v;
		for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v.push_back({x,y,z,r});
		for(i=0;i<n;i++)parent[i]=i;
		for(q=m=i=0;i<n;i++)for(j=i+1;j<n;j++){
			for(x=k=0;k<3;k++)x+=(t=v[i][k]-v[j][k])*t;
			x=sqrt(x)-v[i][3]-v[j][3];
			if(x<=0){if(unite(i,j))q++;}
			else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
		}
		sort(node,node+m);
		for(x=i=0;i<m&&q<n-1;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
		printf("%.3f\n",x);
	}
}

Measured memory_bytes: 1296