akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    std::vector<bool> okay(N, false);
    {
        int d1, d2;
        for(int i(0); i < N; ++i){
            std::cin >> d1 >> d2;
            if(d1 == d2) okay[i] = true;
        }
    }
    for(int i(1), i_len(N-1); i < i_len; ++i){
        if(okay[i-1] && okay[i] && okay[i+1]){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	a=max(m-n+1,-1000000);
	b=min(m+n-1,1000000);
	for (int i=a;i<=b;++i) cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))


def down(H, l, r):
    for i in range(l, r):
        H[i] -= 1


s = 0
for h in range(100):
    # LとRを求める
    l = 0
    while l < N:
        if H[l]:
            for j in range(l+1, N):
                if H[j] == 0:
                    r = j
                    break
            else:
                r = N
            down(H, l, r)
            s += 1
            l = r+1
        else:
            l += 1
print(s)


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

int main(){
    int N; cin>>N;
    if(N/100==N%10)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}





Measured memory_bytes: 256
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});
process.stdin.on('end', () => {
  let exprs = content
    .trim()
    .split('\n')
    .map(line => parseExpr(line));
  for (const expr of exprs) {
    const [a, op, b] = expr;
    switch (op) {
      case '+':
        console.log(a + b);
        break;
      case '-':
        console.log(a - b);
        break;
      case '*':
        console.log(a * b);
        break;
      case '/':
        console.log(Math.floor(a / b));
        break;
    }
  }
});

const parseExpr = expr => {
  const [a, op, b] = expr.split(' ');
  return [parseInt(a, 10), op, parseInt(b, op)];
};


Measured memory_bytes: 16080
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <sstream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define maxn 100005
int s[200005];
int main()
{
	int ans=0,a,b;
	cin >> a >> b;
	for (int i=1;i<=a;i++)
	{
		cin >> s[i];
	}
	for (int i=b+1;i<=a;i++)
	{
		if (s[i] <= s[i-b])
		{
			cout << "No" << endl;
		}
		else cout << "Yes" << endl;
	}
}


Measured memory_bytes: 4420
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
a.reverse()

f=True
t=0
c=0
for i in a:
  if i==t:
    t-=1
  elif i<t:
    f=False
    break
  else:
    t=i-1
    c+=i
if t!=-1:
  f=False
print(c if f else -1)

Measured memory_bytes: 88072
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e5+100;
const ll bits = 21;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

ll bit[N],a[N],h[N];

ll get(ll index){
    ll sum = 0;
    index = index + 1; 
    while (index>0) 
    {
        sum = max(bit[index],sum);
        index -= index & (-index); 
    } 
    return sum;
}

void upd(ll index, ll val) 
{  
    index = index + 1; 
    while (index < N) 
    {
    bit[index] = max(bit[index],val);
    index += index & (-index); 
    } 
}

int main(){
    FASTIO;
    PRECISION;

    ll n;
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>h[i];
    }

    for(int i=1;i<=n;i++){
        cin>>a[i];
    }

    ll res = 0;

    for(int i=1;i<=n;i++){
        ll ans = get(h[i]-1);
        ans+=a[i];
        res = max(res,ans);
        upd(h[i],ans);
    }

    cout<<res<<"\n";
    

}

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

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

#define INF 2e9
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=0;
    while(a>0 && c>0){
        if(i%2==0){
            c-=b;
        }
        else{
            a-=d;
        }
        i++;
    }
    if(i%2==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long dp[200100];

int main(){
    string S;
    cin >> S;

    int ans = 9999;
    int x =0;

    rep(i,S.length()-2){
           int a = S[i]-'0';
           int b = S[i+1]-'0';
           int c = S[i+2]-'0'; 

           x = 100*a + 10*b +c;
           ans = min(abs(753-x),ans);
    }

    cout << ans << endl;

}



Measured memory_bytes: 3568
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();

        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            uf.unite(in.i() - 1, in.i() - 1);
        }
        System.out.println(uf.ncc - 1);
    }
}

class UnionFind {
    private final int N;
    int[] parent;
    int ncc;

    UnionFind(int n) {
        N = n;
        parent = new int[N];
        Arrays.setAll(parent, i -> i);
        ncc = n;
    }

    boolean isRoot(int x) {
        return x == parent[x];
    }

    int root(int x) {
        while (!isRoot(x)) {
            x = parent[x] = root(parent[x]);
        }
        return x;
    }

    boolean same(int x, int y){
        return root(x) == root(y);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y) {
            parent[x] = y;
            ncc--;
        }
    }

    int ncc() {
        return ncc;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 36256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,a,b,c,count;
  count = 0;
  cin >> N;
  vector<int> L(N+1);
  for(int i = 0;i < N;i++){
    cin >> L.at(i);
  }
  L.at(N) = 0;
  for(int i = 0;i < N*2;i++){
    for(int j = 0;j < N;j++){
      if (L.at(j) > L.at(j+1)){
        a = L.at(j);
        L.at(j) = L.at(j + 1);
        L.at(j+1) = a;
      }
    }
  }
  for(int i = 1;i < N-1;i++){
    a = L.at(i);
    for(int j = i+1;j < N;j++){
      b = L.at(j);
      if (a == b){
        continue;
      }
      for(int k = j+1;k < N+1;k++){
        c = L.at(k);
        if (a == c){
          continue;
        }
        else if(b == c){
          continue;
        }
        else if(b+c > a and a+b > c and a+c > b){
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3564
use std::io;
use std::io::prelude::*;

fn main () {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();
    let t: f64 = iter.next().unwrap().parse().unwrap();
    let x: f64 = iter.next().unwrap().parse().unwrap();
    println!("{}", t / x);
}


Measured memory_bytes: 4352
from collections import Counter

def CHK():
    N = int(input())
    A = list(map(int,input().split()))
    L=[]
    R=[]
    cnt = 0
    for i in range(N):
        L.append(i + A[i])
    L_Cnt=Counter(L)

    for i in range(N):
        chk = i -A[i]
        cnt += L_Cnt[chk]
    print(cnt)

CHK()


Measured memory_bytes: 42788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
	int a,b,c;
  	cin>>a>>b>>c;
  
  	int k;
  	cin>>k;
  
	int cnt=0;
  
  while(a>=b){
  	cnt++;
    b*=2;
  }
  
  while(b>=c){
  	cnt++;
    c*=2;
  }
  
  if(cnt<=k){
  	cout<<"Yes"<<endl;
  }
  
  else{
  	cout<<"No"<<endl;
  }
  
 
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int l;
  while(cin >> l && l){
    int a=0;
    for(int i = 1; i <= 12; i++){
      int n,m;
      cin >> n >> m;
      if(!a) l -= n-m;
      if(!a && l <=0) a = i;
    }
    if(l > 0) cout << "NA" << endl;
    else cout << a << endl;
  }
}

Measured memory_bytes: 1160
def main():
    a_lst = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b_lst = [int(input()) for _ in range(n)]
    appear = [[False for _ in range(3)] for _ in range(3)]
    is_bingo = False

    for b in b_lst:
        for r in range(3):
            for c in range(3):
                if a_lst[r][c] == b:
                    appear[r][c] = True

    for r in range(3):
        if appear[r][0] == True and appear[r][1] == True and appear[r][2] == True:
            is_bingo = True

    for c in range(3):
        if appear[0][c] == True and appear[1][c] == True and appear[2][c] == True:
            is_bingo = True

    if appear[0][0] == True and appear[1][1] == True and appear[2][2] == True:
        is_bingo = True

    if appear[0][2] == True and appear[1][1] == True and appear[2][0] == True:
        is_bingo = True

    if is_bingo:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int n;
	int a, max = -1000001, min = 1000001;
	long int sum = 0;
	cin >> n;
	for (int i = 1;i<=n;i++){
		cin >> a;
		sum = sum + a;
		if (max < a)max = a;
		if (min > a)min = a;
	}
	cout << min <<" " << max << " " << sum << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
const int MOD=998244353;
int W[1000001], sum[1000001], res[1000000];
 
long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0;
	cin>>N;
	for(int i=1;i<=1000000;i++) {
		W[i]=(W[i]+fast_pow(i,MOD-2))%MOD;
		for(int j=2*i;j<=1000000;j+=i) W[j]=(W[j]+MOD-W[i])%MOD;
	}
	while(N--) {
		int a;
		cin>>a;
		res[a]=(res[a]+1LL*sum[a]*a)%MOD;
		sum[a]=(sum[a]+a)%MOD;
	}
	for(int i=1;i<=1000000;i++) {
		for(int j=2*i;j<=1000000;j+=i) {
			res[i]=(res[i]+res[j]+1LL*sum[i]*sum[j])%MOD;
			sum[i]=(sum[i]+sum[j])%MOD;
		}
		ans=(ans+1LL*W[i]*res[i])%MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

int main() {
    int _n, _m;
    cin >> _n >> _m;
    int n = min(_n, _m);
    int m = max(_n, _m);

    if (n == 1) {
        if (m == 1) {
            cout << 1 << endl;
        } else {
            cout << m - 2 << endl;
        }
    } else {
        cout << (ll)(n - 2) * (m - 2) << endl;
    }

    return 0;
}


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

int main()
{
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int count = 0;
    for(int i=0;i<n;i++)
    {
        if(s[i] != t[i])
        {
            count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(i,n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int dp[100001][3];
int n;

int maxi(int a,int b,int c){
	int d=max(a,b);
	return max(d,c);
}

int main(){
	cin >> n;
	int arr[n][3];
	FOR(i,n){
		FOR(j,3){
			cin >> arr[i][j];
			//cout << arr[i][j];
		}
	}
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i(0);i<n;++i){
		FOR(j,3){
			FOR(k,3){
			 	if((i+1)<n && j!=k){
					dp[i+1][k]=max(dp[i+1][k],dp[i][j]+arr[i+1][k]);
				}
			}
		}
	}
/*	FOR(i,n){
		FOR(j,3){
			cout << dp[i][j] << '\n';
		}
	}*/

	cout << maxi(dp[n-1][0],dp[n-1][1],dp[n-1][2]);

}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
import sys
c = list()
for i in range(3):
    c.append(list(map(int, input().split())))

a = [0] * 3
b = [0] * 3

for i in range(3):
    b[i] = c[0][i] - a[0]

a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print("No")
            sys.exit()

print("Yes")


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

S=input()
C=collections.Counter(S)
C["a"]=C["a"] 
C["b"]=C["b"] 
C["c"]=C["c"] 
print("YES" if max(C.values())-min(C.values()) <= 1 else "NO")
# print(C)

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

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i=0; i<N; i++) {
        char c; cin >> c;
        if(c == 'E') D[i] = 1;
        else D[i] = 0;
    }
    vector<int> A(N);
    vector<int> B(N);
    A[0] = (D[0] == 0);
    for(int i=1; i<N; i++) {
        A[i] = A[i-1];
        A[i] += (D[i] == 0);
    }
    B[N-1] = (D[N-1] == 1);
    for(int i=N-2; i>=0; i--) {
        B[i] = B[i+1];
        B[i] += (D[i] == 1);
    }
    
    int ans = B[1];
    for(int i=1; i<N-1; i++) {
        ans = min(ans, A[i-1] + B[i+1]);
    }
    ans = min(ans, A[N-2]);
    cout << ans << endl;
}

Measured memory_bytes: 3712
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();

    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let n: i32 = vec[0].parse().unwrap_or(0);
    let m: i32 = vec[1].parse().unwrap_or(0);

    println!("{}", n+m/2);
}


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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

int main() {
	int r; cin >> r;
	cout << r*r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <assert.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a;
  map<int, int> checkMap;
  a.resize(n);
  int v;
  for (int i=0; i<n; i++) {
    cin >> v;
    a[i] = v;
    if (checkMap.find(v) == checkMap.end()) {
      checkMap.insert(make_pair(v, 1));
    } else {
      checkMap[v] += 1;
    }
  }

  int var = (int)checkMap.size();
  long long int allcomb = 0;
  for (auto it = checkMap.begin(); it != checkMap.end(); it++) {
    long long int num = it->second;
    if (num >= 2) {
      allcomb += num * (num-1) / 2;
    }
  }
    
    
  for (int i=0; i<n; i++) {
    int numai = checkMap[a[i]];
    if (numai == 1) {
      cout << allcomb  << endl;
    } else if (numai > 1)  {
      long long int origin = numai * (numai-1) / 2;
      long long int sub = (numai-1) * (numai-2) / 2;	
      cout << allcomb - origin + sub << endl;
    } else {
      assert(false);
    }
  }

  return 0;
}
    
  


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using type = pair<int, int>;
using event = pair<int, type>;

int main() {
    int N, Q;
    vector<event> data;
    vector<int> res;
    multiset<int> pos;
    
    cin >> N >> Q;
    res.resize(Q);
    for (int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        data.push_back({s-x, type(-1, x)});
        data.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; i++) {
        int d;
        cin >> d;
        data.push_back({d, type(1, i)});
    }
    
    sort(data.begin(), data.end());
    
    for (auto d : data) {
        int c, x; tie(c, x) = d.second;
        if (c == 1) res[x] = (pos.empty() ? -1 : *(pos.begin()));
        else if (c == -1) pos.insert(x);
        else pos.erase(pos.lower_bound(x));
    }
    
    for (auto ans : res) cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19048
from collections import defaultdict
import decimal
import sys
input = sys.stdin.readline


def prime_factor_count(n):
    def count(n, i):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        return n, cnt

    d = {}
    if n == 1:
        return d

    n, cnt = count(n, 2)
    d[2] = cnt

    lst = [2]
    for num in range(3, int(n ** 0.5) + 1, 2):
        if n == 1:
            break
        for p_num in lst:
            if num % p_num == 0:
                break
            elif p_num * p_num > num:
                lst.append(num)
                n, cnt = count(n, num)
                d[num] = cnt
                break
    else:
        if n != 1:
            d[n] = 1
    return d



def main():
    n = int(input())
    d = prime_factor_count(n)

    cnt = 0
    tmp_n = 0
    for k, v in d.items():
        exp_cnt = 1
        while 1:
            if exp_cnt > v:
                break
            else:
                if tmp_n % (tmp_exp := k ** exp_cnt) == 0:
                    tmp_n //= tmp_exp
                    cnt += 1
                    v -= exp_cnt
                    exp_cnt += 1
    else:
        if n == tmp_n:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15520
import math
a, b, c = map(float, input().split())
r = math.radians(c)
S = (a * b * math.sin(r)) / 2
print(S)
d = (a**2 + b**2 - 2 * a * b * math.cos(r))
d = math.sqrt(d)
L = a + b + d
print(L)
h = 2 * S / a
print(h)

Measured memory_bytes: 7696
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,dist[1010][1010],ans;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s[1010];
queue <pair <pii,int> > q;

bool out(int x,int y)
{
	return x<0||y<0||x>=n||y>=m;
}

int main()
{
	cin>>n>>m;
	rep(i,n)
	{
		cin>>s[i];
		rep(j,m) if(s[i][j]=='#') q.push({{i,j},0});
	}
	while(!q.empty())
	{
		int x=q.front().fi.fi,y=q.front().fi.se,val=q.front().se;
		q.pop();
		rep(i,4)
		{
			int xx=x+dx[i],yy=y+dy[i];
			if(out(xx,yy)) continue;
			if(s[xx][yy]=='#') continue;
			if(dist[xx][yy]!=0) continue;
			dist[xx][yy]=val+1;
			ans=max(ans,val+1);
			q.push({{xx,yy},val+1});
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 13456
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 
	
	int n, m;
	cin >> n >> m;
	vector< vector<int> > a(n, vector<int>(m, 0));
	for(int i= 0; i < n ; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k ;j++){
			int temp;
			cin >> temp;
			a[i][temp-1] = 1;
		}
	}	

	int count = 0;
	for(int i = 0; i < m; i++){
		int flag = 1;
		for(int j = 0; j < n; j++){
			if(a[j][i] == 0){
				flag = 0;
				break;
			}
		}
		count += flag;
	}

	cout << count ;
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll calc_gcd(ll a, ll b){
    ll  r, tmp;

    //大小入れ替え
    if( a < b ){
        tmp = a;
        a = b;
        b = tmp;
    }

    //ユークリッドの互除法
    r = a % b;
    while( r ){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    int k,sum=0;
    scanf("%d",&k);

    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                sum += calc_gcd( a, calc_gcd(b,c) );
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

string A, B, C;

int main() {
	while(cin >> A, A != "0") {
		cin >> B >> C;

		reverse(A.begin(), A.end());
		reverse(B.begin(), B.end());
		reverse(C.begin(), C.end());

		int n = B.size();

		ll dp[55][2] = { 0 };

		dp[0][0] = 1;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 2; j++) {
				int q = 0, s = 0, t = 0;
				if(A[i] == '?') q++;
				else s += A[i] - '0';
				if(B[i] == '?') q++;
				else s += B[i] - '0';
				if(C[i] != '0') t = C[i] - '0';

				if(q == 2) {
					for(int a = 0; a <= 9; a++) {
						for(int b = 0; b <= 9; b++) {
							if(i == n - 1 && (a == 0 || b == 0)) continue;
							if(i == n - 1 && ((a + b + j) % 10 == 0)) continue;
							if((C[i] == '?' || (a + b + j) % 10 == t)) {
								int nj = a + b + j >= 10;
								(dp[i + 1][nj] += dp[i][j]) %= MOD;
							}
						}
					}
				}
				else if(q == 1) {
					for(int a = 0; a <= 9; a++) {
						if(i == n - 1 && a == 0) continue;
						if((i == n - 1 && (s + a + j) % 10 == 0)) continue;
						if(C[i] == '?' || (s + a + j) % 10 == t) {
							int nj = s + a + j >= 10;
							(dp[i + 1][nj] += dp[i][j]) %= MOD;
						}
					}
				}
				else { // q == 0
					if((i == n - 1 && (s + j) % 10 == 0)) continue;
					if(C[i] == '?' || (s + j) % 10 == t) {
						int nj = (s + j) >= 10;
						(dp[i + 1][nj] += dp[i][j]) %= MOD;
					}
				}
			}// for j
		}// for i
		cout << dp[n][0] << endl;
	}// while
}// main

Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007


int main(){

    vector<int> a(10),b(10);
    
    REP(i,10){
        cin >> a[i];
    }

    REP(i,10){
        cin >> b[i];
    }

    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end(),greater<int>());
    
    int a_sum = 0,b_sum = 0;
    REP(i,3){
        a_sum += a[i];
        b_sum += b[i];
    }
    cout << a_sum << " " << b_sum << endl;


    return 0;
}




Measured memory_bytes: 3144
# include "cstdio"
# include "iostream"
# include "map"

using namespace std;

int n;
string a,b;
map <string,bool> L;

int main(){
	register int t;
	scanf("%d",&n);
	cin>>a;
	L[a]=true;
	for(t=1;t<n;t++){
		cin>>b;
		if(a[a.size()-1]!=b[0] || L[b]){
			printf("No");
			return 0;
		}else{
			a=b;
		}
		L[b]=true;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int a, b, c;
    ll k;
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    if(k % 2 == 0) {
        cout << a - b;
    }
    else {
        cout << b - a;
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
// 2011/09/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, k;
		cin >> n >> k;
		if(n==0&&k==0)
			break;

		int C[100003] = {0};
		for(int i=0; i<k; i++){
			int c;
			cin >> c;
			C[c] = 1;
		}

		int max = 1;

		if(C[0]==0){
			int sum = 0;
			for(int i=1; i<=n+1; i++)
				if(C[i]==1)
					sum++;
				else{
					if(max<sum)
						max = sum;
					sum = 0;
				}
			cout << max << endl;
			continue;
		}

		if(C[0]==1){
			int sum = 0;
			int sum2 = 0;
			for(int i=1; i<=n+2; i++)
				if(C[i]==1){
					sum++;
					sum2++;
				}
				else{
					if(max<sum2)
						max = sum2;
					sum2 = sum;
					sum2++;
					sum = 0;
				}
			cout << max << endl;
			continue;
		}
	}

	return 0;
}

Measured memory_bytes: 0
A, B, M = input().split(" ")
M = int(M)
A_list = input().split(" ")
A_list = list(map(int, A_list))
B_list = input().split(" ")
B_list = list(map(int, B_list))
M_min = 99999999
for i in range(M):
    m = input().split(" ")
    m = list(map(int, m))
    if M_min > A_list[m[0]-1]+B_list[m[1]-1]-m[2]:
        M_min = A_list[m[0]-1]+B_list[m[1]-1]-m[2]
AB_min = min(A_list)+min(B_list)
if AB_min < M_min:
    print(AB_min)
else:
    print(M_min)

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  map<int, int> d;
  rep(i, n) {
    int k;
    cin >> k;
    d[k]++;
  }
  int m;
  cin >> m;
  vector<int> t(m);
  rep(i, m) cin >> t[i];

  rep(i, m) {
    if (d[t[i]]-- == 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;



  
  return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//C

int main(void) {
	ll n;
	cin >> n;
	vector<ll> d = vector<ll>(n);
	rep(i, 0, n)cin >> d[i];
	sort(d.begin(), d.end());
	ll abc = d.size() / 2 - 1;
	ll lb = d[abc] + 1;
	ll ub = d[abc + 1];
	cout << ub - lb + 1 << endl;
}


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

const int M = 1e9+7, N = 1e6+7;
int a[N], mx[N];

LL power(LL a, LL b, LL m) {
	LL ans = 1;
	while (b) {
		if (b & 1) ans = (ans*a)%m;
		a = (a*a)%m;
		b >>= 1;
	}
	return ans;
}

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

    int n;
    cin>>n;

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

        int x = a[i];
        for (int i=2; i*i<=x; i++) {
            if (x%i)    continue;
            int cnt = 0;
            while (x%i==0)  x/=i, cnt++;
            mx[i] = max(mx[i], cnt);
        }
        if (x > 1)  mx[x] = max(mx[x], 1);
    }

    long long lcm = 1;
    for (int i=1; i<N; i++) {
        if (mx[i] == 0) continue;
        lcm = (lcm * power(i, mx[i], M))%M;
    }
    long long ans = 0;
    for (int i=1; i<=n; i++) {
        ans = (ans + lcm*power(a[i], M-2, M))%M;
    }        
    cout<<ans<<endl;
}

Measured memory_bytes: 4096
def main():
  N, M = (int(_) for _ in input().split())
  if N > 1 and M > 1:
    N = max(0, N-2)
    M = max(0, M-2)
    print(N * M)
  else:
    if N * M == 1:
      print(1)
    else:
      print(max(max(N, M)-2, 0))
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string s="", ss;
    cin>>ss;
    for(int i=0;i<ss.size();i++){
    	if(ss[i]=='0') s+='0';
    	else if(ss[i]=='1') s+='1';
    	else{
    		int len=s.size();
			if(len>0) s.erase(len-1);
		}
	}
	cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
# ABC099C - Strange Bank
# DP ver.
def main():
    n = int(input())
    # initialize dp table with using only ¥1
    dp = [i for i in range(n + 1)]
    cand = (6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049)
    for j in cand:
        for i in range(n + 1):
            if j > n:
                break
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + 1)
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 7064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		int n  = Integer.parseInt(line);

		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0) {
				System.out.print(" " + i);
			} else {
				String s = Integer.toString(i);
				if (s.contains("3")) {
					System.out.print(" " + i);
				}
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 27472
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
long long n, f[100001][5], l=0, r, mid ,a[1000001], b[100001], c[100001];

bool cmp(long long a, long long b){
	return a < b ;
}
int main(){
    scanf("%lld", &n);
    for(int j = 1 ; j <= n; ++j)
        scanf("%lld", &a[j]);
    for(int j = 1 ; j <= n; ++j)
        scanf("%lld", &b[j]);
    for(int j = 1 ; j <= n; ++j)
        scanf("%lld", &c[j]);
    sort(a+1, a+1+n, cmp);
	sort(b+1, b+1+n, cmp);
	sort(c+1, c+1+n, cmp);
	
    for(int j = 1 ; j <= n; ++j){
        f[j][1]=j;
    }
    for(int j = 1 ; j <= n; ++j){
            l = 1, r = n;
            while(l <= r){
                mid = (l+r)/2;
                if(b[j] <= a[mid])
                    r = mid-1;
                else
               		l = mid+1;
            }
            f[j][2] = f[j-1][2]+f[r][1];
    }
    for(int j = 1 ; j <= n; ++j){
            l = 1, r = n;
            while(l <= r){
                mid = (l+r)/2;
                if(c[j] <= b[mid])
                    r = mid-1;
                else
               		l = mid+1;
            }
            f[j][3] = f[j-1][3]+f[r][2];
    }
    printf("%lld", f[n][3]);
    return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



struct Combinations {
  static int num;
  vi fact,factr,inv;

  Combinations(int num) {

    fact.assign(num+1,0);
    factr.assign(num+1,0);
    inv.assign(num+1,0);
    inv[1]=fact[0]=factr[0]=1;
    FOR(i,2,num+1) inv[i]=inv[M%i]*(M-M/i)%M;
    FOR(i,1,num+1) fact[i]=fact[i-1]*i%M,factr[i]=factr[i-1]*inv[i]%M;
  }


  int comb(int n,int c){
    if(c<0||c>n) return 0;
    return factr[c]*fact[n]%M*factr[n-c]%M;
  }

  int per(int n,int c){
    if(c<0||c>n) return 0;
    return fact[n]*factr[n-c]%M;
  }

  int hcomb(int n,int c){
    if(n==0&&c==0) return 1;
    return comb(n+c-1,c);
  }

};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k;
  cin>>n>>k;
  Combinations comb(k);
  cout<<comb.comb(k,n)<<endl;


}


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

int main(){
	int K, sum;
	cin >> K;
	sum = 0;
	for(int a =1;a<=K;a++){
		for(int b =1;b<=K;b++){
			for(int c= 1;c<=K;c++){
				if(a==1 || b==1||c==1){
					sum+=1;
				}else{
					sum+=__gcd(__gcd(a,b),c);
				}
			}
		}
	}
	cout << sum;

}
	
	


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;




int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < to_string(n).size(); i += 2) {
        ans += pow(10, i) - pow(10, i - 1);
    }

    if (to_string(n).size() % 2) {
        ans += n - pow(10, to_string(n).size() - 1) + 1;
    }


    cout << ans;




}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

int a[100010];
int b[100010];
int c[100010];

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> a[i];
    rep(i, N)cin >> b[i];
    rep(i, N)cin >> c[i];

    sort(a, a + N);
    sort(c, c + N);

    ll sum = 0;

    rep(i, N) {
        ll numa = lower_bound(a, a + N, b[i]) - a;
        ll numc = N - (upper_bound(c, c + N, b[i]) - c);
        sum += numa*numc;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}



Measured memory_bytes: 2508
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for n := range h {
		fmt.Scan(&h[n])
	}
	fmt.Println(garden(h))
}

func garden(h []int) int {
	//  全ての山の増加分の和
	var c, p int
	for _, v := range h {
		if p <= v {
			c += v - p
		}
		p = v
	}
	return c
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  long long A[N];
  int p = 1; // parity
  bool flag = false;

  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] < 0){
      p *= -1;
    }
    else if(A[i] == 0){
      flag = true;
    }
  }
  /******
  for(int i = 0; i < N; i++){
    cout << A[i] << "\n";
  }  
  ******/

  if(p == 1) flag = true;
  for(int i = 0; i < N; i++){
    A[i] = abs(A[i]);
  }  
  unsigned long ans = 0;
  for(int i = 0; i < N; i++){
    ans += A[i];
  }
    
  if(flag == false){
    sort(A, &A[N]);
    ans -= A[0]*2;
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())

S = []
for _ in range(N):
  a,b = map(int,input().split())
  S.append((a,b))

T = []
for _ in range(M):
  c,d = map(int,input().split())
  T.append((c,d))

  
for i in S:
  ans = 0
  D = 10**16
  for idx,j in enumerate(T):
    if D > abs(i[0]-j[0])+abs(i[1]-j[1]):
      D = abs(i[0]-j[0])+abs(i[1]-j[1])
      ans = idx + 1
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  double mean=0;
  rep(i,n)mean+=a[i];
  mean/=n;
  double d=1e9;
  rep(i,n)chmin(d,abs(a[i]-mean));
  rep(i,n){
    if(d==abs(a[i]-mean)){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  
  cin >> S;
  int A;
  A= S.size();
  A--;
  for(int i=0; i<A ; i++)
  {
    if(S.at(i)=='A' && (S.at(i+1)=='C'))
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ARainySeason {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin>>s;
        int ans=0,tmp=0;
        int n=s.length();
        for (int i=0;i<n;i++){
            if (s[i]=='R')
                tmp++;
            else{
                ans=max(ans,tmp);
                tmp=0;
            }
        }
        ans=max(ans,tmp);
        cout<<ans;
	}
};


int main() {
	ARainySeason solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt();
    ll test=-1e16;
    multiset <ll> a,b,c;
    vector <ll> v(3*n);
    generate(all(v),nxtl);
    ll left=0,right=0;
    for(int i=0;i<n;i++)
    {
        left+=v[i];
        a.insert(v[i]);
    }
    for(int i=n;i<3*n;i++)
        c.insert(v[i]);
    for(int i=0;i<n;i++)
    {
        auto it=c.begin();
        b.insert(*it);
        right+=*it;
        c.erase(it);
    }
    test=left-right;
    //cout<<test<<endl;
    for(int i=n;i<2*n;i++)
    {
        ll val=v[i];
        if(val>*a.begin())
        {
            left-=*a.begin();
            left+=val;
            a.erase(a.begin());
            a.insert(val);
        }
        if(c.find(val)!=c.end())
        {
            c.erase(c.find(val));
        }
        else
        {
            b.erase(b.find(val));
            right-=val;
            b.insert(*c.begin());
            right+=*c.begin();
            c.erase(c.begin());
        }
        if(left-right>test)
            test=left-right;
        //cout<<i<<" "<<left<<" "<<right<<" "<<test<<endl; 
    }
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 16640