akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>

using namespace std;

long long cnt = 0;
int A[1000000];
vector<int> G;


void shellSort(int A[], int n) {
    /*int h = 1;
    while(h < n) {
        G.push_back(h);
        h = h * 3 + 1;
    }*/
    //int h = 1;
    //while(h < n/3) h = 3*h + 1;

    for(int h = 1; ;) {
        if(h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for(int m = G.size()-1; m >= 0; m--) {
        int h = G[m];
        for(int i = h; i < n; i++) {
            for(int j = i; j >=h && A[j] < A[j-h]; j = j-h) {
                int temp = A[j];
                A[j] = A[j-h];
                A[j-h] = temp;
                cnt++;
            }
        }
    }

}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    cnt = 0;
    shellSort(A, n);

    cout << G.size() << endl;

    for(int i = G.size()-1; i >=0; i--) {
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");

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

    for(int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }
    return 0;
}

Measured memory_bytes: 7188
#include <cstdio>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a + b == 15) {
        printf("+\n");
    } else if (a * b == 15) {
        printf("*\n");
    } else {
        printf("x\n");
    }

    return 0;
}

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

int main()
{   
    long long n,a,b;
    cin>>n;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            a = i;
            b = n/a;
        }
    }

    cout<<a-1+b-1<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
ll GCD(ll x, ll y) {
    if ( y == 0) return x;
    else return GCD(y, x % y);
}

ll solve(int n,ll m,vector<ll> &a){
    bool same = true;
    while(a[0]%2==0){
        for(int i = 0;i < n;i++){
            if(a[i]%2 != 0)return 0;
            a[i]/=2;
        }
        m/=2;
    }
    rep(i,n) if(a[i]%2==0) return 0;

    ll lcm = 1;
    rep(i,n){
        ll g = GCD(lcm,a[i]);
        lcm = lcm/g*a[i];
        if(lcm > m) return 0;
    }
    return (m/lcm+1)/2;
}

int main(void){
    // Your code here!
   int n;ll m;cin >> n >> m;
   vector<ll> a(n);
   rep(i,n) cin >> a[i],a[i]/=2;
   cout << solve(n,m,a) << endl;
}


Measured memory_bytes: 1152
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;
const ll mod1=1e9+7;
const ll mod2=998244353;
const int INF=0x3f3f3f3f;
int n,ans,a[1005],k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)	cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=k;i++)	ans+=a[i];
	cout<<ans;




	return 0;
}


Measured memory_bytes: 3128
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve() {
  ins(S);

  vector<bool> appeared(26, false);
  for (auto c : S) {
    if (appeared[c - 'a']) {
      out("no");
      return;
    }

    appeared[c - 'a'] = true;
  }

  out("yes");
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	char prime[1000001];
	int i, j;
	int n;
	
	for (i = 0; i <= 1000000; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	
	for (i = 0; i <= 1000; i++){
		if (prime[i] == 1){
			for (j = 2; j <= 1000000 / i; j++){
				prime[i * j] = 0;
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		j = 0;
		for (i = 2; i <= n; i++){
			if (prime[i] == 1){
				j++;
			}
		}
		
		printf("%d\n", j);
	}
	
	return (0);
}

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

#define MAXPOS 2000

int main(void){
    int num;    cin >> num;
    int pos[num];   for(int i = 0; i < num; i++)    cin >> pos[i];
    int minpos = MAXPOS, maxpos = 0;
    for(int i = 0; i < num; i++){
        if(pos[i] < minpos) minpos = pos[i];
        if(pos[i] > maxpos) maxpos = pos[i];
    }
    if(!((maxpos - minpos) % 2))   cout << (maxpos - minpos) / 2 << endl;
    else    cout << (maxpos - minpos) / 2 + 1 << endl;
}


Measured memory_bytes: 3096
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")

Measured memory_bytes: 62588
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    ll ans = 0;
    if (v[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        if (v[i - 1] < v[i])
        {
            if (v[i - 1] + 1 != v[i])
            {
                cout << -1 << endl;
                return 0;
            }
            else
                ans++;
        }
        else
            ans += v[i];
    }
    cout << ans << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S, T;
    cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<char>());
    cout << (S < T ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> s[i] >> p[i];
    }
    string anss = "zzzzzzzzzzz";
    int ansp = -1, ans;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(s[j] < anss || (s[j] == anss && p[j] > ansp)){
                anss = s[j];
                ansp = p[j];
                ans = j;
            }
        }
        cout << ans + 1 << endl;
        s[ans] = anss = "zzzzzzzzzzz";
        p[ans] = ansp = -1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) {return log(b) / log(a);}

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int main() {
	std::cout << std::fixed << std::setprecision(10);

	int n;
	cin >> n;
	vector<double> p(n);
	rep(i, n) {
		cin >> p[i];
	}
	vector<vector<double>> a(n + 1);
	rep(i, n+1) {
		a[i].resize(n + 1);
	}

	rep(i, n + 1) {
		rep(j, n + 1) {
			if (i == 0) {
				if (j == 0) {
					a[i][j] = 1;
				}
				else {
					a[i][j] = 0;
				}
			}
			else if (j == 0) {
				a[i][j] = a[i - 1][j] * (1 - p[i-1]);
			}
			else {
				a[i][j] = a[i - 1][j - 1] * (p[i - 1]) 
					+ a[i - 1][j] * (1 - p[i - 1]);
			}
		}
	}
	double ans = 0;
	FOR(i, (n + 1) / 2, n + 1) {
		ans += a[n][i];
	}
	cout << ans << endl;
}


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

long long N, X;


long long lenmemo [55];
long long getlen(long long layer){
	if(layer == 0){
		return 1;
	}
	if(lenmemo[layer] != 0){
		return lenmemo[layer];
	}
	lenmemo[layer] = 3 + 2*getlen(layer-1);
	return lenmemo[layer];
}

long long patimemo[55];
long long getpati(long long layer){
	if(layer == 0){
		return 1;
	}
	if(patimemo[layer] != 0){
		return patimemo[layer];
	}
	patimemo[layer] = 1 + 2*getpati(layer-1);
	return patimemo[layer];
}

long long eat(long long len, long long layer){
	if(len == 1){
		if(layer == 0){
			return 1;
		} else {
			return 0;
		}
	}
	long long nextlayer_len = getlen(layer - 1);
	//最初のl-1 layerの途中
	if(len < nextlayer_len + 1){
		return eat(len-1, layer-1);
	}
	//最初のl-1 layerを食べきるところ
	if(len == nextlayer_len + 1){
		return getpati(layer-1);
	}
	//最初のl-1 layerと真ん中のパティまで
	if(len == nextlayer_len + 2){
		return 1 + getpati(layer-1);
	}

	//2つ目ののl-1 layerの途中
	if(len < 2 * nextlayer_len  + 2){
		return 1 + getpati(layer-1) + eat(len - nextlayer_len - 2, layer - 1);
	}
	//2つ目ののl-1 layerの食べ終わり
	if(len == 2 * nextlayer_len  + 2){
		return 1 + 2* getpati(layer-1);
	}
	//2つ目ののl-1 layerの食べ終わり + 最後のban
	if(len == 2 * nextlayer_len  + 3){
		return 1 + 2* getpati(layer-1);
	}
	exit(1);
}

int main(){
	cin >> N >> X;
	cout << eat(X, N) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstring>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if((a*b)%2==0)printf("Even\n");
	else printf("Odd\n");
}

Measured memory_bytes: 256
/*
AtCoder ABC150 D "Semi Common Multiple".
Math, Least Common Multiple.
*/
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long   llong;
typedef vector<int> vi;

template<class Type>
Type igcd(Type x,Type y){//Euclidean algorithm.
	if(x==0 or y==0) return 0;
	return (y%x)?igcd(y%x,x):x;
}

template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<llong> a(n);
	REP(i,n){
		cin>>a[i];
		a[i]/=2;
	}
	
	llong num=1LL;
	REP(i,n){
		num=ilcm(num,a[i]);
		if(num>m){
			cout<<0<<endl;
			return 0;
		}
	}
	
	REP(i,n){
		if((num/a[i])%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
		
	cout<<(m/num+1)/2<<endl;//Tech.
}


Measured memory_bytes: 1024
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vll a(n),b(m);
    vll sum1(n), sum2(m);
    ll ans = 0;
    fn(i,n) {
    cin>>a[i];
    sum1[i] = (i==0 ? a[i] : sum1[i-1]+a[i]);
    if(sum1[i] <= k)
          ans++;
    }
    fn(i,m) {
       cin>>b[i];
       sum2[i] = (i==0 ? b[i] : sum2[i-1] + b[i]);
       if(sum2[i] <= k)
       {
           int j = upper_bound(sum1.begin(),sum1.end(), k - sum2[i]) - sum1.begin();
           ans = max(ans,i+j+1);
       }
    }

    cout<<ans<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int a,b,ans=0;
  cin >> a >> b;

  ans+= a>b ? a-- : b--;
  ans+= a>b ? a-- : b--;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a==b) cout << "a == b" << endl;
    if(a>b) cout << "a > b" << endl;
    if(a<b) cout << "a < b" << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}
const int NM = 110;
const int VM = 1e5+10;
const ll INF = 1LL << 60;
int w[NM], v[NM];
ll dp[NM][VM]; // 重さの最小値


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W; cin>>N>>W;
    rep(i, N){
        cin>>w[i]>>v[i];
    }
    rep(i, NM) rep(j, VM) dp[i][j] = INF;
    dp[0][0]=0;

    for(int i=0; i<=N; i++){
        // valueに対してループ
        for(int value=0; value<VM; value++){
            // iを選ぶ
            if(value-v[i]>=0)
                chmin(dp[i+1][value], dp[i][value-v[i]]+w[i]);
            chmin(dp[i+1][value], dp[i][value]);
        }
    }
    ll ans = 0;
    for(int v=0; v<VM; v++){
        if(dp[N][v]<=W) ans = v;
    }
    cout<<ans<<endl;

}

// dp_e

Measured memory_bytes: 86272
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
using namespace std;

int main(){
	map<int,int> mp;
	map<int,int>::iterator it;
	string s;
	int a,b;
	while(getline(cin,s),!s.empty()){
		sscanf(s.c_str(),"%d %d",&a,&b);
		--mp[a];
	}
	while(cin>>s){
		sscanf(s.c_str(),"%d %d",&a,&b);
		it = mp.find(a);
		if(it!=mp.end()){
			if(it->second<0)it->second = 1-it->second;
			else ++it->second;
		}
	}
	for(it=mp.begin();it!=mp.end();++it){
		if(0<it->second)cout<<it->first<<' '<<it->second<<endl;
	}
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s.at(i);
    sort(s.begin(), s.end());
    string res;
    for (int i = 0; i < N; i++) res += s.at(i);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cmath>
#include <cctype>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

void read_un() {};
template<typename T, typename... Args> void read_un(T& x, Args&&... args) {
  x = 0; int ch = 0;
  while (!isdigit(ch = getchar())); x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (x << 3) + (x << 1) + (ch ^ '0');
  read_un(args...);
};

int main() {
  unsigned n; read_un(n);
  vector<int> h(n);
  for (auto &x : h) read_un(x);
  vector<int> f(n);
  f.at(0) = 0;
  f.at(1) = abs(h.at(1) - h.at(0));
  for (unsigned i = 2; i < n; ++i) f.at(i) = min(f.at(i - 2) + abs(h.at(i) - h.at(i - 2)), f.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
  printf("%d", f.back());
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b;
    cin >>a >> b;
    string s;
    cin >> s;
    bool flag = true;
    rep(i,a+b+1){
        if(i == a){
            if(s[i]!= '-'){
                flag = false;
            }
        }else{
            if(s[i]=='-'){
                flag = false;
            }
        }

    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
c=0
i=0
list1=[]
list2=[]


S = input('')
char_list = list(S)
c = len (char_list)
c= c-1
#print(c)

while c>1:
	if c % 2 == 0:
		d=int(c/2)
		#print (d)
		for i in range(d):
			list1.append(char_list[i]) 
			list2.append(char_list[i+d])
		#print (list1)
		#print(list2)

		if list1 == list2:
			print (len (list1)*2)
			break

		list1=[]
		list2=[]
	c=c-1

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){

int n,a[1000],i,j;

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


Measured memory_bytes: 2036
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			int N = sc.nextInt();
			int ans = N / 3;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23508
D, G = map(int, input().split())

lst = [list(map(int, input().split())) for i in range(D)]
ans = []
ref = []
for i,v in enumerate(lst):
	ref.append(v[0]*(i+1)*100 + v[1])
  
for i in range(2 ** D):
	score = 0
	cnt = 0
	for j in range(D):  
		if ((i >> j) & 1):  
			score += ref[j]
			cnt += lst[j][0]
	if (score >= G):
		ans.append(cnt)
	else:
		for l in range(D)[::-1]:
			if ((i >> l) & 1):
				continue
			for _ in range(1,lst[l][0]):
				score += (l+1) * 100
				cnt += 1
                
				if score >= G:
					ans.append(cnt)  
					break
print(min(ans))
             
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,X;
    cin >>A>>B>>X;
    if(A<=X && A+B>=X) cout <<"YES" << endl;
    else cout <<"NO" <<endl;



}


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


class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        var ret = a - (b * 2);
        Console.Write(ret < 0 ? 0 : ret);
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll l,r; cin >> l >> r;
    const ll MAX_N = 200000;
    vector<int> val(r-l+1); iota(val.begin(),val.end(),l);
    vector<int> cnt(r-l+1);
    vector<int> is_primes(MAX_N+1,true);
    is_primes[0] = is_primes[1] = false;
    for(ll i = 2; i < MAX_N; i++){
        if(!is_primes[i]) continue;
        for(ll j = 2*i; j <= MAX_N; j+=i){
            is_primes[j] = false;
        }
        ll T = i;
        while(T <= r){
            for(ll k = (l + T-1)/T*T; k <= r; k+= T){
                cnt[k-l]++;
                val[k-l]/=i;
            }
            T *= i;
        }
    }
    for(int i = 0; i < r-l+1;i++){
        cnt[i] += val[i]>1;
        res += is_primes[cnt[i]];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 11528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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



int main(){
  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005][1005],s;
string st;
int lost_map(int i,int j)
{
	return a[i][j-1]+a[i][j+1]+a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		cin>>st;
		for(int j=0;j<st.size();j++)
		  if(st[j]=='#') a[i][j+1]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			s=lost_map(i,j);
			if(a[i][j]) printf("#");
			  else printf("%d",s);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x1 = sum(a) // n
    x2 = x1 + 1
    ans1 = 0
    ans2 = 0
    for ai in a:
        ans1 += (ai - x1) ** 2
        ans2 += (ai - x2) ** 2

    print(min(ans1, ans2))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38544
import collections

N = int(input())
a = sorted(list(map(int, input().split())))

a_count = collections.Counter(a)

ans_list = []
for x in range(min(a), max(a)+1):
    ans_list.append(a_count[x-1] + a_count[x] + a_count[x+1])
        
print(max(ans_list))

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

using namespace std;

int main(){
    int x;
    int sum=0;
    scanf("%d",&x);
    for(int t=1;;t++){
        sum+=t;
        if(sum>=x){
            printf("%d\n",t);
            break;
        }
    }
    return 0;
}



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

int main() {
  string s;
  cin>>s;
  int n=s.size(), x=1,m=2019,tot=0;
  reverse(s.begin(),s.end());
  vector<int> a(m);
  long long ans=0;
  for(int i=0;i<n;i++){
    a[tot]++;
    tot+=(s[i]-'0')*x;
    tot%=m;
    ans+=a[tot];
    x=x*10%m;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3716
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	// 入力
	int N, D;
	cin >> N >> D;
	
	int answer = 0;
	// 1人の監視員iが見れる木はi - D以上、i + D以下、
	// 仮にiを3番目に置いて、Dを2にした場合
	// 1、2、3、4、5の5本の木が見れる。
	// 監視員が見れる木の数は2D + 1本である
	// 監視員を前から順に配置することが、最短の監視で済むため
	answer = ceil(N / float(2 * D + 1));
	cout << answer << endl;

	return 0;
}

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

int main() {
  
  long long A, B;
  cin >> A >> B;
  
  if (A < B) {
    
    long long r = B;
    B = A;
    A = r;
    
  }
  
  while (B > 0) {
    
    long long r = A % B;
    A = B;
    B = r;
    
  }
  
  int ans = 1;
  
  for (int i = 2; i < 1000000; i++) {
    
    int flag = 0;
    
    while (true) {
      if (A % i != 0) break;
      flag = 1;
      A /= i;
    }
    
    if (flag == 1) ans++;
    
  }
  
  if (A != 1) ans++;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

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

bool f(string& S, int n){
    bool ret = true;
    REP(i, n){
        if(S[i] != S[i+n]){
            ret = false;break;
        }
    }
    return ret;
}

void Main(){
    string S;
    cin >> S;
    for(int i=S.length()/2-1; i>=1; i--){
        if(S[i] == S[0] && f(S, i)){
            cout << 2*i << el;return;
        }
    }
}



Measured memory_bytes: 3596
N = int(input())
h = list(map(int,input().split()))
dp = [10000000000]*(N)
dp[0] = 0

for i in range(N-1):
  dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1]-h[i]))
  if i < N-2:
    dp[i+2] = dp[i] + abs(h[i+2]-h[i])
  
print(dp[-1])

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

using namespace std;

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int cnt = 0;
    for(int i = 0; i < N - 1; i++){
        if(S[i] != S[i + 1]) cnt++;
    }
    if(cnt <= K * 2) cout << N - 1 << endl;
    else{
        cnt -= K * 2;
        cout << N - 1 - cnt << endl;
    }
}

Measured memory_bytes: 3752
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
H = getList()
now = H[0]
ans = 0
for i in range(1, N):
    if now <= H[i]:
        now = H[i]
    else:
        ans += H[i - 1] - H[i]
        now = H[i]
ans += H[-1]
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>
 
int main()
{
  int x[5],i;
  scanf("%d %d %d %d %d",&x[1],&x[2],&x[3],&x[4],&x[5]);
  
  i=1;
  while (1)
  {
  	  if (x[i]==0)
      {
        printf("%d",i);
        return 0;
      }
    i+=1;
  }
  
  return 0;
}

Measured memory_bytes: 2096
# Union Find

# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


# 初期化
# 根なら-size,子なら親の頂点


N, M = map(int, input().split())
par = [-1] * N
for i in range(M):
    A, B = map(int, input().split())
    unite(A - 1, B - 1)

max_num = 0
for i in range(N):
    max_num = max(max_num, size(i))
print(max_num)

Measured memory_bytes: 14604
/*
	JAI JAGANNATH!
*/
//@Author : zanj0

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

typedef long long int lli;

#define ff              first
#define ss              second
#define pb              push_back
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            lli x; cin>>x; while(x--)

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const lli N = 1e6 + 5;

lli dp[N][2][2];
lli mul(lli a, lli b) {
	return ((a  % mod)  * (b % mod)) % mod;
}
lli add(lli a, lli b) {
	return ((a  % mod)  + (b % mod)) % mod;
}

lli dfs(lli idx, lli zero, lli nine) {
	//cout << idx << " " << zero << " " << nine << endl;
	if (idx == 0) {
		return zero && nine;
	}
	if (dp[idx][zero][nine] != -1) return dp[idx][zero][nine];
	lli ret = 0;
	for (lli i = 0; i <= 9; i++) {
		ret = add(ret, dfs(idx - 1, i == 0 || zero, i == 9 || nine));
	}
	return dp[idx][zero][nine] = ret;
}
void solve() {
	memset(dp, -1, sizeof dp);
	lli n;
	cin >> n;
	cout << dfs(n, 0, 0) << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1ll<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1ll<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
// priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
#define MX 1000000
int u[MX+5];
int p[MX+5]; //p[] stores list of prime numbers u[i] stores the smallest prime factor of i
int pn; //strores number of prime numbers

void sieve() {
	//p[2]=2; p[0]=0;
	for(int i = 2; i <= MX; i++) {
		if(!u[i]) {
			u[i]=p[++pn]=i;
		}
		for(int j = 1; i*p[j] <= MX; j++) {
			u[i*p[j]]=p[j];
			if(i%p[j]==0)
				break;
		}
	}	
}
signed main(void)
{
	IOS;
	sieve();
	int n;
	cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	map<int,int> f;
	for(int i = 0; i < n; i++) {
		int num=a[i];
		while(num>1) {
			int p=u[num],pp=0;
			while(num%p==0) {
				num/=p;
				pp++;
			}
			if(f.find(p)!=f.end())
				f[p]=max(f[p],pp);
			else
				f[p]=pp;
		}
	}
	// if(sz(f)==0) {
	// 	cout<<n<<endl;
	// 	return 0;
	// }
	int num=1;
	for(auto it = f.begin(); it!=f.end(); it++) {
		num=(num*powmod(it->ff,it->ss,MOD))%MOD;
	}
	int ans=0;
	for(int i = 0; i < n; i++) {
		ans=(ans+(num*powmod(a[i],MOD-2,MOD))%MOD)%MOD;
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 11008
# -*- coding: utf-8 -*-
"""
AtCoder A
"""
 
import sys, math, random
import numpy as np
 
# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
 
def main():
    N = I()
    out=0
    if N==100000:
        out=90909
    elif N>9999:
        out+=N-9999
        out+=9+900
    elif N>999:
        out+=909
    elif N>99:
        out+=N-99
        out+=9
    elif N>9:
        out+=9
    else:
        out+=N
    print(out)
 
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 23464
// https://atcoder.jp/contests/abc018/tasks/abc018_4

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

Graph G;
vector<int> _count;

// 深さ優先探索
// vector<bool> seen;
// vector<int> colors;
ll ne = -1;
ll _plus = 0;

 void dfs(int i, int pre){
    //  cout << i << endl;

     for(auto ni: G[i]){
         if(ni == pre)continue;
         _count[ni] += _count[i];
         dfs(ni, i);
     }
 }

int main() {

  int N, Q;
  cin >> N >> Q;
  G.assign(N, vector<int>(0, 0));
  _count.assign(N, 0);

  // グラフ入力受取 (ここでは無向グラフを想定)
  
  for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
  }

  REP(i, Q){
    cin >> ne >> _plus;
    ne--;
    _count[ne] += _plus;
  }
  dfs(0, 0);

  REP(i, N){
      cout << _count[i] << " ";
  }cout << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    // 解説AC
    int n;
    cin >> n;
    pint red[n], blue[n];
    rep (i, 0, n) cin >> red[i].first >> red[i].second;
    rep (i, 0, n) cin >> blue[i].first >> blue[i].second;
    sort (red, red + n);
    sort (blue, blue + n);
    bool chk[n] = {};
    int ans = 0;
    // まず、blueの点を固定する
    rep (i, 0, n) {
        int res = -1;
        int now = -1;
        rep (j, 0, n) {
            if (chk[j]) continue;
            if (red[j].first < blue[i].first &&
                red[j].second < blue[i].second) {
                // 条件に当てはまる中でredのyが最も大きいのを選ぶ
                if (now < red[j].second) {
                    res = j;
                    now = red[j].second;
                }
            }
        }
        if (res != -1) {
            chk[res] = 1;
            ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3640
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
AB.sort(key=lambda x: [x[1]])
migi = 0
cnt = 0
for i in range(m):
    a, b = AB[i]
    if migi <= a:
        cnt += 1
        migi = b

print(cnt)


Measured memory_bytes: 35480
//by tzupengwang™
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

ll a , b , c ;

void init() {
  cin >> a >> b >> c ;
}

void process() {
  if ( a % 2 == 0 || b % 2 == 0 || c % 2 == 0 ) {
    printf( "0\n" ) ;
    return ;
  } else {
    ll ans = min( a * b , min( a * c , b * c ) ) ;
    printf( "%lld\n" , ans ) ;
  }
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 256
from collections import deque, defaultdict

n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
def check(x):
    """
    最大値をx以下にできるか？
    """
    used = [0]*n
    if x >= n:
        return True
    # NM
    b = [deque(a[i]) for i in range(n)]
    d = defaultdict(list)

    ng = set()
    while True:
        for i in range(n):
            if used[i]:
                continue
            while b[i] and b[i][0] in ng:
                b[i].popleft()
            if not b[i]:
                return False
            like = b[i].popleft()

            d[like].append(i)
            used[i] = 1
        # チェック
        flag = True
        for key, value in d.items():
            if len(value) > x:
                flag = False
                ng.add(key)
                for v in value:
                    used[v] = 0
                d[key] = []
        if flag:
            return True

left = 0
right = n
while right - left > 1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)

Measured memory_bytes: 63708
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

A, B = map(int, raw_input().split())

A -= 1
if B % 4 == 1:
    B = 1
elif B % 4 == 2:
    B += 1
elif B % 4 == 3:
    B = 0
if A % 4 == 1:
    A = 1
elif A % 4 == 2:
    A += 1
elif A % 4 == 3:
    A = 0

print A ^ B


Measured memory_bytes: 2808
a, b, c, k = list(map(int, input().split()))
na = 0
nb = 0
nc = 0
if k < a:
    na = k
else:
    na = a
    k -= a
    if k < b:
        nb = k
    else:
        nb = b
        k -= b
        nc = k
point = na - nc
print('{}'.format(point))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define ll long long int
#define first fi
#define second se
#define whT int t; cin>>t; while(t--)
int main() 
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#endif
	int a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";	

}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

//~ const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }
        // int a, b, c - a lot of implementation
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N],B[N+1];
    for(int i=0;i<N;i++){
    cin >> A[i];
    B[A[i]] = i;
    }
    for(int i=1;i<N+1;i++)cout << B[i]+1 << " ";
  
}


Measured memory_bytes: 1536
import java.util.HashMap;
import java.util.Scanner;
/**
 * Created by maxmo on 19.06.2017.
 */
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        HashMap<Character, Integer> counter = new HashMap<>();

        for(int i = 0; i < S.length(); i++){
            try{
                counter.put(S.charAt(i), counter.get(S.charAt(i)) +1);
            }
            catch (Exception e) {
                counter.put(S.charAt(i),1);
            }
        }

        boolean doubledChar = false;
        for(Character characters : counter.keySet()){
            if(counter.get(characters) > 1){
                doubledChar = true;
            }
        }
        System.out.println((doubledChar)? "no" : "yes");
    }


}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define debug(x) cerr << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define ull unsigned LL
#define ls i << 1
#define rs (i << 1) + 1
#define fi first
#define se second
#define ptch putchar
#define CLR(a) while(!(a).empty()) a.pop()

using namespace std;
inline LL read() {
    LL s = 0,w = 1;
    char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-')
            w = -1;
        ch = getchar();
    }
    while(isdigit(ch))
        s = s * 10 + ch - '0',ch = getchar();
    return s * w;
}
inline void write(LL x) {
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
#ifndef ONLINE_JUDGE
clock_t prostart = clock();
#endif

int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif

    LL n,a,b; cin >> n >> a >> b;
    LL cir = n / (a + b);
    LL left = n % (a + b);
    cout << cir * a + min(left,a) << endl;

#ifndef ONLINE_JUDGE
    cerr << "time: " << 1.0 * (clock() - prostart) / CLOCKS_PER_SEC << " s" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  cin>>n;
  vector<int> t(n),v(n);
  for(int i=0;i<n;i++) cin>>t[i],t[i]*=2;
  for(int i=0;i<n;i++) cin>>v[i],v[i]*=2;
  vector<vector<int> > dp(222,vector<int>(2,-1));
  dp[0][0]=0;
  int cur=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<t[i];j++){
      bool f=cur%2;
      for(int k=0;k<222;k++) dp[k][!f]=-1;
      for(int k=0;k<=v[i];k++){
	if(dp[k][f]<0) continue;
	dp[k][!f]=max(dp[k][!f],dp[k][f]+k+k);
	if(k+1<=v[i])
	  dp[k+1][!f]=max(dp[k+1][!f],dp[k][f]+k+(k+1));
	if(k-1>=0)
	  dp[k-1][!f]=max(dp[k-1][!f],dp[k][f]+k+(k-1));
      }
      cur++;
    }
  }
  //assert(sum==cur);
  cout<<fixed<<setprecision(12)<<(double)dp[0][cur%2]/8.0<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

order = [int(input()) for _ in range(5)]

extra_list = []

tmp = 11
for i in range(5):
    extra = order[i] % 10
    if extra != 0:
        if extra < tmp:
            tmp = extra
            extra_list.append(i)


ans = 0
for i in range(5):
    if extra_list and i == extra_list[-1]:
        continue
    if order[i] % 10 == 0:
        ans += order[i]
    else:
        ans += 10 * (order[i] // 10 + 1)
if extra_list:
    print(ans + order[extra_list[-1]])
else:
    print(ans)


Measured memory_bytes: 38256
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define MAX 100

long long M[MAX][MAX];
int V, E;

int warshall_floyd()
{
	REP(i, V)REP(j, V)REP(k, V)
	{
		if (M[j][i] == INF)break;
		if (M[i][k] == INF)continue;
		M[j][k] = min(M[j][k], M[j][i] + M[i][k]);
	}
	REP(i,V)if (M[i][i] < 0)return 1;
	return 0;
}

int main()
{
	cin >> V >> E;
	REP(i, V)REP(j, V)
	{
		if (i == j)M[i][j] = 0;
		else M[i][j] = INF;
	}
	REP(i, E)
	{
		long long s, t, d;
		cin >> s >> t >> d;
		M[s][t] = d;
	}
	if (warshall_floyd() == 1)
	{
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	REP(i, V)
	{
		REP(j, V)
		{
			if (i == j)cout<<0;
			else if (M[i][j] >= INF)cout << "INF";
			else cout << M[i][j];
			if (j != V - 1 || (j == V - 2 && i == V - 1))cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> win(n);
    vector<int> lose(n);
    vector<vector<int>> match(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        match[a - 1].push_back(b - 1);
        win[a - 1]++;
        lose[b - 1]++;
    }
    bool only = true;
    for (int i = 0; i < n; i++) {
        int next = -1;
        for (int j = 0; j < n; j++) {
            if (lose[j] == 0) {
                if (next != -1)only = false;
                next = j;
            }
        }
        cout << next + 1 << endl;
        lose[next]--;
        for (auto x :match[next]) lose[x]--;
    }
    cout << (only ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 3744
def isPrime(n):
    i = 2
    while i*i <= n:
        if n % i == 0:
            return False
        i += 1
    return True
    
n = int(input())
ans = 0

for i in range(n):
    t = int(input())
    if isPrime(t):
        ans += 1
print(ans)

Measured memory_bytes: 7648