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

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
    auto t = prime_table(55555);
    int n;
    cin >> n;
    for(int i = 2; i <= 55555; i++){
        if(t[i] && i % 5 == 1){
            cout << i << ' ';
            n--;
            if(!n) break;
        } 
    }
}

Measured memory_bytes: 3604
#include<algorithm>
#include<iostream>
#define INF -11111111
using namespace std;
int main(){
  int n;
  int a[5555]; // 配列
  while(1){
    int ret = INF,sum;
    cin >> n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    for(int i=0;i<n;i++){
      sum = 0;
      for(int j=i;j<n;j++){
	sum += a[j];
	ret = max( ret , sum );
      }
    }
    cout << ret << endl;
  }
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n, 0);

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

    vector<int> dp(k + 1, 0);

    for (int i = 0; i <= k; i += 1)
        for (int j = 0; j < n; j += 1)
            if (i - v[j] >= 0 and dp[i - v[j]] == 0)
                dp[i] = 1;

    if (dp[k])
        cout << "First\n";
    else 
        cout << "Second\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> list(n), dis(n);
  for (int i = 0; i < n; i++) {
    cin >> list[i];
  }

  for (int i = 0; i < n - 1; i++) {
    dis[i] = list[i + 1] - list[i];
  }
  dis[n - 1] = k - list[n - 1] + list[0];
  sort(dis.begin(), dis.end());

  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += dis[i];
  }
  cout << ans << endl;
  return 0;

}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<long long>> foo(n + 1, vector<long long>(n + 1));
  vector<vector<long long>> bar(n + 1, vector<long long>(n + 1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < i; ++j) {
      cin >> foo[j][i];
    }
    for (int j = i + 1; j <= n; ++j) {
      cin >> bar[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      foo[i][j] += foo[i - 1][j] + foo[i][j - 1] - foo[i - 1][j - 1];
      bar[i][j] += bar[i - 1][j] + bar[i][j - 1] - bar[i - 1][j - 1];
    }
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 1ll << 60));
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < max(i, 1); ++j) {
      for (int k = i + 1; k <= n; ++k) {
        long long sum_foo = foo[i][n] + foo[j][k] - foo[i][k] - foo[j][n];
        long long sum_bar = bar[k][k] + bar[i][i] - bar[i][k] - bar[k][i];
        dp[k][i] = min(dp[k][i], dp[i][j] + sum_foo + sum_bar);
      }
    }
  }
  cout << *min_element(dp[n].begin(), dp[n].end()) << "\n";
  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

const ll N = 2002;
ll fac[N] = {};
void pre(){
	fac[0] = 1;
	forn(i, 1, N){
		fac[i] = mul(fac[i-1], i);
	}
}

ll C(ll n, ll r){
	return mul(fac[n], mod_inv(mul(fac[n-r], fac[r])));
}


int main(){
	fast;
	pre();
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll n, k;
	cin>>n>>k;
	ll ans = 0;
	forn(i, 0, k){
		if(n-k<i)cout<<0<<endl;
		else{ 
			ll a = C(n-k+1, i+1);
			ll b = C(k-1, i);

			cout<<mul(a, b)<<endl;
		}
	}
}

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

int Gcd(int a,int b){
	return  b == 0 ? a : Gcd(b,a % b);
}

int main(){
	int n; cin >> n;
	long long sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				sum += Gcd(i,Gcd(j,k));
			}
		}
	}

	cout << sum << endl;

}

Measured memory_bytes: 3672
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-21 15:04:55
 */
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

const int N = 1e7 + 105;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");
int main(){
    int n, f = 0, s = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x, y; cin >> x >> y;
        if(x == y) ++s;
        else s = 0;
        f += (s >= 3);
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    // system("pause");
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
using namespace std;
char z[20]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J'}; 
void zhuan(int n,int m){//printf("n:%d m:%d",n,m);
    if(n==0)return;
    else{
        if(n>0||n%m==0){zhuan(n/m,m);printf("%c",z[n%m]);return;}
        else {zhuan(n/m+1,m);printf("%c",z[-m+n%m]); return;}
    }
}
int main(){
    int n,m;
    scanf("%d",&n);
    if(n==0){cout<<0;return 0;}
    m=-2;
    //printf("%d=",n);
    zhuan(n,m);
    //printf("(base%d)",m);
    return 0;
}

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

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split(" ".ToCharArray());
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      
      string result;
      if(a * b % 2 == 0)
      {
        // 偶数
        result = "Even";
      }
      else
      {
        // 奇数
        result = "Odd";
      }
      
      Console.WriteLine(result);
    }
  }
}

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

#define M_PI 3.14159265358979323846
#define DEG_TO_RAD(x) ((x)*M_PI/180)

int main() {
	int a, b, h, m;
	double mrad, hrad;
	cin >> a >> b >> h >> m;
	mrad = DEG_TO_RAD(m * 6);
	hrad = DEG_TO_RAD(h * 30 + m * 0.5);
	cout << fixed << setprecision(10) << sqrt(a*a + b * b - (2 * a*b*cos(abs(hrad - mrad)))) << endl;
	return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = -1;
  stack<int> st;
  vector<bool> used(100, false);
  for (int i = 0; i < N; i++){
    int c;
    cin >> c;
    if (c > 0){
      if (used[c]){
        ans = i + 1;
        break;
      } else {
        st.push(c);
        used[c] = true;
      }
    } else {
      if (st.empty()){
        ans = i + 1;
        break;
      } else if (st.top() + c != 0){
        ans = i + 1;
        break;
      } else {
        st.pop();
        used[-c] = false;
      }
    }
  }
  if (ans == -1){
    cout << "OK" << endl;
  } else {
    cout << ans << endl;
  }
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, sz;
    cin >> n;
    sz = 3 * n;
    vector <ll> a(sz);

    for(int i = 0; i < sz; i++)
        cin >> a[i];

    ll lsum = 0, rsum = 0, ans;
    set <pair<ll, ll> > rs, rem; 
    multiset <ll> ls;

    for(int i = 0; i < n; i++)
    {
        lsum += a[i];
        ls.insert(a[i]);
    }

    for(int i = (2 * n); i < sz; i++)
    {
        rsum += a[i];
        rs.insert({a[i], i});
    }

    for(int i = (2 * n) - 1; i >= n; i--)
    {
        rsum += a[i];
        rs.insert({a[i], i});
        pair<ll, ll> p = *rs.rbegin();
        rs.erase(p);
        rem.insert(p);
        rsum -= p.first;
    }

    ans = lsum - rsum;
    
    for(int i = n; i < (2 * n); i++)
    {
        ls.insert(a[i]);
        ll ln = *ls.begin();
        lsum += a[i];
        lsum -= ln;
        ls.erase(ls.begin());

        if(rs.find({a[i], i}) != rs.end())
        {
            rsum -= a[i];
            rs.erase({a[i], i});
            pair<ll, ll> p = *rem.begin();
            rem.erase(p);
            rs.insert(p);
            rsum += p.first;
        }

        else
        {
            rem.erase({a[i], i});
        }

        ans = max(ans, lsum - rsum);
    }

    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 19840
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int[] nums = new int [3];

        Scanner in = new Scanner(System.in);
        for(int x = 0; x < nums.length; x++){
            nums[x] = in.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(nums[0] + " "+ nums[1] + " " + nums[2]);
    }
}

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

int main() {
    int A,B;
    cin >> A >> B;

    if(A==1) A=14;
    if(B==1) B=14;

    if(A==B)cout << "Draw" << endl;
    else if(A>B) cout << "Alice" << endl;
    else cout << "Bob" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((c+b-1)/b>(a+d-1)/d) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 3592
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = int(rr().replace(' ',''))
print('YNEOS'[a%4!=0::2])









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

int main(){
	long A, B, C, K;
	cin >> A >> B >> C >> K;
	int sum = 0;
	if(K >= A){
		sum = sum + 1 * A;
		K = K - A;
	}else{
		sum = sum + 1 * K;
		K = 0;
	}
	
	if(K >= B){
		K = K- B;
	}else{
		K = 0;
	}
	
	if(K > 0){
		sum = sum - 1 * K;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3160
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=200+10,maxd=10000000+10;
int x[maxn],s[maxd],pri[maxd],r[maxn],a[maxn],b[maxn];
bool bz[maxd],dis[maxn][maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,num,sum,tmp,ans;
void prepare(){
    bz[1]=1;
    fo(i,2,maxd-10){
        if (!bz[i]) pri[++top]=i;
        fo(j,1,top){
            if ((ll)i*pri[j]>maxd-10) break;
            bz[i*pri[j]]=1;
            if (i%pri[j]==0) break;
        }
    }
}
bool dfs(int x){
    int i;
    fo(i,1,sum)
        if (dis[x][i]&&!pd[i]){
            pd[i]=1;
            if (!r[i]||dfs(r[i])){
                r[i]=x;
                return 1;
            }
        }
    return 0;
}
int main(){
    prepare();
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%d",&x[i]);
        s[x[i]]^=1;
    }
    fo(i,1,maxd-9){
        if (s[i]!=s[i-1]){
            if (i%2==1) a[++num]=i;
            else b[++sum]=i;
        }
    }
    fo(i,1,num)
        fo(j,1,sum)
            if (!bz[abs(a[i]-b[j])]) dis[i][j]=1;
    fo(i,1,num){
        fo(j,1,sum) pd[j]=0;
        if (dfs(i)) tmp++;
    }
    ans+=2*((num-tmp)/2);
    ans+=2*((sum-tmp)/2);
    ans+=tmp;
    if (num%2!=tmp%2) ans+=3;
    printf("%d\n",ans);
}

Measured memory_bytes: 53376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int (i) = 0; i < (n); ++(i))
using namespace std;
static const int MAX = 100000;


int N, M;
int H[MAX], A[MAX], B[MAX], C[MAX];
vector<int> D[MAX];

int main(){
    cin >> N >> M;
    int ans = 0;

    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        D[A[i]].push_back(B[i]);
        D[B[i]].push_back(A[i]);
    }
    for(int i = 0; i < N; i++){
        if(C[i] != 0) continue;
        bool flag = true;
        for(int j = 0; j < D[i].size(); j++){
            if(H[i] <= H[D[i][j]]){
                flag = false;
                continue;
            }
            else{
                C[D[i][j]] = 1;
            }
        }
        if(flag)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10284
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, K;
	cin >> N >> K;

	vector<int> V;
	char c = '1';
	int l = 0;
	for (int i = 0; i < N; i++) {
		char tmp; cin >> tmp;
		if (tmp == c) l++;
		else {
			V.push_back(l);
			l = 1;
			c = tmp;
		}
	}
	V.push_back(l);
	V.push_back(0);
	//cout << V.size() << endl;

	if (V.size() / 2 <= K) cout << N << endl;
	else {
		vector<int> W; // 累積和
					   // W[i] : V[0]～V[i]の和
		for (int i = 0; i < V.size(); i++) {
			W.push_back(V[i]);
			if (i != 0)W[i] += W[i - 1];
			//cout << W[i] << " ";
		}

		// Vの2K+1個の区間和の最大の長さ
		int ans = 0;
		for (int i = 0; i <= V.size() - 1 - 2 * K; i += 2) {
			if (i == 0) ans = max(ans,W[i + 2 * K]);
			else ans = max(ans, W[i + 2 * K] - W[i - 1]);
		}
		cout << ans << endl;
	}



	return 0;
}

Measured memory_bytes: 1400
N, M = map(int, input().split())

p = [0] * M
k = [""] * M

for i in range(M):
    p[i], k[i] = input().split()
    p[i] = int(p[i])-1
    

ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
    if k[i] == "WA" and ans[p[i]] == 0:
        pen[p[i]] += 1
    elif k[i] == "AC" and ans[p[i]] == 0:
        pena += pen[p[i]]
        ans[p[i]] = 1
        accept += 1
        
print(str(accept) + " " + str(pena))

Measured memory_bytes: 14836
#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);

int main()
{
    speed;

    string s;
    cin>>s;

    unordered_map<char,int>m;

    for(int i=0;i<s.size();i++) m[s[i]]++;

    int flag=0;
    
    for(auto i : m) 
    {
        if(i.second%2!=0)
        {
            flag=1;
            break;
        }
    }

    if(flag) cout<<"No"<<"\n";
    else cout<<"Yes"<<"\n";
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))

def kouyaku(a, b):
    if a % b == 0:
        return b
    else:
        return kouyaku(b, a % b)
a.sort()
tmpa = a[0]
for i in range(1, n):
    tmpa = kouyaku(tmpa, a[i])
print(tmpa)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define ll long long
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll A[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++) cin>>A[i][j];
  }
  ll N;
  cin>>N;
  ll b[N];
  set<ll> s;
  for(ll i=0;i<N;i++){
    cin>>b[i];
    s.insert(b[i]);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(s.count(A[i][j])) A[i][j]=0;
    }
  }
  for(int i=0;i<3;i++){
    if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
      cout<<"Yes"<<endl;
      return 0;
  }
  if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
# D - Replacing

from collections import defaultdict

N = int(input())
A = list(int(a) for a in input().split())
d = defaultdict(int)
ans = 0
for a in A:
    d[a] += 1
    ans += a

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    tmp = d[b]
    d[b] -= tmp
    d[c] += tmp
    ans += -b*tmp + c*tmp
    print(ans)

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

int main () {
  int ans =0;
  vector<int>a(3);
  cin >> a[0] >> a[1] >> a[2];
 
  while(1) {
    sort(a.begin(), a.end());
    if (a[0] == a[2]) break;
    if (a[0] != a[1]) a[0] += 2;
    else {
      a[0]++;
      a[1]++;
     }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = max(a)
s = collections.Counter(a)
answer = s[0]+s[1]
for i in range(1,b+1):
    result=s[i-1] + s[i] + s[i+1]
    if (answer < result):
        answer = result
print(answer)

Measured memory_bytes: 14564
n,x=map(int,input().split())

a,p=[1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if x==1:
        if n==0:
            return 1
        else:
            return 0
    elif 1<x<=a[n-1]+1:
        return f(n-1,x-1)
    elif x==a[n-1]+2:
        return p[n-1]+1
    elif a[n-1]+2<x<=2*a[n-1]+2:
        return p[n-1]+1+f(n-1,x-a[n-1]-2)
    else:
        return 2*p[n-1]+1

print(f(n,x))

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

int main(){
				int S;
				int h=0,m=0,s=0;
				cin >> S ;
				int i = (h+1) * 60 * 60;
				while(i <= S){
								h += 1;
								i = (h+1) * 60 * 60;
				}
				S = S - h*60*60;
				
				i = (m+1) * 60;
				while(i <= S){
								m += 1;
								i = (m+1) * 60;
				}
				S = S - m*60;

				i = s+1;
				while(i <= S){
								s += 1;
								i = s+1;
				}
				S = S - s;

				cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3084
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

use std::i64;
const M: i64 = i64::MAX;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<i64> = (0..n).map(|_|sc.cin()).collect();
    let mut memo = vec![vec![None; n+1]; n+1];
    let mut stack = vec![(0, n)];
    while let Some((l, r)) = stack.pop() {
        if memo[l][r].is_some() {
            continue;
        }
        if l + 1 >= r {
            memo[l][r] = Some(0);
            continue;
        }
        stack.push((l, r));
        let mut ok = true;
        for i in l+1..r {
            if memo[l][i].is_none() { stack.push((l, i)); ok=false; }
            if memo[i][r].is_none() { stack.push((i, r)); ok=false; }
        }
        if ok {
            let mut mn = M;
            for i in l+1..r {
                mn = min(mn, memo[l][i].unwrap() + memo[i][r].unwrap());
            }
            for i in l..r {
                mn += xs[i];
            }
            memo[l][r] = Some(mn);
        }
    }
    put!(memo[0][n].unwrap());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	vi a(n),b(n);
	REP(i,n)
		a[i]=read();
	REP(i,n)
		b[i]=read();
	int s=accumulate(ALL(a),int(0))-accumulate(ALL(b),int(0));
	if(s<0){
		print(-1);
		return 0;
	}
	vi waf;
	REP(i,n){
		if(a[i]>=b[i])
			waf.PB(a[i]-b[i]);
	}
	sort(ALL(waf));
	int ans=0;
	for(auto w:waf){
		if(s>=w){
			ans++;
			s-=w;
		}
	}
	print(n-ans);
}


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

int main(){
  ll a,b,c,k,x;
  cin >> a >> b >> c >> k;
  x = 0;
  while(a>=b){
    b*=2;
    x++;
  }
  while(b>=c){
    c*=2;
    x++;
  }
  if(k>=x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<pair<int, int> > ans;
	int n = N / 2;
	for(int i = 1; i <= n - 1; ++i) {
		ans.push_back(make_pair(i, i + 1));
		ans.push_back(make_pair(i, 2 * n - i));
		ans.push_back(make_pair(2 * n - (i - 1), 2 * n - i));
		ans.push_back(make_pair(2 * n - (i - 1), i + 1));
	}
	if(N != 4) {
		if(N % 2 == 0) {
			ans.push_back(make_pair(n, 1));
			ans.push_back(make_pair(n, 2 * n));
			ans.push_back(make_pair(n + 1, 1));
			ans.push_back(make_pair(n + 1, 2 * n));
		} else {
			ans.push_back(make_pair(N, 1));
			ans.push_back(make_pair(N, 2 * n));
			if(N != 3) {
				ans.push_back(make_pair(N, n));
				ans.push_back(make_pair(N, n + 1));
			}
		}
	}
	cout << ans.size() << '\n';
	for(int i = 0; i < ans.size(); ++i) {
		cout << ans[i].first << ' ' << ans[i].second << '\n';
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> city(6);
  vector<int> answer(4);
  bool j = false;
  for(int i = 0;i < 6;i++) cin >> city[i];
  sort(city.begin(), city.end());
  for(int i = 1;i <5;i++){
    int num = count(city.begin(), city.end(),i);
    if(num >= 3) j = true;
  }
  if(j == true) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll dp[100005][13];

void solve() {
	string S; cin >> S;
    int N = S.size();

    dp[0][0] = 1;
    for(int i=0; i < N; i++){
        int c = 0;
        if(S[i] == '?') c = -1;
        else c = S[i] - '0';

        for(int j=0; j<10; j++){
            if(c != -1 && c != j) continue;
            rep(k, 13){
                dp[i+1][(k*10 + j)%13] += dp[i][k];
            }
        }
        rep(j, 13) dp[i+1][j] %= mod;
    }

    cout << dp[N][5] << endl;
}

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


Measured memory_bytes: 14800
score_a = Array.new(4)
score_b = Array.new(4)
score_a = gets.split(nil)
sum_a = score_a[0].to_i + score_a[1].to_i + score_a[2].to_i + score_a[3].to_i
score_b = gets.split(nil)
sum_b = score_b[0].to_i + score_b[1].to_i + score_b[2].to_i + score_b[3].to_i
if sum_a <= sum_b
	puts sum_b
else
	puts sum_a
end

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int cmp(string s, string t){
    if(s.size() > t.size()) return 1;
    else if(s.size() < t.size()) return -1;
    else{
        rep(i, s.size()){
            if(s[i] < t[i]) return -1;
            else if(s[i] > t[i]) return 1;
        }
        return 0;
    }
}

int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int a[m];
    rep(i, m) scanf("%d", &a[i]);
    string dp[n+1];
    rep(i, n)if(i == 0 || !dp[i].empty()){
        rep(j, m){
            char c = '0' + a[j];
            if(i+num[a[j]] <= n && cmp(dp[i] + c, dp[i+num[a[j]]]) == 1){
                dp[i+num[a[j]]] = dp[i] + c;
            }
        }
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

struct DisjointSet{
	vector<int> p;
	void init(int n){
		p.resize(n); iota(p.begin(), p.end(), 0);
	}
	int root(int i){
		return p[i] == i ? i : p[i] = root(p[i]);
	}
	void unify(int i, int j){
		int x = root(i), y = root(j);
		if(x==y) return;
		p[x]=y;
	}
} dsu;

vector<vector<ii> > g;
vector<vector<int> > G;
int n, m;

int bfs(){
	queue<int> q;
	vector<int> dist(n+m, -2);
 dist[0] = 0; q.push(0);
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int v: G[u]){
			if(dist[v] == -2 || dist[v] > dist[u]+1){
				dist[v] = dist[u]+1;
				q.push(v);
			}
		}
	}
	return dist[n-1];
}

signed main(){
	cin >> n >> m;
	g.assign(n, vector<ii>());
	for(int i=0; i< m; ++i){
		int u, v, c; cin >> u >> v >> c;
		g[--u].push_back({c, i});
		g[--v].push_back({c, i});
	}
	dsu.init(m);
	G.assign(n+m, vector<int>());
	for(int i=0; i< n; ++i){
		sort(g[i].begin(), g[i].end());
		//unify same node-edges
		for(int j=1; j< g[i].size(); ++j){
			if(g[i][j].first == g[i][j-1].first){
				dsu.unify(g[i][j].second, g[i][j-1].second);
			}
		}
	}
	//add connection from node-node to node-edge
	for(int i=0; i< n; ++i){
		for(ii v : g[i]){
			int r = n + dsu.root(v.second);
			G[r].push_back(i);
			G[i].push_back(r);
		}
	}
	cout << (bfs()/2);
}

Measured memory_bytes: 27648
#include <cstdio>
int n, count = 0;
void dfs(long long nextNum, int flag357) {
	if (nextNum <= n) {
		if (flag357 == 07) {// 07 is BIN 111 3、5、7都包含
			++count;
		}
		dfs(nextNum * 10 + 3, flag357 | 01); // BIN 001 只含3
		dfs(nextNum * 10 + 5, flag357 | 02); // BIN 010 只含5
		dfs(nextNum * 10 + 7, flag357 | 04); // BIN 100 只含7
	}
}
int main() {
	scanf("%d", &n);
	dfs(0, 0);
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans = (ans * i) % (1000000000 + 7);
    }
    cout << ans << endl;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  for(int i = 0; i < h; i++){
    cin >> vec.at(i);
  }
  
  for(int i = -1; i <= h; i++){
    for(int j = -1; j <= w; j++){
      if(i == -1 || i == h || j == -1 || j ==w){
        cout << '#';
      }else{
        cout << vec.at(i).at(j);
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int m,n,q,r,a,i,j,t[100],s;
	for(;scanf("%d%d",&m,&n),m;printf("%d\n",q)){
		for(s=i=q=0;i<n;i++){
			scanf("%d",&a);
			t[i]=a;
			s+=a;
			if(q<a)q=a;
		}
		r=s>1500000?1500000:s;
		for(;q<r;){
			j=m;
			a=q+r>>1;
			s=0;
			for(i=0;i<n;i++){
				s+=t[i];
				if(s>a){
					if(!--j)break;
					s=t[i];
				}
			}
			if(i==n){	r=a;	}
			else{	q=a+1;	}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	void solve(){
		
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		String b = "A";
		
		while(sc.hasNext()){
			String str[] = sc.next().split("\\,");
			String l = str[0];
			String r = str[1];
			if(b.equals(l)){
				b = r;
			}else if(b.equals(r)){
				b = l;
			}
		}
		
		System.out.println(b);
		
		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		io();
	}
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
n, m = map(int,input().split())
ss = [input() for i in range(n)]
a1, a2 = input()
a3, a4 = input()
dic = {"J":0, "O":1, "I":2}
n1, n2, n3, n4 = dic[a1], dic[a2], dic[a3], dic[a4]
fix = [[[0] * m for i in range(n)] for j in range(3)]

ans = 0

for x in range(n - 1):
  for y in range(m - 1):
    b1, b2, b3, b4 = ss[x][y], ss[x][y + 1], ss[x + 1][y], ss[x + 1][y + 1]
    if a1 == b1 and a2 == b2 and a3 == b3 and a4 == b4:
      ans += 1
      for i in range(3):
        if i != n1:
          fix[i][x][y] -= 1
      for i in range(3):
        if i != n2:
          fix[i][x][y + 1] -= 1
      for i in range(3):
        if i != n3:
          fix[i][x + 1][y] -= 1
      for i in range(3):
        if i != n4:
          fix[i][x + 1][y + 1] -= 1
 
    elif not (a1 == b1) and a2 == b2 and a3 == b3 and a4 == b4:
      fix[n1][x][y] += 1
    elif a1 == b1 and not (a2 == b2) and a3 == b3 and a4 == b4:
      fix[n2][x][y + 1] += 1
    elif a1 == b1 and a2 == b2 and not (a3 == b3) and a4 == b4:
      fix[n3][x + 1][y] += 1
    elif a1 == b1 and a2 == b2 and a3 == b3 and not (a4 == b4):
      fix[n4][x + 1][y + 1] += 1

rec = 0
for i in range(3):
  for x in range(n):
    for y in range(m):
      if fix[i][x][y] > rec:
        rec = fix[i][x][y]

print(ans + rec)


Measured memory_bytes: 30368
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (char c : s)
		sum += c - '0';
	if(sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

#define y0 kyuridenamida
#define y1 kyuridenanmaida

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}


template<class T>
T pow(T x, ll n) {
    T r = 1;
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    const ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    const ModInt operator-(const ModInt &r) const {return make(normS(v+normS(MD-r.v)));}
    const ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};

// ここまでテンプレ

using Mint = ModInt<TEN(9)+7>;
const int MN = 2*5050;

Mint p2[MN];
Mint fact[MN], iFac[MN];
void first() {
    p2[0] = 1;
    for (int i = 1; i < MN; i++) {
        p2[i] = p2[i-1]*2;
    }
    fact[0] = 1;
    for (int i = 1; i < MN; i++) {
        fact[i] = fact[i-1]*i;
    }
    iFac[MN-1] = Mint::inv(fact[MN-1]);
    for (int i = MN-1; i >= 1; i--) {
        iFac[i-1] = iFac[i]*i;
    }
}

Mint C(int x, int y) {
    return fact[x]*iFac[y]*iFac[x-y];
}
Mint K(int x, int y) {
    //(0, 0)から(x, y)へ移動する経路数
    if (x < 0 or y < 0) return 0;
    return C(x+y, x);
}

Mint K(int x0, int y0, int x1, int y1) {
    //(x0, y0)から(x1, y1)へx<yを通らずに移動する経路数
    int x2 = y1-1, y2 = x1+1;
    return K(x1-x0, y1-y0) - K(x2-x0, y2-y0);
}

Mint calc(int N, int M) {
    //(0, -M)から(N-i, -M+i)へ
    Mint ans = 0;
    for (int i = 0; i <= N; i++) {
        if (N-i < -M+i) break;
        ans += K(0, -M, N-i, -M+i) * p2[i];
    }
    return ans;
}

int main() {
    first();
    int N;
    string s;
    cin >> N >> s;
    int M = (int)s.size();
    Mint ans = calc(N, M) - calc(N, M-1);
    ans *= pow(Mint::inv(2), M);
    cout << ans.v << endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;

    return 0;
}

Measured memory_bytes: 3620
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, k: u64
    }
    if (n-1)*(n-2)/2 >= k {
        let mut delta = (n-1)*(n-2)/2 - k;
        let mut edges = vec![];
        for i in 1..n {
            edges.push((0, i));
        }
        for i in 1..n {
            for j in i+1..n {
                if delta == 0 {
                    break;
                } else {
                    edges.push((i, j));
                    delta -= 1;
                }
            }
        }
        println!("{}", edges.len());
        for (p, q) in edges {
            println!("{} {}", p+1, q+1);
        }
    } else {
        println!("-1");
    } 
}

Measured memory_bytes: 4352
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n; cin >> n;
	ll a[n]; parseArray(a, n);
	bool vis[n + 1]; memset(vis, 0, sizeof vis);
	ll ans = 0;
	for ( int k = 0; k < n; k++ ){
		if (a[k] == 1)
			vis[1] = 1, ans = max(ans, 1ll);
		else if (vis[a[k] - 1])
			vis[a[k]] = 1, ans = max(ans, a[k]);
	}
	if (ans == 0)
		cout << -1 << endl;
	else
		cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 2048
import sys

read = sys.stdin.buffer.read
INF = 1 << 60


def main():
    H, N, *AB = map(int, read().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

    for a, b in zip(*[iter(AB)] * 2):
        for i in range(H + 1):
            dp[i] = min(dp[i], dp[max(i - a, 0)] + b)

    print(dp[H])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 68204
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii < (ll)(ee); ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
ll a,b,c;
int main(){
	FAST
	ll n;cin>>n;ll ans=0;
	FOR(i,1,n+1) {
		if( ((ll)log10(i) + 1) & 1) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    long long n,k;
    cin>>n>>k;
    long long num=0;
    if(k==0)num=n*n;
    else
    {
        for(int b=k+1;b<=n;b++)
        {
            num+=(n/b)*(b-k);
            if(n%b>=k)num+=n%b-k+1;
        }
    }
    printf("%lld\n",num);
    return 0;
}


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

int main(void){
	int x;
	int y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;
		if(x <= y){
			printf("%d %d\n", x, y);
		}else if(x > y){
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  bool flag=true;
  for(int i=0;i<N-1;i++){
    if(p.at(i)>p.at(i+1)){
      flag=false;
      break;
    }
  }

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int tmp=p.at(i);
      p.at(i)=p.at(j);
      p.at(j)=tmp;
      bool sub=true;
      for(int k=0;k<N-1;k++){
        if(p.at(k)>p.at(k+1)){
          sub=false;
          break;
        }
      }
      if(sub){
        flag=true;
      }
      if(flag){
        break;
      }
      tmp=p.at(i);
      p.at(i)=p.at(j);
      p.at(j)=tmp;
    }
    if(flag){
      break;
    }
  }
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define MOD 1000000007
#define int long long
#define N 100005
signed main()
{
    int n;
    cin>>n;
    int i;
    int a[n+1];
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    map <int,int> mp;
    for(i=1;i<=n;i++)
    {
        mp[a[i]]=i;
    }
    map <int,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
        cout<<it->second<<" ";
    }
    //cout<<cnt<<endl;
}

Measured memory_bytes: 7808
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    ll n,m;
    cin>>n>>m;
    V<ll> a(n);
    cinf(n,a);
    sort(all(a));
    ll left=0,right=1e18+1;
    while(right-left>1){
        ll mid=(right+left)/2;
        ll cnt=0;
        for(ll i=0;i<n;i++){
            ll u=lb(all(a),mid-a[i])-a.begin();
            cnt+=n-u;
        }
        if(cnt>=m) left=mid;
        else right=mid;
    }
    V<ll> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+a[i];
    ll ans=0;
    ll cnt=0;
    for(ll i=0;i<n;i++){
        ll u=ub(all(a),left-a[i])-a.begin();
        ans+=(n-u)*a[i]+s[n]-s[u];
        cnt+=n-u;
    }
    ans+=(m-cnt)*left;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792