akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y, std::vector<long long> z)
{

    ll ans = LLONG_MIN;
    for (int i = 0; i < 8; i++)
    {
        ll tmpMax = 0;
        vector<ll> cake(N,0);
        for (int j = 0; j < N; j++)
        {
            ll tmp = 0;
            if (i & 1)
            {
                tmp += x[j];
            }
            else
            {
                tmp += (-1 * x[j]);
            }
            if (i & 2)
            {
                tmp += y[j];
            }
            else
            {
                tmp += (-1 * y[j]);
            }
            if (i & 4)
            {
                tmp += z[j];
            }
            else
            {
                tmp += (-1 * z[j]);
            }
            cake[j] = tmp;
        }
        RSORT(cake);
        for (int j = 0; j < M; j++)
        {
            tmpMax += cake[j];
        }
        ans = max(ans, tmpMax);
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> z(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
        scanf("%lld", &z[i]);
    }
    solve(N, M, std::move(x), std::move(y), std::move(z));
    return 0;
}


Measured memory_bytes: 384
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

types = []
last = [-1] * 26
S = 0
for d in range(D):
    # search type
    M = -float('inf')
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        if tmp > M:
            M = tmp
            M_tt = tt

    S += s[d][M_tt]

    last[M_tt] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    types.append(M_tt)


last = [-1] * 26
S = 0
ans = []
for d in range(D):
    seq = []
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        seq.append([tmp, tt])

    seq.sort(reverse=True)

    tmpmax = -float('inf')
    for i in range(15):
        tt = seq[i][1]
        _last = last[:]
        _types = types[:]
        _types[d] = tt
        _S = S

        for dd in range(d, D):
            _S += s[dd][_types[dd]]
            _last[_types[dd]] = dd
            for i in range(26):
                _S -= c[i] * (dd - _last[i])

        if _S > tmpmax:
            cand = tt
            tmpmax  = _S

    S += s[d][cand]
    last[cand] = d
    for i in range(26):
        S -= c[i] * (d - last[i])

    ans.append(cand + 1)
    
for _ans in ans:
    print(_ans)


Measured memory_bytes: 70092
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long double x, base = 100;
    cin >> x;
    for (int i = 0; ; i++, base = floor(base * 1.01)) {
        if (base >= x) return cout << i, 0;
    }
    return 0;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) cout << s[i];
    cout << endl;
    return 0;
}			

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
lli n;

lli calc(lli ind,lli a[],lli b[],lli c[],lli prev, vector<vector<lli> > &memo)
{
    if(ind >= n)
        return 0;
    if(prev != -1)
    {
        if(memo[ind][prev-1] != -1)
            return memo[ind][prev-1];
    }
    lli ans = 0;
    lli pos = -1;
    if(prev == -1)
    {
        lli val = a[ind] + calc(ind+1,a,b,c,1,memo);
        if(val > ans)
        {
            pos = 0;
            ans = val;
        }
        val = b[ind] + calc(ind+1,a,b,c,2,memo);
        if(val > ans)
        {
            pos = 1;
            ans = val;
        }
        val = c[ind] + calc(ind+1,a,b,c,3,memo);
        if(val > ans)
        {
            pos = 2;
            ans = val;
        }
    }
    if(prev == 1)
    {
        lli val = b[ind] + calc(ind+1,a,b,c,2,memo);
        if(val > ans)
        {
            pos = 1;
            ans = val;
        }
        val = c[ind] + calc(ind+1,a,b,c,3,memo);
        if(val > ans)
        {
            pos = 2;
            ans = val;
        }
    }
    if(prev == 2)
    {
        lli val = a[ind] + calc(ind+1,a,b,c,1,memo);
        if(val > ans)
        {
            pos = 0;
            ans = val;
        }
        val = c[ind] + calc(ind+1,a,b,c,3,memo);
        if(val > ans)
        {
            pos = 2;
            ans = val;
        }
    }
    if(prev == 3)
    {
        lli val = a[ind] + calc(ind+1,a,b,c,1,memo);
        if(val > ans)
        {
            pos = 0;
            ans = val;
        }
        val = b[ind] + calc(ind+1,a,b,c,2,memo);
        if(val > ans)
        {
            pos = 1;
            ans = val;
        }
    }
    if(prev != -1)
        memo[ind][prev-1] = ans;
    return ans;
}

int main()
{
    cin>>n;
    lli a[n],b[n],c[n];
    vector<vector<lli> > memo(n,vector<lli>(3));
    for(lli i=0;i<3;i++)
    {
        for(lli j=0;j<n;j++)
        {
            memo[j][i] = -1;
           // cout<<memo[j][i]<<" ";
        }
       // cout<<endl;
    }
    for(lli i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<calc(0,a,b,c,-1,memo);
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;
const int inf = 1e9 +5;
int main()
{
    int n;
    cin>>n;
    vector<int> h;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        h.push_back(x);
    }
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+2;j++)
        {
            if(j<n)
            {
                dp[j]=min( dp[j] , dp[i] + abs( h[i]  - h[j] ) );
            }

        }
    }
    cout<<dp[n-1];
    return 0;
}


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

typedef long long ll;

const int MAXN = 100005;

int N, M;
ll K;
int x[MAXN], a[MAXN];
int perm[MAXN];
bool bio[MAXN];
vector < vector <int> > C;
int who[MAXN];
int pos[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", x + i);
	scanf("%d%lld", &M, &K);
	for (int i = 0; i < M; i++) {
		scanf("%d", a + i);
		a[i]--;
	}
}

void dfs(int x) {
	if (bio[x]) return;
	vector <int> curr;
	for (int i = x; !bio[i]; i = perm[i]) {
		bio[i] = true;
		curr.push_back(i);
	}
	for (int i = 0; i < curr.size(); i++) {
		who[curr[i]] = C.size();
		pos[curr[i]] = i;
	}
	C.push_back(curr);
}

int get(int x) {
	int len = C[who[x]].size();
	return C[who[x]][(pos[x] + K % len) % len];
}

void solve() {
	for (int i = 0; i < N - 1; i++)
		perm[i] = i;
	
	for (int i = 0; i < M; i++)
		swap(perm[a[i] - 1], perm[a[i]]);
	
	for (int i = 0; i < N - 1; i++)
		dfs(i);
		
	ll sum = 0; 
	for (int i = 0; i < N; i++) {
		printf("%lld.0\n", x[0] - sum);
		int tmp = get(i);	
		sum += x[tmp] - x[tmp + 1]; 
	}
}

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

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

int selectionSort(int*,int);

int main(){
  int i,j,count,A[N];

  scanf("%d",&i);

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

  count=selectionSort(A,i);

  printf("%d",A[0]);
  for(j=1;j<i;j++){
    printf(" %d",A[j]);
  }

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

  return 0;
}

int selectionSort(int *A,int n){
  int i,j,count=0,min,temp;

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j]<A[min]) min=j;

    }

    if(i!=min){
      temp=A[i];
      A[i]=A[min];
      A[min]=temp;
      count++;
    }
      
  }

  return count;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
int main()
{
	//cout << fixed << setprecision(9);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
    int t;cin>>t;
    string s;
    cin>>s;
    int n =s.size();
    if(t>=s.size())cout<<s;
    else{

        for(int i=0;i<t;i++){
            cout<<s[i];
        }
    cout<<"...";
    }
	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var ca = S.ToCharArray();
		for(int i=0;i<ca.Length;i++){
			ca[i] = 'x';
		}
		Console.WriteLine(new String(ca));
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int m,b[10]={2,5,5,4,5,6,3,7,6};
char a[10];
bool done[10101];
string memo[10101];

string maxs(string x, string y){
	if(x[x.l_ength()-1]=='m'){
		return y;
	}else if(y[y.l_ength()-1]=='m'){
		return x;
	}else if(x.l_ength()>y.l_ength()){
		return x;
	}else if(x.l_ength()<y.l_ength()){
		return y;
	}else{
		return max(x,y);
	}
}

string solve(int x){
	int i,ans;
	if(x<0){
		return "Morojenium";
	}
	if(done[x]){
		return memo[x];
	}
	done[x] = true;
	if(!x){
		memo[x] = "";
		return memo[x];
	}else if(x==1){
		memo[x] = "Morojenium";
		return memo[x];
	}
	memo[x] = "Morojenium";
	for(i=0; i<m; ++i){
		memo[x] = maxs(memo[x],(a[i])+solve(x-b[a[i]-'1']));
	}
	return memo[x];
}

int main(void){
	int n,i;
	fill(done,done+10101,false);
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> a[i];
	}
	cout << solve(n) << endl;
	return 0;
}


Measured memory_bytes: 28416
def FUNC00(ARG00):
    for VAR00 in range(1, len(ARG00)):
        VAR01 = ARG00[VAR00]
        VAR02 = VAR00 - 1
        while VAR02 >= 0 and ARG00[VAR02] > VAR01:
            ARG00[VAR02 + 1] = ARG00[VAR02]
            VAR02 -= 1
        ARG00[VAR02 + 1] = VAR01
        print(' '.join([str(VAR03) for VAR03 in ARG00]))
VAR04 = int(input())
VAR05 = [int(VAR06) for VAR06 in input().split()]
print(' '.join([str(VAR06) for VAR06 in VAR05]))
FUNC00(VAR05)


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

int main()
{
    int n;
    cin>>n;
    int arr[n],sz=n+5;
    vector<int>brr(sz,0);
    for(int i=0;i<n-1;i++)
    {
        cin>>arr[i];
        brr[arr[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<brr[i]<<endl;
    }
    return 0;
}


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

int main() {
  int a,b; 
  string c;
  cin >> a >> b;
  vector<string> vec(0);
  for (int i = 0; i < a; i++) {
     cin >> c;
     vec.push_back(c);
  }
  for(int i = 0 ; i < b+1 ; i++){
    cout << "#";
  }
  cout << "#" << endl;
  for(int i = 0 ; i < a ; i++){
    cout << "#";
    cout << vec.at(i);
    cout << "#" << endl;
  }
  for(int i = 0 ; i < b+1 ; i++){
    cout << "#";
  }
  cout << "#" << endl;
}


Measured memory_bytes: 3588
from math import sqrt
from bisect import bisect_left
def circle_center(x1, y1, x2, y2):
    xd = x2 - x1; yd = y2 - y1
    d = xd**2 + yd**2
    k = sqrt((4.0 - d) / d) / 2.0
    xc = (x1 + x2) / 2.0
    yc = (y1 + y2) / 2.0
    return [[xc - k*yd, yc + k*xd], [xc + k*yd, yc - k*xd]]
while 1:
    n = int(raw_input())
    if n==0: break
    p = [map(float, raw_input().split()) for i in xrange(n)]
    p.sort()
    prev = 0
    ans = 1
    for i in xrange(n):
        bx, by = p[i]
        while bx - p[prev][0] >= 2.0: prev += 1
        for j in xrange(i+1, n):
            cx, cy = p[j]
            if cx - bx >= 2.0: break
            if (bx - cx)**2 + (by - cy)**2 <= 4.0:
                for ex, ey in circle_center(bx, by, cx, cy):
                    count = 2
                    for k in xrange(prev, n):
                        if k==i or k==j: continue
                        dx, dy = p[k]
                        if dx - bx >= 2.0: break
                        if (ex - dx)**2 + (ey - dy)**2 <= 1.0:
                            count += 1
                    ans = max(ans, count)
    print ans

Measured memory_bytes: 6520
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

int main()
{
    int64_t a,b;
    std::cin>> a;
    std::cin>> b;
    int64_t c = 0;

    if( a == 1 )
    {
        c += 300000;
    }
    else if( a == 2 )
    {
        c += 200000;
    }
    else if( a == 3 )
    {
        c += 100000;
    }

    if( b == 1 )
    {
        c += 300000;
    }
    else if( b == 2 )
    {
        c += 200000;
    }
    else if( b == 3 )
    {
        c += 100000;
    }

    if( a == 1 &&
        b == 1 )
    {
        c += 400000;
    }
    std::cout<< c;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()

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

    int res = 0;
    rep(k,29){
        vector<int> bk(n);
        rep(i,n){
            bk[i] = b[i] % (1<<(k+1));
        }
        sort(all(bk));
        int bit = 0;
        rep(i,n){
            int pos[4];
            int ak = a[i] % (1<<(k+1));
            rep(m,4){
                pos[m] = lb(bk,((m+1)<<k) - ak);
            }
            bit ^= (pos[3]-pos[2] + pos[1]-pos[0]) & 1;
        }
        res |= bit<<k;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
map<ll, int> mp;
int main(){
    ll n;
    while(cin>>n){
        ll ans1, ans2;
        bool l=0;
        for(ll i=0; i<=3000; ++i){
        	ll tmp=i*i*i*i*i;
        	mp[tmp]=i;
        	if(mp.count(tmp-n)){
        		ans1=i;ans2=mp[tmp-n];
        		l=1;
        		break;
        	}
        	tmp*=-1;
        	mp[tmp]=-i;
        	if(mp.count(tmp-n)){
        		ans1=i;ans2=mp[tmp-n];
        		l=1;
        		break;
        	}
        }
        assert(l);
        cout<<ans1<<" "<<ans2<<endl;
    }
  return 0;
}




Measured memory_bytes: 3644
n,m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
a = []
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  print(sum(a[:m-n]))

Measured memory_bytes: 13960
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm> // sort

using namespace std;

//重複のない1～Nまでが格納された配列

//連続したK個を選び、すべてを選んだ要素の最小値に置き換える
//Kの数は決められている
//Nの数も
//基本方針は、 左辺、右辺に向けて、K-1 をのばしていく
//ただし、すでに、最小値になっている場合は、操作をしなくてもよくなる
//→重複ないから考えなくて良い


int main(){
    int N,K,A,res;
    int tmp,l,r;
    int l_res,r_res;
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    cin >> N >> K;

    //両方で割れたら格納
    for(int i = 1; i <= N; i++)
    {
        cin >> A;

        if(A == 1){
            tmp = i;
            break;
        }
    }
    l = tmp - 1;
//    r = N - tmp;


    if(l == 0)
    {
        l_res = 0;
        r = N - tmp;
    }
    else
    {
        l_res = (l + (K-1-1)) / (K-1);
        //塗った範囲
        int hani;

        //塗った範囲とtmpの大きいほう
        hani = max(l_res * (K-1) + 1, tmp);
        r = N - hani;
    }
    //左辺から、塗り替えたときのあまりを右辺に使用できる
    //ただし、L_res == 0はまずい

    if(r == 0)
    {
        r_res = 0;
    }
    else
    {
        r_res = (r + (K-1-1)) / (K-1);
    }
    

    //l = 1なら切りすてたい
    //r_res = r / (K-1);//切り捨てでなく切り上げたい
    //(a + (b - 1)) / b
    //分母-1 足しておけば、1余っても切り上がる

    res = l_res + r_res;
    cout << res << endl;
}



Measured memory_bytes: 256
from fractions import gcd
n = int(input())
t = [int(input()) for _ in range(n)]
if n == 1:
    print(t[0])
    exit()
ans = t[0] * t[1] // gcd(t[0], t[1])
for i in range(2, n):
    ans = ans * t[i] // gcd(ans, t[i])
print(ans)


Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 3;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(A.begin(),A.end(),greater<ll>());
  cout << A[0]*10 + A[1] + A[2];
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string s; cin>>s;
  if(s.size()<4) print("No");
  else if(s.substr(0,4)=="YAKI") print("Yes");
  else print("No");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long X;
    cin >> X;
    long long P = 100, step = 0;
    while(P < X)
    {
        P += P / 100;
        step++;
    }
    cout << step << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<int,int> memo;
  rep(i,N){
    int a;
    cin >> a;
    memo[a]++;
  }

  ll ret = 0;
  FOR(it,memo){
    ret += (it->first) * (ll)(it->second);
  }
  
  int Q;
  cin >> Q;
  rep(i,Q){
    int b, c;
    cin >> b >> c;

    ll sum1 = b * (ll)memo[b];
    ll sum2 = c * (ll)memo[b];

    cout << ret - sum1 + sum2 << endl;

    ret = ret - sum1 + sum2;
    
    memo[c] += memo[b];
    memo[b] = 0;
  }
  
  return 0;
}

Measured memory_bytes: 7960
// AOJ 1202: Mobile Phone Coverage
// 2017.12.5 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int x1, y1, x2, y2; } T;
T tbl[102];
int xx[202], xs;
int yy[202], ys;
char map[202][202];

char buf[32], *p;

int getint()
{
	int n = 0;
	while (*p == ' ') p++;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	n *= 100;
	if (*p == '.') {
		p++;
		if (*p >= '0') n += 10*(*p++ & 0xf);
		if (*p >= '0') n +=     *p++ & 0xf;
	}
	return n;
}

int bsch(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) break;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return m;
}

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, i, x, y, r, x1, y1, x2, y2;
	int cno = 0;
	long long t, ans;

	while (fgets(buf, sizeof(buf), stdin) && *buf != '0') {
		n = atoi(buf);
		for (xs = ys = 0, i = 0; i < n; i++) {
			fgets(p=buf, sizeof(buf), stdin);
			x = getint(), y = getint(), r = getint();
			x1 = x-r, y1 = y-r, x2 = x+r, y2 = y+r;
			tbl[i].x1 = x1, tbl[i].y1 = y1, tbl[i].x2 = x2, tbl[i].y2 = y2;
			xx[xs++] = x1, xx[xs++] = x2, yy[ys++] = y1, yy[ys++] = y2;
		}
		qsort(xx, xs, sizeof(int), cmp); xs = uniq(xx, xs);
		qsort(yy, ys, sizeof(int), cmp); ys = uniq(yy, ys);

		memset(map, 0, sizeof(map));
		for (i = 0; i < n; i++) {
			x1 = bsch(xx, tbl[i].x1, xs);
			x2 = bsch(xx, tbl[i].x2, xs);
			y1 = bsch(yy, tbl[i].y1, ys);
			y2 = bsch(yy, tbl[i].y2, ys);
			for (y = y1; y < y2; y++) for (x = x1; x < x2; x++) map[y][x] = 1;
		}

		ans = 0;
		for (y = 0; y < ys; y++) {
			t = yy[y+1] - yy[y];
			for (x = 0; x < xs; x++) {
				if (map[y][x]) ans += t * (xx[x+1]-xx[x]);
			}
		}
		ans /= 100;
		printf("%d %lld.%02lld\n", ++cno, ans/100, ans%100);
	}
	return 0;
}

Measured memory_bytes: 1736
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())

cost=[Q,H,S,D]

ans=10**18
for index,item in enumerate(cost):
    temp=item*(N*2**(2-index) if index!=3 else N//2)
    
    for jndex,jtem in enumerate(cost[:3]):
        ans=min(ans,temp+jtem*(0 if index!=3 else (N%2)*2**(2-jndex)))
    
print(ans)


Measured memory_bytes: 3060
N, X = (int(x) for x in input().split())

a = [1]
p = [1]

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

def func(N, X):
  if (N == 0):
    return 0 if(X <= 0) else 1
  elif (X <= 1 + a[N - 1]):
    return func(N - 1, X - 1)
  else:
    return p[N - 1] + 1 + func(N - 1, X - 2 - a[N - 1])
  
print(func(N, X))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
 
int main()
{
        int n;
        cin >> n;
        string s(n, ' ');
        for (int  i=0; i<n; i++)
                cin >> s[i];
 
        vector<int> nums;
        for (int k=1; k<=3; k++)
                for (int i=0; i<n-k+1; i++)
                {
                        stringstream ss(string(s.begin()+i, s.begin()+i+k));
                        int tmp;
                        ss >> tmp;
                        nums.push_back(tmp);
                }
        sort(nums.begin(), nums.end());
        nums.erase(unique(nums.begin(), nums.end()), nums.end());
        for (int i=0; i<=1000; i++)
                if (nums[i] != i)
                {
                        cout << i << endl;
                        break;
                }
}

Measured memory_bytes: 1284
#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 100500
#define MAXZ 1000500000
using namespace std;

int s[MAXN];
int ans[MAXN];
int n, k;
int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> s[i];
        ans[i] = MAXZ;
    }
    ans[0] = 0;
    ans[1] = abs(s[1] - s[0]);
    for (int i = 2; i < n; i++){
        for (int j = 1; j <= min(i, k); j++){
            ans[i] = min(ans[i], ans[i - j] + abs(s[i - j] - s[i]));
        }
    }
    cout << ans[n - 1] << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		
		if (a + b > 2 * c) {
			int ans = 0;
			
			int min = Math.min(x, y);
			ans = min*2*c;
			x-=min;
			y-=min;
			
			if (x > 0 && a > 2*c) {
				ans += x*2*c;
				x = 0;
			}
			
			if (y > 0 && b > 2*c) {
				ans += y*2*c;
				y = 0;
			}
			
			ans += a*x + b*y;
			
			System.out.println(ans);
		} else {
			System.out.println(a*x + b*y);
		}
	}
}


Measured memory_bytes: 23124
s_prime=str(input())
t=str(input())
def solve(s_prime,t):
  ls=len(s_prime)
  lt=len(t)
  for i in range(ls-lt+1):
    temp='?'*(ls-lt-i)+t+'?'*i
    # print(temp)
    f=True
    for j in range(ls):
      if s_prime[j]=='?':
        continue
      elif temp[j] in ['?',s_prime[j]]:
        continue
      f=False
    if f==True:
      ans=''
      for j in range(ls):
        if temp[j]=='?':
          if s_prime[j]=='?':
            ans+='a'
          else:
            ans+=s_prime[j]
        else:
          ans+=temp[j]
      return ans
  return 'UNRESTORABLE'
  
print(solve(s_prime,t))

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  ll h, w;
  cin >> h >> w;
  ll tot = h*w;
  ll ans = tot;
  rep(cnt,2) {
    for(ll i = 1; i <= h/2; i++) {
      ll a = i*w;
      ll j = h-i;
      rep(cnt2,2) {
        ll b = j/2 * w;
        ll c = tot - (a+b);
        ll mx = max({a,b,c});
        ll mn = min({a,b,c});
        chmin(ans,mx-mn);
        swap(j,w);
      }
    }
    swap(h,w);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=1e18;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res*=a;
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vector<int> b(n);
    for(int i=0;i<n;i++) cin>>b[i];
    vector<int> ans;
    while(true){
        int m=(int)b.size();
        for(int i=m-1;i>=0;i--){
            if(b[i]==i+1){
                ans.push_back(b[i]);
                b.erase(b.begin()+i);
                break;
            }
            if(b[i]>i+1){
                cout<<-1<<endl;
                return 0;
            }
        }
        if(b.size()==0) break;
    }
    for(int i=n-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
MOD=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
  for j in range(i+1,N):
    if A[i]>A[j]:
      ans+=((K+1)*K//2)%MOD
    elif A[i]<A[j]:
      ans+=(K*(K-1)//2)%MOD

print(ans%MOD)

Measured memory_bytes: 9164
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 200000;

int main(){
    int N,D;
    int X[MAX],Y[MAX];

    cin >> N >> D;
    for(int i = 0;i < N;i++){
        cin >> X[i] >> Y[i];
    }

    int ans = 0;

    for(int i = 0;i < N;i++){
        if(pow(X[i],2) + pow(Y[i],2) <= pow(D,2)){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4676
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A = getint();
	int B = getint();
	A -= B;
	int H[100000], M[100000] = {};
	ll D[100000] = {}, goukei = 0;;
	rep(i, N) H[i] = getint();
	pakuri_sort(N, H);
	rep(i, N) {
		goukei += H[i];
		D[i + 1] = H[i] / A + D[i];
		M[i] = H[i] % A;
	}

	int L = goukei / (A + (ll)B * N) - 1;
	int R = (1000000000 + B - 1) / B;

	while (L + 1 != R) {
		int mid = (L + R) / 2;
		int damage = B * mid;
		ll cnt = 0;
		auto k = upper_bound(H, H + N, damage) - H;
		ll d = damage / A;
		int m = damage % A;
		cnt += D[N] - D[k] - d * (N - k);
		for (; k != N; k++) {
			cnt += (M[k] > m);
		}
		if (cnt > mid) L = mid;
		else R = mid;
	}

	printf("%lld", R);

	Would you please return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll t[n],a[n];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll h[n];
    memset(h,-1,sizeof(h));
    h[0]=t[0];
    h[n-1]=a[n-1];
    ll ans=1;
    for(int i=1;i<n-1;i++){
        if(t[i]!=t[i-1]){
            h[i]=t[i];
        }
        if(a[i]!=a[i+1]){
            h[i]=a[i];
        }
        if(h[i]==-1){
            ans*=min(a[i],t[i]);
            ans%=mod;
        }
    }
    ll num=h[0];
    for(int i=0;i<n;i++){
        if(i)num=max(h[i],num);
        if(num!=t[i]){
            cout<<0<<endl;
            return 0;
        }
    }
    num=h[n-1];
    for(int i=n-1;i>=0;i--){
        if(i!=n-1){
            num=max(h[i],num);
        }
        if(num!=a[i]){
            cout << 0<<endl;
            return 0;
        }
    }
    cout << ans<<endl;

    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		ans += a[i];
	}
	sort(a.begin(), a.end());
	if (ans % 10 != 0)cout << ans << endl;
	else {
		rep(i, n) {
			if (a[i] % 10 != 0) {
				ans -= a[i];
				cout << ans << endl;
				return 0;
			}
		}
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10000010
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,bir,iki;
	string ar;
	cin>>n;
	bir=n/100;
	iki=n%100;
	if(!(bir>=1 && bir<=12) && !(iki>=1 && iki<=12)) cout<<"NA"<<endl;
	else if((bir>=1 && bir<=12) && (iki>=1 && iki<=12)) cout<<"AMBIGUOUS"<<endl;
	else if(bir>=1 && bir<=12) cout<<"MMYY"<<endl;
	else if(iki>=1 && iki<=12) cout<<"YYMM"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,F=0;
	cin >> N;
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			if(i*j == N){
				F = 1;
			}
		}
	}
	if (F == 1){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
def CountingSort(A,B,k):
    global n
    C = [0 for i in range(k+1)]
    for i in range(n):
        C[A[i]] += 1
    for i in range(1,k+1):
        C[i] += C[i-1]
    #print(C)
    for j in range(n-1,-1,-1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1

n = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(n)]
CountingSort(A, B, 10000)
print(" ".join(map(str,B)))


Measured memory_bytes: 241972
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


void show_tower(vector<int> &d) {
    cout << endl;
    for (int _d : d) {
      cout << _d << endl;
    }
    cout << endl;
}


int main() {
  int n, r;
  int s, f, w, k;

  while (cin >> n >> r && n && r) {

    // begin initialize vector
    vector<int> d(n);
    for (int i=0; i<n; i++) {
      d[i] = n-i;
    }
    // end initialize vector

    // begin r times operation
    for (int i=0; i<r; i++) {
      cin >> s >> f;
      s--;

      // begin initialize tmp vector
      vector<int> tmp(n);
      for (int j=0; j<n; j++) {
        tmp[j] = 0;
      }
      // end initialize tmp vector

      // begin copy selected elements
      for (int k=0; k<f; k++) {
        tmp[k] = d[s];
        d[s] = -1;
        s++;
      }
      // end copy selected elements

      // begin find non-zero index
      int k = 0;
      for (;k<n; k++) {
        if (tmp[k] == 0) break;
      }
      // end find non-zero index

      for (int _d : d) {
        if (_d > 0) tmp[k++] = _d;
      }

      d = tmp;
    }
    cout << d[0] << endl;
  }
}

Measured memory_bytes: 3088
using System;
using System.Collections.Generic;

namespace ABC060B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            var memo = new HashSet<int>();

            for (var i = 0; ; i++)
            {
                var modA = (b * i + c) % a;
                if (modA == 0)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (memo.Contains(modA))
                {
                    Console.WriteLine("NO");
                    return;
                }
                memo.Add(modA);
            }
        }
    }
}


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

int main(void){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    
    if(a<b && b<c){
        cout << "Yes";
        cout << endl;
    }
 
    else{
        cout << "No";
        cout << endl;
    } 

}



Measured memory_bytes: 3100
/**************************************
 * Au: Hany01
 * Prob: agc003c
 * Date: Oct 20th, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define Rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline T read() {
    register char c_; register T _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int maxn = 1e5 + 5;

int n, a[maxn], ans;
map<int, bool> ty;

int main()
{
#ifdef hany01
    File("agc003c");
#endif

	For(i, 1, n = read<int>()) ty[a[i] = read<int>()] = i & 1;
	sort(a + 1, a + 1 + n);
	For(i, 1, n) if (ty[a[i]] ^ (i & 1)) ++ ans;
	printf("%d\n", ans >> 1);

    return 0;
}


Measured memory_bytes: 5376
package main

import (
	"fmt"
)

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}
func main() {
	var N int
	var S string
	fmt.Scanf("%d\n", &N)
	fmt.Scanf("%s\n", &S)

	rs := []rune(S)
	m := [3]map[int]bool{{}, {}, {}}
	for i, s := range rs {
		if string(s) == "R" {
			m[0][i] = true
		} else if string(s) == "G" {
			m[1][i] = true
		} else {
			m[2][i] = true
		}
	}
	minus := 0
	for i := 0; i < N; i++ {
		si := rs[i]
		var tm, tm2 map[int]bool
		if string(si) == "R" {
			tm, tm2 = m[1], m[2]
		} else if string(si) == "G" {
			tm, tm2 = m[0], m[2]
		} else {
			tm, tm2 = m[0], m[1]
		}
		for j := range tm {
			if i >= j {
				continue
			}
			if _, e := tm2[2*j-i]; e {
				minus++
				continue
			}
		}
		for j := range tm2 {
			if i >= j {
				continue
			}
			if _, e := tm[2*j-i]; e {
				minus++
				continue
			}
		}

	}
	fmt.Println(len(m[0])*len(m[1])*len(m[2]) - minus)

}


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

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<ll,ll>;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  ll a, b, c, d; 
  cin >> a >> b >> c >> d;
  ll zero = ((a <= 0 && 0 <= b) || (c <= 0 && 0 <= d)) ? 0 : a * c;
  cout << max({a * c, a * d, b * c, b * d, zero}) << "\n";
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  long n,k,b,ans=0;
  cin >> n >> k;
  for (b=k+1;b<=n;b++){
    ans+=(n/b)*(b-k);
    if (n%b>=k) ans+=n%b-k+1;
  }
  if (k==0) ans=n*n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
m = [[-1 for i in range(n)] for j in range(n)] #お隣さんへのコストを保存（この中から最小を探す）

v = set()
v.add(0)

for i in range(n): #隣接の辺のコストを入力
  nums = list(map(int, input().split()))
  for j in range(n):
    m[i][j] = nums[j]


def prim_mst(n):
  isVisited = [False] * n
  d = [0] + [2001] * (n-1)      #TとV-Tのを繋ぐ最小辺の重みを格納する

  while  True:
    mincost = 2001
    for i in range(n):
      if not (isVisited[i]) and d[i] < mincost:
        mincost = d[i]
        u = i
    isVisited[u] = True


    if mincost == 2001:        #mincostが2001になったら繰り返し作業終了
      break

    for v in range (n):
      if (not isVisited[v]) and (m[u][v] != -1):
        if m[u][v] < d[v]:
          d[v] = m[u][v]
  print(sum(d))

prim_mst(n)





Measured memory_bytes: 5776
#include<bits/stdc++.h>
using namespace std;
const int pi=3.1415926535897932384626433832795;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
void solve(int n,string s,int t1,int t2)
{
	vector<int>sh(n);
	sh[0]=t1;
	sh[1]=t2;
	for(int i=2;i<n;i++)
		sh[i]=(sh[i-1]+sh[i-2]+(s[i-1]=='x'))%2;
	if((sh[n-1]+sh[0]+sh[1]+(s[0]=='x'))%2==0&&(sh[n-2]+sh[n-1]+sh[0]+(s[n-1]=='x'))%2==0)
	{
		for(int i=0;i<n;i++)
			cout<<(sh[i]?'W':'S');
		exit(0);
	}		
}
int main()
{
	int n;
	string s;
	cin>>n>>s;
	solve(n,s,0,0);
	solve(n,s,0,1);
	solve(n,s,1,0);
	solve(n,s,1,1);
	puts("-1");
}

Measured memory_bytes: 1016