akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,q;
  cin>>n>>q;
  
  long long s[n],t[n],x[n];
  REP(i,n){
    cin>>s[i]>>t[i]>>x[i];
  }
  
  long long d[q];
  REP(i,q){
    cin>>d[i];
  }
  
  vector<pair<long long,pair<int,long long> > > events;
  REP(i,n){
    events.push_back(make_pair(s[i]-x[i],make_pair(1,x[i])));
    events.push_back(make_pair(t[i]-x[i],make_pair(-1,x[i])));
  }
  int event_num=events.size();
  sort(events.begin(),events.end());
  
  int index=0;
  set<long long> xs;
  REP(i,q){
    while(events[index].first<=d[i] && index<event_num){
      if(events[index].second.first==1){
        xs.insert(events[index].second.second);
      }else{
        xs.erase(events[index].second.second);
      }
      index++;
    }
    if(xs.empty()){
      cout<<-1<<endl;
    }else{
      cout<<*xs.begin()<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 28136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  ll x;
  cin>>n>>x;
  ll a[n+1]={};
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }

  ll b[n+1]={};
  for(int i=0;i<=n;i++) b[i]=1e9+5;

  ll ans=sum;
  for(int i=0;i<n;i++){
    ll tmp=x*i;
    for(int j=0;j<n;j++){
      b[j]=min(b[j],a[(j-i+n)%n]);
      tmp+=b[j];
    }

    ans=min(ans,tmp);
  }

  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

char str[111][111];
int a[30];

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",str[i]);
        for(int j=0;j<w;j++){
            a[str[i][j]-'a'+1]++;
        }
    }
    int g1=(h%2)*(w%2);
    int g2=(h/2)*(w%2)+(w/2)*(h%2);
    int g3=(h/2)*(w/2);
    for(int i=1;i<=26;i++){
        g3-=(a[i]/4);
        a[i]%=4;
        g2-=(a[i]/2);
        a[i]%=2;
        g1-=a[i];
    }
    g2+=(g3*2);
    if(g3>0||g2>0||g1>0){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    read(n);
    vi a(n+1,0);
    fr(i,n-1){
        read(x);
        a[x]++;
    }
    fr(i,n){
        cout << a[i+1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3988
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    ll=[]
    for i in l:
        ll.append(abs(x-i))
    from functools import reduce
    from fractions import gcd
    print(reduce(gcd,ll))
resolve()

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}

int main() {
    ll n,m;
    cin>>n>>m;
    if (n>= 13) pr(m);
    else if (n>= 6) pr(m/2);
    else pr(0);
    return 0;
}

Measured memory_bytes: 888
import math
a,b,C=map(float,input().split())
S=a*b*math.sin(math.pi*C/180)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*C/180))
L=a+b+c
h=2*S/a
print(f'{S:.5f}')
print(f'{L:.5f}')
print(f'{h:.5f}')



Measured memory_bytes: 5704
A = [int(x) for x in '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')]
K = int(input())
print(A[K-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    bool f = true;
    rep(i, 0, n) {
        if(s[i] == 'L' && i%2 == 0) f = false;
        if(s[i] == 'R' && i%2 == 1) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, accumulate
import itertools
import heapq
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    A = sorted(A)

    cur = 0
    value = 1
    if N % 2 == 1:
        cur = 1
        value = 2
        if A[0] != 0:
            print(0)
            return

    while cur < N:
        if not (A[cur] == value and A[cur+1] == value):
            print(0)
            return
        cur += 2
        value += 2

    if N % 2 == 1:
        print(pow(2, (N - 1) // 2, MOD))
    else:
        print(pow(2, N // 2, MOD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53552
# -*- coding: utf-8 -*-

a,b,k = map(int,input().split())
acd = []
bcd = []
cd = []

for i in range(1,a+1):
    if a % i == 0:
        acd.append(i)
for i in range(1,b+1):
    if b % i == 0:
        bcd.append(i)
for i in acd:
    for j in bcd:
        if i == j:
            cd.append(i)
print(cd[-k])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#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)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll ans=0;
  REP(a,1,n+1) {
    REP(b,1,n+1) {
      REP(c,1,n+1) {
        ll d=__gcd(a,b);
        ans+=__gcd(c,d);
      }
    } 
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

set<ll> s;

void dfs(ll num, int len){
    s.insert(num);
    for(int i=max(num%10-1,0LL);i<=min(num%10+1,9LL);i++){
        if(len+1<=10){
            dfs(num*10+i,len+1);
        }
    }
}

int main() {
    
    ll k;
    cin>>k;
    rep(i,10)dfs(i,0);

    int pos=1;
    s.erase(s.find(0));
    irep(i,s){
        if(pos==k){
            fin(*i);
            break;
        }
        pos++;
    }
}



Measured memory_bytes: 27520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 1e5 + 5;
	int f[N][3],a[N][3];
	int n;

    void solve(){
    	cin>>n;
    	for(int i = 1;i <= n;++i){
    		for(int j = 0;j < 3;++j){
    			cin>>a[i][j];
    		}
    	}
    	for(int i = 1;i <= n;++i){
    		for(int j = 0;j < 3;++j){
    			for(int k = 0;k < 3;++k){
    				if(j ^ k){
    					maximize(f[i][j],f[i - 1][k] + a[i][j]);
    				}
    			}
    		}
    	}
    	cout<<max(max(f[n][0],f[n][1]),f[n][2]);
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
#include <assert.h>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 200005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}
int pow(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % c;
        a = 1LL * a * a % c;
        b >>= 1;
    }
    return ans;
}

int main(){
  int T, i, j, k, ca = 0, m, K;
  ll n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  if((b-a) & 1) {
    ll l = a-1 + (b - (a-1)) / 2;
    ll r = n-b + (b - (a-1)) / 2;
    printf("%lld\n", min(l, r));
  }
  else {
    printf("%lld\n", (b-a) / 2);
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from itertools import combinations
    import sys
    input = sys.stdin.readline

    n = int(input())
    l = list(map(int, input().split()))
    comb = list(combinations(range(n), 3))
    ans = 0

    for i, j, k in comb:
        a = l[i]
        b = l[j]
        c = l[k]

        # 3変数のうち、最大値が残りの2変数よりも大きいことを楽に実装する
        # See:
        # https://www.youtube.com/watch?v=auQRcs5JMwE&feature=youtu.be
        # a + b <= c (ただし、a < b < c)
        # 両辺にcを足す
        # a + b + c <= c + c
        if a == b:
            continue
        if b == c:
            continue
        if c == a:
            continue

        if sum([a, b, c]) <= 2 * max(a, b, c):
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20536
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n,0);
    for(int i = 0; i< n; i++){
        cin >> p[i];
    }
    //cout << "--1-" << endl;
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k;i++){
        //cout << "---" << endl;
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double n,m,d;
    cin >> n >> m >> d;
    if(d==0){
        cout << (m-1)*(1/n) << endl;
    }else{
        cout << (m-1)*(2*(n-d)/(n*n));
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment (linker, "/stack:256000000")

#include <iostream>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <cmath>
#include <cassert>
#include <ctime>
#include <memory.h>

using namespace std;

#define fo(a,b,c) for(int a=(b);a<(c);a++)
#define fd(a,b,c) for(int a=(b);a>=(c);a--)
#define fi(a) fo(i,0,(a))
#define fj(a) fo(j,0,(a))
#define fk(a) fo(k,0,(a))
#define _(a,b) memset((a),(b),sizeof(a))
#define __(a) memset((a),0,sizeof(a))
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__);fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << (x) << endl;}
#else
#define dbg(...) {}
#define dbgx(x) {}
#endif

typedef long long lint;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1000000000;
const lint LINF = 4000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int n;

void read()
{
	scanf("%d", &n);
}

bool solve()
{
	int s = 0;
	fi(n + 1) if (i)
	{
		s += i;
		if (s >= n)
		{
			printf("%d\n", i);
			return false;
		}
	}
	return false;
}

int main()
{
	prepare();
	read();
	while (solve());
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    println!("{}", v[1]/v[2] - v[0]/v[2] + (if v[0] % v[2] == 0 {1} else {0}));
}



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

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

	int N = S.size();
	int b = 0;
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( S[i] == 'B' ) b++;
		else ans += b;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3744
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    XL=[0]*N
    YL=[0]*N
    for i in range(N):
        x,y=MI()
        X=x+y
        Y=x-y
        XL[i]=X
        YL[i]=Y
        
    x=max(XL)-min(XL)
    y=max(YL)-min(YL)
    
    print(max(x,y))
        

main()


Measured memory_bytes: 71852
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

Ap = [0] * N
Am = [0] * N

for i in range(N):
	Ap[i] = i + A[i]
	Am[i] = i - A[i]

import collections
h = collections.defaultdict(int)
ans = 0
for i in range(N):
	if Am[i] in h:
		ans += h[Am[i]]
	h[Ap[i]] += 1
print(ans)


Measured memory_bytes: 114668
#include<bits/stdc++.h>
using namespace std;
int dis(int a, int b) {
  return max(a - b, b - a);
}
int main () {
  int N, M;
  cin >> N >> M;
  int sx[100];
  int sy[100];
  int cx[100];
  int cy[100];
  for (int i = 0; i < N; i ++) cin >> sx[i] >> sy[i];
  for (int i = 0; i < M; i ++) cin >> cx[i] >> cy[i];
  for (int i = 0; i < N; i ++) {
    int ans = 0;
    int mdi = 1e9 + 5;
    for (int j = M - 1; j >= 0; j --) {
      if (mdi >= (dis(sx[i], cx[j]) + dis(sy[i], cy[j]))) {
        ans = j + 1;
        mdi = dis(sx[i], cx[j]) + dis(sy[i], cy[j]);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
typedef long long ll;
ll K, rec[60], ans[60];
const ll N = 50;
int main() {
	cin >> K;
	ll div = K / N, mo = K % N;
	for (ll i=0;i<N;i++)
		rec[i] = div + (i < mo);
	for (ll i=0;i<N;i++) {
		ll sum = 0;
		for (ll j=0;j<N;j++){
			if(i != j)
				sum += rec[j];}
		ans[i] = N * (rec[i] + 1) - sum - 1;
	}
	cout << N << endl;
	for (ll i=0;i<N;i++) cout << ans[i]<<" ";
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
import numpy as np

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

a = ni()
s, t = ns().split()
for i, j in zip(s, t):
    print(i, end="")
    print(j, end="")
print()

Measured memory_bytes: 12488
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean isPrimeNumber[] = new boolean[55555 + 1];
        Arrays.fill( isPrimeNumber, true );
        int root = (int)Math.ceil(Math.sqrt(55555));
        for(int i = 2; i < root; i++) {
            if( !isPrimeNumber[i] ) continue;
            int index = 2;
            while( i * index <= 55555 ) {
                isPrimeNumber[i*index] = false;
                index++;
            }
        }
        
        int cnt = N;
        StringBuilder ans = new StringBuilder();
        for(int i = 2; i <= 55555; i++ ) {
            if( isPrimeNumber[i] && i % 5 == 1 ){
                ans.append(i);
               
                if( --cnt == 0 ) {
                    break;
                } else {
                    ans.append(" ");
                }
            }
            

        }
        System.out.println(ans);
    }
}




Measured memory_bytes: 36028
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define MOD 1000000007
#define PI 3.14159265358979323846

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

	int n = 0, m = 0;
	cin >> n >> m;

	vector<vector<int> > graph;
	graph.resize(n+2);

	int x, y;
	for( int i = 0; i < m; i++ ) {
		cin >> x >> y;
		// cout<<x<<" "<<y<<endl;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	// for( int i = 0; i <= n; i++ ) {
	// 	cout<<i << " => ";
	// 	for( int j = 0; j < graph[i].size() ; j++ ) {
	// 		cout<<graph[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	vector<int> visited(n+1, 0);
	queue<int> qu;
	qu.push(1);
	visited[1] = 1;
	vector<int> result(n+1, 0);

	while( !qu.empty() ) {
		int siz = qu.size();
		for( int i = 0; i < siz; i++ ) {
			int v = qu.front();
			qu.pop();

			for( auto u : graph[v] ) {
				if( visited[u] == 0 ) {
					result[u] = v;
					visited[u] = 1;
					qu.push(u);
				}
			}
		}
	}

	for( int i = 1; i <= n; i++ ) {
		if( visited[i] == 0 ){
			cout<< "No" <<endl;
			return 0;
		}
	}

	cout << "Yes"  <<endl;
	for( int i = 2; i <= n; i++ ) {
		cout << result[i] <<endl;
	}

	return 0;

}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;



int main(int argc, const char * argv[]) {
    
   
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int H,W; cin >> H >> W;
    vector<string> field(H);
    
    rep(i,H) cin >> field[i];
    
    
    
    
    
    
    rep(i,H){
        rep(j,W){
            
            
            
            ll nowH = i;
            ll nowW = j;
            if(field[nowH][nowW] == '#') {
                cout << '#';
                continue;
            }
            
            
            int CB = 0;
            rep(k,8){
                ll newH = nowH + dx8[k];
                ll newW = nowW + dy8[k];
                if( !( 0<=newH&&newH<H && 0<=newW&&newW<W ) ) continue;
                if( field[newH][newW] == '#' ) CB++;
            }
            cout << CB;
            
            CB = 0;
            
            
            
        }
        cout << endl;
    }
    
  
    
    
    
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s %s', $s, $t);
fscanf(STDIN, '%d %d', $a, $b);
fscanf(STDIN, '%s', $u);

if ($u == $s) {
  $a -= 1;
} else {
  $b -= 1;
}

echo $a.' '.$b;

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int f(int nn){
  int n=nn;
  int t=0;
  while(n){
    int pc = __builtin_popcount(n);
    n%=pc;
    t++;
  }
  return t;
}

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

  int pc=0;
  for(auto c:s)if(c=='1')pc++;
  
  if(pc==0){
    rep(i, n)cout<<1<<endl;

    return 0;
  }
  
  int pc0=pc+1;
  int pc1=pc-1;

  vector<int>pow2_pc1(n);
  int s1=0;
  if(pc>=2){
    int t1=1;
    rep(i, n){
      int ci = n-1-i;
      pow2_pc1[ci]=t1%pc1;
      t1 = t1*2%pc1;
    }
    int t=1;
    rrep(i, n){
      if(s[i]=='1')s1 = (s1+t)%pc1;
      t = t*2%pc1;
    }
  }


  vector<int>pow2_pc0(n);
  int s0=0;
  int t0=1;
  int t=1;

  rep(i, n){
    int ci = n-1-i;
    pow2_pc0[ci]=t0%pc0;
    t0 = t0*2%pc0;
  }

  rrep(i, n){
    if(s[i]=='1')s0 = (s0+t)%pc0;
    t = t*2%pc0;
  }

  
  rep(i, n){
    int ci = n-1-i;
    if(s[i]=='1'){
//            cout<<'u';
      int tmp = s1-pow2_pc1[i];
      if(pc<=1)cout<<0<<endl;
      else cout<<f((tmp+pc1)%pc1)+1<<endl;
    }else{
      int tmp = (s0+pow2_pc0[i])%pc0;

//      cout<<'d';
//      cout<<tmp<<' '<<s0<<' '<<pow2_pc0[i]<<'('<<i<<')';

      cout<<f(tmp)+1<<endl;
    }
  }

  return 0;

  cout<<"---"<<endl;
  cout<<pc0<<' '<<pc1<<' '<<s1<<' '<<s0<<endl;
  rep(i, n)cout<<pow2_pc1[i]<<' ';cout<<endl;
  rep(i, n)cout<<pow2_pc0[i]<<' ';cout<<endl;
  
  rep(i, n)cout<<s[i];cout<<endl;

  return 0;
}

Measured memory_bytes: 5108
#include<stdio.h>

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

if(-1000 <= a && b <= 1000){
if(a < b){
printf("a < b\n");
}
else if(a > b){
printf("a > b\n");
}
else if(a == b){
printf("a == b\n");
}
}
}


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

const ll INF = 1e12+1;

ll S, c;

bool check(ll num){
    ll needS = max(0LL, num - S);
    ll needC = needS*2;
    if(c < needC) return false;
    if(c - needC < num*2) return false;
    return true;
}

int main(void){
    cin >> S >> c;

    ll l = 0, r = INF;
    while(l+1 < r){
        ll mid = (l+r)/2;
        if(check(mid)) l = mid;
        else r = mid;
    }
    cout << l << endl;
}


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


void solve(long long R, long long G){
    cout << G * 2 - R << endl;
}

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


Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var h = firstLine[0];
            var w = firstLine[1];
            var dp = new List<int[]>();

            for (var i = 0; i < 10; i++)
            {
                dp.Add(ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
            }

            var wall = new List<int[]>();

            for(var i = 0; i < h; i++)
            {
                wall.Add(ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
            }

            for(var i = 0; i < 10; i++)
            {
                for(var j = 0; j < 10; j++)
                {
                    for(var k = 0; k < 10; k++)
                    {
                        dp[j][k] = Min(dp[j][k], dp[j][i] + dp[i][k]);
                    }
                }
            }

            var cost = 0;
            for(var i = 0; i < h; i++)
            {
                for(var j = 0; j < w; j++)
                {
                    if(wall[i][j] == -1)
                    {
                        continue;
                    }
                    cost += dp[wall[i][j]][1];
                }
            }

            WriteLine(cost);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	ll N,D; cin>>N>>D;
  vector<vector<ll>> x(N,vector<ll>(D));
  rep(i,N){
  	rep(j,D){
    	cin>>x[i][j];
    }
  }
  double tmp=0.0;
  ll cnt=0;
  rep(i,N-1){
  	for(int j=i+1;j<N;j++){
    	rep(k,D){
        	tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
      if((int)sqrt(tmp)*(int)sqrt(tmp)==(int)tmp) cnt++;
      tmp=0;
    }
  }
  
  printf("%lld",cnt);
    
  
  
}

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


int main() {
    int n;
    cin >> n;

    map<string,int> count;

    vector<string> str(n);
    rep(i,n) {
        cin >> str[i];
        count[str[i]] += 1;
    }

    int max_value = 0;
    for(const auto& i :count){
        int value = i.second;
        if(value > max_value) max_value = value;
    }

    for (auto itr = count.begin(); itr != count.end(); itr++){
        if(itr->second == max_value){
            print(itr->first);
        }
    }
}

Measured memory_bytes: 26752
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    max_count = 0 
    ans = 1
    for i in range(1, n+1):
        count = 0
        tmp = i
        while tmp % 2 == 0:
            count += 1
            tmp //= 2
        if max_count < count:
            max_count = count
            ans = i

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77100
N, K = map(int, input().split())
A = list(map(int, input().split()))
order = [-1]*N
crr = 0
T = 0
s = -1
order[0] = 0
for i in range(N+1):
    crr = A[crr] - 1
    if order[crr] >= 0:
        T = (i+1) - order[crr]
        s = order[crr]
        break
    order[crr] = i+1

if K <= s:
    crr = 0
    while(K):
        K -= 1
        crr = A[crr]-1
    print(crr+1)
else:
    k = K-s
    d = k % T
    while(d):
        d -= 1
        crr = A[crr]-1
    print(crr+1)


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

ll dp[3][3];
ll ans[3][3];
int main(){

    for(ll i = 0; i < 3; i++){
        for(ll j = 0; j < 3; j++){
            cin >> dp[i][j];
        }        
    }

    ll N;
    cin >> N;

    for(ll k = 0; k < N; k++){
        ll t; cin >> t;
        for(ll i = 0; i < 3; i++){
            for(ll j = 0; j < 3; j++){
                if(t ==dp[i][j]) ans[i][j] = 1;
               // cout << ans[i][j];
            }       
           // cout << endl; 
        }
    }

    if(ans[0][0] == 1 && ans[0][1] == 1 && 1 == ans[0][2]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[1][0] == 1 && ans[1][1] == 1 && 1 == ans[1][2]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[2][0] == 1 && ans[2][1] == 1 && 1 == ans[2][2]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[0][0] == 1 && ans[1][0] == 1 && 1 == ans[2][0]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[0][1] == 1 && ans[1][1] == 1 && 1 == ans[2][1]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[0][2] == 1 && ans[1][2] == 1 && 1 == ans[2][2]){
            cout << "Yes" << endl;
            return 0;        
    }

    if(ans[0][0] == 1 && ans[1][1] == 1 && 1 == ans[2][2]){
            cout << "Yes" << endl;
            return 0;        
    }


    if(ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1){
            cout << "Yes" << endl;
            return 0;        
    }

    cout << "No" << endl;


}

Measured memory_bytes: 256
# これ愚直じゃダメなのかな
# 上下左右それぞれのテーブルを用意し、いまいるところより上/下/左/右にいくつあるかをセーブする（自分は含まない）
# ↑ この4方向累積和方針はあってるっぽいけど愚直に4方向のテーブルを作ってみたいな方針でやったらTLEなった。あとは頼む
# ↑ やりました（4ヶ月ぶり） -> 駄目でした TLE
h, w = map(int, input().split())
grid = []
for _ in range(h):
    grid.append(list(input()))

toR, toL = (
    [[0 for _ in range(w + 1)] for _ in range(h)],
    [[0 for _ in range(w + 1)] for _ in range(h)],
)
toU, toD = (
    [[0 for _ in range(w)] for _ in range(h + 1)],
    [[0 for _ in range(w)] for _ in range(h + 1)],
)


for y in range(h):
    for x in range(w):
        if grid[y][x] == ".":
            toR[y][x + 1] += toR[y][x] + 1
            toD[y + 1][x] += toD[y][x] + 1
        else:
            toR[y][x + 1] = 0
            toD[y + 1][x] = 0

        if grid[y][w - x - 1] == ".":
            toL[y][w - x - 1] += toL[y][w - x] + 1
        else:
            toL[y][w - x - 1] = 0

        if grid[h - y - 1][x] == ".":
            toU[h - y - 1][x] += toU[h - y][x] + 1
        else:
            toU[h - y - 1][x] = 0

ans = 0
for y in range(h):
    for x in range(w):
        tmp = toR[y][x + 1] + toL[y][x] + toD[y + 1][x] + toU[y][x] - 3
        ans = max(ans, tmp)

print(ans)



Measured memory_bytes: 313864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}



int main(){
  //cout << fixed << setprecision(10);
  int x;cin >> x;
  vector<ll> five(600);
  for(ll i=-300;i<=300;i++){
    five[i+300]=exp(i,5);
  }
  rep(i,601){
    rep(j,601){
      if(five[i]-five[j]==x){cout << i-300 << ' ' << j-300 << endl;return 0;}
    }
  }
  return 0;
}

Measured memory_bytes: 3572
W,H,x,y = map(int, input().split())

if (W%2==1) or (H%2==1):
    print((W*H)/2,"0")
elif (x == int(W/2)) and (y == int(H/2)):
    print((W*H)/2,"1")
else:
    print((W*H)/2,"0")

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

using namespace std;

int main() {
	string s,t;

	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

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

	return 0;
}

Measured memory_bytes: 256
public class Main {


  private static void solve() {
    char[] s = ns();
    int left = 0;
    int right = 0;
    for (int i = 0; i < s.length; i ++) {
      if (s[i] - '0' != i % 2) {
        left ++;
      } else if (s[i] - '0' != (i + 1) % 2){
        right ++;
      }
    }
    System.out.println(Math.min(left, right));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 26196
from collections import defaultdict

S=input()
T=input()

ds={}
dt={}
for i in range(len(S)):
  if S[i] not in ds:
    ds[S[i]]=T[i]
  elif ds[S[i]]!=T[i]:
    print('No')
    exit()
  if T[i] not in dt:
    dt[T[i]]=S[i]
  elif dt[T[i]]!=S[i]:
    print('No')
    exit()
      
print('Yes')

Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int a, p;
  cin >> a >> p;

  cout << (3 * a + p)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define TEST cout << "ococo" << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<int> arr(n);
	vector<int> answer(n,0);

	for(int i = 0; i != n; i++){
		cin >> arr[i];
		answer[arr[i] - 1] = i + 1;
	}
	for(int i = 0; i != n; i++){
		if(i != 0)cout << " ";
		cout << answer[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
using namespace std;
//strÌ(start)Ú©ç3¶æèo·
char* strpick(char *str, int start)
{
	static char result[4];
	for (int i = 0; i < 3; i++)
	{
		result[i] = str[start+i];
	}
	result[3] = '\0';
	return result;
}
int main()
{
	char str[10001];
	char *tmp;
	int ioi, joi, i;
	while (cin >> str)
	{
		if (cin.eof()) break;
		ioi = joi = 0;
		for (i = 0; i < signed(strlen(str))-2;)
		{
			if (str[i] == 'I' || str[i] == 'J')
			{
				tmp = strpick(str, i);
				if (strcmp(tmp, "IOI") == 0)
					ioi++, i+=2;
				else if (strcmp(tmp, "JOI") == 0)
					joi++, i+=2;
				else
					i++;
			}
			else
				i++;
		}
		cout << joi << endl << ioi << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
// char alph[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
// void change(char a, char b, string& s, int n){
//   for(int i = n; i < s.size(); i++){
//     if(s[i] == a){
//       s[i] = b;
//     }else if(s[i] == b){
//       s[i] = a;
//     }
//   }
// }
void change(char a, char b, string& s){
  for(int i = 0; i < s.size(); i++){
    if(s[i] == a){
      s[i] = b;
    }else if(s[i] == b){
      s[i] = a;
    }
  }
}
int main()
{
  string s, t;
  cin >> s >> t;
  int i = 0;
  REP(j, s.size()){
    if(s[j] != t[j]){
      // cout << s[j] << " " << t[j]<<" ";
      change(s[j], t[j], s);
      // cout << "Yes" << endl;
      // cout << s << endl;
      i ++;
    }
    if(i == 26){break;}
  }
  if(s == t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 776
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A: d[a] += 1
    ans = 0
    for key in d:
        if d[key] < key:
            ans += d[key]
            continue
        ans += d[key] - key
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 22448
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, t;
  cin >> n >> t;
  int ans = 0;
  int bf = -1;
  rep(i, n){
    int tt;
    cin >> tt;
    if(i == 0){
      bf = tt;
    }else if(bf + t > tt){
      ans += tt - bf;
      bf = tt;
    }else {
      ans += t;
      bf = tt;
    }
  }
  ans += t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636