akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int search(int arr[],int n,int key){
    for(int i=0;i<n;i++){
        if(arr[i]==key)
        return 0;
    }
    return 1;
}

int main(){
    int x,n,i;
    cin>>x>>n;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    int min=INT_MAX,value=0;
    for(i=0;i<=101;i++){
        int temp=search(arr,n,i);
        if(temp){
            int l=abs(x-i);
            if(l<min){
                min=l;
                value=i;
            }
        }
    }
    cout<<value;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int N,MAX=0,ans=0;
    cin>>N;
    vector<int> E(N);
    vector<int> H(N);
    rep(i,N){
        cin>>E[i];
        MAX=max(E[i],MAX);
    }
    for(int i=0;i<=MAX;i++){
        bool ok=false;
        for(int j=0;j<N;j++){
            if(E[j]>H[j]&&!ok){
                ans++;
                ok=true;
                H[j]++;
            }else if(E[j]<=H[j]&&ok){
                ok=false;
            }else if(E[j]>H[j]&&ok){
                H[j]++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;


void solve(){
	string s,t; cin>>s>>t;
	int n=sz(s), m=sz(t);
    int dp[n+1][m+1]; f(i,0,n+1) f(j,0,m+1) dp[i][j]=0;
    f(i,0,n+1) f(j,0,m+1) {
    	if(i==0 || j==0) continue;
    	else if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
    	else dp[i][j]=max(dp[i-1][j] , dp[i][j-1]);
	}
	//cout<<dp[n][m]<<"\n";
	string ret;
	int curr_r=n, curr_y=m;
	while(curr_r > 0 && curr_y >0){
		if(s[curr_r-1] == t[curr_y-1]) {
			ret+=s[curr_r-1];
			--curr_r;
			--curr_y;
		}else{
			if(dp[curr_r][curr_y]==dp[curr_r-1][curr_y]){
				curr_r--;
			}else curr_y--;
		}
	}
	reverse(all(ret));
	cout<<ret;
	return ;
}



signed main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


Measured memory_bytes: 74024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
const int N=300010;
int ft[N],a[N],ans[N],n,m,tot;
struct edge{int t,n;}E[N];
void adde(int x,int y){
	E[++tot]=(edge){y,ft[x]},ft[x]=tot;
}
int ask(int x){
	int s=0;
	for (;x;x-=x&-x) s+=a[x];
	return s;
}
void add(int x,int k){
	for (;x<=n+5;x+=x&-x) a[x]+=k;
}
int main(){
	scanf("%d%d",&m,&n);
	rep(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		adde(y-x+1,x);
	}
	int sum=m;
	rep(i,1,n){
		ans[i]=sum;
		for (int j=i;j<=n;j+=i) ans[i]+=ask(j);
		go(i){
			--sum;
			int x=v,y=v+i;
			add(x,1);
			add(y,-1);
		}
		printf("%d\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 5248
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def get_factor(N):
    N1 = N + 2
    A = [2, 0] * (N1//2)

    for i in range(3, N1, 2):
        if A[i]:
            continue
        for j in range(i, N1, 2*i):
            A[j] = i

    def factor(n):
        i = 0
        ans = []

        while n & 1 == 0:
            i += 1
            n >>= 1
        if i:
            ans.append((2, i))

        while n > 1:
            a = A[n]
            i = 1
            while True:
                n //= a
                b = A[n]
                if a != b:
                    ans.append((a, i))
                    b = a
                    break
                i += 1

        return ans


    return factor

def resolve():
    N = int(sys.stdin.readline())

    f = get_factor(N)

    ans = 0
    for i in range(1, N):
        num = 1
        #print(i, f(i))
        for a, b in f(i):
            num *= b + 1
        ans += num
    print(ans)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 76452
n,m = (int(i) for i in input().split())
x = [(int(i) for i in input().split()) for i in range(m)]
x,y,z,a,par,rank = x[::-1],[1]*(n+1),[n*(n-1)//2],n*(n-1)//2,[i for i in range(n+1)],[0]*(n+1)
def root(x):
	if par[x]!=x: par[x] = root(par[x])
	return par[x]
def unite(x,y):
	x2,y2 = root(x),root(y)
	if x2!=y2:
		if rank[x2]<rank[y2]: par[x2] = y2
		else: par[y2] = x2
		if rank[x2]==rank[y2]: rank[x2]+=1
for i,j in x:
    if root(i)!=root(j):
        a-=y[root(i)]*y[root(j)]
        num = y[root(i)]+y[root(j)]
        z.append(a)
        unite(i,j)
        y[root(i)] = num
    else: z.append(a)
z = z[::-1]
for i in range(m): print(z[i+1])

Measured memory_bytes: 96076
N = int(input())
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x:(x[1],x[0]))
 
t = 0
ans = 'Yes'
for a,b in AB:
    t += a
    if t <= b:
        continue
    else:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 53852
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
llin(x);
vllin(d,n);
ll k=0;
FOR(i,0,n-1){
k+=d[i];
if(k>x){
sal(i+1)
return 0;
}
}
sal(n+1)
}


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

int main(void)
{
  int N;
  int sum = 0;
  int count;
  fscanf(stdin,"%d",&N);

  for(int ix=1;ix<=N;ix+=2){
    count = 0;
    for(int jx=1;jx<=ix;++jx)
      if(ix%jx == 0)
        ++count;
    if(count == 0x8)
      ++sum;
  }
  printf("%d\n",sum);
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

int a[3], k;

int main(){
	cin >> a[0] >> a[1] >> a[2] >> k;
	
	sort(a, a+3);
	
	for(int i = 0; i < k; i++) a[2] *= 2;
	
	cout << a[0]+a[1]+a[2] << endl;
	
	return 0;
}

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

int main(){
	string S; cin>>S;
	int l = 0, r = S.size()-1;
	int ans = 0;
	while(l < r){
		if(S[l] != S[r]) ans++;
		l++, r--;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <cctype>
#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> P;
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 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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

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

    for(int i = 0; i <= Y / 10000; i++) {
        for(int j = 0; j <= (Y - i * 10000) / 5000; j++) {
            int k = (Y - i * 10000 - j * 5000) / 1000;
            if(i + j + k == N){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    string a,c;
    cin>>a>>c;
    if(a.size()>c.size())
    {
    	cout<<"GREATER"<<endl;
	}
	else if(a.size()<c.size())
	{
		cout<<"LESS"<<endl;
	}
	else if(a==c)
	{
		cout<<"EQUAL"<<endl;
	}
	else
	{
		for(int i=0;i<a.size();i++)
		{
			if(a[i]>c[i])
			{
				cout<<"GREATER"<<endl;return 0;
			}
			if(a[i]<c[i]){
				cout<<"LESS"<<endl;return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
N, X, Y = gets.chomp.split.map(&:to_i)

ans = Array.new(N-1,0)

(1..N-1).each do |i|
  (i+1..N).each do |n|
    dist = [n - i, (i-X).abs+(n-Y).abs+1].min 
  ans[dist-1] += 1
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll r,c,k;
  cin>>r>>c>>k;
  vector mat(r, vecll(c));
  REP(i,k) {
    ll y,x,v;
    cin>>y>>x>>v;
    --y;--x;
    mat[y][x] = v;
  }
  vector dp(4, vector(r, vecll(c)));
  dp[1][0][0] = mat[0][0];
  REP(i,r) {
    REP(j,c) {
      REP(m,3) {
        if (j > 0) {
          dp[m+1][i][j] = max(dp[m+1][i][j], dp[m][i][j-1] + mat[i][j]);
        }
      }
      REP(m,4) {
        if (j > 0) {
          dp[m][i][j] = max(dp[m][i][j], dp[m][i][j-1]);
        }
        if (i > 0) {
          dp[0][i][j] = max(dp[0][i][j], dp[m][i-1][j]);
          dp[1][i][j] = max(dp[1][i][j], dp[m][i-1][j] + mat[i][j]);
        }
      }
    }
  }
  ll mx = 0;
  REP(i,4) {
    mx = max(mx, dp[i][r-1][c-1]);
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 425624
N = int(input())
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB.sort(key=lambda x:x[1])

a = 0
for i in range(N):
    a += AB[i][0]
    if a > AB[i][1]:
        print("No")
        break
    if i + 1 == N:
        print("Yes")
        


Measured memory_bytes: 53724
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b>=10)cout<<"error"<<endl;
    else cout<<a+b<<endl;
}


Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())


Measured memory_bytes: 32192
#include<iostream>
using namespace std;
int main(){
	int N;
	long K;
	long long A[2000],countA=0,countB=0;
	long long sum;
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A[i]>A[j])countA++;
		}
		for(int j=0;j<i;j++){
			if(A[i]>A[j])countB++;
		}
	}
	if(K%2==1){
		sum=(countA+countB)*(K-1)/2;
		sum%=1000000007LL;
		sum*=K;
		sum%=1000000007LL;
	}else{
		sum=(countA+countB)*K/2;
		sum%=1000000007LL;
		sum*=(K-1);
		sum%=1000000007LL;
	}
	sum += countA*K;
	sum%=1000000007LL;
	cout<<sum<<endl;
	return 0;
}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

int g[202][202];

static const int INF = 0x3f3f3f3f;

void solve() {
        int n, m, r;
        cin >> n >> m >> r;
        vector<int> city(r);
        for (int i = 0; i < r; i ++) { 
                cin >> city[i];
                city[i] --;
        }
        for (int i = 0; i < 202; i ++) {
                for (int j = 0; j < 202; j ++) {
                        g[i][j] = INF;
                }
        }
        for (int i = 0; i < m; i ++) {
                int a, b, c;
                cin >> a >> b >> c;
                a --, b --;
                g[a][b] = c;
                g[b][a] = c;
        }
        for (int i = 0; i < 202; i ++) g[i][i] = 0;
        for (int k = 0; k < n; k ++) {
                for (int i = 0; i < n; i ++) {
                        for (int j = 0; j < n; j ++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                }
        }
        sort(all(city));
        int ans = INF;
        do {
                int sum = 0;
                for (int i = 0; i < r - 1; i ++) {
                        sum += g[city[i]][city[i + 1]];
                }
                ans = min(ans, sum);
        } while (next_permutation(all(city)));
        cout << ans << endl;
        return;
}

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

        //int T;
        //freopen("a.in", "r", stdin);
        //cin >> T;
        //while (T --) solve();
        
        solve();
        return 0;
}



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)


int main(){
	
    std::string s[3]; rep(i, 3)std::cin >> s[i];

    std::cout << s[0][0] << s[1][0] << s[2][0];

	system("pause");
	return 0;
}

Measured memory_bytes: 504
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		h := io.NextInt()
		if h == 0 {
			break
		}
		p := make([][]int, h)
		for i := 0; i < h; i++ {
			p[i] = make([]int, 5)
			for j := 0; j < 5; j++ {
				p[i][j] = io.NextInt()
			}
		}
		ans := 0
		for {
			sc := puyo(p, h)
			if sc == 0 {
				break
			}
			fall(p, h)
			ans += sc
		}
		io.Println(ans)
	}
}

func puyo(p [][]int, h int) int {
	sc := 0
	for i := 0; i < h; i++ {
		for j := 0; j < 3; j++ {
			var cnt int
			for cnt = 1; j+cnt < 5; cnt++ {
				if p[i][j] != p[i][j+cnt] {
					break
				}
			}
			if cnt > 2 {
				sc += p[i][j]*cnt
				for k := 0; k < cnt; k++ {
					p[i][j+k] = 0
				}
			}
		}
	}
	return sc
}

func fall(p [][]int, h int) {
	for j := 0; j < 5; j++ {
		for k := 1; k < h; k++ {
			for i := h - 1; i >= k; i-- {
				if p[i][j] == 0 {
					p[i][j] = p[i-1][j]
					p[i-1][j] = 0
				}
			}
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<string,int> cnt;
	int n;
	cin>>n;
	for(int i=0; i<n; ++i){
		string s;
		cin>>s;
		cnt[s]++;
	}
	map<int,set<string>> ans;
	for(auto i : cnt){
		ans[i.second].insert(i.first);
	}
	auto get = ans.rbegin();
	for(auto g : get->second){
		cout<<g<<'\n';
	}

	return 0;
}


Measured memory_bytes: 33280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
V<int> e[N];
int n, s, z[N];
void dfs1(int a, int p){
  for(int b : e[a]) if (b != p){
    dfs1(b, a);
    if(!z[b]) z[a]++;
  }
}
void dfs2(int a, int p, bool v){
  if(!v) z[a]++;
  if(!z[a]){
    cout << "First" << endl;
    exit(0);
  }
  for(int b : e[a]) if (b != p) dfs2(b, a, z[a]-!z[b]);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a].pb(b);
    e[b].pb(a);
  }
  {
    FOR(i, 0, n) if(sz(e[i])==1){
      s = i;
      break;
    }
  }
  dfs1(s, -1);
  dfs2(s, -1, true);
  cout << "Second" << endl;
}

Measured memory_bytes: 6272
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int p1,p2,p3,p4,maxi =-1;;
    p1 =a*c;
    p2= a*d;
    p3= b*c;
    p4= b*d;
    //cout<<p1<<endl;
    //cout<<p2<<endl; cout<<p3<<endl; cout<<p4<<endl;
    maxi = max(p1,p2);
    maxi = max(p3,maxi);
    maxi = max(maxi,p4);
    cout<<maxi<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(20000)
def wa(h, w, f):
    if not (0 <= h < H and 0 <= w < W):
        return
    elif mapp[h][w] != f:
        return
    else:
        mapp[h][w] = '$'
        wa(h, w+1, f)
        wa(h-1, w, f)
        wa(h, w-1, f)
        wa(h+1, w, f)

while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0: break
    mapp = [list(raw_input()) for i in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if mapp[h][w] == '@':
                count += 1
                wa(h, w, '@')
            elif mapp[h][w] == '#':
                count += 1
                wa(h, w, '#')
            elif mapp[h][w] == '*':
                count += 1
                wa(h, w, '*')
    else:
        print count

Measured memory_bytes: 12152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a;
    vector<pair<int,int> > pi;
    cin >> n;
    reps(i,n){
      cin >> a;
      pi.pu(mp(a,i));
    }
    sort(pi.begin(),pi.end());
    rep(i,n-1){
      cout << pi[i].se <<" ";
    }
    cout<<pi[n-1].se<<'\n';
    return 0;
}


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];
bool cmp(const pair<string,pii>&a,const pair<string,pii>&b){
  if(a.ff!=b.ff)return a.ff<b.ff;
  if(a.ss.ff!=b.ss.ff)return a.ss.ff>b.ss.ff;
}
int32_t  main(){
	IOS;
  vector<pair<string,pair<int,int>> >v;
  int n;cin>>n;
  fori(i,n){
    string s;int sc;cin>>s>>sc;
    v.pb({s,{sc,i}});
  }
  sort(v.begin(),v.end(),cmp);
  for(auto it:v){
    cout<<it.ss.ss<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, len, i;
	char oct[1028];
	
	while (scanf("%d", &n), n){
		len = sprintf(oct, "%o", n);
		for (i = 0; i < len; i++){
			printf("%c", "01235789"[oct[i] - '0']);
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 620
#Nは品物の数
#ｖはそれぞれの品物の価値
N = input()
v = list(map(int, input().split()))
#vを価値の低い順(昇順)に並び替える
v.sort()
#ans = 出力する最終的な値
ans = 0 
#popは（）の中身の数番目の値を削除する
ans=v.pop(0)

for V in v:
    ans = (ans +V)/2.0

print('{:.6g}'.format(ans))

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0 ; i < n ; i++) cin >> a[i];
    vector<int> dp(n,INF);
    for(int i = 0; i < n ; i++)
        *lower_bound(dp.begin(),dp.end(),a[i]) = a[i];
    cout << lower_bound(dp.begin(),dp.end(),INF) - dp.begin() << endl;
    return 0;
}


Measured memory_bytes: 3900
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

ll a[100001];
ll x[100001];
int main() {
	ll n; cin >> n;
	ll sum = 0;
	repe(i, 1, n) {
		cin >> a[i];
		sum += a[i];
	}

	ll sumA = 0;
	for (int i = 2; i <= n; i += 2) {
		sumA += a[i];
	}
	x[1] = sum - 2 * sumA;

	repe(i, 2, n) {
		x[i] += 2 * a[i - 1] - x[i - 1];
	}
	repe(i, 1, n) {
		cout << x[i];
		if (i != n) {
			cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int y, c[4], d[4];
int a[4]={10, 50, 100, 500};

int main() {
    for(int q=0; ; q++) {
        scanf("%d", &y);
        if(y==0) return 0;
        rep(i, 4) scanf("%d", c+i);
        int t=0;
        rep(i, 4) t+=a[i]*c[i];
        t-=y;
        rep(i, 4) { d[3-i]=t/a[3-i]; t%=a[3-i]; }
        if(q>0) puts("");
        rep(i, 4) if(c[i]-d[i]>0) printf("%d %d\n", a[i], c[i]-d[i]);
    }
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    int ans = INF;
    for (ll a = 1; a * a <= N; a++) {
        if (N % a) continue;
        ll b = N / a;
        int tmp = max(to_string(a).size(), to_string(b).size());
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	long long int n, a;
	long long int b = 0;
	cin >> n;
	for (long long int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 1) {
			b++;
		}
	}
	if (b % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
""" abc061_b:B - Counting Roads """
L = input().rstrip().split(' ')
N = int(L[0])
M = int(L[1])

ANS = []
for i in range(N):
    ANS.append(0)

for i in range(M):
    L = input().rstrip().split(' ')
    ANS[int(L[0])-1] += 1
    ANS[int(L[1])-1] += 1

for i in range(N):
    print(ANS[i])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define pb push_back
#define P pair<int,int>
using namespace std;
using ll = long long;
// using mod = int 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
	int n; cin >> n;
	vector<int> dp(n,0);
	int arr[n];
	rep(i,n){
		cin >> arr[i];
	}

	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2]+ abs(arr[i] - arr[i-2]),dp[i-1]+ abs(arr[i] - arr[i-1]));
	}

	cout << dp[n-1] << endl;
	return 0;
}
		     

Measured memory_bytes: 4052
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        char ans;
        if (a + b == 15) ans = '+';
        else if (a * b == 15) ans = '*';
        else ans = 'x';
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] t = new int[n+1];
		int[] x = new int[n+1];
		int[] y = new int[n+1];
		x[0] = y[0] = t[0] = 0;
		for (int i = 1; i <= n; i++) {
			t[i] = scan.nextInt();
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
		}

		boolean f = true;

		for (int i = 1; i <= n; i++) {
			int dist = 0;
			dist = Math.abs(x[i]-x[i-1])+Math.abs(y[i]-y[i-1]);
			//System.out.println("dist : "+dist);
			//System.out.println("t : "+ (t[i]-t[i-1]));
			if (dist > t[i]-t[i-1]) {
				f = false;
				break;
			} else {
				if ((t[i]-t[i-1]-dist) % 2 == 1) {
					f = false;
					break;
				}
			}
		}

		if (f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		System.out.println("");
	}
}


Measured memory_bytes: 89996
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()


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

int bottom(int wt[], int pr[], int N, int W)
{
	int dp[N + 1][W + 1] = {};
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			//exclude
			dp[i][j] = dp[i - 1][j];
			//include
			if ((j - wt[i - 1]) >= 0)
				dp[i][j] = max(dp[i][j], pr[i - 1] + dp[i - 1][j - wt[i - 1]]);
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	return dp[N][W];
}
int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int N, W;
	cin >> N >> W;
	int pr[N], wt[N];
	for (int i = 0; i < N; i++)
	{
		cin >> wt[i] >> pr[i];
	}
	cout << bottom(wt, pr, N, W);
}
// 3 8
// 3 30
// 4 50
// 5 60

Measured memory_bytes: 79104
def main():
    hatsugen_dic = {}
    inlis = []
    anslis = []

    n= int(input())
    for s in range(n):
        a = int(input())
        for _ in range(a):
            inlis.append(list(map(int, input().split())))
        hatsugen_dic[s] = inlis
        #print(s, inlis)
        inlis = []
    #print(hatsugen_dic)

    for i in range(2**n - 1, -1, -1):   #iは正直/嘘を全列挙（人数n人に対して2^n個のケースを順番に試す）
        cnt = 0
        for j in range(n):              #jはj番目の発言者の辞書から発言リストを取り出し、それぞれiのケースと正しいかを見る
            #print(i, j)
            if ((i >> j) & 1):          #iを二進数でj桁ずらした時に、1（正直者）かどうかチェック。1ならばチェック、0ならシカト
                hatsugen_j = hatsugen_dic[j]            #hatsugen_dicからj番目の発言のリストを取得
                for k in range(len(hatsugen_j)):        #kはjの発言の個数。何人分言及しているかをリスト内のものすべてで探索
                    if ((i>>(hatsugen_j[k][0]-1)) + hatsugen_j[k][1]) % 2 == 0:
                        #print(i, j, k, lis_j, lis_j[k][0], lis_j[k][1])
                        pass
                    else:
                        #print("i>>lis_j[k][0]-1:", (i + hatsugen_j[k][1]) % 2)
                        #print(i, j, k, lis_j, lis_j[k], lis_j[k][0], lis_j[k][1] , cnt)
                        cnt += 1
        if cnt == 0:
            count = 0
            while i:
                count += i & 1
                i >>= 1
            #print(count)
            anslis.append(count)
    print(max(anslis))




if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include<stdio.h>
int main ()
{
    int a,b,c,d,x,y;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a>c) x=a;
    else x=c;
    if(b>d) y=d;
    else y=b;
    if(x>y) printf("0");
    else printf("%d",y-x);
    return 0;



}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 10001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {printf("0\n"); return 0;}
#define FAIL_1 {printf("-1\n"); return 0;}

int N;
int gcd(int a, int b) {
    return (b) ? gcd(b, a%b) : a;
}

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    int g = 0;
    while(N--) {
        int a;
        scanf("%d", &a);
        g = gcd(a, g);
    }

    printf("%d\n", g);
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	ll ren = 0;
	string ans = "No";
	rep(i, n) {
		ll d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2) {
			ren++;
			if (ren == 3) {
				ans = "Yes";
				break;
			}
		}
		else {
			ren = 0;
		}
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 3684
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S;
    int x[4];
    
    scanf("%d", &S);
    
    x[0] = S % 10;
    x[1] = (S % 100 - x[0])/10;
    x[2] = (S % 1000 - x[1])/100;
    x[3] = (S % 10000 - x[2])/1000;
    
    if (x[0] == x[1] || x[1] == x[2] || x[2] == x[3]) {
        printf("Bad");
    }else{
        printf("Good");
    }
    
    //printf("Hello, World!\n");
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const int mx=90+10,mo=1000000007;
const ll inf=1000000000000000000;
ll fib[mx];
vector<pi> a[mx];
vector<pi>::iterator it;
ll x,y,n,m,num;
int i,j,k,l,t,tot,ca,ans;
int main(){
    fib[0]=fib[1]=1;
    tot=1;
    while (1){
        fib[tot+1]=fib[tot]+fib[tot-1];
        if (fib[tot+1]>inf) break;
        tot++;
    }
    a[1].pb(mp(1,2));a[1].pb(mp(1,3));a[1].pb(mp(1,4));
    fo(i,1,tot-3){
        it=a[i].begin();
        while (it!=a[i].end()){
            x=(*it).xx;y=(*it).yy;
            x+=y;
            while (x<=fib[i+3]+fib[i]){
                a[i+1].pb(mp(y,x));
                x+=y;
            }
            it++;
        }
    }
    scanf("%d",&ca);
    while (ca--){
        scanf("%lld%lld",&n,&m);
        if (n>m) swap(n,m);
        ans=1;
        while (fib[ans+1]<=n&&fib[ans+2]<=m) ans++;
        printf("%d ",ans);
        if (ans==1){
            printf("%lld\n",n*m%mo);
            continue;
        }
        else{
            num=0;
            it=a[ans-1].begin();
            while (it!=a[ans-1].end()){
                x=(*it).xx;y=(*it).yy;
                if (y<=n) (num+=(m-x)/y)%=mo;
                if (y<=m) (num+=(n-x)/y)%=mo;
                it++;
            }
            printf("%d\n",num);
        }
    }
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int main(){
	int H,W;
	cin>>H>>W;
	while(H!=0&&W!=0){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2==0){
					cout<<'#';
				}else{
					cout<<'.';
				}
			}
			cout<<endl;
		}
		cout<<endl;
		cin>>H>>W;
	}
	
	return 0;		
}

Measured memory_bytes: 1152
import sys
import bisect
a, b, q = [int(i) for i in sys.stdin.readline().split()]
s_ls = []
t_ls = []
INF = 10 ** 18
for i in range(a):
    s = int(input())
    s_ls.append(s)
for i in range(b):
    t = int(input())
    t_ls.append(t)

for i in range(q):
    x = int(input())
    s_ind = min(bisect.bisect_left(s_ls, x), a-1)
    t_ind = min(bisect.bisect_left(t_ls, x), b-1)
    best = INF
    for _s in [-1, 0]:
        if s_ind == 0 and _s == -1:
            continue
        for _t in [-1, 0]:
            if t_ind == 0 and _t == -1:
                continue
            s = s_ls[s_ind + _s]
            t = t_ls[t_ind + _t]
            if (s - x) * (t - x) >= 0:
                dis = max(abs(t - x), abs(s - x))
            else:
                dis = min(abs(t - x), abs(s - x)) * 2 + max(abs(t - x), abs(s - x))
            best = min(dis, best)
    print(best)

Measured memory_bytes: 80500
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll h,n;
   cin>>h>>n;
   
   pair<ll,ll> arr[n];
   rep(n)
        cin>>arr[i].ff>>arr[i].ss;
   
   ll ans = inf;
   ll dp[h+1];
   rep(h+1)
        dp[i] = inf;
   dp[h] = 0;
   for(ll i=h;i>0;i--)
   {
       repi(j,n)
       {
           if(arr[j].ff>=i)
           {
               ans = min(ans, dp[i]+arr[j].ss);
               continue;
           }
           dp[i-arr[j].ff] = min(dp[i-arr[j].ff],dp[i]+arr[j].ss);
       }
   }
   
   cout<<ans;
   
           
   
   return 0;        
}  
   

Measured memory_bytes: 384
/*
 * 0654_Circle_Cross_Stamps.c
 *
 *  Created on: 2019/05/19
 *      Author: nagashima
 */

#include <stdio.h>
#include <stdlib.h>

int main(void){
	int N;
	char S[1000*100];
	int res=0;

	scanf("%d",&N);
	scanf("%s",S);

	for(int i=0;i<N;)
		if((S[i]=='O'&&S[i+1]=='X')||(S[i]=='X'&&S[i+1]=='O')){
			res++;
			i++;
			i++;
		}else i++;

	printf("%d\n",res);

	return 0;
}



Measured memory_bytes: 2104
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toList
    println(solve(lines))
  }

  def solve(lines: List[String]): String = {
    val List(a, b) = lines(0).split(" ").map(_.toInt).toList
    if (a * b % 2 == 0) "Even" else "Odd"
  }
}


Measured memory_bytes: 25420
use std::io;


fn main() {
    let q = read_one::<usize>();
    let mut cnt = vec![0; 100_001];
    for i in 3..100_000 {
        cnt[i] = cnt[i - 1];
        if is_prime(i) && is_prime((i + 1) / 2) {
            cnt[i] += 1;
        }
    }

    for _ in 0..q {
        let (l, r) = {
            let i = read::<usize>();
            (i[0] - 1, i[1])
        };
        println!("{}", cnt[r] - cnt[l]);
    }
}

fn is_prime(n: usize) -> bool {
    if n < 2 { false }
    else if n == 2 { true }
    else {
        (2..(n as f64).sqrt() as usize + 2).all(|i| n % i != 0)
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4732
N = int(input())

S = [50]*26

for i in range(N):
    s = [0]*26
    for item in input():
        s[ord(item)-97] += 1
    for i in range(26):
        S[i] = min(S[i], s[i])

ans = ""
for i in range(26):
    ans += chr(97+i)*S[i]
print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pos;
int main(){
  long N;cin>>N;
  vector<long> A(N);for(int i=0;i<N;i++)cin>>A[i];
  
  long ans=0;
  
  if(A[N-1]<N)ans+=A[N-1];
  else {cout<<-1;return 0;}
  for(int i=N-2;i>=0;i--){
    //あり得るのは, 一個後に比べて
    //  1だけ小さい (この時自然に作れる)
    //  2以上小さい ありえない()
    //  同じかそれ以上 再度コストを図る
    if(A[i]<A[i+1]-1){cout<<-1;return 0;}
    else if(A[i]>=A[i+1]){
      if(A[i]>i){cout<<-1;return 0;}
      ans+=A[i];
    }
    else{
      
    } 
  }
  cout<<ans;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    VI h(n); VIin(h);
    int maxi = 0,ans = 0;
    rep(i,n){
        if(maxi <= h[i]) ans++;
        maxi = max(maxi,h[i]);
    }
    ANS;
    
    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

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

	string s; cin >> s;
	if(s.size()%2){
		cout << "No\n"; return 0;
	}

	for(int i = 0; i < (int) s.size(); i+=2){
		if(s[i] != 'h' || s[i+1] != 'i'){
			cout << "No\n"; return 0;
		}
	}

	cout << "Yes\n";

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll d;
  cin >> d;

  cout << "Christmas";
  for (ll i = 0; i < 25-d; i++) {
    cout << " Eve";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

def list_count(list_a,n):
	cont = 0
	for i in range(len(list_a)):
		if list_a[i] > n:
			break
		else:
			cont += 1
	return cont

primes = Eratos(1000000)
while True:
	try:
		n = int(input())
		print(list_count(primes,n))
	except EOFError:
		break


Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  vector<vi> g(h + 2, vi(w + 2, -2));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '.') g[i][j] = -1;
  }
  g[ch][cw] = 0;
  deque<pair<int, int>> q;
  q.push_front({ch, cw});
  while(!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    // cout << i << ' ' << j << ' ' << g[i][j] << endl;
    q.pop_front();
    rep(k, 4) {
      int ni = i + dir[k];
      int nj = j + dir[k + 1];
      if(g[ni][nj] != -1 && g[ni][nj] <= g[i][j]) continue;
      g[ni][nj] = g[i][j];
      q.push_front({ni, nj});
    }
    rep2(s, i - 2, i + 3) rep2(t, j - 2, j + 3) {
      // if(i == 3 && j == 3) cout << s << ' ' << t << ' ' << g[s][t] << endl;
      if(s < 0 || s > h || t < 0 || t > w) continue;
      if(g[s][t] != -1) continue;
      g[s][t] = g[i][j] + 1;
      q.push_back({s, t});
    }
  }
  cout << g[dh][dw] << endl;
}

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

typedef long long ll;

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



int main(){

    ll N;

    scanf("%lld",&N);

    ll ans=20000000000000;
    ll tmp;

    for(ll i=1;i<=sqrt(N);++i){
        if(N%i==0){
            tmp=i+N/i;
            ans=tmp<ans?tmp:ans;
        }
    }
    cout<<ans-2<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  double n;
  cin >> n;
  if (int(n / 1.08) * 1.08 == n) {
    cout << int(n / 1.08) << endl;
  } else if (int(int(n / 1.08 + 0.9) * 1.08) == n) {
    cout << int(n / 1.08 + 0.9) << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  bool flag = 1;
  rep(i,n){
    if(s.at(i) != t.at(i)) flag = 0;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3632