akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

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

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

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

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

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

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26720
using System;

namespace _1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            var h = x / 3600;
            var m = (x % 3600) / 60;
            var s = x - (h * 3600 + m * 60);
            Console.WriteLine("{0}:{1}:{2}",h,m,s);
        }
    }
}



Measured memory_bytes: 17996
#include <iostream>
#include <algorithm>

using namespace std;
int d[100010];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> d[i];
	}
	sort(d,d + n);
	cout << d[n/2] - d[n/2 - 1] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		int D = reader.nextInt();
		int ans = Math.min(A, B) + Math.min(C, D) ;
		reader.close();
		System.out.print(ans);
	}
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d)
    cout << "Left" << endl;
  else if(a + b == c + d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  for(int i = 1; i <= B; ++i){
    if(A * i % B == C){
      cout << "YES" << endl;
      break;
    }
    if(A * i % B != C && i == B){
     cout << "NO" << endl;
    }
  }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//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; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


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

    ll tmp,i;    
    ll res;
    vector<ll> v(n);

    for(i=0;i<n;i++){
        cin >> v[i];
        //cout << v[i] <<endl ;
    }
    
    if(k>=n) {
        cout << 0 << endl;
        return 0;
    }
    
    sort(v.begin(),v.end(),greater<ll>());
    
    res = accumulate(v.begin()+k,v.end(),0LL);
    cout << res ;

   // cout << tmp ;
}


Measured memory_bytes: 1792
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
s=0
for i in range(m):
  if a[s]<bc[i][1]:
    t=bisect.bisect_left(a,bc[i][1],s,n)
    for j in range(s,min(t,s+bc[i][0])):
      a[j]=bc[i][1]
    s=min(t,s+bc[i][0])
    if s>=n:
      break
  else:
    break
print(sum(a))


Measured memory_bytes: 82456
#include <stdio.h>
#include <math.h>
int main(void){
  int x,i,j,max=1;
  scanf("%d",&x);
  for(i=1;i<=x;i++){
    for(j=2;j<=x;j++){
      int num=pow(i,j);
      if(num<=x&&max<num) max=num;
      if(num>x) break;
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

std::vector<int> sieve(int n) {
	std::vector<int> res(n);
	std::iota(res.begin(), res.end(), 0);
	for (int i = 2; i*i < n; ++i) {
		if (res[i] < i) continue;
		for (int j = i*i; j < n; j += i)
			if (res[j] == j) res[j] = i;
	}
	return res;
}

ll fibo(ll n){
	ll res=0;
	ll left=n;
	for(ll i=1;i<n;i++){
		left-=i;
		if(left<0) break;
		res++;
	}
	return res;
}

void Main()
{
	ll n,m,l; ll res=0;

	cin>>n;
	VI b(1e6);

	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			b[i]++;
			n/=i;
		}
	}
	if(n!=1) {
		res=1;
	}
	for(ll i=2;i<1e6;i++){
		ll cnt=b[i];
		if(cnt==0) continue;
		else {
			//res += fibo(cnt);
			long long int tmp=1;
			while(b[i]>=tmp){
				b[i]-=tmp;
				tmp++;
				res++;
			}
		}
	}
	cout << res << "\n";
	return;
}

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


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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}
template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  string s;
  cin >> s;
  int n = s.size();

  auto dp = Make2DVector(n + 1, 2, 0);
  dp[1][0] = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      UpdateMax(dp[i + 1][0], dp[i][0] + 1);
      UpdateMax(dp[i + 1][0], dp[i][1] + 1);
    } else {
      UpdateMax(dp[i + 1][0], dp[i][1] + 1);
    }

    UpdateMax(dp[i + 1][1], dp[i - 1][0] + 1);
  }

  int ans = max(dp[n][0], dp[n][1]);
  cout << ans << endl;
}


Measured memory_bytes: 11412
def main(m,k): 
  if k==0:
    ary=[]
    for i in range(2**m):
      ary.append(i)
      ary.append(i)
    return ary
  elif k>=2**m or m==1:
    return [-1]
  else:
    mi=set(range(2**m))
    b=[]
    while mi:
      i=mi.pop()
      j=i^k
      mi.discard(j)
      u=mi.pop()
      v=u^k
      mi.discard(v)
      b.append((i,j,u,v))
    ary=[]
    for i,j,u,v in b:
      ary.append(i)
      ary.append(j)
      ary.append(u)
      ary.append(v)
      ary.append(j)
      ary.append(i)
      ary.append(v)
      ary.append(u)
    return ary

m,k=map(int,input().split())
ary=main(m,k)

print(*ary,sep=' ')
exit()
print(len(ary))

Measured memory_bytes: 104792
#include<iostream>
using namespace std;
int main() {
		int n;
		double sum;
		cin >> n;
		for (int i=0; i<n; i++) {
				double value;
				string unit;
				cin >> value >> unit;
				if (unit == "JPY") {
						sum += value;
				} else {
						sum += value * 380000.0;
				}
		}
		cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double n = scanner.nextInt();
        double x = scanner.nextInt();
        double t = scanner.nextInt();
        System.out.println((int)(Math.ceil(n / x) * t));
    }
}

Measured memory_bytes: 36092
g = []
g.append([1,3,5,7,8,10,12])
g.append([4,6,9,11])
g.append([2])

x,y = map(int,input().split())

for i in range(3):
    if x in g[i] and y in g[i]:
        print("Yes")
        exit()

print("No")

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int a,b,c,k,i=0,j,n;
   /* cin>>a>>b>>c;
    cin>>k;
    bool ok=true;
    while(b<=a){
        b*=2;
        i+=1;
    }
        while(c<=b){
         c*=2;
         i+=1;
        }
    //cout<<i<<" "<<b<<" "<<c<<endl;
    if(i<=k)
        cout<<"YES";
    else
        cout<<"NO";*/
        cin>>n>>k;
    long long int A[n+1];
    for(i=1;i<=n;i++){
        cin>>A[i];
    }
    for(i=k+1;i<=n;i++){
        if(A[i]>A[i-k])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5144
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int m;
    cin >> n >> m;
    cout << pow(2, m) * (m * 1900 + (n - m) * 100) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int x[110];
int y[110];
int p[110];
int q[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d%d",x+i,y+i);
	for(int i=0;i<b;i++)scanf("%d%d",p+i,q+i);
	for(int i=0;i<a;i++){
		int t=0;
		for(int j=0;j<b;j++){
			int L=ABS(x[i]-p[j])+ABS(y[i]-q[j]);
			int R=ABS(x[i]-p[t])+ABS(y[i]-q[t]);
			if(R>L){
				t=j;
			}
		}
		printf("%d\n",t+1);
	}
}

Measured memory_bytes: 128
from bisect import bisect_left, bisect_right
from decimal import Decimal
from scipy.special import comb
n, a, b = map(int, input().split())
v = list(map(lambda x:-int(x), input().split()))
v.sort()
li = [[None]*2 for _ in range(n+1)]
for k in range(a, b+1):
    li[k][0] = -sum(v[:k])
    li[k][1] = comb(bisect_right(v, v[k-1])-bisect_left(v, v[k-1]), k-bisect_left(v, v[k-1]), exact=True)
ans = [Decimal(0), 0]
for i in range(n+1):
    if li[i][0] is None:
        continue
    tmp = Decimal(li[i][0]) / Decimal(i)
    if ans[0]==tmp:
        ans[1] += li[i][1]
    elif ans[0]<tmp:
        ans[0] = tmp
        ans[1] = li[i][1]
print(ans[0])
print(ans[1])

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n), b(n+1);
	rep(i, n) cin >>a[i];
	
	rep(i, n) b[i+1] = b[i] + a[i];
	//for(auto x :b) printf("%lld ",x); puts("");
	ll ans = 1LL<<60;
	rep2(i, 1, n-1){
		
		ll smb = b[i+1]/2;
		ll sma = (b[n] - b[i+1])/2;
		int ps1 = lower_bound(all(b), smb) - b.begin();
		int ps2 = lower_bound(all(b), sma+b[i+1]) - b.begin();
		rep2(x, max(0,ps1-5), min(ps1+5,i+1)) rep2(y, max(i,ps2-5), min(n,ps2+6)){				VL qs={b[x+1], b[i+1]-b[x+1], b[y+1]-b[i+1], b[n]-b[y+1]};
			if(qs[0]==0 || qs[1]==0 || qs[2]==0 || qs[3]==0 ) continue;
			ll mnsm = min<ll>({ qs[0], qs[1], qs[2], qs[3] });
			ll mxsm = max<ll>({ qs[0], qs[1], qs[2], qs[3] });
			//dbg("sm",x,i,y,mnsm,mxsm);
			ans = min<ll>(ans, mxsm - mnsm);
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
void MI(int &a, int v) {a = min(a,v);}
void MA(int &a, int v) {a = max(a,v);}

signed main() {
    int n; cin>>n;
    int a[3*n];
    F(i,3*n) cin>>a[i];
    sort(a, a+3*n);
    int sum=0;
    F(i,n) {
        //D(3*n-2*i-2);
        sum += a[3*n-2*i-2];
    }
    P(sum);
}

Measured memory_bytes: 2560
n, k = gets.chomp.split(' ').map(&:to_f)

prob = 0.0
for j in 1..n
  i = 1.0
  while j < k
    prob += (1 / n) * (1.0/2.0) ** i
    j = j * 2.0
    i = i + 1.0
  end
end

puts (1.0 - prob)

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X, Y;
  cin >> X >> Y;
  
  int res = 0;
  for(int i = 0; i <= X; i++){
    int j = X-i;
    int legs = 2 * i + 4 * j;
    if(legs == Y) res++;
  }
  
  if(res != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
/*#include <iostream>
#include <bits/stdc++.h>
#define fast_cin ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;

vector<ll> dp(100005,0);
int m=1e9+7;
bool cmp(pair<int,int>&a,pair<int,int>&b)
{
    if(a.second==b.second)
        return a.first<b.first;
    else
        return a.second<b.second;
}

bool cmp_(pair<int,pair<int,int> >&a,pair<int,pair<int,int> >&b)
{
   return a.second.first<b.second.first;
}

void factorial()
{
    dp[1]=1;
    for(int i=2;i<=100000;i++)
    {
        dp[i]=((dp[i-1]%m)*(i%m))%m;
    }
}

int main()
{
    fast_cin;
      string s,t;
      cin>>s>>t;
      int n=s.length();
      int m=t.length();
      unsigned int dp[n+1][m+1];
      string ans;
      for(int i=0;i<=n;i++)
      {
          for(int j=0;j<=m;j++)
          {
              if(i==0||j==0)
                dp[i][j]=0;
              else if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
              else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
              if(ans.length()<dp[i][j])
                ans+=s[i];
          }
      }
      cout<<dp[n][m]<<endl;
      //cout<<ans<<endl;
    return 0;
}*/
#include <iostream>
#include <bits/stdc++.h>
#define fast_cin ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;

vector<ll> dp(100005,0);
int m=1e9+7;
bool cmp(pair<int,int>&a,pair<int,int>&b)
{
    if(a.second==b.second)
        return a.first<b.first;
    else
        return a.second<b.second;
}

bool cmp_(pair<int,int>&a,pair<int,int>&b)
{
   return a.second>b.second;
}

void factorial()
{
    dp[1]=1;
    for(int i=2;i<=100000;i++)
    {
        dp[i]=((dp[i-1]%m)*(i%m))%m;
    }
}
void binary(int n)
{
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int main()
{
    fast_cin;
    int t;
    t=1;
    while(t--)
    {
       int n;
       cin>>n;
       int dp[n]={0};
       vector<int> v;
       for(int i=0;i<n;i++)
       {
           int u;
           cin>>u;
           v.pb(u);
       }
       dp[1]=abs(v[0]-v[1]);
       for(int i=2;i<n;i++)
       {
           dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
       }
       cout<<dp[n-1];
    }
    return 0;
}


Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  cin >> x >> y;
  if(y%2!=0){
    cout << "No" << endl;
  }else if(y/x >= 4){
    if(y%x>0){
      cout << "No" << endl;
    }else if(y/x == 4){
      cout << "Yes" << endl;
    }else{
      cout << "No" <<endl;
    }
  }else if(y/x < 2){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

void solve(long long x){
    ll ans = 0;
    if(x <= 6) ans = 1;
    else{
        if(x%11 <= 6 && x%11 > 0) ans = 2 * (x/11) + 1;
        else if(x%11 > 6) ans = 2 * (x/11) + 2;
        else ans = 2 * (x/11);
    }
    cout << ans << endl;
    return;
}

int main(){
    long long x;
    scanf("%lld",&x);
    solve(x);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  
  int ans=0;
  
  rep(i,n)
    cin >> a[i];
  
  vector<int> b(n);
  rep(i,n){
    cin >> b[i];
    ans += b[i];
  }
  
  vector<int> c(n);
  rep(i,n-1)
    cin >> c[i];
  
  rep(i,n){
    if(i>0&&a[i]-a[i-1]==1)
      ans+=c[a[i-1]-1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))

using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


int a[100005],b[100005];


int cost(int n){
    if(n<0)return 0;
    else if(b[n]!=-1)return b[n];
    else{
        int i=n;
        b[n]=min(cost(n-1)+abs(a[i]-a[i-1]),cost(n-2)+abs(a[i]-a[i-2]));
        return b[n];
    }
}



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,t,n,k;
   cin>>n;
   _init(b);
   _init0(a);
   fo(i,0,n){
       cin>>x;
       a[i]=x;
   }
   
   b[0]=0;
   b[1]=abs(a[0]-a[1]);
   
     cout<<cost(n-1);

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n+2];
    a[0] = 0;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    a[n+1] = 0;
    for(int i=1;i<=n+1;i++){
        sum += abs(a[i]-a[i-1]);
    }
    for(int i=1;i<=n;i++){
        if ((a[i-1]<=a[i] && a[i]<=a[i+1]) || (a[i-1]>=a[i] && a[i]>=a[i+1])) {
            cout << sum << endl;
        }
        else if((a[i-1] <= a[i] && a[i] >= a[i+1] && a[i-1]>=a[i+1]) || (a[i-1] >= a[i] && a[i] <= a[i+1] && a[i-1]<=a[i+1])){
            cout << sum - (abs(a[i]-a[i-1])*2) << endl;
        }else{
            cout << sum - (abs(a[i+1]-a[i])*2) << endl;
        }
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a[4]={1,4,7,9};
  vector<int>vec(4);
  rep(i,4) cin >> vec[i];
  sort(vec.begin(),vec.end());
  bool ok=true;
  rep(i,4){
    if(vec[i]!=a[i])ok=false;
  }
  if(ok)cout<<"YES"<<endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main() {
  int X, N;
  cin >> X >> N;
  set<int> S;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    S.insert(p);
  }
  int ans = 0;
  int d = X;
  for (int i = 1; i <= 101; i++) {
    if (!(S.count(i))) {
      if (abs(X - i) < d) {
        ans = i;
        d = abs(X - i);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
l, r = map(int, input().split())

if r - l + 1 >= 2019:
    print(0)
    exit()

e = min(r + 1, l + 2019)
ans = 2019
for i in range(l, e):
    for j in range(i + 1, e):
        ans = min(ans, (i * j) % 2019)

print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    set<char> s;
    REP(i, N) {
        char c; cin >> c;
        s.insert(c);
    }

    if(s.size() == 3) print("Three");
    else print("Four");


}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = sorted(readInts(),reverse=True)
a = sum(A)**2
nya = 0
for i in range(n):
    nya += A[i]*A[i]
ans = (a-nya)//2
print(ans%mod)
# a = pow(a,2,mod)
# nya = 0
# for i in range(n):
#     nya += A[i] * A[i]
#     nya %= mod
# if nya > a:
#     a += mod
# #print(a,nya)
# ans = (a-nya)//2
# ans %= mod
# if ans < 0:
#     ans += mod
# print(ans)


Measured memory_bytes: 34372
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, t; cin >> n >> t;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> imosmin(n+1, INF);
    REP(i, n) imosmin[i+1] = min(imosmin[i], a[i]);

    vector<ll> prf(n, 0);
    RANGE(i, 1, n-1) prf[i] = a[i] - imosmin[i];

    sort(ALL_OF(prf), greater<ll>());
    ll ie = upper_bound(ALL_OF(prf), prf[0], greater<ll>()) - prf.begin();
    cout << ie << endl;
    
}

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

int x[8], y[8];

double dist(int a, int b) {
  int dx = x[a] - x[b];
  int dy = y[a] - y[b];
  return sqrt(dx * dx + dy * dy);
}

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    v.at(i) = i;
  }
  double sum = 0.0;
  do {
    for (int i = 0; i < N - 1; i++) {
      sum += dist(v.at(i), v.at(i + 1));
    }
  } while (next_permutation(v.begin(), v.end()));
  
  int total = 1;
  for (int i = 2; i <= N; i++) {
    total *= i;
  }
  
  cout << fixed << setprecision(10) << sum / total << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string S,S2;
    cin >> S >> S2;
    bool ans = true;
    REP(i,S.length()){
        if(S[i] != S2[i]){
            ans = false;
        }
    }
    if(ans){
        fin("Yes");
    }else{
        fin("No");
    }
    //fin(S.length());
    return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

string days[8] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main()
{
  fastio();

  string s; cin >> s;

  auto it1 = find(days,days+8,s);
  auto it2 = find(it1+1,days+8,"SUN");

  cout << it2 - it1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int x;      //賞味期限からsafeまでの期間
  int a;      //賞味期限のa日前に買ってくる
  int b;      //買ってからの日数
  int c;      //買ってから食べるまでの日数(b-a)

  std::cin >> x >> a >> b;
  c = b-a;

  if(c<=0) std::cout << "delicious" << '\n';
  else if(0<c&&c<=x) std::cout << "safe" << '\n';
  else std::cout << "dangerous" << '\n';

  return (0);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,s,z,w,y,v,min;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	s=a+b;
	z=a+c;
	w=b+c;
	min=1000;
	if(min>s){
		min=s;
	}
	if(min>z){
		min=z;
	}
	if(min>w){
		min=w;
	}
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]

def dfs(depth,x,y,z):
  if depth==n:
    return abs(x-a)+abs(y-b)+abs(z-c)-30 if min(x,y,z)>0 else np.inf
  
  A = dfs(depth+1,x+l[depth],y,z)+10
  B = dfs(depth+1,x,y+l[depth],z)+10
  C = dfs(depth+1,x,y,z+l[depth])+10
  X = dfs(depth+1,x,y,z)
  
  return min(A,B,C,X)
print(dfs(0,0,0,0))

Measured memory_bytes: 12964
// 店名、評価点、店番号情報を格納し、店番号は保持して店名でソート、評価点で逆順ソートしたい.
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main() {
  int n; cin >> n;
  pair<pair<string,int>,int> p[105]; // pairは配列に近い.vectorとは異なる.
  for(int i=0;i<n;i++){
    string s; int a; cin >> s >> a;
    p[i] = make_pair(make_pair(s,-a),i); // 逆順ソートのため符号を反転させる.
  }
  sort(p,p+n); // pairは配列に近い.では配列とvectorの,ポインタの役割の違いは?
  for(int i=0;i<n;i++) cout << p[i].second+1 << endl; //pairの2つ目の要素の2番目.
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define LINF (1LL << 60)
using namespace std;
typedef long long Int;

Int n, W, w[110], v[100], dp[110000];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

  for (int i = 0; i < n; i++) {
    Int weight = w[i];
    Int value = v[i];
    for (int j = W; 0 < j; j--) {
      if (0 <= j - weight) {
        dp[j] = max(dp[j - weight] + value, dp[j]);
      }
    }
  }
  cout << dp[W] << endl;
  return 0;
}

Measured memory_bytes: 4396
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int num[]=new int[24];
		double t[]=new double[24];
		boolean ju[]=new boolean[24];
		Arrays.fill(ju, true);
		for(int i=0;i<24;i++)
		{
			num[i]=in.nextInt();
			t[i]=in.nextDouble();
		}

		double ti=Integer.MAX_VALUE;
		int nu=-1;
		int inde=-1;
		for(int j=0;j<2;j++)
		{
			for(int i=0;i<8;i++)
			{
				if(t[i]<ti&&ju[i])
				{
					ti=t[i];
					nu=num[i];
					inde=i;
				}
			}
			ju[inde]=false;
			System.out.println(nu+" "+ti);
			ti=Integer.MAX_VALUE;
			nu=-1;
			inde=-1;
		}
		for(int j=0;j<2;j++)
		{
			for(int i=8;i<16;i++)
			{
				if(t[i]<ti&&ju[i])
				{
					ti=t[i];
					nu=num[i];
					inde=i;
				}
			}
			ju[inde]=false;
			System.out.println(nu+" "+ti);
			ti=Integer.MAX_VALUE;
			nu=-1;
			inde=-1;
		}
		for(int j=0;j<2;j++)
		{
			for(int i=16;i<24;i++)
			{
				if(t[i]<ti&&ju[i])
				{
					ti=t[i];
					nu=num[i];
					inde=i;
				}
			}
			ju[inde]=false;
			System.out.println(nu+" "+ti);
			ti=Integer.MAX_VALUE;
			nu=-1;
			inde=-1;
		}
		for(int j=0;j<2;j++)
		{
			for(int i=0;i<24;i++)
			{
				if(t[i]<ti&&ju[i])
				{
					ti=t[i];
					nu=num[i];
					inde=i;
				}
			}
			ju[inde]=false;
			System.out.println(nu+" "+ti);
			ti=Integer.MAX_VALUE;
			nu=-1;
			inde=-1;
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){


 int h,a,cnt=0;
    cin>>h>>a;
 if(h%a==0)
 {
     cnt=h/a;
 }
 else
    cnt=h/a+1;
  cout<<cnt<<endl;



return 0;


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l;
	cin>>l;
	if(l<1200) cout<<"ABC"<<endl;
	else if(l<2800) cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

a, b = map(int, input().split())
ans = 0
cnt = 1
while True:
    if cnt >= b:
        print(ans)
        sys.exit()
    cnt = cnt + a - 1
    ans += 1

Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N, K, x;
  cin >> N >> K;
  x=N%K;
  cout << min(x, abs(x-K)) << "\n";
}

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

int A, B;

int main () {
	cin >> A >> B;
	if(A==1) A+=13;
	if(B==1) B+=13;
	if (A > B){
		cout << "Alice" << endl;
	}
	if (A < B){
		cout << "Bob" << endl;
	}
	if (A==B){
		cout << "Draw" << endl;
	}
}

Measured memory_bytes: 3536
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    str t; cin>>t;
    int a = t.size(), o=0, pr = 2;
    for(int q=0; q<a; q++){
        if(pr==2){
            o++;
            pr = 1;
            continue;
        }
        if(t[q]!=t[q-1]) o++;
        else{
            if(q+1==a) break;
            pr = 2; q++; o++;
        }
    }
    cout<<o;
}

Measured memory_bytes: 720
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.append(n)
d=[]
for i in range(len(a)-1):
    d.append([i,a[i+1]-a[i]])
d[-1][1]+=a[0]
l=sorted(d,key=lambda x:x[1])

o=l[-1][0]
if o==len(a)-2:
    g=a[-2]-a[0]
else:
    g=a[o]+n-a[o+1]
print(g)

Measured memory_bytes: 43188
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vvi x(n), y(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            int xx, yy;
            cin >> xx >> yy;
            xx--;
            x[i].push_back(xx);
            y[i].push_back(yy);
        }
    }
    int ret = 0;
    for (int i = 0; i < (1 << n); ++i) {
        int cnt = 0;
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if ((1 << j) & i) {
                cnt++;
                int m = x[j].size();
                for (int k = 0; k < m; ++k) {
                    if ((1 << x[j][k] & i) && y[j][k] != 1)
                        ok = false;
                    if (!(1 << x[j][k] & i) && y[j][k] != 0)
                        ok = false;
                }
            }
        }
        if (ok)
            chmax(ret, cnt);
    }
    cout << ret << "\n";
    return 0;
}

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

int main() {
	int x, y;
	cin >> x >> y;

	if(x == 1 && y == 1) cout << 1000000 << endl;
	else if((x == 1 && y == 2) || (x == 2 && y == 1)) cout << 500000 << endl;
	else if((x == 1 && y == 3) || (x == 3 && y == 1)) cout << 400000 << endl;
	else if(x == 2 && y == 2) cout << 400000 << endl;
	else if((x == 2 && y == 3) || (x == 3 && y == 2)) cout << 300000 << endl;
	else if(x == 3 && y == 3) cout << 200000 << endl;
	else if((x == 1 && y > 3) || (x > 3 && y == 1)) cout << 300000 << endl;
	else if((x == 2 && y > 3) || (x > 3 && y == 2)) cout << 200000 << endl;
	else if((x == 3 && y > 3) || (x > 3 && y == 3)) cout << 100000 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int n = 2 * N, k = -1;
    for(int i = 1; i * i <= n ; i++) {
        if(n % i == 0) {
            if(i + 1 == n / i) {
                k = i + 1;
            }
        }
    }
    if(k == -1) No();
    cout << "Yes" << endl;
    cout << k << endl;
    vector<int> S[1000];
    int u = 0, d = 1;
    rep1(i, N) {
        S[u].pb(i); S[d].pb(i);
        d ++;
        if(d == k) {
            u ++;
            d = u + 1;
        }
    }
    rep(i, k) {
        cout << k - 1 << " ";
        rep(j, k - 1) {
            cout << S[i][j] << " ";
        }
        cout << endl;
    }
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  bool four = false;
  for (int i = 0; i < n; i++) {
    char x;
    cin >> x;
    if (x == 'Y') {
      four = true;
    }
  }
  puts(four ? "Four" : "Three");
  return 0;
}




Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 11:27:14 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	vector<ll>	F(100002);
	F.at(1) = 1;
	F.at(2) = 1;
	rep2(i, 3, 100002)
		F.at(i) = (F.at(i - 2) + F.at(i - 1)) % MOD;

	ll	n, m;
	cin >> n >> m;
	if (m == 0)
	{
		cout << F.at(n + 1) << endl;
		return ;
	}
	vector<ll>	V(m);
	rep(i, m)
		cin >> V.at(i);
	ll	ans;
	ans = 1;
	ans *= F.at(V.at(0));
	ans %= MOD;
	ans *= F.at(n - V.back());
	ans %= MOD;
	rep(i, m - 1)
	{
		ans *= F.at(V.at(i + 1) - V.at(i) - 1);
		ans %= MOD;
	}
	cout << ans << endl;
}
// END

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


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

int main()
{
  int s1,s2;
  for(;cin>>s1>>s2,s1||s2;)
    {
      int max=s1+s2;
      char name='A';
      for(int i=1;i<5;i++)
        {
          cin>>s1>>s2;
          if(max<s1+s2)
            {
              max=s1+s2;
              name='A'+i;
            }
        }
      cout<<name<<" "<<max<<endl;
    }
}

Measured memory_bytes: 1160