akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ans=0;
    int deru=0;
    while(1){
        rep(i,n){
            if(a[i]%2==0){
                a[i]/=2;
            }
            else{
                deru=1;
                break;
            }
        }
        if(deru==1)break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# Aizu Problem 0086: Patrol
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


a = [0] * 101
while True:
    try:
        x, y = [int(_) for _ in input().split()]
    except EOFError:
            break
    if x == y == 0:
        c = sum([a[i] % 2 for i in range(3, 101)])
        print("OK" if c == 0 and a[1] % 2 == 1 and a[2] % 2 == 1 else "NG")
        a = [0] * 101
    else:
        a[x] += 1
        a[y] += 1
            

Measured memory_bytes: 7780
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ch=[]
for i in range(n):
    ch.append((a[i],i))
ch.sort(reverse=True)
#print(ch)
dp=[[0]*(n+1) for _ in range(n+1)]
dp[1][1]=ch[0][0]*ch[0][1]
dp[1][0]=ch[0][0]*(n-1-ch[0][1])
for i in range(2,n+1):
    for j in range(i+1):
        if j>=1:
            dp[i][j]=max(dp[i][j],dp[i-1][j-1]+ch[i-1][0]*abs(ch[i-1][1]-j+1))
        if i-1>=j:
            dp[i][j]=max(dp[i][j],dp[i-1][j]+ch[i-1][0]*abs(n-i+j-ch[i-1][1]))
print(max(dp[n]))   

Measured memory_bytes: 100384
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 10000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;




int main(){
    FAST_IO ;
    int N , M ; cin >> N >> M ;
    int  sum = 0 ;
    for( int i = 0 ; i < M ; i++ ){
        int x ; cin >> x ;
        sum += x ;
    }
    cout << max( -1 , N - sum ) << endl ;
    
    return 0 ;
}
 
 

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll N;
    cin >> N;
    cout << 180 * N - 360 << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
template< typename T > using Vec = vector< T >;

int N, M, R, r[10], dp[222][222];

void solve() {
	for_(k,0,N) for_(i,0,N) for_(j,0,N) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
	
	Vec< int > order;
	for_(i,0,R) order.push_back(i);
	
	int ans = 1L << 30;
	do {
		int sum = 0;
		for_(i,0,R-1) sum += dp[r[order[i]]][r[order[i+1]]];
		ans = min(ans, sum);
	} while (next_permutation(allof(order)));
	
	cout << ans << endl;
}

int main() {
	cin >> N >> M >> R;
	
	for_(i,0,R) {
		cin >> r[i];
		--r[i];
	}
	
	for_(i,0,N) for_(j,0,N) dp[i][j] = 1L << 28;
	for_(i,0,N) dp[i][i] = 0;
	
	for_(i,0,M) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		dp[a][b] = dp[b][a] = c;
	}
	
	solve();
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long a,b;
	long long GCD=0,LCM=0;
	long long tmp=0,tmp_a,tmp_b;

	
	while (cin >> a >> b)
	{
		tmp_a = a;
		tmp_b = b;
		tmp = a%b;
		while (tmp!=0) {
			a = b;
			b = tmp;
			tmp = a%b;
		}
		GCD = b;

		LCM = tmp_a*tmp_b / GCD;

		cout << GCD <<" "<<LCM<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
function main(input: string) {
  const lines = input.trim().split('\n')

  const L = 'L'
  const R = 'R'
  const cs = lines[0].split('')
  let k = 0

  const a = cs.map(() => 0)
  cs.forEach((c, i) => {
    if (c === R) {
      k++
      return
    }
    if (k > 0) {
      a[i - 1] = Math.round(k / 2)
      a[i] = Math.floor(k / 2)
      k = 0
    }
  })

  cs.reverse().forEach((c, i) => {
    const j = a.length - i - 1
    if (c === L) {
      k++
      return
    }
    if (k > 0) {
      a[j + 1] += Math.round(k / 2)
      a[j] += Math.floor(k / 2)
      k = 0
    }
  })
  // console.log(a)
  console.log(a.join(' '))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 20040
# = int(input())
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if V*T - W*T < abs(B-A):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9168
a,ans = [],[]
for i in range(5):
    a.append(int(input()))
k = int(input())

for i in range(5):
    for j in range(i+1,5):
        ans.append((a[i]-a[j])**2)
if max(ans) <= k**2:
    print("Yay!")
else:
    print(":(")


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

int main()
{
  int N, M; cin >> N >> M;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  int count = 0, sum = 0;
  rep(i,N) sum += A[i];
  
  rep(i,N){
    if(A[i]*4*M >= sum) count++;
  }
  if(count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val k = nextInt()
    val xx = listOfInt()

    var cnt = 0
    xx.forEach {
        cnt += Math.min(it, Math.abs(k-it)) * 2
    }

    println(cnt)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 38120
#include <iostream>

using namespace std;

int main()
{
long i,sum=0,k, x, max, mini;

cin>> k >> x;
max=x;
mini=x;
for (i=1;i<=k;i++)
{
sum+=x;
if (x<mini)
{
mini=x;
}
if (x>max)
{
max=x;
}
cin >> x;
}
cout << mini << " " << max << " " << sum<< endl;
return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=1e9;
	for (int i=0;i<int(s.size())-2;i++){
		int num=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
		if (abs(num-753)<ans) ans=abs(num-753);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef unsigned long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

ll div_up(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{

    ll N, X, x[212345], sum[212345];
    cin >> N >> X;

    sum[0] = 0;
    for (ll i = 0; i < N; i++)
    {
        cin >> x[i];
        sum[i + 1] = sum[i] + x[i];
    }

    ll res = 1e18 * 18;

    for (ll k = 1; k <= N; k++)
    {
        ll tmp = 0;

        ll a = 5;

        for (ll i = 0; i < div_up(N, k); i++)
        {
            if (N >= k * (i + 1))
                tmp += a * (sum[N - k * i] - sum[N - k * (i + 1)]);
            else
                tmp += a * sum[N - k * i];

            if (i > 0)
                a += 2;
        }

        tmp += k * X;

        res = min(res, tmp);
    }

    res += N * X;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3456
/**********************
author : coldbeer
2019-06-16 8:49:18 PM
***********************/
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define sz(v) (int)v.size()
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
const ll N = 2e3 + 5;
const ll MOD = 1e9 + 7;

ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll n, m;
vector<ll> s, t;
vector<vector<ll>> cache(N, vector<ll>(N, 1));

ll solve()
{
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 1; j < m + 1; j++)
        {
            cache[i][j] = add(add(cache[i - 1][j], cache[i][j - 1], MOD), -cache[i - 1][j - 1], MOD);
            if (s[i] == t[j])
                cache[i][j] = add(cache[i][j], cache[i - 1][j - 1], MOD);
        }
    }
    return cache[n][m];
}

int main()
{
    cin >> n >> m;
    s.assign(n + 1, 0);
    t.assign(m + 1, 0);
    for (int i = 1; i < n + 1; i++)
        cin >> s[i];
    for (int i = 1; i < m + 1; i++)
        cin >> t[i];
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 31744
/*A-Frog 1*/
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
   cin>>n>>k;
   vector<int> a(n);
   for (auto &&i : a)
   {
       cin>>i;
   }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
       
            if(i+j<n)
            dp[i+j]= min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        }
        
    }
    cout<<dp[n-1]<<endl;
    

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  ll n,m;cin>>n>>m;
  ll a[n],b[m];
  ll c[n*m+1];
  fill(c,c+n*m+1,(ll)0);
  for(ll i=0;i<n;i++){
    
    cin>>a[i];
    if(c[a[i]]){
      cout<<0<<endl;
      return 0;
    }
    c[a[i]]=1;
  }
  for(ll i=0;i<m;i++){
    cin>>b[i];
    if(c[b[i]]>=2){
      cout<<0<<endl;
      return 0;
    }
    if(c[b[i]]){
      c[b[i]]=3;
    }
    else c[b[i]]=2;
  }
  ll st=0,sy=0;
  ll ans=1;
  for(ll i=n*m;i>=1;i--){
    if(c[i]==3){
      st++;
      sy++;
    }
    else if(c[i]==2){
      ans*=st;
      ans%=mod;
      sy++;
    }
    else if(c[i]==1){
      ans*=sy;
      ans%=mod;
      st++;
    }
    else{
      ll u=st*sy-(n*m-i);
      if(u<=0)u=0;
      ans*=u;
      ans%=mod;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
}
  
  

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    ll ans = 0, sum = 0;
    vector<ll> cnt(N);
    bool loop = true;
    while (loop) {
        loop = false;
        for (int i = 0; i < N; i++) cnt[i] = v[i] / N;
        sum = accumulate(cnt.begin(), cnt.end(), 0LL);
        ans += sum;
        for (int i = 0; i < N; i++) {
            v[i] -= cnt[i] * N;
            v[i] += (sum - cnt[i]);
            if (v[i] >= N) loop = true;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll kai[(1<<21)];
ll dp[(1<<21)];
void init() {
    kai[0] = 1;
    kai[1] = 1;
    for (ll i = 2; i < (1 << 21); i++) {
        kai[i] = kai[i - 1] * i % mod;
    }
}

ll mp(ll a, ll b) {
    if (b == 0) return 1LL;
    ll ret = mp(a,b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) ret *= a;
    return ret % mod;
}

ll inv(ll k) {
    return mp(k,mod-2);
}

ll c(ll n, ll k) {
    if (k == 0) return 1;
    if (n == k) return 1;
    return kai[n] * inv(kai[k]) % mod * inv(kai[n-k]) % mod;
}

int main() {
    init();
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    dp[n] = 1LL;
    for (ll i = n + 1; i <= n + k; i++) {
        dp[i] = dp[i-1] * 26LL % mod;
        dp[i] += c(i-1,n-1) * mp(25LL,i-n);
        dp[i] %= mod;
    }
    cout << dp[n+k] << endl;
    return 0;
}

Measured memory_bytes: 28544
# -*- coding: utf-8 -*-       
import math
def is_prime(x):
    if(x%2==0):return 0
    else:
        a = 3
        while(a<=math.sqrt(x)):
            if(x%a==0):return 0
            a += 2
    return 1

q = int(input())
MAX = 10**5+2
prime = [0 for i in range(MAX)]
alike = [0 for i in range(MAX)]
num = [0 for i in range(MAX)]
prime[2],prime[3] = 1,1
for i in range(4,MAX):
    prime[i] = is_prime(i)
for i in range(1,MAX-1,2):
    if(prime[i]==1 and prime[(i+1)//2]==1):
        alike[i] = 1
    num[i] = num[i-2]+alike[i]
    num[i+1] = num[i]
for i in range(q):
    l, r = list(map(int,input().split()))
    print(num[r]-num[l-1])
 

Measured memory_bytes: 6936
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int p[10] = {0};
int my_next_perm(int n){
    int i, j, tmp;
    if(n <= 1) return 0;
    for(i = n-1; i > 0 && p[i-1] >= p[i]; i--);
    if(i == 0) return 0;
    for(j = n-1; j > i && p[i-1] >= p[j]; j--);
    swap(p[i-1], p[j]);
    for(j = n-1; i < j; i++, j--)
        swap(p[i], p[j]);
    return 1;
}

void fill_sc(char q[10][10], const int x,const int y){
    const int dx[] = {1,1,-1,-1}, dy[] = {-1,1,-1,1};
    q[x][y] = 'Q';
    rep(i,8) if(q[i][y] == 0) q[i][y] = '.';
    rep(i,8) if(q[x][i] == 0) q[x][i] = '.';
    rep(i,4){
        int tmpx = x, tmpy = y;
        while(tmpx >= 0 && tmpx < 8 && tmpy >= 0 && tmpy < 8){
            if(q[tmpx][tmpy] == 0) q[tmpx][tmpy] = '.';
            tmpx += dx[i]; tmpy += dy[i];
        }
    }
}

char P[10][10] = {0}, Q[10][10] = {0};
int ch[10] = {0};
int main(){
    int k; scanf("%d", &k);
    rep(i,k){
        int r,c; scanf("%d%d", &r, &c);
        fill_sc(P,r,c);
        ch[r] = 1;
    }

    int tmp=0;
    rep(i,8-k){
        while(ch[tmp] != 0) tmp++;
        p[i] = tmp; tmp++;
    }
    do{
        memcpy(Q,P,sizeof(P));
        int ng;
        rep(i,8-k){
            ng = 1;
            rep(j,8){
                if(Q[p[i]][j] == 0){
                    fill_sc(Q,p[i],j);
                    ng = 0;
                    break;
                }
            }
            if(ng) break;
        }
        if(ng == 0) break;
    }while(my_next_perm(8-k));
    
    rep(i,8){
        rep(j,8){
            printf("%c", Q[i][j]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define N 200005
#define M 2000
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N

using namespace std;
double pi = acos(-1);
int hr = 12*60;
int mr = 60;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
     int k; cin>>k;
     string s; cin>>s;
     for(int i=0;i<s.length();i++){
         if(i==k){
             cout<<"...";
             return 0;
         }
        else cout<<s[i];
     }
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n,time;
    int c,t;
    int ans=-1;
    cin>>n>>time;
    for(int i=0;i<n;i++){
        cin>>c>>t;
        if(t<=time){
            if(ans==-1){
                ans=c;
            }else{
                ans=min(ans,c);
            }
        }
    }
    if(ans==-1)
        cout<<"TLE\n";
    else
        cout<<ans<<"\n";

        return 0;
}


Measured memory_bytes: 384
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            x = C[i][k] + C[k][j]
            if x < C[i][j]:
                C[i][j] = x

answer = 0
for x in A:
    for y in x:
        if y >= 0:
            answer += C[y][1]
print(answer)

Measured memory_bytes: 3316
def main():
	team_num  = int(input())
	match_num = int((team_num * (team_num - 1)) / 2)
	win_points = {}

	for i in range(team_num):
		win_points[i+1] = 0

	for i in range(match_num):
		match_result = input().split(" ")
		teamA_num    = int(match_result[0])
		teamB_num    = int(match_result[1])
		teamA_point  = int(match_result[2])
		teamB_point  = int(match_result[3])

		if teamA_point > teamB_point:
			# TeamA Win
			win_points[teamA_num] += 3
		elif teamA_point < teamB_point:
			# TeamB Win
			win_points[teamB_num] += 3
		else:
			# Draw
			win_points[teamA_num] += 1
			win_points[teamB_num] += 1

	win_points_sorted = sorted(win_points.items(), key=lambda x:x[1], reverse=True)

	pre_team_point = -1
	ranks = [0]*team_num
	rank = 0
	for i in range(len(win_points_sorted)):
		if win_points_sorted[i][1] != pre_team_point:
			rank = i+1
		ranks[win_points_sorted[i][0]-1] = rank
		pre_team_point = win_points_sorted[i][1]

	for i in ranks:
		print(i)


if __name__ == '__main__':
	main()


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    int al = 0, bb = 0;

    for(int i = 0; i < n; i++){
        if(i & 1)bb += a[i];
        else al += a[i];
    }
    cout << al - bb << endl;

}

Measured memory_bytes: 256
import sys
S = sys.stdin.readline().rstrip()
a1 = S[0]
a2 = S[1]
a3 = S[2]
a4 = S[3]
count1=0
count2=0
count3=0
count4=0

for i in range(4):
  if a1==S[i]:
    count1+=1
  if a2==S[i]:
    count2+=1
  if a3==S[i]:
    count3+=1
  if a4==S[i]:
    count4+=1
    
if count1==2 & count2==2 & count3==2 & count4==2:
  print('Yes')
else: print('No')  

Measured memory_bytes: 3064
def c_next_prime():
    from bisect import bisect_left
    X = int(input())

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    primes = prime_table(2 * X)
    return primes[bisect_left(primes, X)]

print(c_next_prime())

Measured memory_bytes: 5216
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
  a, b = ab[i]
  
  dis = 10 ** 20
  res = 0
  for i, check in enumerate(cd):
    tmp_dis = abs(a - check[0]) + abs(b - check[1])
    if dis == tmp_dis:
      continue
    if tmp_dis < dis:
      dis = tmp_dis
      res = i + 1
  
  print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s.length() < 4) return printf("No"), 0;
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') return printf("Yes"), 0;
    return printf("No"), 0;
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

s,t = map(str, stdin.readline().rstrip().split())
a,b = map(int, stdin.readline().rstrip().split())
u = input()
if(u == s):
	a -= 1
else:
	b -= 1
print(a,b)

Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> a(N + 1, 0);
    vector<int> flg(N + 1, 1);
    REP(i, M)
    {
        int p;
        cin >> p;
        flg[p] = 0;
    }
    a[0] = 1;
    a[1] = flg[1] ? 1 : 0;
    FORS(i, 2, N)
    {
        if (flg[i] == 1)
        {
            a[i] = (a[i - 1] + a[i - 2]) % MOD;
        }
    }
    cout << a[N] << "\n";
}


Measured memory_bytes: 1024
n,m,Q = gets.chomp.split(" ").map(&:to_i)
l = []
r = []
cnt = Array.new(n+1){Array.new(n+1,0)}
m.times do |i|
  l[i],r[i] = gets.chomp.split(" ").map(&:to_i)
  cnt[l[i]][r[i]] += 1
end
p = []
q = []
Q.times do |i|
  p[i],q[i] = gets.chomp.split(" ").map(&:to_i)
end
arr = Array.new(n+1){Array.new(n+1,0)}
1.upto(n) do |i|
  1.upto(n) do |j|
    arr[i][j] = arr[i][j-1] + cnt[i][j]
  end
end
1.upto(n) do |i|
  1.upto(n) do |j|
    arr[j][i] = arr[j-1][i] + arr[j][i]
  end
end
Q.times do |i|
  cnt = arr[q[i]][q[i]] - arr[q[i]][p[i]-1] - arr[p[i]-1][q[i]] + arr[p[i]-1][p[i]-1] 
  puts cnt
end

Measured memory_bytes: 22792
#include<stdio.h>
int main(){
	int n,h,m;
	char a[10];
	double h2,m2,ggg;
	scanf("%d",&n);
	while(n-->0){
		scanf("%s",a);
		h=(a[0]-'0')*10+a[1]-'0';
		m=(a[3]-'0')*10+a[4]-'0';
		h2=(double)360*(h*60+m)/(60*12);
		m2=(double)360*m/60;

		if(h2<m2)
			ggg=m2-h2;
		else
			ggg=h2-m2;
		
		
		if(ggg>=0&&ggg<30)
			printf("alert\n");
		else if(ggg>=90&&ggg<=270)
			printf("safe\n");
		else if(ggg<360&&330<ggg)
			printf("alert\n");
		else printf("warning\n");
		
		
		
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
    // 整数の入力
    int n, x[20];
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x[i];
    }
    //
    int cnt = 0;
    for(int i=1;i<n-1;i++){
      if((x[i-1] < x[i] && x[i] < x[i+1]) || (x[i-1] > x[i] && x[i] > x[i+1])){
        cnt += 1;
      }
    }
    //
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int N,K;
const int maxn = 55;
LL v[maxn];
LL ans;

void judge(vector<LL> &vi,int rest){
    int i = 0;
    for(i = 0;i < rest && i < vi.size();i++){
        if(vi[i] >= 0){
            LL temp = 0;
            _for(j,i,vi.size()){
                temp += vi[j];
            }
            ans = max(ans,temp);
            return;
        }
    }

    LL temp = 0;
    if(vi.size() > rest){
        _for(i,rest,vi.size()){
            temp += vi[i];
        }
    }
    ans = max(ans,temp);

}


int main()
{
    cin >> N >> K;
    ans = 0;
    _for(i,0,N){
        int num;
        cin >> num;
        v[i] = num;
    }
    for(int l = 0;l <= N && l <= K;l++){
        for(int r = 0; r <= N && r+l <= K && r+l <= N;r++){
            vector<LL> vi;
            _for(i,0,l) vi.PB(v[i]);
            _for(i,0,r) vi.PB(v[N-i-1]);
            sort(ALL(vi));
            judge(vi,K-l-r);

        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;



void solve(){
    int x , y;
    cin >> x >> y;
    for(int i = 0; i <= x; ++ i){
        int x2 = i * 2;
        int x3 = (x - i) * 4;
        if(x2 + x3 == y){
            cout << "Yes";return;
        }
    }
    cout << "No";
}

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

/**

**/


Measured memory_bytes: 3648
using System;
class main
{
    static void Main(string[] args)
    {
        string s;
        while ((s = Console.ReadLine()) != null)
        {
            int n,m,l,o;
            int[] a = new int[int.Parse(s)];
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < a.Length; ++i)
            {
                a[i] = i + 1;
            }
            for (int i = 0; i < n; ++i)
            {
                string[] t = Console.ReadLine().Split(',');
                m = int.Parse(t[0]);
                l = int.Parse(t[1]);
                o = a[m - 1];
                a[m -1] = a[l - 1];
                a[l -1] = o;
            }
            for (int i = 0; i < a.Length; ++i)
            {
                Console.WriteLine(a[i]);
            }
        }
    }
}

Measured memory_bytes: 5592
(sx, sy, tx, ty) = map(int, input().split())

print('U'*(ty-sy), end='')
print('R'*(tx-sx), end='')
print('D'*(ty-sy), end='')
print('L'*(tx-sx), end='')
print('L', end='')
print('U'*(ty+1-sy), end='')
print('R'*(tx+1-sx), end='')
print('D', end='')
print('R', end='')
print('D'*(ty+1-sy), end='')
print('L'*(tx+1-sx), end='')
print('U')


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

int main(){
    int N,ans=0;
    cin>>N;
    vector<long long>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<N;i++){
        while(a.at(i)%2==0){
            if (a.at(i)%2==0){
                ans++;
                a.at(i)/=2;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 105;
int a[MAXN][MAXN], b[MAXN][MAXN];
vector <int> G[MAXN][MAXN];
struct Edges { int to, next; } e[MAXN * MAXN];
int head[MAXN], tot;
int link[MAXN], vis[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
}
bool xyl(int k) {
  if (vis[k]) return 0;
  vis[k] = 1;
  for (RI i = head[k]; i; i = e[i].next)
    if (!link[e[i].to] || xyl(link[e[i].to])) {
      link[e[i].to] = k;
      return 1;
    }
  return 0;
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= m; ++j)
      read(a[i][j]), G[i][(a[i][j] + m - 1) / m].push_back(a[i][j]);
  for (RI i = 1; i <= m; ++i) {
    memset(head, 0, sizeof(head)), tot = 0;
    memset(link, 0, sizeof(link));
    for (RI j = 1; j <= n; ++j)
      for (RI k = 1; k <= n; ++k)
        if (G[j][k].size())
          addedge(j, k);
    for (RI j = 1; j <= n; ++j)
      memset(vis, 0, sizeof(vis)), xyl(j);
    for (RI j = 1; j <= n; ++j) {
      b[link[j]][i] = G[link[j]][j].back();
      G[link[j]][j].pop_back();
    }
  }
  for (RI i = 1; i <= n; ++i, puts(""))
    for (RI j = 1; j <= m; ++j)
      printf("%d ", b[i][j]);
  for (RI i = 1; i <= m; ++i)
    for (RI j = 1; j <= n; ++j)
      for (RI k = 1; k < n; ++k)
        if (b[k][i] > b[k + 1][i])
          swap(b[k][i], b[k + 1][i]);
  for (RI i = 1; i <= n; ++i, puts(""))
    for (RI j = 1; j <= m; ++j)
      printf("%d ", b[i][j]);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long ans = Math.Max(0,N-M*2);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N;
	std::cin >> N;
	vll A(N);
	map<ll, ll> dic, s;
	rep(i, 0, N) {
		std::cin >> A[i];
		dic[A[i]]++;
	}

	ll c = 0;
	for (auto itr = dic.begin(); itr != dic.end(); itr++) {
		c += itr->second * (itr->second - 1);
	}
	c /= 2;

	rep(i, 0, N) {
		std::cout << c - (dic[A[i]] - 1) << endl;
	}

	return 0;
}


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

int main(){
	string n;
	int i,count=0;
	int x=0,y=0,z=0;
	cin >> n;
	for(i=0;i<3;i++){
		
		if(n[i]=='a'&&x==0){
			x=1;
			count++;
		}
		else if(n[i]=='b'&&y==0){
			y=1;
			count++;
		}
		else if (n[i]=='c'&&z==0){
			z=1;
			count++;
		}
		else break;
		
	}
	if(i==3)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
  int n, k; cin >> n >> k;
  vector<int> A(n); rep(i, n) cin >> A[i];
  if(k >= 5000){
    rep(i, n) cout << n << " ";
    cout << ln;
  }else{
    rep(i, k){
      vector<int> plus(n), minus(n);
      rep(j, n){
        int s = max(0, j-A[j]), t = min(n-1, j+A[j]);
        plus[s]++; minus[t]++;
      }
      int cnt = 0;
      rep(j, n){
        cnt += plus[j];
        A[j] = cnt;
        cnt -= minus[j];
      }
    }
    rep(i, n){
      cout << A[i] << " ";
    }cout << ln;
  }
}


Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s1[10];
   cin>>s1;
     char s2[10];
   cin>>s2;
     char s3[10];
   cin>>s3;
    if(s1[0]>='a' && s1[0]<='z')
    {
          s1[0]-=32;
        
    }
     if(s2[0]>='a' && s2[0]<='z')
    {
       s2[0]-=32;
      
    }
      if(s3[0]>='a' && s3[0]<='z')
    {  s3[0]-=32;
       
    }
    cout << s1[0]<<s2[0]<<s3[0];
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	s := 0
	for i := 1; i <= n; i++ {
		t := 0
		c := i
		for j := 0; j <= 5; j++ {
			t += c % 10
			c /= 10
		}

		if a <= t && t <= b {
			s += i
		}
	}

	fmt.Println(s)
}


Measured memory_bytes: 1772
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()

for i in range(1, 500100):
    if int(i * 1.08) == N:
        print(i)
        break
else:
    print(":(")


Measured memory_bytes: 44400
#include<iostream>
#include<algorithm>

using namespace std;

int c[] = {1, 4, 1, 4, 1, 2, 1, 2};
int ans[] = {14141212,
	     41412121,
	     14121214,
	     41212141,
	     12121414,
	     21214141,
	     12141412,
	     21414121};
int p[8];
int main(){
    while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
	int lex = 1 << 30, an, rem = 1 << 30;
	for(int i = 0;i < 8;i++){
	    int tmp = 0;
	    for(int j = 0;j < 8;j++){
		tmp += max(p[j] - c[(i + j) % 8], 0);
	    }
	    if(tmp < rem || tmp == rem && ans[i] < lex){
		lex = ans[i];
		an = i;
		rem = tmp;
	    }
	}
	for(int i = 0;i < 8;i++){
	    cout << c[(i + an) % 8];
	    if(i != 7)cout << " ";
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);
#define f first
#define s second

using namespace std;

const int maxn = (int)(1e5)+2;
const int inf = (int)(1e9)+7;

ll n, a[maxn], A, B;

bool check(ll m) {
 	ll cur = 0,l=0,r=0,res=0;
 	for (int i = 1; i <= n;i++) {
 		l = 0, r = 1e9;
 		while (l <= r) {
 		 	ll mid = (l+r) >> 1;
 		 	if (a[i] < mid*A) {
 		 	 	cur = mid;
 		 	 	r = mid-1;
 		 	 	continue;
 		 	}
 		 	if ((a[i]-mid*A + B - 1) / B <= m-mid) {
 		 	 	cur = mid;
 		 	 	r = mid-1;
 		 	}
 		 	else 
 		 		l = mid+1;
 	 	}
 	 	res += cur;
 	}
 	return res <= m;
}


int main() {
	_
	
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++)	cin >> a[i];

	ll l = 1, r = 2e9, ans = 0;
	while(l<=r) {
	 	ll mid = (l+r) >> 1;
	 	if (check(mid)) {
	 	    r = mid-1;
	 		ans = mid;
	 	}
	 	else {
	 	 	l = mid+1;	
	 	}
	}
	cout << ans;
	return 0;
}

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

long long INF = 1e18;

int main(){
    int n, k;
    cin >> n >> k;
    double imp;
    double p[n + 100];
    for (int i = 0; i < n; i++){
        cin >> imp;
        p[i] =(double) (0.5 * imp * (imp + 1)) / imp;
        
    }

    double max = 0;
    int l = 0;
    for (int i = 0; i < k; i++){
        max += p[i];
    }
    double box = max;
    for (int l = k; l < n; l++)
    {
        box = box - p[l - k] + p[l];
        if (max <box)
        {
            max = box;
            
        }
        
        }
        printf("%.12f\n", max);
        return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
long L,A,B,M;
long power(long a,long b){return b?power(a*a%M,b/2)*(b%2?a:1)%M:1;}
long ten[99],sten[99],iten[99];
long n;
long sum(long k)
{
	long ret=0,p=1;
	for(int i=61;i--;)
	{
		if(k>>i&1)
		{
			(ret+=sten[i]*p)%=M;
			p=p*ten[i]%M;
		}
	}
	return ret;
}
long isum(long k)
{
	long ret=0,p=1,g=0;
	for(int i=61;i--;)
	{
		if(k>>i&1)
		{
			(ret+=(iten[i]+sten[i]*g)%M*p)%=M;
			p=p*ten[i]%M;
			g=(g+(1LL<<i))%M;
		}
	}
	return ret;
}
long cnt[18],SUM[18];
main()
{
	cin>>L>>A>>B>>M;
	long pre=0,tmpten=1;
	long ans=0;
	for(n=1;n<=18;n++)
	{
		cnt[n-1]=1;
		long l=pre,r=L;
		tmpten*=10;
		while(r-l>1)
		{
			long m=(l+r)/2;
			if(A+B*m<tmpten)l=m;
			else r=m;
		}
		long k=l-pre;
		if(k<0||l>=L||A+B*l>=tmpten)
		{
			continue;
		}
		pre=l+1;
		ten[0]=tmpten%M;
		sten[0]=1;
		iten[0]=0;
		if(k+1&1)cnt[n-1]=tmpten%M;
		for(int i=1;i<61;i++)
		{
			ten[i]=ten[i-1]*ten[i-1]%M;
			sten[i]=(ten[i-1]+1)%M*sten[i-1]%M;
			iten[i]=((ten[i-1]+1)%M*iten[i-1]+(1LL<<i-1)%M*sten[i-1]%M*ten[i-1])%M;
			if(k+1>>i&1)cnt[n-1]=cnt[n-1]*ten[i]%M;
		}
		SUM[n-1]=(((A+B*l)%M*sum(k+1)%M-B%M*isum(k+1))%M+M)%M;
	}
	long p=1;
	for(int i=18;i--;)
	{
		ans=(ans+SUM[i]*p)%M;
		p=p*cnt[i]%M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
s  =gets.chomp.to_i

ss = []
previous = s
ss << previous
until ss.count(previous) == 2
  if previous.even?
    ss << previous / 2
    previous = previous / 2
  else
    ss << previous * 3 + 1
    previous = previous * 3 + 1
  end
end

puts ss.length

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

int main(){
  string S;
  cin >> S;
  int N=S.size()-1;
  vector<int> idx(N+2);
  idx[0]=0;
  vector<string> s(N+2);
  long ans=S[0]-'0';
  for(int i=1; i<S.size(); i++){
    ans= ans*10+(S[i]-'0');
  }
  for(int i=1; i< (1<<N); i++){
    int bit=i;
    int num=1;
    int count=1;
    for(int j=1; j<=N; j++){
      if(bit%2){
        idx[count]=num;
        count++;
      }
      bit/=2;
      num++;
    }
    idx[count]=N+1;
    int count1=0;
    for(int j=0; j<count; j++){
      string c="";
      for(int k=idx[j]; k<idx[j+1]; k++){
        c+=S[k];
      }
      s[count1]=c;
      count1++;
    }
    for(int i=0; i<count1; i++){
      long n=s[i][0]-'0';
      for(int j=1; j<s[i].size(); j++){
        n = n*10+(s[i][j]-'0');
      }
      ans+=n;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long long x, y; cin >> x >> y;
  if (x < y) {
    if (y <= 0 || x >= 0) cout << y - x << endl;
    else if (abs(x) > abs(y)) cout << 1 + abs(x) - y << endl;
    else cout << 1 + y - abs(x) << endl;
  }
  else {
    if (x < 0 || y > 0) cout << 2 + abs(x - y) << endl;
    else if (abs(x) < abs(y)) cout << 1 + abs(y) - x << endl;
    else cout << 1 + x - abs(y) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeN(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  

int nextPrime(ll N)
{
  
    if (N <= 1)
        return 2;
  
    ll prime = N;
    bool found = false;
  
    while (!found) {
        prime++;
  
        if (primeN(prime))
            found = true;
    }
  
    return prime;
}
  

int main(){
    ll n;
    cin>>n;
    
    if(primeN(n))cout<<n<<endl;
    else cout << nextPrime(n)<<endl;;
  
    return 0;
}


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

int main(){
    string S;  cin >> S;
    int N = S.length();
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(!(S[i]=='A' || S[i]=='G' || S[i]=='T' || S[i]=='C')) continue;
        string tmp = "";
        for(int j=i; j<N; j++){
            if(S[j]=='A' || S[j]=='G' || S[j]=='T' || S[j]=='C'){
                tmp += S.substr(j, 1);
            }else{
                break;
            }
        }
        if(tmp.length() > cnt){
            cnt = tmp.length();
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  char S[4];
  cin >> S;

  int ans = 700;
  for (int i = 0; i < 3; i++)
    if (S[i] == 'o') ans += 100;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++)
typedef pair<ll, ll> P;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    map<ll, ll> mp;
    vector<P> bc(m);
    priority_queue<ll, vector<ll>, less<ll>> que;

    rep(i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    rep(i, 0, a.size()) que.push(a[i]);
    
    rep(i, 0, m) {
        cin >> bc[i].first >> bc[i].second;
    }
    
    rep(i, 0, m) {
        que.push(bc[i].second);
        mp[bc[i].second] += bc[i].first;
    }

    ll sum = 0;
    ll k = 0;
    while(1) {
        if(k >= n) break;
        ll tmp = que.top();
        que.pop();
        if(k+mp[tmp] > n) {
            sum += tmp*(n-k);
            mp[tmp] = 0;
            k += n-k;
        }
        else {
            sum += tmp*mp[tmp];
            k += mp[tmp];
            mp[tmp] = 0;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 16628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		i,N,a[1001];

	scanf("%d", &N);
	for(i=1;i<=N;i++) {
		scanf("%d", &a[i]);
	}
	for(i=N;i>0;i--) {
		printf("%d",a[i]);
		if (i!=1) printf(" ");
	}
	ENTER;

	return 0;
}



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

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

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

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

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

    string S, T;
    cin >> S >> T;
    ll res = 0;
    REP(i, 3) res += (S[i] == T[i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
typedef struct {
  int l;
  int r;
} Query;

bool isPrime(int n)
{
  if(n == 0 || n == 1) return false;
  if(n == 2) return true;
  bool res = true;
  for(int i=2; i*i <= n; i++) {
    if (n%i == 0) res = false;
  }
  return res;
}

int main()
{
  int q;
  cin >> q;
  vector<Query> Q(q);
  rep(i,q) {
    int l,r;
    cin >> l >> r;
    Q[i] = (Query){l, r};
  }

  bool isPrimeNum[100001];
  rep(i, 100001) isPrimeNum[i] = isPrime(i);

  int d[100001];
  d[0] = 0;
  for ( int i = 1; i <= 100000; i++ ) {
    int a = ( isPrimeNum[i] && isPrimeNum[(i+1)/2] ) ? 1 : 0;
    d[i] = d[i-1] + a;
  }

  rep(i,q) {
    int ans = d[Q[i].r] - d[Q[i].l-1];
    cout << ans << endl;
  }

}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> A(n);
  std::vector<int> B(n);
  std::vector<int> C(n);
  for (int i = 0; i < n; i++)
  {
    std::cin >> A[i];
  }
  for (int i = 0; i < n; i++)
  {
    std::cin >> B[i];
  }
  for (int i = 0; i < n; i++)
  {
    std::cin >> C[i];
  }
  std::sort(A.begin(),A.end());
  std::sort(B.begin(),B.end());
  std::sort(C.begin(),C.end());
  long long  counter = 0;
  int b_idx = 0;
  for (int i = 0; i < n; i++)
  {
    auto a_it = std::lower_bound(A.begin(), A.end(), B[i]);
    long long  num_lower_than_target = n-std::distance(a_it, A.end());
    // std::cout << "a_it "<< *a_it << std::endl;
    // std::cout << "num lower "<< num_lower_than_target << std::endl;
    auto c_it = std::upper_bound(C.begin(), C.end(), B[i]);
    long long num_upper_than_target = std::distance(c_it, C.end());
    counter += (num_upper_than_target*num_lower_than_target);
    // std::cout << "c_it "<< *c_it << std::endl;
    // std::cout << "num upper "<< num_upper_than_target << std::endl;
    // std::cout << "upper "<<num_upper_than_target << std::endl;
    // std::cout << "b it "<< *b_it << std::endl;
    // if(b_it == B.end())continue;
    // auto c_it = std::upper_bound(C.begin(), C.end(), *b_it);
    // if(c_it==C.end()) continue;
    // std::cout << "C IT "<< *c_it << std::endl;
    // int dist = std::distance(C.begin(), c_it);
    // std::cout << "dist "<<dist << std::endl;


    // int a = A[i];
    // while(a >= B[b_idx])
    // {
    //   b_idx++;
    // }
    // int c_idx = 0;
    // for (int j = b_idx; j < n; j++)
    // {
    //   while(B[j]>=C[c_idx])
    //   {
    //     c_idx++;
    //   }
    //   int num_c = n - c_idx;
    //   counter += num_c;
    // }
  }
  std::cout << counter << std::endl;

}


Measured memory_bytes: 1408