akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

a = sorted(a, reverse=True)

x = 0
y = 0
for i in range(len(a)):
    if i % 2 == 0:
        x += a[i]
    else:
        y += a[i]

print(x-y)


Measured memory_bytes: 77584
#include <iostream>

using namespace std;

int main () {

    int N, K;

    cin >> N >> K;

    // any two adjecent balls can be painted in p(K,2) colours
    int c_2 = K * (K - 1);

    int no_pairs = N / 2;
    int is_single = N % 2;

    if (N == 0) {
        c_2=0;
    } else if (N == 1) {
        c_2=K;
        is_single = 0;
    }
    

    while(--no_pairs > 0) {
        c_2 *= (K-1)*(K-1);
    }

    if (is_single) {
        c_2 *= (K-1);
    }

    cout << c_2 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N = int(input())
ans = [[0] * N for i in range(N)]

def calc_level(start, n, now):
  # start, start+1, ..., start+n-1 までを埋める
  # 今は level=now まで使っている
  global ans
  if n == 1:
    return True
  n1 = n // 2
  n2 = n - n1
  for i in range(start, start+n1):
    for j in range(start+n1, start+n):
      ans[i][j] = ans[j][i] = now + 1
  calc_level(start, n1, now+1)
  calc_level(start+n1, n2, now+1)

calc_level(0, N, 0)
for i in range(N):
  print(*ans[i][i+1:])

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int cnt[1000][1000][3];
int fld[1000][1000];
int main(){
      int h,w,k;
      char t;
      cin>>h>>w>>k;
      REP(i,h)REP(j,w){
            cin>>t;
            fld[j][i]=t=='J'?0:t=='O'?1:2;
      }
      cnt[0][0][fld[0][0]]++;
      REP(i,w)REP(j,3)if(i!=0)cnt[i][0][j]=cnt[i-1][0][j]+(fld[i][0]==j?1:0);
      REP(i,h)REP(j,3)if(i!=0)cnt[0][i][j]=cnt[0][i-1][j]+(fld[0][i]==j?1:0);
      REP(i,w)REP(j,h){
            if(i==0||j==0)continue;
            REP(k,3)cnt[i][j][k]=cnt[i-1][j][k]+cnt[i][j-1][k]-cnt[i-1][j-1][k]+(fld[i][j]==k?1:0);
      }
      //REP(i,h)REP(j,w)printf("%d%c",cnt[j][i][0],j==w-1?'\n':' ');
      int a,b,c,d;
      while(k--){
            cin>>a>>b>>c>>d;a--;b--;c--;d--;
            int ans[3];
            REP(i,3)ans[i]=cnt[d][c][i];
            if(a!=0)REP(i,3)ans[i]-=cnt[d][a-1][i];
            if(b!=0)REP(i,3)ans[i]-=cnt[b-1][c][i];
            if(a!=0&&b!=0)REP(i,3)ans[i]+=cnt[b-1][a-1][i];
            REP(i,3)printf("%d%c",ans[i],i==2?'\n':' ');
      }
}

Measured memory_bytes: 16768
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	long a = sc.nextLong();
	long v = sc.nextLong();
	long b = sc.nextLong();
	long w = sc.nextLong();
	long t = sc.nextLong();
	boolean esc = false;
	if(a<=b){
	    if(a+t*v>=b+t*w){
		esc = true;
	    }
	}else{
	    if(a-t*v<=b-t*w){
		esc = true;
	    }
	}
	if(esc){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
      }
}


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

int main() {
  int N; string S; cin >>N >>S;
  int x=0,ans=0;
  rep(i,0,N) {
    if (S[i]=='I') x++;
    else x--;
    ans=max(ans,x);
  }
  cout <<ans <<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int n;
    cin >> n;

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    cout << *max_element(all(nums)) - *min_element(all(nums)) << endl;
}

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

int main(){
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if a[0]:
    print(0)
    exit()
a.sort()
j=0
l=list()
#print(a)
for i in range(max(a)+1):
    k=0
    while j<n and a[j]==i:
        j+=1
        k+=1
        #print(l,j,k)
    l.append(k)
#print(l)
p=l[0]==1
mod=998244353
for i in range(len(l)-1):
    #print(p)
    p=(p*pow(l[i],l[i+1],mod))%mod
print(p%mod)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;

// ll recV1(int ind, const vector<int> & stones) {
// 	if(ind >= (int)stones.size() - 1) return 0;

// 	int cost1 = ind + 1 < (int)stones.size() ? abs(stones[ind + 1] - stones[ind]) : INT_MAX;
// 	int cost2 = ind + 2 < (int) stones.size() ? abs(stones[ind + 2] - stones[ind]) : INT_MAX;

// 	//cout << ind << " cost1:" << cost1 << " cost2:" << cost2 <<endl;
// 	auto oneJump = recV1(ind + 1, stones) + cost1;
// 	auto twoJumps = recV1(ind + 2, stones) + cost2;
// 	//	cout << ind << " oneJump:" << oneJump <<  " twoJumps:" << twoJumps <<endl;
// 	return min(oneJump, twoJumps);
// }


// ll recV2(int ind, const vector<int> & stones, unordered_map<int, ll> & memo) {
// 	if(ind >= (int)stones.size() - 1) return 0;
// 	if(memo.count(ind)) return memo[ind];

// 	int cost1 = ind + 1 < (int)stones.size() ? abs(stones[ind + 1] - stones[ind]) : INT_MAX;
// 	int cost2 = ind + 2 < (int) stones.size() ? abs(stones[ind + 2] - stones[ind]) : INT_MAX;

// 	//cout << ind << " cost1:" << cost1 << " cost2:" << cost2 <<endl;
// 	auto oneJump = recV2(ind + 1, stones, memo) + cost1;
// 	auto twoJumps = recV2(ind + 2, stones, memo) + cost2;
// 	//	cout << ind << " oneJump:" << oneJump <<  " twoJumps:" << twoJumps <<endl;
// 	memo[ind]  = min(oneJump, twoJumps);
// 	return memo[ind];
// }

// ll recV3(const vector<int> & stones) 
// {
// 	vector<int> dp(stones.size());

// 	for(auto i = 1; i < (int)dp.size(); ++i) {
		
// 		auto oneJump = i - 1 >= 0? dp[i - 1] + abs(stones[i - 1] - stones[i]) : INT_MAX;
// 		auto twoJumps =  i - 2 >= 0 ? dp[i - 2] + abs(stones[i - 2]  - stones[i]) : INT_MAX;

// 		dp[i] = min(oneJump, twoJumps);
// 	}

// 	return dp[dp.size() - 1];
// }

ll recV4(const vector<int> & stones) 
{
	vector<int> dp(stones.size(), INT_MAX);
	dp[0] = 0;
	for(auto i = 0; i < (int)dp.size(); ++i) {
		for(auto j : {i + 1, i + 2}) {
			if(j < (int)stones.size()) {
				dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));
			}
		}
	}

	return dp[dp.size() - 1];
}


// ll recV5(const vector<int> & stones) 
// {
// 	ll dp1 = 0, dp2 = 0, cur = 0;

// 	for(auto i = 1; i < (int)stones.size(); ++i) {
		
// 		auto oneJump =  dp1 + abs(stones[i - 1] - stones[i]) ;
// 		auto twoJumps = dp2 + abs(stones[i - 2]  - stones[i]);

// 		cur = min(oneJump, twoJumps);
// 		dp1 = oneJump;
// 		dp2 = twoJumps;
// 	}

// 	return cur;
// }


void solveFrog1() 
{
	int n; cin >> n;
	vector<int> stones(n);
	for(auto &it : stones) {
		cin >> it;
	}
	
	//cout <<  recV1(0, stones) <<endl; 
	//unordered_map<int, ll> memo;
	//cout <<  recV2(0, stones, memo) <<endl; 
	//cout << recV3(stones) <<endl;
	cout << recV4(stones) <<endl;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	solveFrog1();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

int n, t;
int a[200000];

int main(){
    cin >> n >> t;
    rep(i, n){
        cin >> a[i];
    }

    int p = 0;
    int q = 0;
    int ans = 0;
    rep(i, n){
        if(a[i] < q){
            q = a[i] + t;
        }
        else{
            ans += q - p;
            p = a[i];
            q = a[i] + t;
        }
    }
    ans += q - p;
    cout << ans << endl;
    return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll mo[6]={1,10,9,12,3,4};
    string s;cin>>s;
    ll n=s.size();
    reverse(s.begin(),s.end());
    ll dp[n+1][13];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<13;j++){
            if(i==0){
                if(j==0) dp[i][j]=1;
                else dp[i][j]=0;
            }else{
                dp[i][j]=0;
            }
        }
    }
    int num;
    string str;
    for(ll i=0;i<n;i++){
        if(s[i]=='?'){
            for(ll j=0;j<13;j++){
                for(ll k=0;k<10;k++){
                    dp[i+1][(j+mo[i%6]*k)%13]+=dp[i][j]%1000000007;
                }
            }
        }else{
            str=s[i];
            num = atoi(str.c_str());
            for(ll j=0;j<13;j++){
                dp[i+1][(j+mo[i%6]*num)%13]+=dp[i][j]%1000000007;
            }
        }
    }
    cout<<dp[n][5]%1000000007<<endl;
    return 0;
}



Measured memory_bytes: 10624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll R;
    cin >> R;

    if (R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
string st[2];
int main()
{
	cin>>st[0]>>st[1];
	if (st[0]==st[1]) cout<<"H"; else cout<<"D";
	return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    b=10000*i+5000*j+1000*(n-i-j)
    if y==b:
      print(i,j,n-i-j)
      exit()
print(-1,-1,-1)

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

int main() {
  int N=0;
  cin >> N;

  // ここにプログラムを追記
  int L=0,R=0,i=0,Sum=0;
  for (int i=0; i<N; i++) {
    cin >> L >> R;
    Sum+=R-L+1;
  }
  cout << Sum <<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
}

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

struct Settings {
    int D;
    int TMAX = 26;
    vector<ll> C;
    vector<vector<ll>> S;
    Settings(int d, vector<ll>& c, vector<vector<ll>>& s) : D(d), C(c), S(s) {}
};

struct Schedule {
    Settings& ss;
    vector<int> T;  // T[d]: type of day d+1, T[d]=-1:invalid
    vector<set<int>> ts; // ts[ty]: indexes of ty
    ll score = 0;
    Schedule(Settings& ss) : ss(ss) {
        ts.assign(ss.TMAX, set<int>());
        T.assign(ss.D, -1);
        score = 0;
        for ( int t = 0; t < ss.TMAX; t++ ) {
            ts[t].insert(-1);
            int dd = ss.D+1;
            score -= dd*(dd-1)/2 * ss.C[t];
            ts[t].insert(ss.D);
        }
    }
    // d+1日目の種類をq+1に変える
    void change(int d, int q) {
        // remove
        if ( T[d] >= 0 ) {
            auto p = ts[T[d]].find(d);
            auto p_prev = prev(p), p_next = next(p);
            score -= (d-*p_prev) * (*p_next-d) * ss.C[T[d]];
            score -= ss.S[d][T[d]];
            ts[T[d]].erase(d);
            T[d] = -1;
        }
        // add
        if ( q >= 0 ) {
            T[d] = q;
            ts[T[d]].insert(d);
            auto p = ts[T[d]].find(d);
            auto p_prev = prev(p), p_next = next(p);
            score += (d-*p_prev) * (*p_next-d) * ss.C[T[d]];
            score += ss.S[d][T[d]];
        }
    }
};

ll solve() {

    
    ll ans = 0;
    return ans;
}

int main() {
    ll D;
    cin >> D;
    vector<ll> C(26);
    for ( int i = 0; i < 26; i++ ) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    for ( int i = 0; i < D; i++ ) {
        for ( int j = 0; j < 26; j++ ) cin >> S[i][j];
    }
    Settings ss(D,C,S);
    Schedule sch(ss);
    vector<int> T(D,-1);

    // Tの初期値設定　貪欲法
    for ( int d = 0; d < ss.D; d++ ) {
        ll sc = -(1LL<<60);
        for ( int q = 0; q < ss.TMAX; q++ ) {
            sch.change(d,q);
            if ( sc < sch.score ) {
                T[d] = q;
                sc = sch.score;
            }
        }
        sch.change(d,T[d]);
    }


    for ( int d = 0; d < ss.D; d++ ) {
        cout << T[d]+1 << "\n";
    }   
    return 0;
}

Measured memory_bytes: 3836
def resolve():
    N = int(input())
    S = input()

    L=[]
    Slen = len(S)
    for i in range(Slen):
        tmp = ord(S[i]) + N
        if tmp <= 90:
            L.append(chr(tmp))
        if tmp > 90:
            tmp = tmp - 26
            L.append(chr(tmp))
    ans = ''.join(L)
    print(ans)
resolve()

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

d = {}
for i in range(n): 
    s = input()
    if(d.get(s) is None):
        d[s] = 1
    else:
        d[s] = d[s] + 1

l = list(d.items())

l.sort(key=lambda x: (-x[1], x[0])) 

for k, v in l:
    if(v != l[0][1]): break
    print(k)


Measured memory_bytes: 59224
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 500000
int dirx[] = {1, -1,0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};



//=============================================ASIFAZAD==============================================//

vi vis(N), adj[N];

void dfs(int nod)
{
    vis[nod] = 1;
    for(auto x: adj[nod])
        if(vis[x] == 0)
            dfs(x);
}


int32_t main()
{
    io;
    int n, m;
    cin>>n>>m;
    for(int i = 0; i < m;i++)
    {
        int u, v;
        cin>>u >>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int com = 0;
    for(int i = 1; i<= n;i++)
    {
        if(vis[i] == 0)
        {
            com++;
            dfs(i);
        }
    }
    cout<<com-1;
    return 0;
}


Measured memory_bytes: 20660
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) {
        a[i]--;
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,a,b,c,d = li()

exist = False

for m in range(n-1):
    if -d*m+c*(n-1-m) <= b-a <= -c*m+d*(n-1-m):
        exist = True
        
if exist:
    print("YES")
else:
    print("NO")
    

Measured memory_bytes: 3188
PROGRAM A
  IMPLICIT NONE
  CHARACTER(len=3) :: S
  CHARACTER(len=1) :: w1,w2,w3
  INTEGER :: i=0

  READ *, S
  w1 = S(1:1)
  w2 = S(2:2)
  w3 = S(3:3)

  IF (w1=="R") THEN
    i=i+1
    IF (w2==w1) THEN
      i=i+1
      IF (w3==w2) THEN
        i=i+1
      ELSE
      END IF
    ELSE
    END IF
  ELSE
    IF (w2=="R") THEN
      i=i+1
      IF (w3==w2) THEN
        i=i+1
      ELSE
      END IF
    ELSE
      IF (w3=="R") THEN
        i=i+1
      ELSE
      END IF
    END IF
  END IF

  PRINT *, i
END PROGRAM A


Measured memory_bytes: 2716
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<functional>
#include<ctime>
#include<cassert>
#include<cstring>
#include<unordered_map>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define fo(a,b) for(int o=a;o<=b;++o)
#define fdi(a,b) for(int i=a;i>=b;--i)
#define fdj(a,b) for(int j=a;j>=b;--j)
#define fdo(a,b) for(int o=a;o>=b;--o)
#define pb push_back
#define mp make_pair
#ifdef LOCAL
#define err(format, ...) fprintf(stderr, format, __VA_ARGS__);
#else
#define err(format, ...) while(false) {}
#endif
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef vector<int> vi;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

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

int n, k;
ll ans;

int calc(int a) {
	int cur = a;
	int res = 0;
	while(cur <= n) {
		int q;
		int x = cur + 1;
		int y = cur + a - 1;
		y = min(y, n);
		q = max(0, y - x + 1 - k + 1);
//		err("a = %d x = %d y = %d q = %d\n", a, x, y, q);
		res += q;
		cur += a;
	}
//	err("a = %d res = %d\n", a, res);
	return res;
}

void solve() {
	fi(1, n) {//a < b
		if (k != 0) {
			ans += max(0, i - k);
		} else {
			ans += max(0, i - 1);
		}
	}	     	
	fi(1, n) {
		ans += calc(i);
	}			
}

int main() {
#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d", &n, &k);	
	solve();		
	printf("%lld\n", ans);

	
#ifdef LOCAL
	fprintf(stderr, "ELAPSED TIME: %.3lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 256
num = int(input())
A_i = [ int(x) for x in input().split()]
B_i = [ int(x) for x in input().split()]
C_i = [ int(x) for x in input().split()]
 
prev = 50
result = 0
for a in A_i:
  result += B_i[a-1]
  if a-1 == prev:
    result += C_i[prev-1]
  prev = a
  
print(result)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (sc.next().equals(s)) {
            a--;
        } else {
            b--;
        }


        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21844
import collections
def main():
    n,k=map(int, input().split())
    A=[int(i) for i in input().split()]
    dd = collections.defaultdict(int)
    for i in A:
        dd[i]+=1
    res = []

    for i in dd.keys():
        res.append([i,dd[i]])

    res.sort(key = lambda x:x[1])
    type = len(res)
    result = 0
    i=0
    while(type > k):
        result += res[i][1]
        type-=1
        i+=1

    print(result)


if __name__ == '__main__':
    main()


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

//typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
//#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i]
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n;
    scanf("%d",&n);
    int a[n];
    map<int,int> mp1;
    int ans=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        mp1[a[i]]++;
    }
    for(int i=0;i<n;i++){
        int fl=0;
        if(mp1[a[i]]>1){
            continue;
        }
        if(a[i]==1){
            ans++;
            continue;
        }
        for(int j=1;j*j<=a[i];j++){
            if(a[i]%j==0){
                if(mp1[j]){
                    fl=1;
                    break;
                }

                if(mp1[a[i]/j] && j>1){
                    fl=1;
                    break;
                }
            }
        }
        if(fl==0)
        ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 33480
#include<bits/stdc++.h>
#define rint register int
using namespace std;
int read(){
    int s=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=0;c=getchar();}
    while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
    return f?s:-s;
}
int n,m,Q,s[100010],mmp[100010],cl[100010];
int col[100010],vis[100010][11],hxcAK[100010];
int tot,head[100010],ver[200010],nxt[200010];
void add(int x,int y){
    nxt[++tot]=head[x]; ver[tot]=y;
    head[x]=tot;
}
void dfs(int x,int dis,int cr){
	if(!hxcAK[x]) col[x]=cr,hxcAK[x]=1;
	vis[x][dis]=1;
	if(dis==0) return;
	for(rint i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(vis[y][dis-1]) continue;
		vis[y][dis-1]=1;
		dfs(y,dis-1,cr);
	}
}
int main(){
    n=read(); m=read();
    for(rint i=1,x,y;i<=m;++i){
        x=read(); y=read();
        add(x,y); add(y,x);
    }
    Q=read();
    for(rint i=1;i<=Q;++i)
        s[i]=read(),mmp[i]=read(),cl[i]=read();
    for(rint i=Q;i;--i) dfs(s[i],mmp[i],cl[i]);
    for(rint i=1;i<=n;++i) printf("%d\n",col[i]);
    return 0;
}
/*
14 10
1 4
5 7
7 11
4 10
14 7
14 3
6 14
8 11
5 13
8 3
8
8 6 2
9 7 85
6 9 3
6 7 5
10 3 1
12 9 4
9 6 6
8 2 3

*/

Measured memory_bytes: 8832
N = int(input())

n100 = int(N/100)
n10 = int((N-n100*100)/10)
n1 = int(N - n100*100 - n10*10 )
if n100==7 or n10==7 or n1==7 :
    print('Yes')
else:
    print('No')
    


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

int main(){
    int n,c=0;cin>>n;
    for(int i=1;i<=n;i++){
        int k;cin>>k;
        if(k!=i) c++;
    }
    if(c==0||c==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
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; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  int l;
    cin >> n>>m>>l;
  if(abs(m-l)%2) return cout<<"Borys"<<"\n",0;
 	cout<<"Alice"<<"\n",0;
  
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,M,answer=0;
  cin >> N >> M;
  long long x[N],y[N],z[N],X[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  for (int n = 0; n < 8; n++) {
    for (int i = 0; i < N; i++) {
      int m = n;
      if (m%2) {
        X[i] = x[i];
      } else {
        X[i] = -x[i];
      }
      m /= 2;
      if (m%2) {
        X[i] += y[i];
      } else {
        X[i] -= y[i];
      }
      m /= 2;
      if (m%2) {
        X[i] += z[i];
      } else {
        X[i] -= z[i];
      }
    }
    long long Y = 0;
    sort(X,X+N,greater<long long>());
    for (int i = 0; i < M; i++) {
      Y += X[i];
    }
    answer = max(answer,Y);
  }
  cout << answer;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323
int i,j,k;
// int n;
// const int N=1e6+5;
// vector<bool> prime(N);
// void sieve(){
//     for(int i=0;i<=N;i++)prime[i]=true;
//     prime[0]=prime[1]=false;
//     for(int i=2;i*i<=N;i++){
//         if(prime[i] and i*i<=N){
//             for(int j=i*i;j<=N;j+=i){
//                 prime[j]=false;
//             }
//         }
//     }
// }
// const bool cmp(pii a,pii b){
//     return a.F-a.S>b.F-b.S;
// }
const int N=1e4+5;
int ans[N];
void f(){
    for(i=1;i<=105;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                int v=i*i+j*j+k*k+i*j+j*k+k*i;
                if(v<N)ans[v]++;
            }
        }
    }
}
void Anon_mouS(){
    int n;
    f();
    cin>>n;
    for(i=1;i<=n;i++)cout<<ans[i]<<endl;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int a[10] = {1,2,4,8,16,32,64};
int main(){
	int n;
	scanf("%d",&n);
	if(n >= 64){
		printf("64\n");
	}else if(n <= 1){
		printf("1\n");
	}else{
		int s1 = 0;
		for(int i = 0;i<n;i++){
			if(a[i] <= n && abs(s1-n) > abs(a[i]-n)){
				s1 = a[i];
			}
		}
		printf("%d\n",s1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  string top;
  while(cin >> top, top != "-"){
    string left, right, bottom, res;
    cin >> left >> res;

    char center = left[0];
    left.erase(0, 1);
    while(!top.empty() || !left.empty()){
      if(res.find(center, 0) == string::npos && !left.empty()){
	right.push_back(center);
	center = left[0];
	left.erase(0, 1);
      }else if(!top.empty()){
	bottom.push_back(center);
	center = top[0];
	top.erase(0, 1);
      }
    }
    if(res.find(center, 0) == string::npos){
      right.push_back(center);
    }

    cout << right << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int main(void) {
  int k, a, b;
  cin >> k;
  vector<int> vec(k, 46);
  vec[1] = 1;
  deque<int> q;
  q.push_back(1);
  while (a = q.front()) {
    q.pop_front();
    b = a * 10 % k;
    if (vec[a] < vec[b]) {
      vec[b] = vec[a];
      q.push_front(b);
    }
    b = (a + 1) % k;
    if (vec[a] + 1 < vec[b]) {
      vec[b] = vec[a] + 1;
      q.push_back(b);
    }
  }
  cout << vec[0] << endl;
  return 0;
}

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

#define INF 1234567890
#define ll long long

ll N, res;
int X, M;
int g[100101], in[100101];
bool vis[101001];
ll S[100101];

int main()
{
	scanf("%lld %d %d", &N, &X, &M);
	for(int i=0; i<=M; i++)
	{
		g[i] = (int)((ll)i*i%M);
		in[g[i]]++;
	}
	queue<int> q;
	for(int i=0; i<=M; i++)
		if (in[i] == 0)
			q.push(i);
	while(!q.empty())
	{
		int n = q.front(); q.pop();
		if (--in[g[n]] == 0)
			q.push(g[n]);
	}
	// 사이클에 들어갈 때까지 이동
	int cnt = 0, x = X;
	while(1)
	{
		if (in[x]) break;
		N--;
		res += x;
		x = g[x];
		if (N == 0) return !printf("%lld", res);
	}
	while(1)
	{
		if (vis[x]) break;
		vis[x] = true;
		cnt++;
		S[cnt] = S[cnt-1] + x;
		x = g[x];
	}
	res += S[cnt]*(N/cnt);
	N %= cnt;
	res += S[N];
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 5172
#include<stdio.h>
#include<string.h>

int main(void)
{
  int i;
  int len;
  int joi, ioi;
  char str[100000];

  memset(str,'\0',sizeof(str));

  while (scanf("%s", str) != EOF){
  
	joi = 0;
	ioi = 0;
	
	len = strlen(str);

	for (i = 0;i < len - 2;i++){
	  if (str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I'){
		joi++;
	  }
	  if (str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I'){
		ioi++;
	  }
	}

	memset(str,'\0',sizeof(str));

	printf("%d\n%d\n", joi, ioi);
  }

  return 0;
}

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

int main(void){
  int n,s;
  cin>>n;
  for(int x=0;x<n;++x){
    cin>>s;
    cout<<"Case "<<x+1<<":"<<endl;
    for(int i=0;i<10;++i){
      stringstream ss;
      ss<<s*s;
      string a,b;
      ss>>a;
      for(;a.size()<2*4;)a="0"+a;
      b=a.substr(a.size()/2-4/2,4);
      ss.clear();
      ss<<b;
      ss>>s;
      cout<<s<<endl;
    }
  }
  return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3620
n,a,b = map(int,input().split())
h_list = []
for _ in range(n):
    h = int(input())
    h_list.append(h)

def ba(s):
    count = 0
    for i in h_list:
        i -= s*b
        if i > 0:
            count += -(-i//(a-b))
    if count <= s:
        return True
    else:
        return False


ng = 0
ok = 10**9
while ok  > ng +1 :
    mid = (ng+ok)//2
    if ba(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 12960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005,mod=1e9+7;
int to[N],s[N],a[N],jb[N];
ll g[N],f[N],c[N],myh,sum=1;
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
#define lowbit(i) i&-i
ll ask(int pos){
	ll ans=0;
	for(int i=pos;i;i-=lowbit(i))ans+=c[i];
	return ans;
}
void change(int pos,int de){
	for(int i=pos;i<N;i+=lowbit(i))c[i]+=de;
}
int main(){
	int n=read();
	For(i,1,n)to[a[i]=read()]++;
	Rep(i,n,1){
		to[i]+=to[i+1];
		sum=sum*(s[i]=to[i]-(n-i))%mod;
	}
	For(i,f[0]=g[0]=1,n){
		f[i]=f[i-1]; jb[i]=jb[i-1];
		if(s[i]>1)f[i]=f[i]*(s[i]-1)%mod*ksm(s[i],mod-2)%mod;
		 else jb[i]=i-1;
		g[i]=ksm(f[i],mod-2);
	}
	For(i,1,n){
		change(a[i],1);
		myh+=i-ask(a[i]);
	}
	mem(c);
	ll ans=myh*2%mod;
	For(i,1,n){
		ans=(ans+(ask(a[i])-ask(jb[a[i]]))%mod*f[a[i]])%mod;
		change(a[i],g[a[i]]);
	}
	mem(c);
	Rep(i,n,1){
		ans=(ans-(ask(a[i]-1)-ask(jb[a[i]]))%mod*f[a[i]])%mod;
		change(a[i],g[a[i]]);
	}
	//cout<<ans-2*myh<<" "<<myh<<" "<<ans<<endl;
	ans=(ans*(mod+1)/2%mod+mod)%mod;
	cout<<ans*sum%mod<<endl;
}

/*
Taj/Tai 
*/

Measured memory_bytes: 8064
/*
ID: rajiv
TASK: test
LANG: C++14
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>
#include<iterator>
#include<random>
#include<chrono>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ONLINE_JUDGE

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int rnd(int a, int b){ // including a and b
	return a+(rng()%(b-a+1));
}
#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sortr(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb push_back
#define endl '\n'

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

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

void solve(){
	string s,t ;
	cin>>s>>t;
	int ans=0;
	rep(i, s.size()){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
	
}

int main(){
	fast_io
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif 
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

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

	int n, i, j;
	cin >> n;
	i = 1;
	while (i*2 <= n) i *= 2;
	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    string s; cin >> s;
    int ans = 700;
    rep(i,s.size())if(s[i] == 'o')ans+=100;
    cout << ans << endl;
}


Measured memory_bytes: 888
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
import heapq

L,R = [10**15],[10**15]
lenL,lenR = 1,1
sumL,sumR = 0,0
y = 0

Q = int(input())
for i in range(Q):
    query = list(map(int,input().split()))
    if len(query) == 1:
        x = -L[0]
        f = sumR - sumL + y
        if lenL != lenR:
            f += x
        print("{} {}".format(x, f))
    else:
        q,a,b = query
        y += b
        if lenL > lenR:
            sumL += a
            a = -heapq.heappushpop(L, -a)
            sumL -= a
            heapq.heappush(R, a)
            sumR += a
            lenR += 1
        else:
            sumR += a
            a = heapq.heappushpop(R, a)
            sumR -= a
            heapq.heappush(L, -a)
            sumL += a
            lenL += 1




Measured memory_bytes: 11132
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("019c.in","r",stdin);
	//freopen(".out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
struct node{
	int x,y;
	void get(){
		x=read();
		y=read();
	}
}st,fin,a[NN];
int l,r,u,d;
int dp[NN]={};
bool cmp(node a,node b){
	return a.x<b.x;
}
int main(){
	//open();
	st.get();
	fin.get();
	n=read();
	l=min(st.x,fin.x);
	r=max(st.x,fin.x);
	u=max(st.y,fin.y);
	d=min(st.y,fin.y);
	int cnt=0;
	LD res=100ll*(abs(st.y-fin.y)+abs(st.x-fin.x));
	LD hu=acos((LD)-1)*5;
	for(int i=1;i<=n;++i){
		node tp;
		tp.get();
		if(l<=tp.x&&tp.x<=r&&d<=tp.y&&tp.y<=u){
			a[++cnt]=tp;
		}
	}
	if(st.x>fin.x)swap(st,fin);
	if(st.y>fin.y){
		for(int i=1;i<=cnt;++i){
			a[i].y=-a[i].y;		
		}
	}
	sort(a+1,a+1+cnt,cmp);
	memset(dp,127,sizeof dp);
	dp[0]=-1000000000;
	for(int i=1;i<=cnt;++i){
		int pos=upper_bound(dp,dp+cnt+1,a[i].y)-dp;
		dp[pos]=a[i].y;
	}
	for(int i=cnt;i>=1;--i){
		if(dp[i]<1000000000){
			res+=(hu-20)*i;
			if(i==min(abs(l-r),abs(u-d))+1)res+=hu;
			break;
		}
	}
	printf("%.13Lf\n",res);

	close();
	return 0;
}

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

const int MAXN = 1e5+10;

int p[MAXN];
int tmp[MAXN];
int main() {
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		scanf("%d", &p[i]);
		tmp[i] = p[i];
	}

	int cnt1=0;
	for(int i=1;i<=n;i++) {
		if(i<n) {
			if(tmp[i]==i) {
				cnt1++;
				swap(tmp[i], tmp[i+1]);
			}	
		}
		else {
			if(tmp[i]==i) {
				cnt1++;
				swap(tmp[i], tmp[i-1]);
			}
			
		}
	}

	int cnt2=0;
	for(int i=1;i<=n;i++)
		tmp[i] = p[i];

	for(int i=n;i>=1;i--) {
		if(i>=2) {
			if(tmp[i]==i) {
				cnt2++;
				swap(tmp[i], tmp[i-1]);
			}	
		}
		else {
			if(tmp[i]==i) {
				cnt2++;
				swap(tmp[i], tmp[i+1]);	
			}
		}
	}
	// printf("%d %d\n", cnt1, cnt2);
	printf("%d", min(cnt1, cnt2));
	return 0;
}

Measured memory_bytes: 896
/**
 *      ABC 46 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-01 21:08:27
**/

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

int_fast64_t mag(int_fast64_t x1, int_fast64_t x2){
    if (x1 % x2 == 0) return x1 / x2;    
    else return x1 / x2 + 1;    
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int_fast32_t N; cin >> N;
    int_fast64_t T[N] = {}; int_fast64_t A[N] = {};
    for (auto i = 0; i < N; ++i) cin >> T[i] >> A[i];    

    for (auto i = 1; i < N; ++i) {
        if (T[i] < T[i - 1] || A[i] < A[i - 1]){
            int_fast64_t magni = max(mag(T[i - 1], T[i]), mag(A[i - 1], A[i]));
            T[i] *= magni; A[i] *= magni;
        }
    }
    cout << T[N - 1] + A[N - 1] << '\n';    
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll le[100100];
ll ri[100100];
int N, K;

void init()
{
	cin >> N >> K;
	vector<int> l, r;
	reps(i, 1, N+10) {
		le[i] = 1e9;
		ri[i] = 1e9;
	}
	rep(i, N) {
		int x;
		cin >> x;
		if (x < 0) {
			l.PB(-x);
		} else {
			r.PB(x);
		}
	}
	reverse(all(l));
	rep(i, l.size()) {
		le[i+1] = l[i];
	}
	rep(i, r.size()) {
		ri[i+1] = r[i];
	}
}

void solve()
{
	ll mi = 1e9;
	rep(i, K+1) {
		mi = min(mi, le[i] + 2 * ri[K-i]);
		mi = min(mi, 2 * le[i] + ri[K-i]);
	}
	cout << mi << endl;
}





Measured memory_bytes: 2556
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>
typedef long long ll;

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

	int all_inputs;
	int h;
	int w;
	int a;
	int b;
	int count = 0;

	std::cin >> all_inputs >> h >> w;
	for (int i = 0; i < all_inputs; i++){
		std::cin >> a >> b;
		if (h <= a && w <= b){
			count++;
		}
	}

	std::cout << count << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.F < element2.F;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.F > element2.F;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.S < element2.S;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.S > element2.S;
}

int main() {
	vector<int>abc(3);
	rep(i, 3) {
		cin >> abc[i];
	}
	sort(all(abc));
	int cnt = 0;
	reverse(all(abc));
	if (abc[0] - abc[1] >= 2) {
		while (abc[0]-1 > abc[1]) {
			abc[1] += 2;
			cnt++;
		}
	}
	if (abc[0] - abc[2] >= 2) {
		while (abc[0] - 1 > abc[2]) {
			abc[2] += 2;
			cnt++;
		}
	}
	queue<int>A, B, C, count;
	count.push(cnt);
	A.push(abc[0]);
	B.push(abc[1]);
	C.push(abc[2]);

	while (1) {
		if (A.front() == B.front() &&
			B.front() == C.front()) {
			break;
		}
		A.push(A.front() + 2);
		B.push(B.front());
		C.push(C.front());
		count.push(count.front() + 1);

		A.push(A.front());
		B.push(B.front()+2);
		C.push(C.front());
		count.push(count.front() + 1);

		
		A.push(A.front() );
		B.push(B.front());
		C.push(C.front()+2);
		count.push(count.front() + 1);

		A.push(A.front() + 1);
		B.push(B.front()+1);
		C.push(C.front());
		count.push(count.front() + 1);

		A.push(A.front() );
		B.push(B.front()+1);
		C.push(C.front()+1);
		count.push(count.front() + 1);

		A.push(A.front() +1);
		B.push(B.front());
		C.push(C.front()+1);
		count.push(count.front() + 1);

		A.pop();
		B.pop();
		C.pop();
		count.pop();
	}
	cout << count.front() << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if (a == b) {
			System.out.println(c);
		} else if (a == c) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}

	}

}


Measured memory_bytes: 23764