akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int n;
	int ar[200] = { 1,1 };
	int a = 0;
	int count = 0;
	cin >> n;

	REP(i, 200)
	{
		ar[i] = 1;
	}

	for (int i = 0; i <= n; i++)
	{
		for (int j = 2; j < n+1; j++)
		{
			if ((i + 1) % j == 0)ar[i]++;
		}
	}

	REP(i, n)
	{
		if (ar[i] == 8 && (i + 1) % 2 == 1)count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char C; cin >> C;
  if(C <= 'z' && C >= 'a'){
    cout << "a" << endl;
  }else{
    cout << "A" << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
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++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

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();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;

		int N=sc.nextInt();
		int X=sc.nextInt();
		
		int[] x = new int[N];
		
		for(int i=0;i<N;i++){
			x[i]=sc.nextInt();
			x[i]=Math.abs(x[i]-X);
		}
		
		int now=x[0];
		for(int i=0;i<N;i++){
			int tmp;
	        while ((tmp = x[i] % now) != 0) {
	            x[i] = now;
	            now = tmp;
	        }	
		}
		System.out.println(now);
		
		
	}
}

Measured memory_bytes: 51980
#include <stdio.h>
inline int max(int a,int b){return a>b?a:b;}
int k,t,x,MAX=0;
int main(){
	scanf("%d%d",&k,&t);
	for(register int i=1;i<=t;i++){
		scanf("%d",&x);
		MAX=max(MAX,x);
	}
	return printf("%d\n",max(MAX-1-k+MAX,0)),0;
}

Measured memory_bytes: 128
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int n = read.to!int;
	int m = read.to!int;
	
	bool[] xs;
	xs.length = n + 1;
	foreach(i; 1 .. n + 1) xs[i] = 0;
	foreach(i; 0 .. m){
		int a = read.to!int;
		int b = read.to!int;
		xs[a] = !xs[a];
		xs[b] = !xs[b];
		}
	
	string ans = "YES";
	foreach(x; xs) if(x) ans = "NO";
	
	ans.writeln;
	
	}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}



int main()
{
   cin>>N;
   vector<int> A(N);
   set<int> s;
   for(auto &x:A) cin>>x,s.insert(x);
   
   cout<<(s.size()==N ? "YES\n":"NO\n");
    
}

Measured memory_bytes: 36712
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll mod=1e9+7,i,j;
ll n;
ll a[300005];
ll x,y;
int main(){
    cin>>n;
    if(n%2==1){
        cout<<"0";
    }
    else{
        ll ans=0,k=10;
        while(k<=n){
            ans+=n/k;
            k=k*5;
        }
        cout<<ans;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;

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

	int N, M;

	cin >> N >> M;

	vector<int> pena(N);
	vector<bool> AC(N);


	for(int i = 0; i < M; i++) {
		int p;
		string s;
		cin >> p >> s;

		if(s == "AC") {
			AC[p - 1] = true;
		} else if(!AC[p - 1]) {
			pena[p - 1]++;
		}
	}

	int count_ac = 0;
	int count_wa = 0;

	for(int i = 0; i < N; i++) {
		if(AC[i]) {
			count_ac++;
			count_wa += pena[i];
		}
	}

	cout << count_ac << " " << count_wa << endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ff first
#define ss second

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

const int maxn=2e5+3;

int mn,sum,rt;
int w[maxn],prt[maxn],sz[maxn];
ll dis[maxn];
bool vis[maxn];
vector<pii>e[maxn];
struct edge{
	int a,b;ll w;
	bool operator<(const edge&R)const{return w<R.w;}
};
vector<edge>ed;

void Getrt(int u,int fa){
	sz[u]=1;
	int re=0;
	for(pii x:e[u]){
		int v=x.ss;
		if(v==fa||vis[v])continue;
		Getrt(v,u);
		sz[u]+=sz[v];
		re=max(re,sz[v]);
	}
	re=max(re,sum-sz[u]);
	if(re<mn)mn=re,rt=u;
}

void Dfs(int u,int fa,pair<ll,int>&mi){
	mi=min(mi,{dis[u]+w[u],u});
	for(pii x:e[u]){
		int v=x.ss;
		if(v==fa||vis[v])continue;
		dis[v]=dis[u]+x.ff;
		Dfs(v,u,mi);
	}
}

void Link(int u,int fa,pair<ll,int>mi){
	ed.emplace_back(edge{u,mi.ss,mi.ff+dis[u]+w[u]});
	for(pii x:e[u]){
		int v=x.ss;
		if(v==fa||vis[v])continue;
		Link(v,u,mi);
	}
}

void Solve(int u){
	vis[u]=1;
	pair<ll,int>mi(1ll<<60,0);
	dis[u]=0;
	Dfs(u,0,mi);
	Link(u,0,mi);
	int re=sum;
	for(pii x:e[u]){
		int v=x.ss;
		if(vis[v])continue;
		sum=mn=sz[v]<sz[u]?sz[v]:re-sz[u];
		Getrt(v,0);
		Solve(rt);
	}
}

inline int Gf(int x){return prt[x]==x?x:prt[x]=Gf(prt[x]);}

int main(){
#ifdef changxv
	freopen("in","r",stdin);
#endif
	ios::sync_with_stdio(0),cin.tie(0);
	int n;cin>>n;
	For(i,1,n)cin>>w[i];
	For(i,2,n){
		int x,y,z;cin>>x>>y>>z;
		e[x].emplace_back(z,y);
		e[y].emplace_back(z,x);
	}
	mn=sum=n;
	Getrt(1,0);
	Solve(rt);
	
	sort(ed.begin(),ed.end());
	For(i,1,n)prt[i]=i;
	int tot=0;
	ll ans=0;
	for(edge x:ed){
		int fx=Gf(x.a),fy=Gf(x.b);
		if(fx==fy)continue;
		ans+=x.w;
		prt[fx]=fy;
		if(++tot==n-1)break;
	}
	cout<<ans<<'\n';
return 0; } 

Measured memory_bytes: 98404
N = int(input())
t = x = y = 0
for i in range(N):
  tn,xn,yn = map(int,input().split())
  dt = tn-t
  d = abs(xn-x)+abs(yn-y)
  if d <= dt and dt%2 == d%2:
    t,x,y = tn,xn,yn
    isValid = True
  else:
    isValid = False
    break
print("Yes" if isValid else "No")

Measured memory_bytes: 3060
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,i,j,k;
		cin>>n;
		map<string,int>a;
		for(i=0;i<n;i++){
			string s;
			cin>>s;
			sort(s.begin(),s.end());
			a[s]++;
		}
		long long int ans=0;
		for(auto i:a){
			long long int num=i.S;
			ans+=((num*(num-1))/2);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a,b;
    String op;
    for(;;){
      a = sc.nextInt();
      op = sc.next();
      b = sc.nextInt();
      if(op.equals("+")){
         System.out.println(a+b);
       }else if(op.equals("-")){
        System.out.println(a-b);
       }else if(op.equals("*")){
        System.out.println(a*b);
       }else if(op.equals("/")){
        System.out.println(a/b);
       }else if(op.equals("?")){
        sc.close();
        break;  
       }
    }
  }
}


Measured memory_bytes: 26304
#include<bits/stdc++.h>
using namespace std ;
long long a[3] ;
int main()
{
	cin >> a[0] >> a[1] >> a[2];
	sort ( a , a+3 ) ;
	for ( int i = 0 ; i < 3 ; i++)
		if ( a[i] % 2 == 0 ) 
		{
			cout << "0" << endl;
			return 0 ;

		}
	long long ans = a[0] * a[1] ;
		cout << ans << endl;


}

Measured memory_bytes: 256
import math

a,b,h,m = map(int, input().split())

h_rad = ((12-h)/6 - m/(60*6))*math.pi
m_rad = (60-m)/30*math.pi

x = a * math.cos(h_rad) - b * math.cos(m_rad)
y = a * math.sin(h_rad) - b * math.sin(m_rad)

distance = math.sqrt(x**2 + y**2)
print(distance)

Measured memory_bytes: 9584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << fixed << setprecision(8) << a / b << " " << a%b <<" "<< (long double)a / b << endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  int m = a[n-1];
  for (int i=1; i<n-1; i++) {
    if (a[i] >= 0) {
      m += a[i];
    } else {
      m -= a[i];
    }
  }
  m -= a[0];
  cout<<m<<endl;
  int left = a[0];
  int right = a[n-1];
  for (int i=1; i<n-1; i++) {
    if (a[i] >= 0) {
      cout<<left<<" "<<a[i]<<endl;
      left -= a[i];
    } else {
      cout<<right<<" "<<a[i]<<endl;
      right -= a[i];
    }
  }
  cout<<right<<" "<<left<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 5;
int z[maxn], sum[maxn], x[maxn], y[maxn];
long long ans[maxn];
int find(int x)
{
    return x == z[x] ? x : z[x] = find(z[x]); //这里一开始写错了，写成了x = find。。
}
void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        sum[a] += sum[b];
        sum[b] = 0;
        z[b] = a;
    }
}
int main()
{
    int n, m;
    while(cin >> n >> m)
    {
        for(int i = 0; i < maxn; i++) sum[i] = 1, z[i] = i;
        memset(ans, 0, sizeof(ans));
        for(int i = 1; i <= m; i++)
        {
            scanf("%d%d", &x[i], &y[i]);
        }
        long long cnt = n;
        ans[m+1] = cnt * (cnt-1) / 2;
        for(int i = m; i >= 2; i--)
        {
            int xx = find(x[i]), yy = find(y[i]);
            if(xx != yy)
            {
                ans[i] = ans[i+1] - sum[xx] * sum[yy];
                join(x[i], y[i]);
            }
            else
                ans[i] = ans[i+1];
        }
        for(int i = 2; i <= m+1; i++)
            printf("%lld\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=4e18;
const ll MOD=1e9+7;
const double EPS=1e-7;

ll N,T;
ll a[100010];
int main(){
    cin>>N>>T;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    ll mi=a[0];
    ll ma=-INF;
    ll ans=0;
    for(ll i=1;i<N;i++){
        if(a[i]-mi>ma){
            ma=a[i]-mi;
            ans=1;
        }else if(a[i]-mi==ma){
            ans++;
        }
        mi=min(mi,a[i]);
    }
    cout<<ans<<endl;
}

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

int func(vector<vector<int>> m,int a,int b,int c,int d){
    int ret=10;
    for(int i=b;i<=d;i++){
        ret=min({ret,m[a][i],m[c][i]});
    }
    for(int i=a;i<=c;i++){
        ret=min({ret,m[i][b],m[i][d]});
    }
    int ff=-1;
    a++;b++;c--;d--;
    for(int i=b;i<=d;i++){
        ff=max({ff,m[a][i],m[c][i]});
    }
    for(int i=a;i<=c;i++){
        ff=max({ff,m[i][b],m[i][d]});
    }
    if(ff>=ret){
        ret=-1;
    }
    return ret;
}

int main(){

    while(1){
        int d,w;
        cin >> d >> w;
        if(d==0)break;
        vector<vector<int>> m(d,vector<int>(w));
        for(int i=0;i<d;i++){
            for(int j=0;j<w;j++){
                cin >> m[i][j];
            }
        }
        int ans=0;
        for(int i=0;i<=d-3;i++){
            for(int j=0;j<=w-3;j++){
                for(int k=i+2;k<d;k++){
                    for(int l=j+2;l<w;l++){
                        int mi=func(m,i,j,k,l);
                        int su=0;
                        if(mi==-1)continue;
                        for(int s=i+1;s<k;s++){
                            for(int t=j+1;t<l;t++){
                                su+=max(0,mi-m[s][t]);
                            }
                        }
                        ans=max(ans,su);
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    REP(i, N) {
        cin >> m[i];
        X -= m[i];
    }
    sort(ALL(m));
    cout << X / m[0] + N << "\n";
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double EPS = 1e-10;

int main(){
    int w,h,v,t,sx,sy,gx,gy;
    cin>>w>>h>>v>>t>>sx>>sy>>gx>>gy;
    int rad = v*t;

    int stp=gx, diff=gx;
    while(stp+EPS > sx-rad){
        stp -= 2*diff;
        diff = w-diff;
    }
    stp += 2*(w-diff);

    long long int ans=0;
    for(int x=stp; x<=sx+rad; x+=2*diff, diff=w-diff){
        double d = sqrt((double)rad*rad -(double)(sx-x)*(sx-x));
        double lub[2]={d-sy, d+sy};
        for(int i=0; i<2; i++){
            if(lub[i]-gy+EPS > 0){ 
                ans += (long long int)((lub[i]-gy+EPS)/(2*h)+1);
            }
            if(lub[i]-(2*h-gy)+EPS > 0){
                ans += (long long int)((lub[i]-(2*h-gy)+EPS)/(2*h)+1);
            }
        }
        if(gy<lub[1] && gy<-lub[0]) ans -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int n, x[100];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	int cost;
	int max = 1000000;
	int z = 0;
	for (int p = 0; p < 100; p++)
	{
		cost = 0;
		for (int i = 0; i < n; i++)
		{
			cost += ((x[i] - p)*(x[i] - p));
		}
		if (cost < max)
		{
			max = cost;
			z = p;
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  cin >> N;
  if(((N % 10) == 9) || ((N / 10) == 9)){
    cout << "Yes" << endl;
  }else
    cout << "No" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



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

int sz = 1, cnt[100010];
pair<int, int> p[100010];
void rec(int r, int pos, const string &s){
	//cerr<<"r: "<<r<<" pos:"<<pos<<" s:"<<s<<endl;
	if(pos >= s.size()) {
		cnt[r]++;
		return;
	}
	if(s[pos] == '0'){
		if(!p[r].first) p[r].first = ++sz;
		rec(p[r].first, pos + 1, s);
	}
	else{
		if(!p[r].second) p[r].second = ++sz;
		rec(p[r].second, pos + 1, s);
	}
}
ll grundy(int r, ll l){
	//cerr<<"r: "<<r<<endl;
	if(!r) return l ? 1ll << __builtin_ctz(l) : 0ll;
	if(cnt[r]) return 0;

	ll res = 0;
	res ^= grundy(p[r].first, l - 1);
	res ^= grundy(p[r].second, l - 1);
	return res;
}

int main(){
	/*
	std::vector<int> v(1000);
	v[1] = 1;
	for(int i = 2; i < 1000; i++){
		set<int> s; s.insert(0);
		int g = 0;
		rep(j, i){
			g ^= v[i - j - 1];
			s.insert(g);
		}
		for(int j = 0; ; j++) if(!s.count(j)){
			v[i] = j;
			break;
		}
	}
	for(int i = 1; i < 1000; i++){
		
		cerr<<i<<" "<<v[i]<<" "<<__builtin_ctz(i)<<endl;
	}
	return 0;
	*/
	int n;
	ll l;
	cin >> n >> l;
	vector<string> in(n);
	rep(i, n){
		cin >> in[i];
		rec(1, 0, in[i]);
	}
	ll ans = grundy(1, l+1);
	cout << (ans ? "Alice" : "Bob") << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// ll abs(ll a) {
//     if (a >= 0) { return a; }
//     return -a;
// }

ll min(ll a, ll b) {
    if (a < b) { return a; }
    return b;
}

int main() {
    ll N, K, big, small;
    cin >> N >> K;

    ll div = N / K;
    ll num1 = abs(N - (K * div));
    // if (num1 < 0) { num1 = 2305843009213693951; }
    
    ll num2 = abs(N - (K * (div + 1)));
    // if (num2 < 0) { num2 = 2305843009213693951; }

    ll m = min(min(num1, num2), N);

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <utility>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;

int main(){
	int n, m;
	vector<pair<int, int>> st;
	vector<pair<int, int>> cp;
	int a, b;
	pair<int, int> p;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> a >> b;
		p.first = a;
		p.second = b;
		st.push_back(p);
	}
	for(int i=0; i<m; i++){
		cin >> a >> b;
		p.first = a;
		p.second = b;
		cp.push_back(p);
	}
	for(int i=0; i<n; i++){
		int min = INT_MAX;
		int num = 0;
		for(int j=0; j<m; j++){
			int dist = abs(st[i].first - cp[j].first) + abs(st[i].second - cp[j].second);
			if(dist < min) {
				min = dist;
				num = j + 1;
			}
		}
		cout << num << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int N_in;
int X_in;
int T_in;

int out;

int main(int argc, char* argv[]){
    int i,j;
    scanf("%d %d %d",&N_in, &X_in, &T_in);
    out = N_in/X_in;
    if(N_in % X_in >=1){
        out ++;
    }
    out *= T_in;

    printf("%d",out);
    
    return 0;
}

Measured memory_bytes: 1732
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    vl = list(map(int, input().split()))
    vl.sort()
    while len(vl) > 1:
        val = vl.pop(0)
        vl[0] = (vl[0] + val) / 2

    print(vl[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ans=0;
  if (a == d) {
    ans++;
  }
  if (b == e) {
    ans++;
  }
  if (c == f) {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	m := map[int]struct{}{}
	for i := a; i < a+k; i++ {
		if a <= i && i <= b {
			if _, ok := m[i]; !ok {
				fmt.Println(i)
				m[i] = struct{}{}
			}
		}
	}
	for i := b - k + 1; i <= b; i++ {
		if a <= i && i <= b {
			if _, ok := m[i]; !ok {
				fmt.Println(i)
				m[i] = struct{}{}
			}
		}
	}

}


Measured memory_bytes: 1856
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        int[] A = sc.IntArray();

        bool[]ball = new bool[N+1];

        var list = new List<int>();

        for (int i = N; i >= 1; i--)
        {
            int cnt = 0;
            for (int j = i + i; j <= N; j += i)
            {
                if (ball[j])
                    cnt++;
            }

            if (cnt % 2 == A[i - 1])
            {
                
            }
            else
            {
                ball[i] = true;
                list.Add(i);
            }
        }

        Console.WriteLine(list.Count);
        if(list.Count > 0)
            Console.WriteLine(string.Join(" ",list));
    }
}


class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 30168
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int ans = 0;
	string n;
	
	cin>>n>>K;
	
	// N = stoi(n);
	
	// for(int i = 1; i <= N; i++){
		// string num = to_string(i);
		// int con = count(num.begin(), num.end(), '0');
		
		// if(num.size() - con == K) {
			// cout<<i<<endl;
			// ans++;
		// }
	// }
	
	// cout<<ans<<endl;
	
	if(K == 1) {
		int con = ((int)n.size() - 1) * 9 + n[0] - '0';
		// cout<<"<> "<<n[0]<<" size "<<n.size()<<endl;
		cout<<con<<endl;
	} else if(K == 2) {
		// int con = ((int)n.size() - 1) * 9 * 9;
		int con =  9 * 9;
		int hoge = 0;
		
		
		// cout<<con<< " [] "<<(n.size()-0) * (n.size()-1) / 2<<endl;
		con *= (n.size()-0) * (n.size()-1) / 2;
		// for(int i = 0; i < (int)n.size()-1; i++){
			// hoge *= 9;
		// }
		
		// cout<<con<<" "<<hoge<<endl;
		con -= (9 - (n[0] - '0')) * (n.size()-1) * 9;
		
		int cc = 0;
		
		for(int i = 1; i < n.size(); i++){
			if(n[i] != '0' || n.size() == i + 1) {
				cc++;
				con -=  (9 - (n[i] - '0')) + hoge;
			}
			if(cc >= 1) break;
			// hoge /= 9;
			hoge += 9;
		}
		
		if(cc == 0) {
			
		}
		
		cout<<con<<endl;
	} 
	/* else if(K == 3) {
		int con =  9 * 9 * 9;
		int hoge = 0;
		cout<<con<< " [] "<<(n.size()-0) * (n.size()-1) * (n.size() - 2)/ 6<<endl;
		con *= (n.size()-0) * (n.size()-1) * (n.size() - 2)/ 6;
		cout<<con<<" "<<hoge<<endl;
		
		// con -= (9 - (n[0] - '0')) * (n.size()-1) * 9 * 9;
		con -= (9 - (n[0] - '0')) * 9 * 9 * (n.size()-1) * (n.size()-2) / 2;
		
		cout<<con<<endl;
		
		int cc = 0;
		
		for(int i = 1; i < n.size(); i++){
			// if(n[i] != '0' || n.size() == i + 1 || (cc == 0 && n.size() == i + 2)) {
			// if(n[i] != '0' || n.size() == i + 1 || (cc == 0 && n.size() == i + 2)) {
			if(n[i] != '0') {
				cc++;
				con -=  (9 - (n[i] - '0')) + hoge;
			}
			if(cc >= 2) break;
			// hoge /= 9;
			hoge += 9;
		}
		
		con += 9;
		
		cout<<con<<endl;


	}
	*/
	else if(K == 3) {
		int con =  9 * 9 * 9 *  (n.size()-1) * (n.size()-2) * (n.size() - 3)/ 6;
		
		for(int i = 0, cc = 0; i < n.size() && cc < 3; i++){
			if(n[i] != '0') {
				if(cc == 0) con += ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * (n[i] - '1') * 9 * 9;
				else if(cc == 1) con += ((int)n.size() - i - 1)  / 1 * (n[i] - '1') * 9 + ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * 9 * 9;
				else if(cc == 2) con += (n[i] - '0') + ((int)n.size() - i - 1) * 9;
				cc++;
			}
		}
		
		cout<<con<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 1LL << 20;
template<class T> inline bool chmin(T& a, T b) {
    if (b < a) {
        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;
}

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N, K;
    cin >> N >> K;
  
 	int h[100001];
 	ll c[100001];
    for(int i = 0; i < N; i++){
      cin >> h[i];
      c[i] = llINF;
    }

    c[0] = 0L;
    for(int i = 0; i < N; i++){
	    for(int j = 1; j <= K; j++){
	      int n = i+j;
          if(N <= n) continue;
          ll cn = (ll)abs(h[n] - h[i]) + c[i];
          chmin(c[n], cn);
    	}
    }

    cout << c[N-1] << endl; 
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <climits>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int a[100010];
int n;
int imos[100010];

bool check(int k)
{
	memset(imos, 0, sizeof imos);

	for (int i = 0; i <= n - k; ++i) {
		if (i > 0) imos[i] += imos[i - 1];
		if ((a[i] + imos[i]) % 2 == 1) {
			imos[i]++;
			imos[i+k]--;
		}
	}
	for (int i = n - k + 1; i < n; ++i) imos[i] += imos[i - 1];

	for (int i = n - k + 1; i <= k - 1; ++i) {
		if ((a[i] + imos[i]) % 2 == 1) {
			return false;
		}
	}

	return true;
}

signed main()
{
	{
		string s; cin >> s;
		n = s.size();

		rep(i, n) a[i] = s[i] - '0';
	}

	int l = 1, r = n + 1;

	while (r - l > 1) {
		int m = (l + r) / 2;

		if (check(m)) {
			l = m;
		} else {
			r = m;
		}
	}

	cout << l << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a;
string s;

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] h = new int[N];
		int[] m = new int[N];
		for(int i = 0 ; i<N ; i++){
			h[i] = scan.nextInt();
			m[i] = scan.nextInt();
		}
		int M = scan.nextInt();
		int[] k = new int[M];
		int[] g = new int[M];
		int[] Z = new int[N+M];
		for(int i = 0 ; i<N ; i++){
			Z[i] =  h[i]*60+m[i];
		}
		for(int i = 0; i<M ; i++){
			k[i] = scan.nextInt();
			g[i] = scan.nextInt();
			Z[N+i] = k[i]*60+g[i];
		}
		int r;
		for(int i = 0; i < N+M ; i++){
			for(int j = i+1; j <M+N; j++){
				if(Z[i] > Z[j]){
					r = Z[i];
					Z[i] = Z[j];
					Z[j] = r;
				}
			}
		}
		for(int i = 0; i<N+M; i++){
			if(i == N+M-1){
				String s = String.valueOf(Z[i]%60);
				if(s.length() ==1){
					System.out.println(Z[i]/60+":0"+Z[i]%60);
				}else{
					System.out.println(Z[i]/60+":"+Z[i]%60);
				}
			}else{
				if(Z[i+1] != Z[i]){
					String s = String.valueOf(Z[i]%60);
					if(s.length() ==1){
						System.out.print(Z[i]/60+":0"+Z[i]%60+" ");
					}else{
						System.out.print(Z[i]/60+":"+Z[i]%60+" ");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20828
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int MAX = -1;
   int MIN = 1001;
   int a;
   for (int i = 0; i < N; i++) {
      cin >> a;
      chmax(MAX, a);
      chmin(MIN, a);
   }
   cout << MAX - MIN << endl;

   return 0;
}


Measured memory_bytes: 256
S = input()

len_S = len(S)
if len_S % 2 == 0:
    half_len = int(len_S / 2)
else:
    half_len = int(len_S / 2) + 1

idx = None
target = None

for i in range(half_len):
    if S[i] == S[-i-1]:
        if target == None:
            target = S[i]
            idx = i
        else:
            if S[i] != target:
                target = S[i]
                idx = i
            else:
                continue
    else:
        target = None
        idx = None

if idx != None:
    print(len_S - idx)
else:
    print(half_len)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> v(n),c(n);
  int ans=0;
  for(int i=0;i<n;i++) cin>>v[i];
  for(int i=0;i<n;i++) cin>>c[i];

  for(int i=0;i<n;i++){
    ans+=max(0,v[i]-c[i]);
  }
  cout<<ans<<endl;

  return 0;
}


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

int main(){
  static const double pi = acos(-1);
  int A,B,H,M;
  cin >> A >> B >> H >> M;

  double X = (30*H+0.5*M);
  double Y = (6*M);
  double x1 = A * cos(pi/2-pi/180*X);
  double y1 = A * sin(pi/2-pi/180*X);
  double x2 = B * cos(pi/2-pi/180*Y);
  double y2 = B * sin(pi/2-pi/180*Y);

  //cout << x1 << y1 << x2 << y2 << endl;

  double a = pow(x1-x2,2);
  double b = pow(y1-y2,2);

  double c = sqrt(a+b);

  cout << fixed << setprecision(10) << hypot(x2-x1,y2-y1) << endl;





}


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

int main(void)
{
  int W, H, N;
  std::cin >> W >> H >> N;

  bool rect[W][H] = {false};
  for (int i = 0; i < N; i++) {
    int x, y, a;
    std::cin >> x >> y >> a;

    // x--;  y--;

    if (a == 1) {
      for (int w = 0; w < x; w++) {
        for (int h = 0; h < H; h++) {
          rect[w][h] = true;
        }
      }
    }

    if (a == 2) {
      for (int w = x; w < W; w++) {
        for (int h = 0; h < H; h++) {
          rect[w][h] = true;
        }
      }
    }

    if (a == 3) {
      for (int h = 0; h < y; h++) {
        for (int w = 0; w < W; w++) {
          rect[w][h] = true;
        }
      }
    }

    if (a == 4) {
      for (int h = y; h < H; h++) {
        for (int w = 0; w < W; w++) {
          rect[w][h] = true;
        }
      }
    }
  }

  int cnt = 0;
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (!rect[i][j]) {
        cnt++;
      }
    }
  }

  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define pb push_back
const int N=1e5+5;
 
inline int read(){
    int x=0; char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
void W(int x){ if(x>=10) W(x/10); putchar(x%10+'0');}
 
vector<int> g[N];
int mx[N],n,col[N],Q,d[N],c[N],m,p[N];
 
void dfs(int x){
    if(!col[x]) col[x]=c[Q];
    for(int i:g[x]) if(mx[x]-1>mx[i]) mx[i]=mx[x]-1,dfs(i);
}
 
int main(){
    memset(mx,-1,sizeof(mx));
     
    n=read(),m=read();
    for(int i=1,uu,vv;i<=m;i++)
        uu=read(),vv=read(),g[uu].pb(vv),g[vv].pb(uu);
    Q=read();
    for(int i=1;i<=Q;i++) p[i]=read(),d[i]=read(),c[i]=read();
     
    for(;Q;Q--) if(d[Q]>mx[p[Q]]) mx[p[Q]]=d[Q],dfs(p[Q]);
     
    for(int i=1;i<=n;i++) W(col[i]),puts("");
    return 0;
}

Measured memory_bytes: 8440
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1;;i++){
            int x = sc.nextInt();
            if(x==0) break;
            System.out.printf("Case %d: %d\n",i,x);
            }
            sc.close();
    }
}


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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 3e3 + 5;
int n , sum;
int a[N];
int dp[N][N];

main()
{
    //freopen("L.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
    {
        cin >> a[i];
        sum += a[i];
    }
    FOR(i , 1 , n)
        dp[i][i] = a[i];
    FOR(i , 1 , n - 1)
        dp[i][i + 1] = max(a[i] , a[i + 1]);
    FOR(r , 1 , n)
        FORD(l , r - 2 , 1)
            dp[l][r] = max(min(dp[l + 2][r] , dp[l + 1][r - 1]) + a[l] , min(dp[l][r - 2] , dp[l + 1][r - 1]) + a[r]);
    cout << dp[1][n] - (sum - dp[1][n]);
}


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

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

    unordered_map<int, int> mp;
    REP(i, 3){
        int a;
        cin >> a;
        mp[a]++;
    }

    for(auto x : mp){
        if(x.second == 1){
            cout << x.first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 998244353; INF = float("inf")

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M, K = getlist()
	if N == 1:
		print(M)
		return

	Com = Combination(N - 1, con)
	ans = 0
	for i in range(N - 1 - K, N):
		ans += Com.com(N - 1, i) * pow(M - 1, i, con)
		ans %= con
	ans *= M
	ans %= con
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 73188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0;
  string s;
  std::cin >> x>>y;
  rep(i,y){
    std::cin >> z;
    w+=z;
  }
  if(x>w)std::cout << "No" << '\n';
  else std::cout << "Yes" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,i,j,K;


int main()
{
  cin>>N;

  i=1;
  while(N>0)
  {
    N=N/2;
    i=i*2;
  }
  i=i-1;
  
  cout <<i;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;

int main() {
  int x; cin >> x;
  vector<bool> expo(x+1);
  expo[1] = 1;
  for(int b=2;b<=x;b++){
    int v = b*b;
    while(v<=x){
      expo[v]=1;
      v*=b;
    }
  }
  for(int i=x;i>=1;i--)if(expo[i]){
    cout << i << endl;
    return 0;
  }
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n;
		n=sc.nextInt();
		int ans=0;
		int k;
		for(int i=0;i<15;i++)
		{
			for(int j=0;j<26;j++)
			{
				k=7*i+4*j;
				if(k==n)
				{
					ans=1;
					break;
				}
				if(k>n)
					break;
			}
		}
		if(ans==1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

bool linear_search(int key, vector<int> A, int sentinal) {
    int i = 0;
    A.push_back(key);
    while (A[i] != key) {
        i++;
        if (i == sentinal) {
            return false;
        }
    }
    return true;
}

int main() {
    int n, q;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++) {
        cin >> T[i];
    }

    int cnt = 0;

    for (int i = 0; i < q; ++i) {
        int key = T[i];
        if(linear_search(key, S, n)) {
            cnt++;
        };
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pb push_back
using namespace std;

const int N = 1e5 + 2;

struct Point {
	int x, y, id;
};

int n;
Point p[N], og[N];
vector<pair<int, int>>edges;

bool cmp1(const Point &a, const Point &b ) {
	if (a.x == b.x)return a.y < b.y;
	return a.x < b.x;
}
bool cmp2(const Point &a, const Point &b) {
	if (a.y == b.y)return a.x < b.x;
	return a.y < b.y;
}

int cost(pair<int, int>a) {
	int d1 = min(abs(og[a.first].x - og[a.second].x), abs(og[a.first].y - og[a.second].y));
	return d1;
}


bool cmpEdges(const pair<int, int>&a, const pair<int, int>&b) {
	return cost(a) < cost(b);
}

void buildEdges(bool tip) {
	if (!tip) sort(p, p + n, cmp1);
	else sort(p, p + n, cmp2);
	set<pair<int, int>>y;
	map < int, vector<pair<int, int>>>coords;
	for (int i = 0; i < n; ++i) {
		coords[p[i].x].emplace_back(p[i].y, p[i].id);
	}
	for (auto &all : coords) {
		auto &vec = all.second;
		sort(vec.begin(), vec.end());
		for (auto &itr : vec) {
			if(y.empty()) continue;
			auto good = y.lower_bound(make_pair(itr.first, -1));
			if (good != end(y)) {
				edges.emplace_back(itr.second, good->second);
			}
			if (good != begin(y)) {
				good--;
				edges.emplace_back(good->second, itr.second);
			}
		}
		for (int i = 0; i < vec.size() - 1; ++i)
			edges.emplace_back(vec[i].second, vec[i + 1].second);
		for (auto &itr : vec)
			y.insert(make_pair(itr.first, itr.second));
	}
	y.clear();
	for (auto all = coords.rbegin(); all != coords.rend(); ++all) {
		auto &vec = all->second;
		for (auto &itr : vec) {
			if(y.empty()) continue;
			auto good = y.lower_bound(make_pair(itr.first, -1));
			if (good != end(y)) {
				edges.emplace_back(itr.second, good->second);
			}
			if (good != begin(y)) {
				good--;
				edges.emplace_back(good->second, itr.second);
			}
		}
		for (int i = 0; i < vec.size() - 1; ++i)
			edges.emplace_back(vec[i].second, vec[i + 1].second);
		for (auto &itr : vec)
			y.insert(make_pair(itr.first, itr.second));
	}
}

int dsu[N];

int get(int node) {
	if (node == dsu[node]) {
		return node;
	}
	return dsu[node] = get(dsu[node]);
}

void join(int a, int b) {
	a = get(a);
	b = get(b);
	dsu[a] = b;
}

void initdsu() {
	for (int i = 0; i < n; ++i) {
		dsu[i] = i;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i].x >> p[i].y, p[i].id = i, og[i] = p[i];
	sort(p, p + n, cmp1);
	for (int i = 1; i < n; ++i) {
		edges.emplace_back(p[i].id, p[i - 1].id);
	}
	sort(p, p + n, cmp2);
	for (int i = 1; i < n; ++i) edges.emplace_back(p[i].id, p[i - 1].id);
	buildEdges(0);
	for (int i = 0; i < n; ++i) swap(p[i].x, p[i].y);
	buildEdges(1);
	initdsu();
	sort(edges.begin(), edges.end(), cmpEdges);
	long long apm = 0;
	for (auto itr : edges) {
		if(itr.first == itr.second)
			continue;
		if (get(itr.first) != get(itr.second))
			apm += cost(itr), join(itr.first, itr.second);
	}
	cout << apm;

}


Measured memory_bytes: 28268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
# define PI           3.14159265358979323846  /* pi */
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       double a,b,h,m,am;
       double c,ang;
       cin>>a>>b>>h>>m;
       am=(h+(m/60))*5;
       //cout<<am<<" "<<(max(am,m)-min(am,m))<<" ";
       if((max(am,m)-min(am,m))>30)
       ang=360-((max(am,m)-min(am,m))*6);
       else
       ang=((max(am,m)-min(am,m))*6);
       //cout<<ang<<" ";
       ang=(ang*PI)/180;
       //cout<<ang<<" "<<cos(ang)<<" ";
       c=a*a+b*b-2*a*b*cos(ang);
       //cout<<c<<" ";
       c=sqrt(c);
       cout.precision(25);
       cout<<c;
    }        
    return 0;
}

Measured memory_bytes: 4240
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[10000];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        while(arr[i]%2==0)
        {
            arr[i]/=2;sum++;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 384
#include <stdio.h>

int main (void){

	int N, M, C;
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &C);

	int i, j;
	int B[100] = {};

	for(j = 0; j < M; j++){
		scanf("%d", &B[j]);
	}
	
	int A[100][100] = {};

	for(i = 0; i < N; i++){
		for(j = 0; j < M; j++){
			scanf("%d", &A[i][j]);
		}
	}	

	int count = 0;
	int sum = 0;

	for(i = 0; i < N; i++){
		sum = 0;

		for(j = 0; j < M; j++){
			sum = sum + A[i][j] * B[j];
		}

		if(sum + C > 0){
			count++;
		}
	}

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

}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()
ok = 10**12
ng = -1
while ng+1 < ok:
    c = (ok+ng) // 2
    k = K
    for a, f in zip(A, F):
        k -= max(0, a - c//f)
    if k >= 0:
        ok = c
    else:
        ng = c
print(ok)


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

int main(){
    int H, W;
    cin >> H >> W;
    int costs[10][10];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> costs[i][j];
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                costs[j][k] = min(costs[j][k], costs[j][i] + costs[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < H * W; i++){
        int num;
        cin >> num;
        if(num != -1){
            ans += costs[num][1];
        }
    }
    cout << ans << endl;
}


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

const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(100100);
  rep(i,n) cin >> h[i];
  vector<int> dp(100100,INF);
  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    for(int j = 1; j <= k; j++){
      if(i > j-1) {
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n;
char s[3005];
int dp[3005][3005];
int si[3005][3005];

int main(){
	cin>>n;
	cin>>s+1;
	dp[1][1]=1;
	for(int i=1;i<=n;i++) si[1][i]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(s[i-1]=='>') dp[i][j]=(si[i-1][i-1]-si[i-1][j-1]+mod)%mod;
			else dp[i][j]=si[i-1][j-1];
		}
		for(int j=1;j<=i;j++){
			si[i][j]=si[i][j-1]+dp[i][j];
			si[i][j]%=mod;
		}
	}
	cout<<si[n][n]<<endl;

	return 0;
}

Measured memory_bytes: 69504