akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    string S;cin>>S;
    int k;cin>>k;
    vector<string> list;
    rep(i,5){
        for(int j=0;j<(int)S.length()-i;j++){
            list.push_back(S.substr(j,i+1));
        }
    }
    sort(ALL(list));
    list.erase(unique(ALL(list)),list.end());
    cout<<list[k-1]<<endl;
}

Measured memory_bytes: 4316
#include <stdio.h>
     
    int main(void)
    {
     int A, B;
     
     scanf("%d", &A);
     scanf("%d", &B);
     
     if ((A + B) >= 10) puts("error");
     else printf("%d\n", A + B);
     
     
     return 0;
     
    }

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var A = int.Parse(input[0]);
        var B = int.Parse(input[1]);

        if (A > 9 || B > 9)
        {
            Console.WriteLine(-1);
        }
        else
        {
            Console.WriteLine(A * B);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long N,L[300],ans,i;
	cin>>N;
	for(i=0;i<2*N;i++)
	{
		cin>>L[i];
		
	}
	ans=0;
	sort(L,L+(2*N));
	for(i=0;i<2*N;i++)
	{
		if(i%2==0)
		{
			ans+=L[i];
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i < N+1;i++ ){
        int a;
        cin >> a;
        if(i%2 == 1){
            if(a%2 == 1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, K = IL()
s = S()

score = 0
for i in range(N-1):
  if s[i] == s[i + 1]:
    score += 1
ans = min(score + 2*K, N-1)
print(ans)

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

// chmax, chmin
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; }


// debug stream of pair, vector
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



int N, K;
vector<vector<int> > G;

using pint = pair<int,int>;
vector<pint> dp;
pint rec(int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue;
        rec(nv, v);
    }
    pint res = {0, 1};
    for (auto nv : G[v]) {
        if (nv == p) continue;
        res.first += dp[nv].first;
        res.second = max(res.second, dp[nv].second + 1);
    }
    //cout << v << ": " << res << endl;
    
    if (v != 0 && p != 0 && res.second >= K) ++res.first, res.second = 0;
    
    //cout << v << ": " << res << endl;
    
    return dp[v] = res;
}

int main() {
    cin >> N >> K;
    int res = 0;
    G.clear(); G.resize(N);
    for (int i = 0; i < N; ++i) {
        int a; cin >> a; --a;
        if (i == 0 && a != 0) ++res;
        if (i != 0) {
            G[i].push_back(a);
            G[a].push_back(i);
        }
    }
    dp.assign(N, pint(N, N));
    rec(0, -1);
    cout << res + dp[0].first << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
using ll = long long;
int main() {
  int x;cin>>x;
  for(int i=-200;i<200;i++){
      for(int j=i;j<200;j++){
          if(pow(j,5)-pow(i,5)==x){
              cout<<j<<" "<<i<<endl;
              return 0;
          }
      }
  }

 
}

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

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

    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
	int a, b;
 	cin >> a >> b;
  	int res = -100000;
  	res = max(res, a+b);
  	res = max(res, a-b);
  	res = max(res, a*b);
  	cout << res << endl;
  	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;
int main() {
	string s;
	int k;
	cin >> s;
	cin >> k;
	int n = s.size();
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') { continue; }
		int x = (26 - (s[i] - 'a'));
		if (x <= k) { s[i] = 'a'; k -= x; };
	}
	for (int i = 0; i<s.size(); i++) {
		int x = (26 - (s[i] - 'a'));
		if (x <= k) { s[i] = 'a'; k -= x; };
	}
	s[n - 1] += (k % 26);
	cout << s << endl;
}

Measured memory_bytes: 512
import math

A, B, H, M = map(int,input().split())

h = (H + (M / 60)) / 6 * math.pi
m = M * math.pi / 30
ans = math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(h - m)))
print(ans)

Measured memory_bytes: 9508
#include<stdio.h>
int main(){
   int P,Q,R;
    scanf("%d" "%d" "%d",&P,&Q,&R);
    if(P<=Q&&R<=Q){
        printf("%d",P+R);
    }else if(P<=R&&Q<=R){
        printf("%d",P+Q);
    }else{
        printf("%d",Q+R);
    }
    return 0;
}

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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
#define division long(1e9 + 7)

int main(){
    int n;
    cin >> n;
    deque<int> ans;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        if((n + i) % 2){
            ans.push_front(num);
        }else{
            ans.push_back(num);
        }
    }
    array_output(ans.begin(), ans.end());
}


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

int main() {
    int n;

    cin >> n;
    
    vector<int> l(n);

    for(int i = 0; i < n; i++)
        cin >> l.at(i);
    
    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    for(int i = 1; i < n; i++) sum += l.at(i);

    if (sum > l.at(0))
        cout << "Yes" << endl;
    else 
        cout << "No"  << endl;
    return 0;
    
}

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

int main() {
  ll N, M;
  cin >> N >> M;
  map<ll, ll> dict;
  dict.insert(make_pair(0, 1));
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    ll ai;
    cin >> ai;
    sum += ai;
    ll mod = sum % M;
    if (dict.find(mod) == dict.end()) {
      dict.insert(make_pair(mod, 1));
    } else {
      ++dict.at(mod);
    }
  }
  ll result = 0;
  for (auto iter = dict.begin(); iter != dict.end(); ++iter) {
    ll cnt = iter->second;
    result += (cnt * (cnt - 1)) / 2;
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 4224
fun main() = abc165b()

@OptIn(ExperimentalStdlibApi::class)
fun abc165b() {
    val x = readLine()!!.toLong()

    var curr = 100L
    var answer = 0

    while (curr < x) {
        val add = curr / 100
        curr += add
        answer++
    }

    println(answer)
}


Measured memory_bytes: 34496
#include <stdio.h>

int main(void){
  int N,X;
  scanf("%d%d",&N ,&X);
  int m[110];
  int sum = 0;
  int i;

  for (i = 0; i < N; i++) {
    scanf("%d", &m[i]);
  }

  int min = m[0];

  for (i = 0; i < N; i++) {
    if (m[i] < min) {
      min = m[i];
    }
      sum += m[i];
  }


  int temp = X - sum;
  int count = 0;

  while (temp >= min) {
    temp -= min;
    count++;
  }

  printf("%d\n", N + count);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 10000000000

							
									//nestedcode

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,i,s,fl = 0,a;
    s = 1;
    cin>>n;
    for(i=0;i<n;i++){
    	cin>>a;
    	if(a == 0){
    		fl = 2;
    		continue;
		}
    	if((1000000000000000000 % a == 0) && (1000000000000000000/a < s)){
    		fl = 1;
		}
		if((1000000000000000000 % a != 0) && ((1000000000000000000/a) + 1 < s)){
    		fl = 1;
		}
		s *= a;
	}
   if(fl == 1 || s>1000000000000000000)	cout<<-1;
   else if(fl == 2)	cout<<0<<endl;
   else	cout<<s;
}


Measured memory_bytes: 3640
//ABC163 C

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;
lint a[200001];
lint buka[200001];


int main() {
  cin >> n;

  rep(i,n-1){
    scanf("%lld",&a[i+2]);
  }
  
  reps(i,2,n+1){
    buka[a[i]]++;
  }
  
  reps(i,1,n+1){
    printf("%lld\n",buka[i]);
  }

  //printf("%lld\n",ans);
}


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

int main(){
	int n, ans;
	while(cin >> n){
		ans = 0;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if(i + j + k + l == n) ans++;
					}
				}
			}
		}
	cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
    int H = 0;
    int W = 0;
    int c[10][10];
    // int A[200][200];
    scanf("%d %d", &H, &W);
    for(int i=0; i < 10; i++){
        for(int j=0; j < 10; j++){
            scanf("%d", &(c[i][j]));
        }
    }

    for(int k=0; k < 10; k++){
        for(int i=0; i < 10; i++){
            for(int j=0; j < 10; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int num = -1;
    long res = 0;
    for(int i=0; i < H; i++){
        for(int j=0; j < W; j++){
            scanf("%d", &num);
            if(num != -1){
                res += c[num][1];
            }
        }
    }

    printf("%ld\n", res);

    return 0;
}

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

int main( void )
{
	int n;
	while ( cin >> n && n != 0 )
	{
		vector <int> visited;
		map <int, long long> profit;
		bool exist = false;
		for ( int i = 0; i < min(n, 4000); i++ )
		{
			int no, p, q;
			cin >> no >> p >> q;

			profit[no] += (long long)p * q;

			if ( find( visited.begin(), visited.end(), no ) == visited.end() && profit[no] >= 1000000L )
			{
				exist = true;
				visited.push_back( no );
			}
		}

		if ( exist )
		{
			for ( vector <int>::iterator it = visited.begin(); it != visited.end(); it++ )
			{
				cout << *it << endl;
			}
		}
		else
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll b, ll n) {
	if(n < b) {
		return n;
	}
	return f(b, n / b) + (n % b);
}
int main() {
	ll n, s;
	cin >> n >> s;
	if(s > n) {
		cout << -1 << '\n';
		return 0;
	}
	for(ll b = 2; b * b <= 2 * n; ++b) {
		if(f(b, n) == s) {
			cout << b << '\n';
			return 0;
		}
	}
	vector<ll> ans;
	for(ll d = 1; d * d <= n; ++d) {
		ll x = s - d;
		if(x >= 0 && (n - x) % d == 0) {
			ll b = (n - x) / d;
			if(b > 1 && b > x) {
				ans.emplace_back(b);
			}
		}
	}
	if(s == n) {
		ans.emplace_back(n + 1);
	}
	if(ans.empty()) {
		cout << -1 << '\n';
	} else {
		cout << *min_element(ans.begin(), ans.end()) << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
alp =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
l=len(s)
u=[]
for j in range(l):
    u.append(s[j])
for k in range(l):
    for h in range(26):
        if u[k]==alp[h]:
            u[k]=alp[(h+n)%26]
            break    
for b in range(l):
    print(u[b], end="")       

Measured memory_bytes: 4596
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll n, m, k;
  cin>>n>>m>>k;

  vector<ll> a(n, 0), b(m, 0);
  ll current = 0, left = 0;
  for (ll i=0; i<n; i++) 
    cin>>a[i];
  for (ll i=0; i<m; i++)
    cin>>b[i];
  while (left < n && current + a[left] <= k) {
    current += a[left];
    left++;
  }

  ll ans = left, right = 0;
  for (ll i=left; i>=0; i--) {
    if (i < left) 
      current -= a[i];

    while (right < m && current + b[right] <= k) {
      current += b[right];
      right++;
    }

    ans = max(ans, i + right);
  }
  cout<<ans<<endl;
}

int 
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

struct Pair {
    int left, right;
    bool operator<(const Pair& r) const {
        return right < r.right;
    }
};

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<Pair> ps(m);
    for (auto& p : ps)
        scanf("%d%d", &p.left, &p.right);
    
    sort(ps.begin(), ps.end());

    int r = 0, ans = 0;
    for (auto& p : ps) {
        if (p.left < r) continue;
        r = p.right;
        ans++;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
struct seg{
    int l, r;
    bool operator < (const seg & x) const{
        return r < x.r;
    }
};

int main(){
    vector<seg> a;
    int n;
    scanf("%d", &n);
    for(int i = 1 ;i <= n; i++){
        int x, l;
        scanf("%d %d", &x, &l);
        a.push_back({x - l , x + l });
    }
    sort(a.begin(), a.end());
    int last  = -1e9 - 7;
    int ans = 0;
    for(auto i : a){
        if(i.l >= last){
            ++ ans;
            last = max(last, i.r);
        }
    }
    printf("%d\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1400
import sys
st = input()
if len(st) < 4:
    print('No')
    sys.exit()
if st[0] == 'Y':
    if st[1] == 'A':
        if st[2] == 'K':
            if st[3] == 'I':
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')




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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++) cin >> l[i];

  int max_n=0,max_i;
  for(int i=0;i<n;i++){
    if(max_n < l[i]){
      max_n = l[i];
      max_i = i;
    }
  }
  int sum_n=0;
  for(int i=0;i<n;i++){
    if(i == max_i) continue;
    sum_n += l[i];
  }
  if(max_n < sum_n) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    x, y = map(int, input().split())

    if x == y:
        print(0)

    elif abs(x) == abs(y):
        print(1)

    elif x < y:
        if x >= 0 and y >= 0:
            print(y - x)

        elif x >= 0 and y <= 0:
            pass

        elif x <= 0 and y >= 0:
            if y == 0:
                print(abs(x))
            else:
                if abs(y) > abs(x):
                    print(abs(y) - abs(x) + 1)
                else:
                    print(abs(x) - abs(y) + 1)

        elif x <= 0 and y <= 0:
            print(abs(x) - abs(y))

    elif x > y:
        if x <= 0 and y <= 0:
            c1 = abs(y) - x + 1
            c2 = abs(y) - abs(x) + 2
            print(min(c1, c2))

        elif x <= 0 and y >= 0:
            pass

        elif x >= 0 and y <= 0:
            print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)
            
        elif x >= 0 and y >= 0:
            print(x - y + 2)

if __name__ == "__main__":
    main()

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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;

		static void Main(string[] args)
		{
			var str = R;
			var k = RI;
			var list = new HashSet<string>();
			for (int i = 1; i < 10; i++)
			{
				for (int j = 0; j <= str.Length - i; j++)
				{
					list.Add(str.Substring(j, i));
				}
			}
			var li = new List<string>(list);
			li.Sort();
			Out(li[k - 1]);
		}
	}
}


Measured memory_bytes: 13792
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

using namespace std;

const int MOD = 1000000007;


map <string, int> m;
int main(){

    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;

    string s[n];
    REP(i,n)
    {
        cin >> s[i];
    }
    int M;
    cin >> M;
    string t[M];
    REP(i,M)
    {
        cin >> t[i];
    }

    REP(i,n)
    {
        decltype(m)::iterator it = m.find(s[i]);
        if(it == m.end()) 
        {
            m[s[i]] = 1;
        }
        else
        {
            m[s[i]] += 1;
        }
    }
    
    REP(i,M)
    {
        decltype(m)::iterator it = m.find(t[i]);
        if(it == m.end()) 
        {
            m[t[i]] = -1;
        }
        else
        {
            m[t[i]] -= 1;
        }
    }

    int iMax = 0;
    for( auto i = m.begin(); i != m.end() ; ++i)
    {
        iMax = max(iMax, i->second);
    }

    cout << iMax << endl;

    return 0;     
}



Measured memory_bytes: 256
def main():
    n = int(input())

    count_list = [0] * n
    upper = int(n**0.5) + 2
    for x in range(1, upper):
        for y in range(1, upper):
            for z in range(1, upper):
                num = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if num <= n:
                    count_list[num-1] += 1
    for count in count_list:
        print(count)


if __name__ == '__main__':
    main()


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

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

  vector<int> L(N, 0);
  for (int i = 0; i < N; i++) cin >> L.at(i); 
  
  int count = 0;
  
  sort(L.begin(), L.end());
  
  int a, b, c;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        a = L.at(i);
        b = L.at(j);
        c = L.at(k);
        if (c - b < a && a < b + c) {
          count++;
        }
      }
    }
  }
  
  cout << count;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    return YES if sum(A) >= H else NO


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(H, N, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14068
n,m = map(int,input().split())
a = []

for i in range(n):
	a.append(list(map(int,input().split())))

a.sort()

c = 0
p = 0
left = m

for i in range(n):
	if left >= a[i][1]:
		b = a[i][1]
		c += b
		p += a[i][0] * b
		left -= b
	elif left < a[i][1]:
		c += left
		p += a[i][0] * left
		left = 0
        
	if left == 0:
		break
	
print(p)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;

    LP ans = LP(0, 0);
    rep(i, 31) rep(j, 31) {
        ll wat = 100 * a * i + 100 * b * j;
        if (wat > f) continue;
        rep(k, 3001) {
            ll sgru = (a * i + b * j) * e;
            ll sgr = d * k;
            if (sgr > sgru) continue;
            if (f - wat - sgr < 0) continue;
            sgr += min(sgru - sgr, f - wat - sgr) / c * c;
            if (ans.fi * sgr >= ans.se * (sgr + wat)) ans = LP(sgr + wat, sgr);
        }
    }
    cout<<ans.fi<<" "<<ans.se<<endl;
}

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

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

    int n; cin >> n; string s; cin >> s;

    if (s.size()<=n) {
        cout << s << "\n";
    }

    else {
        for (int i=0; i<n; i++) {
            cout << s[i];
        }
        cout << "..." << "\n";
    }
    

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <utility>

using namespace std;

int main(void)
{
    long long N, n[5];
    cin >> N;
    for (int i = 0; i < 5; i++) cin >> n[i];
    for (int i = 1; i < 5; i++) n[i] = min(n[i], n[i - 1]);
    cout << (5 + (N - 1) / n[4]) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String str = sc.next();
        if(str.charAt(a) != '-') {
          System.out.println("No");
          return;
        }
        if(!isValid(str.substring(0, a), a) || !isValid(str.substring(a+1), b)) {
          System.out.println("No");
          return;
        }
        System.out.println("Yes");
    }

    private static boolean isValid(String str, int len) {
      if(str.length() != len) return false;
      for(char c : str.toCharArray()) {
        if(!Character.isDigit(c)) return false;
      }
      return true;
    }
}

Measured memory_bytes: 22996
#include<stdio.h>

int main(void){
  int K; scanf("%d",&K);
  long int ans = 0;

  for(int a = 1;a <= K;a++){
    for(int b = 1;b <= K;b++){
      for(int c = 1;c <= K;c++){
        int r,tmp;
        //a,b
        int a_copy = a,b_copy = b,c_copy;
        int g_ab;
        if(a_copy < b_copy){
          tmp = a_copy;
          a_copy = b_copy;
          b_copy = tmp;
        }
        r = a_copy % b_copy;
        while(r > 0){
          a_copy = b_copy;
          b_copy = r;
          r = a_copy % b_copy;
        }
        g_ab = b_copy;

        //b,c
        b_copy = b;
        c_copy = c;
        int g_bc;
        if(b_copy < c_copy){
          tmp = b_copy;
          b_copy = c_copy;
          c_copy = tmp;
        }
        r = b_copy % c_copy;
        while(r > 0){
          b_copy = c_copy;
          c_copy = r;
          r = b_copy % c_copy;
        }
        g_bc = c_copy;

        //g_ab,g_bc
        int g_abc;
        if(g_ab < g_bc){
          tmp = g_ab;
          g_ab = g_bc;
          g_bc = tmp;
        }
        r = g_ab % g_bc;
        while(r > 0){
          g_ab = g_bc;
          g_bc = r;
          r = g_ab % g_bc;
        }
        g_abc = g_bc;
        ans += g_abc;
      }
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int dp[MAX];
int main(){
    int N;cin>>N;
    for(int i=0;i<MAX;i++)dp[i]=N;
    dp[0]=0;
    for(int n=1;n<=N;++n){
        for(int pow6=1;pow6<=n;pow6*=6){
            dp[n]=min(dp[n],dp[n-pow6]+1);
        }
        for(int pow9=1;pow9<=n;pow9*=9){
            dp[n]=min(dp[n],dp[n-pow9]+1);
        }
    }
cout<<dp[N]<<endl;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0) break;
    int taro[n],hanako[m];
    int tarosum=0,hanakosum=0;
    bool flag=false;
    rep(i,n){
      cin>>taro[i];
      tarosum+=taro[i];
    }
    rep(i,m){
      cin>>hanako[i];
      hanakosum+=hanako[i];
    }
    sort(taro,taro+n);
    sort(hanako,hanako+m);
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	//cout<<taro[i]<<" "<<hanako[j]<<endl;
	if(2*(taro[i]-hanako[j]) == tarosum-hanakosum){
	  cout<<taro[i]<<" "<<hanako[j]<<endl;
	  flag=true;
	  break;
	}
      }
      if(flag) break;
    }
    if(!flag) cout<<-1<<endl;
  }

  return 0;
}



Measured memory_bytes: 3056
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,q; string s; cin >> n >> q >> s;
  vl acsum(n+1);
  
  for(ll i=0; i <= n-2; i++){
    acsum[i+2] = acsum[i+1];
    if(s[i] == 'A' and s[i+1] == 'C'){
      acsum[i+2]++;
    }
  }
  
  
  rep(i,q){
    ll l,r; cin >> l >> r;
    cout << acsum[r] - acsum[l] << endl;
  }
  
}

Measured memory_bytes: 4292
use std::cmp::Ordering;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let v: Vec<isize> = (0..n).map(|_| read()).collect();

    let (sorted, cnt) = selection_sort::<&isize>((&v).iter().collect());
    let st: String = sorted
        .iter()
        .map(|i| i.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}\n{}", st, cnt)
}

fn selection_sort<T: Ord + Copy>(v: Vec<T>) -> (Vec<T>, usize) {
    match v.get(0) {
        Some(&e) => {
            let (a, p, c) = step(v, e);
            let (pp, cc) = selection_sort(p.collect::<Vec<_>>()[1..].into());
            (insert_head(pp.into_iter(), a).collect(), c + cc)
        }
        None => (vec![], 0),
    }

}

fn step<'a, T: Ord + Copy + 'a>(v: Vec<T>, s: T) -> (T, Box<Iterator<Item=T> + 'a>, usize) {
    match v.get(0) {
        Some(&e) => {
            let (a, p, _) = step(v[1..].into(), s);
            match e.cmp(&a) {
                Ordering::Greater => (a, Box::new(insert_head(p, e)), 1),
                _ => (e, Box::new(insert_head(v[1..].to_vec().into_iter(), s)), 0),
            }
        }
        None => (s, Box::new(v.into_iter()), 0),
    }
}

fn insert_head<T, I: Iterator<Item=T>>(v: I, e: T) -> std::iter::Chain<std::vec::IntoIter<T>, I> {
    vec![e].into_iter().chain(v)
}



Measured memory_bytes: 5080
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<ll> x(N), y(N), h(N);
    int idx = 0;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0) {
            idx = i;
        }
    }
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            ll H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);

            bool ok = true;
            for (int i = 0; i < N; i++) {
                if (h[i] != max(0ll, H - abs(cx - x[i]) - abs(cy - y[i]))) {
                    ok = false;
                }
            }

            if (ok) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> d(N);
  rep(i, N) cin >> d[i];

  long ans = 0;

  for (long i = 0; i < N; i++) {
    for (long j = i + 1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;

void Task() {
      int even, odd;
      cin >> even >> odd;
      int ansEven = even * (even - 1) / 2;
      int ansOdd = odd * (odd - 1) / 2;
      int ans = ansEven + ansOdd;
      cout << ans << endl;
}

signed main() {
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr); cout.tie(nullptr);

      if (fopen("in.txt", "r")) {
            freopen("in.txt", "r", stdin);
      }

      int tc = 1;
      while (tc--) {
            Task();
      }
}


Measured memory_bytes: 3572
class Card
	attr_reader :suit
	attr_reader :no
	attr_reader :name
	def initialize(n)
		@name = n
		@suit = n[0]
		@no = n[1].to_i
	end

	def Search(n)
		return self if n == @no
	end
end

def Swap(a, b)
	return b,a
end

def PrintArray(d)
	d.length.times { |i|
		print " " unless i == 0
		print "#{d[i].name}"
	}
	puts
end

def Stable(a, b)
	stable = true
	(1..9).each { |i|
		bt = b.each_with_object(i).map(&:Search).compact
		next if bt.length < 1
		a.each_with_object(i).map(&:Search).compact.each_with_index { |at, j|
			if at.name != bt[j].name
				stable = false
				break
			end
		}
		break if not stable
	}
	puts "Stable" if stable
	puts "Not stable" if not stable
end

def BubbleSort(d_o)
	d = Marshal.load(Marshal.dump(d_o))
	(d.length-1).times { |i|
		(d.length-1).step(i+1, -1) { |j|
			d[j],d[j-1] = Swap(d[j],d[j-1]) if d[j-1].no > d[j].no
		}
	}
	PrintArray(d)
	Stable(d, d_o)
end

def SelectionSort(d_o)
	d = Marshal.load(Marshal.dump(d_o))
	d.length.times { |i|
		min = i
		(i...d.length).each_with_index { |j|
			min = j if d[min].no > d[j].no
		}
		d[i],d[min] = Swap(d[i],d[min]) if i != min
	}
	PrintArray(d)
	Stable(d, d_o)
end

gets
d = Array.new
gets.chomp.split(" ").each { |c| d << Card.new(c) }
BubbleSort(d)
SelectionSort(d)

Measured memory_bytes: 8768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e3 + 5, M = 5e3 + 5, inf = 1e9 + 7 ;
using namespace std ;

int n, e, a[N], ter[N], nxt[N], lnk[N], f[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ; 
}

bool dfs(int p) {
	if (!lnk[p]) {
		f[p] = 0 ;
		return true ;
	}
	int bit[M] ;
	rep(i, 0, a[p]) bit[i] = inf ; bit[0] = 0 ;
	for (int i = lnk[p] ; i; i = nxt[i]) {
		int v = ter[i] ;
		if (!dfs(v)) return false ;
		for (int j = a[p] ; j >= 0 ; -- j) {
			int res = inf ;
			if (j - a[v] >= 0) res = min(res, bit[j - a[v]] + f[v]) ;
			if (j - f[v] >= 0) res = min(res, bit[j - f[v]] + a[v]) ;
			bit[j] = res ;
		}
	}
	int mn = inf ;
	rep(i, 0, a[p]) mn = min(mn, bit[i]) ;
	if (mn == inf) return false ;
	f[p] = mn ;
	return true ;
}

int main() {
	scanf("%d", &n) ;
	int x ;
	rep(i, 2, n) scanf("%d", &x), add(x, i) ;
	rep(i, 1, n) scanf("%d", &a[i]) ;
	if (dfs(1)) puts("POSSIBLE") ; else puts("IMPOSSIBLE") ;
	return 0 ; 
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 1e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    int res = 0;

    for(int i=n;i>=1;i--){
        if(mx<=A[i])cnt++,mx = A[i];
        else {
            res = max(res,cnt);
            cnt = 1;
            mx = A[i];
        }
    }

    res = max(res,cnt);

    res--;

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
      a[i]=sc.nextInt();
    int dp[]=new int[n];
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
      dp[i]=Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
    System.out.println(dp[n-1]);
  }
}

Measured memory_bytes: 51164
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;

	ll h , n ;
	cin>>h>>n;
	ll sum=0;
	for(ll i=0,a ;i<n;i++){
		cin>>a;
		sum+=a;
	}
	if(sum>=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N), cnt(4);
  REP(i,N){
	cin >> xs[i];
	xs[i] %= 4;
	if(xs[i] <= 2)
	  cnt[xs[i]]++;
	else
	  cnt[1]++;
  }

  if(cnt[2]){
	if(cnt[1] == 0){
	  cout << "Yes" << endl;
	  return 0;
	}
	if(!cnt[0]){
	  cout << "No" << endl;
	  return 0;
	}
	cnt[0]--;
  }
  
  bool ok = (cnt[0]+1 >= cnt[1]);
  cout << (ok? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 640
import math
n = int(input())
a = list(map(int,input().split()))
left = [0]*(n+1)
right = [0]*(n+1)

for i in range(n):
  left[i+1] = math.gcd(left[i],a[i])
for i in range(n-1,-1,-1):
  right[i] = math.gcd(right[i+1],a[i])
ans = 0
for i in range(n):
  tmp = math.gcd(left[i],right[i+1])
  ans = max(tmp,ans)
  
print(ans)

Measured memory_bytes: 86260
#include <iostream>
#include <string>
using namespace	std;
int main(){

  string a,b;
  int tmp;
  cin>>a>>b;
  if(a.size()<b.size())	return 0;
  for(int i=0;i<a.size()-b.size()+1;i++){
    if(a[i]==b[0]){
      tmp=1;
      for(int j=0;j<b.size();j++) if(a[i+j]!=b[j]){
          tmp=0;
          break;
	}
      if(tmp) cout<<i<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3232
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll = long long int;
using pi=pair<int,int>;
using vi = vector<int>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

constexpr int INF = 1 << 30;  // 1e9
constexpr ll INFL = 1l << 60; // 1e18
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, 0, (n))

#define EVAL 1

#ifdef EVAL
#define LOG(x) ;
#else
#define LOG(x) cerr << #x << ": " << (x) << endl;
#endif

bool isPrime(int n){
	if(n==1) return false;
	int sq=sqrt(n);
	RANGE(i,2,sq){
		if(n%i==0) return false;
	}
	return true;
}
vi cnt5p=vi(5,0);
vi ans;
int N;
void solve() {
	cin>>N;
	REP(i,55555){
		if(isPrime(i)) {
			cnt5p[i%5]++;
			if(i%5==1) ans.push_back(i);
		}
	}
	REP(i,5) LOG(cnt5p[i]);
	REP(i,N) printf("%d ", ans[i]);
}

int main() {
	solve();
	return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x = nil->next;
  while(x->key != key){
    if(x == nil) break;
    x = x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer x = nil->prev;
  if(x == nil) return;
  deleteNode(x);
}

void delete(int key){
  NodePointer x;
  x = listSearch(key);
  if(x == nil) return;
  deleteNode(x);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next = x;
  x->next->prev = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
if __name__ == '__main__':
    while True:
        data = [int(x) for x in input().split(' ')]
        H = data[0]
        W = data[1]

        if H == 0 and W == 0:
            break

        for i in range(H):
            if i == 0 or i == H-1:
                print('#' * W)
            else:
                print('#' + '.'*(W-2) + '#')
        print('')



Measured memory_bytes: 5624
import math

n = int(input())
ta = [tuple(map(int, input().split())) for _ in range(n)]

a, b = ta[0]
for i in range(n):
    x, y = ta[i]
    z = max(-(-a//x), -(-b//y))
    a = x * z
    b = y * z

ans = a + b
print(ans)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
	int n;cin >> n;
	vector<ll> a(n);
	set<ll> aset;
	int minus_cnt = 0;
	ll sum = 0;
	rep(i,n){
		cin >> a.at(i);
		if(a.at(i) < 0){
			aset.insert(0 - a.at(i));
			minus_cnt++;
			sum -= a.at(i);
		}
		else{
			aset.insert(a.at(i));
			sum += a.at(i);
		}
	}
	ll ans;
	if(minus_cnt % 2 == 0)ans = sum;
	else ans = sum - ((*aset.begin()) * 2);
	cout << ans << endl;
	return 0;
}    

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <unordered_set>
using namespace std;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<map<int, vector<int>>> g(n);

    for (int i = 0; i < m; i++) {
        int p, q, c;
        scanf("%d%d%d", &p, &q, &c);
        p--, q--, c--;

        g[p][c].emplace_back(q);
        g[q][c].emplace_back(p);
    }

    set<pair<int, pair<int, int>>> q;
    set<pair<int, int>> close;

    q.insert(make_pair(0, make_pair(0, -1)));

    while (q.size()) {
        int dep = q.begin()->first;
        int cur = q.begin()->second.first;
        int com = q.begin()->second.second;
        q.erase(q.begin());

        if (cur == n - 1 && com == -1) {
            cout << dep << endl;
            return 0;
        }

        if (close.count(make_pair(cur, com)))
            continue;
        close.insert(make_pair(cur, com));

        if (com == -1) {
            for (auto &e: g[cur]) {
                for (auto &c: e.second) {
                    q.insert(make_pair(dep + 1, make_pair(c, e.first)));
                }
            }
        }
        else {
            for (auto &e: g[cur][com]) {
                q.insert(make_pair(dep, make_pair(e, com)));
            }
            q.insert(make_pair(dep, make_pair(cur, -1)));
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 75904