akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> BA(N);
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        BA[i] = make_pair(B, A);
    }

    sort(BA.begin(), BA.end());

    ll s = 0;
    rep(i, N) {
        s += ll(BA[i].second);
        if (s > ll(BA[i].first)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans=-1;
  if(s=="RRR") ans=3;
  if(s=="RRS"||s=="SRR") ans=2;
  if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR") ans=1;
  if(s=="SSS") ans=0;
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;


int main(){

	int answer,player,table[10],S,hit,blow;

	while(true){
		scanf("%d %d",&answer,&player);
		if(answer == 0 && player == 0)break;

		for(int i = 0; i < 10; i++)table[i] = 0;
		hit = blow = 0;

		S = 1000;

		for(int i = 1; i <= 4; i++){
			table[answer/S] = i;
			answer %= S;
			S /= 10;
		}

		S = 1000;

		for(int i = 1; i <= 4; i++){
			if(table[player/S] == i){
				hit++;
			}else if(table[player/S] != 0){
				blow++;
			}
			player %= S;
			S /= 10;
		}

		printf("%d %d\n",hit,blow);

	}

    return 0;
}

Measured memory_bytes: 2588
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
 
void Main()
{
	int N;
    int M;
  
  	cin >> N;
    cin >> M;
  
  int S;
  
  S = (N * (N - 1) + M * (M - 1)) / 2;
    
    printf("%d", S);
	
	
}
 
int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.



int main() {
    int H,W,h,w;
    cin>>H>>W;
    cin>>h>>w;
    cout << (H*W)-(h*W+w*H-h*w)<<endl;  
   

   return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
    
        x,y=map(int,input().split())
        for i in range(x+1):
            if 2*i+4*(x-i)==y:
                return 'Yes'
        return 'No'
    print(main())
    
resolve()

Measured memory_bytes: 61832
# -*- coding: utf-8 -*-
a,b,k = map(int,input().split())
"""
for i in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a,b)
"""

if k <= a and a >= 1:
    a = a - k
elif k <= a + b and b >= 1:
    c = a
    a = 0
    b = b - (k - c)
else:
    a = 0
    b = 0
print(a, b)


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

bool check(int a1, int b1, int a2, int b2){
    if(a1 * b2 <= a2 * b1)return true;
    return false;
}

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    set<int> st1, st2;
    for(int i = 0; i <= f; i++){
        for(int j = 0; j <= f; j++){
            int now1 = a * i + b * j;
            if(100 * now1 <= f)st1.insert(100 * now1);
            int now2 = c * i + d * j;
            if(now2 <= f)st2.insert(now2);
        }
    }
    int ans1 = 0, ans2 = 0;
    for(auto x : st1){
        for(auto y : st2){
            if(x + y > f || y > e * x / 100)continue;
            if(check(ans1, ans2, y, x+y)){
                ans1 = y; ans2 = x+y; 
            }
        }
    }
    cout << ans2 << " " << ans1 << endl;
}


Measured memory_bytes: 3760
<?php
  
$s = fgets(STDIN);

$u = 'yes';
$com = [];
for($i=0; $i<strlen($s); $i++){
  	if (in_array($s[$i], $com)) {
      $u = 'no';
      break;
    }
	array_push($com, $s[$i]);
}

echo $u;

?>

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  long long int a,b;
  char c;
  cin >> a >> c >> b;
  long long int ans;
  if(c == '+') {
    ans = a + b;
  } else {
    ans = a - b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# 奇数 * 奇数　の場合
# 1文字 - 1
# 2文字 - H//2 + W//2個
# 4文字 - H//2 * W//2個

# 奇数 * 偶数の場合　（Hが奇数とする）
# 2文字 - W//2個
# 4文字 - W//2個 * H//2個

# 偶数 * 偶数の場合
# 4文字 - w//2 * H//2個

H,W = map(int,input().split())
from collections import defaultdict
chars = defaultdict(int)
for i in range(H):
  for c in input():
    chars[c] += 1
    
# print(chars)
chars = sorted(chars.values())[::-1]
# print(chars)

ok = True

if H%2 == 1 and W%2 == 1:
  # 両方とも奇数の場合
  
  letter4 = (H//2) * (W//2)
#  print(H//2,W//2,letter4)
  ind = 0
  for i in range(letter4):
#    print(i,"in",letter4)
    while ind < len(chars):
      if chars[ind] >= 4:
        chars[ind]-=4
#        print(chars,ind)
        break
      else:
        ind+=1
        if ind == len(chars):
          ok = False
          break
        continue
        
#  print(chars,ok)
        
  letter2 = (H//2) + (W//2)
  ind = 0
  for i in range(letter2):
#    print(i,"in",letter2)
    while ind < len(chars):
      if chars[ind] >= 2:
        chars[ind]-=2
        break
      else:
        ind+=1
        if ind == len(chars):
          ok = False
          break
        continue
#  print(chars)
  if sum(chars) != 1:
    ok = False
elif H%2 == 0 and W%2== 0:
  # 両方とも偶数の場合
  
  # すべてのペアが4の倍数であることを確認
  for c in chars:
    if c%4 != 0:
      ok = False
      
else:
  # 片方が奇数の場合
  odd = -1
  even = -1
  if H%2 == 1:
    odd = H
    even = W
  else:
    odd = W
    even = H
    
  letter4 = (odd//2) * (even//2)
  ind = 0
  for i in range(letter4):
    while ind < len(chars):
      if chars[ind] >= 4:
        chars[ind]-=4
        break
      else:
        ind+=1
        if ind==len(chars):
          ok = False
          break
        continue
#  print(chars)
  for c in chars:
    if c%2 != 0:
      ok = False
#  print(chars)
  
print(("No","Yes")[ok])
  

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

#define MOD 1000000007
#define MAXN 1000

long long num[MAXN];

// nを素因数分解し、各べき指数の数をカウント
void factorization(int n)
{
	int i;

	// 2で割り切れるまで割る
	while (n % 2 == 0) {
		n = n / 2;
		//num[1] = (num[1] + 1) % MOD;
		num[1]++;
	}
	// 3以上nの平方根以下の数で割り切れるまで割る
	for (i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			n = n / i;
			//num[i - 1] = (num[i - 1] + 1) % MOD;
			num[i - 1]++;
		}
	}
	if (n > 1) num[n - 1]++;//num[n - 1] = (num[n - 1] + 1) % MOD;
}

int main(void)
{
	long long N;
	long long ans = 1;
	long long i;

	scanf("%lld", &N);

	// 素因数分解
	for (i = 1; i <= N; i++) {
		factorization(i);
	}
	// 約数の個数を求める
	for (i = 1; i < N; i++) {
		ans = (ans * (num[i] + 1)) % MOD;
	}
	printf("%lld\n", ans);

	return (0);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int count = 0;
	for (int i = 0; i < 16; i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
ans = [0] * n
for i in range(n - 1):
    if (s[i] == 'R') and (s[i + 1] == 'L'):
        shift = 0
        while s[i - shift] == 'R':
            if shift % 2 == 0:
                ans[i] += 1
            else:
                ans[i + 1] += 1
            shift += 1
            if i - shift == -1:
                break
        shift = 0
        while s[i + 1 + shift] == 'L':
            if shift % 2 == 0:
                ans[i + 1] += 1
            else:
                ans[i] += 1
            shift += 1
            if i + 1 + shift == n:
                break
for i in range(n):
    print(ans[i], end=' ')

Measured memory_bytes: 4864
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
even = 0
odd = 0
num = A[0]
cnt = 0
for i in range(N+1):
    if i < N and num == A[i]:
        cnt += 1
    else:
        if cnt%2 == 0:
            even += 1
        else:
            odd += 1
        cnt = 1
        num = A[min(i, N-1)]

if even%2 == 0:
    ans = even + odd
else:
    ans = max(even + odd - 1, 1)
    
print(ans)

Measured memory_bytes: 14396
import sys
readline = sys.stdin.readline


def main():
    N, W = map(int, readline().rstrip().split())
    dp = [0] * (W + 1)

    for _ in range(N):
        v, w = map(int, readline().rstrip().split())
        for j in range(W-w+1):
            dp[j+w] = max(dp[j+w], dp[j] + v)

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5916
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N,M = II()
A = III()
B,C = Line(M)

a = []
for i in range(N):
  a.append([1,A[i]])
for i in range(M):
  a.append([B[i],C[i]])

#a.sort(key=lambda x:x[1],reverse=True)
a.sort(key=lambda x:-x[1])
counter = 0
ans = 0

for i in range(N+M):
  if counter + a[i][0] >= N:
    ans += a[i][1]*(N-counter)
    break
  else:
    counter += a[i][0]
    ans += a[i][1]*a[i][0]

print(ans)

Measured memory_bytes: 104832
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    int n, m, p, x;
    int min = mod;
    cin >> n >> m >> x;

    vector<vector<int> > a(n, vector<int> (m));
    vector<int> c(n);
    FOR(i,0,n){
        cin >> c[i];
        FOR(j,0,m){
            cin >> a[i][j];
        }
    }

    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> u(m, 0);
        int cost = 0;
        for (int i = 0; i < n; i++) { // i冊目の本を買う
            if (bit & (1<<i)) {
                cost += c[i];
                FOR(j,0,m){
                    u[j] += a[i][j];
                }
            }
        }

        bool isOK = true;
        FOR(i,0,m){
            if(u[i] < x)isOK = false;
        }

        if(isOK && cost < min)min = cost;
    }

    if(min == mod){
        cout << -1 << endl;
    }else{
        cout << min << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
di = collections.defaultdict(int)

for i in range(n):
    s = S()
    di[s]+=1

mx = 0
l = []
for i in di:
    if mx<di[i]:
        l = [i]
        mx = di[i]
    elif mx==di[i]:
        l.append(i)
l.sort()
for v in l:
    print(v)

Measured memory_bytes: 34228
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a >= b && a >= c){
		rep(i,k)a *= 2;
		cout << a+b+c << endl;
	}
	else if(b >= a && b >= c){
		rep(i,k)b *= 2;
		cout << a+b+c << endl;
	}
	else{
		rep(i,k)c *= 2;
		cout << a+b+c << endl;
	}
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a * b % 2) cout << "Odd" << endl;
  else cout << "Even" << endl;
  
  return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  double a,b;
  cin >> a >> b;
  double c = (a+b)/2;
  int d = (a+b)/2;
  d++;
  if(d-0.5 <= c){
    cout << d << endl;
    return 0;
  }else{
    cout << d-1 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// D=25 なら Christmas
// D=24 なら Christmas Eve
// D=23 なら Christmas Eve Eve
// D=22 なら Christmas Eve Eve Eve
int main()
{
int D;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> D;

	if( D == 25 )
		cout << "Christmas" << endl;
	else if( D == 24 )
		cout << "Christmas Eve" << endl;
	else if( D == 23 )
		cout << "Christmas Eve Eve" << endl;
	else if( D == 22 )
		cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}


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

const long long INF=1LL<<60;

long long dist[210][210];

int main(){
  int N,M,R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for(int i=0;i<R;++i){
    cin >> r[i];
    r[i]--;
  }
  for(int i=0;i<210;++i){
    for(int j=0;j<210;++j){
      dist[i][j]=INF;
    }
    dist[i][i]=0;
  }
  vector<int> a(M),b(M),c(M);
  for(int i=0;i<M;++i){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]]=c[i];
    dist[b[i]][a[i]]=c[i];
  }
  for(int k=0;k<N;++k){
    for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  long long ans=INF;
  sort(r.begin(),r.end());
  do{
    long long cal=0;
    for(int i=1;i<R;++i) cal+=dist[r[i]][r[i-1]];
    ans=min(ans,cal);
  }while(next_permutation(r.begin(),r.end()));

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 768
def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
ll int h,w;
cin>>h>>w;
char c[h][w];
for(ll int i=0;i<h;i++)
{for(ll int j=0;j<w;j++)
cin>>c[i][j];    
}
ll int a[h][w];
memset(a,0,sizeof a);
for(ll int i=0,j=0;j<w;j++)
{if(c[i][j]!='#')
a[i][j]=1;
else
break;}
for(ll int i=0,j=0;i<h;i++)
{if(c[i][j]!='#')
a[i][j]=1;
else
break;}
for(ll int i=1;i<h;i++)
{for(ll int j=1;j<w;j++)
{if(c[i][j]!='#')
a[i][j]=(a[i-1][j]%mod+a[i][j-1]%mod)%mod;
    
}
    
    
}

cout<<a[h-1][w-1]<<endl;

}

Measured memory_bytes: 9088
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n;
	int[] pow;
	String[] names;
	HashSet<String>[] sets;

	@SuppressWarnings("unchecked")
	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			names=new String[n];
			pow=new int[n];
			sets=new HashSet[n];
			for(int j=0; j<n; j++){
				names[j]=sc.next();
				pow[j]=sc.nextInt();
				sets[j]=new HashSet<String>();
				int m=sc.nextInt();
				for(int i=0; i<m; i++){
					sets[j].add(sc.next());
				}
			}
			solve();
		}
	}

	long[] g;
	int[] _;
	int ans;

	void solve(){
		HashMap<String, Integer> map=new HashMap<String, Integer>();
		for(int i=0; i<n; i++){
			map.put(names[i], i);
		}
		g=new long[n];
		for(int i=0; i<n; i++){
			for(String s : sets[i]){
				int j=map.get(s);
				g[i]|=1L<<j;
			}
		}
		// _:順番->ID
		_=new int[n];
		for(int i=0; i<n; i++){
			_[i]=i;
		}
		for(int j=0; j<n; j++){
			for(int i=j+1; i<n; i++){
				if(Long.bitCount(g[_[i]])>Long.bitCount(g[_[j]])){
					int t=_[i];
					_[i]=_[j];
					_[j]=t;
				}
			}
		}

		ans=0;
		// mis(1, 1, pow[0]);
		mis_(0, 1, pow[0]);
		println(ans+"");
	}

	void mis_(int k, long choosed, int sum){
		if(k==n){
			ans=max(ans, sum);
			return;
		}
		if((choosed&(g[_[k]]|(1L<<_[k])))==0){
			mis_(k+1, choosed|(1L<<_[k]), sum+pow[_[k]]);
			long rem=0;
			for(int i=k+1; i<n; i++){
				if((choosed&g[_[i]])==0)
					rem|=g[_[i]];
			}
			if((rem>>>_[k]&1)==0){
				return;
			}
		}
		mis_(k+1, choosed, sum);
	}

	void mis(int k, long choosed, int sum){
		if(k==n){
			// String c=Long.toBinaryString(choosed);
			// for(; c.length()<n; c="0"+c);
			// debug(c, sum);
			ans=max(ans, sum);
			return;
		}
		if((choosed&(g[k]|(1L<<k)))==0){
			mis(k+1, choosed|(1L<<k), sum+pow[k]);
			long rem=0;
			for(int i=k+1; i<n; i++){
				if((choosed&g[i])==0)
					rem|=g[i];
			}
			if((rem>>>k&1)==0){
				return;
			}
		}
		mis(k+1, choosed, sum);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int a, n;

int main()
{
    cin >> n >> a;
    cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1005;

int dr[] = {0, 1, 0, -1};
int dc[] = {1, 0, -1, 0};

int R, C, R0, C0, R1, C1;
char denah[MAXN][MAXN];
int dist[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> R >> C;
    cin >> R0 >> C0;
    cin >> R1 >> C1;
    R0--; C0--; R1--; C1--;
    
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> denah[i][j];
        }
    }
    
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            dist[i][j] = INF;
        }
    }
    
    deque<ii> q;
    dist[R0][C0] = 0;
    q.push_back({R0, C0});
    while (!q.empty()) {
        ii now = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            int nr = now.a + dr[i];
            int nc = now.b + dc[i];
            if (0 <= nr && nr < R && 0 <= nc && nc < C &&
                    denah[nr][nc] == '.' && dist[nr][nc] > dist[now.a][now.b]) {
                dist[nr][nc] = dist[now.a][now.b];
                q.push_front({nr, nc});
            }
        }
        
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nr = now.a + i;
                int nc = now.b + j;
                if (0 <= nr && nr < R && 0 <= nc && nc < C &&
                        denah[nr][nc] == '.' && dist[nr][nc] > dist[now.a][now.b]+1) {
                    dist[nr][nc] = dist[now.a][now.b] + 1;
                    q.push_back({nr, nc});
                }
            }
        }
    }
        
    int ans = dist[R1][C1] == INF? -1: dist[R1][C1];
    cout << ans << "\n";
    
}


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

int A,B,C,X,Y;
long long ans=1000000000;

int main(){
    cin>>A>>B>>C>>X>>Y;

    for (int i = 0; i <= 200000; i+=2)
    {
        long long a = max(0,X-i/2);
        long long b = max(0,Y-i/2);

        ans = min(ans, A*a + B*b + C*i);
    }
    cout << ans << endl;

    return 0;
}


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

signed main(void)
{
	int s, w;
	cin >> s >> w;
	if (w >= s)
	cout << "unsafe" << endl;
	else
	cout << "safe" << endl; 
	return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
su = dict()
sd = dict()
for i in range(n):
    if a[i] + i + 1 in su:
        su[a[i] + i + 1] += 1
    else:
        su[a[i] + i + 1] = 1
    if a[i] - i - 1 in sd:
        sd[a[i] - i - 1] += 1
    else:
        sd[a[i] - i - 1] = 1
fsu = []
for d in su:
    fsu.append([d, su[d]])
fsu.sort()
fsd = []
for d in sd:
    fsd.append([d, sd[d]])
fsd.sort()
s = 0
i1 = len(fsu) - 1
j1 = 0
#print(fsu)
#print(fsd)
while (i1 >= 0 and j1 <= len(fsd)-1):
    if (fsu[i1][0] + fsd[j1][0] == 0):
                s+=fsu[i1][1] * fsd[j1][1]
                i1-=1
    elif (fsu[i1][0] + fsd[j1][0] > 0):
                i1-=1
    elif (fsu[i1][0] + fsd[j1][0] < 0):
                j1+=1

print(s)


Measured memory_bytes: 82324
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
char tab[51][51];
int H,W;
bool Possible(int x,int y)
{
    if(tab[x][y]=='#')return false;
    if(x<1 || y<1)return false;
    if(x>W || y>H)return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    int Min[51][51];
    bool visited[51][51];
    int counter=0;
    cin>>H>>W;
    queue<pair<int,int> > kolejka;
    for(int i=1; i<=H; i++)
    {
        for(int j=1; j<=W; j++)
        {
            cin>>tab[j][i];
            if(tab[j][i]=='#')counter++;
            Min[j][i]=visited[j][i]=0;
        }
    }
    Min[1][1]=visited[1][1]=1;
    int x,y;
    kolejka.push(make_pair(1,1));
    while(!kolejka.empty())
    {
        x=kolejka.front().first;
        y=kolejka.front().second;
        if(x==W && y==H)break;
        kolejka.pop();
        if(Possible(x-1,y) && visited[x-1][y]==false)
        {
            Min[x-1][y]=Min[x][y]+1;
            kolejka.push(make_pair(x-1,y));
            visited[x-1][y]=true;
        }
        if(Possible(x,y-1) && visited[x][y-1]==false)
        {
            Min[x][y-1]=Min[x][y]+1;
            kolejka.push(make_pair(x,y-1));
            visited[x][y-1]=true;
        }
        if(Possible(x+1,y) && visited[x+1][y]==false)
        {
            Min[x+1][y]=Min[x][y]+1;
            kolejka.push(make_pair(x+1,y));
            visited[x+1][y]=true;
        }
        if(Possible(x,y+1) && visited[x][y+1]==false)
        {
            Min[x][y+1]=Min[x][y]+1;
            kolejka.push(make_pair(x,y+1));
            visited[x][y+1]=true;
        }
    }
    if(Min[W][H]==0){cout<<-1<<endl;return 0;}
    cout<<H*W-counter-Min[W][H]<<endl;
}


Measured memory_bytes: 256
N, X, Y = [int(x) for x in input().split()]
P = Y - X + 1
limit = (P + 1) // 2
L = X - 1
R = N - Y
for k in range(1, N):
  ans = 0
  if limit > k:
    ans += P
  elif limit == k:
    if P % 2 == 0:
      ans += P // 2
  for i in range(1, X):
    t = k - (X - i)
    if t <= 0:
      ans += 1
    elif t < limit:
      ans += 2
    elif t == limit:
      if P % 2 == 0:
        ans += 1
    if t - 1 > 0 and t - 1 <= R:
      ans += 1
  for i in range(N, Y, -1):
    if k - (i - Y) <= 0:
      ans += 1
    elif k - (i - Y) < limit:
      ans += 2
    elif k - (i - Y) == limit:
      if P % 2 == 0:
        ans += 1
  print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  cout << (s[0] == '+' ? 1 : -1)
   + (s[1] == '+' ? 1 : -1)
   + (s[2] == '+' ? 1 : -1)
   + (s[3] == '+' ? 1 : -1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n;cin>>n;
    vlli count(n,0);
    flli(i,1,n-1)
    {
    	for(lli j=i;j<n;j+=i)
    	{
    		count[j]++;
    	}
    }
    lli ans=0;
    flli(c,1,n-1)
    {
    	lli ab=n-c;
    	ans+=count[ab];
    }
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 11024
n = int(input())
dic = {'M':set(),'A':set(),'R':set(),'C':set(),'H':set()}
for i in range(n):
    s = input()
    if s[0] in dic.keys():
        dic[s[0]].add(s)

ans = 0

M = len(dic['M'])
A = len(dic['A'])
R = len(dic['R'])
C = len(dic['C'])
H = len(dic['H'])

memo =[[M, A, R],[M, A ,C],[M, A, H],[M, R, C],[M, R, H],[M, C, H],[A, R, C],[A, R, H],[A,C,H],[R, C, H]]
for i in memo:
    ans += (i[0]*i[1]*i[2])
    
    
print(ans)


Measured memory_bytes: 14316
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();
    let x: u32 = read();

    let mut ans = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500 * i + 100 * j + 50 * k == x {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c=0, d=0, e, f, g, n;
  string s, k, t={};
  cin >> n;
  int x[n];
  rep(i,0,n) cin >> x[i];
  rep(i,0,n){
    if(x[i]==c+1){
      d++;
      c++;
    }
  }
  
  if(c==0) co(-1);
  else co(n-c);
  
  
  return 0;
}

Measured memory_bytes: 1024
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  void solve() {
    int x;
    cin >> x;

    ll l = 0, r = 1e5;
    while (r > l + 1) {
      ll m = (l + r) / 2;
      if (m * (m + 1) / 2 >= x) {
        r = m;
      } else {
        l = m;
      }
    }
    cout << r << "\n";
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    for(int& elem : H)
        cin >> elem;
    sort(H.begin(),H.end());
    for (int i=0; i<K && H.size()>0; i++){
        H.pop_back();
    }
    long sum = 0;
    for (int elem : H)
        sum+=elem;
    cout << sum;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * ((n+x-1)/x) << endl;
}   

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int a,b;cin>>a>>b;
    if(a>b)cout<<a-1<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 256
require 'pp'

class Fractional
    attr_reader :mod

    def initialize(max, mod)
        @max = max
        @mod = mod
        @frac     = { 0 => 1, 1 => 1 }
        @frac_inv = { 0 => 1, 1 => 1 }
        @inv      = {         1 => 1 }

        pre_calc(max)
    end

    def pre_calc(max)
        2.upto(max) do |i|
            @frac[i] = @frac[i - 1] * i % @mod;
            @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
            @frac_inv[i] = @frac_inv[i - 1] * @inv[i] % @mod
        end
    end

    def at(i)
        @frac[i]
    end

    def inv_at(i)
        @frac_inv[i]
    end
end

class Combination
    def initialize(fraction)
        @fraction = fraction
    end

    def calc(n, r)
        return 0 if n < r
        return 0 if (n < 0 || r < 0)

        denom_inv = (@fraction.inv_at(r) * @fraction.inv_at(n - r) % @fraction.mod)
        return @fraction.at(n) * denom_inv % @fraction.mod
    end
end

MOD = 10 ** 9 + 7
frac = Fractional.new(10 ** 5 + 1, MOD)
comb = Combination.new(frac)

n, k  = gets.chomp!.split.map(&:to_i)
a_n  = gets.chomp!.split.map(&:to_i).sort!

j = 1
sum = 0
(n - 1).downto(k - 1) do |i|
    x = comb.calc(i, k - 1)

    sum = (sum + x * (a_n[-j] - a_n[j-1])) % MOD

    j += 1
end

puts sum


Measured memory_bytes: 29236
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, x, y; cin >> n >> x >> y;
  const ll MAX = 2*1000;
  ll ans[MAX + 1] = {};

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

  for (int i = 1; i < n; i++) outl(ans[i]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main(){

  ll N, all=1,MOD=1e9+7,zn=1, e=1;
  cin >> N;

  rep(i,N){
    all*=10;
    zn*=9;
    e*=8;
    all%=MOD;
    zn%=MOD;
    e%=MOD;
  }

  ll ans = all - 2*zn + e;
  while(ans<0){
    ans+=MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3672
import Control.Applicative

toInt ::String -> Int
toInt x=read x :: Int

isInner :: (Int,Int,Int,Int,Int) -> Bool
isInner (w,h,x,y,r) = r<=x && x<=(w-r) && r<=y && y<= (h-r)

main :: IO()
main = do
    [w,h,x,y,r] <- map toInt <$> words <$> getLine
    putStrLn (if (isInner (w,h,x,y,r)) then "Yes" else "No")


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

using namespace std;

typedef long long int ll;

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

  ll n;
  cin >> n;
  vector < ll > v;
  for(int i = 0; i < 20; i++) v.push_back(2 * i + 1);
  string s;
  for(int i = 0; i < 40; i++) s += '0';

  for(ll i = 0; i < ((ll)1 << 20); i++){
    int tmp = n;
    string res = s;
    for(int j = 0; j < 20; j++){
      if((i >> j) & 1){
        tmp += (1 << v[j]);
        res[v[j]] = '1';
      }
    }
    if(tmp < 0) continue;
    for(int bt = 38; bt >= 0; bt -= 2){
      if(tmp >= ((ll)1 << bt)){
        tmp -= ((ll)1 << bt);
        res[bt] = '1';
      }
    }

    if(tmp == 0){
      reverse(res.begin(), res.end());
      int k = 39;
      for(int j = 0; j < 40; j++){
        if(res[j] == '1'){
          k = j;
          break;
        }
      }
      for(int j = k; j < 40; j++) cout << res[j];
      cout << '\n';
      return 0;
    }
  }
}


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

int main() {
int x,y;
cin >> x >> y;
int min = x*2;
int max = x*4;
if(y>=min && y<=max && y%2 == 0){
	cout << "Yes" << endl;
} else {
	cout << "No" << endl;
}
return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int n, m;
	while (cin >> n >> m && n || m){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (i == 0 || i == n - 1)cout << '#';
				else if (j == 0 || j == m - 1)cout << '#';
				else cout << '.';
			}
			cout << endl;
		}cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import math

nums = list(map(int, input().split(" ")))

a = nums[0]
b = nums[1]
x = nums[2]

bottle = a * a * b

if bottle / 2.0 < x:
    temp = bottle - x
    y = temp * 2 / a / a
    result = math.degrees(math.atan(y/a))
else:
    y = x * 2 / b / a
    result = math.degrees(math.atan(b/y))

print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), h(n);
    rep(i, 0, n) cin >> x[i] >> y[i] >> h[i];
    ll cx, cy;
    rep(cx, 0, 101){
        rep(cy, 0, 101){
            bool flag = false;
            ll H = -1;
            rep(i, 0, n){
                ll tH = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                if(h[i] != 0){
                    if(H != -1){
                        if(tH != H){
                            flag = true;
                            break;
                        }
                    }else{
                        H = tH;
                    }
                }
            }
            if(flag) continue;
            rep(i, 0, n){
                ll tH = abs(cx - x[i]) + abs(cy - y[i]);
                if(h[i] == 0){
                    if(max(H-tH, 0LL) != 0){
                        flag = true;
                        break;
                    }
                }
            }
            if(!flag){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if (n % 1000 == 0)
    cout << 0 << endl;
  else
    cout << 1000 - n % 1000 << endl;
}

Measured memory_bytes: 3624
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()

students = []
for i in range(N):
    students.append(nl())

points = []
for i in range(M):
    points.append(nl())

for student in students:
    min_dist = 300000000
    min_i = M
    for i in range(M):
        dist = abs(points[i][0] - student[0]) + abs(points[i][1] - student[1])
        if dist < min_dist:
            min_dist = dist
            min_i = i
    print(min_i+1)


Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int h,w,i,j;
  while(1){
    scanf("%d%d",&h,&w);
    if(h==0 && w==0)
      break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)
    printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
# -*- coding: utf-8 -*-
import sys
H, W = map(int, input().split(' '));

board = []
flags = [ True for x in range(W)]
for i in range(H):
    line = list(input())
    if ( '#' in line ):
        board.append(line)
        flags = [ f and s == '.' for s,f in zip(line, flags) ]

j = 0
for b in board:
    for l,flag in zip(b,flags):
        if not flag:
            sys.stdout.write(l)
    print()

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    string S,T;
    cin >> S >> T;

    vector<int> cnts,cntt;
    cnts.resize(S.size());
    cntt.resize(T.size());
    if(S[0]=='A') cnts[0]=1;
    else cnts[0]=2;
    if(T[0]=='A') cntt[0]=1;
    else cntt[0]=2;
    rep(i,1,S.size()){
        cnts[i]=cnts[i-1];
        if(S[i]=='A') ++cnts[i];
        else cnts[i]+=2;
    }
    rep(i,1,T.size()){
        cntt[i]=cntt[i-1];
        if(T[i]=='A') ++cntt[i];
        else cntt[i]+=2;
    }

    int q;
    cin >> q;
    rep(i,0,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        --a;
        --b;
        --c;
        --d;

        int x=cnts[b],y=cntt[d];
        if(a>0) x-=cnts[a-1];
        if(c>0) y-=cntt[c-1];
        if(x%3==y%3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1744
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
signed main(){
	
    int n;
    string s;
    cin>>n>>s;
    rep(i,n-1){
        if(s[i]!=s[i+1])ans++;
    }
    ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
// https://atcoder.jp/contests/abc154/tasks/abc154_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        cout << a - 1 << " " << b << "\n";
    } else {
        cout << a << " " << b - 1 << "\n";
    }

    return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = new List<List<int>>();

            for (int i = 0; i < 3; i++)
            {
                c.Add(Console.ReadLine().Split().Select(int.Parse).ToList());
            }

            foreach (var item in c) item.Add(item.First());
            c.Add(c.First());

            var isAnableA = true;
            var isAnableB = true;

            for (int i = 0; i < 3; i++)
            {
                var dist = c[i][0] - c[i + 1][0];
                var distCheck = true;
                for (int j = 0; j < 3; j++)
                {
                    distCheck &= ((c[i][j] - c[i + 1][j]) == dist);
                }
                isAnableA &= distCheck;
            }

            for (int i = 0; i < 3; i++)
            {
                var dist = c[0][i] - c[0][i + 1];
                var distCheck = true;
                for (int j = 0; j < 3; j++)
                {
                    distCheck &= ((c[j][i] - c[j][i+1]) == dist);
                }
                isAnableB &= distCheck;
            }

            var ans = isAnableA && isAnableB;

            Console.WriteLine(ans?"Yes":"No");
        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<49;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define V 110
struct edge{ll to, cap, rev;};
vector<edge> G[V];
bool used[V];

void add_edge(ll from, ll to, ll cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
	//G[to].push_back((edge){from, cap, G[from].size()-1});
}

ll dfs(ll v, ll t, ll f){
	if(v==t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			ll d = dfs(e.to, t, min(f, e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(ll s, ll t){
	ll flow = 0;
	while(1){
		memset(used, 0, sizeof(used));
		ll f = dfs(s, t, 1e16);
		if(f==0) return flow;
		flow += f;
	}
}

int main(){
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i, n) cin>>a[i];
	int s = n, t = s+1;
	rep(i, n){
		if(a[i]<0) add_edge(s, i, -a[i]);
		else add_edge(i, t, a[i]);
	}
	rep(i, n) for(int j = 2*(i+1); j <= n; j+=i+1) add_edge(i, j-1, 1e11);
	ll res = 0;
	rep(i, n) res += max(0LL, a[i]);
	res -= max_flow(s, t);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256