akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<iomanip>
#include<unordered_map>
#define deg(x) cerr<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=998244353;
const int inf=1e9+7;
const double eps=1e-6;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return (r+m)%m;}
const double pi=acos(-1);


int main(){
    TB
    string s;
    cin>>s;
    int sum=0;
    fd(s.length()){
        int x=s[i]-'0';
        sum+=x;
    }
    if(sum%9==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>

int main(){
	int n, m, i, a;
	scanf("%d%d", &n, &m);
	int work=0;
	for(i=0; i<m; i++){
		scanf("%d", &a);
		work+=a;
	}
	if(n-work>=0){
		printf("%d", n-work);
	}
	else{
		printf("-1");
	}
	return 0;
}

Measured memory_bytes: 1732
from math import pi, cos, sqrt
A, B, H, M = map(int, input().split())
t = H * 60 + M
deg = abs(t / 2 - (t % 60) * 6)
if deg > 180:
    deg = 360 - deg
deg = deg * pi / 180
print(sqrt(A*A + B*B - 2*A*B*cos(deg)))


Measured memory_bytes: 9492
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 2011;
const ll INF = 5e16;
const ll P = 1e9 + 7;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, k, C[N][N];
	
	inline void Init() {
		C[0][0] = 1;
//		For ( i, 1, N - 5 ) C[i][1]
		For ( i, 1, N - 5 ) C[i][0] = C[i][i] = 1;
		For ( i, 1, N - 5 ) For ( j, 1, i )
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
	}
	
	int main() {
		Init();
		n = read(), k = read();
		For ( i, 1, k ) 
			wln (C[k - 1][i - 1] * C[n - k + 1][i] % P);
		return 0;
	}

}

int main()
{
	return Cesare::main();
}

/*

*/






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

typedef long long ll;

vector<ll> Adj[500005];

int main() {
    
    
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        Adj[x].push_back(y+n);
        Adj[x+n].push_back(y+2*n);
        Adj[x+2*n].push_back(y);
        
    }
    
    ll src,des;
    cin>>src>>des;
    
    queue<ll> pq;
    pq.push(src);
    ll visited[5*n];
    ll dist[5*n];
    visited[src]=1;
    
    memset(visited,0,sizeof(visited));
    memset(dist,-1,sizeof(dist));
    dist[src]=0;
    
    while(!pq.empty())
    {
        ll top=pq.front();
        pq.pop();
        for(auto it:Adj[top])
        {   
            if(!visited[it])
           { pq.push(it);
           visited[it]=1;
           dist[it]=dist[top]+1;
           }
        }
    }
    
    
    if(dist[des]!=-1)
    
    {  ll x=dist[des]/3;
        cout<<x<<endl;
    }
	
	else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 29184
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def inv(x):
    return pow(x, mod - 2, mod)

cms = 10**5+5
cm = [0] * cms

def comb_init():
    cm[0] = 1
    for i in range(1, cms):
        cm[i] = cm[i-1] * i % mod

def comb(a, b):
    return (cm[a] * inv(cm[a-b]) % mod) * inv(cm[b]) % mod

def main():
    n,k = LI()
    a = sorted(LI())
    r = 0
    comb_init()
    for i in range(k-1,n):
        ai = a[i]
        aj = a[n-i-1]
        c = comb(i,k-1)
        r += c * (ai - aj)
        r %= mod

    return r


print(main())





Measured memory_bytes: 19764
N, M = map(int,input().split())
accepted = [0]*N
wrong_ans =[0]*N 
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s =="AC":
        accepted[p] = 1
    elif s == "WA" and accepted[p]==0:
        wrong_ans[p] = wrong_ans[p]+1

AC = 0
penalty = 0
for i in range(N):
    if accepted[i] == 1:
        AC = AC+1
        if wrong_ans[i]>=1:
            penalty = penalty+wrong_ans[i]
print(AC,penalty)

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

int main() {
  int r, a, b,c;
  cin >> r;
  
  a = r * r * 3;
  
  b = 1 * 1 * 3;
  
  c = a / b;
  
  cout << c << endl;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a == 0){
		if(1868 <= b && 1911>= b){
			cout<<"M"<<b-1867<<endl;
		}
		if(1912 <= b && 1925>= b){
			cout<<"T"<<b-1911<<endl;
		}
		if(1926 <= b && 1988>= b){
			cout<<"S"<<b-1925<<endl;
		}
		if(1989 <= b && 2016>= b){
			cout<<"H"<<b-1988<<endl;
		}

	}
	else if( a == 1){
		cout<<b+ 1867<<endl;
	}
	else if( a == 2){
		cout<<b+ 1911<<endl;
	}
	else if( a == 3){
		cout<<b+ 1925<<endl;
	}
	else if( a == 4){
		cout<<b+ 1988<<endl;
	}
}


Measured memory_bytes: 3112
fun main(){
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val c = MutableList(h){ MutableList(w){0} }
    for (i in 0 until h){
        val x = readLine()!!.split(" ")[0].toCharArray()
        for (j in 0 until w){
            if (x[j] == '#'){
                c[i][j] = 1
            }
        }
    }
    var ans = 0
    var black = 0
    for (i in 0 until 1.shl(h)){
        for (j in 0 until 1.shl(w)){
            val useC = MutableList(h){ MutableList(w){ 0 } }
            for (iii in 0 until h){
                for (jjj in 0 until w){
                    useC[iii][jjj] = c[iii][jjj]
                }
            }
            for (ii in 0 until h){
                if (i and 1.shl(ii) == 1.shl(ii)){
                    for (l in 0 until w){
                        useC[ii][l] = -1
                    }
                }
            }
            for (jj in 0 until w){
                if (j and 1.shl(jj) == 1.shl(jj)){
                    for (l in 0 until h){
                        useC[l][jj] = -1
                    }
                }
            }
            for (l in 0 until h){
                for (m in 0 until w){
                    if (useC[l][m] == 1) black++
                }
            }
            if (black == k) ans++
            black = 0
        }

    }
    println(ans)
}



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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	rep(i,2)rep(j,n) cin >> a[i][j];
	int ans = 0;
	rep(k,n){
		int score = 0;
		for(int i = 0; i <= k; ++i) score += a[0][i];
		for(int j = k; j < n; ++j) score += a[1][j];
		chmax(ans, score);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int x[8];
int y[8];

void path(int* out, int N) {
	for (int i = N - 2; i >= 0; i--) {
		int t = out[i] + 1;
		while (t < N) {
			bool e = true;
			for (int j = 0; j < i; j++) {
				if (out[j] == t)e = false;
			}
			if (e) {
				break;
			}
			t++;
		}
		if (t == N)continue;
		out[i] = t;
		for (int p = i + 1; p < N; p++) {
			for (int j = 0; j < N; j++) {
				bool e = true;
				for (int k = 0; k < p; k++) {
					if (out[k] == j)e = false;
				}
				if (e) {
					out[p] = j;
					break;
				}
			}
		}
		return;
	}
	out[0] = -1;
	return;
}

int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", x + i, y + i);
	}
	int p[8];
	for (int i = 0; i < N; i++) {
		p[i] = i;
	}
	double sum = 0;
	while (p[0] != -1) {
		for (int i = 1; i < N; i++) {
			sum += sqrt((double)(x[p[i]] - x[p[i - 1]])*(x[p[i]] - x[p[i - 1]]) + (y[p[i]] - y[p[i - 1]])*(y[p[i]] - y[p[i - 1]]));
		}
		path(p, N);
	}
	int nkai = 1;
	for (int i = 0; i < N; i++)nkai *= i + 1;
	sum /= nkai;
	printf("%lf", sum);
	return 0;
}

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

int field[6][2] = 
{
	{1, 2},
	{-1, 3},
	{1, -1},
	{4, 5},
	{5, 2},
	{2, 1},
};

int main() {
	string p;
	while(cin >> p, p != "#"){
		int state = 0;
		
		for(int i = 0; i < (int)p.size() && state != -1; ++i) {
			state = field[state][(p[i] == '1') ? 1 : 0];
		}
		
		if(state == 5) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int ans = 0;
    if (s[1] == '1') ans++;
    if (s[2] == '1') ans++;
    if (s[0] == '1') ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; cin >> s;
    int A = (int) (s[0] - '0');
    int B = (int) (s[1] - '0');
    int C = (int) (s[2] - '0');
    int D = (int) (s[3] - '0');

    if(A + B + C + D == 7) {cout << A << '+' << B << '+' << C << '+' << D << "=7"<< endl; return 0;}
    if(A + B + C - D == 7) {cout << A << '+' << B << '+' << C << '-' << D << "=7"<< endl; return 0;}
    if(A + B - C + D == 7) {cout << A << '+' << B << '-' << C << '+' << D << "=7"<< endl; return 0;}
    if(A + B - C - D == 7) {cout << A << '+' << B << '-' << C << '-' << D << "=7"<< endl; return 0;}
    if(A - B + C + D == 7) {cout << A << '-' << B << '+' << C << '+' << D << "=7"<< endl; return 0;}
    if(A - B + C - D == 7) {cout << A << '-' << B << '+' << C << '-' << D << "=7"<< endl; return 0;}
    if(A - B - C + D == 7) {cout << A << '-' << B << '-' << C << '+' << D << "=7"<< endl; return 0;}
    if(A - B - C - D == 7) {cout << A << '-' << B << '-' << C << '-' << D << "=7"<< endl; return 0;}
}

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

using namespace std;
typedef long long ll;

ll K,A,B;

int main(){
    cin >> K;
    cin >> A >> B;
    for(int i=A;i<=B;i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

int main() {
	int x,k;cin>>x>>k;
	vector<int> r(k);
	vector<int> ur(k),dr(k),us(k),ds(k);
	int u=x;
	int d=0;
	int l=-1;
	int exus=0;
	int exds=0;
	int ext=0;
	for(int i=0;i<k;i++){
		cin>>r[i];
		u+=l*(r[i]-ext);
		d+=l*(r[i]-ext);
		if(u>x){
			exus+=u-x;
			u=x;
		}
		if(u<0){
			u=0;
		}
		if(d<0){
			exds+=-d;
			d=0;
		}
		if(d>x){
			d=x;
		}
		ur[i]=u;
		dr[i]=d;
		us[i]=exus;
		ds[i]=exds;
		ext=r[i];
		l*=-1;
	}
//	for(int i=0;i<k;i++){
//		cout<<ur[i]<<' '<<dr[i]<<' '<<us[i]<<' '<<ds[i]<<endl;
//	}
	int q;cin>>q;
	for(int i=0;i<q;i++){
		int t,a;cin>>t>>a;
		int j=upper_bound(r.begin(),r.end(),t)-r.begin();
		int extime,s;
		extime=0;
		s=a;
		if(j){
			extime=r[j-1];
			s=dr[j-1]-ds[j-1]+a;
			if(s<dr[j-1])s=dr[j-1];
			if(s>ur[j-1])s=ur[j-1];
			if(ur[j-1]==dr[j-1])s=ur[j-1];
		}
		s+=((j%2)*2-1)*(t-extime);
		if(s>x)s=x;
		if(s<0)s=0;
		cout<<s<<endl;

	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int h, w;
    cin >> h >> w;
    vvchar g(h, vchar(w));
    rep(y, h) rep(x, w) cin >> g[y][x];

    int ans = 0;
    rep(y, h) rep(x, w)
    {
        if (g[y][x] == '#')
            continue;
        if (ans == h + w - 1)
            break;
        int now = 0;
        for (int ry = y; ry <= h; ry++)
        {
            if (ry >= h || g[ry][x] == '#')
            {
                now += ry - y - 1;
                break;
            }
        }
        for (int ry = y; ry >= -1; ry--)
        {
            if (ry < 0 || g[ry][x] == '#')
            {
                now += y - ry - 1;
                break;
            }
        }
        for (int rx = x; rx <= w; rx++)
        {
            if (rx >= w || g[y][rx] == '#')
            {
                now += rx - x - 1;
                break;
            }
        }
        for (int rx = x; rx >= -1; rx--)
        {
            if (rx < 0 || g[y][rx] == '#')
            {
                now += x - rx - 1;
                break;
            }
        }
        ans = max(ans, now + 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7520
#include<stdio.h>
#include<string.h>
typedef struct {
	int id;
	int ac ;
	int time;
	int pt[300];
	int ok[20];

} Player;

int M, T, P,R;



void makeScore(int n, Player * A)
{
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= P; j++)
		{
			if (A[i].ok[j] == 0)
			{
				if (A[i].pt[j])
					A[i].time += (20 * A[i].pt[j]);
			}

		}
	
		
	}
}

void makeRank(int n, Player*A)
{
	int i, j;
	Player temp;
	for (int i = 0; i < n; i++)
		for (int j = n; j > i + 1; j--)
		{
			if (A[j].ac>A[j - 1].ac)
			{
				temp = A[j]; A[j] = A[j - 1]; A[j - 1] = temp;
			}
			else if (A[j].ac == A[j - 1].ac)
			{
				if (A[j].time < A[j - 1].time)
				{
					temp = A[j]; A[j] = A[j - 1]; A[j - 1] = temp;
				}
				else if (A[j].time == A[j - 1].time)
				{
					if (A[j].id > A[j - 1].id)
					{
						temp = A[j]; A[j] = A[j - 1]; A[j - 1] = temp;
					}
				}
			}
		}
}

void Print(int n, Player *A)
{
	int i;
	for (i = 1; i <= n; i++)
	{
		
		printf("%d", A[i].id);
		if (A[i].ac == A[i + 1].ac&&A[i].time==A[i+1].time && i != n)
			printf("=");
		else if (i != n)
			printf(",");
	}
	printf("\n");
}
int main()
{

	int i;
	int time, team, num, ok;
	Player plr[100];
	
	while (scanf("%d%d%d%d", &M, &T, &P, &R) && M || T || R || P)
	{
		for (int i = T; i>=1;i--)
		{
			memset(plr[i].pt, 0, sizeof(plr[i].pt));
			memset(plr[i].ok, -1, sizeof(plr[i].ok));
			plr[i].ac = plr[i].time = 0;
			plr[i].id = i;
		}
	
		for (i = 0; i < R; i++)
		{
			scanf("%d%d%d%d", &time, &team, &num, &ok);
			if (ok == 0)
			{
				plr[team].ac++;
				plr[team].time += time;
				plr[team].ok[num] = 0;
			}
			else
			{
				
				plr[team].pt[num]++;
			}
		}

		makeScore(T, plr);
		makeRank(T, plr);
		Print(T, plr);



	}
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> dp(3,0);
  for(int i=0; i<n; i++){
    vector<int> c(3);
    for(int j=0; j<3; j++)
      	cin>>c[j];
    vector<int> new_dp(3, 0);
    for(int x=0; x<3; ++x)
    {
      for(int y=0; y<3; ++y)
      {
        if(x != y)
        {
       		new_dp[x] = max(new_dp[x], dp[y] + c[x]);    
        }
      }  
    }
    dp = new_dp;
  }
  cout<<max({dp[0], dp[1], dp[2]});
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()

{
	int N, M;
	scanf("%d %d", &N, &M);
	
	int x, y; //ループ用
	
	int a[N];
	int b[N];
	int c[M];
	int d[M];
	
	for(x=0; x<N; x++) scanf("%d %d", &a[x], &b[x]);
	for(x=0; x<M; x++) scanf("%d %d", &c[x], &d[x]);
	
	int e[N];
	int j, k, l;
	
	for(x=0; x<N; x++) e[x] = 0;
	
	for(x=0; x<N; x++){
		l = 1000000000;
		for(y=0; y<M; y++)
		{
			j = a[x]-c[y];
			k = b[x]-d[y];
			if(j < 0) j = -j;
			if (k < 0) k = -k;
			if(j+k < l){
				l = j+k;
				e[x] = y+1;
			}
		}
	}
	
		
		for(x=0; x<N; x++) printf("%d\n", e[x]);
		
		return 0;
		}


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

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

int ctoi(const char c){
  switch(c){
      case '0': return 0;
      case '1': return 1;
      case '2': return 2;
      case '3': return 3;
      case '4': return 4;
      case '5': return 5;
      case '6': return 6;
      case '7': return 7;
      case '8': return 8;
      case '9': return 9;
      default : return -1;
  }
}

int main() {
  string n;
  cin >> n;
  ll k = n.length();
  ll m=0;
  rep(i,k){
    char o=n[i];
    int j =ctoi(o);
    m+=j;
  }
  if(m%9==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
const int N=2e5;
int t[N+5];
int cnt[4]={0};
bool vis[2*N+5][4];
//读不懂题目一次，卡了一会儿输入， 
//平局和输是一样的 
int main()
{
	int n,k,r,s,p;
	scanf("%d %d %d %d %d",&n,&k,&cnt[1],&cnt[2],&cnt[3]);
	char ch='4';
	while(ch<='a' or ch>='z') ch=getchar(); 
	for(int i=1;i<=n;i++){
		if(ch=='r') t[i]=1;
		else if(ch=='s') t[i]=2;
		else if(ch=='p') t[i]=3;
		ch=getchar();
		//cout<<ch<<t[i]<<endl;
	}
	long long ans=0;
    for(int i=1;i<=n;i++)
    {
    	if(t[i]==1)
    	{
    		if(vis[i][3]==false){
    			vis[i+k][3]=true;
    			ans+=cnt[3];
    		}
    		//else if(vis[i][1]==false)
    		//	vis[i+k][1]=true;
    		//else if(vis[i][2]==false)
    		//	vis[i+k][2]=true;
   	//cout<<ans<<endl;
	   }
        else if(t[i]==2)
    	{
    		if(vis[i][1]==false){
    			vis[i+k][1]=true;
    			ans+=cnt[1];
    		}
    	//	else if(vis[i][2]==false)
    		//	vis[i+k][2]=true;
    	//	else if(vis[i][3]==false)
    		//	vis[i+k][3]=true;
    //cout<<ans<<endl;
		}
    	else if(t[i]==3)
    	{
    		if(vis[i][2]==false){
    			vis[i+k][2]=true;
    			ans+=cnt[2];
    		}
    	//	else if(vis[i][3]==false)
    			//vis[i+k][3]=true;
    	//	else if(vis[i][1]==false)
    		//	vis[i+k][1]=true;
   // cout<<ans<<endl;
   	}	
    }
	cout<<ans<<endl;
	
} 

Measured memory_bytes: 1024
n=int(input())
list_ = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    list_.append([tmp[0]-tmp[1], tmp[0]+tmp[1]])

list_.sort()
count = 0
now_start = -(10**9+1)

for i in range(n):
    if now_start <= list_[i][0]:
        now_start = list_[i][1]
        count = count + 1
    else:
        if now_start > list_[i][1]:
            now_start = list_[i][1]

print(count)



Measured memory_bytes: 20524
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace ABC121D_XorWorld
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var input = Console.ReadLine().Split(' ').Select(elem => long.Parse(elem)).ToArray();
            var A = input[0];
            var B = input[1];
            var answer = f(A - 1) ^ f(B);
           Console.WriteLine(answer);
        }

        private long f(long val)
        {
            if (val < 0)
            {
                return 0;
            }

            long answer = 0;
            for(int i = 0; i < 40; i++)
            {
                // i桁目が0か1かを調べる
                //  0:0000 0000
                //  1:0001 0001
                //  2:0010 0011
                //  3:0011 0000
                //  4:0100 0100
                //  5:0101 0001
                //  6:0110 0111
                //  7:0111 0000
                //  8:1000 1000
                //  9:1001 0001
                // 10:1010 1011
                // i = 0 -> 1
                // i = 1 -> 2
                // i = 2 -> 4
                var loop = (long)Math.Pow(2, i + 1);
                var count = (val / loop) * (long)Math.Pow(2, i);
                count += Math.Max(0, ((val % loop) - (long)Math.Pow(2, i) + 1));
                if (count % 2 == 1)
                {
                    answer += (long)Math.Pow(2, i);
                }
            }

            return answer;
        }
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    A,B=pin()
    if A>9 or B>9:print(-1);return
    print(A*B)
#%%submit!
resolve()

Measured memory_bytes: 38384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b, x = MAP()

def f(n):
	if n >= 0:
		return n//x + 1
	if n==-1:
		return 0

print(f(b)-f(a-1))

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> t(n), a(n);
  for (int i = 0; i < n; i++) cin >> t.at(i);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll ans = 1;
  vector<int> x(n, -1), y(n);
  for (int i = 0; i < n; i++) {
    if (i == 0) x.at(i) = t.at(i);
    else if (t.at(i - 1) < t.at(i)) x.at(i) = t.at(i);
    y.at(i) = t.at(i);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      if (x.at(i) == -1) {
        if (y.at(i) < a.at(i)) ans = 0;
        x.at(i) = a.at(i);
      }
      else {
        if (x.at(i) != a.at(i)) ans = 0;
      }
    }
    else if (a.at(i) > a.at(i + 1)) {
      if (x.at(i) == -1) {
        if (y.at(i) < a.at(i)) ans = 0;
        x.at(i) = a.at(i);
      }
      else {
        if (x.at(i) != a.at(i)) ans = 0;
      }
    }
    y.at(i) = min(y.at(i), a.at(i));
  }
  
  for (int i = 0; i < n; i++) {
    if (x.at(i) == -1) {
      ans *= y.at(i);
      ans %= MOD;
    }
  }
  
  cout << ans << '\n';
}

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

namespace AtCoder.Contests.ABC162
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();

            long sum = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 == 0 || i % 5 == 0) continue;
                sum += i;
            }

            Console.WriteLine(sum);
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27488
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define maxn 2009
#define pb push_back
#define X first
#define Y second
#define mod 1000000007
#define base 17
using namespace std;

ll N, K, Q;
ll a[maxn];

bool canRemove(ll mi, ll ma){
	ll maxRemove = 0;
	ll size = 0;
	ll greater_max = 0;
	ll less_max = 0;
	For(i,1,N+1){		
		if(a[i] < mi || i==N+1){
			maxRemove += max(0LL,min(size - K + 1, less_max));
//			cout << K << " " << size << " " << less_max << " " << greater_max << " " << maxRemove <<  "\n";
			less_max = greater_max = size = 0;
			continue;
		}				
			size ++;
			if(a[i] > ma) greater_max ++;
			else less_max ++;
		
	}	
//	cout << maxRemove << " !! ";
	if(maxRemove >= Q) return true;
	return false;
}
main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    cout.tie(NULL);   
    cin >> N >> K >> Q;
    For(i,1,N) cin >> a[i];
    vector<ll> b(a+1,a+N+1);
    sort(b.begin(),b.end());
    std::vector<ll>::iterator it;
	it = std::unique (b.begin(), b.end()); 
    b.resize( std::distance(b.begin(),it) );
    ll ans = b.back()-b[0];
//    cout << "Check " << canRemove(2,2);
    For(i,0,b.size()-1){
//	   	cout << i << " ";
    	if(!canRemove(b[i],b.back())) break;
//    	cout << " ! ";
    	ll mi = i;
    	ll ma = b.size()-1;
    	while(mi<ma){
    		ll mid = (mi+ma)/2;
    		if(canRemove(b[i],b[mid])){
    			ma = mid;
			}	else	{
				mi = mid + 1;
			}
		}
//		cout << mi <<  " \n";
		ans = min(ans,b[ma]-b[i]);
	}
	cout << ans;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    ll ans = (M * 1900 + (N - M) * 100) * (1ll << M);
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

int s[10000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &s[i]);
	sort(s, s + n);
	int q; scanf("%d", &q);
	int cnt = 0;
	rep(i, q) {
		int t; scanf("%d", &t);
		if (binary_search(s, s + n, t))cnt++;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 3236
#解説参照済み
n=int(input())
a=list(input())
from collections import defaultdict
d=defaultdict(int)
for i in a:
    d[i]+=1
cnt=[]
for i in d.values():
    cnt.append(i+1)
ans=1
mod=10**9+7
for i in cnt:
    ans*=i
    ans%=mod
print(ans-1)

Measured memory_bytes: 4140
#include <stdio.h>
#include <algorithm>

using namespace std;

int kiriage(int a, int b){
  if(a%b == 0){
    return a/b;
  }else{
    return a/b + 1;
  }
}

int main(){
  int n, k;
  int a[123456];
  scanf("%d %d", &n, &k);
  for(int i=0; i < n; i++){
    scanf("%d", a + i);
  }
  int m;
  int mid;
  mid = min_element(a, a + n) - a;
  m = a[mid];

  int i = 0;
  int cnt = 0;

  // starter
  cnt = kiriage(mid, k - 1);
  i = (k - 1)*cnt;

  // simulate
  while(i < n - 1){
    if(a[i + 1] != m){
      i += k - 1;
      cnt++;
    }else{
      i++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 512
// HowManyDivisors.c
// ３つの整数 a、b、cを読み込み、aからbまでの整数の中に、
// cの約数がいくつあるかを求めるプログラムを作成してください。
// 【入力】
// a、b、cが１つの空白区切りで１行に与えられます。
// 【出力】
// 約数の数を１行に出力してください。
// 【制約】
// ・1≤a,b,c≤10000
// ・a≤b
// 【例】
// 入力：5 14 80
// 出力：3
#include<stdio.h>

int main( void) {
  int a, b, c;
  int counter = 0;

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

  for ( int i = a; i <= b; i++)
    if ( c % i == 0) counter++;

  printf( "%d\n", counter);

  return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
#define ll long long

ll expr();
ll term();
ll fac();
int left();
char peek();
char pop();
int isdeg(char z);
int isdeg(char z);
void eat(char z);
ll num();

string s;
int t;

int main(){
  int n;
  cin >> n;
  cin >> s;
  while(n){
    long long ans=0;
    t=0;
    s.pop_back();
    ans=expr();
    n--;
    cout << ans << endl;
    cin >> s;
  }
}


ll expr(){
  ll res=term();
  while(left()&&(peek()=='+'||peek()=='-')){
    if(peek()=='+'){
      eat('+');
      res+=term();
    }
    else if(peek()=='-'){
      eat('-');
      res-=term();
    }
  }
  return res;
}

ll term(){
  ll res=fac();
  while(left()&&(peek()=='*'||peek()=='/')){
    if(peek()=='*'){
      eat('*');
      res*=fac();
    }
    else if(peek()=='/'){
      eat('/');
      res/=fac();
    }
  }
  return res;
}

ll fac(){
  if(peek()=='('){
    eat('(');
    ll res=expr();
    eat(')');
    return res;
  }
  else{
    return num();
  }
}


int left(){                 //まだ文字列が残っているかを調べる
  return int(s.size())>t;
}

char peek(){                //次の文字を一文字先読みする
  return s[t];
}

char pop(){                 //次の文字を読みとって、インデックスを進める
  t++;
  return s[t-1];
}

int isdeg(char z){
  return z>='0'&&z<='9';
}

void eat(char z){
  if(s[t]!=z) cout << "warning " << t << endl;
  t++;
}

ll num(){
  ll res=0;
  while(left()&&isdeg(peek())){
    res*=10;
    res+=pop()-'0';
  }
  return res;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define f first
#define s second
#define N 1e5 + 10
ll ok(ll n)
{
	if(pow(2,log2(n+1))==n+1)
	{
		return 1;
	}
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m,x;
	cin>>n>>m;
	ll i,a,b;
	ll MOD=1e9+7;
	ll dp[n+1];
	vector<ll> vis(n+1,1);
	for(i=0;i<m;i++)
	{
		cin>>x;
		vis[x]=0;
	}
	dp[0]=1;
	dp[1]=vis[1];
	for(i=2;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dp[i]=0;
			continue;
		}
		if(vis[i-1]==0)
		{
			a=0;
		}
		else
		{
			a=dp[i-1];
		}
		if(vis[i-2]==0)
			b=0;
		else
			b=dp[i-2];
		dp[i]=a%MOD+b%MOD;
	}
	cout<<dp[n]%MOD;
}	

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	string w; cin >> w;
	int n = w.size();

	map<char, int>mp;
	rep(i, n) {
		mp[w[i]]++;
	}
	bool okay = true;

	for(pair<char,int>p : mp) {
		if (p.second % 2 != 0) {
			okay = false;
			break;
		}
	}
	if (okay == true)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

# below model is for VALUE Constraint
V = int(pow(10,3)+1) * N
dp = [[float('INF') for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
	for sum_v in range(V):
		if sum_v - v[i] >= 0:
			dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v-v[i]]+w[i])
		dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

max_v = 0
for sum_v in range(V):
	if dp[N][sum_v] <= W:
		max_v = sum_v

print(max_v)

Measured memory_bytes: 319216
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:
  print(0)
else:
  dif = sorted([x[i+1] - x[i] for i in range(m-1)])[::-1]
  print(x[-1]- x[0] - sum(dif[:n-1]))

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

int main()
{
    string s;
    cin >> s;
    int ans = 1e9;
    for(int i=0; i<s.size()-2; i++){
        int x = (s[i] -'0') * 100 + (s[i+1] - '0') * 10 + s[i+2] -'0';
        ans = min(ans, abs(x-753));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			System.out.print("3C");
			int ans = n % 39;
			if(ans < 10)
			{
				if(ans == 0)
				{
					System.out.println("39");
				}
				else
				{
					System.out.println("0" + ans);
				}
			}
			else
			{
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 12000
def main(ab_list, m):
    ab_list.sort(key=lambda x:x[0])
    it = iter(ab_list)
    paid = 0
    buyed_drinks = 0
    while buyed_drinks < m:
        rest_num = m - buyed_drinks
        a, b = next(it)
        if rest_num <= b:
            paid += a*rest_num
            return paid
        else:
            paid += a*b
            buyed_drinks += b



if __name__ == "__main__":
    n, m = list(map(int, input().split(" ")))
    ab_list = []
    for _ in range(n):
        a, b = list(map(int, input().split(" ")))
        ab_list.append((a, b))
    print(main(ab_list, m))


Measured memory_bytes: 18112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

int n, m;

vector <int> V[555555];

char ch[555555];

int vis[555555][2], inst[555555][2];

void DFS(int x, int y) {
    inst[x][y] = 1;
    vis[x][y] = 1;
    for(int i = 0; i < V[x].size(); i++)
        if(ch[V[x][i]] != ch[x] ^ y) {
            if(inst[V[x][i]][!y]) {
                puts("Yes");
                exit(0);
            } else if(!vis[V[x][i]][!y]) DFS(V[x][i], !y);
        }
    inst[x][y] = 0;
}

int main() {
    scanf("%d%d", &n, &m);
    scanf("%s", ch + 1);
    for(int i = 1; i <= m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    for(int i = 0; i < 2; i++)
        for(int j = 1; j <= n; j++) if(!vis[j][i]) {
            DFS(j, i);
        }
    puts("No");
    return 0;
}

Measured memory_bytes: 31616
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a)
{
    if (a == 2)
        return true;
    if (a <= 1 || a % 2 == 0)
        return false;

    for (int i = 3; i * i <= a; i += 2)
    {
        if (a % i == 0)
            return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key)
{
    if (a[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key)
{
    int ng = -1;            //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

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

    int alice = 0, bob = 0;

    vector<int> a(n);

    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    rep(i, n)
    {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }

    cout << alice - bob << endl;

    return 0;
}


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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  double dist = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
  printf("%f\n", dist);
}



Measured memory_bytes: 3220
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a * 100 + b * 10 + c;
  if (d % 4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] roadInfo = new int[n+1];
		for(int i = 0;i < m;i++) {
			roadInfo[sc.nextInt()]++;
			roadInfo[sc.nextInt()]++;
		}
		for(int i =1;i <=n;i++) {
			System.out.println(roadInfo[i]);
		}

	}

}

Measured memory_bytes: 21972
def main():
    N, K = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    count = 1
    num = 0
    dic = {}
    for a in A:
        if num == a:
            count += 1

        elif num > 0:
            dic.update({num:count})
            count = 1

        num = a

    dic.update({num:count})

    sort_dic = sorted(dic.items(), key= lambda x:x[1])

    count = 0
    keys = len(dic.keys())
    for i in range(keys-K):
        count += sort_dic[i][1]

    print (count)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Measured memory_bytes: 39196
length = input()
number_list = []

for i in input().split():
    number_list.append(int(i))

count = -1
number = 0
is_ok = True

while is_ok:
    for i in number_list:
        if i % 2 != 0:
            is_ok = False
            break
        number_list[number] = i / 2
        number += 1
    count += 1
    number = 0

print(count)

Measured memory_bytes: 3188
def main():
    n = int(input())
    values = list(map(int, input().split()))
    count = None
    for x in values:
        temp_count = 0
        while x % 2 == 0:
            x /= 2
            temp_count += 1
        count = temp_count if count == None else min(count, temp_count)


    print(count)

def canBeDevide(values, num):
    return all(x % 2 == 0 for x in values)








main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#define LL long long 
using namespace std;
LL dist[330][330],map[330][330],many[330][330];
int main()
{
    int i,j,k,start;
	long long ans=0;
    int n,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    	for(j=1;j<=n;j++){
    		scanf("%d",&k);
    		map[i][j]=dist[i][j]=k;
    		if(i<j)ans+=(LL)k;
    	}
    for(k=1;k<=n;k++)
    	for(j=1;j<=n;j++)
    		if(k!=j)
    			for(i=1;i<=n;i++)
    				if(i!=j&&i!=k){
    					if(dist[i][j]==dist[i][k]+dist[k][j])
    						many[i][j]=2;
    					if(dist[i][j]>dist[i][k]+dist[k][j])
    						dist[i][j]=dist[i][k]+dist[k][j],many[i][j]=1;
    				}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(i!=j){
				if(dist[i][j]!=map[i][j]){
					printf("-1\n");return 0;
				}
				if(i<j&&many[i][j]>1)
					ans-=map[i][j];
			}
	printf("%lld\n",ans);
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll a,b,c;
  cin >> a >> b >> c;

  map<ll, ll> m;
  m[a] += 1;
  m[b] += 1;
  m[c] += 1;

  if(m[5] == 2 && m[7] == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256