akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
const int inf  = 1e9;
using namespace std;

int main()
{
	ll h,n;
	cin>>h>>n;
	
	ll a[n];
	ll b[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	ll dp[h+1];
	dp[0]=0;
	
	for(ll i=1;i<=h;i++)
	{
		dp[i] = inf;
		for(ll j=0;j<n;j++)
		{
			if(a[j]>=i)
			{
				dp[i] = min(dp[i],b[j]);
			}
			else
			{
				dp[i] = min(dp[i],b[j] + dp[i-a[j]]);
			}
		}
	}
	cout<<dp[h]<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int compare(const int*a,const int*b){return *a-*b;}
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void AscRadix(int A[],const int sz,const int minus)
{
  int temp[200001];
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>8*k&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>8*k&255]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>8*k&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>8*k&255]]=temp[sz-1-i];
  }
  rep(i,minus)temp[i]=A[sz-minus+i];
  rep(i,sz-minus)temp[minus+i]=A[i];
  rep(i,sz)A[i]=temp[i];
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,sign=0,A[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  while(N--){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  AscRadix(A,m+p,m);
  rep(i,m)A[i]*=-1;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[m+i]*A[m+plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m-1-i]*A[m-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{mid*=-1l;sign=1;int low=0;rep(i,m){while(1l*A[m+low]*A[i]<mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K){if(sign)r=-mid-1l;else r=mid-1l;}else{if(sign)l=-mid+1l;else l=mid+1l;}
  }
  return OUT(l),0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

ll dp[310][90010];
ll dp2[310][90010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    ll res = 0;
    res = powLL(3, N);
    res -= (3*powLL(2, N)%mod);
    res += mod;
    res %= mod;
    res += 3;
    res %= mod;

    ll ma = 90010;
    REP(i, 310)REP(j, ma){
    	dp[i][j] = 0;
    	dp2[i][j] = 0;
    }
    dp[0][0] = 1;
    dp2[0][0] = 1;

    REP(i, N){
    	REP(j, ma){
    		dp[i+1][j] += 2*dp[i][j];
    		dp[i+1][j] %= mod;
    		dp2[i+1][j] += dp2[i][j];
    		dp2[i+1][j] %= mod;
    		if(j+a[i] < ma){
    			dp[i+1][j+a[i]] += dp[i][j];
    			dp[i+1][j+a[i]] %= mod;
    			dp2[i+1][j+a[i]] += dp2[i][j];
    			dp2[i+1][j+a[i]] %= mod;
    		}
    	}
    }

    ll sum = 0;
    REP(i, N) sum += a[i];
    for(int i=(sum+1)/2;i<=sum-1;i++){
    	ll tmp = 0;
    	tmp += dp[N][i];

    	tmp -= dp2[N][i];
    	tmp += mod;
    	tmp %= mod;

    	tmp -= dp2[N][i];
    	tmp += mod;
    	tmp %= mod;

    	tmp *= 3;
    	tmp %= mod;

    	res -= tmp;
    	res += mod;
    	res %= mod;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 436352
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Char (digitToInt)
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  [h, w] <- f
  solve h w <$> V.fromList <$> concat <$> replicateM h g >>= print
  where
    f = map read <$> words <$> getLine
    g = map digitToInt <$> getLine

solve :: Int -> Int -> Vector Int -> Int
solve h w v = runST $ do
  dp <- V.thaw v
  forM_ [1 .. w-1] $ \x -> do
    d1 <- VM.read dp (toIdx (x-1, 0))
    d2 <- VM.read dp (toIdx (x, 0))
    VM.write dp (toIdx (x, 0)) (d1 + d2)
  forM_ [1 .. h-1] $ \y -> do
    d1 <- VM.read dp (toIdx (0, y-1))
    d2 <- VM.read dp (toIdx (0, y))
    VM.write dp (toIdx (0, y)) (d1 + d2)
  forM_ [1 .. w-1] $ \x -> do
    forM_ [1 .. h-1] $ \y -> do
      d1 <- VM.read dp (toIdx (x-1, y))
      d2 <- VM.read dp (toIdx (x, y-1))
      d3 <- VM.read dp (toIdx (x, y))
      VM.write dp (toIdx (x, y)) (d3 + min d1 d2)
  VM.read dp (toIdx (w-1, h-1))
  where
    toIdx (x, y) = x + y * w



Measured memory_bytes: 4884
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int a = int(sqrt(n));

    cout << a*a << endl;
};

Measured memory_bytes: 256
#include <cstdio>
#define Maxn 200000
#define ll long long
int n,k;
ll m;
int fa[Maxn+5],left[Maxn+5],right[Maxn+5];
int ask(int x){
	return x==fa[x]?x:fa[x]=ask(fa[x]);
}
int main(){
	scanf("%d%lld%d",&n,&m,&k);
	int ds=n;
	int a,b,c;
	int len=0;
	for(int i=0;i<n;i++){
		fa[i]=i;
	}
	while(k--){
		scanf("%d%d%d",&a,&b,&c);
		int p=ask(a),q=ask(b);
		if(c==0&&p!=q){
			ds--;
			fa[q]=p;
		}
		if(c==1){
			left[++len]=a;
			right[len]=b;
		}
	}
	for(int i=1;i<=len;i++){
		if(ask(left[i])==ask(right[i])){
			puts("No");
			return 0;
		}
	}
	if((m+ds-n>1ll*ds*(ds-1)/2)||(len&&(ds==2||m<n))){
		puts("No");
	}
	else{
		puts("Yes");
	}
	return 0;
}


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

int main(){
  int K,X;
  cin >> K >> X;
  for(int i = X - K + 1; i <= X + K -2 ;i++){
    if(i >= -1000000 && 1000000 >= i)cout << i << " ";
  }
  
  if(X+K-1 <= 1000000)cout << X + K -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - W * h - H * w + h * w << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;


vector<pll> G[N] ; 
ll in[N]  , H[N] ; 
struct Event{
	ll l , r , len ;
}E[N];

void DFS (ll x , ll h = 1) {
	H[x] = h;
	for (auto u : G[x]) {
		if (!H[u.F])
			DFS(u.F , h + u.S) ;
	}
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , m;
    cin >> n >> m ;
    for (int i = 1 ; i <= m ; i ++) {
    	cin >> E[i].l >> E[i].r >> E[i].len;
    	G[E[i].l].pb({E[i].r , E[i].len}) ;
    	in[E[i].r] = 1 ;
	}
	ll cnt = 0 ;
	for (int i = 1;  i <= n ; i ++) {
		if (!in[i]) DFS(i) ;
		else cnt ++ ;
	}
	//cout << H[1] << ' ' << H[2] << endl;
	for (int i = 1 ; i <= m ; i ++) {
		if (H[E[i].l] + E[i].len != H[E[i].r] || cnt == n) return cout << "No" , 0 ;
	}
	cout << "Yes" ;
    
    return (0) ;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 5e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int s;
    cin >> s;
    vector<ll> dp(s + 1, 0);
    dp[0] = 1;
    for(int i=1;i<=s;i++) {
        for(int j=i;j>=3;j--) {
            dp[i] = max(dp[i], dp[i] + dp[i-j]) % MOD;
        }
    }
    dp[s] %= MOD;
    cout << dp[s] << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) solve();
    solve();
    return 0; 
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int INF = 1e9;

signed main(){
	int H, W, K; cin >> H >> W >> K;
	vector<vector<char> > field(H, vector<char> (W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) cin >> field[i][j];
	}
	int ans = INF;
    for(int i = 0; i < (1 << (H - 1)); i++){
        bool ok = true;
		int N = __builtin_popcount(i); int ans1 = N;
		vector<int> data(N + 1, 0);
		for(int j = 0; j < W; j++){
			int num = 0;
			for(int k = 0; k < H; k++){
				if(field[k][j] == '1') data[num]++;
				if(i & (1 << k)) {
                  num++;
                }
			}
            if(*max_element(data.begin(), data.end()) > K){
              if(ok) {
                ans1 = INF;break;
              }
              ans1++;
              for(lint l = 0; l < data.size(); l++) data[l] = 0;
              --j; ok = true; 
              continue;
            }
          ok = false;
		}
		ans = min(ans, ans1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var colors = new int[9];
        foreach (var a in array)
        {
            var c = Math.Min(a / 400, 8);
            colors[c]++;
        }

        var min = colors.Take(8).Count(c => c != 0);
        var max = min + colors.Last();
        min = Math.Max(1, min);

        Console.WriteLine($"{min} {max}");
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public 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 ans = 0;
    for (int i = 0; i < N - 1; i++) {
      for (int j = i + 1; j < N; j++) {
        ans += d[i] * d[j];
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include <stdio.h>
#define TRUE 1
#define FALSE 0

int main(void){
  int a = FALSE;
  int b = FALSE;
  int c = FALSE;
  char s;
  int i;
  
  for( i=0; i<3; i++){
    scanf("%c",&s);
    if( s == 'a' ) a = TRUE;
    if( s == 'b' ) b = TRUE;
    if( s == 'c' ) c = TRUE;
  }
  
  ( a == TRUE && b == TRUE && c == TRUE ) ? printf("Yes\n") : printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>x>>y;
    int cnt[n+9] = {0};

    for(i=1; i<n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            v = min(abs(i-j), abs(x-i)+abs(y-j)+1);
            cnt[v]++;
        }
    }

    for(i=1; i<n; i++)
    {
        cout<<cnt[i]<<endl;
    }

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


vll par(MAX),siz(MAX);

//par[i]=iならiは根（はじめは全て根）
void init(ll n){
  rep(i,0,n){
    par[i]=i;siz[i]=1LL;
  }
  return;
}
//xの根
ll root(ll x){
  return (par[x]==x)?x:par[x]=root(par[x]);
}
//xが根の木とyが根の木を繋げる
void unite(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y){return;}
  if(siz[x]<siz[y]){swap(x,y);}
  siz[x]+=siz[y];
  par[y]=x;
}
//根が同じかどうか
bool same(ll x,ll y){
  return root(x)==root(y);
}
int main(){
  ll n,m;cin>>n>>m;
  vll p(n);
  rep(i,0,n){
    ll x;cin>>x;
    p[x-1]=i;
  }
  init(n);
  
  rep(i,0,m){
    ll a,b;cin>>a>>b;
    unite(a-1,b-1);
  }
  ll ans=0;
  rep(i,0,n){
    if(root(i)==root(p[i])){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}



Measured memory_bytes: 11980
from collections import namedtuple
from math import sqrt

Coordinates = namedtuple('Coordinates', 'idx x y')


def calc_dist(a: Coordinates, b: Coordinates) -> float:
    return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2))


n = int(input())

Coods = []
for idx in range(n):
    x, y = map(int, input().split())
    Coods.append(Coordinates(idx=idx, x=x, y=y))

ret = 0
for a in Coods:
    for b_idx in range(a.idx + 1, n):
        if a.idx == b_idx:
            continue
        b = Coods[b_idx]
        ret += calc_dist(a, b)
ret *= 2 / n
print(ret)

# 特定の2点を固定し、それ以外を並べる + 固定順を逆にする
# [oo]ooo... これを4個の要素の並び替えを見なす
# (n-1)! * 2!
# この2点間の移動が含まれる並び順は、(n-1)! * 2!通り
# 各2点間の距離の総和*(n-1)! * 2!通り / n!
# 各2点間の距離の総和*2/n


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int n;
    cin >> n;
    int t = 0;
    REP(i,n+10){
        t += i;
        if(n<=t){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[1000000];
int b[1000000];
int x[1000000];
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		a[x[i]] = i;
		b[x[i]] = i;
	}
	int sum = 0;
	queue<H>q;
	for (int i = n * n; i >= 1; i--) {
		if (b[i] > 0 && b[i] < n) {
			q.push(H{ b[i],n - b[i] });
		}
	}
	for (int i = n * n; i >= 1; i--) {
		if (q.empty()) continue;
		if (b[i] == q.front().x) {
			cout << "No\n";
			return 0;
		}
		if (b[i] == 0) {
			a[i] = q.front().x;
			q.front().y--;
			if (q.front().y == 0) q.pop();
		}
	}
	if (!q.empty()) {
		cout << "No\n";
		return 0;
	}
	for (int i = 1; i <= n * n; i++) {
		if (b[i] > 0 && b[i] > 1) {
			q.push(H{ b[i],b[i] - 1 });
		}
	}
	for (int i = 1; i <= n * n; i++) {
		if (q.empty()) continue;
		if (b[i] == q.front().x) {
			cout << "No\n";
			return 0;
		}
		if (b[i] == 0 && a[i] == 0) {
			a[i] = q.front().x;
			q.front().y--;
			if (q.front().y == 0) q.pop();
		}
	}
	if (!q.empty()) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	for (int i = 1; i <= n * n; i++) {
		cout << (i == 1 ? "" : " ") << a[i];
	}
	cout << endl;
}

Measured memory_bytes: 9344
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    a = int(readline())
    s = readline().rstrip().decode()

    if a >= 3200:
        print(s)
    else:
        print('red')


if __name__ == '__main__':
    main()


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

signed main(){
  int N,ans=111;
  cin>>N;
  rep(i,10){
    if(ans<N){
      ans+=111;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
       for(int i=0;i<=202;i++)
       {
           for(int j=0;j<=202;j++)
           {
               if((i*i*i*i*i-j*j*j*j*j)==t)
               {
                   cout<<i<<" "<<j<<'\n';
                   return 0;
               }
               if((i*i*i*i*i+j*j*j*j*j)==t)
               {
                   cout<<i<<" "<<-j<<'\n';
                   return 0;
               }
           }
       }
    }
}

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**8)

n = int(input())
ps = []
cs = [[] for _ in range(n)]
for i in range(1, n):
	a = int(input())
	ps.append(a-1)
	cs[a-1].append(i)
depths = [10**10 for _ in range(n)]
for i in range(1, n):
	if not cs[i]:
		depths[i] = 0

def search(x):
	for c in cs[x]:
		if depths[c] > 10**9:
			search(c)
	d_list = sorted([depths[c] for c in cs[x]], reverse=True)
	Ma = 0
	for d, i in enumerate(d_list):
		Ma = max(Ma, d+i+1)
	depths[x] = Ma
	return

search(0)
print(depths[0])

Measured memory_bytes: 113004
#include<iostream>
#include<vector>
using namespace std;
int main(){
  string s;
  int n,k,i,j,zeros;
  char c;
  bool fst;
  vector<int> vec;
  vec.push_back(0);
  vec.push_back(0);
  cin>>n>>k;
  cin>>s;
  c=s[0];
  if(s[0]=='0') fst=0;
  else fst=1;
  for(i=0;i<n;i++){
    if(s[i]==c) vec[vec.size()-1]++;
    else{
      c=s[i];
      vec.push_back(1);
    }
  }
  vec.push_back(0);
  zeros=vec.size()-2;
  if(!fst) zeros++;
  zeros=zeros/2;

  //全て1にできる場合終了
  if(zeros<=k){
    cout<<n<<endl;
    return 0;
  }

  
  int max=0,buf;
  if(fst) j=1;
  else j=0;
  for(i=0;i<k*2+1;i++){
    max+=vec[j];
    j++;
  }
  j--;
  buf=max;
  for(i=0;i<zeros-k;i++){//シフトしつつ比較
    buf=buf+vec[j+1]+vec[j+2]-vec[j-k*2]-vec[j-k*2+1];
    j+=2;
    if(max<buf) max=buf;
  }

  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 1020
k = int(input())

ls = []
for i in range(1,10):
  ls.append(i)
idx_next = 0
for i in range(1,10):
  idx = idx_next
  idx_next = len(ls)
  for v in ls[idx:]:
    r = v%10
    if r-1 >= 0:
      ls.append(v*10+r-1)
    ls.append(v*10+r)
    if r+1 <= 9:
      ls.append(v*10+r+1)
print(ls[k-1])

Measured memory_bytes: 11992
// D - Islands War
#include <bits/stdc++.h>
using namespace std;
int V[100000+1];

int main(){
	int N,M; scanf("%d%d",&N,&M);
	int l,r;
	while(M--){
		scanf("%d%d",&l,&r);
		V[r] = max(V[r], l);
	}
	int ans = 0, R = 1;
	for(r=1; r<=N; ++r) if(V[r]>=R) R=r, ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,W;
    cin >> N >> W;
    lint w[N],v[N];
    rep(i,N) cin >> w[i] >> v[i];
    lint base=w[0];
    vector<lint> value[4];
    rep(i,N){
        value[w[i]-base].push_back(v[i]);
    }
    rep(i,4) sort(value[i].begin(),value[i].end(),greater<lint>());
    int vsize[4];
    rep(i,4) vsize[i]=value[i].size();
    lint ans=0;
    rep(i,vsize[0]+1) rep(j,vsize[1]+1) rep(k,vsize[2]+1) rep(l,vsize[3]+1){
        lint weight=base*i+(base+1)*j+(base+2)*k+(base+3)*l;
        lint Va=0;
        if(weight>W) continue;
        rep(a,i) Va+=value[0][a];
        rep(a,j) Va+=value[1][a];
        rep(a,k) Va+=value[2][a];
        rep(a,l) Va+=value[3][a];
        ans=max(ans,Va);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  string s;cin>>s;
  rep(i,n-1){
    if(s[i]=='#'&&s[i+1]=='#'){
      if((a-1<=i&&i<c-1)||(b-1<=i&&i<d-1)){
      cout<<"No"<<endl;
      return 0;
    }
    }
  }
  if((a>b&&c<d)||(a<b&&c>d)){
    rep(i,n-2){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        if(max(a,b)-1<=i+1&&i+1<min(c,d)){
        cout<<"Yes"<<endl;
        return 0;
      }
      }
    }
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
int main(void){
  int n,k,h[100001],dp[100001];
  dp[0]=0;
  scanf("%d%d",&n,&k);
  int i,j;
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(i=1;i<n;i++) dp[i]=1E9;
  for(i=1;i<n;i++){
    for(j=1;j<=k;j++){
      if(i-j<0) break;
      dp[i]=fmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
import java.lang.*;
import java.util.*;

class LCS_new {
	
	public int LCS(String x, String y) {
		Integer[][] matrix = new Integer[x.length()+1][y.length()+1];
		for (int i = 0; i <= x.length(); i++) {
			matrix[i][0] = 0;
		}
		for (int j = 0; j <= y.length(); j++) {
			matrix[0][j] = 0;
		}
		for (int i = 1; i <= x.length(); i++) {
			for (int j = 1; j <= y.length(); j++) {
				if (x.charAt(i-1) == y.charAt(j-1)) {
					matrix[i][j] = 1 + matrix[i-1][j-1];
				}
				else {
					matrix[i][j] = Math.max(matrix[i-1][j], matrix[i][j-1]);
				}
			}
		}
		return matrix[x.length()][y.length()];
	}
}

public class Main {

	public static void main(String[] args) {
		
		LCS_new x = new LCS_new();
		Scanner in = new Scanner(System.in);
		int q = in.nextInt();
		in.nextLine();
		for (int i = 0; i < q; i++) {
			String a = in.nextLine();
			String b= in.nextLine();
			System.out.println(x.LCS(a, b));
		}

	}

}




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

string s;

bool is_num(char x){return x=='0' || x=='1';}

bool valid_num(int x){
  const int SUP=1024;
  return 0<=x && x<SUP;
}

int calc(int lhs,int rhs,char op){
  int res;
  if(op=='+'){
    res=lhs+rhs;
  }else if(op=='-'){
    res=lhs-rhs;
  }else if(op=='*'){
    res=lhs*rhs;
  }else{
    throw "calc";
  }
  if(!valid_num(res)) throw "invalid";

  return res;
}

int formula(int &p);
int formulap(int &p);
int term1(int &p);
pair<int,bool> term1p(int &p);
int term2(int &p);
int get_num(int &p);

int formula(int &p){
  int res=term1(p);
  while(p<s.size()){
    char op=s[p];
    p++;
    if(op!='+' && op!='-') throw "formula";
    int rhs=term1(p);
    res=calc(res,rhs,op);
  }
  return res;
}

int formulap(int &p){
  bool isok=false;
  auto ret=term1p(p);
  isok|=ret.second;
  int res=ret.first;
  if(p>=s.size()) throw "AHO";
  while(s[p]!=')'){
    char op=s[p];
    p++;
    if(op!='+' && op!='-') throw "formulap_op";
    isok=true;
    int rhs=term1p(p).first;
    res=calc(res,rhs,op);
      if(p>=s.size()) throw "AHO";
  }

  if(!isok) throw "formulap_isok";
  return res;
}

int term1(int& p){
  int res=term2(p);
  while(p<s.size() && (s[p]!='+' && s[p]!='-')){
    char op=s[p];
    p++;
    if(op!='*') throw "term1_op";
    int rhs=term2(p);
    res=calc(res,rhs,op);
  }
  return res;
}

pair<int,bool> term1p(int &p){
  int res=term2(p);
  bool isop=false;
  if(p>=s.size()) throw "AHO";
  while(s[p]!=')' && s[p]!='+' && s[p]!='-'){
    char op=s[p];
    p++;    
    if(op!='*') throw "term1p";
    isop=true;
    int rhs=term2(p);
    res=calc(res,rhs,op);
    if(p>=s.size()) throw "AHO";
  }
  return {res,isop};
}

int term2(int& p){
  if(p>=s.size()) throw "MANUKE";
  if(s[p]=='('){
    p++;
    int res=formulap(p);
    if(p>=s.size() || s[p]!=')') throw "term2";
    p++;
    return res;
  }else if(is_num(s[p])){
    int res=get_num(p);
    return res;
  }else throw "term2";
}

int get_num(int& p){
  int res=0;
  while(p<s.size() && is_num(s[p])){
    res*=2;
    res+=(s[p]-'0');
    if(!valid_num(res)) throw "Invalid";
    p++;
  }

  return res;
}

int dfs(int i){
  if(i==s.size()){
    int res=-1;
     try{
       int p=0;
       res=formula(p); 
     }catch(const char* &e){
       return -1;
     }
     return res;
  }
  else if(s[i]=='.'){
    const string ch="01+-*()";
    int res=-1;
    for(int j=0;j<ch.size();j++){
      s[i]=ch[j];
      int ret=dfs(i+1);
      res=max(ret,res);
      s[i]='.';
    }
    return res;
  }
  else{
    return dfs(i+1);
  }
}

int main(){
  cin>>s;
  cout<<dfs(0)<<endl;
  return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  
void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec));
  vector<int> vec1(N),vec2(N);
  int MODE = 0;
  int L =0, R = N -1;
  for (int i = 0; i < N; i++)
  {
    if(MODE == 0)
    {
      vec1[(i+1)%(N)] = vec[L];
      L++;
    }
    else
    {
      vec1[(i+1)%(N)] = vec[R];
      R--;
    }
    MODE^=1;
  }

  MODE = 1;
  L =0, R = N -1;
  for (int i = 0; i < N; i++)
  {
    if(MODE == 0)
    {
      vec2[(i+1)%(N)] = vec[L];
      L++;
    }
    else
    {
      vec2[(i+1)%(N)] = vec[R];
      R--;
    }
    MODE^=1;
  }

  int ANS = 0;
  int SUM = 0;
  for (int i = 0; i < N-1; i++)
  {
    SUM += abs(vec1[i]-vec1[i+1]);
  }
  chmax(ANS,SUM);
  SUM = 0;
  // DEBUG(vec1);DEBUG(vec2);
  
    for (int i = 0; i < N-1; i++)
  {
    SUM += abs(vec2[i]-vec2[i+1]);
  }
  chmax(ANS,SUM);
  cout<<ANS<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define endl '\n'

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

    int n;
    cin >> n;
    int p[n], q[n], sla[n];
    for (int i=0; i<n; i++) cin >> p[i];
    for (int i=0; i<n; i++){
        cin >> q[i];
        sla[i] = i+1;
    }

    int ans=1, a=0,b=0;
    do{
        bool ok1=true,ok2=true;
        for (int i=0; i<n; i++){
            if (sla[i] != p[i]) ok1=false;
            if (sla[i] != q[i]) ok2=false;
        }
        if (ok1) a = ans;
        if (ok2) b = ans;
        ans++;
    } while(next_permutation(sla, sla+n));

    cout << abs(a-b) << endl;


}

Measured memory_bytes: 256
import sys
import math

(N, H) = tuple(map(int, input().split(" ")))

a = []
b = []
result = 0

for i in range(N):
    (ai,bi) = tuple(map(int, input().split(" ")))
    a.append(ai)
    b.append(bi)

a_max = max(a)
b.sort()
b.reverse()
b_length = len(b)

for i, bi in enumerate(b):
    if bi < a_max:
        b_length = i
        break


S = 0

for l in range(b_length):
    S += b[l]
    if S >= H:
        result = l + 1
        print(result)
        sys.exit()


result = b_length + int(math.ceil((H - S)/a_max))

print(result)


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

int main(){
  int n, w;
  cin >> n >> w;
  vi weight(n+1), value(n+1);
  rep(i,n) cin >> weight[i+1] >> value[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(w+1));
  for(int i=1; i<=n; i++){
    for(int j=0; j<=w; j++){
      if(j >= weight[i]) dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]] + value[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  ll ans = dp[n][w];
  cout << ans << endl;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int ans = 0;
	REP(i,n){
		int t;
		cin >> t;
		if(a <= t && t < b){
			ans++;
		}
	}
	cout << n - ans << endl;
}

Measured memory_bytes: 256
#a
k = int(input())
a, b = map(int, input().split())

def amari(x,y):
    if x%y!=0:
        return 1
    else:
        return 0

if (a <= (a//k+amari(a,k))*k)  and ((a//k+amari(a,k))*k <= b):
    print("OK")
else:
    print("NG")

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

using namespace std;

int N, M;
char S[100000], T[100000];

int main() {
  scanf("%d%d", &N, &M);
  scanf("%s%s", S, T);
  
  // 最大公約数を計算
  int g = __gcd(N, M);
  int stepS = N / g;
  int stepT = M / g;
  for (int i = 0; i < g; i++) {
    if (S[stepS * i] != T[stepT * i]) {
      puts("-1");
      return 0;
    }
  }
  printf("%lld", 1ll * N / g * M);
  return 0;
}

Measured memory_bytes: 384
// ref: https://img.atcoder.jp/abc115/editorial.pdf
// ref: https://drken1215.hatenablog.com/entry/2019/05/13/114600

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 pow2(int n){ return (1ll << (n-1)); }

int64 rec(int n, int64 x){
    if(n==0){ return (x<=0 ? 0:1); }
    
    int64 len     = pow2(n+2) - 3;
    int64 numPate = pow2(n+1) - 1;
    
    if(x<=len+1){ return rec(n-1, x-1);
    }    else   { return numPate + 1 + rec(n-1, x-1-(len+1)); }
}

int main(){
    int N; int64 X; cin >> N >> X;
    cout << rec(N, X) << endl;
    
    return 0;
}


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

int main(){
  long n;
  cin >> n;
  vector<long> area(5);
  long min = 0;
  int num = 0;int count = 0;
  for(int i = 0;i < 5;i++){
    cin >> area.at(i);
    if(i == 0){
      min = area.at(i);
    }else if(min > area.at(i)){
      min = area.at(i);
      num = i;
    }
    if(n <= area.at(i)){
      count++;
    }
  }
  long ans = 0;
  if(count == 5){
    cout << 5 << endl;
  }else{
    if(n%area.at(num) == 0){
    ans = n/area.at(num);
    }else{
    ans = n/area.at(num)+1;
    }
    ans += 4;
    cout << ans << endl;
  }
 
    return 0;
}


Measured memory_bytes: 256
/*************************************************************************
  >         File: A.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 26 Nov 2016 11:47:30 PM JST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      std::string s;
      std::cin >> s;
      if (s == "snuke") {
        std::cout << char('A' + j);
        std::cout << 1 + i << std::endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var L, R int
	fmt.Scanf("%d %d", &L, &R)

	lmod := L % 2019
	rmod := R % 2019
	if lmod >= rmod || (R-L) >= 2019 {
		fmt.Println(0)
		return
	}

	minmod := 2019
	for i := lmod; i <= rmod; i++ {
		for j := i + 1; j <= rmod; j++ {
			tmp := i * j % 2019
			if tmp < minmod {
				minmod = tmp
			}
		}
	}
	fmt.Println(minmod)
}


Measured memory_bytes: 512
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();

        double ans = 0.0;
        for (int i = 1; i <= n; i++) {

            double p = 1;
            int tmp = i;

            while (tmp < k) {
                p *= 0.5;
                tmp *= 2;
            }
            ans += p / n;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define tc int t;cin>>t;while(t--)


int main()

{
   int n;
   cin>>n;
   ll arr[n],ans=0;
   for(int i=0;i<n;i++){
    cin>>arr[i];
    if(i){
        if(arr[i]<arr[i-1]){
            ans+=arr[i-1]-arr[i];
            arr[i]+=arr[i-1]-arr[i];
        }
    }
   }
   cout<<ans;
}


Measured memory_bytes: 5196
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    int n,W; cin >> n >> W;
    vector<ll> w(n),v(n);
    rep(i,n) cin >> w[i] >> v[i];

    ll dp[102][100005];
    rep(i,102) rep(j,100005) dp[i][j] = 0;

    for(int j=1;j<=W;j++){
        for(int i=1;i<=n;i++){
            if(j >= w[i-1]) dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]] + v[i-1]);
            else dp[i][j] = dp[i-1][j];
       }
    }

    cout << dp[n][W] << endl;
}

Measured memory_bytes: 80000
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := MakeSegTree(n)
	for ; q > 0; q-- {
		if ReadInt() == 0 {
			t.Add(ReadInt()-1, ReadInt(), ReadInt())
		} else {
			Println(t.Get(ReadInt() - 1))
		}
	}
}

type SegTree []int

func MakeSegTree(n int) SegTree {
	return make([]int, n*2)
}

func (t SegTree) Add(l, r, x int) {
	l += len(t) >> 1
	r += len(t) >> 1
	for l < r {
		if l&1 == 1 {
			t[l] += x
			l++
		}
		if r&1 == 1 {
			t[r-1] += x
		}
		l >>= 1
		r >>= 1
	}
}

func (t SegTree) Get(i int) int {
	i += len(t) >> 1
	v := t[i]
	for i > 1 {
		i >>= 1
		v += t[i]
	}
	return v
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



Measured memory_bytes: 4424
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] a = new int[n + 1];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		a[n] = a[0];
		sa = br.readLine().split(" ");
		int[] b = new int[n + 1];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		b[n] = b[0];
		br.close();

		int[] ax = new int[n];
		int[] bx = new int[n * 2 - 1];
		for (int i = 0; i < n; i++) {
			ax[i] = a[i] ^ a[i + 1];
			bx[i] = b[i] ^ b[i + 1];
		}
		System.arraycopy(bx, 0, bx, n, n - 1);

		MP mp = new MP(ax);
		List<Integer> list = mp.findAllFrom(bx);
		PrintWriter pw = new PrintWriter(System.out);
		if (!list.isEmpty() && list.get(0) == 0) {
			list.remove(0);
			list.add(n);
		}
		for (int i = list.size() - 1; i >= 0; i--) {
			int j = n - list.get(i);
			pw.println(j + " " + (a[j] ^ b[0]));
		}
		pw.flush();
	}

	static class MP {
		int n;
		int[] arr;
		int[] a;

		public MP(int[] arr1) {
			arr = arr1;
			n = arr.length;
			a = new int[n + 1];
			a[0] = -1;
			int j = -1;
			for (int i = 0; i < n; i++) {
				while (j >= 0 && arr[i] != arr[j]) {
					j = a[j];
				}
				j++;
				a[i + 1] = j;
			}
		}

		List<Integer> findAllFrom(int[] arr2) {
			List<Integer> ret = new ArrayList<>();
			int j = 0;
			for (int i = 0; i < arr2.length; i++) {
				while (j >= 0 && arr2[i] != arr[j]) {
					j = a[j];
				}
				j++;
				if (j == n) {
					ret.add(i - j + 1);
					j = a[j];
				}
			}
			return ret;
		}
	}
}


Measured memory_bytes: 93472
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val mp = scala.collection.mutable.Map[Int, Int]()
    for (i <- 0 until n) {
      val a = sc.nextInt
      if (mp.contains(a)) mp(a) += 1
      else mp.put(a, 1)
    }

    var ans = 0
    for (num <- mp.keys) {
      if (mp(num) < num) ans += mp(num)
      else if (mp(num) > num) ans += mp(num) - num
    }

    println(ans)
  }
}


Measured memory_bytes: 56292
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL n; cin>>n;
  LL an = (n*(n+1)*(n+2))/6;
  forn(i,n-1){
  	LL u,v; cin>>u>>v;
  	if(u > v) swap(u,v);
  	an -=  u*(n-v+1);
  }
  cout<<an<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
  using namespace std;
  int main()
  {
      string s;
      cin>>s;
      for(int i=0;i<s.length();i++)
      {
          if(s[i]!=',')
         {
             cout<<s[i];
         }
         else
         {
             cout<<" ";
         }
     }
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll N; cin>>N;
    vector<pair<ll, ll>> points(N);
    for(ll i=0; i<N; ++i){
        ll a, b; cin>>a>>b;
        points[i] = {a, b};
    }
    vector<ll> a1, a2;
    for(auto i: points){
        a1.push_back(i.first+i.second);
        a2.push_back(i.first-i.second);
    }
    ll c1 = *maxof(a1) - *minof(a1), c2 = *maxof(a2) - *minof(a2);
    cout<<max(c1, c2)<<endl;
}

Measured memory_bytes: 9776
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

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

int number(string s) {
  int n=0,a=1;
  for(int i=0; i<s.size(); i++) {
    if(s[i]>='0' && s[i]<='9') {
      a=(int)s[i]-48;
      continue;
    } 
    if(s[i]=='m') n+=a*1000;
    else if(s[i]=='c') n+=a*100;
    else if(s[i]=='x') n+=a*10;
    else n+=a;
    a=1;
  }
  return n;
}

string str(int n) {
  string s="",t="";
  if(n%10) {
    if(n%10!=1) t=n%10+'0';
    t+='i';
    s=t+s;
    t="";
  }
  n/=10;
  if(n%10) {
    if(n%10!=1) t=n%10+'0';
    t+='x';
    s=t+s;
    t="";
  }
  n/=10;
  if(n%10) {
    if(n%10!=1) t=n%10+'0';
    t+='c';
    s=t+s;
    t="";
  }
  n/=10;
  if(n%10) {
    if(n%10!=1) t=n%10+'0';
    t+='m';
    s=t+s;
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s,t;
    cin >> s >> t;
    int ns=number(s),nt=number(t);
    int ans=ns+nt;
    string r=str(ans);
    cout << r << endl;
  }
  return 0;
}
    


Measured memory_bytes: 1208
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<string,int>;

int main() {
    int N; cin>>N;
    string S; cin>>S;
    for (int i = 0; i < S.size(); i++){
        cout<<(char)(((int)S[i]-(int)'A'+N)%26+(int)'A');
    }
    cout<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  sort(A,A+N);
  reverse(A,A+N);
  ll ans = 0;
  for (int i=0;i<N;i++) {
    if (i==0) continue;
    ans += A[i/2];
  }

  cout << ans << endl;
    

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#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 inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> from1(n+1, 0), ton(n+1, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    if(a == 1) from1[b] = 1;
    if(b == n) ton[a] = 1;
  }
  
  rep1(i, n){
    if(from1[i]){
      if(ton[i]){cout << "POSSIBLE" << "\n"; return 0;}
    }
  }
  cout << "IMPOSSIBLE" << "\n";
}   

Measured memory_bytes: 1792