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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;
int f[10][10];

int main(){
    cin >> N;
    int cnt=0;
    FOR(i,1,N+1)
    {
        string s = to_string(i);
        f[s[0]-'0'][s[s.length()-1]-'0']++;
    }

    FOR(i,1,10)
    {
        FOR(j,1,10)
        {
            cnt+=f[i][j]*f[j][i];
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int data[101][101] = {{0}};

int main (void)
{
	int r, c, i, j;

	scanf("%d %d", &r, &c);

	for (i=0; i<r; i++){
		for (j=0; j<c; j++){
			scanf("%d", &data[i][j]);
			data[i][c] += data[i][j];
			data[r][j] += data[i][j];
		}
		data[r][j] += data[i][c];
	}

	for (i=0; i<=r; i++){
		for (j=0; j<=c; j++){
			printf("%d", data[i][j]);
			if (j != c)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1072
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

def should_sd(cur_t, cur_v, next_ix, T, V):
    for i in range(next_ix, len(T)):
        Vsup = V[i+1]
        rem_t = T[i] - cur_t
        if cur_v - Vsup >= rem_t:
            return True
    return False

def main():
    N = I()
    T = LI()
    V = LI()
    V.append(0)
    for i in range(N-1):
        T[i+1] += T[i]
    cur_t = 0
    cur_v = 0
    prev_v = 0
    ix = 0
    next_ix = 0
    area = 0
    while cur_t < T[-1]:
        if cur_t == T[next_ix]:
            next_ix += 1
        if should_sd(cur_t, cur_v, next_ix, T, V):
            prev_v = cur_v
            cur_v -= 0.5
        else:
            if cur_v < V[next_ix]:
                prev_v = cur_v
                cur_v += 0.5
            else:
                prev_v = cur_v
        # add menseki
        p = (prev_v + cur_v) * 0.5 / 2
        area += p
        cur_t += 0.5
    print(area)
main()



Measured memory_bytes: 67304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
const int judger = 1e9;

int main( void ){
	int N, K, S;
	cin >> N >> K >> S;
	rep(i,0,K){
		cout << S << " ";
	}
	rep(i,K,N){
		if (S >1)
		cout << S-1 << " ";
		else
			cout << S+1 << " ";
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const ll mod = 1000000007;

// a^n mod を計算する
ll power(ll a,ll b)
{
  ll ans=1;
  while(b)
  {
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}


// 二項係数計算
ll C(ll x,ll y)
{
  ll ans=1;
  if(x-y<y) y=x-y;
  for(int i=1;i<=y;i++)
  {
    ans=ans*x%mod*power(i,mod-2)%mod;
    x--;
  }
  return ((-ans)%mod+mod)%mod;
}


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


      // 計算例
    cout << ((power(2,n)+C(n,a)+C(n,b)-1)%mod)%mod << endl;
}

Measured memory_bytes: 384
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print(dfs(0, 'TTT'))


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

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

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

    string str;
    cin >> str;

    cout << str.replace(0, 4, "2018") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
    int a, b = 0;
    string s, t;
    cin >> s >> t;
    a = s.size();
    for(int i = 0; i < a; i++){
        if(s[i] != t[i]){
            b++;
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }

        ll factorial(ll n, ll mod){
            ll answer = 1;
            for(int i=2; i<=n; i++){
                answer = (answer * i) % mod;
            }
            return answer % mod;
        }

        ll inverse(ll base, ll mod){
            return pow(base, mod-2, mod) % mod;
        }

        /*ll C(ll n, ll m, ll mod){
            return (factorial(n, mod) * inverse(factorial(m,mod) * factorial(n-m, mod)%mod, mod) ) % mod;
        } */  

        

        void solve(){
            cin >> x >> n;
            set<int> used;
            for(int i=-200; i <= 200; i++){
                used.insert(i);
            }
            for(int i=1; i <= n; i++){
                int a; cin >> a;
                used.erase(a);
            }
            ll mn = -1;
            ll ans = -1;
            for(int y : used){
                if(abs(x-y) < mn || mn == -1){
                    ans = y;
                    mn = abs(x-y);
                }
            }
            cout << ans << endl;
        }

       
    


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

          
            

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

}


Measured memory_bytes: 35872
h,w = map(int,input().split())
l = list('.'+input()+'.' for _ in range(h))
l = ['.'*(w+2)] + l + ['.'*(w+2)]

for i in range(1,h+1):
    ans=''
    for j in range(1,w+1):
        if l[i][j] == '#':
            ans += '#'
        else:
            _tmp = l[i-1][j-1:j+2]+l[i][j-1:j+2]+l[i+1][j-1:j+2]
            ans+=str(_tmp.count('#'))
    print(ans)

Measured memory_bytes: 3188
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

A=many_int()

count=0
for i in range(0, len(A),2):
    if A[i]%2==1:
        count+=1

print(count)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  ll ma = 0, mi = 100005;
  for(ll i = 0; i < m; i++){
    ll l, r;
    cin >> l >> r;
    ma = max(ma, l);
    mi = min(mi, r);
  }

  ll ans = 0;
  for(ll i = 1; i <= n; i++){
    if(i >= ma && i <= mi) ans++;
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll a, b, ans[108][108];

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

	memset(ans, 0, sizeof(ans));
	rep(i, 1, 100){
		rep(j, 1, 50){
			ans[i][j] = 1;
		}
	}
	
	rep(k, 2, a){
		ans[2*(k%50)+1][2*(k/50)+2] = 0;
	}
	rep(k, 2, b){
		ans[2*(k%50)+1][2*(k/50)+52] = 1;
	}
	
	print("100 100")
	rep(i, 1, 100){
		rep(j, 1, 100){
			char c = (ans[i][j] == 0)? '.' : '#';
			cout << c;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 100001;

main(){
  int n, m; cin >> n >> m;
  int D[MAX], k, a, sum, p;
  D[0] = 0;
  for ( int i = 1; i < n; i++ ){
    cin >> k;
    D[i] = D[i-1] + k;
  }
  sum = 0, p = 0;
  for ( int i = 0; i < m; i++ ){
    cin >> a;
    sum += max(D[p], D[p+a]) - min(D[p], D[p+a]);
    sum = sum%100000;
    p = p+a;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1232
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    ll d[N];
    ll out = 0;
    rep(i,N) cin >> d[i];
    rep(i,N){
        rep(j,N){
            if(i != j) out += d[i]*d[j];
        }
    }
    cout << out/2 << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  int64_t n;
  cin >> n;
  vector <int64_t> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  int tmp = 0;
  int64_t a = 0, b = 0;
  rep(i, n-1) {
    if (tmp == 0) {
      if (v.at(n-1-i) == v.at(n-1-(i+1))) {
        tmp++;
        a = v.at(n-1-i);
        i++;
      }
    } else if (tmp == 1) {
      if (v.at(n-1-i) == v.at(n-1-(i+1))) {
        b = v.at(n-1-i);
        break;
      }
    }
  }
  cout << a*b << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000003;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;

int main(){
    
    cin>>N;
    
    cout<<(N-1)/2<<endl;


    return 0;
}


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

int main() {
    char alpha;
    cin >> alpha;
    
    if (isupper(alpha))
     {
         cout << "A" << endl;
     }
     else
     {
         cout << "a" << endl;
     }

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
main()
{
int n;
cin>>n;
int a[n];
//sort(a,a+n);
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
int cou=0;
sort(a,a+n)
;for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{
		for(int k=j+1;k<n;k++)
		{
			if(a[i]==a[j]||a[j]==a[k]||a[k]==a[i])
			continue;
			if(a[i]+a[j]>a[k])
			{
				//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
				cou++;
			}
		}
	}
}
cout<<cou<<endl;

//	cout<<ans<<endl;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

void Main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    deque<int> d;
    rep(i,n){
        int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if(p == 0){
            d.push_front(a[i]);
        }
        else d[p-1] = a[i];
    }
    int ans = d.size();
    cout << ans << "\n";
}

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


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a = vector<ll>(n);
  rep(i, n) cin >> a[i];
  vector<ll> d1 = vector<ll>(60, 0);
  rep(x, 60) {
    rep(i, n) {
      if((a[i] >> x) & 1) {
        d1[x]++;
      }
    }
  }
  ll ans = 0;
  rep(i, 60) {
    ll c1 = d1[i];
    ll c0 = n - c1;
    ll p = (ll)pow(2, i) % 1000000007;
    ans += p * (c1 * c0 % 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
use strict;
use warnings;

sub main {
    my $i=0;
    my ($N,$K,@h);
    while(<STDIN>){
        chomp;
        if($i==0){
            ($N,$K) = split(/ /,$_);
        } elsif($i==1) {
            @h = split(/ /, $_);
        }
        $i++;
    }
    print solver($N,$K,\@h);
}
main() unless caller;

sub solver {
    my ($N,$K,$h) = @_;
    my $ans = 0;
    for my $i(@$h) {
        if($i >= $K) {
            $ans++;
        }
    }
    return $ans;
}

Measured memory_bytes: 16804
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int a,b,x;cin>>a>>b;
	x=max(4-a,0)+max(4-b,0);
	if(x==6){x=10;}
	x*=100000;
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

k,a,b=map(int,input().split())


if(b>a+2):

	rem = k-a+1
	if(rem%2==0):
		n=(b-a)*rem//2+a
	else:
		n=(b-a)*(rem//2)+a+1
	print(n)
	
else:
	print(1+k)

Measured memory_bytes: 3060
s = input()
if len(s) % 2 == 0:
    s1 = s[:len(s) // 2]
    s2 = s[:len(s) // 2 - 1:-1]
else:
    s1 = s[:len(s) // 2]
    s2 = s[:len(s) // 2 : -1]
cnt = 0
for index, value in enumerate(zip(s1, s2)):
    if value[0] == value[1]:
        continue
    else:
        #s1[index] = value[0]
        s1 = s1[:index] + value[0] + s1[index:]
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
from collections import deque
h, w = map(int, input().split())
wall = '#'
maze = [[wall] * (w + 2)]
wn = 0
for y in range(1, h+1):
    maze.append([wall] + [c for c in input()] + [wall])
    for x in range(1, w+1):
        if maze[y][x] == '.':
            wn += 1
maze.append([wall] * (w + 2))

q = deque()
q.append((1, 1, 0))
reachable = False
while q:
    y, x, i = q.popleft()
    if maze[y][x] == '#':
        continue
    if y == h and x == w:
        reachable = True
        break
    maze[y][x] = '#'
    i += 1
    q.append((y+1, x, i))
    q.append((y-1, x, i))
    q.append((y, x+1, i))
    q.append((y, x-1, i))
print(wn - i - 1 if reachable else -1)


Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
int dp[105][4][2];
int main (){
    string N;
    int k;
    cin >> N >> k;
    

    int l=N.size();
    
    dp[0][0][0]=1;
    for(int i=0; i<l; i++){
        for(int j=0; j<4; j++){
            for(int smaller=0; smaller<2; smaller++){
                int x_ = N[i] - '0';
                for(int x=0; x < 10;x++){
                    //cout << x<< endl;
                   int i_ = i+1;
                   int j_ = j;
                   int smaller_ =smaller ;

                   if(x!=0) j_++;
                   if(j_>k) continue;

                   if(smaller_==0){
                       if(x_<x) continue;
                       else if(x<x_) smaller_ = 1;

                   }
                   dp[i_][j_][smaller_]+=dp[i][j][smaller];
                }
            }
        }
    }
    
    cout << dp[l][k][0] + dp[l][k][1]  <<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

int main() {
  int n;
  while(cin >> n){
  	long ans = 0;
  	for(int i = 1; i<=n; i++){
  		if(i%3 != 0 && i%5 != 0) 
  			ans += i;
  	}
    cout << ans << endl;
  }
	return 0;
}

Measured memory_bytes: 3632
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
struct Edge { LL to, cost; };
LL h, w, n, m, s[100000], t, k, p, q, ans = 0, a[100000], b[100000], sum[2];
int main() {
	cin >> n ;
	rep(i, n) {
		cin >> a[i];
		sum[0] += a[i];
	}
	rep(i, n) {
		cin >> b[i];
		if (b[i] > a[i]) {
			if (b[i] % 2 != a[i] % 2) w++, h++;
			h += (b[i] - a[i]) / 2;
		}
		else w += (a[i] - b[i]);
		sum[1] += b[i];
	}
	ans = sum[1] - sum[0];
	cout << (ans>=0&&(ans-w) == (ans-h)*2&&ans>=w&&ans>=h ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
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){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    vector<bool> passed(n,false);
    int sum=0;
    int foreign=0;
    REP(i,n) {
        if(s[i]=='a') {
            if(sum<a+b) {
                sum++;
                passed[i]=true;
            }
        }
        else if(s[i]=='b') {
            if(sum<a+b && foreign<b) {
                foreign++;
                sum++;
                passed[i]=true;
            }
        }
    }
    REP(i,n) {
        cout<<(passed[i]?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int a, b, c;
    cin >> a >> b >> c;

    if (a == b) {
        cout << c << '\n';
    } else if (b == c) {
        cout << a << '\n';
    } else {
        cout << b << '\n';
    }


    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
using namespace std;
#define N 605
#define mod 1000000007
int dp[N][N][N],c1,n,is[N],a,b;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		if(a>b)a^=b^=a^=b;
		if(b==-1)c1++;
		else if(a==-1)is[n*2-b+1]=1;
		else is[n*2-a+1]=is[n*2-b+1]=2;
	}
	dp[0][0][0]=1;
	for(int i=1;i<=n*2;i++)
	for(int j=0;j<=i&&j<=n;j++)
	for(int k=0;k<=i;k++)
	if(dp[i-1][j][k])
	{
		if(is[i]==2)dp[i][j][k]=dp[i-1][j][k];
		else if(is[i]==1){dp[i][j+1][k]=(dp[i-1][j][k]+dp[i][j+1][k])%mod;if(k)dp[i][j][k-1]=(dp[i][j][k-1]+dp[i-1][j][k])%mod;}
		else
		{
			if(k)dp[i][j][k-1]=(dp[i][j][k-1]+dp[i-1][j][k])%mod;
			if(j)dp[i][j-1][k]=(dp[i][j-1][k]+1ll*dp[i-1][j][k]*j)%mod;
			dp[i][j][k+1]=(dp[i][j][k+1]+dp[i-1][j][k])%mod;
		}
	}
	int as=dp[n*2][0][0];
	for(int i=1;i<=c1;i++)as=1ll*as*i%mod;
	printf("%d\n",as);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


signed main(){
    int N;
    cin>>N;
    vint A(N);
    rep(i,N)cin>>A[i];

    rep(i,N-1)A[i+1]+=A[i];
    int ans=1001001001001001001ll;
    for(int i=0;i<N-1;i++){
        chmin(ans,abs(A[N-1]-2*A[i]));
    }

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

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

int main(){
    int n,m;
    cin>>n>>m;
    if(m>n){
        int temp=m;
        m=n;
        n=temp;
    }
    for(int i=1;i<=n;i++){
        cout<<m;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
  int n;
  cin>>n;
  LL a[n];
  LL lcm;
  for(int i=0;i<n;++i){
    if(!i){ cin>>a[i]; lcm=a[i]; }
    else{ cin>>a[i]; lcm=(lcm/__gcd(lcm,a[i]))*a[i]; }
  }
  cout<<lcm<<endl;


  return 0;
}

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

using namespace std;

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

	if ((a+b==c)||(a+c==b)||(b+c==a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
    [a,b] <- map read . words <$> getLine
    putStrLn $ unwords ["a", relation a b, "b"]

relation :: Int -> Int -> String
relation a b
    | a == b = "=="
    | a <  b = "<"
    | a >  b = ">"


Measured memory_bytes: 3632
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
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) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    if n == 1 {
        put!("Hello World");
    } else {
        put!(sc.cin::<i64>() + sc.cin::<i64>());
    }
}

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() -> Self { 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()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

using namespace std;

#define ll long long

signed main() {
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	/* aの累積和sを計算する. */
	vector<ll> s(n + 1,0);
	for (int i = 0; i < n; ++i)
		s[i + 1] = s[i] + a[i];

	/* 連続する部分列の和をすべて求める. */
	vector<ll> cs;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j <= n; ++j)
			cs.push_back(s[j] - s[i]);

	/* 最上位のビットmを決定する. */
	vector<int> ans; // 答えの立っているビット
	vector<ll> pos; // 最上位ビットの立っているものの集合
	for (int i = 40; i >= 0; --i) {
		vector<ll> ok; // 下からiビット目が立っているcs
		for (auto csi : cs)
			if (csi & (((ll)1) << i))
				ok.push_back(csi);
		if (ok.size() >= k) {
			pos = ok;
			ans.push_back(i);
			break;
		}
	}

	/* k個以上立っているビットがなければ必ず0. */
	if (pos.size() == 0) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = ans[0] - 1; i >= 0; --i) {
		vector<ll> ok;
		for (auto posi : pos)
			if (posi & (((ll)1) << i))
				ok.push_back(posi);
		if (ok.size() >= k) {
			pos = ok;
			ans.push_back(i);
		}
	}

	ll answer = 0;
	for (auto ansi : ans)
		answer ^= ((ll)1 << ansi);

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 6516
n = int(input())
a = list(map(int,input().split()))
if(a.count(0) != 0):
	print(0)
	exit(0)
m = 1e18
p = 1
for i in a:
	if(p*i > m):
		print(-1)
		break
	p *= i
else:
	print(p)


Measured memory_bytes: 84660
object Main extends App {
  import scala.io.StdIn.readLine;
  val area : (Int, Int) => Int = (a:Int, b:Int) => a * b;
  val length : (Int, Int) => Int = (a:Int, b:Int) => 2 * a + 2 * b
  val in = (readLine().split(' ').map(_.toInt));
  println(area(in(0), in(1)).toString + ' ' + length(in(0), in(1)))
}

Measured memory_bytes: 43804
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N; SCD(N);
    VI pi;
    VSCD(pi,N);
    int sum = 0;
    sort(pi.begin(),pi.end());
    REP(i,N){
        sum += pi[i];
    }

    PRINTD(sum - (pi[N-1]/2));
}

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

int main() {
    //入力
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
    }

    //処理
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec.size() << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
long long dp[2][41][262144]; //haiku, N, bitmask
int N, X, Y, Z;
int main()
{
    scanf("%d%d%d%d", &N, &X, &Y, &Z);
    int myhaiku = (1<<(X+Y+Z))+(1<<(X+Y))+(1<<X);
    dp[0][0][1] = 1;
    
    for(int i=0; i<N; ++i)
    {
        for(int s=0; s<2; ++s)
        {
            for(int j=0; j<262144; ++j)
            {
                for(int k=1; k<=10; ++k)
                {
                    int mask = ((j<<k)&262143)|1;
                    int bs = s;
                    if((mask&myhaiku)==myhaiku) bs = 1;
                    dp[bs][i+1][mask] =
                        (dp[bs][i+1][mask] + dp[s][i][j])%MOD;
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0; i<262144; ++i)
    {
        
        ans += dp[1][N][i]; ans %= MOD;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 166144
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<stack>
#include<sstream>
//#include <Eigen/Dense>
//#include <Eigen/Geometry>
//using namespace Eigen;
using namespace std;
 
int n;
const int maxn = 2e5 + 100;
int mod = 1e9 + 7;
vector<int> g[maxn];
int vis[maxn], sz[maxn];
long long ans[maxn], inv[maxn];
 
void inv_n(int n)
{
	inv[1] = 1;
	for (long long i = 2; i <= n; i++)
	{
		inv[i] = inv[mod%i] * (mod - mod / i) % mod;
	}
}
 
 
int dfs1(int cur,int p)
{
	sz[cur] = 1;
	for (int i : g[cur])
	{
		if (i != p)	
			sz[cur] += dfs1(i, cur);
	}
	return sz[cur];
}
 
void dfs2(int cur, int p)
{
	ans[cur] = ans[p] * sz[cur] % mod * inv[(n - sz[cur])] % mod;//ans[p] * sz[cur] * inv[(n - sz[cur])] % mod溢出报错
	for (int i : g[cur])
	{
		if (i != p)
			dfs2(i,cur);
	}
}
int main()
{
	int u, v;
	cin >> n;
	inv_n(n);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ans[1] = 1;
	for (int i = 1; i <= n; i++)
		ans[1] = ans[1] * i%mod;
	dfs1(1, 0);
	for (int i = 1; i <= n; i++)
		ans[1] = ans[1] * inv[sz[i]] % mod;
	
	for (int i : g[1])
		dfs2(i, 1);
	for (int i = 1; i <= n; i++)
		cout << ans[i] << endl;
 
	return 0;
}

Measured memory_bytes: 18676
#include <stdio.h>

int main(void) {
	int n1, n2, n3;
	int wa;

	scanf("%d %d %d", &n1, &n2, &n3);

	wa = n1 + n2 + n3;

	if(wa >= 22) {
		puts("bust");
	} else {
		puts("win");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char a[9];
    rep(i,9) cin >> a[i];
    cout << a[0] << a[4] << a[8] << endl;
}


Measured memory_bytes: 256
/* Arunava Chakraborty [ @iArunava ] */

/* Katana Thrower - AtCoder */

#include <bits/stdc++.h>

using namespace std;

bool comp(int a, int b) {
    return a > b;
}

int main() {
    int n = 0, h = 0, ai = 0, bi = 0, i = 0, j = 0, mxk = 0, cnt = 0;
    int warr[100010] = {};
    int tarr[100010] = {};

    scanf ("%d%d", &n, &h);
    for (i = 0; i < n; ++i) {
        scanf ("%d%d", warr+i, tarr+i);
        mxk = max(mxk, warr[i]);
    }

    sort(tarr, tarr+n, comp);
    
    i = 0;
    while(h > 0 && i != n) {
        if (tarr[i] < mxk) break;
        h -= tarr[i];
        ++i;
        ++cnt;
    }
    
    if (h > 0) cnt += ceil(h/(double)mxk);

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

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>
#include <queue>
#include <stack>
using namespace std;

int main() {
	int n, r;
	while(cin >> n >> r && (n || r)){
		deque<int> dq;
		for(int i = 1; i <= n; ++i)
			dq.push_front(i);
		
		int p, c;
		for(int i = 0; i < r; ++i){
			cin >> p >> c;
			
			stack<int> ps;
			for(int j = 0; j < p - 1; ++j){
				ps.push(dq.front());
				dq.pop_front();
			}
			
			stack<int> cs;
			for(int j = 0; j < c; ++j){
				cs.push(dq.front());
				dq.pop_front();
			}
			
			for(int j = 0; j < p - 1; ++j){
				dq.push_front(ps.top());
				ps.pop();
			}
			for(int j = 0; j < c; ++j){
				dq.push_front(cs.top());
				cs.pop();
			}
		}
		cout << dq.front() << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	if (n==25)
	  {
	  	printf ("Christmas\n");
	  }
	if (n==24)
	  {
	  	printf ("Christmas Eve\n");
	  }
	if (n==23)
	  {
	  	printf ("Christmas Eve Eve\n");
	  }
	if (n==22)
	  {
	  	printf ("Christmas Eve Eve Eve\n");
	  }
	return 0;
 } 

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    for(int in=0;in<n;in++) {
        cin >> p.at(in);
    }

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

    int ans = 0;
    for(int ik=0;ik<k;ik++) {
        ans += p.at(ik);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
    return 0;
  }
  ll ret = n / 10;
  n /= 10;
  while (n) {
    ret += n / 5;
    n /= 5;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;






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


    int total, max, time;
    cin >> total >> max >> time;

    int res = 0;

    while (total > 0) {
    	res += time; 
    	total -= max;
    }


    cout << res;

    return 0;


}


Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ll y, x;scanf("%lld%lld",&x,&y);
   
    printf("%lld",(x*y)/__gcd(x,y));
    
        
return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = [input() for _ in range(n)]
    ans = 0
    for j in range(n):
        f = True
        for i in range(n-1):
            for k in range(i+1, n):
                if a[(0+i)%n][(j+k)%n] != a[(0+k)%n][(j+i)%n]:
                    f = False
                    break
            if not f:
                break
        if f:
            ans += n
    print(ans)

if __name__ == "__main__":
    main()

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

int prime(int n){
  long long cnt=0,prime[n];
  bool f[n+1];
  for(int i=0;i<=n;i++){
    f[i]=true;
  }
  f[0]=f[1]=false;
  for(int i=2;i<=n;i++){
    if(f[i]){
      prime[cnt++]=i;
      for(int j=2*i;j<=n;j+=i){
        f[j]=false;
      }
    }
  }
  return cnt;
}

int main(){
  long long n;
  while(cin >> n){
    cout << prime(n) << endl;
  }
  return 0;
}



Measured memory_bytes: 5624
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
    B[n+1] = B[n] + A[n]
C = B.pop()

Z = {}
for n in range(N):
    Z[A[n]] = 0
for n in range(N):
    Z[A[n]] += 1

D = []
Q = int(input())
for q in range(Q):
    x, y = map(int, input().split())
    if x in Z:
        C = C - x*Z[x]
        C = C + y*Z[x]
        D.append(C)
        if x == y:
            continue
        if y in Z:
            Z[y] += 1*Z[x]
        else:
            Z[y] = Z[x]
        Z.pop(x)
    else:
        D.append(C)
for d in D:
    print(d)

Measured memory_bytes: 26968
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(0);
// Inspired by: https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define repc(...)                                    \
  GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) \
  (__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();
//http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

void solve()
{
  const int n = in();
  vector<int> a(n);
  vcin(a);

  auto dp = make_v<lint>(n + 1, 2);

  dp[0][0] = 0;
  dp[0][1] = -(2 << 24);

  rep(i, n)
  {
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
  }

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

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


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

using namespace std;

typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;

typedef pair<int, int> ii;

typedef vector<bool> vb;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int s, n;
	string in;
	cin >> s >> in >> n;
	string res = "";
	for ( int i = 0 ; i < s ; i++ ){
		if ( in[n-1] != in[i] ){
			res += "*";
		} else {
			res += in[i];
		}
	}
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<59;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const string t="AKIHABARA";

string s;

int main(){
	cin>>s;
	for(int i=0;i<1<<9;i++){
		string t_;
		for(int j=0;j<9;j++){
			if(i&1<<j) t_+=t[j];
			else if(t[j]!='A') t_+='a';
		}
		if(t_==s){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256