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

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

long long lcm(long long a,long long b){
    long long g = gcd(a,b);
    return a/g*b;
}

int main(){
    // int a,b;
    // cin >> a >> b;
    // cout << lcm(a,b) << endl;
    long long n,temp1,temp2;
    cin >> n;
    cin >> temp1;
    for(int i=1;i<n;i++){
        cin >> temp2;
        temp1 = lcm(temp1,temp2);
    }
    cout << temp1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
ll primeFactors(ll n)  
{  
    map<int,int> mp;
    while (n % 2 == 0)  
    {  
        mp[2] ++;
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
   
    if (n > 2)  
        mp[n]++;
    ll res = 0;
    for(auto x : mp){
        res += (-1 + sqrt(1+8*x.second))/2;
    }
    return res;
}
int main(int argc, const char** argv) {
    ll n;
    cin>>n;
    cout<<primeFactors(n);
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a==0&&b==0) break;
		for(int i=1;i<=b;i++)
		cout<<"#";
		cout<<endl;
		for(int i=a-2;i>0;i--)
		{
		cout<<"#";
		for(int j=b-2;j>0;j--)
		cout<<".";
		cout<<"#"<<endl;
		}
		for(int i=1;i<=b;i++)
		cout<<"#";
		cout<<endl;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int gcd(int x,int y){
    int r,m;
    if(x < y){
        m=x;
        x=y;
        y=m;
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
    unsigned long long int a,b,x,n;
    while(scanf("%lld%lld",&a,&b)!=EOF){
        x=gcd(a,b);
        printf("%lld ",x);
        n=a/x*b;
        printf("%lld\n",n);
    }
    return 0;
}

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

int main(void) {
    int x;
    cin >> x;
    switch(x) {
        case 3:
        case 5:
        case 7:
            cout << "YES\n";
            break;
        default:
            cout << "NO\n";
            break;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
typedef pair<int, int>P;

int dx[4] = { 1,0,-1,0 };//D,R,U,L
int dy[4] = { 0,1,0,-1 };


vector<int>ans;


signed main() {
	ll K; cin >> K;
	ans.resize(50);
	REP(i, 50) {
		ans[i] = i;
	}
	ll st = K / 50;
	ll rem = K - st * 50;
	REP(i, 50) {
		ans[i] += st;
	}
	while (rem > 0) {
		ll mn = INF;
		REP(i, 50) {
			mn = min(ans[i], mn);
		}
		int idx;
		REP(i, 50) {
			if (ans[i] == mn)idx = i;
		}
		REP(i, 50) {
			if (i == idx) {
				ans[i] += 50;
			}
			else ans[i]--;
		}
		rem--;
	}
	print(50);
	REP(i, 50)pe(ans[i]);
	cout << endl;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    map<int,int> a;
    rep(i,N) cin >> A[i];
    for(int n:A) ++a[n];
    ll c = 0;
    for(auto x :a){
        c += (ll)x.second*(x.second-1)/2;
    }
    for(int n:A) {
        ll b = a[n]-1;
        cout << c - b << endl;
    }
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int N_MAX = 100000;
    const int V_MAX = 100000;
    int n;
    int v[N_MAX];
    cin >> n;
    REP(i, n) cin >> v[i];
    int count[2][V_MAX + 1];
    REP(i, 2) REP(j, V_MAX + 1) count[i][j] = 0;
    REP(i, n) ++count[i%2][v[i]];
    vector<pii> w[2];
    REP(i, 2) REP(j, V_MAX + 1) w[i].push_back(pii(count[i][j], j));
    REP(i, 2) sort(w[i].begin(), w[i].end());
    int ret;
    if (w[0][V_MAX].second != w[1][V_MAX].second) {
        ret = (n / 2 - w[0][V_MAX].first) + (n / 2 - w[1][V_MAX].first);
    } else {
        int x0 = (n / 2 - w[0][V_MAX].first) + (n / 2 - w[1][V_MAX - 1].first);
        int x1 = (n / 2 - w[0][V_MAX - 1].first) + (n / 2 - w[1][V_MAX].first);
        ret = min(x0, x1);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
#include<cassert>

using namespace std;

#define int long long

const int INF = (int)1e9;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int xx = 0;
  
  while(true){
    vector<deque<pair<pair<int,int>,pair<int,int>>>> lanes(2);
    vector<pair<int,int>> a;
    int con  = 0;
    int n;
    
    cin>>n;

    if(!n) break;

    for(int i = 0; i < n; i++){
      int t, c;

      cin>>t>>c;

      c *=2;
      
      a.push_back(make_pair(t,c));
    }

     sort(a.begin(), a.end(), greater<pair<int,int>>());
     // sort(a.begin(), a.end());

  
    for(int i = 0; i < a.size(); i++){
      lanes[0].push_back(make_pair(a[i], make_pair(0,a[i].first)));
    }

    while(lanes[0].size() || lanes[1].size()){ //cout<<con<<" "<<lanes[0].size()<<" "<<lanes[1].size()<<endl;
      vector<vector<pair<int,int>>> temp(2);
      int hoge = INF;
      for(int k = 0; k < 2; k++){
        for(int i = 0; i < lanes[k].size(); i++){
          hoge = min(hoge,lanes[k][i].second.second - lanes[k][i].second.first);
        }
      }
      for(int k = 0; k < 2; k++){
        for(int i = 0; i < lanes[k].size(); i++){
          lanes[k][i].second.first += hoge;
        }
      }
      for(int k = 0; k < 2; k++){
        for(int i = (int)lanes[k].size()-1; i >= 1; i--){
          if(lanes[k][i-1].second.first * lanes[k][i].second.second > lanes[k][i].second.first*lanes[k][i-1].second.second){
            lanes[k][i-1].second = lanes[k][i].second;
          }
        }
      }
      for(int k = 0; k < 2; k++){
        while(lanes[k].size()){
          if(lanes[k].back().second.first == lanes[k].back().second.second){
            if(lanes[k].back().first.second >= 2) {
              temp[k].push_back(make_pair(lanes[k].back().first.first,lanes[k].back().first.second-1));
            }
             lanes[k].pop_back();
          } else break;
        }

      sort(temp[k].begin(), temp[k].end());
      }
      
      for(int k = 0; k < 2; k++){
        for(int i = 0; i < temp[k].size(); i++){
          lanes[!k].push_front(make_pair(temp[k][i], make_pair(0, temp[k][i].first)));
        }
      }
      con += hoge;
    }
    
    cout<<con<<endl;
  }
  return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, d;
ll t[100000], f[100000];

int main(){
    cin >> n >> d;
    rep(i,n) cin >> t[i] >> f[i];
    ll cnt = 1;
    ll ans = 0;
    if(t[0] < f[0]-1) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1; i < n; i++) {
        if(f[i-1]+f[i]-2 <= t[i]-t[i-1]) {
            ans += cnt*(f[i-1]-1);
            cnt = 1;
        } else {
            ans += (t[i]-t[i-1])*cnt;
            if(abs(f[i]-f[i-1]) > t[i]-t[i-1]) {
                cout << -1 << endl;
                return 0;
            }
            cnt++;
            if(cnt > d) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ans += cnt*(f[n-1]-1);
    cout << ans << endl;
}

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

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){

            A[j+g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }

    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i], &cnt);


    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{

    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);



    shellSort(A, n);

    return 0;
}



Measured memory_bytes: 7064
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int P = 998244353;

int Sum(int a, int b) {
    return (a + b) % P;
}

int Mult(int a, int b) {
    return (a * (long long) b) % P;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    string s;
    int k;
    cin >> s >> k;
    int n = sz(s);

    vector<int> a(1);
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            ++a.back();
        } else {
            a.pb(0);
        }
    }

    vector<int> sum(sz(a) + 1);
    sum[0] = 0;
    for (int i = 0; i < sz(a); ++i) {
        sum[i + 1] = sum[i] + a[i];
    }

    vector<vector<vector<int>>> d(sz(a) + 1, 
        vector<vector<int>>(n + 1,
            vector<int>(n + 1)));

    d[0][0][0] = 1;
    for (int i = 0; i < sz(a); ++i) {
        for (int left_sum = 0; left_sum <= n; ++left_sum) {
            for (int left_sum_up = 0; left_sum_up <= left_sum; ++left_sum_up) {
                for (int cur = 0; cur <= n; ++cur) {
                    if (left_sum + cur < sum[i + 1] || left_sum + cur > sum.back()) {
                        continue;
                    }
                    
                    int add_up = max(0, cur - a[i]);
                    d[i + 1][left_sum + cur][left_sum_up + add_up] =
                        Sum(d[i + 1][left_sum + cur][left_sum_up + add_up],
                            d[i][left_sum][left_sum_up]);
                }
            }
        }
    }

    int res = 0;
    for (int sum_up = 0; sum_up <= min(n, k); ++sum_up) { 
        res = Sum(res, d[sz(a)][sum.back()][sum_up]);
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 112960
#include<bits/stdc++.h>
using namespace std;
const int  MAX_N=10000;
const int MAX_C=10000;
int main(){
        int dp[MAX_C+10];
        int c,n,m;cin >> c >> n >> m;
        int s[n],p[n];
        for(int i=0;i<n;i++){
                cin >> s[i] >> p[i];
        }
        fill(dp,dp+MAX_C+10,0);
        for(int i=0;i<n;i++){
                for(int j=MAX_C;j>=0;j--){
                        if(j<s[i]){
                                dp[j] = dp[j];
                        }
                        else dp[j] = max(dp[j],dp[j-s[i]]+p[i]);
                }
        }
        for(int i=1;i<m+1;i++){
                cout << dp[c/i]*i << endl;
        }
}


Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;

char Toupper(char);

int main(){

	char c;
	string str;
	
	getline(cin, str);

	transform(str.begin(), str.end(), str.begin(), Toupper);
	
	cout << str << endl;

	return 0;
}

char Toupper(char c){

	return toupper((int)c);
	
}

Measured memory_bytes: 1176
import java.util.*;

public class Main {
    static int INF = 1001001009;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int n = sc.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
            values[i] = sc.nextInt();
        }
        
        // dp[i][w]: 品物0~iまでなめた時のwダメージ与えられる最小コスト
        int[][] dp = new int[n + 1][W + 1];
        // 初期化
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                dp[i][w] = INF;
            }
        }
        // 0ダメージ与えられる最小のコストは0
        for (int i = 0; i <= n; i++) {
            dp[i][0] = 0;
        }
        
        // dp[i + 1][w] (品物iまでを使ったときの)wダメージ与えられる最小のコスト
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                // 品物iを選択できる(重量[i]がw以下)
                if (w - weights[i] >= 0) {
                    // 選択できる場合、選択する方/しない方の最善を選ぶ
                    // (選択するにはダメージ[i]分少ないとこからなら遷移できる)
                    dp[i + 1][w] = Math.min(dp[i + 1][w - weights[i]] + values[i], dp[i][w]);
                } else {
                    // 選択できない場合、技iを使ったコストを入れ続ける
                    dp[i + 1][w] = Math.min(dp[i + 1][0] + values[i], dp[i][w]);
                }
            }
        }
        // for (int i = 0; i < n+1; i++) {
        //     System.out.println(Arrays.toString(dp[i]));
        // }
        
        System.out.println(dp[n][W]);
    }
}


Measured memory_bytes: 81364
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> t(n), a(n);
    rep(i, n) {
        cin >> t[i] >> a[i];
    }
    int sum = t[0] + a[0], taka = t[0], ao = a[0];
    for(int i = 1; i < n; ++i) {
        int x = max((taka + t[i] - 1) / t[i], (ao + a[i] - 1) / a[i]);
        taka = t[i] * x, ao = a[i] * x;
        sum = taka + ao;
    }
    cout << sum << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  int[] H = new int[N];
	  for(int i=0; i<N; i++) {
		  H[i] = sc.nextInt();
	  }
	  int count = 0;
	  int max = 0;
	  
	  for(int i=0; i< N-1; i++) {
		  if (H[i] >= H[i + 1]) {
			  count++;
			  if (max < count)
				  max = count;
		  } else {
			  count = 0;
		  }
	  }
	  
	  out.println(max);
	  
  }
}

Measured memory_bytes: 52384
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int N; cin >> N;
	ll res = 0;
	for (int i = 1; i <= N; ++i){
		int tmp = N / i;
		res += i * (tmp * (1LL + tmp) / 2LL);
	}
	cout << res << endl;
	return 0;
}

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

 using namespace std;

 int main() {
   string S;

   cin >> S;

   int ans = 753;
   for (int i = 0; i <= S.length() - 3; i++) {
     ans = min(ans, abs(stoi(S.substr(i, 3)) - 753));
   }

   cout << ans << endl;
}


Measured memory_bytes: 764
#include <stdio.h>

int main(void) {
    int
        N, A, B, C, D,
        s1 = 0,
        s2 = 0, 
        v1 = 0,
        v2 = 0,
        b1 = 1,
        b2 = 1;

    scanf("%d", &N);
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &D);

    do {
        if (b1) {
            s1 += A;
            v1 += B;
        }
        if (b2) {
            s2 += C;
            v2 += D;
        }
        b1 = s1 < N;
        b2 = s2 < N;
    } while (b1 || b2);

    printf("%d\n", v1 < v2 ? v1 : v2);
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    bool ans = true;
    if(s.size() % 2 != 0) ans = false;
    REP(i, s.size() / 2){
        ans &= (s[2*i] == 'h' && s[2*i+1] == 'i');
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

bool is_palindromic(int n) {
    string s, t;
    s = to_string(n);
    t = to_string(n);
    reverse(t.begin(), t.end());

    if (s.compare(t) == 0)
        return true;
    else
        return false;
}

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

    int count = 0;
    for (int i = a; i <= b; i++) {
        if(is_palindromic(i))
            count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a,last;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&a);
		if(!last){
			last=a;
		}
		if(a==last||a-1==last){
			continue;
		}
		if(a<last){
			puts("No");
			return 0;
		}
		if(a-1>last){
			last=a-1;
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
  char buf[82];
  char *p;
  int l;
  string str;

  while (cin.getline(buf, 82)) {
    l = strlen(buf);

    for (int i=0; i<26; i++) {
      for (int j=0; j<l; j++) {
        if (buf[j]>='a' && buf[j]<='z') {
          buf[j] = (buf[j]-'a'+1)%26 + 'a';
        }
      }
      str.assign(buf);
      if (str.find("the")!=string::npos ||
          str.find("this")!=string::npos ||
          str.find("that")!=string::npos) {
        break;
      }
    }

    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
n, m, x = gets.chomp.split(" ").map(&:to_i)
rikai = Array.new(m,0)
sankousyo = []
n.times do 
	ngo = gets.chomp.split(" ").map(&:to_i)
	sankousyo << ngo
	(1..ngo.length-1).each do |i|
		rikai[i-1] += ngo[i]
	end
end
rikai.each do |r|
	if r < x then
		puts -1
		exit
	end
end

min = 114514810
(1..n).each do |i|
	comb = (0..n-1).to_a.combination(i).to_a
	comb.each do |co|
		rikai = Array.new(m,0)
		co.each do |c|
			m.times do |cc|

				rikai[cc] += sankousyo[c][cc+1]
			end
		end
		if rikai.find{|r| r < x} == nil then
			kingaku = 0
			co.each do |c|
				kingaku += sankousyo[c][0]
			end
			min = kingaku if kingaku < min
		end
	end
end
puts min


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

int main(){

    int a,b;

    cin >> a >> b;

    if(a>=b+1){
        cout << a+(a-1) << endl;
    }
    else if(b>=a+1){
        cout << b+(b-1) << endl;
    }
    else if(a==b){
        cout << a+a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
x=int(input())
print(arr[x-1])

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

ll sum_10num(ll N){
    string num=to_string(N);
    ll sum=0;
    rep(i,0,num.size()){
        sum+=num[i]-'0';
    }
    return sum;
}

int main(){
    ll N;
    cin >> N;
    if(N%sum_10num(N)==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define w(x)            int x;  cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,a,b)       for(int i = a; i < b; i++)
//int tc = 0;
//printf("Case #%d: %d\n",tc,);

/*
    string binary = bitset<8>(input number).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();   //binary to decimal
    cout<<decimal<<"\n";
*/

int main(){
    FIO;
    //w(t)
       //tc++;
       int n;
       cin >> n;
       n%=10;
       if(n == 2||n == 4||n == 5||n == 7||n == 9){cout<< "hon";return 0;}
       else if(n == 0||n == 1||n == 6||n == 8){cout<< "pon";return 0;}
       else if(n == 3){cout<< "bon";return 0;}
        
    return 0;
}

Measured memory_bytes: 3616
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();


		int gcd=gcd(2,N);

		int lcm=2*N/gcd;

		pln(lcm);

	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 21972
#include <stdio.h>

int main ()
{
    int n,m,a,sum,dif;
    while (scanf ("%d",&n)   !=EOF)
    {
        scanf ("%d",&m);
        sum = 0;
        for (int i=0;i<m;i++)
        {
            scanf ("%d",&a);
            sum+=a;
        }
        dif = n-sum;
          if (dif>=0)
            printf("%d\n",dif);
          else
            printf("-1\n");
    }
    return 0;
}


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

int main(){
  int i,j;ll cnt=0;
  int n;
  cin>>n;
  string s[n];
  for(i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);
  char t[n];
  for(i=0;i<n;i++){
    if(s[i][0]=='M' || s[i][0]=='A' || s[i][0]=='R' || s[i][0]=='C' || s[i][0]=='H'){
      t[cnt++]=s[i][0];
    }
  }
  if(cnt==0){
    cout<<0<<endl;
    return 0;
  }
  n=cnt;cnt=0;
  ll p[5];
  for(i=0;i<5;i++)p[i]=0;
  for(i=0;i<n;i++){
    if(t[i]=='M')p[0]++;
    if(t[i]=='A')p[1]++;
    if(t[i]=='R')p[2]++;
    if(t[i]=='C')p[3]++;
    if(t[i]=='H')p[4]++;
  }
  ll sum=0;
  for(i=0;i<5;i++){
    for(j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++){
        sum+=p[i]*p[j]*p[k];
      }
    }
  }
  cout<<sum;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;

int main() {
        int k;
        cin >> k;
        string s;
        cin >> s;
        if (s.size() > k){
            s = s.substr(0,k) + "...";
            cout << s;
        }
        else
            cout << s;
	return 0;
}


Measured memory_bytes: 3632
from collections import deque
import sys
input = sys.stdin.readline

def bfs(s):
    que = deque([(0, s)])
    while que:
        d, v = que.popleft()
        if visited[v]:
            if d != dist[v]:
                return False
            continue
        visited[v] = True
        dist[v] = d
        for w, u in A[v]:
            que.append((d + w, u))
    return True

N, M = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(M):
    l, r, w = map(int, input().split())
    l -= 1
    r -= 1
    A[l].append((w, r))
    A[r].append((-w, l))
visited = [0] * N
dist = [0] * N
res = 'Yes'
for i in range(N):
    if visited[i]:
        continue
    f = bfs(i)
    if not f:
        res = 'No'
print(res)

Measured memory_bytes: 93800
#include <iostream>
#define INF 1000000000000000000LL
using namespace std;
using ll = long long;

int main()
{
  ll a;
  double b;
  cin >> a >> b;
  ll tmp = b * 100 + 0.5;

  cout << (ll)(a * tmp / 100) << endl;
  return 0;
}

Measured memory_bytes: 3724
N, K = list(map(int, input().split()))
if K==0:
    print(N*N)
    exit()

ans = 0
r = 1
for b in range(K+1, N+1):
    ans += (N//b)*r + max((N%b)-K+1 ,0)
    r += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a[5],k;
    REP(i,5)cin>>a[i];
    cin>>k;
    REP(i,5){
        if(i!=0){
            if(a[i]-a[0]>k){
                printf(":(\n");
                return 0;
            }
        }
    }
    printf("Yay!\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int n;
    cin>>n;
    
    vector<int> vec_x(n),vec_y(n);
    REP(i,n){
        cin>>vec_x[i];
        cin>>vec_y[i];
    }

    long double distance_sum=0.0, distance, x_dif, y_dif;
    REP(i,n-1){
        FOR(j,i+1,n){
            x_dif=vec_x[i]-vec_x[j];
            y_dif=vec_y[i]-vec_y[j];
            distance = sqrt(x_dif*x_dif+y_dif*y_dif);
            distance_sum+=distance;
        }
    }
    
    long double distance_ave = 2*distance_sum/n;
    cout<< fixed << setprecision(10)<< distance_ave;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

bool match(vector<vector<char>> a, vector<vector<char>> b, int n){
    bool m = true;
    rep(i,n){
        rep(j,n){
            if(a[i] != b[i]) m = false;
        }
    }
    return m;
}   

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    vector<vector<char>> b(m, vector<char>(m));

    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }

    rep(i,m){
        rep(j,m){
            cin >> b[i][j];
        }
    }

    vector<vector<char>> c(m, vector<char>(m));

    rep(i, n-m+1){
        rep(j, n-m+1){

            rep(k,m){
                rep(l,m){
                    c[k][l] = a[i+k][j+l];
                }
            }

            if(match(b,c,m)){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int n,m;
int s;

vector<int> put[105];
bool ima[105][105];

struct edge{
    int x;
    ll cost;
    ll duz;
};
vector<edge> graf[105];

ll cc[105];
ll dd[105];
struct stanje{
    int x;
    ll duz;
    ll kolko;
};

ll dist[55][55 * 55];
bool bio[55][55 * 55];


bool operator > (const stanje &prvi, const stanje &drugi){
    return prvi.duz > drugi.duz;
}

priority_queue<stanje, vector<stanje>, greater<stanje> > pq;

int main()
{

    ios_base::sync_with_stdio(false); //cin.tie(0);
    cin >> n >> m >> s;
    ff(i,1,m){
        int x,y,a,b;
        cin >> x >> y >> a >> b;
        graf[x].pb({y,a,b});
        graf[y].pb({x,a,b});
    }
    ff(i,1,n)cin >> cc[i] >> dd[i];
    ff(i,1,50){
        ff(j,0,51 * n){
            dist[i][j] = -1;
        }
    }
    //tr.pb({1,0,s});
    if(s > 51*n)s = 51 * n;
    pq.push({1,0,s});
    dist[1][s] = 0;

    while(!pq.empty()){
        stanje sta = pq.top();
        int tr = sta.kolko;
        ll tajm = 0;
        //cout << sta.x << " " << sta.duz << " " << sta.kolko << endl << endl;
        //cout << sta.x <<  " " << tr << endl;
        //cout << sta.x << endl;
        pq.pop();
        int koliko = tr + cc[sta.x];
        tajm = dd[sta.x];
        if(koliko > 51 * n)koliko = 51 * n;
        if(koliko != tr && ( dist[sta.x][koliko] == -1 || dist[sta.x][koliko] > dist[sta.x][tr] + tajm )){
            dist[sta.x][koliko] = dist[sta.x][tr] + tajm;
            pq.push({sta.x, dist[sta.x][tr] + tajm, koliko});
            bio[sta.x][koliko] = 1;
        }
        for(auto c:graf[sta.x]){
            if(c.cost > tr)continue;
            if(dist[c.x][tr - c.cost] == -1 || dist[c.x][tr - c.cost] > dist[sta.x][tr] + c.duz){
                dist[c.x][tr - c.cost] = dist[sta.x][tr] + c.duz;
                pq.push({c.x, dist[sta.x][tr] + c.duz, tr - c.cost});
                bio[c.x][tr - c.cost] = 1;
            }
        }
        ///
        continue;

    }

    ff(i,2,n){
        ll mini = -1;
        ff(j,0,51 * n){
            if(mini == -1)mini = dist[i][j];
            else mini = min(mini, dist[i][j]);
        }
        cout << mini << endl;
    }
    return 0;
}


Measured memory_bytes: 7848
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

vector<ll> A;
vector<ll> RUI;
ll cache[401][401];

ll dfs(int l, int r, ll cost = 0) {
  if (l == r) return 0;
  if (cache[l][r] != -1) return cache[l][r];

  cost += RUI[r + 1] - RUI[l];

  ll minCost = LONG_MAX;

  for (int m = l; m <= r - 1; ++m) {
    ll ncost = cost + dfs(l, m) + dfs(m + 1, r);

    minCost = min(minCost, ncost);
  }

  return cache[l][r] = minCost;
}

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

  memset(cache, -1, sizeof(cache));

  RUI.push_back(0);
  ll a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
    RUI.push_back(RUI.back() + a);
  }

  cout << dfs(0, N - 1) << endl;

  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
	long long a,b;
	char c;
	scanf("%ld %c %ld",&a,&c,&b);
	if(c=='+'){
		printf("%ld",a+b);
	}else{
		printf("%ld",a-b);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string a, b, c;
  cin >> a >> b >> c;
  char d, e, f;
  d = a[0] - 32;
  e = b[0] - 32;
  f = c[0] - 32;
  cout << d << e << f <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		char x = sc.next().charAt(0);
		char y = sc.next().charAt(0);

		if(x < y) {
			System.out.println("<");
		} else if (x > y) {
			System.out.println(">");
		} else {
			System.out.println("=");
		}
	}
}

Measured memory_bytes: 35568
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[30010][11][11][11];

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  set<ll> se;
  clr(dp,0);
  rep(i,1,s.sz+1){
    ll a = s[i-1]-'0';
    rep(j,0,11){
      rep(k,0,11){
        rep(l,0,11){
          if(j==10&&k==10&&l==10){
            dp[i][a][k][l] = 1;
          }
          if(dp[i-1][j][k][l]==1){
            if(j!=10&&l==10){
              dp[i][j][a][l] = 1;
            }
            if(j!=10&&k!=10){
              dp[i][j][k][a] = 1;
              se.insert(j*100+k*10+a);
            }
          }
        }
      }
    }
  }
  cout << se.sz << endl;
  return 0;
}

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

int main(){
	int n;
	map<string, int> num;
	while(cin>>n){
		char tmp;
		string s;
		cin >> tmp >> s;
		num[s]++;
	}
	cout << num["A"] << endl << num["B"] << endl;
	cout << num["AB"] << endl << num["O"] << endl;
	return 0;
}


Measured memory_bytes: 3164
// C - Dice and Coin
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	double ans = 0;
	for(int n=1; n<=N; ++n){
		int c = ceil(log2( (K+n-1)/n ));
		if(K<=n<<c) ans += 1./(N*(1<<c));
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 1005
using namespace std;
int n,tt,s[4];bool col[2][MN][MN],vis[MN][MN];
const int dx[]={-1,-1,1,1};
const int dy[]={-1,1,-1,1};
struct que{int x,y;}q[MN];
void dfs(int x,int y,int c,int typ){
	vis[x][y]=1,col[typ][x][y]=c;
	for(int i=0;i<4;i++)
		for(int j=1;j<=tt;j++){
			int tx=x+dx[i]*q[j].x,ty=y+dy[i]*q[j].y;
			if(tx<0||ty<0||tx>2*n||ty>2*n||vis[tx][ty])continue;
			dfs(tx,ty,!c,typ);	
		}
}
int main(){
	int x,y;scanf("%d%d%d",&n,&x,&y);
	tt=0;for(int i=0;i<=2*n;i++)if(i*i<=x)for(int j=0;j<=2*n;j++)if(i*i+j*j==x)q[++tt].x=i,q[tt].y=j;
	for(int i=0;i<2*n;i++)for(int j=0;j<2*n;j++)if(!vis[i][j])dfs(i,j,0,0);memset(vis,0,sizeof(vis));
	tt=0;for(int i=0;i<=2*n;i++)if(i*i<=y)for(int j=0;j<=2*n;j++)if(i*i+j*j==y)q[++tt].x=i,q[tt].y=j;
	for(int i=0;i<2*n;i++)for(int j=0;j<2*n;j++)if(!vis[i][j])dfs(i,j,0,1);
	for(int i=0;i<2*n;i++)for(int j=0;j<2*n;j++)s[col[0][i][j]*2+col[1][i][j]]++;
	for(int i=0;i<4;i++)if(s[i]>=n*n){
		int cnt=0;
		for(int j=0;j<2*n&&cnt<n*n;j++)for(int k=0;k<2*n&&cnt<n*n;k++)if(col[0][j][k]*2+col[1][j][k]==i)printf("%d %d\n",j,k),cnt++;
		return 0;
	}
}


Measured memory_bytes: 31232
from collections import Counter

N = int(input())
cnt = Counter()
for i in range(N):
  cnt[input()] += 1

mc = cnt.most_common(1)[0][1]
ms = []
for kw, count in cnt.most_common():
  if(count<mc):
    break
  ms.append(kw)
  
ms.sort()
for s in ms:
  print(s)


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

void initialize(int **mat, int row, int col);

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    long A[n][m], B[m][l], C[n][l];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> A[i][j];
    for (int i = 0; i < m; i++)
        for (int j = 0; j < l; j++)
            cin >> B[i][j];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            C[i][j] = 0;
            for (int k = 0; k < m; k++)
            {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cout << C[i][j];
            if (j != l - 1)
                cout << ' ';
        }
        cout << endl;
    }
}



Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
const double INF = 1e18;
const double EPS = 1e-10;

int main(){
	int m,n;
	cin >> m >> n;
	vector<vector<double> > p(m, vector<double>(n));
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			cin >> p[i][j];
		}
	}
	
	vector<vector<double> > dp(1<<m, vector<double>(m, 0));
	for(int i=0; i<(1<<m); i++){
		for(int j=0; j<m; j++){
			if((1<<j & i) != 0) dp[i][j] = 1;
		}
	}
	
	for(int i=n-1; i>=0; i--){
		vector<vector<double> > ndp(1<<m, vector<double>(m, 0));
		for(int j=0; j<(1<<m); j++){
			for(int k=0; k<m; k++){
				if((j & 1<<k) == 0) continue;
				double nextmax = 0;
				for(int l=0; l<m; l++){
					nextmax = max(nextmax, ndp[j & ~(1<<k)][l]);
				}
				ndp[j][k] = p[k][i]*dp[j][k] +(1 -p[k][i])*nextmax;
			}
		}
		dp = ndp;
	}
	
	cout << fixed << setprecision(10);
	cout << *max_element(dp[(1<<m) -1].begin(), dp[(1<<m) -1].end()) << endl;
	return 0;
}


Measured memory_bytes: 24628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n,k,res;
    cin >> n >> k;
    int r = min(n,k);
    vector<int> v(n);
    rep(i,n)cin >> v[i];
    int ans = 0;
    rep(a,r+1)rep(b,r+1){
        if(a+b>r)break;
        res = 0;
        vector<int> minus;
        rep(i,a){
            res += v[i];
            if(v[i]<0)minus.push_back(v[i]);
        }
        rep(i,b){
            res += v[n-1-i];
            if(v[n-1-i] < 0)minus.push_back(v[n-1-i]);
        }
        sort(minus.begin(),minus.end());
        rep(i,min((int)minus.size(),k-(a+b)))res -= minus[i];
        ans = max(ans,res);
        
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
X2SUM = sum([i**2 for i in X])
XSUM = sum([i for i in X])
minn = float('inf')
for i in range(1,101):
    minn = min(minn, X2SUM+-2*XSUM*i+N*(i**2))
print(minn)

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define rg register
using namespace std;
template<typename T>inline void in(T &a)
{
	T ch=getchar(),f=1;
	for(a=0;!isdigit(ch);ch=getchar())
	  ch=='-'?f=-1:f=f;
	for(;isdigit(ch);ch=getchar())
	  a=(a<<3)+(a<<1)+ch-'0';
	a*=f;
}
template<typename T>inline void print(T x)
{
	if(x<0)
	  putchar('-'),x=-x;
	if(x>9)
	  print(x/10);
	putchar(x%10+'0');
}
signed main()
{
	int d;
	cin>>d;
	if(d==25)
	  cout<<"Christmas"<<endl;
	else if(d==24)
	  cout<<"Christmas Eve"<<endl;
	else if(d==23)
	  cout<<"Christmas Eve Eve"<<endl;
	else if(d==22)
	  cout<<"Christmas Eve Eve Eve"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define clr(a,n) memset(a,0,sizeof(int)*(n+1))
#define lint long long
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=310;queue<int> q;
int cnt[N],del[N],c[N][N],fp[N],a[N][N],b[N][N];
int check(int x,int n,int m)
{
	clr(cnt,m),clr(del,m);
	rep(i,1,n) clr(c[i],m),cnt[a[i][fp[i]=1]]++;
	while(!q.empty()) q.pop();
	rep(i,1,m) if(cnt[i]>x) q.push(i),del[i]=1;
	while(!q.empty())
	{
		int z=q.front();q.pop();
		rep(i,1,n) c[i][b[i][z]]=1;
		rep(i,1,n)
		{
			int t=0;
			while(fp[i]<=m&&c[i][fp[i]]) fp[i]++,t=1;
			if(fp[i]>m) return false;
			int y=a[i][fp[i]];if(t) cnt[y]++;
			if(cnt[y]>x&&!del[y]) q.push(y),del[y]=1;
		}
	}
	return true;
}
int main()
{
	int n=inn(),m=inn(),L=1,R=n,mid=(L+R)>>1;
	rep(i,1,n) rep(j,1,m) a[i][j]=inn(),b[i][a[i][j]]=j;
	while(L<=R)
	{
		if(check(mid,n,m)) R=mid-1;
		else L=mid+1;mid=(L+R)>>1;
	}
	return !printf("%d\n",L);
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll memo[405][405]={0};
vector<ll> black,white;
string s[405];
int h,w;
void dfs(ll x,ll y,ll k){
  int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
  memo[x][y]=k;
  if(s[x][y]=='#') black[k]++;
  else white[k]++;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx>=0&&nx<h&&ny>=0&&ny<w){
      if(s[x][y]!=s[nx][ny]){
        if(memo[nx][ny]==0) dfs(nx,ny,k);
      }
    }
  }

}
int main(){
  ll ans=0;
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>s[i];
  ll cnt=1;
  black.push_back(0);
  white.push_back(0);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(memo[i][j]==0) {
        black.push_back(0);
        white.push_back(0);
        dfs(i,j,cnt);
        cnt++;
      }
    }
  }
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cout<<memo[i][j]<<" ";
    cout<<endl;
  }*/
  for(int i=1;i<black.size();i++) ans+=black[i]*white[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 24192
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    if N > 0 and As[0] != 0:
        return -1
    if N == 0 and As[0] != 1:
        return -1        

    vertices = [1] * (N+1)
    previous = 0
    for i, a in enumerate(As[:0:-1]):
        max_n_vert = a + previous
        previous = max_n_vert
        vertices[N-i] = max_n_vert

    n_not_leaves_prev = 1
    for i, a in enumerate(As):
        if i == 0:
            continue
        # if n_not_leaves_prev == 0:
        #     return -1

        max_n_vert = 2 * n_not_leaves_prev
        vertices[i] = min(vertices[i], max_n_vert)
        n_not_leaves_prev = vertices[i] - a

        if max_n_vert < a:
            return -1

    return sum(vertices)


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 20008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll sum[200000];

int main()
{
	int N, a;
	ll ans = (ll)1e18;

	cin >> N;
	rep(i, N) {
		cin >> a;
		if (i == 0) sum[i] = a;
		else sum[i] = sum[i - 1] + a;
	}

	rep(i, N - 1) {
		ll diff = abs(sum[i] - (sum[N - 1] - sum[i]));
		ans = min(ans, diff);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792