akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

signed main(){
    int N;
    cin >> N;
//    N = 500;
    vector<int> P(N*N);
    rep(i,0,N*N) {
        cin >> P[i];
        P[i]--;
    }
//    rep(i,0,N*N) P[i] = i;
//    random_shuffle(all(P));
    vector<vector<pair<int, int>>> distance(N, vector<pair<int, int>>(N));
    vector<vector<bool>> exist(N, vector<bool>(N, true));
    rep(i,0,N) rep(j,0,N) {
        vector<pair<ll,int>> el = {{i,-1}, {j,-1}, {N-i-1,-1}, {N-j-1,-1}};
        distance[i][j] = *min_element(all(el));
    }
    ll answer = 0;
    const vector<int> dx = {1, 0, 0, -1}, dy = {0, 1, -1, 0};
    rep(i,0,N*N) {
        int x = P[i] % N;
        int y = (P[i] - x) / N;
        answer += distance[y][x].first;
        exist[y][x] = false;
        queue<pair<int, int>> que;
        que.push({x, y});
        while (!que.empty()) {
            auto current = que.front();
            que.pop();
            rep(j,0,4) {
                pair<int, int> next = {current.first + dx[j], current.second + dy[j]};
                if (next.first < 0 || next.first >= N || next.second < 0 || next.second >= N) continue;
                if (distance[next.second][next.first].second == i) continue;
                int update = distance[current.second][current.first].first + (exist[current.second][current.first] ? 1 : 0);
                if (distance[next.second][next.first].first > update) {
                    distance[next.second][next.first] = {update, i};
                    que.push(next);
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 6156
import math


# 素因数分解（試し割り法）
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
fact = prime_factorize(math.factorial(n))
before_x = 1
total = 1
count = 0
for i in range(len(fact)):
    if fact[i] == before_x:
        count += 1
    else:
        total *= (count + 1)
        count = 1
        before_x = fact[i]
    if i == len(fact) - 1:
        if fact[i] == before_x:
            total *= (count + 1)
        else:
            total *= 2
print(total % ((10**9) + 7))

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

int main(void) {

	int N, M;
	cin >> N >> M;

	int* a = new int[M];
	int* b = new int[M];
	int* answer = new int[N];
	
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i < N; i++) {
		answer[i] = 0;
	}

	for (int i = 0; i < M; i++) {
		int temp = a[i]-1;
		answer[temp]++;
		temp = b[i]-1;
		answer[temp]++;
	}

	for (int i = 0; i < N; i++) {
		cout << answer[i] << endl;
	}

	delete[] a;
	delete[] b;
	delete[] answer;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define min(a,b) (((a)>(b))?(b):(a))
#define max(a,b) (((a)>(b))?(a):(b))
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n,y;
	cin>>n>>y;
	int s=0;
	s=y-1000*n;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=n-a;b++){
			if(s==9000*a+4000*b){
				cout<<a<<" "<<b<<" "<<n-a-b;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
s = input() + 'R'

ans = [0] * (len(s) - 1)
cntR = cntL = 0

for i in range(len(s) - 1):
    if s[i] == 'R':
        cntR += 1
        if s[i + 1] == 'L':
            RtoL = i
    if s[i] == 'L':
        cntL += 1
        if s[i + 1] == 'R':
            ans[RtoL] += -(-cntR // 2) + cntL // 2
            ans[RtoL + 1] += -(-cntL // 2) + cntR // 2
            cntR = cntL = 0

print(*ans, sep=' ')

Measured memory_bytes: 6400
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=1;i<N;i++){
			E[Parent[i]].Add(i);
		}
		
		int[] depth = new int[N];
		var Q = new Queue<int>();
		depth[0] = 0;
		Q.Enqueue(0);
		while(Q.Count>0){
			var now = Q.Dequeue();
			foreach(var nxt in E[now]){
				depth[nxt] = depth[now] + 1;
				Q.Enqueue(nxt);
			}
		}
		
		var L = new List<Pair>();
		for(int i=0;i<N;i++){
			L.Add(new Pair(i,depth[i]));
		}
		L.Sort((p,q) => -1 * p.Depth.CompareTo(q.Depth));
		
		int[] min = new int[N];
		int Inf = (int)1e9;
		for(int i=0;i<N;i++) min[i] = Inf;
		
		foreach(var now in L.Select(p => p.Pos)){
			if(E[now].Count == 0){
				min[now] = 0;
				continue;
			}
			
			var dp = new Dictionary<int,int>();
			dp.Add(0,0);
			foreach(var c in E[now]){
				int a = X[c];
				int b = min[c];
				var nxt = new Dictionary<int,int>();
				foreach(var k in dp.Keys){
					if(k + a <= X[now]){
						if(!nxt.ContainsKey(k + a)) nxt.Add(k + a,dp[k]+b);
						nxt[k+a] = Math.Min(nxt[k+a],dp[k]+b);
					}
					if(k + b <= X[now]){
						if(!nxt.ContainsKey(k + b)) nxt.Add(k + b,dp[k]+a);
						nxt[k+b] = Math.Min(nxt[k+b],dp[k]+a);
					}
				}
				if(nxt.Count == 0){
					Console.WriteLine("IMPOSSIBLE");
					return;
				}
				dp = nxt;
			}
			
			foreach(var k in dp.Keys){
				min[now] = Math.Min(min[now],dp[k]);
			}
		}
		
		Console.WriteLine(min[0] == Inf ? "IMPOSSIBLE" : "POSSIBLE");
		
	}
	
	class Pair{
		public int Pos,Depth;
		public Pair(int pos, int dep){
			Pos = pos; Depth = dep;
		}
	}
	
	int N;
	int[] Parent;
	int[] X;
	public Sol(){
		N = ri();
		int[] d = null;
		if(N != 1){
			d = ria();
		} else {
			rs();
		}
		Parent = new int[N];
		Parent[0] = -1;
		for(int i=1;i<N;i++) Parent[i] = d[i-1]-1;
		
		X = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
typedef pair<int, int> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

struct RollingHash {
    ll H, W;
    const ll B1, B2, M;
    vector<vector<ll>> h;
    vector<ll> pow1, pow2;

    RollingHash(vector<string> &str) : B1(1009), B2(1007), M(1000000009) {
        H = str.size(), W = str[0].size();
        h.assign(H + 1, vector<ll>(W + 1, 0));
        pow1.assign(H + 1, 1);
        pow2.assign(W + 1, 1);

        rep(i, H)pow1[i + 1] = pow1[i] * B1 % M;
        rep(i, W)pow2[i + 1] = pow2[i] * B2 % M;

        rep(y, H)
            rep(x, W) {
                h[y + 1][x + 1] = (h[y][x + 1] * B1 % M + h[y + 1][x] * B2 % M
                                   + (M - h[y][x] * B1 % M * B2 % M) + str[y][x]) % M;
            }
    }

    ll hash(int x1, int y1, int x2, int y2) {
        return (h[y2][x2]
                + (M - h[y1][x2] * pow1[y2 - y1] % M)
                + (M - h[y2][x1] * pow2[x2 - x1] % M)
                + (h[y1][x1] * pow1[y2 - y1] % M * pow2[x2 - x1] % M)) % M;
    }
};

int main() {

    int h, w;
    cin >> h >> w;

    vector<string> s_list(h);
    rep(i, h) cin >> s_list[i];

    int r, c;
    cin >> r >> c;
    vector<string> t_list(r);
    rep(i, r) cin >> t_list[i];

    vector<vector<vector<int>>> z(h, vector<vector<int>>(r));


    RollingHash rs(s_list), pt(t_list);
    ll target = pt.hash(0, 0, c, r);
    for (int y = r; y < h + 1; y++)
        for (int x = c; x < w + 1; x++) {
            if (rs.hash(x - c, y - r, x, y) == target) {
                cout << y - r << " " << x - c << endl;
            }
        }


}


Measured memory_bytes: 44228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int a,b;
    char c;
    cin >> a >> c >>b;

    if(c=='+')cout << a+b << endl;
    else cout << a-b << endl;
    
    
    return 0;
}


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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    string s;
    cin >> s;
      
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;

   
    return 0;
}

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

int n;
char s[15];
long long an[10];
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		if(s[0]=='M') an[1]++;
		if(s[0]=='A') an[2]++;
		if(s[0]=='R') an[3]++;
		if(s[0]=='C') an[4]++;
		if(s[0]=='H') an[5]++;
	}
	for(int i=1;i<=3;i++)
		for(int j=i+1;j<=4;j++)
			for(int k=j+1;k<=5;k++)
				ans+=an[i]*an[j]*an[k];
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {

    string  s;
    int vec[3];
    cin >> s ;
    
    int n = 3;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        int ans = ctoi(s[0]) ;
           // cout << ans << endl ;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                ans+=ctoi(s[i+1]);
            }else{
                ans-=ctoi(s[i+1]);
            }
        }
        //cout << ans << endl ;
        if(ans==7){
            cout << s[0] ;
            for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                cout << '+' << s[i+1] ;
            }else{
                cout << '-' << s[i+1] ;
            }
        }
                    break ;
    }
    }

    cout << '=' << 7 ;

    return 0 ;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
mul = lambda x, y : x * y % MOD
from functools import reduce
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(key = abs, reverse = 1)

    if all(a < 0 for a in A) or n == k:
        if k & 1:
            print(reduce(mul, A[-k:]))
        else:
            print(reduce(mul, A[:k]))
        return

    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(-a)

    pos.reverse()
    neg.reverse()
    ans = 1
    if k & 1:
        ans *= pos.pop()
        k -= 1

    for _ in range(k // 2):
        if len(pos) >= 2 and len(neg) >= 2:
            a, b = pos[-2:]
            c, d = neg[-2:]
            if a * b >= c * d:
                ans *= pos.pop()
                ans *= pos.pop()
                ans %= MOD
            else:
                ans *= neg.pop()
                ans *= neg.pop()
                ans %= MOD
        elif len(pos) >= 2:
            ans *= pos.pop()
            ans *= pos.pop()
            ans %= MOD
        elif len(neg) >= 2:
            ans *= neg.pop()
            ans *= neg.pop()
            ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 116312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string KUROE;
  int YUNI, TIERU, OOT = 0;
  int JNY;
  JNY = -1;
  bool COCCOLO = true;
  double PKRN;
  cin >> YUNI >> TIERU;
  
  for(int TKSS = 0; TKSS < TIERU; TKSS ++){
    cin >> OOT;
    YUNI -= OOT;
    if(YUNI < 0){
      cout << JNY << endl;
      COCCOLO = false;
      break;
    }
  }
  
  if(COCCOLO){
  cout << YUNI << endl;
  }
}
  

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n;  cin >> n;
    int a[n];
    vector <int> edge;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    int va, cnt = 1;
    for(int i = 0; i < n; i++){
        if(i == 0)  va = a[i];
        else if(va == a[i]){
            cnt++;
            if(cnt % 2 == 0)
                edge.push_back(a[i]);
        }
        else{
            cnt = 1;
            va = a[i];
        }
    }
    if(edge.size() < 2)
        cout << 0 << endl;
    else
        cout << (long long int)*(edge.end() - 2) * *(edge.end() - 1)<< endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n,r=0,g=0,b=0;
    cin >>n;
    string s;
    cin >>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
ll sum=r*g*b;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int p=j+j-i;
            if(p<n){
              if(s[p]!=s[i] && s[p]!=s[j] && s[i]!=s[j])sum--;
            }
        }
    }
    if(n<3)sum=0;
    cout << sum << "\n";
   return 0;
}


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

void solve(long long A, long long P){
    cout << (3 * A + P) / 2 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int dx[8] = {-1,1,0,0};
int dy[8] = {0,0,-1,1};

inline void solve(){
    int h,w;
    cin >> h >> w; 
    string s[h];
    for (int i=0;i<h;i++) cin >> s[i];
    bool ok=true;
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (s[i][j]=='#'){
                int cnt=0;
                for (int k=0;k<4;k++){
                    int x=i+dx[k],y=j+dy[k];
                    if (x<0 or x>=h or y<0 or y>=w) continue; 
                    if (s[x][y]=='#') cnt++;
                }
                if (cnt<1) ok=false; 
            }
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3584
#include <vector>
#include <iostream>
using namespace std;
void a(){

    vector<int> antena(5);
    for(int i = 0; i < 5; i++){
        cin >> antena[i];
    }
    int k; cin >> k;

    bool ok =(antena[4] - antena[0] <= k);

    if (ok)
        cout << "Yay!";
    else
        cout << ":(";

}

int main(){

    a();
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){if(x==0)return 0;int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int i,n,k,cunt=0,p,r,s=1;
		cin>>n>>k;
		int a[n+1],vis[n+1]={0},dis[n+1]={0};
		for(i=1;i<=n;i++)
		cin>>a[i];
		i=1;
		vis[1]=1;
		while(cunt<k)
		{
			p=a[i];
			if(i==p)
			{
				cout<<p<<endl;
				return 0;
			}
			if(dis[p]==0)
			dis[p]=dis[i]+1;
			else
			{
				if(i!=p)
				{
					s=p;
					dis[p]=dis[i]+1-dis[p];
					k-=dis[i]+1;
				}
			}
			cunt=dis[p];
			if(vis[p])
			break;
			vis[p]=1;
			i=p;
		}
		if(cunt==k)
		{
			cout<<p<<endl;
			continue;
		}
		if(s!=1)
		cunt=max((int)0,cunt);
		r=k%cunt;
		p=s;
		while(r)
		{
			p=a[p];
			r--;
		}
		cout<<p<<endl;
	}
}



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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int a[2];

    map <int,int> mp;
    loop(i,0,2)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    loop(i,1,4)
    {
        if(mp[i]==0)
        {
            cout<<i;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c,n;
  int i, q;
  P u;
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11920
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
using namespace std;

int main(){
  int n;
   vector<int> dp[1024];
  
  for(int i=1;i<=1023;i++){
    if(i == 1 || i == 2 || i == 4 || i == 8 || i == 16 || i == 32 || i == 64 || i == 128 || i == 256 || i == 512){
      dp[i].push_back(i);
      continue;
    }
    if(dp[i].empty()){
      int index,bg;
      bg = i-1;
      for(int j=1;j<bg;j++){
	index = bg+j;
	for(int k=0;k<dp[j].size();k++){
	  dp[index].push_back(dp[j][k]);
	}
	for(int k=0;k<dp[bg].size();k++){
	  dp[index].push_back(dp[bg][k]);
	}
      }
    }
  }

  while(cin >> n){
    assert(n<=1023);
    for(int i=0;i<dp[n].size();i++){
      cout << dp[n][i];
      i==dp[n].size()-1?cout << endl:cout << " ";
    }


  }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll s;
    cin >> s;
    if(s == 1000000000000000000){
        cout << 0 << " " << 0 << " " << 0 << " " << 1000000000 << " " << 1000000000 << " " << 0 << endl;
    }else{
        ll x = s / 1000000000 + 1, y = 1000000000 - s % 1000000000;
        cout << 0 << " " << 0 << " " << 1 << " " << 1000000000 << " " << x << " " << y << endl;
    }
}

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

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007ll;
const int N = 2005;
int n, a[N];
long long k, ans = 0ll;
int main () {
    scanf("%d%lld", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] < a[j]) ans = (ans + k * (k - 1) / 2) % mod;
            if (a[i] > a[j]) ans = (ans + k * (k + 1) / 2) % mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int tc;
	cin >> tc;
	if(tc%10 == 3)cout << "bon" << "\n";
   else if(tc%10 == 0 || tc%10 == 1 || tc%10 == 6 || tc%10 == 8)cout << "pon" << "\n";
  else cout << "hon" << "\n";
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  string s, t;
  cin >> n >> s >> t;
  for(int i = 0; i < n; i++){
    for(int j = 0; i + j < n; j++){
      if(s[i + j] != t[j])break;
      if(j == n - i - 1){
        cout << n + i << endl;
        return 0;
      }
    }
  }
  cout << 2 * n << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long int k,v,cv,n=0;
	long int sum=0;
	double sum_v=0;

	while(scanf("%ld,%ld",&k,&v) != EOF)
	{
		sum+=k*v;
		sum_v+=(double)v;
		n++;
	}
	sum_v/=(double)n;
	cv=(long int)sum_v;

	if((double)sum_v-(double)cv>=0.5)
		cv++;

	printf("%ld\n",sum);
	printf("%ld\n",cv);

	return 0;
}

Measured memory_bytes: 592
use std::io::*;
use std::str::FromStr;
use std::char;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let s: String = read();
    let new_s: String = s.as_str().chars().map(|c| convert(&c, n)).collect();
    println!("{}", new_s);
}

fn convert(c: &char, offset: u32) -> char{
    let i: u32 = *c as u32;
    char::from_u32((i + offset - 65) % 26 + 65).unwrap()
}


Measured memory_bytes: 4352
/*
given H and A

find if can use all A once to reduce health to zero

10 3
4 5 6

Yes



*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long; 

const int mod = 1e9+7;

int add(int a, int b) {
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }
    return c;
}


int main() {
    int n;
    int k;
    scanf("%d%d", &n, &k);
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        v.push_back(num);    
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for (int i = 0; i < n-k; i++) {
        ans += v[i];
    }
    printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String s = sc.next();
        if (s.charAt(A) == '-' && s.replace("-", "").length() == A + B) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

#define int ll

int n, ans;

void check(int m)
{
	if(!m)
		return;

	if(n % m == n / m)
		ans += m;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i * i <= n; ++i)
	{
		if(n % i == 0)
		{
			check(i - 1);

			if(n / i != i)
				check(n / i - 1);
		}
	}

	cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

map<pll, bool> m;
ll num[10];

int main()
{
    ll H, W;
    cin >> H >> W;
    int N;
    cin >> N;
    vector<pll> v;
    REP(i, N)
    {
        pll g(0, 0);
        cin >> g.first >> g.second;
        m[g] = true;
        for (int x = -1; x <= 1; ++x)
        {
            for (int y = -1; y <= 1; ++y)
            {
                ll nx = g.first + x, ny = g.second + y;
                if (nx <= 1 || ny <= 1 || nx >= H || ny >= W)
                    continue;
                v.push_back(pll(nx, ny));
            }
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    memset(num, 0, sizeof(num));
    REP(i, v.size())
    {
        int n = 0;
        for (int x = -1; x <= 1; ++x)
        {
            for (int y = -1; y <= 1; ++y)
            {
                ll nx = v[i].first + x, ny = v[i].second + y;
                if (m[pll(nx, ny)])
                    n++;
            }
        }
        num[n]++;
    }

    num[0] = (H - 2) * (W - 2) - v.size();
    REP(i, 10)
    {
        cout << num[i] << endl;
    }
    return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl

ll factorial(int x) {
    ll res = 1;
    while(x > 1) {
        res = (res * x) % MOD;
        x--;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, M; cin >> N >> M;
    if (abs(N - M) == 1) {
        cout << (factorial(N) * factorial(M)) % MOD << "\n";
    } else if (N == M) {
        cout << (((factorial(N) * factorial(M)) % MOD) * 2) % MOD << "\n";
    } else {
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  N= parseInt(input[0]);
  H= parseInt(input[1]);
  W= parseInt(input[2]);
  var ans=(N-H+1)*(N-W+1);
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n = int(input())
c = [0]*4
for _ in range(n):
    s = str(input())
    if s == 'AC':
        c[0] += 1
    elif s == 'WA':
        c[1] += 1
    elif s == 'TLE':
        c[2] += 1
    else:
        c[3] += 1

print('AC x '+str(c[0]))
print('WA x '+str(c[1]))
print('TLE x '+str(c[2]))
print('RE x '+str(c[3]))


Measured memory_bytes: 9200
#include<iostream>
using namespace std;
int main(){
  
  int n,m;
  char  moji,change[1000000][2];

  while(1){
    
    cin >>n;
    
    if( n == 0)break;
    
    for(int i=0 ; i < n ; i++){
      cin >>change[i][0]>>change[i][1];
    }
    
    cin >>m;
    
    for(int i=0 ; i < m ; i++){
      cin >>moji;
      for(int j=0 ; j < n ; j++){
	if(moji == change[j][0]){
	  moji=change[j][1];
	  break;
	}
    }
      cout<<moji;
    }
    cout <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back

using namespace std;
using ll = long long;
const int MOD = (int) 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c, k, ans = 0;
	cin>>a>>b>>c>>k;

	if(k == 0) {
		cout<<ans<<'\n';
		return 0;
	}

	if(a <= k) {
		k -= a;
		ans += a;

	} else {
		ans += k;
		k = 0;
	}

	if(k == 0) {
		cout<<ans<<'\n';
		return 0;
	}

	if(b <= k) {
		k -= b;
	} else {
		k = 0;
	}

	if(k == 0) {
		cout<<ans<<'\n';
		return 0;
	}

	if(c <= k) {
		ans -= c;
		k -= c;
	} else {
		ans -= k;
		k = 0;
	}

	cout<<ans<<'\n';


	return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  
  int cost = 0;
  if(13 <= A) {
    cost = B;
  }
  else if(6 <= A && A <= 12) {
    cost = B/2;
  }
  else {
    cost = 0;
  }
  
  cout << cost << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
char s[4];
int main() {
  scanf("%s", s);
  for (int i = 0; i < 3; i++) {
    if (s[i] == '7') {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 2156
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s=="ABC"){
    	cout<<"ARC"<<endl;
    }else{
    	cout<<"ABC"<<endl;
    }
    return 0;
}


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

int main() {
    int n, m,ans;

    cin >> n >> m;
    vector<int> l(m),r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }

    int mn = 0;
    int mx = INT_MAX;
    ans = 0;
    rep(i, m) {
        mn = max(mn, l[i]);
        mx = min(mx, r[i]);
    }

    if (mn<=mx)
        ans = mx - mn + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4032
N=int(input())
a_n=[]
a2_n=[]
a_n = input().split(" ")
count = 0

for i in range(N):
    if int(a_n[i])/400 < 8:
         a2_n.append(int(a_n[i])//400)
    else:
        count += 1

n_min = len(set(a2_n))
n_max = n_min+count

print(max(1, n_min),n_max)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Console.ReadLine().ToInt();
		var q = (p/1000);
		var n = p % 1000;
		if(n != 0)
		{
			q++;
		}
		Console.WriteLine(q*1000-p);
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27480
S = gets.chomp.chars

completed = false

2.upto(3) do |i|
  break if completed
  S.each_cons(i).with_index do |s, j|
    if s.uniq.size != i
      puts "#{j + 1} #{i + j}"
      completed = true
      break
    end
  end
end

puts "-1 -1" unless completed


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

const int inf = 1<<28;

int main(){
  int N,M,L,K,A,H;
  while(cin>>N>>M>>L>>K>>A>>H,N){
    vector<vector<int> > v(N,vector<int>(N,inf));
    vector<bool> nlist(N,false);
    for(int i=0;i<L;i++){
      int t;
      cin>>t;
      nlist[t]=true;
    }
    nlist[A]=nlist[H]=true;
    for(int i=0;i<K;i++){
      int x,y,t;
      cin>>x>>y>>t;
      v[x][y]=v[y][x]=t;
    }
    for(int k=0;k<N;k++){
      for(int i=0;i<N;i++){
	for(int j=0;j<N;j++){
	  v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
	}
      }
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if(v[i][j] > M) v[i][j]=inf;
	if(!nlist[i] || !nlist[j]) v[i][j]=inf;
      }
    }
    for(int k=0;k<N;k++){
      for(int i=0;i<N;i++){
	for(int j=0;j<N;j++){
	  v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
	}
      }
    }
    int ans = v[A][H];
    if(ans == inf) cout<<"Help!"<<endl;
    else{
      if(ans > M) ans += ans - M;
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1256
/* ----------------------------
 * ABC 91 C
 * ---------------------------- */
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<int, int>> a;
	vector<pair<int, int>> b;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		a.push_back({x, y});
	}
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		b.push_back({x, y});
	}
	int ans = 0;
	auto x_sorter = [](pair<int, int> a, pair<int, int> b) -> bool {
		return a.first < b.first;
	};
//	auto y_sorter = [](pair<int, int> a, pair<int, int> b) -> bool {
//		return a.second < b.second;
//	};
	// a, b を x座標で昇順にソート
	sort(a.begin(), a.end(), x_sorter);
	sort(b.begin(), b.end(), x_sorter);
	
	// b の要素をループ
	for(auto p: b){
		int target = -1;
		int max_y = -1;
		// b の x座標も、かつ y座標も小さい a の点を見つけて vector から削除
		for(int i = 0; i < a.size(); i++){
			// x 座標が逆転したら もう a は調べない(ソート済みなので)
			if(a[i].first >= p.first) break;
			// y 座標が逆転していればこいつとはペアを組めないので次の周回へ
			if(a[i].second >= p.second) continue;
			// 最大の y 座標を保存
			int before = max_y;
			// y 座標を更新
			max_y = max(max_y, a[i].second);
			// y 座標が更新されれば、こいつがペアの相手(削除対象)
			if(before != max_y) target = i;
		}
		// パートナーが見つからなかったら次の周回に期待
		if(target == -1) continue;
		// ペアが決まったので a から削除
		a.erase(a.begin() + target);
		// ペアの数を更新
		++ans;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  pii a, b;
  cin >> a >> b;

  int vx = b.fi - a.fi, vy = b.se - a.se;

  pii c;
  c.fi = b.fi - vy, c.se = b.se + vx;
  vx = c.fi - b.fi, vy = c.se - b.se;

  pii d;
  d.fi = c.fi - vy, d.se = c.se + vx;
  cout<<c<<" "<<d<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    map<char,int> P;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=0;j<m;j++){
            P[s[j]]++;
        }
    }
    int a1=0,a4=0;
    for(auto x:P){
        if(x.second%2==1)a1++;
        a4+=x.second/4;
    }
    if(n&1&&m&1){
        if(a1==1 && (m-1)*(n-1)/4<=a4){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    else if(n%2==0 && m%2==0){
        if(m*n/4<=a4 && a1==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    else{
        if(m%2==0)swap(m,n);
        if((m-1)*n/4<=a4 && a1==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define N 100010
#define LL long long
int a[N];
LL b[N];
vector<LL> q;
int main()
{
    int i,j,k,n,m;
    int x,y,z;
    LL d,t,s;
    scanf("%d%d",&n,&m);
    b[0]=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=b[i-1]+a[i];
    }
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j++)
        {
            d=b[j]-b[i-1];
            q.push_back(d);
        }
    }
    s=0;
    for(i=40;i>=0;i--)
    {
        d=s|(LL)pow(2,i);
        k=0;
        for(j=0;j<n*(n+1)/2;j++)
        if((q[j]&d)==d)
            k++;
        if(k>=m)
            s=s+(LL)pow(2,i);
    }
    printf("%lld\n",s);
    return 0;
}


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

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i = 0; i<n; i++)
    cin >> s.at(i);
  sort(s.begin(), s.end());
  for(int i = 0; i<n; i++)
    cout << s.at(i);
  cout << endl;
}

Measured memory_bytes: 3592
import numpy as np

H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

b = []
for i in range(H):
    if '#' in a[i]:
        b.append(a[i])
b = np.array(b)

c = []
for i in range(W):
    if '#' not in b[:, i]:
        c.append(i)

b = np.delete(b, c, axis=1)

for i in range(len(b)):
    print(*b[i], sep='')


Measured memory_bytes: 21812
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if judge!=0:
        break
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

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

int main() {
	string a, b, c;
  	cin >> a >> b >> c;
  
  	char A = a.at(0) - 0x20;
  	char B = b.at(0) - 0x20;
  	char C = c.at(0) - 0x20;
  	
  	cout << A << B << C << endl;
}

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

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

int N;
int dp[100001];

int main(){
    scanf("%d",&N);

    for(int i = 0;i <= N;i++){
        dp[i] = N;
    }

    dp[0] = 0;

    for(int i = 1;i <= N;i++){
        int six = 0;
        int keep_i = i;
        while(1){
            keep_i = keep_i/6;
            if(keep_i == 0)break;
            six++;
        }

        int nine = 0;
        int keep_i2 = i;
        while(1){
            keep_i2 = keep_i2/9;
            if(keep_i2 == 0)break;
            nine++;
        }

        dp[i] = dp[i-1] + 1;
        for(int j = 1;j <= six;j++){
            int pre = pow(6,six);
            dp[i] = min(dp[i],dp[i-pre]+1);
        }
        for(int j = 1;j <= nine;j++){
            int pre = pow(9,nine);
            dp[i] = min(dp[i],dp[i-pre]+1);
        }
    }
    

    printf("%d\n",dp[N]);

    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x : int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)

mod = 10**9+7
fact = [1] * N
fact_inv = [1] * N
for i in range(1, N):
    fact[i] = i * fact[i-1] % mod
inv = lambda x : pow(x, mod-2, mod)
fact_inv[N-1] = inv(fact[N-1])
for i in range(1, N)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k : fact[n] * fact_inv[k] * fact_inv[n-k] % mod

dp = [1] * N
size = [0] * N
def dfs(par, v):
    for u in G[v]:
        if par == u:
            continue
        dfs(v, u)
        size[v] += size[u]
        dp[v] = dp[v] * dp[u] * fact_inv[size[u]] % mod
    dp[v] = dp[v] * fact[size[v]] % mod
    size[v] += 1

ans = [0] * N
def reroot(par, val_par, size_par, v):
    ans[v] = val_par * dp[v] * comb(N-1, size_par) % mod
    for u in G[v]:
        if par == u:
            continue
        val = ans[v] * inv(dp[u] * comb(N-1, size[u])) % mod
        reroot(v, val, N-size[u],  u)

dfs(-1, 0)
reroot(-1, 1, 0, 0)
print(*ans, sep='\n')

Measured memory_bytes: 86856