akhauriyash/Code-Regression huggingface dataset:
//abc146_d.cpp
//Sun Dec 22 18:42:46 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<int> graph[n];
	map<P, int> mp;
	int from[n-1];
	int to[n-1];
	for (int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		from[i] = a;
		to[i] = b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		mp[make_pair(a,b)] = -1;
		mp[make_pair(b,a)] = -1;
	}

	queue<int> q;
	int parent[n];
	fill(parent,parent+n,-1);
	int used[n];
	fill(used,used+n,0);
	q.push(0);
	used[0] = 1;
	int k = 0;
	while (q.size()){
		int x = q.front();q.pop();
		int color = 0;
		k = max(k,(int)graph[x].size());
		for (int i=0;i<graph[x].size();i++){
			if (used[graph[x][i]]){
				continue;
			}
			if (color==parent[x]){
				color++;
			}
			P p1 = make_pair(x,graph[x][i]);
			P p2 = make_pair(graph[x][i],x);
			mp[p1] = color;
			mp[p2] = color;
			q.push(graph[x][i]);
			parent[graph[x][i]] = color;
			used[graph[x][i]] = 1;
			color++;
//			cout << "test" << endl;
		}
	}

	cout << k << endl;
	for (int i=0;i<n-1;i++){
		cout << mp[make_pair(from[i],to[i])]+1 << endl;
	}

}

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

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

using namespace std;

const int INF=1<<29;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	int h,w,k; scanf("%d%d%d",&h,&w,&k);
	char B[10][1001];
	rep(i,h) scanf("%s",B[i]);

	int ans=INF;
	rep(S,1<<(h-1)){
		int m=0,id[10];
		rep(i,h){
			id[i]=m;
			if(i==h-1 || (S>>i&1)) m++;
		}

		int res=popcount(S);
		int cnt[10]={},pre=0;
		rep(j,w){
			bool ng=false;
			rep(i,h) if(B[i][j]=='1') {
				cnt[id[i]]++;
				if(cnt[id[i]]>k) ng=true;
			}
			if(ng){
				if(pre==j){ res=INF; break; }
				pre=j;
				j--;
				fill(cnt,cnt+m,0);
				res++;
			}
		}
		ans=min(ans,res);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

Measured memory_bytes: 21004
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int i1 = 0;
    int i2 = 0;
    if (X == 1) {
      i1 = 300000;
    }else if(X == 2) {
      i1 = 200000;
    }else if(X == 3) {
      i1 = 100000;
    }
    
    if (Y == 1) {
      i2 = 300000;
    }else if(Y == 2) {
      i2 = 200000;
    }else if(Y == 3) {
      i2 = 100000;
    }
    
    if (X == 1 && Y == 1) {
      int shoukin = i1 + i2 + 400000;
      System.out.println(shoukin);
    }else{
      int shoukin = i1 + i2;
      System.out.println(shoukin);
    }
  }
 }
      


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

long long dist(long long a, long long b, long long c, long long d) {
    return abs(a - c) + abs(b - d);
}

long long solve(long long a, long long b, long long c, long long d) {
    const long long N = 205891132094649LL;
    if (c - a > d - b) { swap(a, b); swap(c, d); }
    long long s = N/3;
    while (s > 0) {
        // cerr << a << ' ' << b << ' ' << c << ' ' << d1 << " " << s << endl;
        long long a2 = a / s % 3, b2 = b / s % 3, c2 = c / s % 3;
        if (a2 == 1 && c2 == 1) {
            long long d1 = b2 == 0 ? b / s * s + s : (b / s / 3 + 1) * 3 * s + s;
            if (d1 <= d) {
                long long h1 = min(a % s * 2 + 2, (s - a % s) * 2),
                    h2 = min(c % s * 2 + 2, (s - c % s) * 2);
                // cerr << h1 << " " << h2 << " " << s << endl;
                return dist(a, b, c, d) + min(h1, h2);
            }
        } else if (a2 != c2) {
            break;
        }
        s /= 3;
    }
    return dist(a, b, c, d);
}

int main() {
    int q; cin >> q;
    while (q--) {
        long long a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        cout << solve(min(a, c), min(b, d), max(a, c), max(b, d)) << endl;
    }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;


int main(){
  int N;
  cin>>N;
  int a[N],b[N],c[N];
  rep(i,N) cin>>a[i]>>b[i]>>c[i];
  
  ll DP[N][3];
  rep(i,N)rep(j,3) DP[i][j] = -INF;
  
  DP[0][0]=a[0];
  DP[0][1]=b[0];
  DP[0][2]=c[0];
  
  for(ll i=1;i<N;i++){
      DP[i][0]=max(DP[i-1][1],DP[i-1][2])+a[i];
      DP[i][1]=max(DP[i-1][2],DP[i-1][0])+b[i];
      DP[i][2]=max(DP[i-1][0],DP[i-1][1])+c[i];
  }
  
  ll ans = max(DP[N-1][0],DP[N-1][1]);
  cout<<max(ans,DP[N-1][2]);
}

Measured memory_bytes: 3712
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define int long long
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
int n=read(),E=read(),T=read(),a[100005];
int dp[100005];//dp[i]=min(dp[j]+a[i]-a[j]+max(T,2*(a[i]-a[j+1]))=;
signed main(){
	fz(i,1,n)	a[i]=read();
	memset(dp,63,sizeof(dp));
	deque<int> q;
	q.push_back(0);
	dp[0]=0;
	int mn=0x3f3f3f3f3f3f3f3fll;
	fz(i,1,n){
		while(!q.empty()&&2*(a[i]-a[q.front()+1])>T){
			int j=q.front();
			mn=min(mn,dp[j]-a[j]+2*(-a[j+1]));
			q.pop_front();
		}
		dp[i]=min(dp[i],dp[q.front()]+a[i]-a[q.front()]+T);
		dp[i]=min(dp[i],mn+3*a[i]);
		while(!q.empty()&&dp[q.back()]-a[q.back()]>dp[i]-a[i])	q.pop_back();
		q.push_back(i);
	}
	cout<<dp[n]+abs(a[n]-E)<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
    long long int a,b,x,count=0;
    long long int i;
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)
    {
        printf("%lld\n",(b/x)-(a/x)+1);
    }
    else
    {
        printf("%lld\n",(b/x)-(a/x));
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n, *nam;
    cin >> n;
    nam = new int[n];
    for(int i=0; i<n; i++)
        cin >> nam[i];
    sort(nam,nam+n);
    cout << nam[n/2]-nam[n/2-1] << '\n';
}

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

using namespace std;
const int INF = 1e9 + 5;
using ll = long long;
int main(int argc, char** argv){
    int N = 0, W = 0;

    cin >> N >> W;
    vector<int> weights(N);
    vector<ll> values(N);

    vector<ll> dp(W+1);

    for(int i = 0; i < N; ++i){
       cin >> weights[i] >> values[i]; 
    }


    for(int item = 0; item < N; ++item){
        for(int weight = W; weight >= 0; --weight){
            if(weight + weights[item] <= W){
                dp[weight+weights[item]] =
                    max(dp[weight] + values[item], dp[weight+weights[item]]);
            }
        }
    }
    //for(const auto& i : dp)
    //    cout << i << " ";
    //cout << "\n";
    cout << dp[W] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }
// const ll sz = 2e6 + 5;
// vector<ll> fac(sz, 1);

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;
    
    while(t--) {
        ll n, k;
        cin >> n >> k;
        
        vector<ll> p(n+1), c(n+1);
        for (int i = 1; i <= n; i++)
            cin >> p[i];
        for (int i = 1; i <= n; i++)
            cin >> c[i];
        
        ll res = LLONG_MIN;
        for (int i = 1; i <= n; i++) {
            ll kk = k, ii = i;
            vector<ll> tmp;
            vector<bool> vis(n+1, false);
            
            while(!vis[ii] && kk) {
                vis[ii] = true;
                tmp.pb((tmp.empty() ? 0ll : tmp.back()) + c[p[ii]]);
                res = max(res, tmp.back());
                ii = p[ii];
                kk -= 1;
                // cout << tmp.back() << " " << kk << endl;
            }
            
            if (kk > 0 && tmp.back() > 0) {
                ll sz = (int)tmp.size();
                ll itr = kk / sz;
                kk %= sz;
                ll ans = tmp.back() + tmp.back() * itr;
                // cout << "ans " << ans << " " << "itr " << itr << endl;
                res = max(res, ans);
                
                if (itr >= 1) {
                    for (int x = 0; x < tmp.size(); x++) {
                        // ans += tmp[x];
                        res = max(res, ans + tmp[x] - tmp.back());
                        // cout << "ans " << ans << " " << kk << endl;
                    }
                }
                
                for (int x = 0; kk; x++, kk--) {
                    // ans += tmp[x];
                    res = max(res, ans + tmp[x]);
                    // cout << "ans " << ans << " " << kk << endl;
                }
            }
        }
        
        cout << res << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

// 𝑂(𝑁*log(log 𝑁))
vector<int> eratosthenes(int N)
{
    vector<int> res;
    vector<bool> prime(N + 1, 1);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= N; ++i)
    {
        if (prime[i] == true)
        {
            for (int j = 2 * i; j <= N; j += i)
            {
                prime[j] = false;
            }
        }
    }
    for (int i = 0; i <= N; ++i)
    {
        if (prime[i] == true)
            res.push_back(i);
    }
    sort(res.begin(), res.end());
    return res;
}

int m, M, n;

int main()
{
    auto p = eratosthenes(1000010);
    int l = p.size();
    while (cin >> n)
    {
        for (int i = 0; i + 1 < l && n >= p[i]; i++)
        {
            //cout << p[i] << endl;
            if (n == p[i])
            {
                m = p[i - 1], M = p[i + 1];
                break;
            }
            if (n > p[i] && n < p[i + 1])
            {
                m = p[i], M = p[i + 1];
                break;
            }
        }
        cout << m << " " << M << endl;
    }
}



Measured memory_bytes: 3388
/**
 * Sum of Cards
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	static final int MAX = 1000;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int m = parseInt(line);
			if (m == 0) break;

			int[] dp = new int[MAX + 1];
			int[] vs = new int[m];
			int[] ns = new int[m];
			for (int i = 0; i < m; i++) {
				line = br.readLine();
				vs[i] = parseInt(line.substring(0, line.indexOf(' ')));
				ns[i] = parseInt(line.substring(line.indexOf(' ') + 1));
			}

			//
			for (int i = 0; i < m; i++) {
				for (int j = MAX; j >= 0; j--) {
					if (dp[j] > 0) {
						for (int k = 1; k <= ns[i]; k++) {
							int idx = j + vs[i] * k;
							if (idx <= MAX) dp[idx] += dp[j];
						}
					}
				}
				for (int k = 1; k <= ns[i]; k++) {
					int idx = vs[i] * k;
					if (idx <= MAX) dp[idx]++;
				}
			}

			//
			int g = parseInt(br.readLine());
			for (int i = 0; i < g; i++) {
				int n = parseInt(br.readLine());
				System.out.println(dp[n]);
			}
		} //ene while
	}//end main
}

Measured memory_bytes: 18196
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
ll A, B; 
vector <ll> vec;
void gao(ll x) {
	for (ll i = 2; i * i <= x; ++i) {
		if (x % i == 0) vec.push_back(i);
		while (x % i == 0) x /= i;
	}
	if (x != 1) vec.push_back(x); 
}
void run() {
	vec.clear();
	ll G = gcd(A, B);
	gao(G);	
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	cout << vec.size() + 1 << endl;  
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> A >> B) run();
	return 0;
}


Measured memory_bytes: 256
import sys
N = 8
board = [[0 for j in range(N)] for i in range(N)]
queen = [-1] * N

def main():
    init()
    search(0)

def search(i):
    if i == N:
        printBoard()
        sys.exit()
    
    if queen[i] != -1:
        search(i + 1)

    else :
        for j in range(N):
            if board[i][j] == 0:
                queen[i] = j
                changeBoard(i, j, 1)
                search(i + 1)
                changeBoard(i, j, -1)
                queen[i] = -1

def init():
    k = int(input())

    for i in range(k):
        a = list(map(int, input().split()))
        queen[a[0]] = a[1]
        changeBoard(a[0], a[1], 1)

def changeBoard(i, j, number):
    for k in range(N):
        board[i][k] += number
        board[k][j] += number

    if i > j :
        for k in range(N - (i - j)) :
            board[k + (i - j)][k] += number
    else:
        for k in range(N - (j - i)) :
            board[k][k + (j - i)] += number
    if i + j < N :
        for k in range(i + j + 1) :
            board[i + j - k][k] += number
    else:
        for k in range(i + j - N + 1, N):
            board[i + j - k][k] += number

def printBoard():
    for i in range(N):
        for j in range(N):
            if queen[i] == j:
                print('Q' ,end = "")
            else:
                print('.' ,end = "")
        print()

if __name__ == '__main__':
    main()


Measured memory_bytes: 5624
#include <cstdio>
using namespace std;

int main()
{
	int a,b,c,tc,rc;
	tc = rc = 0;
	while(scanf("%d,%d,%d",&a,&b,&c) == 3)
	{
		if(a == b) ++ rc;
		else if(a * a + b * b == c * c) ++tc;
	}
	printf("%d\n%d\n",tc,rc);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

struct Card {char s; int no; int o;};

int Partition(Card *A, int p, int r) {
	int x = A[r].no;
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j].no <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i + 1;
}

void quickSort(Card *A, int p, int r) {
	if (p < r) {
		int q = Partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}

void isStable(Card *A, int len) {
	bool stable = true;
	for (int i = 0; i < len-1; i++)
		if (A[i].no == A[i+1].no)
			if (A[i].o > A[i+1].o)
				stable = false;
	cout << (stable == true ? "Stable" : "Not stable") << endl;
}

int main() {
	int n;
	cin >> n;
	Card *A = new Card[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i].s >> A[i].no;
		A[i].o = i;
	}
	quickSort(A, 0, n - 1);
	isStable(A, n);
	for (int i = 0; i < n; i++)
		cout << A[i].s << " " << A[i].no << endl;
	delete[] A;
	return 0;
}

Measured memory_bytes: 2328
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//10:14
int compare(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(){
  int n = 0;
  int i = 0;
  int j = 0;
  int hozon = 0;
  int flag = 0;
  int cnt = 0;
  int a[100000] = {};
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  
  qsort(a,n,sizeof(int),compare);
  
  flag = 1;
  hozon = a[0];
  for(i = 1;i < n;i++){
    if(hozon == a[i]){
      flag = !flag;
    }else{
     	cnt += flag;
      	hozon = a[i];
      	flag = 1;
    }
  }
  
  cnt += flag;
  printf("%d",cnt);
  
  return 0;
}
     


Measured memory_bytes: 892
def main(str)
  n, x, y = str.split(" ").map(&:to_i)
  result = (n - 1).times.map { 0 }
  (1..n).each do |n0|
    ((n0+1)..n).each do |n1|
      dis = [
        ((n0 - x).abs + (n1 - y).abs) + 1,
        ((n1 - x).abs + (n0 - y).abs) + 1,
        n1 - n0
      ].min
      result[dis-1] += 1
    end
  end
  result
end

puts main($stdin.read.chomp).join("\n")

Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	vector<int> list(3);
	cin >> list[0] >> list[1] >> list[2];
	sort(list.begin(), list.end());
	cout << list[0] + list[1] << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	K := getInt()
	D := make([]int, K)
	for i := 0; i < K; i++ {
		D[i] = getInt()
	}

	//	out(N, K, D)

	ans := N
	for ans < N*10 {
		flag := false
	L1:
		for j := ans; j != 0; j /= 10 {
			v := j % 10
			for k := 0; k < K; k++ {
				if v == D[k] {
					flag = true
					break L1
				}
			}
		}
		if flag == false {
			break
		}
		//out(ans)
		ans++
	}
	out(ans)
}


Measured memory_bytes: 640
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
lli gcd(lli a, lli b)
{
    return a < b ? gcd(b, a) : (b == 0 ? a : gcd(b, a % b));
}
int main()
{
    string my, op;
    cin >> op;
    my = op;
    string s = "gp";
    rep(i, my.size())
    {
        my[i] = s[i % 2];
    }
    int ans = 0;
    rep(i, my.size())
    {
        if (my[i] == 'p' && op[i] == 'g')
            ans++;
        else if (my[i] == 'g' && op[i] == 'p')
            ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid (l+r)/2
const int mod=1e9+7,inf=0x3f3f3f3f,maxn=1e5+5;
int n,m,Q,K;

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    return x*f;
}
struct node{
    int l,r;
    bool operator <(const node &a)const{
        if(l!=a.l)return l<a.l;
        return r<a.r;
    }
}a[maxn];


signed main(){
//  freopen("a.in","r",stdin);
//  freopen("a.out","w",stdout);
    n=read();
    for(int i=1;i<=n;++i){
        int x=read(),L=read();
        a[i]=(node){x-L,x+L};
    }
    sort(a+1,a+1+n);int ans=n,nowl=a[1].l,nowr=a[1].r;
    for(int i=2;i<=n;++i){
        if(a[i].l<nowr){
            ans--;nowr=min(nowr,a[i].r);
        }
        else nowl=a[i].l,nowr=a[i].r;
    }printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 1024
N=int(input())
t,n,u=[],0,0
for s in list(map(int,input().split())):
    for i in range(8):
        if 0+400*i<=s<=399+400*i:
            t.append(i)
            break
    else:
        n+=1
l=len(set(t))
if l==0:
    u=1
print(str(l+u)+" "+str(l+n))
            
            
        

Measured memory_bytes: 3060
using static System.Math;
using System;

class M
{
    public const int MOD = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(BigMul(a, b) % MOD);
    public M(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var ans = getAns(n, k);
        Console.WriteLine(ans);
    }
    static int getAns(int n, int k)
    {
        var dp = new long[n + 1, k + 1];
        dp[0, 0] = 1;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= k; j++)
            {
                dp[i, j] = dp[i - 1, j] * j + dp[i - 1, j - 1];
                dp[i, j] %= M.MOD;
            }
        var ans = 0L;
        for (int i = 1; i <= k; i++)
        {
            ans += dp[n, i];
            ans %= M.MOD;
        }
        return (int)ans;
    }
}



Measured memory_bytes: 21204
n=int(input())
x=[list(map(int,input().split()))for i in range(n)]
#print(x)

for i in range(n-2):
  cnt = 0
  if  x[i][0]==x[i][1]:
    cnt=1
  else:
    continue
    
  if  x[i+1][0]==x[i+1][1]:
    cnt=cnt+1
    
  else:
    continue
    
  if x[i+2][0]==x[i+2][1]:
    cnt=cnt+1 
    if cnt==3:
      print('Yes')
      break
  else:
    break
if cnt!=3:
  print('No')

       
  

Measured memory_bytes: 9200
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <string>
#include <algorithm>

int main(){
	int a[20], L, tmp[10], i, out[2][20], j;
	char str[10], max[10];
	scanf("%d %d", &a[0], &L);
	while( a[0] + L ){
		for(int k=0; k<20; k++){
			memset(str, '\0', sizeof(str));
			memset(max, '\0', sizeof(max));
			sprintf( str, "%d\0", a[k]);
			for( i=strlen(str); i < L; i++ )
				str[i] = '0';
			str[i] = '\0';
			
			std::sort( str, str + L );
			
			for(i=0; i<L; i++)
				max[i] = str[L-i-1];
			out[0][k] = atoi( max );
			out[1][k] = atoi( str );
			
			a[k+1] = out[0][k] - out[1][k];
			
			bool check=false;
			for( i=0; i<=k; i++ )
				if( a[i] == a[k+1] ){
					j = i;
					check = true;
					break;
				}
			if( check ){
				printf("%d %d %d\n", j, a[k+1], k+1-j );
				break;
			}
			
		}
		scanf("%d %d", &a[0], &L);
	}
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
typedef long long ll;
ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

const ll mod = 1e9 + 7; // change to something else
struct Mod {
    ll x;
    Mod(ll xx = 0) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x + mod) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e&1 ? *this * r : r;
    }
};
const int N = 2e6 + 5;
Mod fac[N];
Mod c (int n, int r) {
    if (n < r)
        return Mod(0);
    return fac[n] / (fac[n - r] * fac[r]);
}
int k;
string s;
void solve() {  
    fac[0] = 1;
    rep(i, 1, N)
        fac[i] = fac[i - 1] * Mod(i);
    cin >> k >> s;
    int n = (int) s.size();
    Mod ans(0);
    for (int after = 0; after <= k; ++after) {
        int before = k - after;
        ans = ans + c(before + n - 1, n - 1) * (Mod(25)^before) * (Mod(26)^after);
    }
    cout << ans.x;
}       

Measured memory_bytes: 19928
#include <bits/stdc++.h>
#define Nmax 2002
#define Smax 4000002
#define ll long long
using namespace std;

int n,v[Nmax];
int s;
map<int,ll> M,M2;
bitset<4000002> B;

int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
    {
        cin>>v[i];
        s += v[i];
    }

    for (int i=1;i<=n;i++)
    {
        B = B | (B<<v[i]);
        B[v[i]] = 1;
    }

    for (int i=s/2+(s%2!=0);i<=4000000;i++)
        if (B[i]==1)
        {
            cout<<i;
            return 0;
        }
    return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int h_init, h_max;
  while (cin >> h_init >> h_max && h_init + h_max){
    int R, C, T, P, S;
    cin >> R >> C;

    vector<string> board(R);
    vector<char>   order;
    vector<int>    portions;
    vector<vector<int> > damage(R, vector<int>(C, 0));

    REP(i, R){
      cin >> board[i];
    }

    cin >> T;
    map<char, int> damage_map;
    REP(i, T){
      char c;
      int d;
      cin >> c >> d;
      damage_map[c] = d;
    }

    REP(i, R) REP(j, C){
      damage[i][j] = damage_map[board[i][j]];
    }

    cin >> S;
    REP(i, S){
      char dir;
      int num;
      cin >> dir >> num;
      REP(j, num){
        order.push_back(dir);
      }
    }

    cin >> P;
    portions.resize(P);
    REP(i, P){
      cin >> portions[i];
    }
    
    vector<vector<int> > dp(order.size() + 1, vector<int>(1 << P, 0));

    
    dp[0][(1 << P) - 1] = h_init;
    int r = 0, c = 0;
    REP(i, order.size()){
      int nr = r + (order[i] == 'D' ? 1 : order[i] == 'U' ? -1 : 0);
      int nc = c + (order[i] == 'R' ? 1 : order[i] == 'L' ? -1 : 0);
      int da = damage[nr][nc];
      for (int mask = (1 << P) - 1; mask >= 0; mask--){
        if (dp[i][mask] == 0) continue;

        if (dp[i][mask] - da > 0){
          dp[i + 1][mask] = max(dp[i + 1][mask], dp[i][mask] - da);
        }

        REP(j, P) if (mask & (1 << j)){
          int nmask = mask ^ (1 << j);
          int nhit  = min(h_max, dp[i][mask] + portions[j]);
          dp[i][nmask] = max(dp[i][nmask], nhit);
        }
      }
      r = nr;
      c = nc;
    }

    bool goal = false;
    REP(mask, 1 << P) if (dp[order.size()][mask] > 0) goal = true;
    cout << (goal ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
#define cnt(s,c) count(begin(s), end(s), c)

int main() {
  int n;
  string s;
  cin >> n >> s;
  auto r = cnt(s, 'R');
  int g = cnt(s, 'G');
  int b = cnt(s, 'B');
  auto ans = r * g * b;
  for (int j = 1; j < n; j++) {
    for (int i = 0; i < j; i++) {
      int k = 2 * j - i;
      if (k >= n) continue;
      if (s[i] == s[j]) continue;
      if (s[j] == s[k]) continue;
      if (s[k] == s[i]) continue;
      ans --;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
int d;

int main(void){
    scanf("%d",&d);
    if(d == 25){
       printf("Christmas");
    }
    if(d == 24){
       printf("Christmas Eve");
    }
    if(d == 23){
       printf("Christmas Eve Eve");
    }
    if(d == 22){
       printf("Christmas Eve Eve Eve");
    }
    
    return 0;
    
}

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

int main() {
  int H,W,K,i,j,k,l;
  cin>>H>>W>>K;
  vector<string> C(H);
  for (i=0;i<H;i++) cin>>C[i];

  int black_num,ans=0;
  for (i=0;i<(1<<H);i++) {
    for (j=0;j<(1<<W);j++) {
      black_num=0;
      for (k=0;k<H && black_num<=K;k++) {
        for (l=0;l<W && black_num<=K;l++) {
          if ((i&(1<<k))==0 && (j&(1<<l))==0 && C[k][l]=='#') black_num++;
        }
      }
      if (black_num == K) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3196
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//高橋
		int b = sc.nextInt();//青木
		int k = sc.nextInt();//行動回数
		
		for(int i = 0; i < k; i++){
			if(i%2==0){
				//高橋君の行動
				if(a%2==1) a--;
				a = a/2;
				b = b + a;
			}else{
				//青木君の行動
				if(b%2==1) b--;
				b = b/2;
				a = a + b;
			}
		}
		System.out.println(a + " " + b);
	}
}

Measured memory_bytes: 38748
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>

using namespace std;

int main(void){
    const int match[] = {10001, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    long long N;
    int M;
    cin >> N >> M;
    vector<int> A(M);
    for(int i = 0; i < M; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());
    vector<int> dp(N + 1, -INT_MAX / 2);
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < A.size(); j++){
            if(i - match[A[j]] >= 0){
                dp[i] = max(dp[i], dp[i - match[A[j]]] + 1);
            }
        }
        // cout << i << " " << dp[i] << endl;
    }
    int n = N;
    for(int i = 0; i < dp[N]; i++){
        for(int j = 0; j < A.size(); j++){
            /*if(i == dp[N] - 1){
                if(n - match[A[j]] == 0){
                    cout << A[j];
                    n -= match[A[j]];
                    break;
                }
            }else*/ if(n - match[A[j]] >= 0 && dp[n - match[A[j]]] + 1 == dp[n]){
                cout << A[j];
                n -= match[A[j]];
                break;
            }
        }
    }
    cout << endl;
    return 0;
}

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

L = [int(x) for x in input().split()]

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and \
                L[k] + L[i] > L[j] and L[i] != L[j] and L[j] != L[k] \
                    and L[k] != L[i]:
                ans += 1

print(ans)

Measured memory_bytes: 9172
N, M = map(int, input().split())
G = [set() for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

if len(G[N - 1] & G[0]) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

bool space[1000][1000];
int s[1000][1000];
int main() {
  int h, w, x0, y0, x1, y1;
  cin >> h >> w >> y0 >> x0 >> y1 >> x1;
  --x0;
  --y0;
  --x1;
  --y1;
  repj(h) repi(w) {
    char c;
    cin >> c;
    space[i][j] = c == '.';
  }
  repi(w) repj(h) s[i][j] = INT_MAX;
  deque<tuple<int, int, int>> q;
  q.push_front(tuple(x0, y0, 0));
  while (!q.empty()) {
    auto [x, y, sp] = q.front();
    q.pop_front();
    if (s[x][y] <= sp) continue;
    s[x][y] = sp;
    auto QP = [&](int nx, int ny, int ns, bool back = false) {
      if (0 <= nx && nx < w && 0 <= ny && ny < h && space[nx][ny]) {
        if (back) {
          q.push_back(tuple(nx, ny, ns));
        } else {
          q.push_front(tuple(nx, ny, ns));
        }
      }
    };
    QP(x - 1, y, sp, false);
    QP(x, y - 1, sp, false);
    QP(x, y + 1, sp, false);
    QP(x + 1, y, sp, false);
    for (int dx = -2; dx <= 2; ++dx) {
      for (int dy = -2; dy <= 2; ++dy) {
        if (abs(dx) + abs(dy) <= 1) continue;
        QP(x + dx, y + dy, sp + 1, true);
      }
    }
  }
  // repj(h) {
  //   repi(w) (space[i][j] ? cout << s[i][j] : cout << '#');
  //   cout << endl;
  // }
  cout << (s[x1][y1] == INT_MAX ? -1 : s[x1][y1]) << endl;
}


Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const ll MOD=998244353;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main(){
  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==1)ans=300000;
  else if(x==2)ans=200000;
  else if(x==3)ans=100000;
  if(y==1)ans+=300000;
  else if(y==2)ans+=200000;
  else if(y==3)ans+=100000;
  if(x==1&&y==1)ans+=400000;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	for(long i = 100000; i > 0; i--) {
		if(Math.pow(i, 2) <= n) {
			System.out.println((int)Math.pow(i, 2));
			break;
		}
	}
}
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0, ed_##i = n; i < ed_##i; i++)
#define FOR(i, n) for(int i = 1, ed_##i = n; i <= ed_##i; i++)
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))  // Leading zeros
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#ifdef QWERTIER
#define err(x) cerr << #x << " : " << x << endl
#else
#define err(x)
#endif

typedef long long LL;
using namespace std;

typedef pair<int,int> pii;
#define MP make_pair

#define MOD 1000000007
char a[100], b[100];
int dp[100][3][3];
int main(){
#ifdef QWERTIER
  freopen("in.txt","r",stdin);
#endif
  int n;
  scanf("%d", &n);
  scanf("%s%s", a+1, b+1);
  FOR (i, n) {
    if (a[i] == b[i]) {
      if (i == 1) {
        REP (c3, 3) {
          dp[i][c3][c3] = 1;
        }
      } else {
        REP (c1, 3) {
          REP (c2, 3) {
            REP (c3, 3) {
              if (c1 != c3 && c2 != c3) {
                (dp[i][c3][c3] += dp[i-1][c1][c2]) %= MOD;
              }
            }
          }
        }
      }
    } else {
      if (i == 1) {
        REP (c3, 3) {
          REP (c4, 3) {
            if (c3 != c4)
              dp[i][c3][c4] = 1;
          }
        }
      } else {
        if (a[i] == a[i-1]) {
          memcpy(dp[i], dp[i-1], sizeof(dp[i-1]));
        } else {
          REP (c1, 3) {
            REP (c2, 3) {
              REP (c3, 3) {
                REP (c4, 3) {
                  if (c3 != c1 && c4 != c2 && c3 != c4) {
                    (dp[i][c3][c4] += dp[i-1][c1][c2]) %= MOD;
                  }
                }
              }
            }
          }
        }
      }
    }
    // REP (k, 3)
    //   REP (l, 3)
    //   printf("%d %d %d %d\n", i, k, l, dp[i][k][l]);
  }
  int ans = 0;
  REP (c3, 3) {
    REP (c4, 3)
      (ans += dp[n][c3][c4]) %= MOD;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,f=0;
  cin >> N;
  int t=N;
  while(t>0)
    f+=t%10, t/=10;
  if(N%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], K = l[1], Q = l[2];
            var a = new int[Q];

            for (var i = 0; i < Q; i++)
                a[i] = int.Parse(Console.ReadLine());

            var man = new int[N];
            for (var i = 0; i < Q; i++)
                man[a[i] - 1]++;

            for (var i = 0; i < N; i++)
            {
                if (man[i] + K - Q > 0)
                    Console.WriteLine("Yes");
                else
                    Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 16348
import bisect

N = int(input())
list = list(map(int, input().split()))
list.sort()

score = 0

for i in range (N-2):
    for j in range (i+1, N-1):
        index = bisect.bisect_left(list, list[i] + list[j]) - j - 1
        score += index

print (score)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  string S;
  ll Q, T, F;
  char C;
  bool rev = 0;
  vector<char> head, tale;
  cin >> S >> Q;
  for(ll i = 0; i < Q; i++) {
    cin >> T;
    if(T == 1) rev ^= 1;
    else {
      cin >> F >> C;
      if(F == 1) {
        if(rev) tale.push_back(C);
        else head.push_back(C);
      }
      else {
        if(rev) head.push_back(C);
        else tale.push_back(C);
      }
    }
  }
  if(rev) {
    for(ll i = 0; i < tale.size(); i++) cout << tale.at(tale.size() - i - 1);
    reverse(S.begin(), S.end());
    cout << S;
    for(ll i = 0; i < head.size(); i++) cout << head.at(i);    
  }
  else {
    for(ll i = 0; i < head.size(); i++) cout << head.at(head.size() - i - 1);
    cout << S;
    for(ll i = 0; i < tale.size(); i++) cout << tale.at(i);    
  }
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int c = 0;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n / 2; i++){
        c += (s[i] != s[n - 1 - i]);
    }
    cout << c;

    return 0;
}


Measured memory_bytes: 3616
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ss: [String; n],
        m: usize,
        ts:[String; m],
    }
    let mut h = std::collections::HashMap::new();
    for s in ss.iter() {
        *h.entry(s).or_insert(0) += 1;
    }
    for t in ts.iter() {
        *h.entry(t).or_insert(0) -= 1;
    }
    let max = *h.iter().max_by(|x, y| x.1.cmp(&y.1)).unwrap().1;
    let max = std::cmp::max(max, 0);
    let ans = max;
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
s = [list(map(int, list(input().split()))) for i in range(M)]

ans = [-1] * N

for i in s:
    if ans[i[0] - 1] != -1 and ans[i[0] - 1] != i[1]:
        print(-1)
        exit()
    ans[i[0] - 1] = i[1]

if M == 0 and N != 1:
    ans[0] = 1
tmp = int(''.join((map(str, [int(str(a).replace('-1', '0')) for a in ans]))))
if N >= 2 and ans[0] == -1:
    ans[0] = 1

ans = [int(str(a).replace('-1', '0')) for a in ans]

res = ''.join((map(str, ans)))
if int(res) >= 0 and len(str(int(res))) == N:
    print(int(res))
else:
    print(-1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        List<Integer> num = new ArrayList<>();
        for(int i = 0;i < len;i++){
            num.add(sc.nextInt());
        }
        //System.out.println(num);
        //System.out.println(len);
        int counter = 0;
        for(int i = 0;i < len-2;i++){
            int one = num.get(0);
            //System.out.println(one);
            int two = num.get(1);
            int three = num.get(2);
            if((one < two) && (two < three)){
                counter++;
            }else if((one > two) && (two > three)){
                counter++;
            }
            num.remove(0);
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";
}

Measured memory_bytes: 256
n, m = map(int,input().split())

d = {}
for i in range(m):
    p, y = map(int,input().split())
    if p not in d:
        d[p] = [(y, i)]
    else:
        d[p].append((y, i))

ans = [0]*m
for k, v in d.items():
    vl = v
    vl.sort()
    num = 1
    for city in vl:
        pre = str(k).zfill(6)
        c = str(num).zfill(6)
        ans[city[1]] = pre+c
        num += 1
print(*ans,sep="\n")

Measured memory_bytes: 46480