akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int N, P[10], highest_key = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        if(P[highest_key] < P[i]){
            highest_key = i;
        }
    }
    int res = 0;
    for (int j = 0; j < N; ++j) {
        if(j != highest_key) {
            res += P[j];
        }else{
            res += P[j]/2;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int H,W,K;
ll dp[105][10];
ll p[10];

ll f(int x){
	if(x<=1)return 1LL;
	return p[x];
}


int main()
{
	cin >> H >> W >> K;

	p[0]=1LL;
	p[1]=1LL;
	rep(i,2,10)p[i]=p[i-1]+p[i-2];

	dp[0][1] = 1;
	rep(i,1,H+1){
		rep(j,1,W+1){
			if(j>1){
				dp[i][j] += f(j-2)*f(W-j)*dp[i-1][j-1];
			}
			dp[i][j] %= MOD;
			if(j<W){
				dp[i][j] += f(j-1)*f(W-j-1)*dp[i-1][j+1];
			}
			dp[i][j] %= MOD;
			dp[i][j] += f(j-1)*f(W-j)*dp[i-1][j];
			dp[i][j] %= MOD;
		}
	}

	cout << dp[H][K] << 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++)
int main()
{
    int a, b;
    cin >> a >> b;
	
  	int ans = a * b - a - b + 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (n, x): (usize, u64) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let mut i = s.split_whitespace();
        (i.next().unwrap().parse().unwrap(), i.next().unwrap().parse().unwrap())
    };
    let l: Vec<u64> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.split_whitespace().map(|e| e.parse().unwrap()).collect()
    };

    let mut d: Vec<u64> = vec![0; n + 1];
    for i in 0..n {
        d[i + 1] = d[i] + l[i]
    };

    let mut ans = 0;
    for e in d.into_iter() {
        if e <= x {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int n;
    cin >> n;
    string ans;
    switch(n%10){
        case 3:
            ans = "bon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            ans = "pon";
            break;
        default:
            ans = "hon";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL);
 
 
int main()
{
	FASTIO;
	int n,r;
  cin>>n>>r;
  if(n>=10) 
    cout<<r<<endl;
  else 
    cout<<r+100*(10-n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}








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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

struct sta{
  int x;
  int y;
  int d;
};

int main(){
  while(1){
    int h,w;
    LL l;
    cin >> h >> w >> l;
    if(h==0) return 0;
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    int sx,sy,d;
    rep(i,h){
      rep(j,w){
        if(f[i][j]!='.'&&f[i][j]!='#'){
          sx=i,sy=j;
          if(f[i][j]=='N') d=0;
          else if(f[i][j]=='E') d=1;
          else if(f[i][j]=='S') d=2;
          else d=3;
          f[i][j]='.';
          break;
        }
      }
    }
    vector<int> vx={-1,0,1,0};
    vector<int> vy={0,1,0,-1};
    vector<vector<vector<vector<sta>>>> nxt(h,vector<vector<vector<sta>>>(w,vector<vector<sta>>(4,vector<sta>(64))));
    rep(i,h){
      rep(j,w){
        rep(k,4){
          nxt[i][j][k][0]={0,0,0};
          if(f[i][j]=='#') continue;
          int nowd=k;
          rep(l,4){
            int nx = i+vx[nowd];
            int ny = j+vy[nowd];
            if(0<=nx&&nx<h&&0<=ny&&ny<w){
              if(f[nx][ny]!='#'){
                nxt[i][j][k][0]={nx,ny,nowd};
                break;
              }
            }
            nowd=(nowd+1)%4;
          }
        }
      }
    }
    repp(t,1,64){
      rep(i,h){
        rep(j,w){
          rep(k,4){
            auto &st = nxt[i][j][k][t-1];
            auto &st2 = nxt[st.x][st.y][st.d][t-1];
            nxt[i][j][k][t]=st2;
          }
        }
      }
    }
    int c=0;
    while(l){
      if(l&1LL){
        auto &st = nxt[sx][sy][d][c];
        sx = st.x;
        sy = st.y;
        d = st.d;
      }
      l>>=1;
      c++;
    }
    cout << sx+1 SP sy+1 << " ";
    if(d==0) cout << 'N';
    else if(d==1) cout << 'E';
    else if(d==2) cout << 'S';
    else cout << 'W';
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 35244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < c && c < b) System.out.println("Yes");
        else if(a > c && c > b) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35828
#include <stdio.h>

int main(void)
{
	int i, ko, colar, ans;
	
	scanf("%d %d", &ko, &colar);
	
	ans = colar;
	for (i = 1; i < ko; i++)
		ans *= (colar - 1);
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        if (a1+a2+a3 <= 21)
        {
            System.out.println("win");
        }else
        {
            System.out.println("bust");
        }

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 23892
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * D - .. (Double Dots)
 * <p>
 * https://atcoder.jp/contests/abc168/tasks/abc168_d
 */

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split(" ");
    int n = Integer.parseInt(input[0]);
    int m = Integer.parseInt(input[1]);
    ArrayDeque<Integer> vQueue = new ArrayDeque<>();
    List<Integer> toVList[] = new ArrayList[n + 1];
    int[] distance = new int[n + 1];
    int[] marks = new int[n + 1];
    Arrays.fill(distance, -1);
    distance[0] = 0;
    distance[1] = 0;

    for (int i = 0; i < m; i++) {
      String[] atob = sc.nextLine().split(" ");
      int a = Integer.parseInt(atob[0]);
      int b = Integer.parseInt(atob[1]);
      if(toVList[a] == null){
        toVList[a] = new ArrayList<Integer>();
      }
      toVList[a].add(b);

      if(toVList[b] == null){
        toVList[b] = new ArrayList<Integer>();
      }
      toVList[b].add(a);
    }
    vQueue.add(1);
    while (!vQueue.isEmpty()) {
      Integer v = vQueue.pollFirst();
      List<Integer> nextVList = toVList[v.intValue()];
      for (Integer nextV : nextVList) {
        if(distance[nextV.intValue()] == -1) {
          distance[nextV.intValue()] = distance[v.intValue()] + 1;
          marks[nextV.intValue()] = v.intValue();
          vQueue.addLast(nextV);
        }
      }
    }
    System.out.println("Yes");
    for (int i = 2; i < marks.length; i++) {
      System.out.println(marks[i]);
    }
  }
}

Measured memory_bytes: 79600
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 1005


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

    int n,x;
    map<int,bool>mp;
    cin>>x>>n;
    for(int i=1;i<=n;i++){
      int ar;cin>>ar;
      mp[ar]=1;
    }
    int mn=INT_MAX,ans;
    for(int i=-100;i<=200;i++){
      if(!mp[i]&&abs(i-x)<mn){
         ans=i;
         mn=abs(i-x);
      }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3628
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] -= 1
cur = h[0]
for i in range(1, n):
    if h[i] < cur:
        print('No')
        exit()
    else:
        cur = h[i]
print('Yes')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n)    cin>>h.at(i);

    bool ans=true;
    for(int i=n-1;i>0;i--) {
        if(h[i]<h[i-1]) {
            h[i-1]--;
            if(h[i]<h[i-1]) {
                ans=false;
                break;
            }
        }
    }

    if(ans==true)   cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    
 return 0;
}

Measured memory_bytes: 640
from collections import Counter

N, M, K = map(int, input().split())
MOD = 998244353

factorial = [1]
for i in range(1, N + 1):
    factorial.append(factorial[-1] * i % MOD)
inv_factorial = [-1] * (N + 1)
inv_factorial[-1] = pow(factorial[-1], MOD - 2, MOD)
for i in reversed(range(N)):
    inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % MOD

ans = 0
for j in range(K + 1):
    ans += (
        pow(M - 1, N - 1 - j, MOD)
        * factorial[N - 1]
        * inv_factorial[j]
        * inv_factorial[N - 1 - j]
        % MOD
    )
    if ans >= MOD:
        ans -= MOD
ans = ans * M % MOD
print(ans)


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

int niz[200010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> niz[i];
    
    sort(niz, niz + n);
    ll sum = 0;
    for(int i = 0; i < n - k; i++)
        sum += niz[i];
    cout << sum;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(a-1)<<' ';
  ll b=-1;
  ll c=vec.at(a-1);
  ll d=-100;
  ll e;
  for(ll i=0;i<a;i++){
    if(b==-1){
      if(vec.at(i)>c/2){
        b=i;
      }
    }
    vec.at(i)=min(vec.at(i),c-vec.at(i));
    if(vec.at(i)>d){
      d=vec.at(i);
      e=i;
    }
  }
  if(e>=b){
    d=c-vec.at(e);
  }
  cout<<d<<endl;
      
  return 0;
}


Measured memory_bytes: 4044
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int A[100][50];
int B[50];

int main() {
  	//freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);
	int n;
	cin>>n;
	string s;
	rep(i, n) {
		cin>>s;
		rep(j, s.size()) {
			A[i][s[j]-'a']++;
		}
	}

	rep(i, 26) {
		int minm = 100;
		rep(j, n) {
			minm = min(minm, A[j][i]);
		}
		B[i] = minm;
	}

	char ch;
	rep(i, 26) {

		rep(j, B[i]) ch = 'a'+i, cout<<ch;
	}


	return 0;
}


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

int main() {
	int n; cin >> n;
	int a = n / 4;
	int b = n / 7;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			if (4*i + 7*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int X[M];
  REP(i,M)cin>>X[i];
  if(N>=M){
    cout<<0<<endl;
    return 0;
  }
  sort(X,X+M);
  vector<int> v;
  REP(i,M-1)v.push_back(X[i+1]-X[i]);
  sort(ALL(v));
  lint ans=0;
  REP(i,M-N){
    ans+=v[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  string S,s="";
  cin >> N >> S;
  vector<char> C(0);
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='('){
      C.push_back('(');
      s+="(";
    }
    else if(S.at(i)==')'){
      if(C.size()>0){
        s+=")";
        C.pop_back();
      }
      else s="("+s+")";
    }
  }
  while(C.size()>0){
    s+=")";
    C.pop_back();
  }
  cout << s << endl;
}

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

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

	int ans = 0;
	for( int n = A; n <= B; n++ ) {
		char s[16];
		sprintf( s, "%d", n );
		string ss( s );
		int l = 0;
		int r = ss.size() - 1;
		int flag = 0;
		while( r > l ) {
			if( ss[l] != ss[r] ) {
				flag = 1;
				break;
			}
			l++;
			r--;
		}
		if( flag == 0 ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(i<10){
      ans++;
    }else if(i>=100&&i<1000){
      ans++;
    }else if(i>=10000&&i<100000){
      ans++;
    }
  }
  cout<<ans<<endl;
  
}

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


void solve()
{
  int N, M;
  cin >> N >> M;
  vector<int> G[N];
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }
  vector<int> ans;
  rep(i,N){
    vector<bool> used(N);
    queue<int> Q;
    queue<vector<int>> P;
    used[i] = true;
    Q.push(i);
    vector<int> tmp;
    tmp.push_back(i);
    P.push(tmp);
    while(Q.size()){
      int u = Q.front();
      Q.pop();
      auto p = P.front();
      P.pop();

      for(auto v : G[u]){
	if(used[v]){
	  //cout << v <<  " " << p << endl;
	  if(v!=p[0])continue;
	  if(ans.size()==0 || p.size()<ans.size()){
	    ans=p;	    
	  }
	}
	else{
	  used[v]=true;
	  Q.push(v);
	  p.push_back(v);
	  P.push(p);
	  p.pop_back();
	}
      }
    }
  }
  if(ans.size()==0)cout << -1 << endl;
  else{
    cout << ans.size() << endl;
    for(auto v : ans){
      cout << (v+1) << endl;
    }
  }
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);
  solve();
  return 0; 
}


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

#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )
#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )

#define LIM 219980131
#define N 10
int d[ N ][ N ];

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j, k;

  for ( ; ; )
  {
    int res = -1, sum = LIM;
    int dn = 0;
    int n;

    for ( i = 0; i < N; ++i )
    for ( j = 0; j < N; ++j )
    {
      d[ i ][ j ] = ( i == j ? 0 : LIM );
    }

    scanf ( "%d", &n );
    if ( n == 0 ) break ;
    for ( i = 0; i < n; ++i )
    {
      int a, b, c;

      scanf ( "%d%d%d", &a, &b, &c );
      d[ a ][ b ] =
      d[ b ][ a ] = c;

      dn = MAX( dn, MAX( a, b ) );
    }

    for ( k = 0; k <= dn; ++k )
    for ( i = 0; i <= dn; ++i )
    for ( j = i + 1; j <= dn; ++j )
    {
      d[ i ][ j ] =
      d[ j ][ i ] = MIN( d[ i ][ j ], d[ i ][ k ] + d[ k ][ j ] );
    }

    for ( i = 0; i <= dn; ++i )
    {
      int s = 0;

      for ( j = 0; j <= dn; ++j )
      {
        s += d[ i ][ j ];
      }

      if ( s < sum )
      {
        res = i;
        sum = s;
      }
    }

    printf ( "%d %d\n", res, sum );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

string S;

bool is_month(string s) {
    return s > "00" && s < "13";
}

int main() {
    cin >> S;
    string first = S.substr(0, 2);
    string second = S.substr(2, 2);
    string ans = "";
    if (is_month(first) && is_month(second)) ans += "AMBIGUOUS";
    else if (is_month(first)) ans += "MMYY";
    else if (is_month(second)) ans += "YYMM";
    else ans += "NA";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  int ans;string N;cin>>N;
  if(N[1]=='R'){
    if(N[0]=='R'||N[2]=='R'){
      if(N[0]==N[2])ans=3;
      else ans=2;
    }
    else ans=1;
  }
  else{
    if(N[0]=='R'||N[2]=='R')ans=1;
    else ans=0;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(void){
    long int n,m,r;
    cin >> n >> m;
    if(n==1){
        cout << m << endl;
        return 0;
    }
    r = m/n;
    if(m%n==0){
        cout << r << endl;
        return 0;
    }
    bool g[r];
    for(int i=1;i<=r;i++){
        g[i]=true;   
    }
    for(int i=2;i<=r;i++){
        if(g[i]){
            if(m%i){
                for(int j=1;j*i<=r;j++){
                    g[j*i]=false;
                }
            }
        }
    }
    for(int i=r;i>0;i--){
        if(g[i]){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 52608
#include<stdio.h>

int main(){
  int i,j,k=0;
  int N;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d ",&j);
    if(k > j){
      puts("No");
      return 0;
    }
    else if(k==j){
      k=j;
    }
    else
      k=(j-1);
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(a) inp(b)
	cout<<a*b<<'\n';
	printclock;
}

Measured memory_bytes: 3796
s = list(str(input()))
f = [s[0],s[1]]
d = int("".join(f))
f = [s[2], s[3]]
e = int("".join(f))
if (d > 12 or d == 0) and (12 >= e > 0):
    print("YYMM")
elif (12 >= d > 0) and (e > 12 or e == 0):
    print("MMYY")
elif (12>=d>0)and(12>=e>0):
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
function Main(input) {
    // console.log(input);
    var tmp = input.split("\n");
    var a = [];
    for (var i = 0; i < 5; i++) {
        a.push(parseInt(tmp[i]));
    }
    var k = parseInt(tmp[5]);
    
    var max = Math.max(...a);
    var min = Math.min(...a);
    
    if (max - min > k) {
        console.log(":(")
    } else {
        console.log("Yay!")
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def p(s):
    f=1
    for i in range(0,len(s)//2):
        if s[i]!=s[len(s)-1-i]:
            f=0
            break
    return f 
s=input()
n=len(s)
if p(s):
    if p(s[:n//2]) and p(s[n//2 + 1:]):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	mk := m - (1 - m%2)
	mg := m - m%2
	idx := 1
	for i := mk; i >= 1; i -= 2 {
		fmt.Printf("%d %d\n", idx, idx+i)
		idx++
	}
	idx = mk + 2
	for i := mg; i >= 2; i -= 2 {
		fmt.Printf("%d %d\n", idx, idx+i)
		idx++
	}
}


Measured memory_bytes: 3376
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    int number;
    long long answer[21] = {0};
    int i = 0;
    long long sum = 0;
    int x;
    while (cin >> number)
    {
        x = (600 / number);
        REP(k, x)
        {
            sum+= (k*number)*(k*number)*(number);
        }
        //cout << tempsum << endl;
        answer[i] = sum;
        sum = 0;
        i++;
    }
    REP(j, i)
    cout << answer[j] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
	
	int s;
	scanf("%d",&s);
	int h=s/3600,m;
	
	s-=h*3600;
	m=s/60;  s-=m*60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}



Measured memory_bytes: 2024
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    F=[]
    for i in range(N):
        f=int("".join(readline().strip().split(" ")),2)
        F.append(f)
    P=[]
    for i in range(N):
        p=list(map(int,readline().split()))
        P.append(p)
    
    max_res=float("-inf")
    for output in range(1,1<<10):
        res=0
        for j in range(N):
            c=bin(output&F[j]).count("1")
            res+=P[j][c]
        max_res=max(res,max_res)

    print(max_res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#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 repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	char c;
	cin >> c;
	cout << (char)(c+1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  int L[256];
  for (int i = 0; i < 2 * N; ++i) {
    L[i] = in();
  }
  sort(L, L + 2 * N);

  int res = 0;
  for (int i = 0; i < N; ++i) {
    res += L[2 * i];
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int N;
  cin >> N;
  vector<int> S(20);
  rep(i, N){
    int a; cin >> a;
    S[a / 400]++;
  }
  ll ans = 0;
  ll m = 0;
  rep(i, 8){
    ans += (S[i] > 0);
  }
  m = ans;
  for(int i = 8; i < 20; i++){
    ans += S[i];
  }
  cout << max(m, 1) << " ";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
#include <cstdio> 
int main() 
{ 
int D;
    scanf ("%d", &D);
    
    if (D == 25)
    {
        printf("Christmas");
    }
    
    else if (D == 24)
    {
        printf ("Christmas Eve");
    }
    
    else if (D == 23)
    {
        printf ("Christmas Eve Eve");
    }

    else if (D == 22)
    {
        printf ("Christmas Eve Eve Eve");
    }

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int N=2e5+7;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll a[N],b[N];
struct sa
{
    int a;
    int b;
}p[N];
int cmp(const sa &a,const sa &b)
{
    if(a.b!=b.b)
    return a.b<b.b;
    else
        return a.a<b.a;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i].a>>p[i].b;
    sort(p+1,p+n+1,cmp);
    int f=1;
    int x=0;
    for(int i=1;i<=n;i++)
    {
        if(x+p[i].a>p[i].b)
        {
            f=0;
            break;
        }
        else
            x+=p[i].a;
    }
    if(f==0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
mod=10**9+7
ans=0
a=0
b=0
for i in range(k):
    a+=n-i
    b+=i
for i in range(k,n+2):
    ans+=(a-b+1)
    ans%=mod
    a+=n-i
    b+=i
print(ans)

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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=5e5+1;
const int M=1e9+7;
ll fac[MAXN];
ll infac[MAXN];
 
ll modexp(ll a,ll b){
	if(b==0)
		return 1;
	if(b%2==0){
		return modexp((a*a)%M,b/2);
	}
	else{
		return (a*modexp((a*a)%M,b/2))%M;
	}
}
 
ll modinver(ll num){
 
	return modexp(num,M-2);
}
 
void intialise(){
	fac[0]=1;
 
	for(int i=1;i<MAXN;i++){
		fac[i]=(fac[i-1]*i)%M;
	}
 
	infac[MAXN-1]=modinver(fac[MAXN-1]);
 
	for(int i=MAXN-2;i>=0;i--){
		infac[i]=(infac[i+1]*(i+1))%M;
		//cout<<i<<" "<<infac[i]<<endl;
	}
}
 
ll ncr(ll n,ll r){
	if(r>n)
		return 0;
 
	ll ans=fac[n];
	ans=(ans*infac[r])%M;
	ans=(ans*infac[n-r])%M;
 
	return ans;
}

ll npr(ll n,ll r){
	if(r>n)
		return 0;
 
	ll ans=fac[n];
	ans=(ans*infac[n-r])%M;
 
	return ans;
}

int main(){
 	
 	intialise();

 	int n,m;
 	sfi(n) sfi(m)

 	ll tot=0;

 	for(int i=0;i<=n;i++){
 		ll temp=ncr(n,i);
 		temp=(temp*npr(m-i,n-i))%M;

 		if(i&1){
 			tot=(tot-temp+M)%M;
 		}
 		else{
 			tot=(tot+temp)%M;
 		}
 	}

 	tot=(tot*npr(m,n))%M;

 	pfln(tot)
 	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int ans = n / 2;
  if (n % 2 != 0) ans += 1;
  cout << ans << endl;
  
  return 0;
}


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

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

    int tmp;
    string result = "APPROVED";
    for(int i=0; i<N; i++)
    {
        cin >> tmp;
        if(tmp%2==0)
        {
            if((tmp%3!=0) && (tmp%5!=0)) result = "DENIED";
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
          fscanf(STDIN, "%d %d %d", $a, $b,$c);
        $input=array($a,$b,$c);
        $input = str_replace(PHP_EOL, '', $input);
        $cnt=array_count_values($input);
$max = max($cnt); 
        if ($max == 2) {
                echo "Yes";
            } else {
                echo "No";
            }
        ?>

Measured memory_bytes: 3700
n, k = map(int, input().split())
x = list(map(int, input().split()))
pl, mi = 0, 0
recp, recm = [], []
for i in range(n):
    if x[i] >= 0:
        pl += 1
        recp.append(x[i])
    else:
        mi += 1
        recm.append(x[i])

num = float("inf")
recm = recm[:: -1]
for i in range(pl + 1):
    if i == 0:
        if k <= mi:
            num = min(num, abs(recm[k - 1]))
        else:
            continue
    else:
        if k - i == 0:
            num = min(num, recp[k - 1])
        elif 0 < k - i <= mi:
            num = min(num, recp[i - 1] + 2 * abs(recm[k - i - 1]))
            num = min(num, 2 * recp[i - 1] + abs(recm[k - i - 1]))

print(num)


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

public class Main {
	
	static int M[][];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt(); M=new int[n][n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++)M[i][j]=-1;
		}
		
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()), k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++) {
				int v=Integer.parseInt(in.next()), c=Integer.parseInt(in.next());
				M[u][v]=c;
			}
		}
		
		dijkstra(n);
	}
	
	static void dijkstra(int n) {
		int INF=2000000000,d[]=new int[n], p[]=new int[n];
		char color[]=new char[n];
		
		for(int i=0;i<n;i++) {
			d[i]=INF;
			color[i]='W';
		}
		
		d[0]=0; p[0]=-1;
		
		while(true) {
			int mincost=INF, u=-1;
			for(int i=0;i<n;i++) {
				if(color[i]!='B' && d[i]<mincost) {
					mincost=d[i];
					u=i;
				}
			}
			
			if(mincost==INF)break;
			color[u]='B';
			
			for(int v=0;v<n;v++) {
				if(color[v]!='B' && M[u][v]!=-1) {
					if(d[v]>M[u][v]+d[u]) {
						p[v]=u;
						d[v]=M[u][v]+d[u];
						color[v]='G'; 
					}
				}
			}
		}
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			out.println(i+" "+d[i]);
		}
		out.flush();
	}
}



Measured memory_bytes: 39560
#include<bits/stdc++.h>
 using namespace std;
 inline int read(){
    int x=0,f=1; char ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
 }
 int N,K,a[100001];
 int main(){
 	cin>>N>>K;
 	for (int i=1; i<=N; i++){
 		a[i]=read();
 	}
 	sort(a+1,a+N+1);
 	int sum=0;
 	for (int i=1; i<=K; i++) sum += a[i];
 	printf("%d\n",sum);
	return 0;
 }
 
 

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int sum = 0;
    for(int i = 0;i<=b;i++){
        sum = a*i;
        if(sum%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

int main() {
    string s;
    cin >> s;
    string ans;
    int n = s.size();
    rep(i, 0, n){
        if(s[i] == '0')ans += '0';
        if(s[i] == '1')ans += '1';
        if(s[i] == 'B'){
            if(ans.size() > 0)ans.erase(ans.size()-1);
            else continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>

using namespace std;

int main(){
    int k;
    string s;
    cin >> k;
    cin >> s;
    int slen = s.length();
    if(k < slen){
        s.erase(k);
        cout << s << "..." << endl;
        return 0;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef int out[33];
void solve(int i,int n,out o);
int main(void){
  int n;
  out o;
  while(1){
    scanf("%d",&n);
    if(!n) break;
    o[0]=n;
    solve(1,n,o); 
  }
}

void solve(int i,int n,out o){
  if(n==0){
    for(int j=1;j<i;j++){
      printf("%d",o[j]);
      if(j==i-1)puts("");
      else printf(" ");
    }
    return;
  }
  if(n<0) return;

  for(int j=o[i-1];j>0;j--){
    o[i]=j;
    solve(i+1,n-j,o);
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







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

    int to[N];
    rep(i,N) {
        ll mn = INF;
        int idx = 0;
        rep(j,M) {
            int dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dis < mn) {
                mn = dis;
                idx = j;
            }
        }
        to[i] = idx + 1;
    }

    rep(i,N) out(to[i]);
    
    return 0;
}









Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 1234560
#endif

int N,M;
vector<int> A(SIZE);

pair<int,int> count(string s) {
    int l = 0, r = 0;
    int tmp = 0;
    for (char c:s) {
        if (c=='(') tmp++;
        else tmp--;
        chmax(r,-tmp);
    }
    reverse(ALL(s));
    tmp=0;
    for (char c:s) {
        if (c=='(') tmp++;
        else tmp--;
        chmax(l,tmp);
    }
    return {l,r};
}

void solve(int _t) {
    cin>>N;
    string s;
    map<int,vector<pair<int,int>>> B;
    vector<pair<int,int>> S,E;
    REP(i,N) {
        cin>>s;
        auto r = count(s);
        if (r.second <= r.first) {
            S.push_back({r.second,r.first});
        }
        else {
            E.push_back(r);
        }
    }
    sort(ALL(S));
    sort(ALL(E));
    reverse(ALL(E));
    int cnt=0;
    for (auto q:S) {
        cnt -= q.first;
        if (cnt < 0) {
            _PN("No");
            return;
        }
        cnt += q.second;
    }
    for (auto q:E) {
        cnt -= q.second;
        if (cnt < 0) {
            _PN("No");
            return;
        }
        cnt += q.first;
    }
    string ans = (!cnt ? "Yes" : "No");
    _PN(ans);
}
EXEC(1)



Measured memory_bytes: 28628
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
ll fac[2000100];
ll rev[2000100];
ll mul(ll a, ll b) {
	return (a * b) % mod;
}
ll add(ll a, ll b) {
	return (a + b) % mod;
}
ll sub(ll a, ll b) {
	return (a - b + mod) % mod;
}
ll mypow(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2)
		return mul(a, mypow(mul(a,a), b / 2));
	else
		return mypow(mul(a,a), b / 2);
}
ll Comb(ll x, ll y) {
	return mul(mul(fac[x],rev[y]),rev[x-y]);
}
ll Cal(ll x, ll y)
{
	if (x < 0 || y < 0)return 0;
	ll sum = 0;
	for (ll i = 0; i <= x; i++) {
		sum += Comb(i + y + 1, i + 1);
		sum %= mod;
	}
	return sum;
}
ll gap(ll a1, ll b1, ll a2, ll b2)
{
	return (Cal(a2, b2) - Cal(a1 - 1, b2) - Cal(a2, b1 - 1) + Cal(a1 - 1, b1 - 1) + mod * mod) % mod;
}

int main()
{
	fac[0] = 1; rev[0] = mypow(fac[0], mod - 2);
	for (int i = 1; i < 2000100; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
		rev[i] = mypow(fac[i], mod - 2);
	}
	ll q, w, e, r;
	scanf("%lld %lld %lld %lld", &q, &w, &e, &r);
	printf("%lld", gap(q, w, e, r));
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
# define int long long int
const int N=2*1e6+10;
vector<int> fact;

const int mod=1e9+7;

//Using binary exponentiation to calculate x^n in log(n) time.
int binExp(int base, int power)
{
    int x = 1;
    while(power)
    {
        if(power%2 == 1)
            x = (1LL * (x % mod) * (base % mod)) % mod;
        base  = (1LL * (base % mod) * (base % mod)) % mod;
        power = power / 2;
    }
    return x;
}

int facto(int num)
{
    int result = 1;
    for(int i=1; i<=num; ++i)
    {
        result = (1LL * (result % mod) * (i % mod)) % mod;
    }
    return result;
}

int calculate_nCi(int N, int i)
{
    //nCi = ( n! ) / (( n-i )! * i!)
    // int nfact = fact(N);
    // int ifact = fact(i);
    // int dfact = fact(N-i);
    int nfact = fact[N];
    int ifact = fact[i];
    int dfact = fact[N-i];
    // Using Euler's theorem of 
    // Modular multiplicative 
    // inverse to
    // find the inverse of a number.
    // (1/a)%mod=a^(m−2)%mod
    int inv_ifact = binExp(ifact, mod-2);
    int inv_dfact = binExp(dfact, mod-2);

    int denm = (1LL * (inv_ifact % mod) * (inv_dfact % mod)) % mod;

    int answer = (1LL * (nfact % mod) * (denm % mod)) %mod;
    return answer;
}

void solve(int N, int s, int k)
{
    //Number of ways to form all possible strings
    int allWays = binExp(26,N);

    //Number of ways to form strings that don't 
    //contain the input string as a subsequence.
    int noWays = 0;

    for(int i=0; i<s; ++i)
    {
        //to calculate nCi 
        int nCi = calculate_nCi(N,i);
        //selecting the remaining characters
        // 25 ^ (N-i)
        int remaining = binExp(25, N-i);

        int multiply = (1LL * (nCi % mod) * (remaining % mod)) % mod;

        noWays = (1LL * (noWays % mod) + 1LL * (multiply % mod)) % mod;
    }

    //Answer is the difference of
    //allWays and noWays
    int answer = ((allWays % mod) - (noWays % mod)) % mod;

    if(answer < 0)
        answer += mod;

    cout<<answer;
}

void preprocess()
{
    fact[0]=1;
    for(int i=1; i<N; ++i)
        fact[i] = ((fact[i-1]%mod) * (i%mod))%mod;
}

int32_t main()
{
    fact = vector<int>(N);
    preprocess();
    //string str = "abc";
    //int k = 2;
    int k; string str; cin>>k>>str;
    int s = str.length();
    int N = s + k;
    solve(N,s,k);
}


Measured memory_bytes: 20872
#include<iostream>
using namespace std;
int present[101];
int main(){
    int n, k, t, a;
    cin >> n >> k;
    for(int i = 0; i < k; ++i){
        cin >> t;
        for(int j = 0; j < t; ++j){
            cin >> a;
            present[a] = 1;
        }
    }
    int count = 0;
    for(int i = 1; i <= n; ++i)
        if(present[i] == 0)
            ++count;
    cout << count;
    return 0;
}

Measured memory_bytes: 3560