akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int seieve[10000001];

int main(){
    for(int i = 2;i*i<=10000000;i++){
        if(seieve[i] == 0){
            for(int j = i*i;j<=10000000;j+=i){
                if(seieve[j] == 0)seieve[j] = i;
            }
        }
    }
    ll ans = 1;
    int n;
    cin>>n;
    for(int i = 2;i<=n;i++){
        map<int,int> mp;
        int x = i;
        while(true){
            if(seieve[x] == 0){
                mp[x]++;
                break;
            }else{
                mp[seieve[x]]++;
                x /= seieve[x];
            }
        }
        ll num = 1;
        for(auto it:mp){
            num *= (it.second + 1);
        }
        ans += (num * i);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 42688
#include "bits/stdc++.h"
using namespace std;

typedef pair<int,pair<int,int>> P;

vector<P> m2n2;
int main()
{
	int test=0;
	for(int i=-150;i<151;i++)
	{
		for(int j=-150;j<151;j++)
		{
			if(i*i+j*j>1 && i*i+j*j<20000)
				m2n2.push_back(P(i*i+j*j,make_pair(i,j)));
		}
	}
	sort(m2n2.begin(),m2n2.end());
	//cerr<<m2n2.size()<<endl;
	cin>>test;
	for(int t=0;t<test;t++)
	{
		int p,q;
		cin>>p>>q;
		int pq=p*p+q*q;
		bool f=true;
		for(int i=0;i<m2n2.size();i++)
		{
			int m=m2n2[i].second.first;
			int n=m2n2[i].second.second;
			if(pq==m2n2[i].first)
				break;
			
			if((m*p+n*q)%m2n2[i].first==0 && (m*q-n*p)%m2n2[i].first==0)
			{
				f=false;
				break;
			}
		}
		if(f)
			cout<<"P"<<endl;
		else
			cout<<"C"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3520
# D - String Formation
s = input()
q = int(input())
f = b = ''
odd = 0
for i in range(q):
    t,*fc = input().split()
    if t=='1': odd ^= 1 #t1
    else: #t2
        if odd ^ (int(fc[0])-1): b += fc[1]
        else: f += fc[1]
s = b[::-1] + s[::-1] + f if odd else f[::-1] + s + b
print(s)

Measured memory_bytes: 4340
from math import gcd

def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            g = gcd(i, j)
            for k in range(1, K+1):
              ans += gcd(g, k)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
struct Unionfind{
	vector<int>r;
	vector<int>size;
	Unionfind(int n){
		r=vector<int>(n,-1);
		size=vector<int>(n,1);
		}
		int root(int x){
			if(r[x]<0)return x;
			else return r[x]=root(r[x]);}
			void make_set(int a,int b){
				a=root(a);
				b=root(b);
				if(a!=b){
					if(size[a]<size[b])swap(a,b);
					size[a]+=size[b];
					r[b]=a;}}
			 int length(int i){
				 return size[root(i)];}};
int main(){IOS;
	int n,m;
	cin>>n>>m;
	Unionfind U(n);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a-=1;
		b-=1;
		U.make_set(a,b);}
		int ans=0;
		for(int i=0;i<n;i++){
		    int sol=U.length(i);
		    ans=max(ans,sol);}
		    cout<<ans<<endl;}

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

using namespace std;
#ifndef localfile
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC optimize("unroll-loops")
#endif
#define int long long
#define x first
#define y second
typedef pair<int, int> pii;


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

    int n, k;
    cin >> n >> k;

    if ((n + 1) / 2 >= k) {
        cout << "YES";
    }

    else {
        cout << "NO";
    }

    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62



def solve(N: int, A: "List[int]"):
    ans = 1
    if 0 in A:
        print(0)
        return 
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 82844
#include <bits/stdc++.h>
using namespace std;
int a[300][5];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i][1],&a[i][2]);
    }
    for(int i=1;i<=n-2;i++){
        if( a[i][1] == a[i][2] && a[i+1][1] == a[i+1][2] && a[i+2][1] == a[i+2][2] ){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}


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

ans = 1
cnt = 2
w = 0
for Ai in sorted(map(int, input().split()), reverse=True):
  if w != Ai:
    w = Ai
  else:
    ans *= w
    cnt -= 1
    if cnt <= 0:
      break
    w = 0

print(ans if cnt <= 0 else 0)


Measured memory_bytes: 14800
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;
struct ki {
    int id;
    ki *parent;
    ki *left;
    ki *right;
};

int Preorder(ki *x) {
    cout << " " << x->id;

    if (x->left->id != -1) {
        Preorder(x->left);
    }
    if (x->right->id != -1) {
        Preorder(x->right);
    }
    return 0;
}

int Inorder(ki *x) {
    if (x->left->id != -1) {
        Inorder(x->left);
    }
    cout << " " << x->id;
    if (x->right->id != -1) {
        Inorder(x->right);
    }
    return 0;
}

int Postorder(ki *x) {
    if (x->left->id != -1) {
        Postorder(x->left);
    }
    if (x->right->id != -1) {
        Postorder(x->right);
    }
    cout << " " << x->id;
    return 0;
}

int main(void) {
    int n, tmp, h, m;
    cin >> n;
    ki *l;
    l = new ki[n+1];
    for (int j = 1; j < n+1; ++j) {
        l[j].parent = &l[0];
    }
    for (int i = 0; i < n; ++i) {
        cin >> tmp >> h >> m;
        ki *ima = &l[tmp + 1];
        ima->id = tmp;
        ima->left = &l[h + 1];
        ima->right = &l[m + 1];
        ima->left->parent = ima;
        ima->right->parent = ima;
    }
    l[0].id = -1;
    ki *nu = &l[0];
    ki *root;
    for (int i = 1; i < n+1; ++i) {
        if (l[i].parent == nu) {
            root = &l[i];
        }
    }
    cout << "Preorder" << endl;
    Preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    Inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    Postorder(root);
    cout << endl;

    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve() {
    string s, t;
    cin>>s>>t;

    ll dp[s.size() + 1][t.size() + 1];

    for(int i = 0; i <= s.size(); i++) {
        for(int j = 0; j <= t.size() ; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
            }else {
                if(s[i-1] == t[j-1]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
                }
            }
        }
    }

    //cout<<dp[s.size() +1][t.size() + 1];
    string ans = "";
    int row = s.size(), col = t.size();

    while(row != 0 && col != 0) {
        if(dp[row][col] == dp[row-1][col]) {
            row = row - 1;
            continue;
        }
        if(dp[row][col] == dp[row][col-1]) {
            col = col - 1;
            continue;
        }

        ans += s[row-1];

        row--;
        col--;
    }

    reverse(ans.begin() , ans.end());
    cout<<ans;
}
int main()
{
    ll t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

long long mincost[301][301]={};
bool mincost_isneed[301][301]={};
int N;
long long answer=0;

int main(void){
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            scanf("%lld",&mincost[i][j]);
        }
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(mincost[i][j]>mincost[i][k]+mincost[k][j]){
                    cout<<"-1"<<endl;
                    return 0;
                }
                if(mincost[i][j]==mincost[i][k]+mincost[k][j] && mincost[i][k]>0 && mincost[k][j]>0){
                    mincost_isneed[i][j]=true;
                }
                
            }
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            if(!mincost_isneed[i][j]) answer+=mincost[i][j];
        }
    }

    cout<<answer<<endl;



    

    
	
    return 0;
}


Measured memory_bytes: 1024
s = input()

while s:
   if s[-5:] in ["dream", "erase"]:
      s = s[:-5]
   elif s[-6:] ==  "eraser":
      s = s[:-6]
   elif s[-7:] == "dreamer":
      s = s[:-7]
   else:
      print('NO')
      import sys
      sys.exit()

print('YES')
      

Measured memory_bytes: 3188
# coding: utf-8
import math

def prime_number(x):
    if x == 2:
        return True
    
    elif x < 2 or x % 2 == 0:
        return False
    
    else:
        i = 3
        while i <= math.sqrt(x):
            if x % i == 0:
                return False
            i = i + 2
        return True

if __name__ == "__main__":
    N = int(input())
    c = 0
    for i in range(N):
        x = int(input())
        c += prime_number(x)
    print(c)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i <= n; ++i)

using namespace std;
using ll = long long;

void solve(ll N, ll P) {
  unordered_map<ll, ll> yakusu;
  FOR(i, 2, sqrt(P)) {
    while (P % i == 0) {
      yakusu[i]++;
      P /= i;
    }
  }
  if (P != 1)
    yakusu[P]++;

  ll ans(1);
  for (auto p : yakusu) {
    // printf("%lld x %lld\n", p.first, p.second);
    REP(i, p.second / N)
      ans *= p.first;
  }

  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, P;
  cin >> N >> P;

  solve(N, P);

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000009
using namespace std;
typedef long long ll;

int n, m;
list<int> adj[100005];

void dfs(int node, stack<int>& ts, bitset<100005>& vis){
	if (vis[node]) return;
	vis[node] = 1;
	for (int kom : adj[node]){
		dfs(kom, ts, vis);
	}
	ts.push(node);
}

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
	}
	
	stack<int> ts;
	bitset<100005> vis;
	vis.reset();
	for (int i = 0; i < n; i++){
		if (vis[i] == 0) dfs(i, ts, vis);
	}
	
	vector<int> dp(n, 0);
	
	int ans = 0;
	while (!ts.empty()){
		int node = ts.top();
		ts.pop();
		ans = max(ans, dp[node]);
		for (int kom: adj[node]){
			dp[kom] = max(dp[kom], dp[node]+1);
		}
	}
	
	//for (int i = 0; i < n; i++) cout << i+1 << ": " << dp[i] << endl;
	
	cout << ans << endl;
	
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
const int N=1e18;



int32_t main()
{
    IOS;
	

	int n;
	cin>>n;
	int mincost[n+1];
	int A[n+1];
	int cost1,cost2;
	
	for(int i=1;i<=n;i++)
	{
		cin>>A[i];
	}
	mincost[1]=0;

	if(n==1) return cout<<0<<endl,0;

	mincost[2]=abs(A[2]-A[1]);

	for(int i=3;i<=n;i++)
	{
		cost1=mincost[i-2]+abs(A[i]-A[i-2]);
		cost2=mincost[i-1]+abs(A[i]-A[i-1]);
		mincost[i]=min(cost1,cost2);
	}

	cout<<mincost[n]<<endl;
	return 0;
}


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

class Program {

    static int MX = 6;
    const int wht = 6, gry = 1, blk = 2;
    const long inf = long.MaxValue;

    static List<Edge> edges = null;
    static long[] d = null;




    class Edge {
        public int frm, to, cst;
        public Edge(int pf, int pt, int pc) {
            frm = pf;
            to = pt;
            cst = pc;
        }
        public string prt() {
            return "eg:" + frm.ToString() + "-" + to.ToString() + " " + cst.ToString();
        }
    }


    static bool shortestPath(int src) {

        for (int i = 0; i < MX; i++) {
            d[i] = inf;
        }
        d[src] = 0;

        int cnt = 0;
        bool updated = true;

        while (updated) {
            updated = false;
            foreach (var eg in edges) {
                if (d[eg.frm] != inf && d[eg.to] > d[eg.frm] + eg.cst) {
                    d[eg.to] = d[eg.frm] + eg.cst;
                    updated = true;
                    if (cnt == MX - 1) return false;
                }
            }
            cnt++;
        }
        return true;
    }

    static void Main(string[] args) {
    

        var inp = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
        int v, e; v = inp[0]; e = inp[1];

        int stt = inp[2];

        MX = v;
        edges = new List<Edge>();
        d = new long[MX];


        for (int i = 0; i < e; i++) {
            var c = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            edges.Add(new Edge(c[0], c[1], c[2]));
        }


        bool ngCyc = false, tmp = false;
        string str = "";

        tmp = shortestPath(stt);
        if (!tmp) {
            ngCyc = true;
        }

        if (ngCyc) Console.WriteLine("NEGATIVE CYCLE");
        else {
            string s = "";
            foreach (var dst in d) {
                if (s.Length > 0) s += " ";
                s = dst == inf ? "INF" : dst.ToString();
                Console.WriteLine(s);
            }

        }

    }
}




Measured memory_bytes: 38580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
using vec = vector < int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
int a,b,c,d,ans;
string s1,s2,s3;
int32_t main() {
    fast();
    cin >> a;
   	if(a&1){
   		cout<<a/2+1;
   	}
   	else
   		cout<<a/2;


    return 0;
}



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

int main(){//４つの配列を用意し、それぞれについて見ていく
   int n;
   cin >> n;
   veci s(13); rep(i, 13) s.at(i) = i+1;
   veci h(13); rep(i, 13) h.at(i) = i+1;
   veci c(13); rep(i, 13) c.at(i) = i+1;
   veci d(13); rep(i, 13) d.at(i) = i+1;
   rep(i, n){
       char q;
       int w;
       cin >> q>> w;
       if (q == 'S'){
           s.at(w-1) = -1;
       }
       if (q == 'H'){
           h.at(w-1) = -1;
       }
       if (q == 'C'){
           c.at(w-1) = -1;
       }
       if (q == 'D'){
           d.at(w-1) = -1;
       }
   }
   rep(i, 4){
       if (i == 0){
           rep(i, 13){
               if (s.at(i) != -1){
                   cout << 'S' << " " << i+1 << endl;
               }
           }
       }
       if (i == 1){
           rep(i, 13){
               if (h.at(i) != -1){
                   cout << 'H' << " " << i+1 << endl;
               }
           }
       }
       if (i == 2){
           rep(i, 13){
               if (c.at(i) != -1){
                   cout << 'C' << " " << i+1 << endl;
               }
           }
       }
       if (i == 3){
           rep(i, 13){
               if (d.at(i) != -1){
                   cout << 'D' << " " << i+1 << endl;
               }
           }
       }
   }
}


Measured memory_bytes: 3088
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = Long.parseLong(in.next());
		String b = in.next();
		long bb = 0;
		int times = 100;
		for(int i = 0; i < 4; i++) {
			if(!b.substring(i, i + 1).equals(".")) {
				bb += times * Integer.parseInt(b.substring(i, i + 1));
				times /= 10;
			}
		}
		long c = a * bb;
		c -= c % 100;
		c /= 100;
		System.out.println(c);
	}
}

Measured memory_bytes: 26836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        //string n;
        string[] input;
        
        public Solution()
        {
            //n = Console.ReadLine();
            input = Console.ReadLine().Split(' ');
        }       
        public void answer()
        {
            int X=Convert.ToInt32(input[0]);
            int A=Convert.ToInt32(input[1]);
            int B = Convert.ToInt32(input[2]);
            int XA = X+A;
            int BA = B - A;

            if (BA > 0 && BA <= X) {

                Console.WriteLine("safe");   
            }
            else if (BA > X) { Console.WriteLine("dangerous"); }
            else if (BA <= 0) { Console.WriteLine("delicious"); }

        }
    }
}

Measured memory_bytes: 11220
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

ans = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for d in make_divisors(N):
    if d == 1: continue
    tmp = N
    while tmp % d == 0:
        tmp //= d
    if tmp % d == 1:
        ans += 1    


print(ans + len(make_divisors(N-1))-1)

Measured memory_bytes: 39152
#include <stdio.h>

int main(){
    int n;
    int k;
    int i,j;
    double point;
    double x=0;
    double a ;

    scanf("%d",&n);
    scanf("%d",&k);

    for(i=1;i<=n;i++){
        point = (double)i;
        a = 1.0;
        while(1){
            if(point>=k){
                x += (double)1.0000000000000000/(n*a);
                break;
            }
            point = point*2;
            a=a*2.0;
        }
    }
    printf("%.15f",x);
}
    

Measured memory_bytes: 128
/*input
4 3
1 2 3 4
1 3
2 3
2 4
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, m, i, j;
	cin >> n >> m;
	vector<int> h(n);
	for(auto &x : h)
		cin >> x;
	vector<int> a(n);
	for(i=0; i<m; i++) {
		int o1, o2;
		cin >> o1 >> o2;
		--o1; --o2;
		assert(o1 < n && o2 < n);
		a[o1] = max(a[o1], h[o2]);
		a[o2] = max(a[o2], h[o1]);
	}
	int ret = 0;
	for(i=0; i<n; i++) {
		if(a[i]==-1 || a[i] < h[i])
			ret++;
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 3984
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static int gcd(int a, int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long array[] = new long[1000001];
        int n = sc.nextInt();
        long k = sc.nextLong();
        for (int i = 0; i < n; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            array[ai] += bi;
        }
        for (int i = 1; i < array.length; i++) {
            if (k <= array[i]) {
                System.out.println(i);
                break;
            }
            k -= array[i];
        }
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 56684
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func printArr(arr []string) {
	fmt.Println(strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]"))
}

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

	coinDaily, _ := nextInt()
	coinWeekly, _ := nextInt()
	coinTarget, _ := nextInt()

	coinCurrent := 0
	i := 0
	for i = 0; i <= 1000000; i++ {
		coinCurrent += coinDaily
		if (i+1)%7 == 0 {
			coinCurrent += coinWeekly
		}
		if coinCurrent >= coinTarget {
			break
		}
	}
	fmt.Println(i + 1)
}



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


int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n)
    cin >> h[i];
  vector<bool> good(n, true);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] >= h[b])
      good[b] = false;
    if (h[a] <= h[b])
      good[a] = false;
  }
  int ans = 0;
  rep(i, n)
    if (good[i])
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3800
//                             .
//                            .:.
//                            :|:
//                           .:|:.
//                           ::|::
//            :.             ::|::             .:
//            :|:.          .::|::.          .:|:
//            ::|:.         :::|:::         .:|:;
//            `::|:.        :::|:::        .:|::'
//             ::|::.       :::|:::       .::|:;
//             `::|::.      :::|:::      .::|::'
//              :::|::.     :::|:::     .::|::;
//              `:::|::.    :::|:::    .::|::;'
//     `::.      `:::|::.   :::|:::   .::|::;'     .:;'
//      `:::..    `;::|::.  :::|:::  .::|:::    ::::;
//        `:::::.    ':|::. :::|::: .::|:'   ,::::;'
//          `:::::.    ':|:::::|:::::|:'   :::::;'
//            `:::::.:::::|::::|::::|::::.,:::;'
//               ':::::::::|:::|:::|:::::::;:'
//                  ':::::::|::|::|:::::::''
//                       `::::::::::;'
//                      .:;'' ::: ``::.
//                           :':':
//                             ;                             

//             ,d                                                  
//             88                                                  
// ,adPPYba, MM88MMM ,adPPYba,  8b,dPPYba,   ,adPPYba, 8b,dPPYba,  
// I8[    ""   88   a8"     "8a 88P'   `"8a a8P_____88 88P'   "Y8  
//  `"Y8ba,    88   8b       d8 88       88 8PP""""""" 88          
// aa    ]8I   88,  "8a,   ,a8" 88       88 "8b,   ,aa 88          
// `"YbbdP"'   "Y888 `"YbbdP"'  88       88  `"Ybbd8"' 88  

// ++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ 
// ++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ 

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n" // never forget to comment out
#define endl '\n'
#define RAGE ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

const ll inf = 1e18 + 42;

const ll MAX = 1e9;

void solve()
{
	ll n;
	cin >> n;
	multiset<ll> a;
	for(ll i = 0; i < n - 1; i++)
	{
		ll x; cin >> x;
		a.insert(x);
	}
	for(ll i = 1; i <= n; i++)
	{
		cout << a.count(i) << endl;
	}

}	

int main()
{
	RAGE
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	ll t;
	//cin >> t;
	//while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 12996
n = int(input());
if n==1:
	print(n)
	exit(0)
point = [[0]*2 for i in range(n) ];
for i in range(n) :
	s = input().split(" ");
	point[i][0] = int(s[0]);
	point[i][1] = int(s[1]);

dict = {}
for i in range(n) :
	for j in range(n) :
		if i != j  :
			x = point[i][0] - point[j][0];
			y = point[i][1] - point[j][1];
			if (x,y) in dict:
				dict[(x,y)] += 1
			else:
				dict[(x,y)] = 1
print(n-max(dict.values()));

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    V<> a(n);
    cin >> a;
    sort(all(a));
    ll sum = accumulate(all(a), 0);
    int ans = n + (x - sum) / a[0];
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 100 * 1000 + 9;
const string FILENAME = "sample";

int n;
pair<pair<string, int>, int> a[maxN];

void read(){
	cin >> n;
	for(int i = 0; i < n; i++){
		string s; int p;
		cin >> s >> p;
		a[i] = make_pair(make_pair(s, -p), i);
	}
}

void solv(){
	sort(a, a + n);
	for(int i = 0; i < n; i++){
		cout << a[i].second + 1 << '\n';
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

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


int main(){
  int H,W,K,ans=0,tot=0;
  cin >> H >> W >> K;
  vector<vector<char>> c(H,vector<char>(W));
  vector <int> gyou(H,0);
  vector <int> retu(W,0);
  
  rep(i,H){
    rep(j,W){
      cin >> c.at(i).at(j);
      if(c.at(i).at(j)=='#'){
        gyou.at(i)++;
        retu.at(j)++;
        tot++;
      }
    }
  }
  
  if(tot<K){
    cout << 0 << endl;
    return 0;
  }

  for (int tmp = 0; tmp < (1 << H); tmp++) {
    
    bitset<6> s(tmp);
    for (int tmp2 = 0; tmp2 < (1 << W); tmp2++) {
       int sum=0,tot2=tot;
      vector <int> co;
      vector <int> co2;
    bitset<6> t(tmp2);
    
    rep(i,H){
      if(s.test(i)){
        sum+=gyou.at(i);
        co.push_back(i);
      } 
      }
      
      rep(i,W){
        if(t.test(i)){
          sum+=retu.at(i);
          co2.push_back(i);
        }
      }
      
      rep(i,co.size()){
        rep(j,co2.size()){
          if(c.at(co.at(i)).at(co2.at(j))=='#')
            sum--;
        }
      }
      
      
      //sum-=(co*co2);
      tot2-=sum;
      //cout << sum << endl;
      if(tot2==K){
        //cout << tmp << tmp2 << endl;
        ans++;
      }
      
  }
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int cnt;
void insertionSort(int *A,int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
void shellSort(int *A,int n){
  cnt=0;
  int r=1;
  vector<int> G;
  while(r<=n){
    G.push_back(r);
    r*=2;
  }
  int m=G.size();
  reverse(G.begin(),G.end());
  cout<<m<<endl;
  for(int i=0;i<m;i++) cout<<G[i]<<" \n"[i==m-1];
  for(int i=0;i<m;i++) insertionSort(A,n,G[i]);
  cout<<cnt<<endl;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  shellSort(A,n);
  for(int k=0;k<n;k++) cout<<A[k]<<endl;
  return 0;
}



Measured memory_bytes: 7016
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;
    cin>>h>>i>>j>>k>>l>>m>>n>>o>>p>>q>>r>>s>>t>>u;
    a=h-i;
    b=j-k;
    c=l-m;
    d=n-o;
    e=p-q;
    f=r-s;
    g=t-u;
    cout<<a<<endl;
    cout<<b<<endl;
    cout<<c<<endl;
    cout<<d<<endl;
    cout<<e<<endl;
    cout<<f<<endl;
    cout<<g<<endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,a,b,kizi,karo[103];
	
	cin>>n>>a>>b>>kizi;
	for(int i=0;i<n;i++)cin>>karo[i];
	sort(karo,karo+n);
	reverse(karo,karo+n);
	int kizinomi=kizi/a;
	int kizitoone=(kizi+karo[0])/a+b;
	int nowans=kizitoone;
	int maeans=kizinomi;
	int anskaro=kizi,ansdor=a;
	//for(int i=0;i<n;i++)cout<<karo[i]<<endl;
		int cnt=0;
	vector<int>anss;
	anss.push_back(kizinomi);
	for(int i=0;i<n;i++){
		anskaro+=karo[i];
		ansdor+=b;
		anss.push_back(anskaro/ansdor);
	}
	sort(anss.begin(),anss.end());
	cout<<anss[anss.size()-1]<<endl;
	//cout<<max(nowans,ans)<<endl;
	return 0;
}

Measured memory_bytes: 1224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            out.println((long) (k * Math.pow(k - 1, n - 1)));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import itertools
n, m, q = map(int, input().strip().split())
L = [list(map(int, input().split())) for _ in range(q)]
ans=0
for possibleA in itertools.combinations_with_replacement(range(1,m+1),n):
    di_total=0
    for a,b,c,d in L:
        if possibleA[b-1]-possibleA[a-1]==c:
            di_total+=d
    ans=max(ans,di_total)
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c') cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define translow transform(s.begin(),s.end(),s.begin(),::tolower);
#define transup transform(s.begin(),s.end(),s.begin(),::toupper);
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

 

    
int main() {
				fast
                // #ifndef ONLINE_JUDGE
                // freopen("input.txt","r",stdin);
                // freopen("output.txt","w",stdout);
                // #endif
               ll n;
               cin>>n;
               ll arr[n];
               map<ll,ll>id;
              for(ll i=0;i<n;i++)
               {
                cin>>arr[i];
                id[arr[i]]+=1;
               }
               ll ans=0;
               for(auto it:id)
               {
                ll x=it.second;
                ans+=(x*(x-1))/2;
               }
               for(ll i=0;i<n;i++)
               {
                ll x=id[arr[i]];
                ans-=(x*(x-1))/2;
                x-=1;
                ans+=(x*(x-1))/2;
                cout<<ans<<endl;
                ans-=(x*(x-1))/2;
                x+=1;

                
                ans+=(x*(x-1))/2;

               }

            
                return 0;
            }

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int h,w,k,sx,sy;
    vector<vector<char>> b;
    vector<vector<int>> dist;
    Problem(LL h, LL w):h(h),w(w),b(h,vector<char>(w)), dist (h,vector<int>(w,-1)){};
    void solve(){
        cin >> k;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> b[i][j];
                if(b[i][j]=='S'){
                    sx=i,sy=j;
                }
            }
        }
        int ans =INF;
        queue<pair<int,int>> Q;
        Q.push({sx,sy});
        dist[sx][sy]=0;
        int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
        while(!Q.empty()){
            int x=Q.front().first;
            int y= Q.front().second;
            Q.pop();
            int st=min({x,y,h-x-1,w-y-1});
            int step;
            if(dist[x][y]<=k){
                step=(st+k-1)/k+1;
            }else{
                step=(dist[x][y]+st+k-1)/k;
            }
            DBG(x,y,st,step)
            ans=min(ans,step);
            for(int i=0; i<4; ++i){
                if(x+dx[i]>=0 and x+dx[i]<h and y+dy[i]>=0 and y+dy[i]<w and b[x+dx[i]][y+dy[i]]=='.' and dist[x+dx[i]][y+dy[i]]<0){
                    dist[x+dx[i]][y+dy[i]]=dist[x][y]+1;
                    DBG(x+dx[i],y+dy[i],dist[x+dx[i]][y+dy[i]])
                    Q.push({x+dx[i],y+dy[i]});
                }
            }
        }
        cout << ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long h=0,w;
    cin >> h >>w;
    Problem p(h,w);
    p.solve();
    return 0;
}



Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main() {
	long long int N = 0, ans = 0, a = 0;
	long long int A[100001] = { 0 };
	long long int B[100000] = { 0 };
	cin >> N;
	for (int i = 0; i < N+1; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		a = A[i];
		if (A[i]-B[i] < 0) {
			ans += A[i];
			A[i] = 0;
			if (A[i + 1]-(B[i]-a) < 0) {
				ans += A[i + 1];
				A[i + 1] = 0;
			}
			else {
				A[i + 1] -= B[i] - a;
				ans += B[i] - a;
			}
		}
		else if (A[i]-B[i] >= 0) {
			A[i] -= B[i];
			ans += B[i];
		}
	}
	/*for (int i = 0; i < N + 1; i++) {
		cout << A[i] << endl;
	}*/
	cout << ans;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cout << #x << ": " << x << endl
#define ALL(x) (x).begin(),(x).end()
 
const int INF = 1e9;
const ll LINF = 1e16;
 
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    while (1) {
        double x, y, s;
        cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) break;
 
        int ret = -1;
 
        for (double a = 1; a < 1000; a += 1) {
            for (double b = a; b < 1000; b += 1) {
                int suma = a + a*x / 100;
                int sumb = b + b*x / 100;
                if (suma + sumb == s) {
                    int ssuma = a + a*y / 100;
                    int ssumb = b + b*y / 100;
                    ret = max(ret, ssuma + ssumb);
                }
            }
        }
        cout << ret << endl;
    }
 
  return 0;
}

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

int main(){
    int X, Y;
    cin >> X >> Y;
    if (Y < 2 * X or Y > 4 * X) {
        cout << "No";
    }
    else if (Y % 2 != 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
} 

Measured memory_bytes: 3584
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
if(len(X)):
  ans=max(ans,Y[min(K-1,len(X)-1)]+1)
  ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Measured memory_bytes: 7200
#include <stdio.h>

enum STATUS {NOTFIN, FIN};

int main(){
  int n, y;
  enum STATUS s = NOTFIN;
  int result[3], p0, p1, p2;
  scanf("%d %d", &n, &y);
  if(n < 1 || 2000 < n || y < 1000 || 20000000 < y || (y%1000))
    return 1;

  for(p0 = 0; p0 <= n + 1; p0++){
    if(s == NOTFIN){
      for(p1 = 0; p1 <= n - p0; p1++){
        if(s == NOTFIN){
          p2 = n - p1 - p0;
            if(s == NOTFIN){
              if((p0 * 10000 + p1 * 5000 + p2 * 1000) == y){
                result[0] = p0;
                result[1] = p1;
                result[2] = p2;
                s = FIN;
              }
            }
        }
      }
    }
  }

  if(s == FIN)
    printf("%d %d %d\n", result[0], result[1], result[2]);
  else
    printf("%d %d %d\n", -1, -1, -1);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string sa,sb,sc;
cin>>sa>>sb>>sc;
ll a=1;
for(ll i=1; i>0; i++){
if(a==1){
if(sa.size()==0){
cout<<'A'<<endl;
break;}
if(sa.at(0)=='a'){
a=1;}
else if(sa.at(0)=='b'){
a=2;}
else
a=3;
sa=sa.substr(1,sa.size()-1);}
if(a==2){
if(sb.size()==0){
cout<<'B'<<endl;
break;}
if(sb.at(0)=='a'){
a=1;}
else if(sb.at(0)=='b'){
a=2;}
else
a=3;
sb=sb.substr(1,sb.size()-1);}
if(a==3){
if(sc.size()==0){
cout<<'C'<<endl;
break;}
if(sc.at(0)=='a'){
a=1;}
else if(sc.at(0)=='b'){
a=2;}
else
a=3;
sc=sc.substr(1,sc.size()-1);}}}



Measured memory_bytes: 3588
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

long long x;

long long f(long long n) {
  long long sum = 0;
  if (n != -1) sum = n / x + 1;
  else sum = 0;
  return sum;
}

int main() {
  long long a, b, ans;

  cin >> a >> b >> x;

  ans = f(b) - f(a - 1);

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n,a,b,c,d;
  cin >> n;
  
  d = n%10;
  n /= 10;
  c = n%10;
  n /= 10;
  b = n%10;
  a = n/10;
  
  if ((a == b && b== c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io;


fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line
}

fn main() {
    let line = get_line();
    let s: i32 = line.trim().parse().unwrap();
    let m = (s / 60) % 60;
    let h = s / (60 * 60);
    let s = s % 60;
    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
import collections
import sys
readline = sys.stdin.readline

n = int(input())
d = collections.Counter([int(x) for x in readline().rstrip().split()])
m = int(input())
t = collections.Counter([int(x) for x in readline().rstrip().split()])
for i in t.items():
    if i[1] > d[i[0]]:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 55256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    string s;
    cin >> s;
    if(find(s.begin(),s.end(),'7') != s.end())cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 3596
#include <cstdio>
#include<cstring>
#include <iostream>
#include <set>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn];
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>a[i-1]) sum+=a[i]-a[i-1];
		else sum+=a[i-1]-a[i];
	}
	a[n+1]=0;
	sum+=abs(a[n+1]-a[n]);
//	printf("sum=%d\n",sum);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=a[i-1]&&a[i]<=a[i+1]||a[i]<=a[i-1]&&a[i]>=a[i+1]) printf("%d\n",sum);
		else
		{
			int l1=abs(a[i]-a[i-1]);
			int l2=abs(a[i+1]-a[i]);
			int minn=min(l1,l2);
			printf("%d\n",sum-2*minn);
		}
	}
} 

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

vector<vector<lli>> v;

lli in[100100];
lli data[100100];
lli depth[100100];

signed main(){

	lli n,m;
	cin>>n>>m;

	v.resize(n);

	REP(i,0,n+m-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		in[b]++;
	}

	lli root;
	REP(i,0,n){
		if(in[i]==0){
			root = i;
			break;
		}
	}
	REP(i,0,100100)data[i]=INF;

	data[root]=0;
	queue<lli> q;
	q.push(root);

	while(q.size()){
		lli top = q.front();
		q.pop();

		for(auto e:v[top]){
			in[e]--;
			if(in[e]!=0)continue;
			data[e] = top+1;
			q.push(e);
		}
	}

	REP(i,0,n){
		cout<<data[i]<<endl;
	}

	return 0;
}

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

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

    int ret = 0;
    for(char n : N) {
        ret += ((int)n) - 48;
    }

    cout << ((ret % 9 == 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3688