akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include<math.h>
    #include<algorithm> 
    #define rep(i,n) for (int i = 0; i < (n) ; ++i)
    using namespace std;
    using ll = long long ;
    using P = pair<int, int> ;
    #define PI 3.14159265358979323846264338327950
    #define INF 1e18
     
    struct UnionFind {
        vector<int> d ;
        UnionFind(int n = 0): d(n, -1) {} 
        int find(int x){
            if(d[x] < 0) return x ;
            return find(d[x]) ;
        }
        bool unite(int x, int y) {
            x = find(x) ; y = find(y) ;
            if(x == y) return false ;
            if(d[x] > d[y]) swap(x, y) ;
            d[x] += d[y] ;
            d[y] = x ;
            return true ;
        }
        bool same (int x, int y){
            return find(x) == find(y) ;
        }
        int size(int x){return -d[find(x)]; }
    };
     
    int d [100005] ;
    vector<int> blk [100005] ;
     
    int main(){
        int n, m, k ;
        cin >> n >> m >> k ;
        UnionFind uf(n) ;
        rep(i, m){
            int a, b ;
            cin >> a >> b ;
            a-- ; b-- ;
            d[a]++ ; 
            d[b]++ ;
            uf.unite(a, b) ;
        }
        rep(i, k){
            int c, d ;
            cin >> c >> d ;
            c-- ; d-- ;
            blk[c].push_back(d) ;
            blk[d].push_back(c) ;
        }
        rep(i, n){
            int ans = uf.size(i) - 1 - d[i] ;
            for(int u : blk[i]){
                if(uf.same(i, u)){
                    ans-- ;
                }
            }
            cout << ans << " "  ;
        }
        cout << endl ;
    }

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

int d[11][11];
int main(){
    int N,D;
    cin>>N>>D;
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            int x;
            cin>>x;
            d[i][j]=x;
        }
    }

    int ans=0;

    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            long int k=0;
            for(int p=0;p<D;p++) k+=(d[i][p]-d[j][p])*(d[i][p]-d[j][p]);
            int t=sqrt(k);
            if(k==t*t) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
from collections import Counter
n = int(input())

la = [int(i) for i in input().split()]

c = Counter(la)

total = 0
for i, num in c.most_common():
  if num > 1:
    total += num * (num-1) // 2
  
for ai in la:
  n = c[ai]
  print(total-n+1)

Measured memory_bytes: 97484
#include <bits/stdc++.h>
 
using namespace std;
string s;
long long su,n,dp[4][100][2],mod=1e9+7,r;
int main()
{
    cin>>s>>n;
  	r=s.size();
    for (int i=0;i<s[0]-'0';i++) dp[0][i%n][0]++;
    dp[0][(s[0]-'0')%n][1]++;
    for (int i=1;i<s.size();i++)
    {
      	for (int j=0;j<100;j++) for (int k=0;k<2;k++) dp[i%2][j][k]=0;
        for (int j=0;j<=9;j++)
        {
            for (int k=0;k<n;k++)
            {
                dp[i%2][(k+j)%n][0]+=dp[(i-1)%2][k][0]%mod;
                dp[i%2][(k+j)%n][0]%=mod;
                if (j>s[i]-'0') continue;
                else if (j==s[i]-'0')
                {
                    dp[i%2][(k+j)%n][1]+=dp[(i-1)%2][k][1]%mod;
                    dp[i%2][(k+j)%n][1]%=mod;
                }
                else
                {
                    dp[i%2][(k+j)%n][0]+=dp[(i-1)%2][k][1];
                    dp[i%2][(k+j)%n][0]%=mod;
                }
            }
        }
    }
    cout<<(dp[(s.size()-1)%2][0][0]%mod+(dp[(s.size()-1)%2][0][1]%mod-1+mod)%mod)%mod;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  vi score(N);
  rep(i,N) cin >> score[i];
  rep(i,N-K){
    if(score[i+K]>score[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
return 0;
}


Measured memory_bytes: 4008
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String line = in.nextLine();
    int n = Integer.parseInt(line.split(" ")[0]);
    int s1 = Integer.parseInt(line.split(" ")[1]);
    int f1 = Integer.parseInt(line.split(" ")[2]);
    int s2 = Integer.parseInt(line.split(" ")[3]);
    int f2 = Integer.parseInt(line.split(" ")[4]);
    String fld = in.nextLine();
    in.close();
    
    String snr = fld.substring(s1-1, s2);
    String fnr = fld.substring(f1-1, f2);
    String o = "...";
    if (f2 < s2) o = fld.substring(f1-2, f2+1);
    if ( !snr.contains("##") && !fnr.contains("##") && o.contains("...")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 28936
#include <iostream>

int n, a[50];
int memo[22][2001];

int solve(int i, int m) {

  if (memo[i][m] != -1) {
    return memo[i][m];
  }

  if (m == 0) {
    memo[i][m] = 1;
    return 1;
  }

  if (i > n) {
    memo[i][m] = 0;
    return 0;
  }

  int res = solve(i+1, m) || solve(i+1, m-a[i]);
  memo[i][m] = res;
  return res;

}

int main() {

  std::cin >> n;

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

  int q;
  std::cin >> q;

  for (int i = 0; i < 22; i++) {
    for (int j = 0; j < 2001; j++) {
      memo[i][j] = -1;
    }
  }

  for (int i = 0; i < q; i++) {

    int m;
    std::cin >> m;

    if (solve(0, m)) {
      std::cout << "yes" << std::endl;
    } else {
      std::cout << "no" << std::endl;
    }
  }

    return 0;

}



Measured memory_bytes: 3268
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			/*
			 * {
			 * Dice dice=new Dice(1,2,3,4,5,6);
			 * dice.rollX();
			 * println(dice.is[0]+"");
			 * dice=new Dice(1,5,3,4,2,6);
			 * dice.rollY();
			 * println(dice.is[0]+"");
			 * dice=new Dice(1,5,3,4,2,6);
			 * dice.rollZ();
			 * println(dice.is[0]+"");
			 * 
			 * }
			 */
			Dice dice=new Dice(1, 2, 3, 4, 5, 6);
			for(int i=0; i<n; i++){
				// news
				// top,northツ猟按つス ,westツづ可つオ
				switch(sc.next().charAt(0)){
				case 'n':
					dice.rollX();
					break;
				case 'e':
					dice.rollY();
					break;
				case 'w':
					dice.rollY();
					dice.rollY();
					dice.rollY();
					break;
				case 's':
					dice.rollX();
					dice.rollX();
					dice.rollX();
					break;
				}
			}
			println(dice.is[0]+"");
		}
	}

	class Dice{
		// top, front, left, right, back, bottom
		int[] is=new int[6];

		Dice(int... is){
			this.is=is;
		}

		void rollX(){
			roll(0, 1, 5, 4);
		}

		void rollY(){
			roll(0, 3, 5, 2);
		}

		void rollZ(){
			roll(1, 3, 4, 2);
		}

		void roll(int a, int b, int c, int d){
			int t=is[d];
			is[d]=is[c];
			is[c]=is[b];
			is[b]=is[a];
			is[a]=t;
		}

		Dice[] rollAll(){
			Dice[] dices=new Dice[24];
			for(int i=0; i<6; i++){
				for(int j=0; j<4; j++){
					dices[i*4+j]=new Dice(is.clone());
					rollZ();
				}
				if((i&1)>0)
					rollX();
				else
					rollY();
			}
			return dices;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;
int a[100010];
int b[100010];
ivec pos;
//ivec neg;
int neg;
signed main(){
  int n;cin>>n;
  int sum=0;
  int ans=0;
  rep(i,n)cin>>a[i];
  rep(i,n){
    cin>>b[i];
    sum+=a[i]-b[i];
    if(a[i]-b[i]<0){
      neg+=b[i]-a[i];
      ans++;
    }
    else if(a[i]-b[i]>0)pos.pb(a[i]-b[i]);
  }
  if(sum<0){
    cout<<-1<<endl;
    return 0;
  }
  if(neg==0){
    cout<<0<<endl;
    return 0;
  }
  sort(all(pos),greater<int>());
  int ima=0;
  for(ima=0;neg>0;ima++){
    neg-=pos[ima];
  }
  ans+=ima;
    
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5224
//素因数分解NTL_1_A
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
//素因数分解をするアルゴリズム
template<typename T>
vector<T> prime_factorization(T n) {
	vector<T> res;
	T check = 2;

	while (check*check <= n) {
		if (n%check == 0) {
			n /= check;
			res.push_back(check);
		}
		else {
			check++;
		}
	}
	if (n != 1) res.push_back(n);
	sort(res.begin(), res.end());
	return res;
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> ans=prime_factorization(n);
  cout<<n<<':';
  for(auto x:ans){
    cout<<' '<<x;
  }
  cout<<'\n';
  return(0);
}


Measured memory_bytes: 3224
N,A,B = map(int,input().split())
S = input()
countA = 0
countB = 0

for i in range(len(S)):
  if S[i] == 'a' and countA + countB < A + B:
    countA += 1
    print('Yes')
  elif S[i] == 'b' and countA + countB < A + B and countB < B:
    countB += 1
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int h1,m1,h2,m2,k;
int main(){
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	printf("%d\n",h2*60+m2-(h1*60+m1)-k);
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=105;
const int max_m=1005;
const int inf=0x3f3f3f3f;
struct edge{
    int u,v,cap,next;
}G[max_m*2];
int head[max_n],dep[max_n],cur[max_n],tot;
void init(int n){
    tot=0;
    for(int i=0;i<=n;i++)head[i]=-1;
}
void add_edge(int u,int v,int cap){
    G[tot]={u,v,cap,head[u]};
    head[u]=tot++;
}
void bfs(int s,int n){
    for(int i=0;i<=n;i++)dep[i]=-1;
    queue<int> que;
    dep[s]=0;
    que.push(s);
    while(!que.empty()){
        int u=que.front();que.pop();
        for(int i=head[u];~i;i=G[i].next){
            int v=G[i].v,cap=G[i].cap;
            if(cap&&dep[v]==-1){
                dep[v]=dep[u]+1;
                que.push(v);
            }
        }
    }
}
int dfs(int u,int t,int flow){
    if(u==t)return flow;
    int sum=0;
    for(int& i=cur[u];~i;i=G[i].next){
        int v=G[i].v,cap=G[i].cap;
        if(cap&&dep[v]==dep[u]+1){
            int d=dfs(v,t,min(flow,cap));
            if(d){
                G[i].cap-=d;
                G[i^1].cap+=d;
                sum+=d;
                flow-=d;
                if(!flow)break;
            }
        }
    }
    if(!sum)dep[u]=-1;
    return sum;
}
ll max_flow(int s,int t,int n){
    ll flow=0;
    while(1){
        bfs(s,n);
        if(dep[t]<0)return flow;
        for(int i=0;i<=n;i++)cur[i]=head[i];
        int f;
        while((f=dfs(s,t,inf))>0)flow+=f;
    }
}
int n,a[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    ll ans=0;
    for(int i=1;i<=n;i++)if(a[i]>=0)ans+=a[i];
    int src=0,trg=n+1;
    init(n+1);
    for(int i=1;i<=n;i++){
        if(a[i]>=0)add_edge(src,i,a[i]),add_edge(i,src,0);
        else add_edge(i,trg,-a[i]),add_edge(trg,i,0);
    }
    for(int i=1;i<=n;i++){
        for(int j=i*2;j<=n;j+=i){
            add_edge(j,i,inf),add_edge(i,j,0);
        }
    }
    printf("%lld\n",ans-max_flow(src,trg,n+1));
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iostream>
using namespace std;
int a, b, B, c, x, i;

int main()
{
    cin>>a>>b;
    B = b;
    while(B>=1){
        B = B / 10;
        a = a * 10;
    }
    c = a + b;
    
    while(i<=x){
        i++;
        x = i * i;
        if(x==c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;
int main() {
    ll n,ans=0; 
    cin>>n;
    vector<ll>a(n),count(n,0);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    while(a!=count){
        for(ll i=0;i<n;i++){
            if(a[i]!=count[i]){
                for(ll j=0;i+j<n;i++){
                    if(count[i+j]!=a[i]){
                        count[i+j]++;
                    }
                    else{
                        break;
                    }
                }
                /*for(ll i=0;i<n;i++){
                    cout<<count[i]<<endl;
                } */  

                ans++;
            }
        }

    }
    cout<<ans<<endl;

}


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

using namespace std;

int main(){
	int n;
	std::cin >> n;cin.get( );
	for(int i=0;i<n;i++){
		string s;
		getline(cin, s);
		for(int j=6;j<s.size();j++){
			if(s.substr(j-6,7)=="Hoshino"){
				s.at(j)='a';
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
with open(0) as f:
    C = [list(map(int, line.split())) for line in f.readlines()]
b = [(C[i][1]-C[i][0], C[i][2]-C[i][1]) for i in range(3)]
a = [(C[1][j]-C[0][j], C[2][j]-C[1][j]) for j in range(3)]
print('Yes' if a[0]==a[1]==a[2] and b[0]==b[1]==b[2] else 'No')

Measured memory_bytes: 9068
#pragma GCC optimize("Ofast", "unroll-loops", "no-stack-protector")
#include <bits/stdc++.h>
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define mem(x, y) memset((x), (y), sizeof(x))
#define loli ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename Ta, typename Tb>istream &operator>>(istream &in, pair<Ta, Tb> &p){ return in >> p.F >> p.S; }
template<typename Ta, typename Tb>ostream &operator<<(ostream &out, pair<Ta, Tb> &p){ return out << p.F << " " << p.S; }
template<typename T>void arr_print(T a, T b){ T i = a; for(cout << *i++; i != b; i++) cout << " " << *i; cout << "\n"; }
template<typename T>ostream &print(T a){ return cout << a << "\n"; }
template<typename T, typename... Args>ostream &print(T a, Args ...args){ cout << a << " "; return print(args...); }

//--------------------Main Code--------------------

int main() {loli
	int h, w, K, cnt = 0, tcnt, ans = 0;
	char c[6][6], tmp[6][6];
	cin >> h >> w >> K;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++){
			cin >> c[i][j];
			if(c[i][j] == '#')
				cnt++;
		}
	for(int i = 0; i < (1 << h); i++)
		for(int j = 0; j < (1 << w); j++){
			tcnt = cnt;
			for(int k = 0; k < h; k++)
				for(int l = 0; l < w; l++)
					tmp[k][l] = c[k][l];
			for(int k = 0; k < h; k++)
				if(i >> k & 1)
					for(int l = 0; l < w; l++){
						if(tmp[k][l] == '#')
							tcnt--;
						tmp[k][l] = '&';
					}
			for(int k = 0; k < w; k++)
				if(j >> k & 1)
					for(int l = 0; l < h; l++){
						if(tmp[l][k] == '#')
							tcnt--;
						tmp[l][k] = '&';
					}
			if(tcnt == K)
				ans++;
		}
	cout << ans << "\n";
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define endl "\n"
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const N = 32000;

int main()
{
    BMW_GTR;

    double D, T, S;
    cin >> D >> T >> S;

    if(D / S <= T)cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,k; cin>>n>>k;
  VI h(n); rep(i,n) cin>>h[i];
  int ans = 0;
  rep(i,n){
    if(h[i]>=k) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    vector<int> v(sz(s));
    rep(i,sz(s)){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
            if(i == 0) v[i] = 1;
            else v[i] = v[i-1]+1;
        }
    }
    int ans = 0;
    rep(i,sz(s)){
        ans = max(ans,v[i]);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main()
{
	char a;
	cin >> a;
	cout << char(a + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const int mod = 1000000007;
int n;
int main(){ //srand((unsigned)time(NULL));
  cin >> n;
  cout << roundup(n,2) << endl;
}


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

using namespace std;


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

    vector<long long> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
    }

    long long min_val = p.at(0);
    long long counter = 1;

    for (int i=1; i<n; i++) {
        if (min_val >=  p.at(i)) {
            counter++;
            min_val = p.at(i);
        }
        
    }

    cout << counter << endl;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int h,w;
  int i,j;

  while(1){

    scanf("%d %d",&h,&w);
    if(h ==0 && w == 0)break;


    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2088
# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))

count = 0
for i in l:
    num = i
    count_i = 0
    while True:
        if num % 2 == 0:
            num = num/2
            count_i += 1
        else:
            break

    count += count_i

print(count)

Measured memory_bytes: 4148
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int par[200];
int rank1[200];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find1(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find1(par[x]);
	}
}
void unite1(int x, int y) {
	x = find1(x);
	y = find1(y);
	if (x == y)return;
	if (rank1[x] < rank1[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank1[x] == rank1[y])rank1[x]++;
	}
}
bool same(int x, int y) {
	return find1(x) == find1(y);
}
struct edge { int u, v, cost,col; };
bool comp(const edge&e1, const edge&e2) {
	if (e1.cost != e2.cost) {
		return e1.cost < e2.cost;
	}
	return e1.col < e2.col;
}
edge cop[600];
int V, E;
int k;
P kruskal() {
	sort(cop, cop + E, comp);
	init(V);
	int res = 0; int cost = 0;
	for (int i = 0; i < E; i++) {
		edge e = cop[i];
		if (!same(e.u, e.v)) {
			unite1(e.u, e.v);
			cost += e.cost;
			if (e.col == 0) {
				res++;
			}
		}
	}
	return { res,cost };
}
edge ori[600];
void init2() {
	rep(i, E) {
		cop[i] = ori[i];
	}
	return;
}
bool ooo(int x) {
	init2();
	rep(i, E) {
		if (cop[i].col == 0) {
			cop[i].cost += x;
		}
	}
	P r = kruskal();
	if (r.first < k) {
		return false;
	}
	return true;
}
int main() {
	while (cin >> V >> E >> k, V) {
		int le = -1000000; int ri = 1000000;
		rep(i, E) {
			int x, y, z;char w;
			cin >> x >> y >> z >> w; x--; y--;
			ori[i] = { x,y,z,w - 'A' };
		}
		while (ri - le > 1) {
			int mid = (ri + le) / 2;
			if (ooo(mid)) {
				le = mid;
			}
			else {
				ri = mid;
			}
		}
		init2();
		rep(i, E) {
			if (cop[i].col == 0) {
				cop[i].cost += le;
			}
		}
		P fin1 = kruskal();
		init2();
		rep(i, E) {
			if (cop[i].col == 0) {
				cop[i].cost += ri;
			}
		}
		P fin2 = kruskal();
		if (fin1.first < k || k < fin2.first) {
			cout << -1 << endl; continue;
		}
		bool f = true;
		rep(i, V) {
			rep(j, V) {
				if (!same(i, j)) {
					f = false;
				}
			}
		}
		if (!f) {
			cout << -1 << endl; continue;
		}
		cout << fin1.second - k * le << endl;
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
 
  if (s.back() == 'F') s += 'T';
  int x, y;
  cin >> x >> y;
  x += 8000, y += 8000;
  vector<int> dx, dy;
  int cnt = 0;
  int f = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'T') {
      if (f % 2 == 0) dx.emplace_back(cnt);
      else dy.emplace_back(cnt);
      cnt = 0;
      f++;
    } else cnt++;
  } 
  int n = dx.size(), m = dy.size();
  vector<bool> dp1(16010, false), dp2(16010, false);
  dp1[8000] = true;
  for (int i = 0; i < n; i++) {
    vector<bool> next(16010, false);
    for (int j = 0; j < 16010; j++) {
      if (!dp1[j]) continue;
      next[j + dx[i]] = true;
      if (i > 0) next[j - dx[i]] = true;
    }
    dp1 = next;
  }
  dp2[8000] = true;
  for (int i = 0; i < m; i++) {
    vector<bool> next(16010, false);
    for (int j = 0; j < 16010; j++) {
      if (!dp2[j]) continue;
      next[j + dy[i]] = true;
      next[j - dy[i]] = true;
    }
    dp2 = next;
  }
  if (dp1[x] && dp2[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
N = int(input())

monsters = list(map(int, input().split()))
powers = list(map(int, input().split()))

# dp[i] = i番目の街のモンスターを最も多く倒せる数
dp = [0 for _ in range(N + 1)]

# 初期条件
# 勇者パワーの方が少ない場合その数しか倒せない
# モンスター数の方が少ない場合もその数しか倒せない
# print(f"powers: {powers}")
dp[N] = min(monsters[N], powers[N - 1])
# 勇者の火力を減らしておく
powers[N - 1] -= dp[N]
# Nから-1ずつ下がって0まで処理する
for i in range(N - 1, 0, -1):
    # print(f"powers: {powers}")
    # i番目の倒せる最大数を求める
    # i番目の勇者がi+1番目のモンスターを倒して残った火力 + i-1番目の勇者の火力と
    # i番目のモンスター数の内、少ない方が倒せる最大数になる
    dp[i] = min(powers[i] + powers[i - 1], monsters[i])
    # i-1番目の勇者の火力を減らしておく
    # ただしi番目の勇者で十分倒せる火力の場合何も減らさない
    powers[i - 1] -= max(dp[i] - powers[i], 0)

# print(f"powers: {powers}")
# 0番目の勇者の倒せる最大数を求める
dp[0] = min(powers[0], monsters[0])

print(sum(dp))

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

const int INF=0x3f3f3f3f;

int N,M,a[2000][13];
int t[5000];
int main()
{
	int f[20000]; 
	memset(f,0x3f,sizeof(f));
	cin>>N>>M;
	for(int i=1;i<=M;i++)
	{
		cin>>a[i][0];
		int u; cin>>u;
		for(int j=1;j<=u;j++)
		{
			int h; cin>>h;
			a[i][h]++;
		}
		for(int jh=0;jh<N;jh++)
		{
			t[i]+=(1<<jh)*a[i][jh+1];
		}
		f[t[i]]=min(a[i][0],f[t[i]]);
	}
	for(int i=0;i<=(1<<N)-1;i++)
	{
		for (int j=i;j;j=(j-1) & i)
		{
			int k=i^j;
			for (int w=1;w<=M;++w)
			{
				if ((t[w] & k)==k)
				{
				//if (f[j]==2) printf("%d\n",j);//					printf("%d %d\n",f[j],a[w][0]);
					f[i]=min(f[j]+a[w][0],f[i]);
				}
			}
		}
	}
	printf("%d\n",f[(1<<N)-1]==INF ? -1 : f[(1<<N)-1]);
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cout.tie(0);
    int n;
    cin >> n;
    vector<long long> counts(5, 0LL);
    while (n--){
        string s;
        cin >> s;
        if (s[0] == 'M') ++counts[0];
        if (s[0] == 'A') ++counts[1];
        if (s[0] == 'R') ++counts[2];
        if (s[0] == 'C') ++counts[3];
        if (s[0] == 'H') ++counts[4];
    }
    long long ans = 0LL;
    for (int i = 0; i < 5; ++i){
        for (int j = i + 1; j < 5; ++j){
            for (int k = j + 1; k < 5; ++k){
                ans += counts[i] * counts[j] * counts[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
int main() {
    std::string s;
    std::cin >> s;
    std::set<int> ss;
    for (int i = 0; i < s.size(); i++)
    {
        ss.insert(s[i]);
    }

    std::string ans = ss.size() == s.size() ? "yes" : "no";

    std::cout << ans << "\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a,p;
  cin>>a>>p;
  int sum=0;
  sum=a*3+p;
  cout<<sum/2<<endl;
}

Measured memory_bytes: 256
import math
import itertools


N, D = (int(i) for i in input().split())
X = [0]*N


for n in range(N):
    l = input().split()
    X[n] = [0]*D
    for d in range(D):
        X[n][d] = int(l[d])


count = 0
for y, z in itertools.combinations(X, 2):
    d = math.sqrt(sum(pow(y[i] - z[i], 2) for i in range(D)))
    if d.is_integer():
        count += 1

print(count)


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n, a, b;
	cin >> n >> a >> b;

	vector<ll> arr(n);
	for(auto& i: arr) cin >> i;

	using BIG = __int128_t;

	BIG lb = 0, ub = 1e18;

	while(ub - lb > 1){
		BIG mid = (lb + ub) / 2;

		BIG moves = 0;

		for(auto i: arr){
			BIG num = i - mid * b;
			if(num > 0) moves += (num + a - b - 1) / (a - b);
		}

		if(moves <= mid) ub = mid;
		else lb = mid;
	}

	assert(ub <= 4e18);

	cout << (ll)ub << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct rect {
    i64 x1, y1, x2, y2;
};

int main() {
    // assert(freopen("/Users/xuzijian/aoj/input", "r", stdin));
    int n;
    cin >> n;
    vector<rect> rs;
    map<i64, int> xs, ys;
    for (int i = 0; i < n; i++) {
        i64 a, b, c, d;
        cin >> a >> b >> c >> d;
        xs[a];
        ys[b];
        xs[c];
        ys[d];
        rs.push_back({a, b, c, d});
    }
    int z = 0;
    map<int, i64> Xs, Ys;
    for (auto& p: xs) {
        p.second = z;
        Xs[z++] = p.first;
    }
    z = 0;
    for (auto& p: ys) {
        p.second = z;
        Ys[z++] = p.first;
    }
    
    vector<rect> cs;
    for (rect r: rs) {
        cs.push_back({xs[r.x1], ys[r.y1], xs[r.x2], ys[r.y2]});
    }

    vvi imos(4040, vi(4040));
    for (rect c: cs) {
        imos[c.x1][c.y1] += 1;
        imos[c.x1][c.y2] -= 1;
        imos[c.x2][c.y1] -= 1;
        imos[c.x2][c.y2] += 1;
    }

    for (int i = 0; i < 4040; i++) {
        for (int j = 0; j < 4040 - 1; j++) {
            imos[i][j + 1] += imos[i][j];
        }
    }
    for (int i = 0; i < 4040 - 1; i++) {
        for (int j = 0; j < 4040; j++) {
            imos[i + 1][j] += imos[i][j];
        }
    }

    i64 ans = 0;
    for (int i = 1; i < xs.size(); i++) {
        for (int j = 1; j < ys.size(); j++) {
            if (imos[i - 1][j - 1]) {
                ans += (Xs[i] - Xs[i - 1]) * (Ys[j] - Ys[j - 1]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 131648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
int main()
{
    ll h1,m1,h2,m2,t,h,m,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
      cin>>h1>>m1>>h2>>m2>>k;
      if(m1==m2)
      {
          h=(h2-h1)*60;
      }
      else if(m2>m1)
      {
          h=(h2-h1)*60+(m2-m1);
      }
      else
      {
          h=(h2-h1-1)*60+(60-m1)+m2;
      }
      if(h-k>0) cout<<h-k<<endl;
      else cout<<0<<endl;
}





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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int to[N];
vector<int> g[N];
int used[N];
bool circle[N];

bool dfs(int u)
{
    used[u] = 1;
    if (used[to[u]] == -1)
    {
        used[u] = -1;
        return false;
    }
    else if (used[to[u]] == 0)
    {
        if (dfs(to[u]))
        {
            if (!circle[u])
            {
                circle[u] = true;
                used[u] = -1;
                return true;
            }
            else
            {
                used[u] = -1;
                return false;
            }
        }
        else
        {
            used[u] = -1;
            return false;
        }
    }
    else
    {
        circle[u] = circle[to[u]] = true;
        used[u] = -1;
        return true;
    }
}

int var[N][2];

int grundy(int u)
{
    set<int> s;
    for (int v : g[u])
        s.insert(grundy(v));
    int res = 0;
    while (s.count(res))
        res++;
    return res;
}

void solve(int u)
{
    set<int> s;
    for (int v : g[u])
        if (!circle[v])
            s.insert(grundy(v));
    int res = 0;
    while (s.count(res))
        res++;
    var[u][0] = res;
    res++;
    while (s.count(res))
        res++;
    var[u][1] = res;
}

bool check(int u, int x)
{
    int v = u, val = x;
    while (true)
    {
        int w = to[v];
        if (var[w][0] != val)
            val = var[w][0];
        else
            val = var[w][1];
        v = w;
        if (v == u)
            break;
    }
    return (val == x);
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n)
    {
        cin >> to[i];
        to[i]--;
        g[to[i]].push_back(i);
    }
    rep(i, 0, n)
        if (used[i] == 0)
            dfs(i);
    rep(i, 0, n)
        solve(i);
    rep(i, 0, n)
        if (circle[i])
        {
            if (check(i, var[i][0]) || check(i, var[i][1]))
            {
                cout << "POSSIBLE\n";
                return 0;
            }
            else
            {
                cout << "IMPOSSIBLE\n";
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 16128
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
ll MOD = 1e9+7;

int n;
bool a[22][22];
bool women[22];

int done[(1<<22)];

int base = 0;
ll pairs(int now){
    if(now == n) return 1;
    if(done[base] != -1) return done[base];
    ll ans = 0;
    for(int j=0;j<n;++j){
        if(a[now][j] && !women[j]){
            women[j] = 1;
            base += 1<<j;
            ans += pairs(now+1);
            women[j] = 0;
            base -= 1<<j;
            if(ans >= MOD) ans-=MOD;
        }
    }
    done[base] = ans;
    //dbg(now); dbg(ans); dbgA(women, n); cerr<<endl;
    return ans;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    cin>>n;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j){
            int x;
            cin>>x;
            a[i][j] = x==1;
        }
    memset(done, -1, sizeof(done));
    cout<<pairs(0);
    return 0;
}


Measured memory_bytes: 19872
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int a,b,i,N,d,ln,ck,k,j;
    char str[5];
    while(scanf("%d%d",&a,&b)==2){
        ck=0;
        N=0;
        i=0;
        while(b>0){
            d=b%10;
            str[i]=d+'0';
            b=b/10;
            i++;
        }
        str[i]='\0';
        ln=strlen(str);
        for(i=ln-1;i>=0;i--){
            a=a*10+(int)str[i]-'0';
        }
        j=sqrt(a);
        for(k=j*j;k<=a;j++){
            if(k==a)
                ck=1;
            k=j*j;
        }
        if(ck==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
pii a[50];
pii b[50];
int main(void)
{
	int n, m;
	scanf("%d%d", &n, &m);
	FOR(i, 0, n)
	{
		scanf("%d%d", &a[i].first, &a[i].second);
	}
	FOR(i, 0, m)
	{
		scanf("%d%d", &b[i].first, &b[i].second);
	}
	FOR(i, 0, n)
	{
		int minD = INF;
		int minI = -1;
		FOR(j, 0, m)
		{
			int d = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
			if (d < minD)
			{
				minD = d;
				minI = j;
			}
		}
		cout << minI + 1 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    static long[] sz;
    static long[] p;

    public static void Main()
    {
	sz = new long[51];
	p = new long[51];

	sz[0] = p[0] = 1;
	for (int i = 1; i <= 50; i++)
	{
	    sz[i] = sz[i-1] * 2 + 3;
	    p[i] = p[i-1] * 2 + 1;
	}

	var tmp = ReadLongArray();
	int n = (int)tmp[0];
	long x = tmp[1];
	WriteLine(numPaties(n, x));
    }

    static long numPaties(int lv, long x)
    {
	if (lv == 0) return 1;
	
	if (x == 1) return 0;
	else if (x < sz[lv-1] + 2) return numPaties(lv - 1, x - 1);
	else if (x == sz[lv-1] + 2) return p[lv-1] + 1;
	else if (x < sz[lv])
	    return p[lv-1] + 1 + numPaties(lv - 1, x - sz[lv-1] - 2);
	else return p[lv-1] * 2 + 1;
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#define mod 1000000007
using namespace std;
 
int main()
{
    int n, a[100010], ans=1;
    bool ok=true;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    if (n%2==1)
    {
        if (a[0]!=0) ok=false;
        for (int i=1; i<n; i++)
        {
            if (i%2==1) { if (a[i]!=a[i-1]+2) ok=false; }
            else { if (a[i]!=a[i-1]) ok=false; }
        }
    }
    else
    {
        if (a[0]!=1 || a[1]!=1) ok=false;
        for (int i=2; i<n; i++)
        {
            if (i%2==0) { if (a[i]!=a[i-1]+2) ok=false; }
            else { if (a[i]!=a[i-1]) ok=false; }
        }
    }
    if (ok)
    {
        if (n%2==0) for (int i=0; i<n/2; i++) ans=ans*2%mod;
        else for (int i=0; i<(n-1)/2; i++) ans=ans*2%mod;
    }
    else ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数


int main (){
    ll int h,a;
    cin >> h >> a;
    ll int ans = 0;
    
    while(1){
        h -= a;
        ans += 1;
        if(h<=0) break;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,a,b;
  	int ga=0;

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

	ga=n*a;
	if(ga<b){
	printf("%d\n",ga);
    }else{
	printf("%d\n",b);
    }
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long INF=999999999;

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

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

using namespace std;

long long counter = 0;

int merge(vector<int> &a, int l, int r,int mid) {

	vector<int> ll(mid - l+1 ,0);
	vector<int> rr(r-mid  ,0);
	for (int i = 0; i < mid-l+1 ; i++) {
		ll[i] = a[l + i];
	}
	for (int i = 0; i < r-mid ; i++) {
		rr[i] = a[mid + i+1];
	}

	int i = 0;
	int j = 0;
	ll.push_back(INT_MAX);
	rr.push_back(INT_MAX);

	while (i+j<r-l+1) {
		if (ll[i] <= rr[j]) {
			a[l + i + j] = ll[i];
			i++;
		}
		else if (ll[i] > rr[j]) {
			a[l + i + j] = rr[j];
			j++;
			if (i != ll.size() - 1) {
				counter += mid - l - i+1;
			}
		}
	}
	return 0;
}

int mergeSort(vector<int> &a, int l, int r) {
	if (l == r) {
		return 0;
	}

	int mid = (l + r) / 2;
	mergeSort(a, l, mid);
	mergeSort(a, mid+1, r);

	merge(a, l, r,mid);
	return 0;
}

int main() {

	int n;
	cin >> n;

	vector<int> a(n, 0);

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

	int l = 0;
	int r = n - 1;

	mergeSort(a, l, r);
	cout << counter << endl;

}


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

using namespace std;

typedef long long ll;

int max(int a, int b)
{ return (a > b) ? a : b; }
int min(int a, int b)
{ return (a > b) ? b : a; }

const int MAXN = 2031;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	
	int n;
	cin >> n;
	int k;
	cin >> k;
	int ans = 0;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] >= k) ans++;
	}
	cout << ans;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String line = sc.next();
    long max = Long.MIN_VALUE;
    for (int i = 1; i < n; i++) {
      Set<Character> set1 = new HashSet<>();
      Set<Character> set2 = new HashSet<>();
      for (char c : line.substring(0, i).toCharArray()) set1.add(c);
      for (char c : line.substring(i).toCharArray()) set2.add(c);
      long count = set1.stream().filter(set2::contains).count();
      max = Math.max(max, count);
    }
    System.out.println(max);
  }
}

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

using i64 = int64_t;

i64 cumsum[30][200005]={0};

int main(){
    string a;
    cin >> a;

    for(int i=1;i<=(int)a.size();++i){
        for(int j='a';j<='z';++j){
            if(j == a[i-1]){
                cumsum[j-'a'][i] = cumsum[j-'a'][i-1];
            }else{
                cumsum[j-'a'][i] = cumsum[j-'a'][i-1] + 1;
            }
        }
    }

    i64 ans = 1;
    for(int i=1;i<(int)a.size();++i){
        ans += cumsum[a[i]-'a'][i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 41476
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
fn main() {
    let n: i32 = read();
    let mut x: Vec<i32> = read_vec();
    x.sort();
    let (a, b) = (*x.first().expect("a"), *x.last().expect("b"));
    if a == b {
        println!("0");
        return
    }
    let mut v: Vec<i32> = Vec::new();
    for i in a..b {
        let mut num = 0;
        for j in x.iter() {
            num += (*j - i).pow(2);
        }
        v.push(num);
    }
    v.sort();
    println!("{:?}", v[0]);
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	ll P = 0;
	if (2 * N - M <= 0)
	{
		P = N;
		P += (M - 2 * N) / 4;
	}
	else {
		P = M / 2;
	}

	cout << P << endl;
	return 0;
}

Measured memory_bytes: 256