akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

bool month(int a) {
    return (1<=a&&a<=12) ? true : false;
}

string s;

void solve()
{
    cin >> s;
    int k, t;
    k = (s[0]-'0')*10 + (s[1]-'0');
    t = (s[2]-'0')*10 + (s[3]-'0');
    //nout(k);nout(t);
    if (month(k)&&month(t)) nout("AMBIGUOUS");
    else if (month(k)) nout("MMYY");
    else if (month(t)) nout("YYMM");
    else nout("NA");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
int ncr(int n, int k) 
{ 
    int res = 1; 
    if(k>n) return 0;
    if (k > n - k) 
        k = n - k; 
    for (int i = 0; i < k; ++i) { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
    return res; 
} 
signed main()
{
    fasino
    int n,m;
    cin>>n>>m;
    cout<<ncr(n,2) + ncr(m,2);
    return 0;
}

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

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];

    private T Convert<T>(string s)
    {
        return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(s);
    }

    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public T Next<T>()
    {
        return Convert<T>(Next());
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public T[] Array<T>()
    {
        var l = StringArray();
        var res = new T[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = Convert<T>(l[i]);
        }
        return res;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}

class Program
{
    private int M;
    private void Scan()
    {
        var sc = new Scanner();
        M = sc.NextInt();
    }


    public void Solve()
    {
        Scan();
        Console.WriteLine(48 - M);
    }

    static void Main(string[] args)
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 11092
# import re


def main():
    s = input()

    print(s.rfind('Z') - s.find('A') + 1)

    # regex = re.compile(r'A*Z')
    # 
    # match_list_len = list(map(len, regex.findall(s)))
    # print(max(match_list_len))


if __name__ == "__main__":

    main()


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = 0;
    for (auto n : A) {
        while (n%2 == 0) {
            ans++;
            n/=2;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int main(){
  
  int i;
  char s[100],t[100];
  
  scanf("%s",s);
  scanf("%s",t);
  
  for(i = 0; s[i] != '\0'; i++){
    if(s[i] != t[i]){
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  
  return 0;
        
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ll x;
  cin >> x;
  for (ll i = -1000; i <= 1000; ++i) {
    for (ll j = -1000; j <= 1000; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x;
    cin >> x;
    int p = 0;
    REP(i,100000){
        p += i;
        if (p >= x){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long


int main()
{
    double r;
    cin>>r;
    double pi=3.14159;
    double k=(2*pi*r);
    cout<<k;
}

Measured memory_bytes: 3784
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    s = list(input().strip())
    t = list(input().strip())
    s.sort()
    t.sort(reverse=True)

    min_len = min(len(s), len(t))
    same = True
    for i in range(min_len):
        if s[i] < t[i]:
            print("Yes")
            return
        if s[i] != t[i]:
            same = False
    if same and len(s) < len(t):
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	int count = 0;
	for (int i = 0; i <= n - 1; i++)
	{
		int min = i;
		int j;
		for (j = i; j <= n - 1; j++)
			if (A[j] < A[min])
				min = j;
		if (min != i)
		{
			swap(A[i], A[min]);
			count++;
		}
	}
	for (int i = 0; i < n; i++)
		if (i != n - 1)
			cout << A[i] << " ";
		else
			cout << A[i] << endl;
	cout << count << endl;
	delete[] A;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <limits.h>
#define N 100

void matrixChainOrder(int, int *);
int min(int, int);

int M[N + 1][N + 1];

int main()
{

    int n;
    int P[N + 1];
    int i;

    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        scanf("%d%d", &P[i - 1], &P[i]);
    }
    //printf("\n");
    for (i = 0; i <= n; i++)
    {
        //  printf("%d ",P[i]);
    }

    matrixChainOrder(n, P);
    //printf("\n");
    printf("%d\n", M[1][n]);

    return 0;
}

void matrixChainOrder(int n, int *p)
{
    int i, l, k, q, j;
    int INF = INT_MAX;
    //n = n -1;//p.length -1

    for (i = 1; i < n; i++)
    {
        M[i][i] = 0;
    }

    for (l = 2; l <= n; l++)
    {
        for (i = 1; i <= n - l + 1; i++)
        {
            j = i + l - 1;
            M[i][j] = INF;

            for (k = i; k <= j - 1; k++)
            {
                q = M[i][k] + M[k + 1][j] + p[i - 1] * p[k] * p[j];
                M[i][j] = min(M[i][j], q);
            }
        }
    }
}

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



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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> n(3);
    REP(i,3) cin>>n[i];
    sort(all(n));
    cout<<(int)n[0]<<" ";
    cout<<(int)n[1]<<" ";
    cout<<(int)n[2]<<endl;
return 0;
}


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

int main(int argc, char const *argv[])
{
	int N,K;
	cin>>N>>K;
	int price[N];
	for(int i=0; i<N; i++)
		cin>>price[i];
	sort(price,price+N);
	int ans=0;
	for(int i=0; i<K; i++)
		ans += price[i];

	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int32_t main(){
    SPEED;
    string t;
    cin >> t;
    int sum = 0;
    for(char c: t){
        sum += c - '0';
    }
    if(sum % 9 == 0) cout <<"Yes" ;
    else cout << "No" ;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 1e6+3;

int main() {
    Int p, q, r;
    cin >> p >> q >> r;
    dump(min({p + q, q + r, r + p}));
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

(h, w) = gets.chomp.split(/ /).map(&:to_i)

bord = []
h.times do
  bord << gets.chomp
end


def del_dot(bord)
  nbord = []
  bord.each do |b|
    if b =~ /#/
      nbord << b.split(//)
    end
  end
  return nbord
end

def turn_bord(bord)
  turnd = []
  s = bord.size #5
  ss = bord[0].size #3

  ss.times do |i|
    str = ''
    bord.each do |b|
      str += b[i]
    end
    turnd[i] = str
  end

  return turnd
end

nbord = del_dot(bord)
tbord = turn_bord(nbord)
resbord = del_dot(tbord)
final_res = turn_bord(turn_bord(turn_bord(resbord)))

final_res.each do |f|
  puts f
end


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 1299710;

int prime[MAX_N];
bool is_prime[MAX_N];

int sieve(int n)
{
	int p = 0;
	for(int i=0;i<=n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<=n;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve(MAX_N-1);
    vector<int> vec;
    rep(i,MAX_N){
        if(is_prime[i]){
            vec.pb(i);
        }
    }
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        if(is_prime[n]){
            cout << "0\n";
        }else{
            int id = lower_bound(all(vec),n) - vec.begin();
            cout << vec[id] - vec[id-1] << endl;
        }
    }
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n, ans = 0, W;
        cin >> n >> W;
        ll v[n], w[n];
        for(int i = 0 ; i < n ; i++){
            cin >> w[i] >> v[i];
        }
        ll a[n + 1][W + 1];
        for(int i = 0; i <= W; i++)
            a[0][i] = 0;
        for(int i = 0; i <= n; i++)
            a[i][0] = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= W; j++){
                if(j >= w[i - 1])
                    a[i][j] = max(a[i - 1][j], a[i -1][j - w[i- 1]] + v[i - 1]);
                else
                    a[i][j] = a[i - 1][j];
            }
        }
       cout << a[n][W] <<endl;
    }
    return 0;
}

Measured memory_bytes: 82472
def main():

    S = input()
    memo = dict()
    n = len(S)

    def recursive(S, i, j):

        v = 0
        if j < i: return v
        if (i, j) in memo: return memo[(i, j)]
        # if n == 1: return int(S)
        for k in range(i, j+1):
            if j - k < 1:
                v += int(S[i:k+1])
            else:
                v += int(S[i:k+1])*pow(2, j-k-1) + recursive(S, k+1, j)
        memo[(i, j)] = v
        return memo[(i, j)]

    ans = recursive(S, 0, n-1)

    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,x,d;
int f(int y){
  int mx=(n-y+n-1)*y/2;
  int mn=y*(y-1)/2;
  return mx-mn+1;
}
int g(int y,int a){
  int l1=((n-y)+(n-1))*y/2,
      l2=y*(y-1)/2,
      r1=((n-y-a*d)+(n-1))*(y+a*d)/2+a*x,
      r2=(y+a*d)*(y+a*d-1)/2+a*x;
  return max(min(l1,r1)-max(l2,r2)+1,0LL);
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  cin>>n>>x>>d;
  if(!d&&!x)fin(1);
  if(!d)fin(n+1);
  if(!x)fin(n*(n-1)/2+1);
  if(x<0)x*=-1,d*=-1;
  int gcd=__gcd(x,abs(d));x/=gcd;d/=gcd;

  int ans=0;
  for(int i=0;i<=n;i++)ans+=f(i);

  vector<int> l(n),r(n);
  for(int i=0;i<=n;i++){
    for(int a=1;a<=1;a++){
      if(i+a*d>n||i+a*d<0)break;
      ans-=g(i,a);
      //cout<<i<<" "<<a<<" "<<g(i,a)<<endl;
    }
  }
  fin(ans);
}


Measured memory_bytes: 3328
s, t  = map(int, input().split())
u = list(map(int,input().split()))
ans = t
for i in range(1,s):
    if u[i] - u[i -1] >= t:
        ans += t
    if u[i] - u[i - 1] < t:
        ans += u[i] - u[i - 1]
print(ans)

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

struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) { }
};

void dfs(vector<vector<Edge>> &G, vector<int> &color, int v, int cur = 0) {
  color[v] = cur;
  for (auto next_v : G[v]) {
    if (color[next_v.to] != -1) continue;
    if (next_v.weight % 2) dfs(G, color, next_v.to, 1 - cur);
    else dfs(G, color, next_v.to, cur);
  }
  return;
}

int main() {
  int N;
  cin >> N;
  vector<vector<Edge>> G(N);
  rep(i, N) {
    int u, v, w;
    cin >> u >> v >> w;
    G[u-1].push_back(Edge(v-1, w));
    G[v-1].push_back(Edge(u-1, w));
  }
  
  vector<int> color(N, -1);
  rep(v, N) {
    if (color[v] != -1) continue;
    dfs(G, color, v);
  }
  rep(i, N) cout << color[i] << endl;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
vector<bool> v(1000000,false);
int f(int n){
    if(n%2 ==0) return n/2;
    else return 3*n + 1;    
}
int main(){
    int s,m,ans=0;
    cin >> s;
    v[s] = true;
    int a = s;
    for(int i=2; ;i++){
        int m = f(a);
        if(v[m]){ 
            ans = i;
            break;
        }
        v[m] = true;
        a = m;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include<iostream>
#define ll long long

int main(){
std::string s;
  std::cin >> s;
  ll t=0,ind=0;
  for(int i=0;i<(ll)s.length();i++){
    if(s[i]=='W'){
        t+=i-ind;
        ind++;
    }
}
  std::cout << t << std::endl;
return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
using namespace std;
int a[10];
string s;
long long ans=0;
void check()
{
	long long num=0;
	num=s[0]-'0';
	for(int i=0;i<s.size()-1;i++)
	{		
		if(a[i])
		{
			ans+=num;
			num=0;
		}
		num=num*10+s[i+1]-'0';				
	}
	ans+=num;
}
void dfs(int x)
{
	if(x==s.size()-1)
	{
		check();
		return;
	}
	a[x]=0;
	dfs(x+1);
	a[x]=1;
	dfs(x+1);
}
int main()
{
	cin>>s;
	dfs(0);
	cout<<ans;
	return 0;
}

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

using namespace std;

int a[111111];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	int l = 0, r = n - 1;
	long s = abs(a[l] - a[r]);
	while (r - l > 1) {
		if (r - l > 2) {
			s += abs(a[l + 1] - a[r]);
			s += abs(a[l] - a[r - 1]);
			l++, r--;
			continue;
		}
		s += max(abs(a[l + 1] - a[r]), abs(a[l] - a[r - 1]));
		l++;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
  char c;

  scanf("%c", &c);

  if(c >= 'a' && c<= 'z'){
    printf("a\n");
  }
  else if(c >= 'A' && c <= 'Z'){
    printf("A\n");
  }

  return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    vint nums(100001, 0);
    ll N;
    cin >> N;
    ll sum = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        nums[a]++;
        sum += a;
    }

    ll Q;
    cin >> Q;
    rep(i, Q) {
        ll b, c;
        cin >> b >> c;
        int bnum = nums[b];
        sum = sum - (bnum*b) + (bnum*c);
        cout << sum << endl;
        nums[c] += bnum;
        nums[b] = 0;
    }
}

Measured memory_bytes: 3696
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: a,v,b,w,t

    read*, a,v
    read*, b,w
    read*, t

    if (t*v >= abs(b-a)+w*t) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
end program main

Measured memory_bytes: 2868
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

long long getKoyaku(long long a , long long b){
  long long r, tmp;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
  //printf("最大公約数 = %d\n", b);
  return b;
}

int main(){

    int N;
    cin >> N;
    vector<int> val;

    int tmp;

    
    int count=0;
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> tmp;
        count+=tmp-1;
        val.push_back(tmp);

    }
    cout << count;
    /*
    sort(val.begin(),val.end());

    long long kobai = 1;
    for( int ni = 0 ; ni < N ; ni++ ){
        kobai = kobai * val[ni] / getKoyaku(kobai,val[ni]);
    }

    long long ans = 0;
    for( int ni = 0 ; ni < N ; ni++ ){
        ans += (kobai - 1) % val[ni];
    }

    cout << ans << endl;
    */
}

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

#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
int sum[11][2000];

int get(int a, int b, int c, int d){
    int ans = 0;
    for (int i = a; i <= c; i++){
        ans += sum[i][d] - (b ? sum[i][b-1] : 0);
    }
    return ans;
}

int calc(int c1, int c2){
    int prev = 0;
    int tot = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        int tmp = get(i, c1, i, c2);
        if (tmp > k) {
            return 1e18;
        }
        if (tot + tmp > k){
            if (prev == i) return 1e18;
            tot = tmp;
            prev = i;
            ans++;
        } else {
            tot += tmp;
        }
    }
    return ans;
}

int solve(int st, int en) {
    if (en == m-1){
        return calc(st, en);
    }
    int ans = min(solve(st, en+1), 1 + calc(st, en) + solve(en+1, en+1));
    return ans;
}

integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> k;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char c;
            cin >> c;
            ar[i] = c - '0';
            sum[i][j] = ar[i];
            if (j){
                sum[i][j] += sum[i][j-1];
            }
        }
    }
    int best = 1e18;
    for (int i = 0; i < (1 << (n-1)); i++){
        vector<pair<int, int>> v;
        int cur = 0;
        for (int j = 0; j < n-1; j++){
            if ((1 << j) & i){
                v.push_back({cur, j});
                cur = j+1;
            }
        }
        if (!v.empty())
            v.push_back({v.back().second+1, n-1});
        else
            v.push_back({0, n-1});

        int ans = v.size() - 1;
        int st = 0;
        for (int l = 0; l < m; l++){
            for (int j = 0; j < v.size(); j++){
                int c1 = st, c2 = l;
                int r1 = v[j].first, r2 = v[j].second;
                int tmp = get(r1, c1, r2, c2);
                if (tmp > k && st == l){
                    goto here;
                } else if (tmp > k){
                    ans++;
                    st = l;
                }
            }
        }
        best = min(best, ans);
        here:
        int z;
    }
    cout << best << endl;

//    cout << solve(0, 0) << endl;

}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 21;
const int mod = 1e9 + 7;
bool arr[maxn][maxn];
int dp[1<<21][maxn + 5] = {};

main() {
	IOS
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> arr[i][j];
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < (1<<n); i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1<<j)) cnt++;
		}
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) {
				if (arr[j][cnt]) {
					dp[i | (1<<j)][cnt+1] += dp[i][cnt];
					dp[i | (1<<j)][cnt+1] %= mod;
				}
			}
		}
	}
	cout << dp[(1<<n)-1][n] << "\n";
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

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

    string T;
    
    cin >> T;

    string ans = "";

    for(char c : T){
        if(c == '?'){
            ans += 'D';
        }else{
            ans += c;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3888
import sys
 
l, r = map(int, input().split())
ans = 10 ** 10
for i in range(l, r):
  for j in range(i+1, r+1):
    if (i * j) % 2019 == 0:
      print(0)
      sys.exit()
    ans = min(ans, (i*j) % 2019)
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    double ans = 0;
    rep(i, 1, n) {
        double cur = 1.0;
        int x = i;
        while(x < k) {
            cur *= .5;
            x <<= 1;
        }
        ans += cur;
    }
    ans /= n;
    cout << fixed << setprecision(13) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   char s[200001],t[200001];
   int i,m,bl[200001];
   long n;
    
   scanf("%s",s);
   for (i=m=0;s[i]!='\0';)
      if (s[i]=='A') {
         t[m++]='A';
         i++;
      } else if (s[i]=='B' && s[i+1]=='C') {
         if (t[m-1]=='B') bl[m-1]++;
         else {
            bl[m]=1;
            t[m++]='B';
         }
         i+=2;
      } else {
         if (t[m-1]!='X') t[m++]='X';
         i++;
      }
   t[m]='\0';
   n=0;
   for (i=m-1;i>=0;i--)
      if (t[i]=='A' && t[i+1]=='B') {
         n+=bl[i+1];
         if (i>0 && t[i-1]=='B')
            bl[i-1]+=bl[i+1];
         else {
           t[i]='B';
           bl[i]=bl[i+1];
         }
      }
   printf("%ld\n",n);
   return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n;
	cin>>n;
	int sum=1;
	for(int i=2;i<=n;i++)
	{
		if(i%3==0 || i%5==0 || (i%15==0))
		continue;
		else
		{
			sum+=i;
		}
	}
	cout<<sum<<endl;
	
	return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if((a>=1 && a<=9) && (b>=1 && b<=9))
    {
        cout << a*b << endl;
    }
    else
    {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=4005,MOD=924844033;
long long n,k;
long long f[MAXN][MAXN][2];
long long vis[MAXN][2];
long long g[MAXN];
long long ed[MAXN];
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
long long jc[MAXN];
long long Inv[MAXN];
void Init()
{
	jc[0]=1;
	for(long long i=1;i<MAXN;i++)
		jc[i]=(jc[i-1]*i)%MOD;
	Inv[MAXN-1]=ksm(jc[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=1;i--)
		Inv[i]=(Inv[i+1]*(i+1))%MOD;
}
int main()
{
	//freopen("captain.in","r",stdin);
	//freopen("captain.out","w",stdout);
	Init();
	scanf("%lld %lld",&n,&k);
	long long tot=0;
	for(long long i=1;i<=n;i++)
	{
		for(long long j=0;j<=1;j++)
		{
			if(vis[i][j])
				continue;
			long long len=0;
			for(long long x=i,y=j;x<=n;x+=k,y^=1)
			{
				vis[x][y]=1;
				len++;
			}
			ed[tot+=len]=1;
		}
	}
	ed[0]=1;
	f[1][0][0]=1;
	for(long long i=1;i<=tot;i++)
	{
		for(long long j=0;j<=n;j++)
		{
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%MOD;
			if(!ed[i])
				f[i+1][j+1][1]=f[i][j][0];
		}
	}
	for(long long i=0;i<=n;i++)
		g[i]=(f[tot][i][0]+f[tot][i][1])%MOD;
	long long ans=jc[n];
    for(long long i=1,j=-1;i<=n;i++,j*=-1)
        ans=((ans+((j*jc[n-i])%MOD*g[i])%MOD)%MOD+MOD)%MOD;
	printf("%lld\n",ans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 249472
#include<stdio.h>

int main()
{
    char s[7];
   // scanf("%d%d%d",&a,&b,&c);
    scanf("%s",s);
    if(s[2]==s[3] && s[4]==s[5])
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}



Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
  //charで読み込むのが間違い
  int y, m, d;
  int ans;

  scanf("%d/%d/%d",&y,&m,&d);

  if(y>=2019 && m >=5)
  {
      printf("TBD\n");
  }
  else
  {
    printf("Heisei\n");
  }

  return 0;
}

Measured memory_bytes: 128
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(S):
    if S[-1] == 's':
        print(S + 'es')
    else:
        print(S + 's')


if __name__ == '__main__':
    S = input()
    # N = int(input())
    # N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(S)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9016
N = gets.to_i
s = N.to_s.chars
if s.size <= 2
  puts 'No'
  exit 0
end
if s.size == 3
  puts(s.uniq.size == 1 ? 'Yes' : 'No')
else
  puts(s[0..2].uniq.size == 1 || s[1..3].uniq.size == 1 ? 'Yes' : 'No')
end


Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include <cstdio> 
#include<string>
using namespace std;
/*
int main(void)
{      
	int botto[10];
	string inp;
	while(cin>>inp){
		for(int i=0;i<10;i++){
			botto[i]=inp[i]-'0';         
		}         
		for(int i=0;i<10-1;i++){
			for(int j=0;j<10-i-1;j++){
				botto[j]=(botto[j]+botto[j+1])%10;
			}        
		}         
		cout<<botto[0]<<endl;     
	}       
	return 0; 
} 
*/

int main(void)
{
	int n[11]={};
string s;
char ch;
while(cin>>s)
{
for(int i=0;i<10;i++)
{
	
n[i]=s[i]-'0';
}
for(int k=0;k<10;k++)
for(int i=0;i<10-k-1;i++)
n[i]=(n[i]+n[i+1])%10;

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n;
ll dd[]={-1,0,1,0,-1};
vector<P> res;
ll tot;

bool valid(ll i,ll j){
  return i>=0&&i<n&&j>=0&&j<n;
}

int main(){
  cin>>n;
  rep(i,n)rep(j,n){
    if((i+j)%2==0)continue;
    tot++;
  }
  UnionFind uf(n*n);
  rep(hoge,7){
    rep(i,n)rep(j,n){
      if((i+j)%2==0)continue;
      bool ok=true;
      ll cnt=0;
      rep(d1,4)repl(d2,d1+1,4){
        ll ni1=i+dd[d1],nj1=j+dd[d1+1];
        ll ni2=i+dd[d2],nj2=j+dd[d2+1];
        if(!valid(ni1,nj1)||!valid(ni2,nj2)||(ni1==ni2&&nj1==nj2))continue;
        if(!uf.same(ni1*n+nj1,ni2*n+nj2))cnt++;
      }
      if(cnt>=7-hoge){
        res.push_back(P(i,j));
        rep(d1,4)rep(d2,4){
          ll ni1=i+dd[d1],nj1=j+dd[d1+1];
          ll ni2=i+dd[d2],nj2=j+dd[d2+1];
          if(!valid(ni1,nj1)||!valid(ni2,nj2))continue;
          uf.unite(ni1*n+nj1,ni2*n+nj2);
        }
      }
    }
  }
  printf("%lld\n", (ll)res.size());
  rep(i,res.size())printf("%lld %lld\n", res[i].se,res[i].fi);
  return 0;
}


Measured memory_bytes: 10096
#include <iostream>
#include <cstdio>
#include <map>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

int m, d;

// functions
void input(){
	cin >> m >> d;
	return;
}

void solve(){
	int cnt=0;
	for(int i=2; i<=9; i++){
		for(int j=2; j<=9; j++){
			if(i*j<=m && 10*i+j<=d){
				cnt++;
			}
		}
	}
	cout << cnt;
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
//#ifdef sheeep
//	freopen("forces.inp", "r", stdin);
//	freopen("forces.out", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro



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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    ll x;cin>>x;
    ll ans = 0;
    ans+=(1000)*(x/500);
    x-=(500)*(x/500);
    ans+=(5)*(x/5);
    cout<<ans;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3572
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        final int n_max = 999999;
        boolean hurui[] = new boolean[n_max+1];
        for(int i=0;i<=n_max;i++) {
            hurui[i] = true;
        }
        for(int i=2;i<n_max+1;i++){
            if(hurui[i]){
                for(int j = i*2; j < n_max+1; j+=i){
                    hurui[j]=false;
                }
            }
        }
        int sum[] = new int[1000000];
        sum[2]=1;
        for(int i=3;i<1000000;i++)
            sum[i]=sum[i-1]+((hurui[i])?1:0);
       
        Scanner scaned = new Scanner(System.in);
        while(scaned.hasNextInt()) {
            int end = scaned.nextInt();
            System.out.println(sum[end]);
        }
    }
}

Measured memory_bytes: 31552
#include<bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
#define rep(i,n) for(Bint i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  Bint x;cin>>x;
  rep(i,10000000){
    Bint now=i*i*i*i*i-x;
    Bint l=-10000000;
    Bint h=10000000;
    
    while(h>l){
      Bint no=(l+h)/2;
      if(no*no*no*no*no>now){
        if(h==no) break;
        h=no;
      }
      else{
        if(l==no) break;
        l=no;
      }
    }
    //cout<<l<<" "<<h<<endl;
    if(l*l*l*l*l==now){
      cout<<i<<" "<<l<<endl;
      break;
    }
    if(h*h*h*h*h==now){
      cout<<i<<" "<<h<<endl;
      break;
    }
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    long double L;
    cin >> L;
    long double a = L / 3.0;
    cout << a * a * a << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
var
 n,i,x,s:longint;
 a:array[0..100003] of longint;
begin
 readln(n);
 for i:=1 to n do
  begin
   read(x);
   if x>n then inc(s)
    else inc(a[x]);
  end;
 for i:=1 to n do
  if a[i]<>0 then
   if a[i]<i then s:=s+a[i]
    else if a[i]>i then s:=s+a[i]-i;
 writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include "stdio.h"

int main(int argc, char *argv[]){
  char str[14];
  scanf("%s",str);
  int i;
  for(i=13;i>4;--i){
    str[i] = str[i-1];
  }
  str[4] = ' ';
  printf("%s\n",str);
  return 0;
}

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

using namespace std;

int main() {
	long long n;
	cin >> n;
	
	vector<long long> v(n);
	long long result = 0;
	for (long long i = 0; i < n; ++i) {
		cin >> v[i];
		v[i] -= i + 1;
		result += abs(v[i]);
	}
	
	sort(v.begin(), v.end());
	
	long long fix = 0;
	if (n % 2) {
		fix = v[n / 2];
	} else {
		fix = (v[n / 2 - 1] + v[n / 2]) / 2;
	}
	
	if (result && fix) {
		result = 0;
		for (long long i = 0; i < n; ++i) {
			result += (abs(v[i] - fix));
		}
	}
	
	cout << result << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+5; 
int a[N],b[N];
LL s[N];
int main(){
	LL n,ans=0;int x,m,si=0;scanf("%lld%d%d",&n,&x,&m);
	while(!b[x])b[x]=++si,a[si]=x,s[si]=s[si-1]+x,x=1ll*x*x%m;
	if(n<=b[x])return printf("%lld",s[n]),0;
	ans+=s[b[x]-1],n-=b[x]-1;
	ans+=(n/(si-b[x]+1))*(s[si]-s[b[x]-1]);
	ans+=s[b[x]+n%(si-b[x]+1)-1]-s[b[x]-1];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4648
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	while(1){
		bool c=false;
		if(!(a|b))return 0;
		for(int i=a;i<=b;i++){
			if(i%400==0){
				c=true;
				printf("%d\n",i);
			}else if(i%100==0);
			else if(i%4==0){
				c=true;
				printf("%d\n",i);
			}
		}
		if(!c)printf("NA\n");
		scanf("%d%d",&a,&b);
		if(a|b)printf("\n");
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){

  int a[4]={0};
  int b[4]={0};
  int suma=0,sumb=0;

  scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
  scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);

  for(int i=0;i<4;i++){
    suma+=a[i];
    sumb+=b[i];
  }

  if(suma<=sumb){
    printf("%d\n",sumb);
  }
  else {
    printf("%d\n",suma);
  }

  return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
int main(void) {
    int i, j, k, l;
    int H, W, cnt;
    char S[51][51];
    scanf("%d %d%*c", &H, &W);
    for (i = 0; i < H; i++) scanf("%s", S[i]);
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                cnt = 0;
                for (k = -1; k <= 1; k++) {
                    for (l = -1; l <= 1; l++) {
                        if (S[i+k][j+l] == '#') cnt++;
                    }
                }
                printf("%d", cnt);
            }
            else printf("#");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
//In the name of ALLAH

#include<bits/stdc++.h>
using namespace std;
#define nn '\n'
#define pb push_back
#define F(i, n) for(int i = 0; i < n; ++i)
#define Fe(i, n) for(auto i: n)
#define  ll long long int





int main(){

	int n; cin>>n;
	int arr[2 * n];
	F(i, 2 * n) cin>>arr[i];
	sort(arr, arr + 2 * n);
	int tot = 0;

	//F(i, 2 * n)
	for(int i = 0; i <2 * n; i += 2){
			tot += arr[i];
		}
	cout<<tot<<"\n";
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long int n; 
	map<long long int, long long int>m;
	long long int i, k;
	cin >> n >> k;
	for(i=0;i<k;i++)
	{
		long long int d;
		cin >> d;
		long long int j;
		for(j=0;j<d;j++)
		{
			long long int k;
			cin >> k;
			m[k]++;
		}
	}
	long long int ans = 0;
	for(i=1;i<=n;i++)
	if(m[i] == 0)
	ans++;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool flag=false;
  for(int i=1;i<10;i++) {
    if(n%i==0&&n/i<10) {
      flag=true;
    }
  }
  if(flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= d; j++) {
				if (j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i) {
					++count;
				}
			}
		}
		System.out.println(count);
	}
}


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>>  C(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> C[i][j];
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << C[i][j];
    }
    cout << endl;
    for(int j=0; j<W; j++){
      cout << C[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,i,flag=1;
  char s[11];
  scanf("%d %d",&a,&b);
  scanf("%s",s);
  for(i=0;i<a+b+1;i++){
    if(i<a&&s[i]=='-')  flag=0;
    else if(i==a&&s[i]!='-')  flag=0;
    else if(i>a&&s[i]=='-')  flag=0;
  }
  if(flag)  printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
#include <stdio.h>

typedef long long ll;
int X;

ll f(ll k) {
    return k * (k + 1) / 2;
}

int binsearch(int head, int tail) {
    if (head == tail) {
        return head;
    }
    int mid = (head + tail) / 2;
    if (f(mid) >= (ll)X) {
        return binsearch(head, mid);
    } else {
        return binsearch(mid + 1, tail);
    }
}

int main() {    
    scanf("%d", &X);
    printf("%d\n", binsearch(1, X+1));
}

Measured memory_bytes: 128