akhauriyash/Code-Regression huggingface dataset:
/*input
6 3
2 1
2 3
4 1
4 2
6 1
2 6
4 6
6 5
*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/
const int N = 100004;

int main()
{
    ifalse;
    int n, m;
    cin >> n >> m;
    vector < int > v[N];
    int in[N] = {0};
    rep(i, 0, n + m - 1) {
    	int x, y;
    	cin >> x >> y;
    	v[x].pb(y);
    	in[y] ++;
    }

  	queue < int > q;
  	for(int i = 1; i <= n; i ++) {
  		if(in[i] == 0) {
  			q.push(i);
  		}
  	}  

  	int ans[N] = {0};
  	while(!q.empty()) {
  		int f = q.front();
  		q.pop();
  		for(auto x: v[f]) {
  			in[x] --;
  			if(in[x] == 0) {
  				ans[x] = f;
  				q.push(x);
  			}
  		}	
  	}
  	for(int i = 1; i <= n; i ++) {
  		cout << ans[i], nl;
  	}
    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int n,ch[1001000][26],f[1001000][26][2],flag[1001000],tot=1;
inline void dfs(int x)
{
	if(x==0) return;
	for(int i=0;i<26;i++) dfs(ch[x][i]);
	for(int i=0;i<26;i++) for(int j=0;j<26;j++)
	{
		if(i==j) f[x][i][1]+=f[ch[x][j]][i][0];
		else f[x][i][0]+=f[ch[x][j]][i][0];
		f[x][i][1]+=f[ch[x][j]][i][1];
	}
	for(int i=0;i<26;i++)
		ans+=1ll*flag[ch[x][i]]*(f[x][i][1]-flag[ch[x][i]]);
	for(int i=0;i<26;i++) f[x][i][0]+=flag[x];
	
}
int main()
{
	scanf("%d",&n);
	for(int x=1;x<=n;x++)
	{
		string s;cin>>s;
		reverse(s.begin(),s.end());
		int now=1;
		for(int i=0;i<(int)s.size();i++)
		{
			if(ch[now][s[i]-'a']==0)ch[now][s[i]-'a']=++tot;
			now=ch[now][s[i]-'a'];
		}
		flag[now]++;
	}
	dfs(1);
	cout<<ans<<endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  int x,y;cin>>x>>y;
  int i,j;
  int fx=0;
  int turns=0;
  int nowdis=0;
  vector<int> xs(0);
  vector<int> ys(0);
  rep(i,s.size())
  {
    if(s[i]=='F')
    {
      nowdis++;
    }
    else
    {
      if(turns==0)
      {
        fx+=nowdis;
      }
      else if(turns%2==0&&nowdis>0)
      {
        xs.emplace_back(nowdis);
      }
      else if(turns%2==1&&nowdis>0)
      {
        ys.emplace_back(nowdis);
      }
      nowdis=0;
      turns++;
    }
  }
  if(turns==0)
  {
    fx+=nowdis;
  }
  else if(turns%2==0&&nowdis>0)
  {
    xs.emplace_back(nowdis);
  }
  else if(turns%2==1&&nowdis>0)
  {
    ys.emplace_back(nowdis);
  }
  x-=fx;
  int xsum=0;
  rep(i,xs.size())xsum+=xs[i];
  vector<vector<bool>> xdp(xsum*2+1,vector<bool>(xs.size()+1,false));
  xdp[xsum][0]=true;
  for(j=0;j<xs.size();j++)
  {
    for(i=0;i<=xsum*2;i++)
    {
      if(i-xs[j]>=0&&i-xs[j]<=xsum*2)
      {
        if(xdp[i-xs[j]][j])xdp[i][j+1]=true;
      }
      if(i+xs[j]>=0&&i+xs[j]<=xsum*2)
      {
        if(xdp[i+xs[j]][j])xdp[i][j+1]=true;
      }
    }
  }
  int ysum=0;
  rep(i,ys.size())ysum+=ys[i];
  vector<vector<bool>> ydp(ysum*2+1,vector<bool>(ys.size()+1,false));
  ydp[ysum][0]=true;
  for(j=0;j<ys.size();j++)
  {
    for(i=0;i<=ysum*2;i++)
    {
      if(i-ys[j]>=0&&i-ys[j]<=ysum*2)
      {
        if(ydp[i-ys[j]][j])ydp[i][j+1]=true;
      }
      if(i+ys[j]>=0&&i+ys[j]<=ysum*2)
      {
        if(ydp[i+ys[j]][j])ydp[i][j+1]=true;
      }
    }
  }
  if(abs(x)>xsum||abs(y)>ysum)cout<<"No"<<endl;
  else if(xdp[xsum+x][xs.size()]&&ydp[ysum+y][ys.size()])
  {
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}



Measured memory_bytes: 2688
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a*b > c*d) printf("%d",a*b);
	else if(a*b < c*d) printf("%d",c*d);
	else printf("%d",a*b);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 998244353;


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


    int n;
    cin>>n;

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

    vector<int> dp(n);

    dp[0]=0;
    dp[1]=dp[0]+abs(height[0]-height[1]);

    for(int i=2; i<n; i++){
    	dp[i] = min(dp[i-2] + abs(height[i-2]-height[i]), 
    			dp[i-1] + abs(height[i-1]-height[i]));
    }

    cout<<dp[n-1]<<endl;

	return 0;
}		


Measured memory_bytes: 1024
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) ((a > b) ? a : b)

int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  int a[n], b[n];
  for (int i=0; i<n; i++)
    scanf("%d%d", a+i, b+i);
  int dp1[n][t], dp2[n][t];
  for (int i=0; i<t; i++) {
    dp1[0][i] = 0;
    dp2[n-1][i] = 0;
  }
  for (int i=0; i<n; i++) {
    dp1[i][0] = 0;
    dp2[i][0] = 0;
  }
  for (int i=1; i<n; i++) {
    for (int j=1; j<t; j++) {
      if (j < a[i-1])
        dp1[i][j] = dp1[i-1][j];
      else
        dp1[i][j] = Max(dp1[i-1][j], dp1[i-1][j-a[i-1]] + b[i-1]);
      if (j < a[n-i])
        dp2[n-i-1][j] = dp2[n-i][j];
      else
        dp2[n-i-1][j] = Max(dp2[n-i][j], dp2[n-i][j-a[n-i]] + b[n-i]);
    }
  }
  int ans = 0;
  for (int i=0; i<n; i++)
    for (int j=0; j<t; j++)
      ans = Max(ans, dp1[i][j]+dp2[i][t-1-j]+b[i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 70528
#include <cstdio>
#include <cstring>
int main(){
	char s[100005];
	scanf("%s", s);
	bool cnt[26];
	int len = strlen(s);
	for(int i = 0; i < len; i++){
		cnt[s[i] - 'a'] = true;
	}
	for(int i = 0; i < 26; i++){
		if(cnt[i] == false){
			printf("%c\n", i+'a');
			return 0;
		}
	}
	printf("None\n");
	return 0;
}

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

int dp[(int)2e5][2];

int main(){
    string s;
    cin >> s;
    if (s.size() == 1){
        cout << 1 << endl;
        return 0;
    }
    //もらうdpをする
    //0番目までの選び方は、0番目のみを選ぶ方法のみ
    dp[0][0] = 1;
    //1番目までの選び方は、0番目と1番目が異なれば、1番目までで長さ2で、そうでなければ長さ2
    if (s[0] != s[1]) dp[1][0] = 2;
    else dp[1][1] = 1;
    //dp[i]を更新する
    for (int i = 2; i < s.size(); i++){
        //i番目を終点とする部分文字列の長さをj - 1とする
        for (int j = 0; j < 2; j++){
            //i - j番目までの部分文字列の長さをk - 1とする
            for (int k = 0; k < 2; k++){
                if (j != k){
                    if (dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
                }
                else{
                    bool flag = false;
                    for (int l = 0; l <= k; l++) if (s[i - j - l - 1] != s[i - l]) flag = true;
                    if (flag && dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
                }
            }
        }
    }
    cout << max(dp[s.size() - 1][0], dp[s.size() - 1][1]) << endl;
}

Measured memory_bytes: 2180
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char s[100005];
    scanf("%s", s);
    int n = strlen(s);
    while (n > 0)
    {
        if (s[0] == 'd' && s[1] == 'r'&& s[2] == 'e' && s[3] == 'a' && s[4] == 'm')
        {
            if (s[5] == 'e' && s[6] == 'r' && s[7] != 'a')
            {
                for (i = 0; i < n - 7; i++)
                    s[i] = s[i + 7];
                for (i = n - 7; i < n; i++)
                    s[i] = '0';
                n -= 7;
            }
            else
            {
                for (i = 0; i < n - 5; i++)
                    s[i] = s[i + 5];
                for (i = n - 5; i < n; i++)
                    s[i] == '0';
                n -= 5;
            }
        }
        else if (s[0] == 'e' && s[1] == 'r' && s[2] == 'a' && s[3] == 's' && s[4] == 'e')
        {
            if (s[5] == 'r' && s[6] != 'a')
            {
                for (i = 0; i < n - 6; i++)
                    s[i] = s[i + 6];
                for (i = n - 6; i < n; i++)
                    s[i] = '0';
                n -= 6;
            }
            else
            {
                for (i = 0; i < n - 5; i++)
                    s[i] = s[i + 5];
                for (i = n - 5; i < n; i++)
                    s[i] = '0';
                n -= 5;
            }
        }
        else
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main( void ) {
	int i, j, tmp, cnt = 0, nData, data[ 100 ];

	scanf( "%d", &nData );

	for ( i = 0; i < nData; i++ )
		scanf( "%d", &data[ i ] );

	for ( i = 0; i < nData - 1; i++ )
		for ( j = nData - 1; j > i; j-- )
			if ( data[ j - 1 ] > data[ j ] ) {
				tmp = data[ j - 1 ];
				data[ j - 1 ] = data[ j ];
				data[ j ] = tmp;

				cnt++;
			}

	for ( i = 0; i < nData - 1; i++ )
		printf( "%d ", data[ i ] );
	printf( "%d\n%d\n", data[ nData - 1 ], cnt );

	return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}

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

int main(void) {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin>>s;
    int ans = 1;
    FOR(i, n-1){
        if(s[i]!=s[i+1])
            ans++;
    }
    cout<<ans;
}

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

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

  int sum;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int l = 0; l <= c; l++){
        sum = i*500 + j*100 + l*50;
        if(sum == x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs

    N = int(input())
    divs = trial_division(N)
    ans = 0
    for d in divs:
        if d != 1 and N//(d-1) == N % (d-1):
            ans += (d-1)
    print(ans)


if __name__ == '__main__':
    main()


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

#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long int

int main()
{
    ios::sync_with_stdio(0);// Input and output clearance
    cin.tie(0);
    string str,str1,str2;
    int end;
    cin>>str;
    if(str[str.length()-1]=='s')
    {
        str+="es";
    }
    else{
        str+='s';
    }
cout<<str;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
    int i,j,k,t;
    long long int count=0;
    scanf("%d",&t);
    for(i=0;i<t;i++){
        scanf("%d",&j);
        if(i==0){
            k=j;
        }
        else{
            if(j<k){
                count=count+(k-j);
                j=k;
            }
            k=j;
        }
    }
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 1688
a,b=gets.chomp.split(' ').map{|n| n.to_i}
if(a<=0 && 0<=b)
	puts "Zero"
elsif(0<a && 0<b)
	puts "Positive"
else
	if((a.abs - (b>0 ? 1 : b.abs) + 1 )% 2 == 0)
		puts "Positive"
	else
		puts "Negative"
	end
end



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

using namespace std;

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

        if ( n % 2 != 0){
                cout << (n / 2) + 1 << endl;
        }
        else if (n % 2 == 0){
                cout << n / 2 << endl;
        }
        return 0;
}

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

typedef long long int ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0;i < N;i++){
     cin >> A[i];
  }
  ll ans = 0;
  vector<ll> memo(100010,0);
  for(int i = 0;i < N;i++){
     if(A[i] > N){
        ans++;
     }else{
        memo[A[i]]++;
     }
  }
  for(int i = 0;i < 100010;i++){
     if(memo[i] != 0){
        if(memo[i] < i){
           ans += memo[i];
        }else{
           ans += memo[i] - i;
        }
     }
  }
  cout << endl;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector <int> x;
vector <int> y;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		x.push_back(t);
	}
	y=x;
	sort(x.begin(),x.end());
	int xs,xb;
	xs=x[x.size()/2-1];
	xb=x[x.size()/2];
	for(int i=0;i<n;i++){
		if(xb>y[i]){
			cout<<xb<<endl;
		}else{
			cout<<xs<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  int n; cin >> n;
  ll money=1000;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  vector<int> b(0);
  vector<int> s(0);
  if(v[0]<v[1]) b.push_back(0);
  rep1(i,n-2){
    if(v[i-1]<v[i]&&v[i]>=v[i+1]) s.push_back(i);
    if(v[i-1]>=v[i]&&v[i]<v[i+1]) b.push_back(i);
  }
  if(v[n-2]<v[n-1]) s.push_back(n-1);
  rep(i,b.size()){
    if(upper_bound(all(s),b[i])!=s.end()){
      money=money%v[b[i]]+money/v[b[i]]*v[*upper_bound(all(s),b[i])];
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
	int  a, b, a1, b1, c, g;
	long l;
	
	while (cin >> a >> b)
	{
		a1 = a;
		b1 = b;
		
		if (a == 0 || b == 0)
		{
			break;
		}
		
		else if (a1 == b1)
		{
			g = a1;
			
		}
		else
		{
			while (1)
			{
				c = abs(a - b);
				if (c == 0)
				{
					break;
				}

				if (a > b)
				{
					a = c;
					g = c;
				}
				else if (a < b)
				{
					b = c;
					g = c;
				}
			}
		}
		l = (a1 / g)*b1;

		cout << g << " " << l << endl;

		a1 = a; b1 = b;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N;
  cin >> N;
  map<ll, ll> mp;
  ll i, j;
  for(i=1; i*i<=N; i++) {
    if(N%i==0) {
      mp[i]++;
      mp[N/i]++;
    }
  }
  
  ll ans=0;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    ll t=it->ft;
    
    if(t==1) continue;
    
    if(N/t==N/(t-1)) {
      if(N/(t-1)==N%(t-1)) ans+=t-1;
    }
    
  }
  
  pt(ans);
  
}









Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

bool prime[1000010];

void eratosthenes(){
    rep(i,1000010) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,1000010){
        if(prime[i]){
            for(int j=i*2; j<1000010; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    ll n;
    cin >> n;
    ll d = n;
    int sqrt_n = (int)sqrt(n);
    int ans = 0;
    eratosthenes();
    rep(i, sqrt_n+1){
        if(d == 1) break;
        if(prime[i]){
            // printf("prime_i = %d\n", i);
            int tmp = 0;
            while(d%i == 0){
                d /= i;
                tmp++;
            }
            // printf("tmp = %d\n", tmp);
            int count = 1;
            while(1){
                tmp -= count;
                if(tmp < 0) break;
                ans++;
                count++;
            }
            // printf("ans = %d\n", ans);
        }
    }
    if(d > sqrt_n){
        ans += 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4656
#include <stdio.h>

int main(void) {

int m,f,r;
	// your code goes here
while(1){
scanf("%d %d %d",&m,&f,&r);

if(m==-1 && f==-1 && r==-1)
 break;
else if(m==-1 || f==-1)
 printf("F\n");
else if(m+f >= 80)
 printf("A\n");
else if(65 <= m+f && m+f < 80)
 printf("B\n");
else if((50 <= m+f && m+f < 65) || r >= 50)
 printf("C\n");
else if(30 <= m+f && m+f < 50)
 printf("D\n");
else if(m+f < 30)
 printf("F\n");
}

	return 0;
}

Measured memory_bytes: 584
import math
a, b, C = (float(x) for x in input().split())
S = a * b * math.sin(math.radians(C)) / 2.0
L = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C))) + a + b
h = b * math.sin(math.radians(C))
print(S)
print(L)
print(h)


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll S; cin >> S;
	ll BIG = sqrt(S) + 1.0;
	if ((BIG-1)*(BIG-1)==S) BIG--;
	print(0, 0, BIG, 1, BIG*BIG-S, BIG);
}

Measured memory_bytes: 256
pub fn main() {
    let mut buf = String::new();
    let (n, k): (usize, usize) = {
        std::io::stdin().read_line(&mut buf).unwrap();
        let words: Vec<usize> = buf.split_whitespace().map(|w| w.parse().unwrap()).collect();
        (words[0], words[1])
    };
    let ps: Vec<f64> = {
        buf.clear();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace().map(|w| w.parse().unwrap()).collect()
    };
    let mut cumsum = vec![0_f64; n + 1];
    for i in 0..n {
        cumsum[i + 1] = cumsum[i] + (ps[i] + 1.0) / 2.0;
    }
    let mut max = cumsum[k] - cumsum[0];
    for i in k + 1..n + 1 {
        let e = cumsum[i] - cumsum[i - k];
        if e > max {
            max = e;
        }
    }
    println!("{}", max);
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

    ll N;
    cin >> N;

    ll S = 0;
    ll tmp = N;

    while(N>0){
        ll amari = 0;
        amari = N % 10;
        S += amari;
        N = (N - amari) / 10;
    }
    if(tmp%S==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    int n;
    str s;
    cin >> n >> s;
    REP(i, s.length()) {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s << "\n";

    return 0;
}


Measured memory_bytes: 256
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
ll ans=0;
void f(vector< int > v1, vector< int > v2, vector< int > v3)
{
	for(int i=0;i<v1.size();i++)
	{
		for(int j=0;j<v2.size();j++)
		{
			if(v2[j]>v1[i])
			{
				bool bo=false;
				if(binary_search(v3.begin(),v3.end(),v2[j]+v2[j]-v1[i]))
					bo=true;
				int x=upper_bound(v3.begin(),v3.end(),v2[j])-v3.begin();
				x=v3.size()-x;
				if(bo)
					x--;
				ans+=x;

			}
		}
	}
}
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
     ll n;
     cin>>n;
     string s;
     cin>>s;
     vector< int > v1,v2,v3;
     for(int i=0;i<s.length();i++)
     	if(s[i]=='R')
     		v1.pb(i);
     	else if(s[i]=='G')
     		v2.pb(i);
     	else
     		v3.pb(i);

     	f(v1,v2,v3);
     	f(v1,v3,v2);
     	f(v2,v1,v3);
     	f(v2,v3,v1);
     	f(v3,v1,v2);
     	f(v3,v2,v1);
     	cout<<ans;
} 

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,x,m=1e10,s=0;
    cin >> n;
    vector< ll >v(n);
    for(i = 0; i < n; i++)cin>>v[i];
        if(n==1){
            cout << 0 << nl;
            return;
        }
    sort( v.begin(), v.end() );
    ll i1 = 0,curp=n-2;
    ll ans = v[n - 1];
    for(i=2;i<n;i++){
        ans+=v[curp];
        i1++;
        if(i1==2){
            i1=0;
            curp--;
        }
    }
    cout << ans << nl;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main(){
	long long  N, M;
	std::cin >> N >> M;
	std::vector<int> A;
	int tmp = 0;
	while(std::cin >> tmp){A.push_back(tmp);}
	long long sum = 0;
	for(const int x : A){
		sum += x;
	}
	if(N - sum >= 0){
		std::cout << N - sum << std::endl;
	}else{
		std::cout << -1 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<string>
#include<ctype.h>
#include<iomanip>

int main() {
	long double N = 0.0;
	long double K = 0.0;
	long double p = 0.0;
	long double p_sum = 0.0;
	long double point = 0.0;
	std::cin >> N;
	std::cin >> K;

	for (int i = 1; i <= N; i++) {
		point = i;
		p = 1.0 / N;
		if (point >= K) {
			p_sum += p;
			p = 0.0;
			continue;
		}
		else {
			for (int j = 0; j < K; j++) {
				point *= 2.0;
				p *= 1.0 / 2.0;
				if (point >= K) {
					break;
				}
			}
			p_sum += p;
			p = 0.0;
		}

	}

	std::cout << std::fixed << std::setprecision(12) << p_sum << std::endl;

}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Po pop_back
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    LL cnt = 0, mx = 1e12;
    for(LL i = 0; i < n; i++){
        LL a;
        cin >> a;


        if(a <= mx)
            cnt++;
        mx = min(mx, a);
    }
    cout << cnt << '\n';
    return 0;
}




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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}


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

    // 高橋は12回しかない
    ll a=in(), b=in();
    ll res;

    if (a <= b) {
        res = a;
    } else {
        res = a - 1;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
  w, q = map(int, input().split())
  if w == 0 and q == 0:
    break
  wall = [None] * w
  for _ in range(q):
    inp = input().split()
    if inp[0] == "s":
      ind, wid = int(inp[1]), int(inp[2])
      for i in range(w - wid + 1):
        if all(x == None for x in wall[i:i + wid]):
          print(i)
          for j in range(i, i + wid):
            wall[j] = ind
          break
      else:
        print("impossible")
    else:
      ind = int(inp[1])
      for i in range(w):
        if wall[i] == ind:
          wall[i] = None
  print("END")


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

int main() {
    int n,max_v=100100;long long W;cin>>n>>W;
    long long w[n],v[n],dp[n+1][max_v];
    for(int i=0;i<n+1;i++) for(int j=0;j<max_v;j++) dp[i][j]=1000000000000;dp[0][0]=0;
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    for(int i=0;i<n;i++){
        for(int sum=0;sum<max_v;sum++){
            if(sum>=v[i]) dp[i+1][sum]=min(dp[i+1][sum],dp[i][sum-v[i]]+w[i]);
            dp[i+1][sum]=min(dp[i+1][sum],dp[i][sum]);
        }
    }
    long long ans=0;
    for(long long j=0;j<max_v;j++){
        if(dp[n][j]<=W) ans=max(ans,j);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int f[9];

int main(){
	int n,a;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> a;
		if(a<=399)
			f[0]++;
		else if(a<=799)
			f[1]++;
		else if(a<=1199)
			f[2]++;
		else if(a<=1599)
			f[3]++;
		else if(a<=1999)
			f[4]++;
		else if(a<=2399)
			f[5]++;
		else if(a<=2799)
			f[6]++;
		else if(a<=3199)
			f[7]++;
		else
			f[8]++;
	}
	int diff=0;
	for(int i=0;i<8;i++)
		if(f[i])
			diff++;
	if(diff==0){
             cout << "1" << " " << f[8] << endl;return 0;}
	int can=f[8];
	cout << diff << " " << diff+can << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <long long> l(n);
    rep(i,n) cin >> l[i];

    int cnt=0;
    for(int i = 0; i<=n-3; i++){
        for(int j=i+1; j<=n-2; j++){
            for(int k=j+1; k<=n-1; k++){
                if(l[i] != l[j]){
                    if(l[j] != l[k]){
                        if(l[k] != l[i]){
                            if((l[i] < l[j]+l[k])&&(l[j]<l[i]+l[k])&&(l[k]<l[i]+l[j])){
                                cnt ++;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String atg[])
	{		
		Scanner sc = new Scanner(System.in);
		String s[] = new String[2002];
		int index = 0;
		while(sc.hasNext())
		{
			String str = sc.next();
			s[index] = str;
			index++;
		}

		int r[] = new int [index];
		boolean flag[] = new boolean[2002];
		Arrays.fill(flag, true);
		int fre=0;
		for(int i=0; i<index; i++)
		{
			for(int j=i+1; j<index; j++)
			{
				if(s[i].equals(s[j])&&flag[j]==true)
				{
					r[i]++;
					flag[j]=false;
				}
			}
		}
		int max=0;
		int maxin=0;
		for(int i=0; i<index; i++)
		{
			if(max < r[i])
			{
				max=r[i];
				maxin = i;
			}
		}
		System.out.print(s[maxin]+" ");
		max =0;
		for(int i=0; i<index; i++)
			if(s[max].length()<s[i].length())
			{
				max =i;
			}
		System.out.println(s[max]);
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int D;
    scanf("%d", &D);

    printf("%s\n",
        D == 25 ? "Christmas" : 
        D == 24 ? "Christmas Eve" : 
        D == 23 ? "Christmas Eve Eve" : "Christmas Eve Eve Eve"
    );

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b){
    say(0);
    return 0;
  }
  if(n == 1){
    if(a == b){
      say(1);
    }else{
      say(0);
    }
    return 0;
  }
  cout << ((b*(n - 1) + a) - (a*(n - 1) + b)) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, x, tmp = INT_MAX, cnt = 0;

    cin >> n;

    while (n--) {

        cin >> x;

        tmp = min(tmp, x);

        if (tmp == x) cnt++;
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int v[51];

int deep[51];

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

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

void _union(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        else if(deep[x] > deep[y]){
                v[y] = x;
        }else{
                if(deep[x] == deep[y])deep[y]++;
                v[x] = y;
        }
        return;
}

int main(){
        int i,j,N,M,sum,ans=0;
        cin >> N >> M;
        int fir[M],las[M];
        for(i=0;i<M;i++){
                cin >> fir[i] >> las[i];
        }
        for(i=0;i<M;i++){
                sum = 0;
                for(j=0;j<=N;j++){
                        v[j] = j;
                        deep[j] = 0;
                }
                for(j=0;j<M;j++){
                        if(i != j){
                                _union(fir[j],las[j]);
                        }
                }
                sum = 0;
                for(j=1;j<=N;j++){
                        if(same(1,j) == true){
                                sum++;
                        }
                }
                if(sum != N)ans++;
                /*for(j=1;j<=N;j++){
                        cout << v[j];
                }
                cout << endl;*/
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

int f(pair<int, int> A, pair<int, int> B) {
	return abs(A.first - B.first) + abs(A.second - B.second);
}
void solve() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> G(N), C(M);
	for (int i = 0; i < N; ++i) {
		cin >> G[i].first >> G[i].second;
	}
	for (int i = 0; i < M; ++i) {
		cin >> C[i].first >> C[i].second;
	}
	for (int i = 0; i < N; ++i) {
		int ans = 0;
		int len = INF;
		for (int j = 0; j < M; ++j) {
			int res = f(G[i], C[j]);
			if (len > res) {
				ans = j;
				len = res;
			}
		}
		cout << ans + 1 << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if (1<=m2&&m2<=12&&d2==1)  cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
const int M=1e5+10;
int n;
P m[2],s[2];
int a[2][M];
void fm(int x)
{
    //for(auto item: a[x])
    for(int i=0;i<M;i++)
    {
        P item=P(i,a[x][i]);
        if(item.se>m[x].se)
        {
            s[x]=m[x];
            m[x]=item;
        }
        else if(item.se>s[x].se)
            s[x]=item;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i&1][x]++;
    }
    fm(0),fm(1);
    if(m[0].fi==m[1].fi)
        printf("%d\n",n-max(m[0].se+s[1].se,m[1].se+s[0].se));
    else
        printf("%d\n",n-m[0].se-m[1].se);
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#include<math.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    double x[3];
    int n;
    double e;

    while(cin >> x[0] >> x[1] >> x[2], x[2]){
        sort(x, x + 3);
        cin >> n;
        rep(i,n){
            cin >> e;
            if( sqrt(x[0] * x[0] + x[1] * x[1]) < 2 * e ){
                cout << "OK" << endl;
            }else{
                cout << "NA" << endl;
            }
        }

    }
}

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include<list>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string X;

int main() {
	cin >> X;

	stack<char> S;
	for (int i = 0; i < X.length(); i++) {
		if (S.empty()) S.push(X[i]);
		else {
			char tmp = S.top();
			if (tmp == 'S' && X[i] == 'T') S.pop();
			else S.push(X[i]);
		}
	}

	cout << S.size();
	return 0;
}

Measured memory_bytes: 1156
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    int[] a = readln.split.to!(int[]);

    a.sort!"a < b";
    auto g = a.group.array;
    g.sort!((x, y) => x[1] < y[1]);
    int cnt;
    while (g.length > k)
    {
        cnt += g[0][1].to!int;
        g.popFront;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 11420
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int a,b,c;
    int ans=0;
    cin>>a>>b>>c;
    int x,y,z;
    x=max(a,max(b,c));
    y=min(a,min(b,c));
    z=a+b+c-x-y;
    if(x-y>=1&&x-z>=1)
    {
        y+=(x-z);
       ans+=(x-z);
       z=x;

    }
    ans+=(x-y)/2;
    y+=(x-y)/2*2;
    if(y==x-1)
    {
        ans+=2;
    }
    cout<<ans<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N;	
	long long x;
	long long *a;

	int i;
	long long candy_eaten = 0;	

	scanf("%d %lld", &N, &x);

	a = (long long*)malloc(sizeof(long long) * N);

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

	for(i=1; i<N; i++){
		// 手前２箱のキャンディの合計がxより多いとき
		if(a[i] + a[i-1] > x){
			// そのうち２番目の箱のキャンディだけを食べれば良いとき
			if(a[i-1] <= x){
				candy_eaten += a[i] + a[i-1] - x;
				a[i] = x - a[i-1];
			}else{
				candy_eaten += a[i] + a[i-1] - x;
				a[i] = 0;
				a[i-1] -= x - a[i];
				
			}
		}else{

		}
	}	

	printf("%lld\n", candy_eaten);

	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		// TODO 自動生成されたメソッド・スタブ
		int i,n;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		int a[] = new int[n];

		for(i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		for(i=0; i<n; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(a[n-i-1]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

 
const int N=1e5+5;
 
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	
	//dp[i] - Maximum cost of task i
	vector<int>dp(3,0);
	while(n--){

		vector<int>new_dp(3,0);
		vector<int>cost(3);

		for(int i=0; i<3; ++i)
			cin>>cost[i];

		//fix one and take the other two to find the sum
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				if(i!=j)
					new_dp[j] = max(new_dp[j], dp[i]+cost[j]);
			}
		}

		dp = new_dp;
	}

	//output would be the maximum of the dp array
	cout<<*max_element(dp.begin(), dp.end());

	return 0;
}

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

using namespace std;

#define ll long long

int main(void){
    ll A, V; cin >> A >> V;
    ll B, W; cin >> B >> W;
    ll T; cin >> T;
    if (W >= V){
        cout << "NO" << endl;
    } 
    else{
        ll D = abs(A - B);
        if (D <= T * (V - W)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
using namespace std;
using ll = long long;
ll a[200005];
ll n;
int main(){
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,[](int a,int b){return a>b;});
	if(n==2) {
		cout<<a[0]<<endl;
		exit(0);
	}
	n--;
	ll t;
	ll q = n;
	if(n&1){
		t = (n-1)/2;
		t++;
	}
	else{
		n++;
		t = (n-1)/2;
		t++; 
	}
	ll ans = a[0];
	for(ll i=1;i<t;i++){
		ans += 2LL * a[i];
	}
	if(q%2 == 0){
		ans -= a[t-1];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    //long long int sum=0;
    if(k>(a+b))
    {
        cout<<a*1+b*0+(k-a-b)*(-1)<<endl;;
    }else
    if(k>a)
    {
        cout<<a*1;
    }
    if(k<=a)
    {
        cout<<k;
    }
    //cout<<sum<<endl;
}


Measured memory_bytes: 3592
n,k=map(int,input().split())
d=[]

c=[]
b=[list(map(int, input().split())) for i in range(2*k)]

for i in range(1,2*k,2):
  for j in range(len(b[i])):
    c.append(b[i][j]) 

d=set(c)
print(n-len(d))



Measured memory_bytes: 68060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int a[100000];

int main() {
  int n,t;
  cin >> n >> t;
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  ll ans = 1;
  const ll mod = 1e9+7;
  int id = 0;
  REP(i,n) {
    while(id<n && a[id]<=a[i]+t) id++;
    ll num = id-i;
    ans = ans * num % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1560