akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  vector<vector<int>>G(N);
  rep(i,N-1){
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> f(N), s(N);
  f[0]=0, s[N-1]=0;
  queue<int> qf, qs;
  qf.emplace(0), qs.emplace(N-1);
  int fd=0, sd=0;
  rep(i,N) f[i]=-1, s[i]=-1;
  while(!qf.empty()){
    int n=qf.front(); qf.pop();
    rep(i,G[n].size()){
      int next=G[n][i];
      if(f[next]!=-1) continue;
      qf.emplace(next);
      f[next]=f[n]+1;
    }
  }
  while(!qs.empty()){
    int n=qs.front(); qs.pop();
    rep(i,G[n].size()){
      int next=G[n][i];
      if(s[next]!=-1) continue;
      qs.emplace(next);
      s[next]=s[n]+1;
    }
  }
  int fennec=0, snuke=0;
  rep(i,N){
    if(f[i]<=s[i]) fennec++;
    else snuke++;
  }
  if(fennec>snuke) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;

  return 0;
}


Measured memory_bytes: 6528
n,k = map(int,input().split())
x = (n-1)*(n-2)//2-k
if x < 0:
    print(-1)
    exit()
print(n*(n-1)//2-k)
for i in range(2,n+1): print(1,i)
cnt = 0
for i in range(2,n+1):
    for j in range(i+1,n+1):
        if cnt == x: exit()
        print(i,j)
        cnt += 1

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> 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 (ll)(1e9+7)
#define int ll

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

signed main() {
  int n, x;
  cin >> n >> x;

  if(x == n * 2 - 1 || x == 1) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  if(n == 2) {
    cout << 1 << " " << 2 << " " << 3 << endl;
    return 0;
  }

  if(x == 2) {
    int cou = 0;
    dep(i, n * 2 - 1, 1) {
      if(i < x - 1 || i > x + 2) cout << i << " ", cou++;
      if(cou >= (n * 2 - 5) / 2) {
        cou = i - 1;
        break;
      }
    }
    cout << 3 << " " << 1 << " " << 2 << " " << 4 << " ";

    dep(i, cou, 1) {
      if(i < x - 1 || i > x + 2) cout << i << " ";
    }
    cout << endl;
    return 0;
  }
  if(x == 3) {
    int cou = 0;
    dep(i, n * 2 - 1, 1) {
      if((i < x - 2 || i > x + 1)) cout << i << " ", cou++;
      if(cou >= (n * 2 - 5) / 2) {
        cou = i - 1;
        break;
      }
    }
    cout << x - 1 << " " << x + 1 << " " << x << " " << x - 2 << " ";

    dep(i, cou, 1) {
      if((i < x - 2 || i > x + 1)) cout << i << " ";
    }
    cout << endl;
    return 0;
  }

  int cou = 0;
  rep(i, 1, n * 2) {
    if(i < x - 2 || i > x + 1) cout << i << " ", cou++;
    if(cou >= (n * 2 - 5) / 2) {
      cou = i + 1;
      break;
    }
  }
  cout << x - 1 << " " << x + 1 << " " << x << " " << x - 2 << " ";
  rep(i, cou, n * 2) {
    if(i < x - 2 || i > x + 1) cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int a[100000][3];
int main()
{
	int f=1,i,j,n;
	cin>>n;
	for(i=0;i<n;i++)
	{
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	if((a[i][2]+a[i][1]>a[i][0])||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0;
	}
	if(f==1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES

typedef long long ll;

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

/* sample input

*/
int a, b, c;


int main()
{
	cin >> a >> b >> c;

	int answer = min(a + b, min(b + c, c + a));

	cout << answer;

	return 0;
}

Measured memory_bytes: 764
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)
#define ps(x) cout << x << endl;
#define ps_end(x) ps(x); return;

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n, m;

void task() {
	cin >> n;
	vector<int> s(n);
	int c1[2] = {}, c2[2] = {};
	char ch;
	
	rep(n) {
		cin >> ch;
		if (ch == 'R') {
			s[i] = 0;
		} else {
			s[i] = 1;
		}
		c2[s[i]]++;
	};
	int ans = n - c2[1];
	rep(n) {
		c1[s[i]]++;
		int left = i + 1 - c1[0];  //W
		int right = c2[0] - c1[0]; //R;
		debug(i, left, right);
		ans = min(ans, max(right, left));
	};
	cout << ans << endl;
	
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3976
import java.util.Scanner;

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

	int N = sc.nextInt();
	int d[] = new int[N];
	for (int i = 0; i < N; i++)
	    d[i] = sc.nextInt();

	int count = 0;
	for (int i = 0; i < N - 1; i++) {
	    for (int j = i + 1; j < N; j++)
		count += d[i] * d[j];
	}

	System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int d; cin >> d;
  vector<int> cost(d, INF);
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que; // cost, num
  que.emplace(0, 1);
  cost[1] = 0;
  while (!que.empty()) {
    auto a = que.top(); que.pop();
    if (cost[a.second] < a.first) continue;
    if (a.second == 0) {
      cout << cost[0] + 1 << '\n';
      return 0;
    }
    int mul10 = (a.second * 10) % d, plus1 = (a.second + 1) % d;
    if (cost[mul10] > a.first) {
      cost[mul10] = a.first;
      que.emplace(a.first, mul10);
    }
    if (cost[plus1] > a.first + 1) {
      cost[plus1] = a.first + 1;
      que.emplace(a.first + 1, plus1);
    }
  }
}


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

int n;
int w,h;
int xs,ys;
int xg,yg;
int color;
int c,d,xb,yb;

int b[100][100];

bool flag;

void saiki(int y,int x,int c){
	if(b[y][x] != c || flag || b[y][x]==0)return;
	b[y][x]=-1;
	if(y==yg&&x==xg)flag = 1;
	if(x-1>=0)saiki(y,x-1,c);
	if(y-1>=0)saiki(y-1,x,c);
	if(x+1<w)saiki(y,x+1,c);
	if(y+1<h)saiki(y+1,x,c);
}

int main(){
	while(cin >> w >> h && w ){
		/*ú»*/
		for(int i=0;i<100;i++)for(int j=0;j<100;j++)b[i][j]=0;
		/*üÍ*/
		cin >> xs >> ys;
		cin >> xg >> yg;
		xs-=1;ys-=1;xg-=1;yg-=1;
		
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> c >> d >> xb >> yb;
			xb-=1;yb-=1;
			if(d==0){
				for(int i=0;i<4;i++){
					b[yb  ][xb+i]=c;
					b[yb+1][xb+i]=c;
				}
			}else{
				for(int i=0;i<4;i++){
					b[yb+i][xb  ]=c;
					b[yb+i][xb+1]=c;
				}				

			}
		}
		flag = 0;
		saiki(ys,xs,b[ys][xs]);
/*		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++)cout << b[i][j];
			cout << endl;
		}*/
		if(flag)cout << "OK";
		else cout << "NG";
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int base=1e9+7;
string k;
int d;
int m;
int f[10004][110][2];
bool kt[10004][110][2];
int F(int i,int mod,int ok)
{
    if (i==m) return mod==0;
    if (kt[i][mod][ok]) return f[i][mod][ok];
    int res=0;
    if (ok)
    {
        int x=int(k[i]-'0');
        for (int j=0;j<=x;j++)
        {
            if (j==x) res=(res+F(i+1,(mod+j)%d,1))%base;
            else res=(res+F(i+1,(mod+j)%d,0))%base;
        }
    }
    else for (int j=0;j<=9;j++)
        {
           res=(res+F(i+1,(mod+j)%d,0))%base;
        }
    kt[i][mod][ok]=true;
    f[i][mod][ok]=res%base;
    return res%base;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.inp", "r", stdin);
    //freopen("ou.out", "w", stdout);
    cin>>k;
    cin>>d;
    m=k.size();
    cout<<max(0,(F(0, 0,1) - 1 +base) %base);
    return 0;
}


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

using namespace std;
 
const int MOD=1e9+7;




//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int h,w,m;
    cin>>h>>w>>m;
    
    vector<pair<int,int>> vp(m);
    vector<int> rc(h+1), cc(w+1);
    
    for(auto &p:vp){
        int x,y;
        cin>>x>>y;
        p={x,y};
        rc[x]++;
        cc[y]++;
    }
    sort(vp.begin(),vp.end());
    vector<int> rb;
    for(int i=1; i<=h; i++){
        rb.push_back(i);
    }
    sort(rb.begin(),rb.end(), [&rc](int i, int j){return rc[i]>rc[j];});
    int ans=0;
    for(int i=0; i<min(2,h);i++){
        for(int j=1; j<=w; j++){
            pair<int,int> p={rb[i],j};
            ans=max(ans,rc[rb[i]]+cc[j]-binary_search(vp.begin(),vp.end(),p));
        }
    }
    
    
    vector<int> cb;
    for(int i=1; i<=w; i++){
        cb.push_back(i);
    }
    sort(cb.begin(),cb.end(), [&cc](int i, int j){return cc[i]>cc[j];});
    
    for(int j=0; j<min(2,w); j++){
        for(int i=1; i<=h; i++){
            pair<int,int> p={i,cb[j]};
            ans=max(ans,cc[cb[j]]+rc[i]-binary_search(vp.begin(),vp.end(),p));
        }
    }
    
    cout<<ans;
    
    
    
    return 0;
}

Measured memory_bytes: 12112
import java.io.*;
import java.util.*;

public class Main{
	public static void main (String[] args) {
		Scanner cin = new Scanner(System.in);
		int a = cin.nextInt();
		int b = cin.nextInt();
		int cur = 0;
		int cnt = 0;
		while(cur < b) {
		    cnt++;
		    cur += a;
		    if(cur < b) cur--;
		}
		System.out.println(b == 1 ? 0 : cnt);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int Fibonacci(int n){
  int a=1,b=1,i,tmp=1;

  for(i=1;i<n;i++){
    tmp=a+b;
    a=b;
    b=tmp;
  }
  return tmp;
  return a;
}
int main(){
  int n,f;

  scanf("%d",&n);
  f=Fibonacci(n);
  printf("%d\n",f);
  return 0;
}



Measured memory_bytes: 2104
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	h, a := nextInt(), nextInt()
	ans := h / a
	if h%a > 0 {
		ans++
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n,d;cin>>n>>d;
    int x[n][d];
    int cnt=0;
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int tmpsum=0;
            for(int k=0;k<d;k++){
                tmpsum+=((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
            }
            if(ceil(sqrt(tmpsum))==floor(sqrt(tmpsum)))cnt++;
        }
    }
    co(cnt);

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
#pragma warning(disable: 4996)
string S[1000]; int H, W;
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)cin >> S[i];
	int dx[8] = { 0,1,1,1,0,-1,-1,-1 };
	int dy[8] = { 1,1,0,-1,-1,-1,0,1 };
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#')cout << "#";
			else {
				int cnt = 0;
				for (int k = 0; k < 8; k++) {
					int cx = i + dx[k], cy = j + dy[k];
					if (cx < 0 || cx >= H || cy < 0 || cy >= W)continue;
					if (S[cx][cy] == '#')cnt++;
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
# A.append(1000000000)
# print(N,A) 入力までは行けた
S = A[0]
sum = 0

for i in range(1,N):
    if S >= A[i]:
        diff = S - A[i]
        sum = sum + diff
    else:
        S = A[i]
        sum = sum + 0

print(sum)



Measured memory_bytes: 32152
K, N = gets.split.map{|i|i.to_i}
A = gets.split.map{|i|i.to_i}
m = 0
N.times{|i|
    d = (A[i] - A[i - 1]) % K
    warn "d:%d" % d
    if d > m
        m = d
    end
}
puts K - m


Measured memory_bytes: 21404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

int r(){int x;cin>>x;return x;}

void solve() 
{   
    ll a,b,k;cin>>a>>b>>k;
    cout<<(a<=k?0:a-k)<<" "<<(a<=k?(b+a-k>=0?b+a-k:0):b)<<endl;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[102];
char s[102][12],t[12];
int main()
{
    int j;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",t);
        for(j=0;j<=i;j++)
        if(strcmp(t,s[j])==0)
        {
            a[j]+=1;break;
        }
        if(j>i)
        {
            strcpy(s[j],t);
            a[j]+=1;
        }
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        scanf("%s",t);
        for(j=0;j<=n;j++)
        if(strcmp(t,s[j])==0)
        {
            a[j]-=1;break;
        }
    }
    sort(a,a+102);
    if(a[101]<0)printf("%d",0);
    else
    printf("%d",a[101]);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1<<30)

class Edge{
public:
    int t, w;
    Edge(){}
    Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
    for(int i=0; i<n; i++) d[i] = INFTY;
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    int u;
    while( !Q.empty()){
        u = Q.front(); Q.pop();
        for(int i=0; i<G[u].size(); i++){
            Edge e = G[u][i];
            if( d[e.t] == INFTY){
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve(){
    //適当な視点sから最も遠い節点 tgt を求める
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for(int i=0; i<n; i++){
        if(d[i] == INFTY) continue;
        if(maxv < d[i]){
            maxv = d[i];
            tgt = i;
        }
    }

    //tgt から最も遠い節点の距離 maxv　を求める
    bfs(tgt);
    maxv = 0;
    for(int i=0; i<n; i++){
        if(d[i] == INFTY) continue;
        maxv = max(maxv, d[i]);
    }

    cout << maxv << endl;
}

main(){
    int s, t, w;
    cin >> n;

    for(int i=0; i<n-1; i++){
        cin >> s >> t >> w;

        G[s].push_back(Edge(t, w));

        G[t].push_back(Edge(s, w));
    }
    solve();
}


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

using namespace std;
using ll=long long;

int main()
{
    char h[4]={'N','W','S','E'};
    bool c[4];
    for(int i=0;i<4;i++)c[i]=false;
    string s;cin >>s;
    for(int i=0;i<(int)s.size();i++){
        for(int j=0;j<4;j++){
            if(s[i]==h[j])c[j]=true;
        }
    }
    bool flg=true;
    if((c[0]&&!c[2])||(!c[0]&&c[2]))flg=false;
     if((c[1]&&!c[3])||(!c[1]&&c[3]))flg=false;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
n =int(input())
l = [int(x) for x in list(str(n))]
#print(l)
n = l[len(l)-1]
#print(n)
if n==2 or n==4 or n==5 or n==7 or n==9:
  print('hon')
elif n==0 or n==1 or n==6 or n==8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <complex>
#include <cctype>
using namespace std;

const int MAX_NUM = 10000;

int p;
string s;
bool _ob;

void ob(const complex<int>& c)
{
  if (c.real() > MAX_NUM || c.real() < -MAX_NUM ||
      c.imag() > MAX_NUM || c.imag() < -MAX_NUM)
    _ob = true;
}

complex<int> p_exp();

complex<int> p_number()
{
  int num = 0;
  while (isdigit(s[p])) {
    if (num > MAX_NUM)
      _ob = true;
    num *= 10;
    num += s[p] - '0';
    ++p;
  }

  if (s[p] == 'i') {
    ++p;
    if (num == 0)
      ++num;
    return complex<int>(0, num);
  } else {
    return complex<int>(num);
  }
}

complex<int> p_factor()
{
  if (s[p] == '(') {
    ++p;
    complex<int> res = p_exp();
    ++p;
    ob(res);
    return res;
  } else {
    return p_number();
  }
}

complex<int> p_term()
{
  complex<int> res = p_factor();
  ob(res);
  for ( ; ; ) {
    if (s[p] == '*') {
      ++p;
      res *= p_factor();
      ob(res);
    } else if (s[p] == '/') {
      ++p;
      res /= p_factor();
      ob(res);
    } else {
      break;
    }
  }
  return res;
}

complex<int> p_exp()
{
  complex<int> res = p_term();
  ob(res);
  for ( ; ; ) {
    if (s[p] == '+') {
      ++p;
      res += p_term();
      ob(res);
    } else if (s[p] == '-') {
      ++p;
      res -= p_term();
      ob(res);
    } else {
      break;
    }
  }
  return res;
}

int main()
{
  while (cin >> s) {
    p = 0;
    _ob = false;
    complex<int> ans = p_exp();
    if (_ob)
      cout << "overflow" << endl;
    else if (ans.real() == 0 && ans.imag() == 0)
      cout << "0" << endl;
    else if (ans.real() == 0)
      cout << ans.imag() << "i" << endl;
    else if (ans.imag() == 0)
	cout << ans.real() << endl;
    else if (ans.imag() > 0)
      cout << ans.real() << "+" << ans.imag() << "i" << endl;
    else
      cout << ans.real() << ans.imag() << "i" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
H, W = map(int, input().split())
M = [input() for _ in range(H)]

S = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if M[i][j] == ".":
            if j > 0:
                S[i][j] = S[i][j - 1] + 1
            else:
                S[i][j] = 1
    for j in range(W - 2, -1, -1):
        S[i][j] = max(S[i][j], S[i][j + 1]) * (1 if S[i][j] else 0)

T = [[0] * W for _ in range(H)]
for j in range(W):
    for i in range(H):
        if M[i][j] == ".":
            if i > 0:
                T[i][j] = T[i - 1][j] + 1
            else:
                T[i][j] = 1
    for i in range(H - 2, -1, -1):
        T[i][j] = max(T[i][j], T[i + 1][j]) * (1 if T[i][j] else 0)

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, S[i][j] + T[i][j] - 1)
print(ans)


Measured memory_bytes: 128984
#include <stdio.h>
#define ll long long
const int mod = 1e9 + 7;

int n;

int mx[21][21];

ll dp[ (1<<21) ];


int main(){

	scanf("%d",&n);
	for(int i=0;i<n;i++) 
	for(int j=0;j<n;j++)
		scanf("%d",&mx[i][j]);
	dp[0] = 1;

	for(int mask = 0;mask<(1<<n);mask++){
		int a = __builtin_popcount(mask);
		for(int i = 0;i<n;i++){

			if(mask>>i&1 || mx[a][i] == 0 ) continue;
			int next = ( mask | (1<<i) ); 
			dp[ next ] += dp[mask];
			if(dp[ next ] > mod) dp[next]-=mod;

		}
	}
	printf("%lld",dp[ (1<<n)-1 ]);
}

Measured memory_bytes: 18172
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);
        v.emplace_back(k);
    }
    for (int i = 0; i < n; ++i) {
        ans++;
        int p = 1;
        if(i >= n-2) break;

        if(v[i]<=v[i+1]) for (int j = i+1; j < n; ++j) {
                if(v[j-1] <= v[j]){
                    p = max(p, j-i+1);
                }else break;
        }
        if(v[i]>=v[i+1]) for (int j = i+1; j < n; ++j) {
                if(v[j-1] >= v[j]){
                    p = max(p, j-i+1);
                }else break;
        }
        i += p-1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 892
n = int(input())

list_ba = [] 

for i in range(n):
    a, b = list(map(int, input().split()))
    list_ba.append([b,a])

list_ba.sort()

w = 0
rtn = "Yes"
for s in list_ba:
    w += s[1]
    if (w > s[0]):
        rtn = "No"
        break

print(rtn)





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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::array<int, 5> ps;
  for (auto& p : ps) {
    std::cin >> p;
  }
  int k;
  std::cin >> k;
  if (ps[4] - ps[0] <= k) {
    std::cout << "Yay!" << std::endl;
  } else {
    std::cout << ":(" << std::endl;
  }
  return 0;
}


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

int main(){

string str;
int char_count[26] = {0};
int i;

while(getline(cin,str)){
  for(i = 0;i < str.size();i++){
    if(str[i] >= 'A' && str[i] <= 'Z'){
      char_count[str[i]-65]++;
    }else if(str[i] >= 'a' && str[i] <= 'z'){
      char_count[str[i]-97]++;
      }
    }
  }

for(i = 0; i < 26;i++){
  cout << (char)(i+97) << " : "<< char_count[i] << endl;
}
return 0;

}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] a = new int[5][4][11];
        int b, f, r, v;
        for(int i =0; i<n; i++){
            b = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            v = sc.nextInt();
            a[b][f][r] += v;
            if(a[b][f][r] < 0) a[b][f][r] = 0;
        }
        for(int i = 1; i < 5; i++){
            for(int j = 1; j < 4; j++){
                for(int k = 1; k<11; k++){
                    System.out.printf(" %d", a[i][j][k]);
                }
                if(i == 4 && j == 3) break;
                System.out.println();
            }
            if(i < 4){
                for(int l = 0; l<20; l++){
                System.out.printf("#");
                }
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 30476
import copy

def main():
    n,m = list(map(int, input().split(' ')))
    ps = [[] for _ in range(n)]
    for i in range(m):
        p, y = list(map(int, input().split(' ')))
        ps[p-1].append((y, len(ps[p-1]), i))

    ans_ = [0 for _ in range(m)]

    ans =  copy.deepcopy(ps)
    for i in range(n):
        p = ps[i]
        sorted_ps = sorted(p)
        for j, sp in enumerate(sorted_ps):
            ans_[sp[2]] = '{0:06d}'.format(i+1) + '{0:06d}'.format(j+1)

    for r in ans_:
        print(r)



if __name__ == '__main__':
    main()


Measured memory_bytes: 55256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int c = 0;
		while ((line = bf.readLine()) != null) {
			if(new StringBuffer(line).reverse().toString().equals(line))
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


ll dp[200200];

int main() {  
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  reverse(rng(s));
  vi ans;
  rep(i,n){
    int next = 0;
    for(int j = 1;j<=m;j++){
      if(s[i+j] == '0')next=j;
    }
    if(!next){
      cout<<-1<<endl;
      return 0;
    }
    ans.push_back(next);
    i+=next-1;
  }
  reverse(rng(ans));
  rep(i,sz(ans)){
    cout<<ans[i]<<((i==n-1)?"\n":" ");
  }
  return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <sstream>
#include <bitset>
using namespace std;

int main(){
  string s1, s2;
  cin >> s1 >> s2;
  if (s1[0] == s2[2] && s2[0] == s1[2] && s1[1] == s2[1])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  string s;
  cin >> N; cin >> s;
  if(s.size()>N){
    for(int i=0;i<N;++i){
      printf("%c",s[i]);
    }
    printf("...");
  }
  else{
	for(int i=0;i<s.size();++i) printf("%c",s[i]);
  }
  
  return 0;
  
}

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

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

  const double PI = acos(-1.0);
  double ans = 2 * R * PI;

  cout << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto &x:a)cin >> x;

    int updown=-2;
    int ans=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            continue;
        }
        int nowupdown;
        if(a[i]>a[i-1])nowupdown=1;
        else nowupdown=-1;
        if(updown==-2){
            updown=nowupdown;
        }else if(updown!=nowupdown){
            ans++;
            updown=-2;
        }else{
            continue;
        }
    }

    cout << ans+1 << endl;

    return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    string s, t;
    cin >> s >> t;
    int count = 0;
    rep(i, s.size()) if(s[i] != t[i]) count++;
    cout << count << endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    Vi a(n),b(n);
    REP(i,0,n) cin>>a[i]>>b[i];
    if(n%2==1){
        sort(ALL(a));
        sort(ALL(b));
        cout<<b[n/2]-a[n/2]+1<<endl;
    }else{
        REP(i,0,n){a[i]*=2;b[i]*=2;}
        sort(ALL(a));
        sort(ALL(b));
        cout<<(b[n/2]+b[n/2-1])/2-(a[n/2]+a[n/2-1])/2+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ld r;
	cin >> r;
	ld v = atan(1) * 4;
	r = 2 * r * v;
	cout << fixed << setprecision(10) << r;
}


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

using namespace std;

pair<int, int> arr[55];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    int ans = N;
    for(int i= 1; i<=N; i++){
        cin >> arr[i].first >> arr[i].second;
    }
    for(int i= 1; i<=N; i++){
        for(int j = i+1; j<=N; j++){
            int t = 0;
            pair<int, int> vec = {arr[i].first - arr[j].first, arr[i].second - arr[j].second};
            if(vec.second < 0){
                vec.first *= -1, vec.second *= -1;
            }
            for(int a = 1; a<=N; a++){
                for(int b = 1; b<=N; b++){
                    pair<int, int> slop = {arr[a].first - arr[b].first, arr[a].second - arr[b].second};
                    if(slop == vec){
                        break;
                    }
                    if(b == N){
                        t++;
                        break;
                    }
                }
            }
            ans = min(t, ans);
        }
    }
    cout << ans << endl;
}

/*
3
1000000000 1000000000
-1000000000 -1000000000
0 0
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int DIGIT(long long a){
  int i=0;
  while(a){
    i++;
    a/=10;
  }
  return i;
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<long long, long long> > x(m);
  vector<long long> p(m),y(m);
  for(int i=0;i<m;i++){
    cin >> p[i] >> y[i];
    x[i].first=p[i]*10000000000+y[i];
    x[i].second=(i+1)*1000000;
  }
  sort(x.begin(),x.end());
  int cnt=1;
  vector<vector<long long> > z(m,vector<long long>(2));
  for(int i=0;i<m;i++){
    if(i){
      if(x[i-1].first/10000000000==x[i].first/10000000000){
        cnt++;
      }else cnt=1;
    }
    x[i].second+=cnt;
    z[i][0]=x[i].second;
    z[i][1]=x[i].first;
  }
  sort(z.begin(),z.end());
  long long t;
  for(int i=0;i<m;i++){
    t=p[i]*1000000 + z[i][0]%1000000;
    for(int j=0;j<12-DIGIT(t);j++)cout<<"0";
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 10112
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

string S, T;
int lastpos = -1;

void putT(int pos) {
	//SとTをposから比べる
	for (int i = pos; i < pos + T.length(); i++) {
		if (S[i] != T[i - pos] && S[i]!='?') {
			return;
		}
	}

	lastpos = pos;
}

void writeT(int pos) {
	for (int i = pos; i < pos + T.length(); i++) {
		S[i] = T[i - pos];
	}
}

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

	if (S.length() < T.length()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	for (int i = 0; i <= S.length() - T.length(); i++) {
		putT(i);
	}

	if (lastpos == -1) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	else {
		writeT(lastpos);
	}

	for (int i = 0; i < S.length(); i++) {
		if (S[i] == '?') {
			S[i] = 'a';
		}
	}

	cout << S << endl;


	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long int n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	long long int m=min(a,min(b,min(c,min(d,e))));
	cout<<((n+m-1)/m+4)<<"\n";
	return 0;
}

Measured memory_bytes: 384
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def load_n_times(n, vtype=int):
    r = []
    for _ in range(n):
        r.append(load(vtype=vtype))
    return r
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s

n, k, q = load_list()

A = load_n_times(q)

d = defaultdict(int)

for a in A:
    d[a] += 1

for i in range(1, n+1):
    if q - d[i] < k:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 20076
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll N,y,x;
int M;
int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>x>>y;
    ll a=min(N-x,x-1);
    ll b=min(N-y,y-1);
    ll c=min(a,b);
    cout<<c%3+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final String S = sc.next();
    		final String T = sc.next();

    		int count = 0;
    		for (int i=0; i<S.length(); i++) {
    			if (S.charAt(i) == T.charAt(i)) {
    				count++;
    			}
    		}

    		System.out.println(count);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int N;
string s;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N>>s;
    int cnt=0;
    int x=0;
    for(int i=0;i<N;i++)
    {
        s[i]=='I'?cnt=max(cnt,++x):--x;
    }
    cout << cnt <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int X,a,b;
int main(){
	cin>>X;
	for(int i=-120;i<=120;i++){
		for(int j=-120;j<=120;j++){
			if(i*i*i*i*i-j*j*j*j*j==X){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3632
N, Q = map(int, input().split())
S = input().strip()
b = None
nm = 0
dp = [0]
for c in S:
#    if b == None:
#        b = c
#        continue
    if b == 'A' and c == 'C':
        nm += 1
    dp.append(nm)
    b = c
#print(dp)
for _ in range(Q):
    l, r = map(int, input().split())
    print(dp[r]-dp[l])


Measured memory_bytes: 51628
/* -- Basic Headers -- */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>

/* -- STL Iterators -- */
#include <vector>
#include <string>
#include <stack>
#include <queue>

/* -- External Headers -- */

/* -- Defined Functions -- */
#define For(a,x,y) for (int a = x; a <= y; ++a)
#define Forw(a,x,y) for (int a = x; a < y; ++a)
#define Bak(a,y,x) for (int a = y; a >= x; --a)

/* -- Defined Words -- */

using namespace std;

namespace FastIO {
    void DEBUG(char comment[], int x) {
        cerr << comment << x << endl;
    }

    inline int getint() {
        int s = 0, x = 1;
        char ch = getchar();
        while (!isdigit(ch)) {
            if (ch == '-') x = -1;
            ch = getchar();
        }
        while (isdigit(ch)) {
            s = s * 10 + ch - '0';
            ch = getchar();
        }
        return s * x;
    }
    inline void __basic_putint(int x) {
        if (x < 0) {
            x = -x;
            putchar('-');
        }
        if (x >= 10) __basic_putint(x / 10);
        putchar(x % 10 + '0');
    }

    inline void putint(int x, char external) {
        __basic_putint(x);
        putchar(external);
    }
}

namespace Solution {

}

int main() {
    #define HANDWER_FILE
    #ifndef HANDWER_FILE
    freopen("testdata.in", "r", stdin);
    freopen("testdata.out", "w", stdout);
    #endif
    using namespace Solution;
    using namespace FastIO;
    int n = getint();
    int t = getint();
    int ans = 2147482333;
    while (n --> 0) {
        int a = getint();
        int b = getint();
        if (b <= t) ans = std::min(ans, a);
    }
    if (ans == 2147482333) puts("TLE");
    else putint(ans, '\n');
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	m := make([]int, n)
	l := 1001
	for i := range m {
		fmt.Scan(&m[i])
		x -= m[i]
		if m[i] < l {
			l = m[i]
		}
	}
	fmt.Println(x/l + n)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {
	int N, K;
	cin >> N >> K;
	vector<long long int> x(N), y(N);
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	
	vector<long long int > xx(N * N), yy(N * N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			xx[N * i + j] = x[i];
			yy[N * i + j] = y[j];
		}
	}


	long long int ans = 4.1e+18;
	for (int i = 0; i < N * N; i++) {
		for (int j = i + 1; j < N * N; j++) {
			int count = 0;
			long long int l = min(xx[i], xx[j]);
			long long int r = max(xx[i], xx[j]);
			long long int d = min(yy[i], yy[j]);
			long long int u = max(yy[i], yy[j]);
			for (int k = 0; k < N; k++) {
				if (l <= x[k] && x[k] <= r && d <= y[k] && y[k] <= u) count++;
			}
			if (count >= K) ans = min(ans, (r - l) * (u - d));
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;

  int count = 0;
  while (N > 0)
  {
    N /= K;
    ++count;
  }

  cout << count << endl;
}

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

int main() {
	
	int n;
	cin >> n;
	int a[n];
	int i;
	for(i=0;i<n;i++)
	{
	    cin >> a[i];
	}
	int check = 1;
	int count = 0;
	for(i=0;i<n;i++)
	{
	   
	   if(check == a[i])
	   {
	       check++;
	       continue;
	       
	   }
	   else
	   {
	       count = count + 1;
	       check++;
	   }
	}
	if(count > 2)
	{
	    cout << "NO" << "\n";
	}
	else
	{
	    cout << "YES"  << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    // 記述はないがmは高々5万
    int n, k;
    cin >> n >> k;

    int d[k];
    int A[k][100];
    for(int i=0; i<k; ++i){
        cin >> d[i];
        for(int j=0; j<d[i]; ++j){
            cin >> A[i][j];
        }
    }

    int get_flag[n];
    for(int i=0; i<n; ++i){
        get_flag[i] = 1;
    }
     
    // 人に対するループ
    for(int i=0; i<n; ++i){
        // お菓子ごとのループ
        for(int j=0; j<k; ++j){
            for(int l=0; l<d[j]; ++l){
                if(i+1 == A[j][l]){
                    get_flag[i] = 0;
                }
            }
        }
    }
    
    int sum = 0;
    for(int i=0; i<n; ++i){
        sum += get_flag[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<utility>
using namespace std;
int main () {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<pair<long long, int>>app(A + B + C);
  for (int i = 0; i < A; i ++) {
    long long a;
    cin >> a;
    app[i] = make_pair(a, 1);
  }
  for (int i = A; i < A + B; i ++) {
    long long a;
    cin >> a;
    app[i] = make_pair(a, -1);
  }
  for (int i = A + B; i < A + B + C; i ++) {
    long long a;
    cin >> a;
    app[i] = make_pair(a, 0);
  }
  sort(app.begin(), app.end());
  reverse(app.begin(), app.end());
  int j = 0;
  long long ans = 0;
  int x = X;
  int y = Y;
  for(int i = 0; i < X + Y;) {
    //cout << app[j].first << ' ' << app[j].second << ' ';
    if (app[j].second == 1) {
      if (x == 0) i --;
      else {
        x --;
        ans += app[j].first;
        //cout << 'E' << endl;
      }
    }
    if (app[j].second == -1) {
      if (y == 0) i --;
      else {
        y --;
        ans += app[j].first;
        //cout << 'E' << endl;
      }
    }
    if (!app[j].second) {
      ans += app[j].first;
      //cout << 'E' << endl;
    }
    i ++;
    j ++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 4992
from itertools import combinations
import math
import numpy as np

n = int(input())
d = []
data = []

for i in range(n):
    data.append(list(map(int, input().split())))

c = list(combinations(range(n), 2))

for row in c:
    x = [data[row[0]][0], data[row[1]][0]]
    y = [data[row[0]][1], data[row[1]][1]]

    d.append(np.sqrt((x[0]-x[1])**2 + (y[0]-y[1])**2))

print(sum(d)*math.factorial(n-1)*2/math.factorial(n))

Measured memory_bytes: 12400