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

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

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll H, W;
	cin >> H >> W;
	char s[51][51];
	REP(i, H)REP(j, W) cin >> s[i][j];

	REP(i, H)REP(j, W){
		if(s[i][j]=='#'){
			bool tmp = true;
			if(i-1>=0){
				if(s[i-1][j]=='#') tmp = false;
			}
			if(j-1>=0){
				if(s[i][j-1]=='#') tmp = false;
			}
			if(i+1<=H-1){
				if(s[i+1][j]=='#') tmp = false;
			}
			if(j+1<=W-1){
				if(s[i][j+1]=='#') tmp = false;
			}
			if(tmp){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#set
include Math
a,b,x = gets.chomp.split(" ").map(&:to_f)
s = (x / a)
limit = ((a * b) / 2)


#main
if s <= limit then
  h = ((2 * s) / b)
  rad = Math.atan2(b ,h) 
else
  h = (2 * (a * b - s) / a)
  rad = Math.atan2(h, a)
end
answer = rad * 180 / PI

print ("#{answer}\n")

Measured memory_bytes: 1788
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

int main(){	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];

	sort(a,a+3);
	cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int N, M;
int K[10];
int S[10][10];
int P[10];

int search(int i, int *onoff) {
  if(i == N) {
    int num = 0;
    for(int j = 0; j < M; j++) {
      int tmp = 0;
      for(int k = 0; k < K[j]; k++) {
	tmp += (onoff[S[j][k]-1] == 1) ? 1 : 0;
      }
      if((tmp % 2) == P[j])
	num++;
    }
    return (num == M) ? 1 : 0;
  }
  
  int onoff_new[10];
  memcpy(onoff_new, onoff, sizeof(int)*10);
  onoff_new[i] = 0;
  int ret = 0;
  ret += search(i+1, onoff_new);// off
  onoff_new[i] = 1;
  ret += search(i+1, onoff_new);// on
  return ret;
}

int main(void) {
  scanf("%d %d", &N, &M);

  for(int i = 0; i < M; i++) {
    scanf("%d", &K[i]);
    for(int j = 0; j < K[i]; j++) {
      scanf("%d", &S[i][j]);
    }
  }
  for(int i = 0; i < M; i++) {
    scanf("%d", &P[i]);
  }

  int onoff[10];
  int X = search(0, onoff);
  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 128
// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( (a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}


void solve(){
	string s1,s2;
	cin>>s1>>s2;
	string s3="";
	ll i,j;
	for(i=0;i<s2.size()-1;i++){
		s3+=s2[i];
	}
	if(s3==s1){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3628
#input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

#output
sum1 = sum(B)
sum2 = 0 
for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        sum2 += C[(A[i]-1)]
print(sum1 + sum2)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
using namespace std;
using ll = long long;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    int i = 1;
    double product = 100.0;
    while(1){
        product = product + product * 0.01;
        if(product > x){
            break;
        }
        i++;
        product=floor(product);
    }
    cout << i;
    
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
uint64_t n,tmp;
std::vector<pair<int,int>> data;


void solve(){
  sort(data.begin(),data.end());

  for(pair<int,int> t:data){
    int x,y;
    tie(x,y)=t;
    cout<<y<<" ";
  }
  cout<<endl;
}


int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    data.push_back(make_pair(tmp,i+1));
  }

  solve();
  return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  vector<pll> p(2);
  for(ll i=0;i<2;i++) {
    ll x,y;
    cin >> x >> y;
    p[i]=pll(x,y);
  }
  for(ll i=0;i<2;i++) {
    ll x=p[i+1].second-p[i].second;
    ll y=p[i+1].first-p[i].first;
    p.push_back(pll(p[i+1].first-x,p[i+1].second+y));
  }
  for(ll i=0;i<2;i++) {
    if(i!=0) cout << " ";
    cout << p[i+2].first << " " << p[i+2].second;
  }
  cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))


d = {}
for num in a:
    d[num] = d.get(num, 0) + 1


for i in range(1, len(a)+2):
    if i in d:
        print(d[i])
    else:
        print(0)


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

ll f(ll X){
    //2^kの桁が1かどうか
    //2^(k+1)のグループがいくつ作れるか
    ll val = 2;
    ll ret = 0;
    if(X%4 == 0 || X%4 == 3) ret = 0;
    else ret = 1;
    while(val <= X){
        ll num_group = X/(val*2);
        ll rem = (X+1) - num_group*(val*2);
        rem -= val;
        if(rem > 0 && rem % 2 == 1) ret += val;
        val *= 2;
    }
    return ret;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    //A^(A+1)^...^B = f(0, B)^f(0, A-1)
    if(A == 0) cout << f(B) << endl;
    else cout << (f(A-1)^f(B)) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    int tc;
    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z') cout << "A";
    else cout << "a";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

#define M 1000000007;

int main() {

	int n;
	cin >> n;

	vector< vector<char> > mp(n, vector<char>(2));

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> mp[j][i];
		}
	}

	if (n == 1) {
		cout << 3 << endl;
	}
	else {
		long long int ans = 6;

		for (int i = 1; i < n-1; i++) {
			if (mp[i][0] == mp[i+1][0]) {
				ans *= 1;
			}
			else if (mp[i][0] == mp[i][1]) {
				ans *= 2;
			}
			else if (mp[i + 1][0] == mp[i + 1][1]) {
				ans *= 1;
			}
			else {
				ans *= 3;
			}
			ans %= M;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    ll ans = 0;
    string s;
    cin >> s;
    
    string rev(s);

    reverse(rev.begin(), rev.end());
    ll size = s.size() / 2;
    s = s.substr(0, size);
    rev = rev.substr(0, size);

    for(int i = 0; i < size; ++i){
        if(s[i] != rev[i]){
            ++ans;
        }
    }

    cout << ans <<  endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	};
	int left_child,right_child,parent;
};

void preORDER(Node order[],int id){
	printf(" %d",id);
	if(order[id].left_child != -1) preORDER(order,order[id].left_child );
	if(order[id].right_child != -1) preORDER(order,order[id].right_child );
}

void inORDER(Node order[],int id){
	if(order[id].left_child != -1) inORDER(order,order[id].left_child );
	printf(" %d",id);
	if(order[id].right_child != -1) inORDER(order,order[id].right_child );
}

void postORDER(Node order[],int id){
	if(order[id].left_child != -1) postORDER(order,order[id].left_child );
	if(order[id].right_child != -1) postORDER(order,order[id].right_child );
	printf(" %d",id);
}

int main(){
	int n,id,left,right,root_id;
	scanf("%d",&n);
	Node order[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left,&right);
		if(left != -1){
			order[id].left_child = left;
			order[left].parent = id;
		}
		if(right != -1){
			order[id].right_child = right;
			order[right].parent = id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(order[root_id].parent == -1) break;
	}

	printf("Preorder\n");
	preORDER(order,root_id);
	printf("\n");

	printf("Inorder\n");
	inORDER(order,root_id);
	printf("\n");

	printf("Postorder\n");
	postORDER(order,root_id);
	printf("\n");
}


Measured memory_bytes: 2756
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 




int main(void){
    ll n,k;
    cin>>k>>n;
    vector<ll>a(n);
    ll sum = 0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = (ll)INF;
    for(ll i=0;i<n;i++){
        if(i==0){
            ans = min(ans,a[n-1]-a[0]);
            ans = min(ans,+a[0]+k-a[1]);
        }
        else{
            if(i==n-1){
                ans = min(ans,a[n-1]-a[0]);
                ans = min(ans,k-a[n-1]+a[n-2]);
            }
            else{
                ans = min(ans,k-a[i]+a[i-1]);
                ans = min(ans,a[i]+k-a[i+1]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
N, M = map(int, sys.stdin.readline().strip().split())
 
def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(size_v):
        for i in range(size_v):
            for j in range(size_v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d
 
edges = []
for i in range(M):
    a, b, c = map(int, sys.stdin.readline().strip().split())
    edges.append((a, b, c))
#print(graph)
 
size_v = N + 1
dist=[[float("inf")] * size_v for i in range(size_v)] 
 
for a, b, c in edges:
    dist[a][b] = c
    dist[b][a] = c
for i in range(size_v):
    dist[i][i] = 0
 
dist = warshall_floyd(dist)
#print(dist)
  
answer_set = set()
for a, b, c in edges:
    if dist[a][b] == c:
        answer_set.add((a, b, c))
    
print(M - len(answer_set))

Measured memory_bytes: 44140
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a,b,i,j,k=2,n,p=1,s,v=1,w=1,x=1,y=1,z[100005];
LL P(LL x,LL y)
{
	LL i=1000000005;
	for(;i;i>>=1)
	{
		if(i&1)
		{
			x=x*y%1000000007;
		}
		y=y*y%1000000007;
	}
	return x;
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>a>>b;
	for(i=n;i;i/=2)
	{
		if(i%2)p=p*k%1000000007;
		k=k*k%1000000007;
	} 
	for(i=0;i++<a;)
	{
		v=v*(n-i+1)%1000000007;
		x=x*i%1000000007;
	}
	for(i=0;i++<b;)
	{
		w=w*(n-i+1)%1000000007;
		y=y*i%1000000007;
	}
	cout<<(p-P(v,x)-P(w,y)+10000000069)%1000000007;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,sum=0,p=1,ans=1,d;
	scanf("%lld",&n);
	for(i=2;i<=n;i++)
	p=(p*i)%1000000007;
	printf("%lld",p);
}

Measured memory_bytes: 256
class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        fi = [pow(f[-1], mod - 2, mod)]
        for idx in range(max_fact, 0, -1):
            fi += [fi[-1] * idx % mod]
        fi = fi[::-1]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 10**6
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation

N, M = [int(_) for _ in input().split()]
ans = 0
for p in range(N + 1):
    ans += (-1)**p * comb(N, p) * perm(M - p, N - p)
    ans %= mod
ans *= perm(M, N)
ans %= mod
print(ans)


Measured memory_bytes: 95836
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int min = 1001;
        
        for(int i = 0; i < n; i++){
            int c = sc.nextInt();
            int tt = sc.nextInt();
            if(tt <= t && c < min){
                min = c;
            }
        }
        if(min == 1001){
            System.out.println("TLE");
        }else{
            System.out.println(min);
        }
    }
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w1 = sc.nextInt();
        int[] w2 = new int[w1];
        for(int i=0;i<w1;i++){
            w2[i] = i+1;
        }
        int n = sc.nextInt();
        for(int i=0;i<n;i++){
            String str = sc.next();
            String[] str2 = str.split(",");
            int a = Integer.parseInt(str2[0])-1;
            int b = Integer.parseInt(str2[1])-1;
            int tmp;
            tmp = w2[a];
            w2[a] = w2[b];
            w2[b] = tmp;
        }
        for(int i=0;i<w1;i++){
            System.out.println(w2[i]);
        }
    }
}


Measured memory_bytes: 26088
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	long long n, cmp = 0;
	cin >> n;
	long long a[n + 2] = {}, b[n + 1] = {};
	a[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i - 1] = abs(a[i] - a[i - 1]);
		cmp += b[i - 1];
	}
	cmp += abs(a[n] - 0);
	for (int i = 1; i < n + 2; i++) {
		b[i - 1] = abs(a[i] - a[i - 1]);
	}
	// for (int i = 0; i < n + 2; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << endl;
	// for (int i = 0; i < n + 1; i++) {
	// 	cout << b[i] << " ";
	// }
	// cout << endl;
	// cout << "cmp:" << cmp << endl;
	for (int i = 1; i < n + 1; i++) {
		cout << cmp - b[i - 1] - b[i] + abs(a[i + 1] - a[i - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>v
#define OUT(v) cout<<v<<endl


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

  VI X, Y, h;
  int s;
  REP(i, N) {
    int x, y, _h;
    IN(x >> y >> _h);
    if (_h > 0) s = i;
    X.PB(x);
    Y.PB(y);
    h.PB(_h);
  }
  REP(CX, 101) {
    REP(CY, 101) {
      int H = abs(X[s] - CX) + abs(Y[s] - CY) + h[s];
      bool matched = true;
      REP(i, N) {
        int hi = max(H - abs(X[i] - CX) - abs(Y[i] - CY), 0);
        if (h[i] != hi) {
          matched = false;
          break;
        }
      }
      if (matched && H != -1) {
        OUT(CX << " " << CY << " " << H);
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll k,x,y,nx,ny,z,ans,d;

ll sig(ll x){
  if(x>0){
    return 1;
  }
  else if(x<0){
    return -1;
  }
  else return 0;
}

void fac(ll x,ll y,ll ans,ll sx,ll sy){
  if(ans==3){
    if(x*y!=0){
      nx=-1*sig(x)*min(d,k);
      ny=sig(y)*(k-min(d,k));
      cout << nx << " " << ny << endl;
      d-=min(d,k);
    }
    else if(y==0){
      ny=min(d,k);
      nx=sig(x)*abs(k-ny);
      d-=ny;
      cout << nx << " " << ny << endl;
    }
    else{
      nx=min(d,k);
      ny=sig(y)*abs(k-nx);
      d-=nx;
      cout << nx << " " << ny << endl;
    }
    fac(x,y,2,nx,ny);
  }
  else if(ans==2){
    if(x==sx){
      cout << k-abs(y/2)+sx << " " << y/2+sy << endl;
    }
    else if(y==sy){
      cout << x/2+sx << " " << k-abs(x/2)+sy << endl;
    }
    else{
      if(abs(x-sx)>abs(y-sy)){
        cout << sig(x-sx)*(abs(x-sx)+abs(y-sy))/2+sx << " " << -1*sig(y)*(2*k-abs(x-sx)-abs(y-sy))/2+sy << endl;
      }
      else{
        cout << -1*sig(x-sx)*(2*k-abs(x-sx)-abs(y-sy))/2+sx << " " << sig(y-sy)*(abs(x-sx)+abs(y-sy))/2+sy << endl;
      }
    }
    cout << x << " " << y << endl;
  }
  nx=x;ny=y;
  return;
}

int main() {
  cin >> k >> x >> y;//s回動かしたとき,距離はs*k-2*m=abs(x)+abs(y);
  if(k%2==0&&(abs(x)+abs(y))%2!=0){
    cout << -1 << endl;
    return 0;
  }
  z=abs(x)+abs(y);
  ans=z/k;
  if(ans==0){
    ans=2;
  }
  if(ans*k<z){
    ans++;
  }
  if(k%2==1&&((ans%2==0&&(abs(x)+abs(y))%2==1)||(ans%2==1&&(abs(x)+abs(y))%2==0))){
    ans++;
  }
  d=(-abs(x)-abs(y)+ans*k)/2;
  cout << ans << endl;
  if(ans==1){
    cout << x << " " << y << endl;
    return 0;
  }
  if(z<=2*k){
    fac(x,y,ans,0,0);
  }
  else{
    if(x!=0){
      if(abs(x)>=(ans-2)*k){
        fac(sig(x)*(abs(x)-(ans-2)*k),y,2,0,0);
      }
      else{
        fac(0,sig(y)*(abs(x)+abs(y)-(ans-2)*k),2,0,0);
      }
    }
    else{
      if(abs(y)>=3*k){
        fac(x,sig(y)*(abs(y)-(ans-2)*k),2,0,0);
      }
    }
    /*if(nx>x){
      ny+=sig(y)*abs(k-(abs(nx-x)));
      nx=x;
      cout << x << " " << ny << endl;
    }*/
    while(abs(x-nx)>=k){
      if(sig(x)==0){
        break;
      }
      nx+=sig(x)*k;
      cout << nx << " " << ny << endl;
    }
    if(abs(x-nx)<k&&abs(x-nx)!=0){
      ny+=sig(y)*abs(k-(abs(x-nx)));
      if(sig(y)==0){
        ny=0;
      }
      nx=x;
      cout << nx << " " << ny << endl;
    }
    while(abs(y-ny)!=0){
      ny+=sig(y)*k;
      cout << nx << " " << ny << endl;
    }
  }
}


Measured memory_bytes: 3620
import numpy as np

N = int(input())
A = list(map(int,input().split()))

a = np.array(A)

odd = a[a%2 == 0]

if np.sum((odd%3 != 0)&(odd%5 != 0)) == 0:
    print('APPROVED')
else:
    print('DENIED')


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

signed main() {
  string a;
  cin >> a;
  int alfa[26] = {};
  for (int i = 0; i < a.size(); i++) {
    alfa[a[i] - 'a']++;
  }

  int sum = 0, len = a.size();
  for (int i = 0; i < 26; i++) {
    if (alfa[i] == 0) continue;
    if(len == alfa[i]) {
      sum++;
      break;
    }
    sum += (alfa[i] * (len - alfa[i]));
    len -= alfa[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String ss = sc.next();
        char[] s = ss.toCharArray();
        int[] ac = new int[n+1];
        ArrayList<Integer> acl = new ArrayList<>();
        int i = 1;
        boolean prevA = false;
        for(char c : s){
            if(c == 'A'){
                prevA = true;
            }else if(c == 'C' && prevA){
                //System.out.println(i-1);
                ac[i-1]++;
                prevA = false;
            }else{
                prevA = false;
            }
            i++;
        }
        //System.out.print(ac[0] + " ");
        for(int j = 1; j <= n; j++){
            ac[j] += ac[j-1];
            //System.out.print(ac[j] + " ");
        }
        //System.out.println();
        for(int j = 0; j < q; j++){
            int left = sc.nextInt()-1;
            int right = sc.nextInt()-1;
            System.out.println(ac[right] - ac[left]);
        }
    }
}

Measured memory_bytes: 71088
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,m,d[maxn];
struct edge{int y,nex;}a[maxn<<1]; int len,fir[maxn];
inline void ins(const int x,const int y){a[++len]=(edge){y,fir[x]};fir[x]=len;}

int fa[maxn],dep[maxn];
void dfs(const int x)
{
	for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(y!=fa[x])
		dep[y]=dep[x]+1,fa[y]=x,dfs(y);
}

int col[maxn];
struct node{int d,x;};
inline bool operator <(const node x,const node y){return x.d<y.d;}
priority_queue<node>q;
bool Col()
{
	for(int i=1;i<=n;i++) q.push((node){dep[i],i});
	memset(col,-1,sizeof col);
	while(!q.empty())
	{
		const node now=q.top(); q.pop();
		int x=now.x;
		if(col[x]!=-1) continue;
		if(x==1) {col[x]=0; break;}
		if(col[fa[x]]!=-1) return true;
		col[fa[x]]=0;
		col[x]=1;
		for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y) d[a[k].y]++;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		ins(x,y); ins(y,x);
	}
	dep[1]=1; dfs(1);
	if(Col()) return puts("First"),0;
	for(int i=1;i<=n;i++) if(!col[i]&&!d[i]) return puts("First"),0;
	puts("Second");
	
	return 0;
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n, k, ans; cin >> n >> k;
    ans = k;
    Rep(i, 1, n){
        ans *= k-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map{/ /*atan2$'-$y,$`-$x}grep!/^$x $y/,@a),"@b"+($P=6.2831853)for@a=<>

Measured memory_bytes: 5248
#include <stdint.h>
#include <stdlib.h>

#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

template <typename T = int64_t>
struct Edge {
  int64_t to;

  Edge(int64_t to_) : to(to_) {}
};

template <typename T>
using Graph = vector<vector<Edge<T>>>;

template <typename T>
bool TopologicalSort(const Graph<T>& graph, vector<int64_t>* sorted,
                     vector<int64_t>* group = nullptr) {
  sorted->clear();
  sorted->reserve(graph.size());
  if (group != nullptr) {
    group->clear();
    group->resize(graph.size(), -1);
  }

  using P = pair<int64_t, int64_t>;

  vector<int64_t> degs(graph.size(), 0);
  queue<P> que;
  for (const auto& v : graph) {
    for (const auto& e : v) {
      degs[e.to]++;
    }
  }

  for (size_t v_id = 0; v_id < graph.size(); ++v_id) {
    if (degs[v_id] == 0) {
      que.emplace(v_id, 0);
    }
  }

  while (!que.empty()) {
    const int64_t v_id = que.front().first;
    const int64_t g_id = que.front().second;
    que.pop();
    sorted->emplace_back(v_id);
    if (group != nullptr) {
      (*group)[v_id] = g_id;
    }

    for (const auto& e : graph[v_id]) {
      degs[e.to]--;
      if (degs[e.to] == 0) {
        que.emplace(e.to, g_id + 1);
      }
    }
  }

  return sorted->size() == graph.size();
}

#ifdef USE_STACK_TRACE_LOGGER
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <glog/logging.h>
#pragma clang diagnostic pop
#endif  //__clang__
#endif  // USE_STACK_TRACE_LOGGER

signed main(int argc, char* argv[]) {
  (void)argc;
#ifdef USE_STACK_TRACE_LOGGER
  google::InitGoogleLogging(argv[0]);
  google::InstallFailureSignalHandler();
#else
  (void)argv;
#endif  // USE_STACK_TRACE_LOGGER
  int64_t V, E;
  cin >> V >> E;
  Graph<int64_t> graph(V);
  for (size_t i = 0; i < size_t(E); ++i) {
    int64_t s, t;
    cin >> s >> t;

    graph[s].emplace_back(t);
  }
  vector<int64_t> sorted;
  TopologicalSort(graph, &sorted);
  for (auto v : sorted) {
    cout << v << endl;
  }
  return EXIT_SUCCESS;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A.at(i).at(j);
    }
  }
  vector<int> row(H);
  vector<int> column(W);
  for(int i = 0; i < H; i++){
    int count = 0;
    for(int j = 0; j < W; j++){
      if(A.at(i).at(j) == '#') count++;
    }
    if(count == 0) row.at(i) = 1;
  }
  
  for(int i = 0; i < W; i++){
    int count = 0;
    for(int j = 0; j < H; j++){
      if(A.at(j).at(i) == '#') count++;
    }
    if(count == 0) column.at(i) = 1;
  }
  
  for(int i = 0; i < H; i++){
    if(row.at(i) == 1) continue;
    for(int j = 0; j < W; j++){
      if(column.at(j) == 1) continue;
      cout << A.at(i).at(j);
    }
    cout << endl;
  }
}


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

using namespace std;

const int N = 100010;

int n, h[N][3], f[N][3];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 3; ++j) {
      scanf("%d", h[i] + j);
    }
  }
  for (int i = n; i > 0; --i) {
    f[i][0] = max(h[i][1] + f[i + 1][1], h[i][2] + f[i + 1][2]);
    f[i][1] = max(h[i][0] + f[i + 1][0], h[i][2] + f[i + 1][2]);
    f[i][2] = max(h[i][1] + f[i + 1][1], h[i][0] + f[i + 1][0]);
  }
  cout << max(f[1][0], max(f[1][1], f[1][2])) << endl;
  return 0;
}



Measured memory_bytes: 2560
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N;
string S;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      S = readToken();
      
      auto sum = new int[N + 1];
      foreach (i; 0 .. N) {
        sum[i + 1] = sum[i] + ((S[i] == '#') ? 1 : 0);
      }
      
      // ...###
      int ans = N + 1;
      foreach (i; 0 .. N + 1) {
        int tmp;
        tmp += sum[i];
        tmp += (N - i) - (sum[N] - sum[i]);
        chmin(ans, tmp);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


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

int main(){
	int S, h, m, s;
	
	cin >> S;
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;
	cout << h << ':' << m << ':' << s << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
using namespace std;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q),b(n);

	for (int i = 0; i < q; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		b.at(i) = 0;
	}
	for (int i = 0; i < q; i++) {
		b.at(a.at(i)-1)++;
	}
	for (int i = 0; i < n; i++) {
		b.at(i) = k - (q  - b.at(i));
	}

	for (int i = 0; i < n; i++) {
		if (b.at(i) > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 4056
import numpy as np

n = int(input())
p = list(map(float, input().split()))

dp = np.zeros(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[1:] = dp[:-1]*p[i-1]+dp[1:]*(1-p[i-1])

print(dp[(n+1)//2])


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

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

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

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

double n(double key){
    double ans=0.0;
    double L=0.0,R=key/3,mid=0.0;
    int cnt=0;
    //cout<<key-3*mid<<endl;
    while(key-(3*mid)>=0.00001){
        mid=L+(R-L)/2;
        if(key>3*mid)L=mid;
        else R=mid;
        //cout<<R<<" "<<L<<" "<<mid<<" "<<key-(3*mid)<<endl;
        //cout<<endl;
        if(cnt==11)break;
        cnt++;
    }
    return R*R*R;
}

//直方体
int main(){
    double L;
    cin>>L;
    cout<<decimal(10)<<n(L)<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =202;
int n , q ;
char a[N][N];
int vis[N];
int main ( ){
   ios::sync_with_stdio(false);

  cin >> n ;
  for  ( int  i = 1;  i <= n ; i++ )
    for ( int j = 1; j <= n ; j++ )
       cin >> a[i][j] ;
  int mx = -1 ;
  for  (int i = 1; i<= n ;i++ ){
       memset( vis , -1 , sizeof vis );
    queue < int > q ;
    bool sol = 1;
     vis[i] = 1 ;
     q.push(i);

     while ( q.size() ){
      int u = q.front() ; q.pop() ;
      for  ( int v = 1; v <= n ; v++ ){
        if ( a[u][v] == '1' ){
            if ( vis[v] == -1 ){
                vis[v] = vis[u]+1 ;
                q.push(v);
            }else if ( vis[v] != -1 && abs(vis[u]-vis[v]) != 1 ) {
             sol =0 ;
            }
        }
      }
     }
     int cur = *max_element(vis+1,vis+1+n);
     if ( sol ) mx = max ( mx , cur );
  }
  cout << mx <<endl;
return 0 ;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int i,j;
  scanf("%d",&i);
  if (i%10==9){
    i-=8;
  }else if (i%10==1){
    i+=8; 
  }
  j=i/100;
  if (j==9){
    i-=800;
  }else if (j==1){
    i+=800; 
  }
  j=(i/10)%10;
  if (j==9){
    i-=80;
  }else if(j==1){
    i+=80;
  }
  printf("%d",i);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
int Nmax = 50;

int n, m;
vector<vector<int> > G(Nmax, vector<int>(Nmax));
vector<int> visited(Nmax);

void dfs(int v) {

    visited[v] = 1;

    r(u, n) {
        if(G[v][u] && !visited[u]) {
            dfs(u);
        }
    }

}

int main() {

    cin >> n >> m;

    vector<int> a(m), b(m);
    r(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    int ans = 0;
    r(i, m) {

        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;

        r(i, n) {
            visited[i] = 0;
        }

        dfs(0);

        r(i, n) {
            if(!visited[i]) {
                ans++;
                break;
            }
        }

        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

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


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[10000];
int main() {
	int n;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int sum = 0;
	rep(i,n)
		while(a[i] % 2 == 0){
			a[i] /= 2;
			sum++;
		}
	cout << sum << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int K = sc.nextInt();
        sc.close();
        if (K == 0) {
            System.out.println(N * N);
            return;
        }
        long ans = 0;
        for (int b = K + 1; b <= N; b++) {
            long p = N / b, r = N % b;
            long k = Math.max(b - K, 0) * p + Math.max(r - K + 1, 0);
            ans += k;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
n = int(input())
x = input().split()

masu_list = []
for i in range(n):
    i=i+1
    if not i%2==0:
        masu_list.append(i)
    else:
        pass

answer_list=[]
for masu in masu_list:
    masu = masu-1
    answer_list.append(x[masu])

answer = [int(s) for s in answer_list]
answer_list_2=[]
for ans in answer:
    if not ans%2==0:
         answer_list_2.append(ans)
    else:
        pass
print(len(answer_list_2))

Measured memory_bytes: 9232
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(n==1){
        if(a!=b)cout<<0<<endl;
        else cout<<1<<endl;
    }
    else cout<<((n-2)*(b-a))+1<<endl;
    return 0;
}

Measured memory_bytes: 256
// B - Checkpoints

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a[50];
int b[50];
int c[50];
int d[50];

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

	for (int i=0; i<N; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i=0; i<M; i++) {
		cin >> c[i] >> d[i];
	}


	for (int i=0; i<N; i++) {
		int min_dist = INF;
		int min_cp;
		for (int j=0; j<M; j++) {
			int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (dist < min_dist) {
				min_dist = dist;
				min_cp = j + 1;
			}
		}

		cout << min_cp << endl;
	}

	return 0;
}

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

using namespace std;

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

    int n; cin >> n;
    string a, b; cin >> a >> b;
    for(int i = 0; i< n; ++i) cout << a[i] << b[i];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n); REP (i, n) cin >> a[i];
  vector<int> acc(n + 1);
  REP (i, n) acc[i + 1] = acc[i] + a[i];
  unordered_map<int, int> mp;
  int ans = 0;
  REP (i, n + 1) {
    ans += mp[acc[i]];
    mp[acc[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11592
def main():
    T, P = input(), input()
    t, p = len(T), len(P)
    if t>=p:
        ans = [str(n) for n, i in enumerate(range(p, t+1)) if T[n:i]==P]
        if ans:
            print("\n".join(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 84952
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;

using namespace std;

typedef long long ll;

void solve() {
	ll n;
	cin >> n;
	vector<int> arr(n);
	read(arr, n);
	int min = n+1;
	int count = 0;
	for(int i   =0; i< n; i++) {
		if (arr[i] <= min) {
			min = arr[i];
			count++;
		}
	}

	cout << count << endl;
	return;
}

int main() {
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();	
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<pair<int, int>> A(N);
    rep(i, N) cin >> A[i].first, A[i].second = i;

    vec<pair<int, int>> B(N);
    rep(i, N) cin >> B[i].first, B[i].second = i;

    sort(all(A));
    sort(all(B));

    rep(i, N) if (A[i].first > B[i].first) {
        cout << "No" << endl;
        return 0;
    }

    vec<pair<int,int>> c(N);
    rep(i, N) {
        c[i] = {A[i].second, B[i].second};
    }
    sort(all(c));

    vec<int> cycle;
    int now = 0;
    rep(i,N){
        cycle.push_back(now);
        now = c[now].second;
        if(now == 0) break;
    }

    if (cycle.size() != N) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, N - 1) {
        if (A[i + 1].first <= B[i].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<pair<ll, ll> > p(n);
    rep(i,n)cin >> p[i].first >> p[i].second;
    sort(all(p));
    rep(i,n)cout << p[i].first << " " << p[i].second << endl;
    return 0;
}


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


int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;


  if(K<=A)
    cout << K << endl;
  else if(K<=A+B)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;
  return 0;
}



Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc081.contest.atcoder.jp/tasks/arc081_c>
問題文============================================================
 文字列 S に対して，その文字列を構成する文字を 0 文字以上取り除き，
 残った文字を元の順番で並べて得られる文字列を S の部分列と呼びます．
 たとえば，arc や artistic や (空文字列) は artistic の部分列ですが，
 abc や ci は artistic の部分列ではありません．
 
 英小文字からなる文字列 A が与えられます．
 このとき，英小文字からなる文字列で，A の部分列ではないようなもののうち，最も短いものを求めてください．
 ただし，そのようなものが複数ある場合には，辞書順で最小のものを求めてください．
=================================================================

解説=============================================================
解説を見た
 
 後ろから利用できる文字に対して印をつけていき、
 のちに復元を行う
================================================================
*/

string solve(){
    string res = "";
    string A; cin >> A;
    vector<int> f(26,0);
    vector<int> nextC(A.length()+1,0);
    for(int i = (int)A.length()-1; i >= 0; i--){
        int cnt = 0;
        f[A[i]-'a'] = true;
        nextC[i] = nextC[i+1];
        for(int j = 0; j < 26;j++){
            if(f[j]) cnt++;
            else break;
        }
        if(cnt == 26) for(int j = 0; j < 26;j++) f[j] = false;
        nextC[i] = cnt%26;
    }
    for(int i = 0; i < A.length(); i++){
        char c = nextC[i] + 'a';
        res += c;
        while(i < A.length() && A[i] != c) i++;
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1300
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
bc = sorted([list(map(int,input().split())) for _ in range(m)], key=lambda x: x[1], reverse=True)
c = 0

for i in range(m):
    for j in range(c, min(c+bc[i][0], n)):
        if a[j] < bc[i][1]:
            a[j] = bc[i][1]
    c += bc[i][0]
print(sum(a))


Measured memory_bytes: 33640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<ll>vec(3);
  ll a=0;
  for(ll i=0;i<3;i++){
    cin>>vec.at(i);
    a+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<a-vec.at(2)<<endl;
  return 0;
}


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

int main() {
  int N,ans=32;
  cin >> N;
  for (int i=0;i<N;i++){
    int A,unta=0;
    cin >> A;
    while (A%2==0){
      A/=2;
      unta++;
    }
    ans=min(ans,unta);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  cout << (int)pow((int)sqrt(N), 2) << endl;
}

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

mod = 10**9 + 7
ans = 0

for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (A[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1
    ans = (ans + (n0 * n1) * (1 << d))% mod
    
print(ans)

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int K, S; cin >> K >> S;
    long ans = 0;
    for(int i = 0; i <= min(K, S); i++){
        if(S - i >= 0 && S - i <= 2 * K)
            if(S - i > K)
                ans += (long)K * 2 - (long)S + (long)i + 1;
            else
                ans += (long)S - (long)i + 1;
            
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256