akhauriyash/Code-Regression huggingface dataset:
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define fastio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fre(i,n) fr(i,1,n)
#define trav(a, x) for (auto& a : x)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define endl "\n"
#define F first
#define S second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define viii vector< vector<vector<int> > >
#define cd complex<double>
#define PI acos(-1)
#define pie 3.14159265358979323846
#define all(c) (c).begin(),(c).end()
#define prec(n) fixed << setprecision(n)
#define print_time {cout << flush; cerr << endl << "Time taken: " << fixed << setprecision(3) << 1.0 * clock() / CLOCKS_PER_SEC << " secs\n";}
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b)) / gcd((a),(b))
#define bc(n) __builtin_popcountll(n)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())

typedef long double ld;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int inft = (1LL<<61) ;
const int inf = 5e18;
const int mod = 1e9+7;

int modpow(int x, int n, int mod)
{
    x %= mod ;
    int res = 1;
    while(n>0){
        if(n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

const int N = 1e6+1e4+1e2+1 ;
const int M = 3*(1e5+1e3+1e1) ;

///////////////////////////  Code Starts from here /////////////////////////////



signed main()
{
    fastio() ;
    cin.exceptions(cin.failbit);
    srand(chrono::steady_clock::now().time_since_epoch().count());

    #ifndef ONLINE_JUDGE
       //freopen("input.txt", "r", stdin);
    #endif // ONLINE_JUDGE

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

    if(a==b && b==c)
    {
        cout << "Yes" ;
    }
    else
    {
        cout << "No" ;
    }

return 0 ;
}





Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		 Scanner sc = new Scanner(System.in);
    	        int n = sc.nextInt();
    	        int k = sc.nextInt();
    	        String str = "";
    	        for(int i = 0; i < k; i++) {
    	        	str = str + sc.next();
    	        }
    	        for(int i = n; i <= 100000; i++ ) {
    	        	if(check(i,str)) {
    	        		System.out.print(i);
    	        		sc.close();
    	        		return;
    	        	}
    	        }
    	        sc.close();
    		}
    		private static boolean check(int n, String str){
    			boolean result = true;
    			String m;
    			while(n >= 1) {
    				m = String.valueOf(n % 10);
    				int comp = str.indexOf(m);
    				if(comp != -1) {
    					result = false;
    				}
    				n = n / 10;
    			}
    			return result;
        }
    }

Measured memory_bytes: 31184
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll h;
  	cin>>h;
  	ll c=1,ans=0;
  	while(h>0){
    	ans+=c;
      	c=c*2;
      	h=h/2;
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(i, j):
    visited[i][j] = True
    res_b = 0
    res_w = 0
    if N[i][j]:
        res_b += 1
    else:
        res_w += 1
    for di, dj in d:
        if i + di < 0 or i + di >= H or j + dj < 0 or j + dj >= W:
            continue
        if N[i][j] == N[i+di][j+dj]:
            continue
        if visited[i+di][j+dj]:
            continue
        tmp_b, tmp_w = dfs(i + di, j + dj)
        res_b += tmp_b
        res_w += tmp_w
    return res_b, res_w

H, W = map(int, input().split())
N = [[False] * W for _ in range(H)]
for i in range(H):
    s = input()
    for j in range(W):
        N[i][j] = (s[j] == "#")

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]
visited = [[False] * W for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if not N[i][j]:
            continue
        if visited[i][j]:
            continue
        b, w = dfs(i, j)
        ans += (b * w)

print(ans)

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

void fastInputOutput(){ios_base::sync_with_stdio(false);cin.tie(NULL);}


ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
ll POW(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}

const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);

int main()
{
    fastInputOutput();
    double r;
    cin >> r;
    double ans = 2 * phi * r;
    printf("%0.10f\n", ans);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> per(n);
    vector<double> x(n),y(n),sum;
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
        per[i] = i;
    }
    do{
        double tmp=0; 
        for(int i=1; i<n; i++){
            tmp += sqrt((x[per[i]]-x[per[i-1]])*(x[per[i]]-x[per[i-1]])+
            (y[per[i]]-y[per[i-1]])*(y[per[i]]-y[per[i-1]]));
        }
        sum.emplace_back(tmp);
    }while(next_permutation(per.begin(), per.end()));
    double ans=0;
    for(int i=0; i<sum.size(); i++){
        ans += sum[i];
    }
    cout << fixed;
    cout << ans / (double)sum.size() << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

class SegT{
private:
  int dat[2 * (1 << 17) - 1]; // = 131072
  int NN;

public:
  SegT(int n_){
	NN = 1;
	while(NN < n_) NN <<= 1;
	for(int i=0;i<2*NN-1;++i) dat[i] = -INF;
  }

  void update(int idx, int a){
	idx += NN - 1;
	dat[idx] += a;
	while(idx > 0){
	  idx = (idx - 1) / 2;
	  dat[idx] = max(dat[idx*2+1], dat[idx*2+2]);
	}
  }

  int query(int k, int l, int r){
	if(r-l == 1) return l;
	int m = (l+r)/2;
	if(dat[k*2+1] >= dat[k*2+2])
	  return query(k*2+1, l, m);
	else
	  return query(k*2+2, m, r);
  }
  int query(){
	return query(0, 0, NN);
  }
};

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

  int N, R, L;
  cin >> N >> R >> L;
  SegT seg(N);
  REP(i,N) seg.update(i, INF);
  VI tm(N);
  int prv = 0;
  REP(i,R){
	int d, t, x;
	cin >> d >> t >> x;
	tm[seg.query()] += t - prv;

	seg.update(d-1, x);
	prv = t;
  }
  tm[seg.query()] += L - prv;

  int ans = 0;
  REP(i,N) if(tm[ans] < tm[i]) ans = i;

  cout << ans+1 << endl;

  return 0;
}



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

#define MAX 1000000
vector<bool> prime(MAX+1,true);
void init(){
	prime[0] = prime[1] = 0;
	for(int i=2;i*i<=MAX;i++){
		if(prime[i]){
			for(int j=i*i;j<=MAX;j+=i){
				prime[j] = false;
			}
		}
	}
}

int main(){
	init();
	
	int n;
	while(cin >> n , n){
		int ans = 0;
		for(int i=1;i<=n/2;i++){
			if(prime[i] & prime[n-i])ans++;
		}
		cout << ans << endl;
	}
}

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

void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 


for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 


int index = L[m][n]; 


char lcs[index+1]; 
lcs[index] = '\0';


int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; 
		i--; j--; index--;	 
	} 

	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
	cout << lcs << "\n"; 
} 

/* Driver program to test above function */
int main() 
{ 
char X[3001] ; 
char Y[3001]; 
cin>>X>>Y;
int m = strlen(X); 
int n = strlen(Y); 
lcs(X, Y, m, n); 
return 0; 
} 


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>0)cout<<"Positive"<<endl;
  else if(b>=0)cout<<"Zero"<<endl;
  else cout<<((b-a+1)%2?"Negative":"Positive")<<endl;
  return 0;
}


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

public class Main {
 static final List<String>  WEEK_STR   = Collections
	                                       .unmodifiableList(
	                                       Arrays.asList(
	                                         "Monday",
	                                         "Tuesday",
	                                         "Wednesday",
	                                         "Thursday",
	                                         "Friday",
	                                         "Saturday",
	                                         "Sunday"));
 static final List<Integer> MONTH_DATE = Collections
	                                       .unmodifiableList(
	                                       Arrays.asList(
	                                         31, 29, 31, 30,
	                                         31, 30, 31, 31,
	                                         30, 31, 30, 31));

 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int month = in.nextInt();
	int date = in.nextInt();
	while (month > 0) {
	 int weekDate = 2 + date;
	 for (int m = 0; m < month - 1; m++) {
		weekDate += MONTH_DATE.get(m);
	 }
	 System.out.println(WEEK_STR.get(weekDate % 7));
	 month = in.nextInt();
	 date = in.nextInt();
	}
 }
}

Measured memory_bytes: 12000
from sys import stdin
import numpy as np
 
def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(x) for x in stdin.readline().rstrip().split()]
    X = 1
    L = [1]
    if A[0] == 1:
        print(1)
        exit()
    if N >= K :
        for i in range(K):
            X = A[X-1]
        print(X)
        exit()
    else:
        for i in range(N):
            X = A[X-1]
            L += [X]
        #print('L',L)#OK
        C = np.zeros(N)
        for i in range(N):
            if C[L[i]-1] == 0:
                C[L[i]-1] += 1
                #print('C,i',C,i)
            else:
                break
        #print('C',C)
        #print('i+1',i+1)#Roop 回数　When Roop Goal
        #print('L[i+1]',L[i+1])#Roop initial Number
        S = L.index(L[i+1])
        #print('S',S)#When Roop Start ,Roop times
        #print(K - i-1)#Remain K
        #print('i + 1 -S',i + 1 - S)#Roop Cycle
        K = (K - i-1)%(i+1 - S)
        #print(K)
        print(L[S+K])
        
main()

Measured memory_bytes: 51036
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int b1 = 0, b2 = 0, b3 = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (p <= a) {
            b1++;
        }
        else if (a + 1 <= p && p <= b) {
            b2++;
        }
        else
            b3++;
    }
    cout << min(b1, min(b2, b3)) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	double a, b;
	cin >> a >> b;
	double n = a / b;
	cout << fixed << setprecision(8) << n << endl;
	return 0;
}


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

int isPrime(int n) {
  int i;
  int l;
  if(n == 1) return 0;
  if(n == 2) return 1;
  if(n % 2 == 0) return 0;

  l = sqrt(n);
  for(i = 3; i <= l; i += 2) {
    if(n % i == 0) return 0;
  }
  return 1;
}

int main() {
  int in;
  int temp;
  int out;

  while(scanf("%d", &in) != EOF) {
    temp = in - 1;
    if(temp == 2) out = temp;
    else {
      if(temp % 2 == 0) temp--;
      for(; temp > 2; temp -= 2) {
	if(isPrime(temp)) {
	  out = temp;
	  break;
	}
      }
    }
    printf("%d ", out);
    
    temp = in + 1;
    if(temp % 2 == 0) temp++;
    for(; ; temp += 2) {
      if(isPrime(temp)) {
	out = temp;
	break;
      }
    }
    printf("%d\n", out);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=1e5+5,M=5e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
typedef multiset<pa>::iterator itr;
multiset<pa>t[N];
pa st[N];
int fa[N],top,n;
int getf(int x){return fa[x]==x?x:fa[x]=getf(fa[x]);}
void adde(int a,int b,int typ){
	itr it=t[a].find(pa(b,1^typ));
	if(it==t[a].end())t[a].insert(pa(b,typ)),t[b].insert(pa(a,typ));else{
		t[a].erase(it);
		it=t[b].find(pa(a,1^typ));
		t[b].erase(it);
		st[++top]=pa(a,b);
	}
}
void merge(int a,int b){
	a=getf(a);b=getf(b);if(a==b)return;
	if(t[a].size()<t[b].size())swap(a,b);
	fa[b]=a;
	for(itr it=t[b].begin();it!=t[b].end();it++){
		int x=it->w1,typ=it->w2;
		itr z=t[x].find(pa(b,typ));
		t[x].erase(z);
		adde(x,a,typ);
	}
}
int main(){
	read(n);
	rep(i,1,n)fa[i]=i;
	rep(i,1,n-1){
		int a,b;read(a,b);
		a=getf(a);b=getf(b);
		adde(a,b,0);
	}
	rep(i,1,n-1){
		int a,b;read(a,b);
		a=getf(a);b=getf(b);
		adde(a,b,1);
	}
	rep(i,1,top)merge(st[i].w1,st[i].w2);
	rep(i,1,n)if(getf(1)!=getf(i))return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 26112
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k,m;
  while(1){
    cin>>n>>k>>m;
    if(n+k+m==0)break;
    m--;
    vi v(n);
    rep(i,n)v[i]=i;
    v.erase(v.begin()+m);
    int a=m-1;
    while(v.size()>1){
      v.erase(v.begin()+(a+k)%v.size());
      a=(a+k)%(v.size()+1)-1;
    }
    cout<<v[0]+1<<endl;
  }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> ABC(3);
    ll count = 0;
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(ABC.begin(), ABC.end());
    count = (ABC[1] - ABC[0]) / 2;
    ABC[0] += 2 * count;
    count += ABC[2] - ABC[1];
    ABC[0] += ABC[2] - ABC[1];
    if(ABC[0] < ABC[2]) count += 2;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func search(bs []int, idx, rest int) int {
	if len(bs) == 1 {
		return bs[idx]
	}
	if bs[idx] <= rest {
		bs = bs[idx:len(bs)]
	} else {
		bs = bs[0:idx]
	}
	return search(bs, int(len(bs)/2), rest)
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m, k := nextInt(), nextInt(), nextInt()

	as := make([]int, n+1)
	as[0] = 0
	bs := make([]int, m+1)
	bs[0] = 0
	amax := 0
	bmax := 0

	for i := 0; i < n; i++ {
		a := nextInt()
		as[i+1] = a + amax
		amax = as[i+1]
	}

	bhash := map[int]int{}
	bhash[0] = 0
	for i := 0; i < m; i++ {
		b := nextInt()
		bs[i+1] = b + bmax
		bmax = bs[i+1]
		bhash[bmax] = i + 1
	}

	ans := 0
	for i := 0; i < len(as); i++ {
		rest := k - as[i]
		if rest < 0 {
			break
		}

		bidx := search(bs, int(len(bs)/2), rest)
		bscount := bhash[bidx]

		if ans < i+bscount {
			ans = i + bscount
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 17460
#include <stdio.h>
#include <string.h>
int main()
{
    char str[3];
    int sum=0;
    scanf("%s",str);
    if(str[0]=='R')
    {
        if(str[1]=='R')
        {
            if(str[2]=='R')
            {
                sum=3;
            }
            else
            {
                sum=2;
            }
        }
        else
        {
            sum=1;
        }
        printf("%d",sum);
        return 0;
    }
    if(str[1]=='R')
    {
        if(str[2]=='R')
        {
            sum=2;
        }
        else
        {
            sum=1;
        }
        printf("%d",sum);
        return 0;
    }
    if(str[2]=='R')
    {
        sum=1;
    }
    printf("%d",sum);
}

Measured memory_bytes: 1700
N,K = map(int, input().split())

MOD = 10**9+7

st = int((K-1)*(K)/2)
go = int((2*N-K+1)*(K)/2)
ans = 0

for i in range(N+1-K+1):
    ans += go - st + 1
    if ans >= MOD:
        ans = ans % MOD
    st = st + i + K
    go = go + N - K - i
    
print(ans)

Measured memory_bytes: 9200
n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]
ans=0
for i in a:
    tmp=1
    while True:
        if tmp*i+1<=d:
            a=tmp*i+1
            #print(a)
            tmp+=1
        else:
            #print("tmp",tmp)
            ans+=tmp
            break
print(ans+x)          
            

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

cost = sorted(list(zip([[2, 5, 5, 4, 5, 6, 3, 7, 6][a-1] for a in A], A)), key=lambda x: (x[0], -x[1]))

#print(list(zip([[2, 5, 5, 4, 5, 6, 3, 7, 6][a-1] for a in A], A)))
#print(cost)


tmp = len(cost)
i = 1
while i < tmp:
    if cost[i][0] == cost[i-1][0]:
        cost.pop(i)
        tmp = len(cost)
    else:
        i += 1
cost.sort(key=lambda x:-x[1])



dp = [0] + [-10] * (N)
for i in range(2, N+1):
    dp[i] = max([-10] + [dp[i-c]+1 for c, _ in cost if i >= c])

n = N
out = ""
i = 0
while n:
    c, a = cost[i]
    if (n >= c) and (dp[n-c] == dp[n] - 1):
        n -= c
        out += str(a)
    else:
        i += 1
print(out)

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

int main()
{
   int n, h, amax = 0, ans = 0;
   cin >> n >> h;
   vector<int> a(n), b(n);
   for(int i = 0;i < n;i++){
       cin >> a[i] >> b[i];
       amax = max(a[i], amax);
   }

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

    for(int i = n - 1;b[i] >= amax && i >= 0;i--){
        h -= b[i];
        ans++;
        if(h <= 0){
            break;
        }
    }

    while(h > 0){
        h -= amax;
        ans++;
    }

    cout << ans;

    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, x, y;
  cin >> n;
  vec2ll v(2, vecll(100000));
  vecll e0(2), e1(2), e2(2);
  forll(i, 0, n){
	cin >> x;
    x--;
	y = i & (ll)1;
	v[y][x]++;
	if(v[y][x] > e1[y]){
	  e1[y] = v[y][x];
	  e0[y] = x + 1;
	}else if(v[y][x] > e2[y]){
	  e2[y] = v[y][x];
	}
  }
  cout << n - (e0[0]!=e0[1]? e1[0]+e1[1]: max(e1[0]+e2[1], e2[0]+e1[1])) <<endl;
}


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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll N; cin >> N;

  ll ans = 0;
  if (B <= N) {
    ans = (A * (B - 1)) / B;
  } else {
    ans = (A * N) / B;
  }
  cout << ans << '\n';
  return 0;
}

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


int main() {
  string s;
  cin >> s;
  for (char c: s) {
    cout << (c == '1' ? '9' : '1');
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int i,j,c=0;
     string s,t;
     cin>>s>>t;
     for(i=0,j=0;i<s.size(),j<t.size();i++,j++){
          if(s[i]!=t[j])
               c++;
               //else continue;
     }
     cout<<c<<endl;

     return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll H,W;
  cin>>H>>W;
  ll Ch,Dh,Cw,Dw;
  cin>>Ch>>Cw>>Dh>>Dw;
char S[H][W];
ll dist[H][W];
  for(ll i=0;i<H;i++){
    for(ll j=0;j<W;j++){
     cin>>S[i][j];
     dist[i][j]=INF;
    }
  }
  
  dist[Ch-1][Cw-1]=0;
  deque<pair<ll,ll> > que;
  que.push_front(make_pair(Ch-1,Cw-1));
  
  
  while(!que.empty()){
  ll h=que.front().first;
  ll w=que.front().second;
  que.pop_front();

    
    for(ll i=-2;i<=2;i++){
      //cout<<i<<endl;
      for(ll j=-2;j<=2;j++){
        if(abs(i)+abs(j)==0){continue;}
        if(h+i<0||H<=h+i){continue;}
        if(w+j<0||W<=w+j){continue;}
        if(S[h+i][w+j]=='#'){continue;}        
        if((abs(i)+abs(j))==1){
          if(dist[h+i][w+j]<=dist[h][w]){continue;}
          dist[h+i][w+j]=dist[h][w];
          que.push_front(make_pair(h+i,w+j));
        }
        
        if(dist[h+i][w+j]<=dist[h][w]+1){continue;}
         dist[h+i][w+j]=dist[h][w]+1;
         que.push_back(make_pair(h+i,w+j));
                
      }
    }
    
  }
  
  
  
  
  
if(dist[Dh-1][Dw-1]==INF){
cout<<"-1"<<endl;
} 
else{
  cout<<dist[Dh-1][Dw-1]<<endl;}
  
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B;
  cin>>A>>B;
  if(A>=13)cout<<B<<endl;
  else if(A>=6)cout<<B/2<<endl;
  else cout<<0<<endl;
  return 0;
}


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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i<N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-indexにしておく
  
  bool can = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }
  cout << (can ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
  int A, B;
  scanf("%d", &A);
  scanf("%d", &B);
  
  if(1 <= A,B <=9 && (A + B) < 10 ){
  printf("%d\n", A+B);
  }
  
  else{
  printf("error");
  }
  
  return 0;
  }

Measured memory_bytes: 128
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

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

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[25][25],n;
ll dp[23][(1<<21)];

ll add(ll x, ll y){
	return (x+y)%mod;
}

ll go(ll men, ll mask){
	if(men == n+1) {
		if(mask == (1<<n)-1) return 1;
		else return 0;
	}

	ll &ans = dp[men][mask]; 
	if(ans!=-1)return ans;

	ans = 0 ;
	for(int i = 1; i<=n; i++){
		if( !( mask&(1<<(i-1)) ) && a[men][i] ) {
			ans = add(ans, go(men+1, mask|(1<<(i-1)))) ;
		}
	}
	return ans;
}

void solve()
{    
    cin>>n ;
    memset(dp,-1,sizeof dp);
    for(int i=1; i<=n; i++){
    	for(int j=1; j<=n; j++){
    		cin >> a[i][j] ;
    	}
    }

    cout<<  go(1,0);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  cin >> n;
  int aa[500001] = {};
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    aa[a + b]++;
  }

  rep(i, 0, 500000) {
    if(aa[i]) {
      aa[i + 1] += aa[i] / 2;
      if(aa[i] % 2 == 1) cout << i << " " << 0 << endl;
    }
  }
}

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

const ll mod = 1e9 + 7;

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

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

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

    ll h, n, a, sum = 0;
    cin >> h >> n;
    rep(i, n) {
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int a[200010],b[200010];
int c[200010],d[200010];
int main(void)
{
	int i,j,k,n,m;
	scanf("%d%d",&n,&m);
	memset(c,0,sizeof(c));
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]==1)
		c[b[i]]++;
		if(b[i]==1)
		c[a[i]]++;
		if(a[i]==n)
		d[b[i]]++;
		if(b[i]==n)
		d[a[i]]++;
		
	}
	k=0;
	for(i=2;i<n;i++)
	{
		if(c[i]==1&&d[i]==1)
		{
			k=1;
			break;
		}
	}
	if(k==1)
	printf("POSSIBLE\n");
	else
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int N, K, Q; cin >> N >> K >> Q;
  
  vector<int> a(100010, 0);

  rep(i, Q) {
    int l;
    cin >> l;
    ++a[l-1]; 
  }
  rep(i, N) {
    if(Q-a[i]<K) cout << "Yes" << endl;
    else cout << "No" << endl;
}
}

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

int main() {
    int N;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N ;
    for(int i=0;i<N;i++)cin>>a[i];

    int count =1;
    sort(a, a + N);  // a[0:N] を大きい順にソート
    for(int i= 1 ;i<N;i++){
      if(a[i-1] != a[i])count++;
     
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 220;
int n,cnt[N][N]; char s[N];
int main(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        int len = strlen( s + 1 );
        for (int j=1;j<=len;j++)
            cnt[i][s[j]-'a'+1]++;
    }
    for (int i=1;i<=26;i++)
    {
        int Min = 1<<30;
        for (int j=1;j<=n;j++)
            Min = min( Min , cnt[j][i] );
        for (int j=1;j<=Min;j++)
            printf("%c",i+'a'-1);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 998244353;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
const ll MAX = 510000;
const ll MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
int main()
{
ll n , m , k ;
cin >> n >> m >> k ;
COMinit();
rep(i,k+1){
  ans=mod(ans+mod(m*mypow(m-1,n-1-i))*COM(n-1,i));
}

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

Measured memory_bytes: 15580
function main(input) {
    const input_array = input.split('\n');

//    const A = parseInt(args[0], 10),
//          B = parseInt(args[1], 10),
//          C = parseInt(args[2], 10),
//          X = parseInt(args[3], 10);

    const coins_count = input_array.slice(0,3);
    const desired_sum = parseInt(input_array.slice(-1), 10);
    const A = parseInt(input_array[0], 10),
          B = parseInt(input_array[1], 10),
          C = parseInt(input_array[2], 10),
          X = parseInt(input_array[3], 10);

    var count = 0;

    for (var a = 0; a <= A; ++a) {
        for (var b = 0; b <= B; ++b) {
            for (var c = 0; c <= C; ++c) {
                var sum = (a * 500) + (b * 100) + (c * 50);
                if (sum === X) ++count;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define dump(variable) cout << #variable << ": " << variable << endl
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    string s, t;
    cin >> s >> t;
    vector<int> c1(26), c2(26);

    rep(i, s.size()) {
        c1[s[i] - 'a']++;
        c2[t[i] - 'a']++;
    }

    sort(c1.begin(), c1.end());
    sort(c2.begin(), c2.end());

    if (c1 == c2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;

}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 305;

int m[N][N];
char a[N][N];

bool mark[N];

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

    int h, w, k;
    cin >> h >> w >> k;
    fo1(i, h) fo1(j, w) {
        cin >> a[i][j];
        if (a[i][j] == '#') mark[i] = true;
    }


    int p = 1;
    fo1(i, h) {
        if (!mark[i]) continue;

        bool first = true;
        fo1(j, w) {
            if (a[i][j] == '#') {
                if (!first) p++;
                first = false;

            }
            m[i][j] = p;
        }

        p++;
    }

    rep(i, 1, h) {
        if (!mark[i] && mark[i-1]) {
            fo1(j, w) {
                m[i][j] = m[i-1][j];
            }
            mark[i]= true;
        }
    }

    repb(i, h-2, -1) {
        if (!mark[i] && mark[i+1]) {
            fo1(j, w) {
                m[i][j] = m[i+1][j];
            }
            mark[i] = true;
        }
    }

    fo1(i, h) { 
        fo1(j, w) {
            cout << (j ? " " : "") << m[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<bool>dp((int)s.size()+1213,0);
  int n=s.size();
  dp.at(0)=1;
  for(int i=0;i<n;++i){
    if(dp.at(i)==0)continue;
    if(i+5<=n && s.substr(i,5)=="dream")dp.at(i+5)=1;
    if(i+7<=n && s.substr(i,7)=="dreamer")dp.at(i+7)=1;
    if(i+5<=n && s.substr(i,5)=="erase")dp.at(i+5)=1;
    if(i+6<=n && s.substr(i,6)=="eraser")dp.at(i+6)=1;
  }
  if(dp.at(n))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


class FactorialMod{
    void calc_inverse(){
        inverse[0] = 0;
        inverse[1] = 1;
        for(int i=2; i<=max_num; i++){
            inverse[i] = MOD-((MOD/i)*inverse[MOD%i]%MOD);
        }
    }

    void calc_factorial_inverse(){
        factorial[0] = factorial_inverse[0] = 1;
        for (int i=1; i<=max_num; i++) {
            factorial[i] = (factorial[i-1]*i)%MOD;
            factorial_inverse[i] = (factorial_inverse[i-1]*inverse[i])%MOD;
        }
    }

    public:
        int max_num;
        vector<ll> inverse; 
        vector<ll> factorial;
        vector<ll> factorial_inverse;
        FactorialMod(int _max_num){
            max_num = _max_num;
            inverse = vector<ll>(max_num+1);
            factorial = vector<ll>(max_num+1);
            factorial_inverse = vector<ll>(max_num+1);
            calc_inverse();
            calc_factorial_inverse();
        }

        ll combination(int n, int k){
            return (((factorial[n]*factorial_inverse[k])%MOD)*factorial_inverse[n-k])%MOD;
        }

        ll multiChoose(int n, int k){
            return combination(n+k-1, k);
        }
        
};

ll modpow(ll x, ll n){
    ll res=1, dig=x;
    while(n){
        if(n&1) res = res*dig%MOD;
        dig = dig*dig%MOD;
        n /= 2;
    }
    return res;
}

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

    ll res=0, n=s.size();
    FactorialMod calc_mod(n+k);
    REP(i, k+1){
        res += modpow(26, i)*modpow(25, k-i)%MOD*calc_mod.multiChoose(n, k-i)%MOD;
        res %= MOD;
    }
    cout << res << endl;
  
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	cin>>n;
	vii v(n);vi vs(n);iota(all(vs),0);
	for(int i=0;i<n;++i){
		cin>>v[i].ff >> v[i].ss;
	}
	vll dist;
	int tot=0;
	do{
		++tot;
		for(int i=1;i<n;++i){
			ll dx = (v[vs[i]].ff-v[vs[i-1]].ff)*(v[vs[i]].ff-v[vs[i-1]].ff);
			ll dy = (v[vs[i]].ss-v[vs[i-1]].ss)*(v[vs[i]].ss-v[vs[i-1]].ss);
			dist.pb(dx+dy);
		}
	}while(next_permutation(all(vs)) );
	double pqp=0.0,na=0.0;
	for(int i=0;i<dist.size();++i){
		pqp+=sqrt(dist[i]);
		na+=dist[i];
	}
	cout.precision(10);
	cout<<fixed<<pqp/(double)tot<<endl;
	return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif
 
	string s;
	cin>>s;
	assert((int)s.size()==6);
	if(s[2]==s[3] and s[4]==s[5])
	{
		cout<<"Yes";
	}
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int m =a.size();
    int n =b.size();
    int i,j,k;
    int dp[m+1][n+1];
    for( i=0; i<=m; i++)
        dp[i][0]=1;
    for( i=0; i<=n; i++)
        dp[0][i]=1;
    for( i=1; i<=m; i++)
    {
        for( j=1; j<=n; j++)
        {
            if(a[i-1]==b[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    i=m;
    j=n;
    vector<char>v;
    while(i>0 && j>0)
    {
        if(dp[i][j]== 1 + dp[i-1][j-1] && a[i-1]==b[j-1])
        {
            v.push_back(a[i-1]);
            i--;
            j--;
            continue;
        }
        if(dp[i][j] == dp[i-1][j])
        {
            i--;
        }
        else
            j--;
    }
    for(int i=v.size()-1; i>=0; i--)
        cout<<v[i];
}


Measured memory_bytes: 35456
#include <stdio.h>

int main(void){

  int H, W;
  int i, j;

  while(1){
  scanf("%d %d",&H ,&W);
  if(H == 0 || W == 0){break;}

  for(j = 0; j < H; j++){
    for(i = 0; i < W; i++){

      if(i == 0 || i == W - 1 || j == 0 || j == H - 1){

	printf("#");

      }
      else printf(".");

}
  printf("\n");
  }
  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
def push(x, top, S):
      S.append(x)
      top = top + 1

def pop(top):
      del S[top-1]
      top = top - 1

if __name__ == "__main__":
      stdin = input()
      stdin = stdin.split()
      n = len(stdin)
      S = []
      top = len(S)
      for i in range(0, n):
            if stdin[i] == '+':
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
      print(S[top])

Measured memory_bytes: 7772
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        string S = ReadLine();
        int N = S.Length;
        var dp = new long[N+1,13];
        dp[0, 0] = 1;
        for (int i = N; i >= 1; i--)
        {
            if (S[i-1] == '?')
            {
                int c = N - i;

                for (int n= 0; n < 10;n++ )
                {
                    Modular m = n * Modular.Pow(10, c);
                    for (int j = 0; j < 13; j++)
                    {
                        var v = dp[c, j];
                        dp[c + 1, (j + (int)m) % 13] += v;
                        dp[c + 1, (j + (int)m) % 13] %= 1000000007;
                    }
                }
            }
            else
            {
                int c = N - i;
                Modular n = S[i-1] - '0';
                Modular m = n * Modular.Pow(10, c);
                for (int j = 0; j < 13; j++)
                {
                    var v = dp[c, j];
                    dp[c + 1, (j + (int)m) % 13] += v;
                    dp[c + 1, (j + (int)m) % 13] %= 1000000007;
                }
            }
        }
        WriteLine(dp[N,5]);
    }
}
class Modular
{
    private const int M = 13;
    private long value;
    public Modular(long value = 0) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    => a.value + b.value;
    public static Modular operator -(Modular a, Modular b)
    => a.value - b.value;
    public static Modular operator *(Modular a, Modular b)
    => a.value * b.value;
    public static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    public static Modular Fac(int n)   //階乗
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Fac(int r, int n)
    {
        int temp = 1;
        for (int i = r; i <= n; i++)
        {
            temp = (int)(Math.BigMul(temp, i) % M);
        }
        return temp;
    }
    public static Modular Ncr(int n, int r) //nCr
    {
        return (n < r) ? 0
             : (n == r) ? 1
                        : (n < 1000000) ? Fac(n) / (Fac(r) * Fac(n - r))
                            : Fac(n - r + 1, n) / Fac(r);
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

Measured memory_bytes: 54784
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int a[1000][1000],b[1000][1000],c[1000][1000];
//char x[1050][150],y[100050][20];

int main()
{
    long long int i,n,m,j,k,x,y;
    long long  int sum=0;
    scanf("%lld",&n);
    //memset(b,1,sizeof(b));
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            scanf("%lld",&a[i][j]);

        }
    }
    memset(c,0,sizeof(c));
    for(k=1;k<=n;k++)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                if(b[i][j]==0)
                {
                    b[i][j]=a[i][j];
                }
                b[i][j]=min(b[i][j],a[i][k]+a[k][j]);
                if((a[i][j]>=a[i][k]+a[k][j])&&(i!=k&&j!=k))
                {
                    c[i][j]=1;
                    b[i][j]=a[i][k]+a[k][j];
                }
            }
        }
    }
    int f=0;
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(a[i][j]!=b[i][j])
            {
                f=-1;
                break;
            }if((c[i][j]!=1)&&(a[i][j]==b[i][j]))
            {
                sum+=b[i][j];
            }
        }
        if(f==-1)
        {
            break;
        }
    }
    if(f==-1)
    {
        printf("-1");
    }else
    {
        printf("%lld",sum);
    }
    return 0;
}


Measured memory_bytes: 14592