akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAX = 1e5 + 5;
vector<int> G[MAX];
bool vis[MAX];
void dfs(int s, int cnt, int &mndis) {
    //cout << s << " " << cnt << endl;
    if (s == 1) {
        mndis = min(cnt, mndis);
    }
    vis[s] = 1;
    for (auto u : G[s]) {
        if (!vis[u]) dfs(u, cnt + 1, mndis);
    }
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s;
    cin >> s;
    int mx = 0;
    for (int i = 1; i <= sz(s) / 2; i++) {
        int cnt = 0;
        for (int j = 0; j < sz(s) - i; j += 2 * i) {
            string s1, s2;
            s1 = s.substr(j, i);
            s2 = s.substr(j + i, i);
            if (s1 == s2 && (2 * i < sz(s))) {
                mx = max(mx, 2 * i);
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
 
const int MAXN = 1E5 + 10;
 
int n, m, Q;
int a[MAXN];
int b[MAXN], id[MAXN];
bool vis[MAXN];
int cnt[MAXN];
 
int main(){
	scanf("%d%d", &n, &m);
	scanf("%d", &Q);
	for (int i = 1; i <= Q; ++i)
		scanf("%d", &a[i]);
	for (int k = 0, j = Q; j > 0; --j)
		if (!vis[a[j]])
			b[++k] = a[j], vis[a[j]] = true;
	for (int j = m, i = m; i > 0; --i)
		if (!vis[i])
			b[j--] = i;
	for (int i = 1; i <= m; ++i)
		id[b[i]] = i;
 
	bool flag = true;
	cnt[0] = n;
	for(int i=1;i<=m;++i) vis[i]=0;
	for (int i = Q; i > 0; --i){
		int t = id[a[i]];
		if (cnt[t - 1] > 0){
			--cnt[t - 1];
			++cnt[t];
			vis[t] = true;
		}
		else if (!vis[t]){
			flag = false;
			break;
		}
	}
 
	int l;
	for (l = 0; cnt[l] == 0; ++l);
	for (int i = l + 1; i < m; ++i)
		flag &= b[i] < b[i + 1];
	puts(flag ? "Yes" : "No");
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
 {
	int n;
	cin>>n;
	int ans=0;
	for(int  i=1;i<=n;i+=2)
	{
	    int count=0;
	    for(int j=1;j*j<=i;j++)
	    {
	        if(i%j==0)count+=2;
	        if(j*j==i)count--;
	    }
	    if(count==8)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){

    int a, b, c, n;

    cin >> a >> b;

    map<int , int> m;
    m[0] = 0;
    for(int i=1; i<=999; i++){
        m[i] = m[i-1] + i;
    }

    cout << m[b-a] - b << endl;

    return 0;
}

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

using namespace std;

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

  s.erase(s.size()-1) ;
  while (1)
  {
      if(s.substr(0,s.size()/2)==s.substr(s.size()/2)) break ;
      /*cout << s.substr(0,s.size()/2) <<endl ;
      cout << s.substr(s.size()/2) <<endl ;
      cout << s <<endl ;
      */
      s.erase(s.size()-1) ;
  }
  
  cout << s.size() << endl ;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
using namespace std;

const string S[]{"Mts", "Fks", "Nyt", "Asg", "Ggs", "Gok", "Sai", "Sei", "Kan", "Ko", "Jou", "Jo", "Gai", "Kei", "Cho", "Oku", "Man", ""};

void debug(const vector<int> &v) {
  for (int i = 17; i >= 0; --i) {
    if (v[i] == 0) continue;
    cerr << v[i] << S[17 - i];
  }
  cerr << endl;
}

int main() {
  int m, n;

  while (cin >> m >> n, m || n) {
    vector<int> v(20, 0), t(20, 0);
    v[0] = m;
    for (int i = 0; i < n - 1; ++i) {
      for (int j = 0; j < 18; ++j) {
        t[j] += v[j] * m;
        t[j + 1] += t[j] / 10000;
        t[j] %= 10000;
      }
      swap(v, t);
      fill(begin(t), end(t), 0);
      // debug(v);
    }
    for (int i = 17; i >= 0; --i) {
      if (v[i] == 0) continue;
      cout << v[i] << S[17 - i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3140
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 10000000;

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

  int x;
  cin >> x;
  int fh = x / 500;
  int f = (x % 500) / 5;
  cout << fh * 1000 + f * 5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
typedef pair<int,int> pii;
typedef long long ll;
int c[10][10];
int dist[10][10];
void fw(){
	for(int k=0;k<=9;k++){
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w;
	cin>>h>>w;
	int x;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			cin>>c[i][j];
		}
	}
	ll res=0;
	fw();
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>x;
			if(x!=-1) res+=c[x][1];
		}
	}
	cout<<res<<endl;
	return 0;
}
    
    
    
    
    

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class ITP1
{
    static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        Q2_D();

        //int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
    }

    static void Q1()
    {
        int input = int.Parse(Console.ReadLine());

        int h = input / 3600;
        int m = input % 3600 / 60;
        int s = input % 3600 % 60;

        Console.WriteLine(String.Format("{0}:{1}:{2}", h, m, s));
    }

    static void Q2_A()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        String sign = a[0] - a[1] > 0 ? ">" : a[0] - a[1] == 0 ? "==" : "<";

        Console.WriteLine(String.Format("a {0} b",sign));
    }

    static void Q2_B()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
        String answer = a[2] - a[1] > 0 ? a[1] - a[0] > 0 ? "Yes" : "No" : "No";

        Console.WriteLine(answer);
    }

    static void Q2_C()
    {
        List<int> a = new List<int>(Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s))));
        a.Sort();

        Console.WriteLine(String.Format("{0} {1} {2}",a[0],a[1],a[2])); 
    }

    static void Q2_D()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        int chk = 0;

        //x-max
        if (a[0] - a[2] - a[4] >= 0) chk++;
        //x-min
        if (a[2] - a[4] >= 0) chk++;
        //y-max
        if (a[1] - a[3] - a[4] >= 0) chk++;
        //y-min
        if (a[3] - a[4] >= 0) chk++;

        String answer = chk == 4 ? "Yes" : "No";
        Console.WriteLine(answer);
        
    }
}

Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S;
  cin >> S;
  vector<int> ym(4);

  for(int i = 0; i < 4; i++){
    ym.at(i) = S / (1000/(pow(10.0, i)));
    S -= (ym.at(i) * (1000/(pow(10.0, i))));
  }
  int front, back;

  front = ym.at(0) * 10 + ym.at(1);
  back = ym.at(2) * 10 + ym.at(3);

  if(front == 0 || front > 12){
    if(back == 0 || back > 13){
      cout << "NA" << endl;
    }else{
      cout << "YYMM" << endl;
    }
  }else{
    if(back == 0 || back > 13){
      cout << "MMYY" << endl;
    }else{
      cout << "AMBIGUOUS" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
ll facto(ll a)
{
	return (a * a * a * a * a);
}

int main()
{
	ll x;
	cin >>  x;
	ll a,b;
	a = 0;
	while (a < 1000)
	{
		b = -1 * a;
		while (b < a)
		{
			if (facto(a) - facto(b) == x)
			{
				cout << a << " " << b << endl; return 0;
			}
			b++;
		}
		a++;
	}
	return 0;
}


Measured memory_bytes: 3636
#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>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int N, M, K;
int ans;
string s;
int A[100000];
int main() {
	cin >> N >> K;
	bool flg = 0;
	if (N % (K - 1) >= 2) {
		flg = 1;
	}
	if (K == 2) {
		cout << N - 1 << endl;
		cin >> N;
		return 0;
	}
	cout << N / (K - 1)+flg;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	if (n == 1) {
		cout << "Hello World";
	}
	else {
		int a, b;  cin >> a >> b;
		cout << a + b;
	}
	end_routine;
}


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

int main(){
  int n,a[110],minn,maxx;
  cin >> n;
  minn=1000000000;
  maxx=-1000000000;
  for(int i = 0; i < n;i++){
    cin >> a[i];
    minn = min(minn,a[i]);
    maxx = max(maxx,a[i]);
  }
  
  cout << maxx - minn << endl;
 return 0; 
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	REP(i, X)cin >> A[i];
	REP(i, Y)cin >> B[i];
	REP(i, Z)cin >> C[i];

	vector<ll> ab(X*Y);
	vector<ll> upperab(K);
	REP(i, X*Y)ab[i] = A[i%X] + B[i / X];
	sort(ab.begin(), ab.end(), greater<ll>());
	REP(i, min((ll)ab.size(), K))upperab[i] = ab[i];

	vector<ll> abc(K*Z);
	REP(i, K*Z)abc[i] = upperab[i%K] + C[i / K];
	sort(abc.begin(), abc.end(), greater<ll>());

	REP(i, K)cout << abc[i] << endl;

	return 0;
}


Measured memory_bytes: 31616
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

an = list(map(int, input().split()))

s = sum(an)

cnt = 0
for a in an:
    if a >= s / (4 * m):
        cnt += 1

if cnt >= m:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int h,n;
    in>>h>>n;
    vector<int> a(n),b(n);
    fr(i,n) in>>a[i]>>b[i];
    vector<int> dp(h+1,1e9);
    dp[0]=0;
    fr(i,n){
        Fr(j,h){
            if(j<a[i]) dp[j]=min(dp[j],b[i]);
            else dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    cout<<dp[h]<<endl;
}

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


using namespace std;
int main()
{

	long long n, l;
	vector< string > v;
	string temp;
	cin >> n >> l;
	
	while (n--)
	{
		cin >> temp;
		v.push_back(temp);
	}

	sort(v.begin(), v.end());

	l = v.size();
	for (long i = 0;i < l;i++)
		cout << v[i];

	//system("pause");
	return 0;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

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

func main() {
	var x, a int
	fmt.Scan(&x, &a)
	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  
const ll MOD = 1e9 + 7;

ll power(ll x, ll y) {
    x %= MOD;
    ll res = 1;
    while (y) {
        if (y & 1) res = (res * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    ll a = power(10, n);
    ll b = power(9, n); b *= 2;
    ll c = power(8, n);
    cout << (((a % MOD) - (b % MOD) + (c % MOD)) + MOD ) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(void)
{
 int i,n=0,m=0,j;
 char s[100000];
 scanf("%s",s);
 i=0;
 while(s[i]=='0' || s[i]=='1') {
    if(s[i]==s[i+1]){
       if     (s[i+1]=='1') s[i+1]='0';
       else if(s[i+1]=='0') s[i+1]='1';
       n=n+1;
    }
    i=i+1;
 }
 j=i;
 while(s[j]=='0' || s[j]=='1') {
    if(s[j]==s[j-1]){
       if     (s[j-1]=='1') s[j-1]='0';
       else if(s[j-1]=='0') s[j-1]='1';
       m=m+1;
    }
    j=j+1;
 }
 if(m<=n) printf("%d\n",n);
 else     printf("%d\n",m);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    ll res=0;
    rep(i,n){
        ll a;cin>>a;
        res+=a-1;
    }
    cout<<res<<endl;
}

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

int main(){
    int n;
    string str;
    cin>>n;
    //cin.ignore();
    cin>>str;

    if(n%2 != 0){
        cout<<"No\n"<<endl;
        return 0;
    }
    int len = n /2;
    for(int i=0;i<len;i++){
        if(str[i]!= str[len+i]){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

	int a = stoi(s.substr(0, 2));
	int b = stoi(s.substr(2, 2));

	if (a > 12 || a < 1) {
		if (b < 13 && b > 0) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	else {
		if (b < 13 && b > 0) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int d;cin>>d;string s;
  if(d==25)s="Christmas";
  if(d==24)s="Christmas Eve";
  if(d==23)s="Christmas Eve Eve";
  if(d==22)s="Christmas Eve Eve Eve";
  cout << s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const ll spn1 = 132694967;
const ll spn2[2] = {61438739, 53287643};

int main() {
    int n; cin >> n;
    string s; cin >> s;
    ll a[n];
    rep(i,n)a[i] = (int)s[i];

    int l = 0;
    int r = n;

    while(l < r){
        int m = (l + r) / 2 + 1;
        ll hash_s[n][2];
        ll spn2_m[2] = {1,1};
        rep(i,m - 1){
            rep(j,2){
                spn2_m[j] = spn2_m[j] * spn2[j] % spn1;
            }
        }
        srep(i,1,n+1){ // ローリングハッシュ
            rep(j,2){
                if(i == 1){
                    hash_s[n- i][j] = a[n-i];
                }else if(i <= m){
                    hash_s[n-i][j] = hash_s[n - i + 1][j] * spn2[j] % spn1 + a[n-i];
                }else{
                    hash_s[n-i][j] = (hash_s[n - i + 1][j] - (a[n - i + m] * spn2_m[j]) % spn1 + spn1) * spn2[j] % spn1 + a[n-i];
                }   
            }
        }

        /*
        cout << m << " : ";
        rep(i,n){
            cout << hash_s[i] << ' ';
        }
        cout << endl;
        */

        set<ll> se[2];
        int flag = 0;
        srep(i,1,n+1){
            if(n - i - m + 1 < 0)break;
            int flag2 = 0;
            rep(j,2){
                auto ite = se[j].find(hash_s[n-i-m+1][j]);
                if(ite != se[j].end()){
                    flag2++;
                }
                if(i >= m){
                    se[j].insert(hash_s[n - i][j]);
                }
            }
            if(flag2 == 2)flag = 1;
        }
        if(flag == 0){
            r = m - 1;
        }else{
            l = m;
        }
    }

    cout << r << endl;
    return 0;
}
 
 


Measured memory_bytes: 896
#include <stdio.h>
void insertion(int a,int b);

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",gcd(a,b));
}

int gcd(int a,int b){
    int r;
    while((r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}



Measured memory_bytes: 2108
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        String s = sc.next(); int n = s.length();
        int [] a = new int [n];
        for (int i = 0; i < n; i++) a[n - 1 - i] = s.charAt(i) - '0';
        int ans = 0; boolean carry = false;
        for (int i = 0; i < n; i++) {
            int look = a[i]; boolean special = false;
            if (carry) {
                look = (look + 1) % 10;
                if (look == 0) special = true;
            }
            if (look <= 4) {
                ans += look;
                carry = false;
                if (special) carry = true;
            } else if (look >= 6) {
                ans += (10 - look);
                carry = true;
            } else {
                ans += 5;
                if (i == n - 1 || a[i + 1] <= 4) carry = false;
                else carry = true;
            }
        }
        if (carry) ans += 1;
        out.println(ans);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int x, y;
    cin >> x >> y;

    int mi = x * 2;
    int ma = x * 4;
    int ans = ma - mi;
    if (mi <= y && y <= ma && y % 2 == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    is_keyence = False
    if S[:7] == "keyence":
        is_keyence = True
    elif S[-7:] == "keyence":
        is_keyence = True
    elif S[:1] == "k" and S[-6:] == "eyence":
        is_keyence = True
    elif S[:2] == "ke" and S[-5:] == "yence":
        is_keyence = True
    elif S[:3] == "key" and S[-4:] == "ence":
        is_keyence = True
    elif S[:4] == "keye" and S[-3:] == "nce":
        is_keyence = True
    elif S[:5] == "keyen" and S[-2:] == "ce":
        is_keyence = True
    elif S[:6] == "keyenc" and S[-1:] == "e":
        is_keyence = True

    ans = "YES" if is_keyence else "NO"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    ll ans = 0;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n){
        //cout<<i<<" start "<<endl;
        if(a[i]>=b[i]){//モンスター多い
            //cout<<"pettern1"<<endl;
            ans+=b[i];
        }else{
            //cout<<"pettern2"<<endl;
            ans+=a[i];
            b[i]-=a[i];
            //cout<<ans<<endl;
            if(a[i+1]>=b[i]){
                //cout<<"pettern2-1"<<endl;
                ans+=b[i];
                a[i+1]-=b[i];
                //cout<<ans<<endl;
            }else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
        //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var H = nextInt();
	var M = nextInt();
	myout((N - H + 1) * (N - M + 1));
}


Measured memory_bytes: 21320
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n];
    string s,t,s1,s2;
    for(int i=1;i<=n;i++)
    {
        char c=i+'0';
        s=s+c;
        t=t+c;
    }
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        char c=a[i]+'0';
        s1=s1+c;
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        char c=b[i]+'0';
        s2=s2+c;
    }
    ll cnta=0,cntb=0;
    while(s.compare(s1)!=0)
    {
        next_permutation(s.begin(),s.end());
        cnta++;
    }
    
    while(t.compare(s2)!=0)
    {
        next_permutation(t.begin(),t.end());
        cntb++;
    }
    cout<<abs(cnta-cntb);
    return 0;
}







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

int main()
{
	int a,b;
	cin >> a >> b;
	bool flag = false;
	if (a%3 == 0 || b%3==0 || (a+b)%3==0) flag = true;
	if (flag) cout << "Possible";
	else cout << "Impossible";


	return 0;
}

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

int main() {
   string N;
   cin >> N;
   if (N.at(0)=='7' || N.at(1)=='7' || N.at(2)=='7') {
       cout << "Yes\n";
   } 
   else cout << "No\n";
}

Measured memory_bytes: 3624
# dwacon5th-prelimsA - Thumbnail
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    avg = sum(A) / N
    D = {(abs(avg - a), i) for i, a in enumerate(A)}
    print(min(D)[1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(final String... args) {
        final String mode = "b";

        if (mode.equals("a")) {
            A.solve();
        } else if (mode.equals("b")) {
            B.solve();
        }
    }
}

class B {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int d = sc.nextInt();
        final int res = calc(n, d);
        System.out.println(res);
    }
    static int calc(final int n, final int d) {
        final int max = (2 * d + 1);
        int res = n / max;
        if (n % max != 0) {
            res += 1;
        }
        return res;
    }
}

class A {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int r = sc.nextInt();
        final int res = calc(r);
        System.out.println(res);
    }

    static int calc(final int r) {
        return 3 * r * r;
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d;
  	cin>>a>>b;
  	c=min(a,b);
  	d=max(a,b);
  	if((d-c-1)%2==1){
    cout<<((d-c-1)/2)+c+1<<endl;
    }
  	else{
    cout<<"IMPOSSIBLE"<<endl;
    }
  	
}

Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
base_ans = 0
for i in c.values():
    base_ans += (i)*(i-1)//2
for a in A:
    i = c[a]
    diff_ans = max(0, i-1)
    print(base_ans - diff_ans)


Measured memory_bytes: 102820
#include <iostream>
#include <vector>

#define ws __ws
using namespace std;

const int MAX_N = 1 << 18;
const int MAX_Q = 1e5 + 5;
const int MAX_L = 1e5 + 5;
const int MAX_LG = 20;
const int HALF = 9;

int dp [MAX_LG][MAX_L]; // dp[l][w] is max value you can get with <= w weight at layer l

void add (int val, int weight, int layer) {
  for (int i = 0; i < MAX_L; i++) {
    if (i - weight >= 0) {
      dp[layer][i] = max(dp[layer - 1][i], dp[layer - 1][i - weight] + val);
    } else {
      dp[layer][i] = dp[layer - 1][i];
    }
  }
}

vector<pair<int, int>> qs [MAX_N]; // <id, L>
int ans [MAX_Q];

int vs [MAX_N];
int ws [MAX_N];

int n;

vector<pair<int, int>> stk;

int lgs [MAX_N];
pair<int, int> memo [MAX_N];
int solve (int d, int L) {
  if (d <= HALF) {
    return dp[d][L];
  }

  int stks = (int) stk.size();
  int sol = 0;
  for (int mask = 0; mask < 1 << stks; mask++) {
    pair<int, int> cur;
    if (mask == 0) {
      cur = make_pair(0, 0);
    } else {
      int lsb = mask & -mask;
      cur = memo[mask - lsb];
      cur.first += stk[lgs[lsb]].first;
      cur.second += stk[lgs[lsb]].second;
    }
    memo[mask] = cur;

    if (cur.second <= L) {
      sol = max(sol, cur.first + dp[HALF][L - cur.second]);
    }
  }
  return sol;
}

void dfs (int u, int d) {
  if (d <= HALF) {
    add(vs[u], ws[u], d);
  } else {
    stk.push_back(make_pair(vs[u], ws[u]));
  }
  
  for (auto pr : qs[u]) {
    ans[pr.first] = solve(d, pr.second);
  }
  
  if (2 * u <= n) dfs(2 * u, d + 1);
  if (2 * u + 1 <= n) dfs(2 * u + 1, d + 1);

  if (d > HALF) {
    stk.pop_back();
  }
}

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

  for (int i = 0; (1 << i) < MAX_N; i++) {
    lgs[1 << i] = i;
  }

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int v, L;
    cin >> v >> L;
    qs[v].push_back(make_pair(i, L));
  }

  dfs(1, 1);

  for (int i = 0; i < q; i++) {
    cout << ans[i] << '\n';
  }
}


Measured memory_bytes: 18936
N, K= gets.split.map(&:to_i)

def judge(n, k)
  if k == 1
    puts 0
    exit
  end

  if n == 0
    puts 0
    exit
  end

  if n == k
    puts 0
    exit
  end

  t = n % k
  puts t < k - t ? t : k - t
end

judge(N, K)


Measured memory_bytes: 1788
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll h,w;cin>>h>>w;
    vector<string> a(h);
    rep(i,h)cin>>a[i];

    ll ans=0;
    vvl d(h,vl(w,INF));
    queue<pl> q;
    rep(i,h)rep(j,w){
        if(a[i][j]=='#'){
            q.emplace(i,j);
            d[i][j]=0;
        }
    }

    while(q.size()){
        pl p=q.front();q.pop();
        rep(i,4){
            ll ty=p.first+D4[i],tx=p.second+D4[i+1];
            if(ty<0||ty>=h||tx<0||tx>=w||d[ty][tx]!=INF)continue;
            d[ty][tx]=d[p.first][p.second]+1;
            chmax(ans,d[ty][tx]);
            q.emplace(ty,tx);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 25524
import sys

fin = sys.stdin.readline
n = int(fin())
ab = [tuple(map(int, fin().split())) for i in range(n)]

ab = sorted(ab, key=lambda x: x[1])

cum = []
for i in range(n):
    if cum:
        cum.append(cum[-1] + ab[i][0])
    else:
        cum = [ab[i][0]]

for i in range(n):
    if cum[i] > ab[i][1]:
        print("No")
        break
else:
    print("Yes")



Measured memory_bytes: 91356
from itertools import permutations

def warshall_floyd():
    '''
    すべての頂点間の最短距離を求める (重み付き有向グラフ)
    '''
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    return dist


n, m, r = map(int, input().split())
city = list(map(int, input().split()))

dist = [[float('inf')] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
for i in range(n):
    dist[i][i] = 0

warshall_floyd()

res = float('inf')
for l in permutations(range(r), r):
    d = 0
    for i in range(r-1):
        d += dist[city[l[i]]-1][city[l[i+1]]-1]
    res = min(res, d)

print(res)

Measured memory_bytes: 74636
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
l = []
for _ in range(n):
    l.append(iil())

l.sort(key=lambda x:x[1])

time = 0

for item in l:
    time += item[0]
    if time <= item[1]:
        continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 53692
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

void dfs(int now, VI &f, VVI e){
    f[now] = 1;
    REP(i,e[now].size()){
        int next = e[now][i];
        if (!f[next]) dfs(next, f, e);
    }
}

int main() {
    int n;
    while (cin >> n && n){
        VVI e(n);
        VI in(n), f(n);
        vector<double> p(n);
        REP(i,n){
            int m;
            cin >> p[i] >> m;
            while (m--){
                int x;
                cin >> x;
                x--;
                e[i].push_back(x);
                in[x] = 1;
            }
        }
        double ans = 1.0;
        REP(i,n){
            if (!in[i]){
                ans *= (1.0-p[i]);
                dfs(i,f,e);
            }
        }
        int r = 0;
        REP(i,n) r += f[i];
        double res = 1.0;
        REP(i,n){
            if (f[i] || e[i].size() == 0) continue;
            res *= p[i];
        }
        if (r < n) ans *= (1.0-res);
        printf("%.10f\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3476
#include<stdio.h>
#include<string.h>
main(){
  char yui[100]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  /* CHAR YUI1[100]="abcdef*/

  char s[10000];
  int a,i;
  
  fgets(s,sizeof(s),stdin);
  
  a=strlen(s);

  for(i=0;i<a;i++){
    if(97<=s[i] && 122>=s[i]){
      s[i]-=32;
    }
  }

 
  printf("%s",s);


  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

const int Size = 1e5 + 5;
long long dp[105][Size];
int main() {
	int n, w;
	scanf("%d %d", &n, &w);
	vector<int> v(n + 1), cost(n + 1);
	for(int i = 1; i <= n; ++i) {
		scanf("%d %d", &v[i], &cost[i]);
	}
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= w; ++j) {
			if(j < v[i]) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j], cost[i] + dp[i - 1][j - v[i]]);
			}
		}
	}
	printf("%lld", dp[n][w]);
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll h,w,n;
    cin >> h >> w >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }

    vector<ll> c;
    for (ll i = 0; i < n; i++){
        while (a[i] != 0){
            c.push_back(i+1);
            a[i]--;
        }
    }
    
    for (ll i = 0; i < h; i++){
        if (i%2 == 0){
            for (ll j = 0; j < w; j++){
                cout << c[i*w + j] << " ";
            }
            cout << endl;
        }
        else{
            for (ll j = w-1; j >= 0; j--){
                cout << c[i*w + j] << " ";
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 3744
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int top,S[1000];
 
void push(int x){
  top++;
  S[top]=x;
}
int pop(){
  top--;
  return S[top+1];
}
int main(){
  int a,b;
  top=0;
  char s[100];
  while((scanf("%s",s))!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
      //printf("%d",atoi(s));
    }
    }
  printf("%d\n",pop());
   
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 string s;
 cin >> s;
 for(int i=0;i<s.size();i++){
    if(i%2==0){
       if(s[i]=='L'){
          cout << "No" << endl;
          return 0;
       }
    }else{
       if(s[i]=='R'){
          cout << "No" << endl;
          return 0;
       }
    }
    }
 cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#define rep(n) for(int i=1;i<=n;i++)
#define mx 100010
int set[mx],n,m,x,y,p[mx],g[mx],cnt;
int mod(int d,int v=-1){
	int &res=set[d],root;
	if(res!=d) res=g[p[d]]=mod(set[d],v);
	else if(v>0){
		root=mod(v);
		if(root>d) res=root;
		else set[root]=d,mod(v);
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(n){
		scanf("%d",&p[i]);
		set[i]=i;
		g[p[i]]=i;
	}
	rep(m){
		scanf("%d%d",&x,&y);
		mod(x,y);
	}
	rep(n) mod(i);
	//rep(n) printf("%d ",set[i]);
	rep(n) cnt+=g[i]==set[i];
	printf("%d\n",cnt);
}

Measured memory_bytes: 1280
#include <stdio.h>

int main() {
  int house[5][4][11] = {0};
  int b, f, r, v;
  int n;
  int i;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    house[b - 1][f - 1][r - 1] += v;
    }

  for (b = 0; b < 4; b++) {
    for (f = 0; f < 3; f++) {
      for (r = 0; r < 10; r++) {
        printf(" %d", house[b][f][r]);
      }
      putchar('\n');
    }
    if (b < 3)
      printf("####################\n");
  }

  return 0;
}



Measured memory_bytes: 2056
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
		long P = sc.nextLong();

		long ans = 1;
		long div = 2;
		while(div*div<=P) {
			if(P%div==0) {
				int cnt=0;
				while(P%div==0) {
					cnt++;
					P/=div;
				}
				for(int i=0; i<cnt/N; i++) 
					ans *= div;
			}
			div++;
		}
		if(N==1)
			ans *= P;
		
		System.out.println(ans);
		sc.close();
	}
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> x( M );
	vector<int> y( M );
	for( int i = 0; i < M; i++ ) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}

	vector<vector<int>> box( N, vector<int>( 2 ) );
	for( int i = 0; i < N; i++ ) {
		box[i][0] = 1;
	}
	box[0][1] = 1;
	for( int i = 0; i < M; i++ ) {
		int from = x[i];
		int to = y[i];
		if( box[from][1] ) box[to][1] = 1;
		box[to][0]++;
		box[from][0]--;
		if( box[from][0] == 0 ) box[from][1] = 0;
	}
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( box[i][1] ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<unordered_map>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

const ll MAX = 1e6;

long long fac[MAX], finv[MAX], inv[MAX];
 
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//binary_libraryを貼る

ll H(ll a, ll b){
  return COM( a + b - 1, b - 1);}

int main(){
  ll N,M; cin >> N >> M; COMinit();
    if( M == 1){ cout << 1 << endl; return 0;} //全て１しかない
 unordered_map<ll,ll> power;  power.clear();
    ll c = sqrt((double) M); ll k = M;
    for(ll j = 2; j <= c + 1; j++){ //Mの素因数分解
      while( k % j == 0){ k /= j; power[j]++;}}
    if( k != 1){ power[k]++;}
    
    ll ans = 1;
     for( auto p : power){
       if(p.second != 0){
        ans *= H(p.second,N); ans %= MOD;}
      } //map全探索を行う
    
    cout << ans << endl; return 0;}
      

Measured memory_bytes: 23680
n = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j = j - 1
    a[j + 1] = v
    print(*a)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
int main(void) {
	int n = 100000;
	Sieve sv(n);
	vi sum(n,0);
	rep(i,n){
		if(i==0) continue;
		sum[i] = sum[i-1];
		if(i%2) continue;		
		int x = i+1;
		if(sv.isPrime(x)&&sv.isPrime((x+1)/2))sum[i]++;
	}
	int q; cin >> q;
	vi ans(q);
	rep(i,q){
		int l,r; cin >> l >> r;
		l--; r--;
		ans[i] = sum[r]-sum[l-1];
	}
	rep(i,q) cout << ans[i] << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W;
char B[55][55];
char A[55][55];

void print() {
   line()
   rep (i, H) {
      rep (j, W) {
         cout << B[i][j];
      }
      puts("");
   }
   line()
   rep (i, H) {
      rep (j, W) {
         cout << A[i][j];
      }
      puts("");
   }
}

int main() {
   rep (i, 55) {
      rep (j, 55) {
         A[i][j] = '.';
      }
   }
   cin >> H >> W;
   rep (i, H) {
      cin >> B[i];
   }

   rep (i, H) {
      rep (j, W) {
         rep (k, 4) {
            int di = i + dy[k], dj = j + dx[k];
            if (B[i][j] == '#' && B[i][j] == B[di][dj]) {
               A[i][j] = A[di][dj] = '#';
            }
         }
      }
   }

   // print();
   rep (i, H) {
      rep (j, W) {
         if (A[i][j] != B[i][j]) {
            puts("No");
            return 0;
         }
         // if (B[i][j] == '#' && B[i][j] == A[i][j]) {

         // } else {
         //    puts("No");
         //    return 0;
         // }
      }
   }

   puts("Yes");

   return 0;
}

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

LL arr[100005];

int main()
{
    LL n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> arr[i];
    LL cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2&&arr[i]%2) cnt++;
    }
    cout << cnt;


	return 0;
}



Measured memory_bytes: 3628
/**
*    created: 21.06.2020 21:02:19
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));
    int sum = 0;
    rep(i,k) {
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3704