akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication58
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;
                int[] b = new int[55];
                for(int c = 0; c < 10; c++)
                {
                    b[c] = a[c] - 48;
                }
                int s = 9;
                for(int d = 0; d < 9; d++)
                { 
                    for(int e = 1; e < 10 - d; e++)
                    {
                        b[s + e] = (b[s + e - (10 - d)] + b[s + e - (10 - d) + 1]) % 10;
                    }
                    s += 9 - d;
                }
                Console.WriteLine(b[54]);
            }
        }
    }
}

Measured memory_bytes: 9020
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 200001;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
     //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string temp;
    set <char> sm;
    for (int i = 0; i < sz(s); i++) {
        if (sm.find(s[i]) == sm.end()) {
            if (!sm.empty()) sm.erase(s[i - 1]);
            temp += s[i];
            sm.insert(s[i]);
        }
    }
    cout << sz(temp);
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    while(n--){
        vector<int>vec;
        for(int i=0;i<10;i++){
            int t;
            cin>>t;
            vec.push_back(t);
        }
        for(int i=0;i<1<<10;i++){
            vector<int>a,b;
            for(int j=0;j<10;j++){
                if((i>>j)&1){
                    a.push_back(vec[j]);
                }
                else{
                    b.push_back(vec[j]);
                }
            }
            int suc=1;
            if(a.size()>1)
                for(int j=0;j<a.size()-1;j++){
                    if(a[j+1]<a[j])
                        suc=0;
                }
            if(b.size()>1)
                for(int j=0;j<b.size()-1;j++){
                    if(b[j+1]<b[j])
                        suc=0;
                }
            if(suc==1){
                cout<<"YES"<<endl;
                goto next;
            }
            a.clear();
            b.clear();
        }
        cout<<"NO"<<endl;
    next:;
    }
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


  

int main(){
  int n, m; cin >> n >> m; ll k; cin >> k; ll a[n+1] = {}; ll b[m], cum[m+1] = {};
  rep(i, n){
    cin >> a[i+1];
  }
  rep(i, m){
    cin >> b[i]; cum[i+1]=b[i]+cum[i];
  }
  ll now = 0; int ans = 0; int tmp;
  rep(i, n+1){
    now+=a[i];
    if(now>k) break;
    tmp=i+(int)(upper_bound(cum, cum+m+1, k-now)-cum-1);
    //cout << tmp << endl;
    ans = max(ans, tmp);
  }
  cout << ans << endl;  
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[n];
	multiset<int> mt;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mt.insert(a[i]);
	}
	for(int i=0;i<n;i++)
	{
		int x = a[i];
		mt.erase(mt.find(x));
		cout<<(*(--mt.end()))<<"\n";
		mt.insert(x);
	}
	
}

Measured memory_bytes: 11776
x,k,d = map(int,input().split())

if(x < 0):
  i = int(abs(x)/d)
  if(k > i):
    k = k - i
    x = x + d*i
  else:
    x = x + d*k
    k = 0
  if(abs(x) > abs(x - d)):
    k += 1
    x = x - d
elif(x > 0):
  i = int(abs(x)/d)
  if(k > i):
    k = k - i
    x = x - d*i
  else:
    x = x - d*k
    k = 0
  if(abs(x) > abs(x + d)):
    k += 1
    x = x + d

if(x == 0):
  if(k%2 == 0):
    print(0)
  else:
  	print(d)
else:  
  if(k%2 == 0):
    print(abs(x))
  else:
    print(min(abs(x+d),abs(x-d)))

Measured memory_bytes: 9240
num = int(input())

shops = {}
narabi = []

for _ in range(num):
    narabi.append(input().split())

jun = 1

for val in narabi:
    name, pt = val
    if name not in shops:
        shops[name] = {}
    shops[name][pt] = jun
    jun+=1

for name in shops:
    shops[name] = sorted(shops[name].items(),key=lambda x: int(x[0]),reverse=True)

shops = sorted(shops.items(), key=lambda x: x[0])

for name in shops:
    for v in name[1]:
        print(v[1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
int32_t main()
{
    int n;
    cin>>n;
    int m=1e9+7;
     int ans=1;
     for(int i=2;i<=n;i++)
     ans=(ans*i)%m;
     cout<<ans<<endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
typedef long long ll;
using namespace std;
void read(int &x){int f=1;x=0;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}x*=f;}
void write(int x){if(x<0){putchar('-');x=-x;}if(x>9)write(x/10);putchar(x%10+'0');}
int main(){
	char a[15],b[15],c[15];
	cin>>a>>b>>c;
	int l1=strlen(a);
	int l2=strlen(b);
	int f1=0,f2=0;
	if(a[l1-1]==b[0])f1=1;
	if(b[l2-1]==c[0])f2=1;
	if(f1&&f2){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    using P = tuple<int, int, int>;
    static P dp[3005][3005];
    
    string S, T;
    cin >> S >> T;
    const int N = sz(S), M = sz(T);

    rep(i, N + 1)rep(j, M + 1)dp[i][j] = MT(0, -1, -1);

    rep(i, N + 1)rep(j, M + 1) {
        rep(p, 2)rep(q, 2) {
            smax(dp[i + p][j + q], dp[i][j]);
        }

        if (S[i] == T[j]) {
            smax(dp[i + 1][j + 1], MT(get<0>(dp[i][j]) + 1, i, j));
        }
    }

    {
        string ans;
        int x, i, j;
        tie(x, i, j) = dp[N][M];
        while (x > 0) {
            ans += S[i];
            tie(x, i, j) = dp[i][j];
        }
        reverse(all(ans));
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 105984
#include <stdio.h>

typedef long long ll;
 
int main(void) {
	
	ll N;
	
	scanf("%lld",&N);
	
	ll h,n,w;
	
	for(h=1ll;h<=3500ll;h+=1ll){
		for(n=1ll;n<=3500ll;n+=1ll){
			if(((4ll*h*n)-(N*h)-(N*n))!=0ll){
			ll div=(N*h*n)%((4ll*h*n)-(N*h)-(N*n));
			w=(N*h*n)/((4ll*h*n)-(N*h)-(N*n));
			if(w>0ll&&div==0ll){
				printf("%lld %lld %lld\n",h,n,w);
				return 0;
			}
			}
		}
	}
	
	
	return 0;
}

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

int n;
int w;
vector< vector<int> > items;
vector< vector<int> > dp;

int knapp(int item, int weight){
	if(item == n || dp[item][weight] == -1){
		if(item == n){
			return 0;
		}
		else{
			if(weight - items[item][0] >= 0){
				dp[item][weight] = max(dp[item][weight], items[item][1] + knapp(item+1, weight - items[item][0]));
			}
			dp[item][weight] = max(dp[item][weight], knapp(item+1, weight));
			return dp[item][weight];
		}
	}
	else{
		return dp[item][weight];
	}
}

main(){
	cin >> n >> w;
	
	items.resize(n, vector<int>(2));
	dp.resize(n, vector<int>(w+1, -1));

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

	cout << knapp(0, w) << "\n";
}

Measured memory_bytes: 79488
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e15
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	bool check = false;
	int n, m, i, j, k;
	cin >> n >> m;
	vector<ll> score(n, INF);
	vector<vector<ll>> G(n, vector<ll>(n, INF));
	vector<bool> c(n, false);

	for (i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		G[a][b] = -c;
	}

	score[0] = 0;

	for (i = 0; i < n; i++) {
		bool update = false;
		for (j = 0; j < n; j++) {
			for (k = 0; k < n; k++) {
				if (G[j][k] != INF && score[j] != INF && score[k] > score[j] + G[j][k]) {
					score[k] = score[j] + G[j][k];
					update = true;
				}
			}
		}
		if (!update)break;
	}

	
	for (j = 0; j < n; j++) {
		for (k = 0; k < n; k++) {
			if (G[j][k] != INF && score[j] != INF && score[k] > score[j] + G[j][k]) {
				score[k] = score[j] + G[j][k];
				c[k] = true;
			}
			if (G[j][k] != INF && c[j])c[k] = true;
		}
	}
	


	if (c[n-1])cout << "inf" << endl;
	else cout << -score[n - 1] << endl;


	return 0;
}

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

int main()
{
    string s;
    cin >> s;

    int ans = 700;
    for(int i = 0; i < 3; i++)
        if(s[i] == 'o') ans += 100;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 



int main()
{ 
    LL n,m,v,p;
    cin>>n>>m>>v>>p;
    LL a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n);
    reverse(a,a+n);
    //大きい方からの累積和
    LL s[n];
    for(int i=0;i<n;i++){
        if(i==0){s[i]=a[i];}
        else{s[i]=s[i-1]+a[i];}
    }

    //上からcheck
    int ans=0;
    for(LL i=0;i<n;i++){
        if(i<p){ans++;}//上からp問は自明
        else{
            LL x;//border
            x=a[i]+m;//xより大きいのはp-1問
            if(a[p-1]<=x){//必要条件
                LL y;
                y=m*(v-p+1-n+i);
                //if(y<0){y=0;}
                LL z;
                z=s[i-1]-s[p-2];
                if(x*(i-p+1)>=z+y){ans++;}
                //cout<<i<<' '<<x<<' '<<y<<' '<<z<<endl;
            }
        }
    }

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

Measured memory_bytes: 1792
/*
      author : nishi5451
      created: 11.08.2020 20:00:00
*/

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


int main(){
    int x,a,b;
    cin >> x >> a >> b;
    int ans = x-a;
    ans%=b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
unsigned long long n,backupn,ans=0;
unsigned long long t5=5;
int main() {
	cin>>n;
	if(n&1) {
		cout<<0;
		exit(0);
	}
	for(int i=1;t5<=n;i++,t5*=5)
		ans+=n/t5/2;
	cout<<ans;
	return 0;
}

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

//31
typedef long long ll;

ll power(ll a , ll b) {
    ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans  * a;
		}
		a = a * a;
		b  /= 2;
	}
	return ans;
}

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> v(n);
	string s;
	cin >> s;
	int p = 0;
	for (int i = 0; i + 1 < n;) {
		v[i] = p;
		if (s[i] == 'A' && s[i + 1] == 'C') {
			p++;
			v[i + 1] = p;
			i += 2;
		}else {
		    i++;
		}
	}
	v[n - 1] = p;
	//for (int i = 0; i < n; ++i) {
		//cout << v[i] << " "<< i << endl;
	//}
	for (int i = 0; i < q; ++i) {
		int l, r;
		cin >> l >> r;
		l--,r--;
		//if(l == 0) {
		//	cout << v[r] << "--"<< endl;
		//}else {
			cout << v[r] - v[l] << endl; 
		//}
	}
}


Measured memory_bytes: 3860
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include <cstring>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  sort(a,a+n);
  if(a[n-1] < sum - a[n-1]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var vals = Console.ReadLine().Split().Select(a => int.Parse(a)).ToList();
    long W=vals[0];
    long H=vals[1];
    long x=vals[2];
    long y=vals[3];
    long w=W-x;
    if(w>x){w=x;}
    long h=H-y;
    if(h>y){h=y;}
    double S1=w*H;
    double S2=h*W;
    bool flag=false;
   /* if(S1==0&&S2==0){
        flag=true;
    }*/
    if(S1==0){
        S1=W*H*0.5;
        flag=true;
    }
    if(S2==0){
        S2=W*H*0.5;
        flag=true;
    }
    if(S1!=W*H*0.5&&S2!=W*H*0.5){
        S1=S2=W*H*0.5;
        flag=true;
    }
    if(S1>S2){
        Console.WriteLine("{0} {1}",S1,0);
    }
    else if(S1==S2){
        if(flag){
            Console.WriteLine("{0} {1}",S1,0);
        }
        else{
         Console.WriteLine("{0} {1}",S1,1);}
    }
    else{
           Console.WriteLine("{0} {1}",S2,0);
    }
    
    }
}


Measured memory_bytes: 13396
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T.copy()
    T_new[P-1] = X
    print(np.array(T_new).sum())

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

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

Measured memory_bytes: 256
s = input()
n = len(s)
k = 'keyence'
for i in range(7):
    if s[i] != k[i]:
        break
else:
    i += 1
tmp = i
for i in range(7):
    if s[n - i - 1] != k[6 - i]:
        break
else:
    i += 1
if i + tmp >= 7:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 38384
<?php
  list($a, $b, $c, $d) = explode(" ", trim(fgets(STDIN)));

  $takahashi = intdiv(($c + $b - 1), $b);
  $aoki = intdiv(($a + $d - 1), $d);

  if($takahashi > $aoki){
    echo "No";
  }else{
    echo "Yes";
  }

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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


int main(){
	int x;
	cin>>x;
	if(x<100){
		cout<<0<<endl;
		return 0;
	}

	int a=x/100;
	if(x%100==0){
		cout<<1<<endl;
		return 0;
	}

	int b=x%100;
	for (int i = 0; i <= 20; i++){
		if(i>b)continue;
		for (int j = 0; j <= 25; j++){
			if(i+j>b)continue;
			for (int k = 0; k <= 33; k++){
				if(i+j+k>b)continue;
				for (int l = 0; l <= 50; l++){
					if(i+j+k+l>b)continue;
					for (int m = 0; m <= 100; m++){
						if(i+j+k+l+m>b)continue;
						if(i*5+j*4+k*3+l*2+m==b&&i+j+k+l+m<=a){
							cout<<1<<endl;
							return 0;
						}
					}
				}
			}
		}
	}

	cout<<0<<endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long int MOD = 1000 * 1000 * 1000 + 7;

// 834732659
int main()
{

// 2

long int n,k;
cin >> n >> k;

long int res = 0;
long int now = n + 1;

for (int i=1; i<=n+1; i++)
{
    if (i>=k) {res += now; res%=MOD;}
    now +=  n - 2 * i;
    now%=MOD;
    if (now<0) now+=MOD;
}

cout << res ;












}







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

int main()
{
int r;
cin >> r;
cout << 2 * r * 3.14159265359;
}
*/


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    int n,i,j,k,a;
    cin >> n;
    int amax = 0;
    for(i=0;i<n;i++)
    {
        cin >> a;
        cnt[a]++;
        amax = max(amax,a);
    }
    int mid ;
    if(amax%2==0)
    {
        mid=amax/2;
        if(cnt[mid]!=1)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    else
    {
        mid = (amax+1)/2;
        if(cnt[mid]!=2)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    int m = cnt[mid];
    for(i=amax;i>mid;i--)
    {
        if(cnt[i]<2)
        {
            cout << "Impossible" << endl;
            return 0;
        }
        m += cnt[i];
    }
    if(m==n)
    {
        cout << "Possible" << endl;

    }
    else cout << "Impossible" << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
	#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
	#define debug(x...)
	#define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif
	
	int a;
	cin >> a;
	cout << a  + a * a + a * a * a << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


Measured memory_bytes: 3616
N=int(input())
LR=[None]*N
for i in range(N):
    LR[i]=list(map(int,input().split()))

RAN=(len(LR)+1)//2

LR_L=sorted(LR,key=lambda x: x[0],reverse=True)
LR_R=sorted(LR,key=lambda x: x[1])

ANS_l=[0]*(RAN*2+2)
ANS_r=[0]*(RAN*2+2)

for i in range(RAN):
    ANS_l[2*i+1]=ANS_l[2*i]+LR_L[i][0]
    ANS_l[2*i+2]=ANS_l[2*i+1]-LR_R[i][1]

    ANS_r[2*i+1]=ANS_r[2*i]-LR_R[i][1]
    ANS_r[2*i+2]=ANS_r[2*i+1]+LR_L[i][0]


print(max(max(ANS_l)*2,max(ANS_r)*2))

Measured memory_bytes: 38272
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3000 + 5;

int n, m;
int64_t cell[maxN][maxN];
int64_t memo[maxN][maxN][4];

int64_t dp(int row, int col, int rem) {
    if(row == n && col == m) {
        int64_t best = 0;

        if(rem > 0) {
            best = cell[row][col];
        }

        return best;
    }

    if(memo[row][col][rem] != -1) {
        return memo[row][col][rem];
    }

    int64_t ans = 0;

    if(col + 1 <= m) {
        ans = max(ans, dp(row, col + 1, rem));
        if(rem - 1 >= 0) {
            ans = max(ans, dp(row, col + 1, rem - 1) + cell[row][col]);
        }
    }

    if(row + 1 <= n) {
        ans = max(ans, dp(row + 1, col, 3));
        if(rem - 1 >= 0) {
            ans = max(ans, dp(row + 1, col, 3) + cell[row][col]);
        }
    }

    return memo[row][col][rem] = ans;
}

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

    int k;
    cin >> n >> m >> k;

    for(int i = 0; i < k; i++) {
        int r, c, v;    cin >> r >> c >> v;
        cell[r][c] = v;
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            for(int rem = 0; rem <= 3; rem++) {
                memo[i][j][rem] = -1;
            }
        }
    }

    cout << dp(1, 1, 3) << '\n';

    return 0;
}


Measured memory_bytes: 356196
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
 
using namespace std;
typedef pair<double,double> pp;
vector<pp> a;
 
#define sqr(x) ((x)*(x))
double Plus (double x){
    return x<0?-x:x;
}
double dist (pp x, pp y){
    return sqr(x.first-y.first) + sqr(x.second-y.second);
}
 
double go (int l, int r)
{
    if (r-l==1)
        return dist(a[l],a[r]);
    if (r-l==2)
        return min(dist(a[l],a[l+1]), min(dist(a[l],a[l+2]), dist(a[l+1],a[l+2])));
 
    int m=(l+r)/2;
    double d=min(go(l,m),go(m+1,r));
 
    vector<pp> v;
    for (auto i=l;i<=r;i++)
        if (sqr(a[i].first-a[m].first)<d)
            v.emplace_back (a[i].second,a[i].first);
    sort (v.begin(),v.end());
    for (auto i=v.begin();i!=v.end();i++)
        for (auto j=i+1;j!=v.end();j++)
        {
if (sqr(j->first - i->first) > d) break;
            d=min(d,dist(*i,*j));
        }
    return d;
}
 
int main ()
{
    int i,n;
    double x,y;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
        scanf ("%lf%lf",&x,&y), a.emplace_back(x,y);
    sort (a.begin(),a.end());
    printf ("%lf ",sqrt(go(0,n-1)));
}



Measured memory_bytes: 6912
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
i = 0
while i < n:
    res = 0
    for j in range(i, n):
        if a[j] == 0: break
        res += a[j]
    ans += res // 2
    i = j + 1

print(ans)


Measured memory_bytes: 7072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int maxn=2003;
int a[maxn],n,g[maxn][maxn],vis[maxn],in[maxn];
vector<int>G[maxn];
int gcd(int a,int b) { return a==0?b:gcd(b%a,a); }
void dfs(int now)
{
    vis[now]=1;
    for(int i=1;i<=n;i++)
        if(!vis[i] and g[now][i])
        {
            in[i]++;
            G[now].push_back(i);
            dfs(i);
        }
}
void Top()
{
    priority_queue<int>que;
    for(int i=1;i<=n;i++) if(!in[i]) que.push(i);
    while(!que.empty())
    {
        int x=que.top(); que.pop();
        cout<<a[x]<<' ';
        for(int i=0;i<(int)G[x].size();i++)
            que.push(G[x][i]);
    }
}
int main()
{
    //freopen("t.in","r",stdin);
    //freopen("t.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(gcd(a[i],a[j])!=1)
                g[i][j]=g[j][i]=1;
    for(int i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
    Top();
    return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
long long n,k1;
long long a[200000];
int main(void)
{
	scanf("%lld%lld",&n,&k1);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	long long sum=0;
	for(i=0;i<n-k1;i++)
	{
		sum+=a[i];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1792
import bisect

def solve(n,m,s,t):
    res = 0
    for string in s:
        plus = bisect.bisect_right(s,string)
        plus -= bisect.bisect_left(s,string)
        minus = bisect.bisect_right(t,string)
        minus -= bisect.bisect_left(t,string)
        tmp = plus - minus
        res = max(res,tmp)
    return res

if __name__ == '__main__':
    n = int(input())
    s = []
    for i in range(n):
        si = input()
        bisect.insort_left(s,si)
    m = int(input())
    t = []
    for i in range(m):
        ti = input()
        bisect.insort_left(t,ti)
    print(solve(n,m,s,t))
        

Measured memory_bytes: 38512
#include <iostream>
#include <set>

int main() {
  int v[3];
  std::cin >> v[0] >> v[1] >> v[2];
  std::set<int> numn(v, v+3);

  if (numn.size() == 2) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}

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

using namespace std;

int main()
{
	int h1, h2, k1, k2, a, b, c, d;

	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;

	int h = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
	int k = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;

	if (h == k)
	{
		cout << "even" << endl;
	}
	else if (h > k)
	{
		cout << "hiroshi" << endl;
	}
	else
	{
		cout << "kenjiro" << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define lc (p<<1)
#define rc ((p<<1)|1)
typedef long long ll;
const int mod=998244353;
inline int add(int a,int b)
{
	if((a+=b)>=mod)a-=mod;
	return a;
}
inline int dec(int a,int b)
{
	if((a-=b)<0)a+=mod;
	return a;
}
inline int mult(int a,int b)
{
	long long t=1ll*a*b;
	if(t>=mod)t%=mod;
	return t;
}
inline int power(int a,int b)
{
	int out=1;
	while(b)
	{
		if(b&1)out=mult(out,a);
		a=mult(a,a);
		b>>=1;
	}
	return out;
}
int T;
ll n;
int a,b,c,d;
unordered_map<ll,ll> mp;
inline ll calc(ll v)
{
    if(!v)return 0;
    if(mp.find(v)!=mp.end())return mp[v];
    ll ans=5e18;
    if(v<=5e18/d)ans=min(ans,v*d);
    if(v==1)return ans;
    ll up=(v/2+1)*2;
    if(v!=2)ans=min(ans,calc(up/2)+a+(up-v)*d);
    up=v/2*2;
    ans=min(ans,calc(up/2)+a+(v-up)*d);
    up=(v/3+1)*3;
    ans=min(ans,calc(up/3)+b+(up-v)*d);
    up=v/3*3;
    ans=min(ans,calc(up/3)+b+(v-up)*d);
    up=(v/5+1)*5;
    ans=min(ans,calc(up/5)+c+(up-v)*d);
    up=v/5*5;
    ans=min(ans,calc(up/5)+c+(v-up)*d);
    return mp[v]=ans;
}
void solve()
{
    mp.clear();
    scanf("%lld%d%d%d%d",&n,&a,&b,&c,&d);
    printf("%lld\n",calc(n));
}
int main()
{
    scanf("%d",&T);
    while(T--)solve();
    return 0;
}


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

using namespace std;

bool ok[10];

bool f(int x)
{
    while(x)
    {
        int d=x%10;
        x/=10;
        if(ok[d]==false) return false;
    }
    return true;
}

int main()
{
    int n; cin>>n;
    int k; cin>>k;
    for(int i=0;i<10;i++) ok[i]=true;
    for(int i=1;i<=k;i++)
    {
        int x; cin>>x; ok[x]=false;
    }
    while(f(n)==false) n++;
    cout<<n;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		int i;
		boolean flag = false;
		for(i = A; i<= B;i++) {
			if(i%K ==0) {
				flag = true;
				break;
			}
		}

		if(flag == true) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}

		System.out.println();
	}

}

Measured memory_bytes: 35828
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    mapM print $ map (\g -> length g - 1) $ group  $ sort $ [1..n] ++ as

Measured memory_bytes: 55776
#include<iostream>
using namespace std;
int main()
{
  int n,j,i,temp=1,count=0,flag=0;
  cin>>n;
  for( j=0;j<n;j++)
  {
  	cin>>i;
    if(i!=temp)
      count++; 
    if(i==temp)
      temp++;
  }
  if(temp==1)
      cout<<"-1";
  else
  	cout<<count;
  return 0;
}  

Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
 
public class Main {
 
 
    public static void main(String[] args){
        int a = 0;
        int b = 0;
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while(true){
                String[] arr = br.readLine().split(" ");
                 
                a = Integer.parseInt(arr[0]);
                b = Integer.parseInt(arr[2]);
                String op = arr[1];
                 
                if("+".equals(op)){
                    System.out.println(a+b);
                }else if("-".equals(op)){
                    System.out.println(a-b);
                }else if("*".equals(op)){
                    System.out.println(a*b);
                }else if("/".equals(op)){
                    System.out.println(a/b);
                     
                }else{
                    break;
                }
                 
                 
            }
        }catch(IOException e){
             
        }
 
    }
}

Measured memory_bytes: 24420
#include<cstdio>
#include<cstdlib>
#define NIL NULL

struct node {
  struct node * right;
  struct node * left;
  struct node * parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x) {};
Node treeMaximum(Node x) {};

Node treeSearch(Node u, int k) {
  Node x = u;

  while (x != NIL) {
    if (k < x->key) x = x->left;
    else if (x->key < k) x = x->right;
    else break;
  }

  return x;
};

Node treeSuccessor(Node x) {};

void treeDelete(Node z) {
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if (y == NIL) root = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", &com);
    if (com[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'f') {
      scanf("%d", &x);
      Node n = treeSearch(root, x);
      if (n == NIL) printf("no\n");
      else printf("yes\n");
    }
  }

  return 0;
}



Measured memory_bytes: 21320
nu,mo = gets.chomp.split(" ").map(&:to_i)

if nu*1000 > mo || nu*10000 < mo
  puts "-1 -1 -1"
  exit
end

for i in 0..mo / 10000
  for j in 0..(mo - i*10000) / 5000
    if i*10000 + j*5000 + (nu - i - j)*1000 == mo
      print i
      print " "
      print j
      print " "
      print nu - i - j
      exit
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 1788
N = int(input())
s = 1
t = 0
while N > 26**s + t:
    t += 26**s
    s += 1
N -= t
ans = []
for i in range(s):
    c = 0
    while N > 26**(s-i-1):
        N -= 26**(s-i-1)
        c += 1
    ans.append(chr(97+c))
print("".join(ans))

Measured memory_bytes: 9188
N = int(input()) 
hs = list(map(int,input().split()))


def minus(x,y): 
    if x > 0:
        return(x - y) 
    else:
        return(x)

def non_zero_min(hs):
    hmin = 1000000 
    for h in hs: 
        if h > 0: 
            if h < hmin: 
                hmin = h 
    return(hmin)


def zero_div_counter(hs):
    length = 0
    n_div = 0
    for i in range(len(hs)):
        h = hs[i]
        if h > 0:
            length += 1
        elif h == 0:
            if length > 0:
                n_div += 1
                length = 0
            else:
                length = 0  
        if i == len(hs)-1:
            if length > 0:
                n_div += 1
    return(n_div)

count = 0

orig_max = max(hs)

for i in range(N):
    # count separation
    n_div = zero_div_counter(hs)
#     print("ndiv: ",n_div)
    nz_min = non_zero_min(hs)
    
    # add count with considering separation
    count += n_div * nz_min
#     print("count:",count)
    
    # update hs
    hs = [minus(x,nz_min) for x in hs] 
#     print("hs  :",hs)

print(count)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int stoi(const char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return -1;
  }
}

int main() {
  ll n, h_tmp, first = 0;
  bool flag;
  cin >> n;
  vector<ll> x(n), y(n), h(n);
  rep(i, n) {
    cin >> x[i] >> y[i] >> h[i];
    if (!first && h[i] > 0) first = i;
  }

  rep(i, 101) {
    rep(j, 101) {
      h_tmp = h[first] + abs(x[first] - i) + abs(y[first] - j);

      flag = true;
      rep(k, n) {
        if (h[k] != max(h_tmp - abs(x[k] - i) - abs(y[k] - j), (ll)0)) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << i << ' ' << j << ' ' << h_tmp;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	int i;
	char s[100010];
	scanf("%s", s);
	i = strlen(s) - 1;
	while (i >= 0)
	{
		if (s[i - 4] == 'd' && s[i - 3] == 'r' && s[i - 2] == 'e' && s[i - 1] == 'a' && s[i] == 'm') {
			i -= 5;
		}
		else if (s[i - 6] == 'd' && s[i - 5] == 'r' && s[i - 4] == 'e' && s[i -3] == 'a' && s[i- 2] == 'm' && s[i - 1] == 'e' && s[i] == 'r') {
			i -= 7;
		}
		else if (s[i - 4] == 'e' && s[i - 3] == 'r' && s[i - 2] == 'a' && s[i - 1] == 's' && s[i] == 'e') {
			i -= 5;
		}
		else if(s[i - 5] == 'e' && s[i - 4] == 'r' && s[i - 3] == 'a' && s[i - 2] == 's' && s[i - 1] == 'e' && s[i] == 'r'){
			i -= 6;
		}
		else
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <utility>
#include <fstream>
#include <bitset>
#include <unordered_map>
#include <set>
using namespace std;
 
#define ll long long
#define ldb long double
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k;
	cin >> n >> k;
	
	cout << min(n % k, k - (n % k));
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())

list=[]
for i in range(n):
 x,l=map(int,input().split())
 list.append([x-l,x+l])
list=sorted(list,key=lambda x:x[1])

cnt=0
min=-10**18

for r,l in list:
 if min<=r:
  cnt+=1
  min=l
print(cnt)

Measured memory_bytes: 22104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

vector<int>G[100010];
vector<int>dp(100010,0);
int r(){int x;cin>>x;return x;}
int dfs(int v){
    int &count=dp[v];
    if(count)return count;
    for(auto it:G[v])count=max(count,dfs(it)+1);
    return count;
}

void solve() 
{
    int n,m,ans=0;cin>>n>>m;
    REP(i,m)G[r()-1].pb(r()-1);
    REP(i,n)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
int buf[10005];
int A[10005];
int B[10005];
int H,N;
int F(int x)
{
    int i,a,minf;
    if(x<=0) return 0;
    if(buf[x]!=-1)return buf[x];
    else
    {
        minf=1000000000;
        for(i=0; i<N; i++)
        {
            a=F(x-A[i])+B[i];
            if(minf>a)
            {
                minf=a;
            }
        }
        buf[x]=minf;
        return minf;
    }
}
int main()
{
    scanf("%d%d",&H,&N);
    int i;
    for(i=0; i<N; i++)
    {
        scanf("%d%d",&A[i],&B[i]);
    }
    for(i=0;i<10005;i++)
    {
        buf[i]=-1;
    }
    printf("%d\n",F(H));
    return 0;
}

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

ll a, b, n;

int main ()
{
	cin >> a >> b >> n;
	ll l = 0;
	ll r = n;
	ll maxx = floor((a*1)/b) - a * floor(1/b);;
	while (r >= l)
	{
		ll mid = (l + r) / 2;
		ll x = mid;
		ll res = floor((a*x)/b) - a * floor(x/b);
		//cout << mid << endl;
		if (res < maxx) {
			r = mid;
		} else {
			l = mid+1;
		}
		maxx = max(maxx, res);
		if (l == r) {
			x = l;
			res = floor((a*x)/b) - a * floor(x/b);
			maxx = max(maxx, res);
			break;
		}
	}
	cout << maxx << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}
int32_t main()
{
	k_007();
	// int JUDGE_ONLINE = 1;
	// if (fopen("ip1.txt", "r")) {
	// 	JUDGE_ONLINE = 0;
	// 	assert(freopen("ip1.txt", "r", stdin));
	// 	assert(freopen("op1.txt", "w", stdout));
	// }
	int a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	// if (!JUDGE_ONLINE) {
	// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	// }
}


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    int x, k;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; ++i) {
        cout << i << ' ';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N); for (auto &a : A) cin >> a;
    sort(rbegin(A), rend(A));
    int total = accumulate(begin(A), end(A), 0);
    bool ans = true;
    for (int i = 0; i < M; i++) {
        if (4 * M * A[i] < total) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;

int findDigits(int n){
	int cnt=0;
  	while(n>0){
    	n= n/10;
      	cnt++;
    }
  
  return cnt;
}

int main(){

  int N;
  
  cin >> N;
  
  int cnt=0;
  for(int i=1; i<=N; i++){
	int answer = findDigits(i);
    if(answer%2 !=0)
      cnt++;
  }
 
  cout << cnt << endl;
  

  
  return 0;
  
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


int imos(const vector<vector<int>> &f, int si, int sj, int ei, int ej) {
    if (si > ei || sj > ej) return 0;
    int res = f[ei][ej];
    if (si > 0) {
        res -= f[si - 1][ej];
    }
    if (sj > 0) {
        res -= f[ei][sj - 1];
    }
    if (si > 0 && sj > 0) {
        res += f[si - 1][sj - 1];
    }

    return res;
}

void solve(long long N, long long K, std::vector<long long> x, std::vector<long long> y, std::vector<std::string> c){
    vector<vector<int>> b(K + 1, vector<int>(K + 1)), w(K + 1, vector<int>(K + 1));
    for (int i = 0; i < N; ++i) {
        char t = c[i][0];
        int xx = x[i] / K % 2, yy = y[i] / K % 2;
        if (xx ^ yy) {
            if (t == 'W') {
                t = 'B';
            } else {
                t = 'W';
            }
        }

        int tx = x[i] % K, ty = y[i] % K;
        if (t == 'W') {
            w[tx][ty]++;
        } else {
             b[tx][ty]++;
        }
    }
    for (int i = 0; i < K + 1; ++i) for(int j = 0; j < K + 1; ++j) {
        if (j > 0) {
            w[i][j] += w[i][j - 1];
            b[i][j] += b[i][j - 1];
        }
        if (i > 0) {
            w[i][j] += w[i - 1][j];
            b[i][j] += b[i - 1][j];
        }
        if (i > 0 && j > 0) {
            w[i][j] -= w[i - 1][j - 1];
            b[i][j] -= b[i - 1][j - 1];
        }
    }
    int res = 0;
    for(int i = 0; i < K; ++i) for(int j = 0; j < K; ++j) {
        res = max(res, imos(w, 0, 0, i - 1, j - 1) + imos(w, i, j, K - 1, K - 1) + imos(b, i, 0, K - 1, j - 1) + imos(b, 0, j, i - 1, K - 1));
        res = max(res, imos(b, 0, 0, i - 1, j - 1) + imos(b, i, j, K - 1, K - 1) + imos(w, i, 0, K - 1, j - 1) + imos(w, 0, j, i - 1, K - 1));
    }
    cout << res << endl;
}

signed main(){
	ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<std::string> c(N);
    for(int i = 0 ; i < N ; i++){
        cin >> x[i] >> y[i];
        std::cin >> c[i];
    }
    solve(N, K, std::move(x), std::move(y), std::move(c));
    return 0;
}

Measured memory_bytes: 23040
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <string>
#define LL long long
using namespace std;
int a[310000],m,n,q=0,t,l=1;
string  s;
int main()
{
    cin>>s;
    if(s[s.size()-1]=='1')
    {
             cout<<-1<<endl;
            return 0;
    }
    if(s[0]=='0')
    {
             cout<<-1<<endl;
            return 0;
    }
    for(int x=0;x<s.size();x++)
    {
        if(a[x]==0)
        {a[s.size()-2-x]=1;
        if(s[x]=='1')
        {
            t++;
        }
        if(s[x]!=s[s.size()-(x+1)-1])
        {
            cout<<-1<<endl;
            return 0;
        }
        }
        else{
            break;
        }
    }
    int ll=1,le=s.size(),q=1,ql=2;
        while(ll<=le-ll)
        {
            if(s[ll-1]=='1')
            {
                cout<<q<<" "<<ql<<endl;
                q=ql;
            }
            else
            {
                cout<<q<<" "<<ql<<endl;
            }
            ql++;
            ll++;
        }
        for(int x=ql;x<=s.size();x++)
        {
            cout<<q<<" "<<x<<endl;
        }

}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string str;
  cin >> str;

  if (str[0] == 'A') {
    rep(i,3) {
      if (str[i] == 'B') {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }else {
    rep(i,3) {
      if (str[i] == 'A') {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int A,B;
	scanf("%d", &A); scanf("%d", &B);

	if (A + B >= A - B && A + B >= A * B)
		printf("%d", A + B);
	else if(A - B >= A + B && A - B >= A * B)
		printf("%d", A - B);
	else 
		printf("%d", A * B);
	return 0;

}

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

const int inf = 1e9;
const ll linf = 1e18;

template <typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) { return b ? gcd(b, a % b) : a; }
template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) { return (a != 0 && b != 0) ? a / gcd(a, b) * b : 0; }

template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
gcd(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = gcd(res, *first);
    return res;
}

template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
lcm(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = lcm(res, *first);
    return res;
}

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << lcm(a.begin(), a.end()) << endl;
    return 0;
}


Measured memory_bytes: 3212