akhauriyash/Code-Regression huggingface dataset:
H, W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
ans = [0]*(H*W)
cnt = 0
for idx,a in enumerate(A):
    for i in range(a):
        ans[cnt+i] = idx+1
    cnt += a
#print(ans)
# ans　をWずつ折り返して表示
for h in range(H):
    if h % 2 == 0:
        print(*ans[h*W:(h+1)*W])
    else:
        temp = ans[h*W:(h+1)*W]
        print(*temp[::-1])

        #print(*ans[h*W:(h+1)*W:-1])



Measured memory_bytes: 3828
from datetime import date
import sys
for line in sys.stdin.readlines():
   m , d = map(int,line.split())
   if m != 0 and d != 0 :
       val = date(2004,m,d)
       day = val.isoweekday()
       if day == 7:
           print("Sunday")
       elif day == 1:
           print("Monday")
       elif day == 2:
           print("Tuesday")
       elif day == 3:
           print("Wednesday")
       elif day == 4:
           print("Thursday")
       elif day == 5:
           print("Friday")
       else:
           print("Saturday")
   else:
       break

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,D;
int A[555555];

int T[555555];
int ans[555555];

signed main(){
    scanf("%lld%lld",&N,&D);
    rep(i,N)scanf("%lld",&A[i]);
    int x=D;
    for(int i=0;i<N;i++){
        T[i]=x;
        x=min(x,abs(x-A[i]));
    }

    int r=0;
    for(int i=N-1;i>=0;i--){
        if(r<T[i]){
            ans[i]=1;
        }
        if(r>=A[i]/2){
            r+=A[i];
        }
    }

    int Q;scanf("%lld",&Q);
    while(Q--){
        int q;scanf("%lld",&q);
        if(ans[q-1])puts("YES");
        else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 14592
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 200005
#define lowbit(o) o&(-o)
using namespace std;
int i,j,l,s,n,m,R[N],L[N],st[N],ans,mx[N],top;
int a[N],b[N];
char c[N];
inline bool cmp(int x,int y) {
	return R[x]<R[y];
}
int main() {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (i=1;i<=n;i++) a[i]=c[i]-48,L[i]=R[i]=100000000;
	scanf("%s",c+1);
	for (i=1;i<=n;i++) b[i]=c[i]-48;
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (b[j]) L[i]=min(L[i],(i-j+n)%n),R[i]=min(R[i],(j-i+n)%n);
	ans=100000000;
	for (i=1;i<=n;i++) {
		top=0; int now=i;
		for (j=1;j<=n;j++) {
			if (a[now]!=b[j]) st[++top]=now;
			now%=n; now++;
		}//printf("%d\n\n",j);
		sort(st+1,st+1+top,cmp);
		mx[top+1]=0;
		for (j=top;j;j--) mx[j]=max(mx[j+1],L[st[j]]);
		
		for (j=0;j<=top;j++) {
			//workL:
			ans=min(ans,(R[st[j]]+max((i-(n+1)+n)%n,mx[j+1]))*2-(i-(n+1)+n)%n+top);
			//workR:
			ans=min(ans,(mx[j+1]+max(((n+1)-i+n)%n,R[st[j]]))*2-((n+1)-i+n)%n+top);
		}
	}
	if (ans>=100000000) ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
string s;
bool a,b;
int k,p;
int main(){
	cin>>s;
	for(int i=0;i<s.size();++i){
		if(s[i]=='C') a=1,k=i;
		if(s[i]=='F') b=1,p=i;
	}
	if(a&&b&&k<p) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m, k = map(int, input().split())
    MOD = 998244353
    ans = 0
    c = 1

    for i in range(k + 1):
        ans += (((m * pow(m - 1, n - i - 1, MOD)) % MOD) * c) % MOD
        ans %= MOD
        c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD
        
        
    print(ans % MOD)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 67480
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]

def dfs(a,b,c,cnt):
#     print(a,b,c,cnt)
    if cnt >= len(l):
        if a==0 or b==0 or c==0:
            return 10**10
        return abs(a-A)+abs(b-B)+abs(c-C)
    
    res0 = dfs(a,b,c,cnt+1)
    res1 = dfs(a+l[cnt],        b, c       ,cnt+1) + 10
    res2 = dfs(       a, b+l[cnt], c       ,cnt+1) + 10
    res3 = dfs(       a,        b, c+l[cnt],cnt+1) + 10
    
    return min(res0,res1,res2,res3)

print(dfs(0,0,0,0)-30)

Measured memory_bytes: 42204
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,r,x,tmp;
  cin>>a>>b;
  x=a*b;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  cout<<x/b<<endl;
  return 0;
}

Measured memory_bytes: 256
def calc_dig_sum(x):
    ret = 0
    while x > 0:
        ret += x % 10
        x //= 10
    return ret


N = int(input())
ans = 10 ** 18
for i in range(1, N):
    A = i
    B = N - A
    if A > B:
        break
    ans = min(ans, calc_dig_sum(A)+calc_dig_sum(B))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define precision(x) fixed << setprecision(x)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(all(x))
#define SUM(x) accumulate(all(x),0LL)
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double PI = acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int h, w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        rep(i,h){
            rep(j,w){
                if((i+j)&1) cout << ".";
                else cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    string s; cin >> s;
    int ans = INF;
    for (char c = 'a'; c <= 'z'; c++) {
        int count = 0;
        string t = s;
        while (1) {
            bool ok = true;
            rep(i, 0, (int)t.size() - 1) {
                if (t[i] != t[i + 1]) {
                    ok = false;
                }
            }
            if (ok) {
                chmin(ans, count);
                break;
            }

            string at;
            rep(i, 0, (int)t.size() - 1) {
                if (t[i] == c || t[i + 1] == c) {
                    at += c;
                }
                else {
                    at += t[i];
                }
            }
            t = at;
            count++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if( a % 2 == 1 && b % 2 ==1 ) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, q;
int k = 0;
vvi e;
vi x, sum;

void dfs(int v) {
	k += x[v];
	sum[v] = k;
	for (auto vv : e[v]) {
		if (sum[vv] < INT_MAX)continue;
		dfs(vv);
	}
	k -= x[v];
	return;
}

int main() {

	cin >> n >> q;
	e.resize(n);
	x.resize(n);
	sum.assign(n, INT_MAX);
	
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	rep(i, q) {
		int pp, xx;
		cin >> pp >> xx;
		x[pp - 1] += xx;
	}

	dfs(0);

	rep(i, n) {
		cout << sum[i];
		if (i < n - 1)cout << " ";
		else cout << endl;
	}

}

Measured memory_bytes: 21248
#include<cstdio>
#define For(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') ch=getchar(),l=-1;
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*l;
}
int main(){
	int ans=0,n=read(),a[100005]={0};
	For(i,1,n){
		int x=read();
		a[x]++; a[x+1]++; a[x+2]++;
	}
	For(i,1,100001) if (a[i]>ans) ans=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
from collections import deque
n, m = map(int, input().split())
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append((a-1, b-1))
ans = 0
for i in range(m):
    graph = [[] for _ in range(n)]
    for j in range(m):
        if i==j:
            continue
        a, b = ab[j]
        graph[a].append(b)
        graph[b].append(a)
    q = deque([0])
    seen = [False]*n
    seen[0] = True
    while q:
        node = q.popleft()
        for child in graph[node]:
            if seen[child]:
                continue
            seen[child] = True
            q.append(child)
    if not all(seen):
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<math.h>
#include<algorithm>

int main()
{
	int x[5][4][11] = {0};
	int n, b, f, r, v;

	scanf("%d", &n);

	for (int m = 1; m <= n; m++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		x[b][f][r] += v;
	}

	for (int m = 1; m <= 4; m++) {
		for (int n = 1; n <= 3; n++) {
			for (int l = 1; l <= 10; l++) {

				printf(" %d", x[m][n][l]);

					}
			printf("\n");
				}
		if (m != 4) {
			printf("####################\n");
		}
			}
	return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int n;
    cin >> n;
    vector<ll> rec(n);
    vector<bool> flag(n, false);
    ll prev=0;
    bool ok = true;
    for(int i=0; i<n; ++i) {
        int t;
        cin >> t;
        if(t > prev) {
            flag[i] = true;
        }
        rec[i] = t;
        prev = t;
    }
    prev = 0;
    vector<ll> a(n);
    for(int i=n-1; i>=0; --i) {
        cin >> a[i];
    }
    for(int i=0; i<n; ++i) {
        if(prev < a[i]) {
            if(flag[n-i-1] && a[i] != rec[n-i-1]) {
                ok = false;
            }
            flag[n-i-1] = true;
            rec[n-i-1] = a[i];
        } else {
            if(flag[n-i-1] && a[i] < rec[n-i-1]) {
                ok = false;
            } else {
                rec[n-i-1] = min(rec[n-i-1], a[i]);
            }
        }
        prev = a[i];
    }
    if(ok) {
        ll res = 1;
        for(int i=0; i<n; ++i) {
            if(!flag[i]) {
                res = res * rec[i] % mod;
            }
        }
        cout << res << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 1920
import itertools
N = int(raw_input())
S = [raw_input() for _ in range(N)]
march = list("MARCH")
I = {"M":0,"A":0,"R":0,"C":0,"H":0}
for s in S:
  if s[0] in I.keys():
    I[s[0]] += 1
for i in march:
  if I[i] < 1:
    I.pop(i)
K = list(I.keys())
ans = long(0)
for c in list(itertools.combinations(K, 3)):
    ans += I[c[0]]*I[c[1]]*I[c[2]]
print ans



Measured memory_bytes: 11488
package main

import (
	"fmt"
	"strings"
)

func main() {
	var Sd, T string
	fmt.Scan(&Sd, &T)

	notFound := strings.Repeat("{", len(Sd))
	ans := notFound
	for i := 0; i < len(Sd)-len(T)+1; i++ {
		match := true
		gen := []byte(Sd)
		for j := 0; j < len(T); j++ {
			if gen[i+j] == '?' {
				gen[i+j] = T[j]
			}
			if gen[i+j] == T[j] {
				continue
			}
			match = false
			break
		}
		if !match {
			continue
		}

		for j := 0; j < len(gen); j++ {
			if gen[j] == '?' {
				gen[j] = 'a'
			}
		}
		genS := string(gen)
		if ans > genS {
			ans = genS
		}
	}
	if ans == notFound {
		fmt.Println("UNRESTORABLE")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 1844
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))             

Measured memory_bytes: 154512
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main()
{
	int n, i, count, f;
	vector<int> s;
	map<int, int> m;
	while (cin>>n, n) {
		s.clear();
		for (i = 0; i < n; i++) {
			cin>>count;
			s.push_back(count);
		}

		f = 0;
		count = 0;
		while (f!=n) {
			f = 0;
			count++;

			m.clear();
			for (i = 0; i < n; i++) {
				if (m.count(s[i])) m[s[i]]++;
				else m[s[i]] = 1;
			}
			for (i = 0; i < n; i++) {
				if (s[i]==m[s[i]]) f++;
				s[i] = m[s[i]];
			}
		}
		cout<<--count<<endl;
		for (i = 0; i < n; i++) {
			if (i) cout<<" ";
			cout<<s[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] a = Console.ReadLine().Split(' ');

            string N = a[0];
            string M = a[1];

            Dictionary<int,List<string>> l = new Dictionary<int, List<string>>();
            for (int i = 0; i < int.Parse(M); i++)
            {
                string[] b = Console.ReadLine().Split(' ');

                if (!l.ContainsKey(int.Parse(b[0])))
                {
                    l[int.Parse(b[0])] = new List<string>();
                }
                    l[int.Parse(b[0])].Add(b[1]);
                
            }

            int ans1 = 0;
            int ans2 = 0;
                

            foreach(var p in l)
            {
                if (p.Value.Contains("AC"))
                {
                    ans1++;


                    ans2 = ans2 + p.Value.TakeWhile(s => s == "WA").Count();
                }
            }

           

            Console.Write(ans1.ToString()+" "+ans2.ToString());

           // Console.ReadKey();
        }
    }
}


Measured memory_bytes: 33912
import java.util.*;
// import java.util.stream.*;

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

  int n;
  String s;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      s = sc.next();
    } finally {
      sc.close();
    }
  }

  void solve() {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int cnt = count(i);
      if (ans < cnt) ans = cnt;
    }
    System.out.println(ans);
  }

  int count(int i) {
    int ans = 0;
    for (char c = 'a'; c < 'z' + 1; c++) {
      if (left(i, c) && right(i, c)) ans++;
    }
    return ans;
  }

  boolean left(int i, char c) {
    for (int j = 0; j < i; j++) if (s.charAt(j) == c) return true;
    return false;   
  }

  boolean right(int i, char c) {
    for (int j = i; j < n; j++) if (s.charAt(j) == c) return true;
    return false;   
  }
}


Measured memory_bytes: 35620
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        _n: usize,
        s: Chars,
    }
    let mut counter = [0; 26];
    let m = 1000000007;

    for &ns in &s {
        let index = (ns as u8 - 'a' as u8) as usize;
        counter[index] += 1;
    }

    let mut ans: usize = 1;
    for &cnt in &counter {
        ans = ans * (cnt + 1) % m;
        ans %= m;
    }
    ans = (ans - 1) % m;
    println!("{}", ans);
}


Measured memory_bytes: 2544
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main (){
  int n;
  int lines[10] = {};
  cin >>n;
  int buf = 0;
  int m=0;
  for(int i=0;i<n;i++){
    cin >> lines[i];
    buf += lines[i];
    m = max(m, lines[i]);
  }
  if(buf - m <= m){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
   int n,z,w;
   cin >> n >> z >> w;
   vector<int> a(n);
   rep(i,n) cin >> a.at(i);
   if (n==1) {cout << abs(a.at(0)-w) << endl;return 0;}
    cout << max(abs(a.at(n-1)-w),abs(a.at(n-1)-a.at(n-2))) << endl;
  }

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

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

    int add, sub, mul;
    add = a + b;
    sub = a - b;
    mul = a * b;

    cout << max( {add, sub, mul} ) << endl;

    return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	ll t = 1;
	ll a = 1;
	
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		ll z,w;
		z = t / x;
		w = a / y;
		if (t%x != 0)z++;
		if (a%y != 0)w++;
		if (z < w)z = w;
		t = z*x;
		a = z*y;
	}

	cout << t + a << endl;
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    std::cout << "Yes" << "\n";
  else
    std::cout << "No" << "\n";
}


Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
s = input()

x = 0
ans = 0

for i in range(n):
    if s[i] == "I":
        x += 1
        if x > ans:
            ans = x
    else:
        x -= 1

print(ans)


Measured memory_bytes: 61860
#include <stdio.h>

int check_sign(int a) {
	if (a >= 0) return a;
	else return -a;
}

int main(void) {
	int N, M;
	int *a, *b, *c, *d;
	int i, j, pre = 0, ans = 0, ans_num = 1, x, y;
	int *point;

	scanf("%d %d", &N, &M);
	a = (int*)malloc(sizeof(int)*N);
	b = (int*)malloc(sizeof(int)*N);
	c = (int*)malloc(sizeof(int)*M);
	d = (int*)malloc(sizeof(int)*M);
	point = (int*)malloc(sizeof(int)*N);

	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		scanf("%d", &b[i]);
	}
	for (i = 0; i < M; i++) {
		scanf("%d", &c[i]);
		scanf("%d", &d[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			x = check_sign(a[i] - c[j]);
			y = check_sign(b[i] - d[j]);
			if (j == 0) ans = x + y;
			else pre = x + y;
			if ((j != 0) && (ans > pre)) {
				ans = pre;
				ans_num = j + 1;
			}
		}
		point[i] = ans_num;
		ans = 0;
		pre = 0;
		ans_num = 1;
	}

	for (i = 0; i < N; i++) printf("%d\n", point[i]);

	return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

class List{
public:
	int head[maxn], nxt[maxn], val[maxn], tot;
	inline void insert(int x, int i){
		val[tot] = i;
		nxt[tot] = head[x];
		head[x] = tot++;
		return;
	}
}s, t;

int n;
int a[maxn], b[maxn], cnt[maxn], ans[maxn], cnt1[maxn], cnt2[maxn];
set<int> v1, v2;
set<pii, greater<pii> > que;

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d", a + i); --a[i]; 
		s.insert(a[i], i);
		++cnt[a[i]];
		++cnt1[a[i]];
		v1.insert(a[i]);
	}
	FOR(i, 0, n){
		scanf("%d", b + i); --b[i];
		t.insert(b[i], i);
		++cnt[b[i]];
		++cnt2[b[i]];
		v2.insert(b[i]);
	}
	
	FOR(i, 0, n) if(cnt[i]){
		que.insert(MP(cnt[i], i));
		if(cnt[i] > n){
			puts("No");
			return 0;
		}
	}
	
	while(!que.empty()){
		int u = (*que.begin()).snd; que.erase(que.begin());
		int v; bool f = false;
		if(v1.count(u)){
			if(v2.count(u)){
				v2.erase(u);
				f = true;
			}
			v = *v2.begin();
			ans[s.val[s.head[u]]] = v;
			s.head[u] = s.nxt[s.head[u]];
			t.head[v] = t.nxt[t.head[v]];
			--cnt1[u]; --cnt2[v];
			if(!cnt1[u])
				v1.erase(u);
			if(!cnt2[v])
				v2.erase(v);
			if(f)
				v2.insert(u);
		}
		else{
			if(v1.count(u)){
				v1.erase(u);
				f = true;
			}
			v = *v1.begin();
			ans[s.val[s.head[v]]] = u;
			s.head[v] = s.nxt[s.head[v]];
			t.head[u] = t.nxt[t.head[u]];
			--cnt1[v]; --cnt2[u];
			if(!cnt1[v])
				v1.erase(v);
			if(!cnt2[u])
				v2.erase(u);
			if(f)
				v1.insert(u);
		}
		que.erase(MP(cnt[v], v));
		--cnt[u]; --cnt[v];
		if(cnt[u])
			que.insert(MP(cnt[u], u));
		if(cnt[v])
			que.insert(MP(cnt[v], v));
	}
	
	puts("Yes");
	FOR(i, 0, n)
		printf("%d ", ans[i] + 1);
	puts("");
	return 0;
}


Measured memory_bytes: 41200
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//文字から数値に変換
int getChar (char ch){
	if( ch == 'A') return 1;
	else if( ch == 'C' ) return 2;
	else if( ch == 'G' ) return 3;
	else if( ch == 'T' ) return 4;
	else return 0;
}

//文字列から数値へ変換してkeyを生成する
long long getKey(char str[]){
	long long sum=0, p=1, i;
	for( i=0; i<strlen(str); i++ ){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
	long long key, i, h;
	key = getKey(str); //文字列を数値に変換
	for(i=0;; i++){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h],str) == 0 ) return 1;
		else if( strlen(H[h]) == 0 ) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str); //文字列を数値に変換
	for(i=0;; i++){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h],str) == 0 ) return 1;
		else if( strlen(H[h]) == 0 ) {
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L], com[9];
	for( i=0; i<M; i++) H[i][0] ='\0';
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%s %s", com, str); //より高速な入力 scanfを使用
		
		if (com[0] == 'i' ){
			insert(str);
		}else{
			if ( find(str) ){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16032
#include<bits/stdc++.h>
#define LL long long
using namespace std;
struct data{int w,t;LL c;}a[53];
int p[53];LL f[53][148877];
inline bool cmp(const data &A,const data &B){
  return A.w*B.c>A.c*B.w;
}
int main(){
  int n,x,d,ans=0;
  scanf("%d%d%d%lld",&n,&x,&d,&a[1].c);
  a[1].w=1,a[1].t=1e9;
  for(int i=2;i<=n;i++)
    scanf("%lld%d",&a[i].c,&p[i]),a[i].w=1,a[i].t=d;
  for(int i=n;i>1;i--) a[p[i]].w+=a[i].w,a[p[i]].c+=a[i].c;
  sort(a+1,a+n+1,cmp);
  memset(f,127,sizeof(f));
  f[0][0]=0;
  for(int i=1;i<=n;i++)
    for(int k=0;k<=min(n,a[i].t);k++)
      for(int j=0;j<=n*n*n-k*a[i].w;j++)
	f[i][j+k*a[i].w]=min(f[i][j+k*a[i].w],f[i-1][j]+k*a[i].c);
  for(int i=0;i<=n*n*n;i++){
    if(f[n][i]>x) continue;
    int W=x-f[n][i],V=i;
    for(int j=1;j<=n;j++){
      int tmp=min(W/a[j].c,1ll*max(0,a[j].t-n));
      W-=tmp*a[j].c;
      V+=tmp*a[j].w;
    }
    ans=max(ans,V);
  }
  printf("%d",ans);
  return 0;
}


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

typedef  long long ll;
typedef long double ld;
using namespace std;
const int N=1e5+5;

#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define point complex<double>
ll mod=1e9+7;
ll inf=2e18;
double eps=1e-10;
double pi=acos(-1);
double dot(point a, point b)
{
    return (conj(a)*b).real();
}
double cross(point a, point b)
{
    return (conj(a)*b).imag();
}
ll add(ll x, ll y)
{
    return (x%mod+y%mod)%mod;
}
point takepoint()
{
    int x, y;
    cin>>x>>y;
    point p(x,y);
    return p;
}
vector<int>v[N];
int dis [3][N];
void dig(int start)
{
    memset(dis,-1,sizeof dis);
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>q;
    dis[0][start]=0;
    q.push({0,{0,start}});
    while(q.size())
    {
        int cu=q.top().first;
        int co=q.top().second.first+1;
        int node=q.top().second.second;
        q.pop();
        if(co==3)
            co=0,cu++;

        for(auto it:v[node])
        {
            if(dis[co][it]==-1||dis[co][it]>cu)
            {
                dis[co][it]=cu;
                q.push({cu,{co,it}});
            }

        }
    }


}

int main()
{
    int n,m;
    cin>>n>>m;
for(int i=0;i<m;i++)
{
    int u,x;
    cin>>u>>x;
    v[u].push_back(x);
}
int s,e;
cin>>s>>e;
dig(s);

cout<<dis[0][e];

    return 0;
}


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

int main() {

    int n;

    cin >> n;

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

    if(n % 2 == 0)
        n++;
    

    while(1) {

        bool isPrime = true;

        for(int i = 2; i * i <= n; i++) {
            if(n % i == 0) {
                isPrime = false;
                break;
            }

        }

        if(isPrime)
            break;

        n += 2;

    }

    cout << n << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;


static const int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v;

  cin >> n;
  REP(i,n){
    REP(j,n){
      M[i][j] = 0; //初期化
    }
  }

REP(i,n){
  cin >> u >> k;
  u--;  //オリジンに変換
  
  REP(j,k){
    cin >> v;
    v--;
    M[u][v] = 1;
  }
}

REP(i,n){
  REP(j,n){
    if(j) cout << " ";
    cout << M[i][j];

  }
  cout << endl;
}


return 0;


}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int A, B, K; cin >> A >> B >> K;
  vector<bool> chk(B+1,0);
  int count=0;
  for(int i=A; i<=B; i++){
    chk[i]=1;
    count++;
    if(count == K) break;
  }
  count = 0;
  for(int i=B; i>=A; i--){
    if(chk[i]) break;
    chk[i]=1;
    count++;
    if(count == K) break;
  }
  
  for(int i=A; i<=B; i++){
    if(chk[i]) cout << i << endl;
  }
  
}
  

Measured memory_bytes: 125092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];

    ll res = 0;
    vll cur(20);
    ll l = 0, r = 0, ng = 0, tmp, cnt;
    // しゃくとり:条件を満たさない最初の r まで r を右に伸ばしてから l を一つずらす
    while (l <= r) {
        ll ng = 0;;
        while (r < n) {
            cnt = 0;
            vll nxt(20);
            tmp = a[r];
            REP(i, 20) {
                if (tmp & 1) nxt[i] = 1;
                tmp >>= 1;
            }
            // 条件確認
            REP(i, 20) {
                if (nxt[i] * cur[i]) ng = 1;
            }
            if (ng == 0) {
                REP(i, 20) cur[i] += nxt[i];
            }
            if (ng) break;
            r++;
        }
        res += (r - l);
        tmp = a[l];
        REP(i, 20) {
            if (tmp & 1) cur[i] = 0;
            tmp >>= 1;
        }
        l++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int[] ABC = new int[3];
        ABC[0] = sc.nextInt();
        ABC[1] = sc.nextInt();
        ABC[2] = sc.nextInt();
        
        int max = 0;
        int maxI = -1;
        for(int i = 0; i < 3; i++){
            if( max < ABC[i] ){
                max = ABC[i];
                maxI = i;
            }
        }
        
        int ans = 0;
        for(int i = 0; i < 3; i++){
            if( i == maxI ){
                ans += ABC[i] * 10;
            } else {
                ans += ABC[i];
            }
        }
        
        System.out.println( ans );
    }
}


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

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R-i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i,z[i]));
    return mx;
}

int main() {
    int n;
    cin >> n;
    cout << n * n * n;
    
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{

		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int K = vs[1];
			string s = Console.ReadLine();

			int st = 0, en = 0, c = s[0] == '0' ? 1 : 0;
			int ans = 0;
			while (en < N) {
				// end
				while (true) {
					en++;
					if (s[en - 1] == '1' && (en < N && s[en] == '0')) {
						c++;
					}
					if (c > K || en >= N) {
						break;
					}
				}
				ans = Math.Max(ans, en - st);
				// start
				while (true) {
					st++;
					if (s[st - 1] == '0' && s[st] == '1') {
						c--;
						break;
					}
					if (st >= N - 1) {
						break;
					}
				}
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string n;
  cin >> n;
  if (n.at(0) == '9' || n.at(1) == '9') {
  	cout << "Yes\n";
  }else {
  	cout << "No\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void){

	int W,H,x,z,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&z,&r);
	if(x-r<0||z-r<0||x+r>W||z+r>H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>

int main(){
  std::string str;
  int k;
  std::cin >> str;
  std::cin >> k;
  int n = 1;
  for(int i=0;i<k;i++){
    if(str[i] != '1'){
      n = str[i] - '1' + 1;
      break;
    }
  }
  std::cout << n << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            var t = ReadLine();
            var cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) cnt++;
            }
            WriteLine(cnt);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 18260
#include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using std::cin; using std::string;
using std::cout; using std::endl;
using std::sort;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;
int main(){
    int n[10];
	int s=0;
	for(int i=0;i<10;i++){
		cin>>n[i];
		s+=n[i];
	}
	cout<<s<<endl;
	return 0;
}      

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 1000010

bool isExist[MAX_N] = {};

static inline ll f(ll n) { return (n % 2 == 0) ? n / 2 : 3 * n + 1; }

signed main()
{
    ll S;
    cin >> S;
    ll a = S;
    isExist[a] = true;
    for(ll i = 2; i < MAX_N; ++i) {
        ll next_a = f(a);
        if(isExist[next_a]) {
            printf("%lld\n", i);
            return 0;
        }
        isExist[next_a] = true;
        a = next_a;
    }
    assert(false);
    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;

ll mod = 1000000007;
ll modsize = 500010;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc(){
    if(modsize == 0) abort();
    fac[0] = 1; fac[1] = 1; inv[1] = 1;
    facinv[0] = 1; facinv[1] = 1;
    for(ll i = 2 ; i < modsize ; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facinv[i] = facinv[i-1] * inv[i] % mod;
    }
}

ll modinv(ll a){
    if(a==0) abort();
    ll b = mod, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= mod;
    if(u<0) u += mod;
    return u;
}

ll modpow(ll a,ll b){
    ll ans = 1;
    a %= mod;
    while(b){
        if(b&1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

ll modcomb(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return fac[n] * facinv[k] % mod * facinv[n-k] % mod;
}

ll modperm(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return fac[n] * facinv[n-k] % mod;
}

ll modhom(ll n, ll k){
    if(n<0||k<0||(n==0&&k>0)) return 0;
    if(n==0&&k==0) return 1;
    return fac[n+k-1] * facinv[k] % mod * facinv[n-1] % mod;
}

int main(){
  int n; cin>>n;
  int ans = modpow(10,n) - modpow(9,n) * 2 + modpow(8,n);
  ans %= mod;
  ans = (ans+mod)%mod;
  cout << ans << endl;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=3005;
const ll INF=1e15;
const int MOD=1e9+5;

int n;
double p[M],dp[M][M];

double DP(int i,int ts){
  if (i > n) return 1;
  if (ts*2 > n) return 0;
  if (dp[i][ts] != -1) return dp[i][ts];
  dp[i][ts] = p[i+1]*DP(i+1,ts) + (1-p[i+1])*DP(i+1,ts+1);
  return dp[i][ts];
}

int main(){

	fastio;
  cin >> n;
  fp(i,1,n+1) cin >> p[i];
  fp(i,0,n+1)
    fp(j,0,n+1) dp[i][j] = -1;
  cout << fixed << setprecision(10) << DP(0,0) << "\n";

	return 0;
}


Measured memory_bytes: 74420
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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 N;
int F[100][14];
int P[100][15];

int main () {
  scanf("%d",&N);
  REP(i,N) {
    REP(j,10) {
      scanf("%d",&F[i][j]);
    }
  }
  
  REP(i,N) {
    REP(j,11) {
      scanf("%d",&P[i][j]);
    }
  }

  int res = -(1<<30);
  FOR(b,1,1<<10) {
    int cc = 0;
    REP(i,N) {
      int c = 0;
      REP(j,10) {
        if ((b>>j&1) && F[i][j]) c++;
      }
      cc += P[i][c];
    }
    if (res<cc) res = cc;
  }
  printf("%d\n",res);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		double result = 0;
		
		for(int i = 1; i<=n; i++) {
			int c = 1;
			for(;;){
				if(i * c >= k) {
					result += 1/(double)c;
					break;
				}
				c *= 2;
			}
		}
		
		System.out.println(result/(double)n);
		
	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<vector>

using namespace std;
typedef pair<int,int> P;
struct edge{
	int t,c;
	edge(int c,int t):c(c),t(t){}

};
string str;
vector<edge> G[6];

bool dijk(){
	queue<P> que;
	que.push(P(0,0));
	while(que.size()){
		P p=que.front();
		que.pop();
		int v=p.second,c=p.first;
		if(c==str.size() && v==5)return true;
		if(c>str.size())continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(e.c==str[c]-'0')que.push(P(c+1,e.t));
		}
	}
	return false;
}

int main(void){
	G[0].push_back(edge(0,1));
	G[0].push_back(edge(1,2));
	G[1].push_back(edge(1,3));
	G[2].push_back(edge(0,1));
	G[3].push_back(edge(0,4));
	G[3].push_back(edge(1,5));
	G[4].push_back(edge(1,2));
	G[4].push_back(edge(0,5));
	G[5].push_back(edge(0,2));
	G[5].push_back(edge(1,1));
	while(1){
		cin >> str;
		if(str=="#")break;
		if(dijk())printf("Yes\n");
		else printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

    int find(int x){
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

int main() {
    ll n, m = 1e5;
    cin >> n;
    VI x(n), y(n);
    map<int, VI> x2y;
    REP(i,n){
        x[i] = in() - 1;
        y[i] = in() - 1;
        x2y[x[i]].push_back(y[i]);
    }

    union_find uf;
    uf.init(m);
    REP(i,m){
        if (x2y[i].empty()) continue;
        REP(j,x2y[i].size()){
            uf.merge(x2y[i][0], x2y[i][j]);
        }
    }

    VL cnt(m);
    vector<set<int>> xs(m);
    REP(i,m){
        cnt[uf.find(i)]++;
    }
    REP(i,n){
        xs[uf.find(y[i])].insert(x[i]);
    }

    ll ans = 0;
    REP(i,m){
        if (uf.find(i) != i) continue;
        ans += cnt[i] * xs[i].size();
    }
    ans -= n;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18688
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())

ans = 0
for i in range(1,N+1,2):
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)


Measured memory_bytes: 38256
from itertools import groupby
import random

s = input()


def ans_1():
    temp, ans = 0, 0
    acgt = {"A", "C", "G", "T"}
    for i in range(len(s)):
        if s[i] in acgt:
            temp += 1
            ans = max(ans, temp)
        else:
            temp = 0
    print(ans)


def ans_2():
    def check(c):
        return c in "AGCT"

    ans = 0
    for k, grp in groupby(s, check):
        temp = len(list(grp))
        if k:
            ans = max(ans, temp)

    print(ans)


def ans_3():
    temp, ans = 0, 0
    for c in s:
        if c in "AGCT":
            temp += 1
            ans = max(ans, temp)
        else:
            temp = 0
    print(ans)


method = random.randrange(3)
if method == 0:
    ans_1()
elif method == 1:
    ans_2()
else:
    ans_3()


Measured memory_bytes: 4720
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
double a,b;
int main(int argc, char const *argv[])
{
cin>>a>>b;
cout<<(int)ceil((a+b)/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		
		int count = 0;
		int number = 0;
		do {
			if (B == 1) {
				break;
			}
			
			if (count == 0) {
				number = A;
			} else {
				number += A - 1;
			}
			count ++;
		} while (number < B);
		System.out.println(count);
	}
}

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

#define NM 100002
#define NRM 100002

using namespace std;

struct elm
{
    int val, f;
};

bool operator < (elm a, elm b)
{
    return a.f > b.f;
}

int n;
int v[NM];

elm vf1[NRM], vf2[NRM];

int main()
{
    cin >> n;
    for(int i = 0; i <= NRM - 2; i++)
        vf1[i].val = vf2[i].val = i;
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i];
        if(i & 1)
            vf1[v[i]].f++;
        else
            vf2[v[i]].f++;
    }
    sort(vf1, vf1 + NRM - 1);
    sort(vf2, vf2 + NRM - 1);
    if(vf1[0].val == vf2[0].val)
        cout << min(n - vf1[0].f - vf2[1].f, n - vf1[1].f - vf2[0].f) << "\n";
    else
        cout << n - vf1[0].f - vf2[0].f << "\n";
    return 0;
}


Measured memory_bytes: 2176
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end
  and doit i =
    if i > 0 then (max_heapify i; doit (i - 1))
  in
  doit (int_of_float (float_of_int h /. 2.))

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  let rec read i =
    if i <= h then (t.(i) <- Scanf.scanf "%d " (fun i -> i); read (i + 1))
  in
  read 1;
  build_max_heap t h;
  let rec doit i =
    if i <= h then (print_string " "; print_int t.(i); doit (i + 1))
  in
  doit 1;
  print_newline ()

Measured memory_bytes: 8488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w=100000;
    cin>>n;
    double num,ans;
    cin>>ans;
    ans/=w;
    for(int i=1;i<n;i++){
        cin>>num;
        num/=w;
        ans+=num;
    }
    ans/=n;
    n=ans*w;
    cout<<n<<endl;
}

Measured memory_bytes: 1228