akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
set < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<n);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
  
    
    int n;
    cin>>n;
    int a[n];
    for(int &i:a)cin>>i;
    int ans[n];
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    int answer=0;
    for(auto x:m)
    {
        answer+=(x.ss*(x.ss-1))/2;
    }
    //deb(answer);
    
    for(int i=0;i<n;i++)
    {
        int num=a[i];
        int ac1=m[a[i]];
        int ac2=m[a[i]]-1;
        
        ans[i]=answer-((ac1*(ac1-1))/2 - (ac2*(ac2-1))/2);
    }
    
    for(int i:ans)cout<<i<<'\n';
    
    
    
   
}

Measured memory_bytes: 12672
N = int(input())
D = [int(x) for x in input().split()]

if D[0] != 0:
  print(0)
else:
  flag = True
  D.sort()
  dic = {}
  prev = -1
  for i in D:
    if i not in dic:
      dic[i] = 1
      if(i != prev + 1):
        flag = False
      else:
        prev = i
    else:
      dic[i] += 1
  prev = -1
  cnt = 1
  if dic[0] != 1:
    flag = False
  if flag:
    for k in dic:
      if k > 0:
        t = 1
        for j in range(dic[k]):
          t *= dic[k - 1]
        cnt *= t
  if flag:
    print(cnt % 998244353)
  else:
    print(0)

Measured memory_bytes: 18592
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll ans;
string s;

void solve() {
	int m = s.size() - 1;
	ll res = 0;
	for (int mask = 0; mask < (1 << m); mask++) {
		ll x = 0;
		for (int i = 0; i < m; i++) {
			x = 10 * x + (s[i] - '0');
			if ((mask & (1 << i)) != 0) {
				res += x;
				x = 0;
			}
		}
		x = 10 * x + (s[m] - '0');
		res += x;
		//cout << res << endl;
		ans += res;
		res = 0;
	}
	cout << ans << endl;
}

int main() {
	cin >> s;
	solve();
	return 0;
}




Measured memory_bytes: 256
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans[] = new int[n+1];
		int data[] = new int[m*2];
		for(int i= 0;i < m*2;i++) {
			data[i] = sc.nextInt();
		}
		for(int i = 1;i <= n;i++) {
			for(int k = 0;k < m*2;k++) {
				if(data[k] == i)ans[i]++;
			}
		System.out.println(ans[i]);
		}
	}

}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<x<<endl

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n],b[n];

    f(i,0,n-1)
    {
        cin>>a[i]>>b[i];
    }

    f(i,1,n-2)
    {
        if(a[i-1]==b[i-1] && a[i]==b[i] && a[i+1]==b[i+1])
        {
            cout<<"Yes";
            return;
        }
    }

    cout<<"No";
}

int main()
{    
    //remove this in kickstart

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    f(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";

        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long

    /// 14 39
    ll w[200010],pref[200010],dp[200010],fact[200010];
    ll mod = 1e9 + 7;

        ll modd(ll x)
    {
        return (x%mod+mod)%mod;
    }

    ll poww( ll x, ll y)
    {
        x = modd(x);
        if( y==0 ) return 1LL;
     //   cout << x << " " << y <<endl;
        ll a=poww(x,y/2)%mod;
        ll ans=(a*a)%mod;
        if(y%2==1)ans*=x;
        ans%=mod;
        return ans%mod;
    }



    ll inv( ll x )
    {
        x=modd(x);
        return poww( x, mod-2 )%mod;
    }

  /*  ll binom( ll br, ll naz )
    {
        if( naz < 0 ) return 0;
        ll brr = fact[br];
        ll nazr = fact[naz]*fact[br-naz];
        nazr%=mod;
        nazr=inv(nazr);
        return brr*nazr;
    }*/
/// 4 57
int main()
{
        ios_base::sync_with_stdio(false);
            cin.tie(NULL);

            ll n;
            cin>>n;
            pref[0]=0;
            for( int i=1;i<=n;i++ ) {
                cin>>w[i];
                pref[i]=modd(pref[i-1]+w[i]);
            }
            fact[0]=1LL;
            fact[1]=1LL;
            for( ll i=2;i<=n;i++ ) fact[i]=( fact[i-1]*i )%mod;
            /// sad racunamo sume svih onih intervala dp-om
            dp[1] = pref[n];
            for( int i=2;i<=n;i++ ){
                    dp[i]=modd(dp[i-1]-(pref[n]-pref[n-i+1]));
             /*   for( int j = i; j<=n;j+=i ){
                    dp[i]+=w[j];
                }
                /// treba oduzeti zadnjih i-1 jer se oni ne pikaju, jer ne postoji taj interval za i
                dp[i]-= ( pref[n]-pref[n-i] );*/
                dp[i]+= modd(pref[n]-pref[i-1]);
                dp[i]=modd( dp[i] );
            /// jos da se oduzme zadnji
            }
     //   cout << " oo "<<endl;
            /// sad kad imamo te duzine, onda gradimo rjesenje nalazeci koliko kojih blokova ima. pazimo na blokove koji nemaju jednu granicu, tj. kojima je granica na -1 ili n+1
            ll res=0;
            for( ll len = 1;len<n;len++ ){
                ll add = modd(fact[n]*( inv( (len+1)*(len+2) ) ));
                add*= modd(2LL*(dp[len]-pref[len] - ( pref[n]-pref[n-len] ) ));
                add=modd(add);
                res+=add;
                res=modd(res);
                add = modd(fact[n]*( inv( len+1 ) ));
                add*=modd( pref[len]+( pref[n]-pref[n-len] ) );
                add=modd(add);
                res+=add;
                res=modd(res);
            }
            res+= modd(pref[n]*fact[n]);  /// ovo je da doda citav interval koji se pozove jednom u svakoj od n!
            res=modd(res);
            cout<<res<<endl;
           // cout << dp[1] << " " << dp[2] << " " << dp[3] <<endl;


            return 0;
}































Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using ll = long long;
int main(){ 
    ll a,b,c,d;
    ll tmp,r;
    cin>>a>>b;
    c=b;
    d=a;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout<<d*c/b;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3612
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	E
# CreatedDate:  2020-09-13 21:46:52 +0900
# LastModified: 2020-09-13 22:18:13 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def f(x, y, version):
    if version == 0:
        return x+y
    else:
        return x-y

def main():
    N = int(input())
    ch_0 = []
    ch_1 = []
    trans_max = -1
    for _ in range(N):
        x, y = map(int, input().split())
        ch_0.append(f(x, y, 0))
        ch_1.append(f(x, y, 1))
    ans_0 = max(ch_0)-min(ch_0)
    ans_1 = max(ch_1)-min(ch_1)
    if ans_0 < ans_1:
        print(ans_1)
    else:
        print(ans_0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24956
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  int n, ans = 0;
  string s;
  cin >> n;
  ans = n;
 
  while(1) {
    cin >> s;
    if(s == "=") break;
    cin >> n;
    if(s=="+") {
      ans += n;
    } else if(s=="-") {
      ans -= n;
    } else if(s=="*") {
      ans *= n;
    } else if(s=="/") {
      ans /= n;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 long long	int a,b,c,d,e;
 	cin>>a>>b;
 	if((a+b)%2==0)
 		cout<<(a+b)/2<<endl;
 	else
 		cout<<"IMPOSSIBLE"<<endl;
 	return 0;
}
 	
 					

Measured memory_bytes: 3540
// 2019/07/03
// AtCoder Beginner Contest 076 - B

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

int main() {
    int n, k, psum;
    cin >> n;
    cin >> k;
    psum = 1;
    for(int i = 0; i < n; i++){
        if(psum < k){
            psum *= 2;
        } else {
            psum += k;
        }
    }
    cout << psum;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
b.append(100000+1)
a = [b[0]]
for i in range(n-1):
	if b[i] > b[i+1]:
		b[i] = b[i+1]
	a.append(b[i])
print(sum(a))

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

int lr[510][510];
int sum[510][510];
int main(){
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= n;j++) {
			lr[510][510] = 0;
		}
	}
	for (int i = 0;i < m;i++) {
		int l, r;
		cin >> l >> r;
		lr[l][r]++;
	}
	vector<int>pl(q), qr(q);
	for (int i = 0;i < q;i++) {
		cin >> pl[i] >> qr[i];
	}


	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= n;j++) {
			sum[i][j] = lr[i][i];
		}
	}
	for (int i = 1;i <= n;i++) {
		for (int j = i + 1;j <= n;j++) {
			sum[i][j] = sum[i][j - 1] + lr[i][j];
		}
	}
	for (int i = n ;i > 1;i--) {
		for (int j = i;j <= n;j++) {
			sum[i - 1][j] += sum[i][j];
		}
	}

	for (int i = 0;i < q;i++) {
		cout << sum[pl[i]][qr[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 3712
# coding: utf-8
# Your code here!

def judge(info_num):
    info_num = info_num.split()
    
    num_list = []
    for num in info_num:
        if not num in num_list:
            num_list.append(num)
    result = len(num_list)
    return result

def main():
    info = input()
    result = judge(info)
    
    if result == 2:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
a=[None]*5
for i in range(5):
    a[i] = int(input())
k=int(input())
for i in range(5):
    for j in range(i+1,5):
        if abs(a[i]-a[j]) > k:
            print(':(')
            exit()
print('Yay!')



Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 01:37:47 2019

@author: yuta
"""

def judge(a,b):
    c = a * b
    if c % 2 == 0:
        print("Even")
    else:
        print("Odd")

x = input().split()
judge(int(x[0]),int(x[1]))

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll a,b,d;

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>a>>b>>d;
		if(a==0)break;
		int resx=INF,resy=INF;
		int sum=0;
		while(1){
			sum++;
			for(int x=sum,y=0;x>=0;x--,y++){
				if(a*x+b*y==d||a*x+d==b*y||a*x==b*y+d){
					if(a*resx+b*resy>a*x+b*y){
						resx=x;
						resy=y;
					}
				}
			}
			if(resx!=INF)break;
		}
		cout<<resx<<" "<<resy<<endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include <stdio.h>

int main(void) {
  int n, i;
  while( 1 ) {
    int ans = 0, a;
    scanf("%d", &n);
    if(!n) break;
    n /= 4;
    for(i = 0; i < n; ++i) {
      scanf("%d", &a);
      ans += a;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vvectorl vector<vector<long long>>
#define vectorl vector<long long>
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int squ(int x) {
	return x * x;
}
int di(vectorl x, vectorl y, int i, int j) {
	return squ(x[i] - x[j]) + squ(y[i] - y[j]);
}
int qmmin(int &a, int b) {
	if (a == -1) {
		a = b;
	}
	else {
		a = min(a, b);
	}
	return a;
}
signed main() {
	int n;
	cin >> n;
	int k; cin >> k;
	vector<int> c(n, 0);
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 1; i < n; i++) {
		c[i] = -1;
		int ze = 0;
		for (int j = max(ze, i - k); j < i; j++) {
			qmmin(c[i], c[j] + abs(h[i] - h[j]));
		}
	}
	cout << c[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, m;
string s;

struct RollingHash {
    typedef long long ll;
    typedef pair<ll,ll> pll;

    ll base1;
    ll base2;
    ll mod1;
    ll mod2;
    vector<ll> hash1;
    vector<ll> hash2;
    vector<ll> pow1;
    vector<ll> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }
    //[l, r)
    pll get(int l,int r) {
        ll t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

    RollingHash::pll concat(pll h1, pll h2, int h2_len) {
        return make_pair((h1.first*pow1[h2_len]+h2.first)%mod1, (h1.second*pow2[h2_len]+h2.second)%mod2);
    }

};

signed main(){
    cin >> n >> m >> s;
    int l = 0, r = 1;
    set<P> st;    
    RollingHash rh;
    rh.init(s);
    rep(i, 0, m){
        string q;
        cin >> q;
        if(q == "L++") l++;
        else if(q == "L--") l--;
        else if(q == "R++") r++;
        else r--;
        st.insert(rh.get(l, r));
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 31308
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let h: Vec<i32> = sc.vec(n);
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        g[a - 1].push(b - 1);
        g[b - 1].push(a - 1);
    }
    let mut ans = 0;
    for i in 0..n {
        let mut flag = true;
        for e in g[i].iter() {
            if h[i] <= h[*e] {
                flag = false;
                break;
            }
        }
        if flag {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 8236
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dpc[10000][10000];

bool chsK(string s) {
	int n = s.length();
	if (n % 2 == 0) {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i-1])return false;
		}
	}
	else {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i-1])return false;
		}
	}
	return true;
}

int check(int X, int Y, int K, int J) {
	int t;
	if (K >= Y && J <= X)t = X - J + K - Y + 1;
	else if (K <= X || J >= Y) t = K - J;
	else if (J >= X && K <= Y)t = min(K - J, J - X + Y - K + 1);
	else if (K >= X && K <= Y)t = min(K - J, X - J + Y - K + 1);
	else if (J >= X && J <= Y)t = min(K - J, J - X + K - Y + 1);
	return t;
}



//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else {return dpc[n][r]=combination(n - 1, r - 1)  + combination(n - 1, r);}}


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


	cout << z<<" "<<x<<" "<<y<<endl;
	return 0;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abck = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var a = abck[0];
            var b = abck[1];
            var c = abck[2];
            var k = abck[3];

            var result = 0;
            if (a >= k)
            {
                result = k;
            }
            else if (a + b >= k)
            {
                result = a;
            }
            else
            {
                result = a - (k - (a + b));
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 28208
n, m = map(int, input().split())

A = []
for i in range(n):
    a = [int(a) for a in input().split()]
    A.append(a)

B = []
for i in range(m):
    b = int(input())
    B.append(b)

C = []
for i in range(n):
    ci = 0
    for j in range(m):
        a = A[i]
        c = a[j]*B[j]
        ci += c
    C.append(ci)

for i in range(n):
    print(C[i])


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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S, T;

  cin >> S >> T;

  // main procedure
  bool ans = S == T.substr(0, T.size() - 1);

  // output
  WRITE_N(ans ? "Yes" : "No");

  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        int h,w,k;
        cin>>h>>w>>k;
        string s[h];
        rep(i,h) cin>>s[i];
        ll ans=0, cnt;
        for(int i=0; i<(1<<h); i++){
            for(int j=0; j<(1<<w); j++){
                cnt=0;
                rep(l,h){
                    if((i>>l)&1) continue;
                    rep(m,w){
                        if((j>>m)&1) continue;
                        else if(s[l][m]=='#') cnt++;
                    }
                }
                if(cnt==k) ans++;
            }
        }
        cout<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int main(void)
{
    int N,ans = 0,tmp;
    cin >> N;

    rep(i, N){
        cin >> tmp;
        if(tmp%2 == 1)
            ans++;
    }

    if(ans%2 == 0)
        cout << "YES" << endl;

    else 
        cout <<"NO" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    ll ac = 0, wa = 0, tle = 0, rte = 0;
    for (ll i = 0; i < n; i++) {
        string s;
        cin >> s;
        if(s == "AC") {
            ac++;
        }
         if(s == "TLE") {
            tle++;
        }
         if(s == "RE") {
            rte++;
        }
         if(s == "WA") {
            wa++;
        }
    }

   cout << "AC" << " " << "x" << " " << ac << endl;
      cout << "WA" << " " << "x" << " " << wa << endl;

         cout << "TLE" << " " << "x" << " " << tle << endl;

            cout << "RE" << " " << "x" << " " << rte << endl;

            return 0;

}



Measured memory_bytes: 3652
using System;
class Program
{
	static void Main(string[] args)
	{
		// ボール数
		int ball_N = int.Parse(Console.ReadLine());
		// BロボットのK値
		int K = int.Parse(Console.ReadLine());
		// 各ボールのx座標
		string[] Xaxis_array = Console.ReadLine().Split(' ');


		// 各ボールの最小距離計算
		int sum = 0;
		foreach (string Xaxis in Xaxis_array) 
		{
			//絶対値を計算
			int A_robot_abs = System.Math.Abs(int.Parse(Xaxis));
			int B_robot_abs = System.Math.Abs(int.Parse(Xaxis) - K);
        	if(A_robot_abs >= B_robot_abs)
			{
				sum += B_robot_abs * 2;
			}
			else
			{
				sum += A_robot_abs * 2;
			}
    	}
		//出力
		Console.WriteLine(sum);
	}
}

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

int main(void){
    int N;cin>>N;
    int T[N];
    for(int i=0;i<N;i++){
        cin>>T[i];
    }
    int M;cin>>M;
    int P[M],X[M];
    for(int i=0;i<M;i++){
        cin>>P[i]>>X[i];
    }
    for(int i=0;i<M;i++){
        int ans=0;
        for(int l=0;l<N;l++){
            if(l==P[i]-1){
                ans+=X[i];
            }
            else{
                ans+=T[l];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
from bisect import bisect_left, bisect_right
 
def main():
    N = int(input())
    L = [int(c) for c in input().split()]
    L = sorted(L)
    num = 0
    for ai in range(N):
        for bi in range(ai+1, N):
            if bi - ai == 1:
                continue
            a = L[ai]
            b = L[bi]
            ci_left = bisect_right(L, abs(L[ai] - L[bi]))
            ci_right = bisect_left(L, L[ai] + L[bi])
            if ci_left == ci_right:
                continue
            else:
                ci_left = max(ci_left, ai + 1)
                ci_right = min(ci_right, bi)
            # print(a, b, ci_left, min(ci_right, bi) - max(ci_left, ai) - 1)
            # num += min(ci_right, bi) - max(ci_left, ai) - 1
                num += ci_right - ci_left
            # print(a, b, ci_right, ci_left, num)
 
    print(num)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 46592
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
	using namespace std;

	int main() {

		int N;
		cin >> N;

		string S;
		cin >> S;

		int K;
		cin >> K;

		for (int i = 0;i < N;i++) {
			if (S[i] != S[K-1]) {
				S[i] = '*';
			}
		}

		cout << S << endl;

		return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using str = string;
template<typename T>
using vec = vector<T>;

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


struct edge {
    int l1;
    int l2;
};

struct node {
    vector<int> link;
};

int n, m, cnt;
vec<edge> ed;
vec<node> nod;

void f(vector<int> pass, int b) {
    pass.push_back(b);
    if (pass.size() == n) {
        cnt++;
        return;
    }
    for (int i : nod[pass.back()].link) {
        for (int j : pass) if (i == j) goto LOOP_END;
        f(pass, i);
    LOOP_END:
        continue;
    }
}

int main() {
    cin >> n >> m;
    nod.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        ed.emplace_back(edge{ a-1, b-1 });
        nod[a - 1].link.push_back(b - 1);
        nod[b - 1].link.push_back(a - 1);
    }
    cnt = 0;
    vector<int> v;
    f(v, 0);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
import sys
input = sys.stdin.readline

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        ans = 'No'
    elif C >= B:
        ans = 'Yes'
    else:
        g = gcd(B, D)
        lb, ub = -10**18, 10**18
        while ub - lb > 1:
            m = (lb + ub) // 2
            if A - g * m > C:
                lb = m
            else:
                ub = m
        if A - g * lb < B:
            ans = 'No'
        else:
            ans = 'Yes'
    print(ans)


Measured memory_bytes: 64876
H,W,K=map(int,input().split())
A = [list(input()) for i in range(H)]

N=1
for i in range(H):
  for j in range(W):
    if A[i][j]=='#':
      A[i][j]=N
      N+=1
      
for i in range(H):
  for j in range(W-1):
    if str(A[i][j]).isdigit() and A[i][j+1]=='.':
      A[i][j+1]=A[i][j]

for i in range(H):
  for j in range(0,W-1):
    if str(A[i][(W-j-1)]).isdigit() and A[i][(W-j-2)]=='.':
      A[i][W-j-2]=A[i][W-j-1]

for i in range(H-1):
  if A[i+1]==['.']*W:
    A[i+1]=A[i]

for i in range(H-1):
   if A[H-i-2]==['.']*W:
    A[H-i-2]=A[H-i-1]
    
for a in A:
  print(*a)

Measured memory_bytes: 7504
#include<bits/stdc++.h>
using namespace std;
#define maxx 3000
int n;
double p[maxx];
double dp[maxx][maxx];
double f(int n,int x)
{
    if(x==0)
        return 1.0;
    if(n==1)
    {
        return p[n];
    }
    if(dp[n][x]!=-1)
        return dp[n][x];
    if(n==x)
    {
        dp[n][x]=p[n]*f(n-1,x-1);
        return dp[n][x];
    }
    dp[n][x]= p[n]*f(n-1,x-1)+(1-p[n])*f(n-1,x);
    return dp[n][x];
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    for(int i=0;i<maxx;i++)
        for(int j=0;j<maxx;j++)
            dp[i][j]=-1;
    cout<<fixed<<setprecision(10)<<f(n,(n+1)/2);
}


Measured memory_bytes: 74328
#include <bits/stdc++.h>
#define MAX 1000
#define MAX_HALF 500
using namespace std;

struct P{
    int x;
    int y;
    int cnt;
    P(int x, int y, int cnt){
        this->x = x;
        this->y = y;
        this->cnt = cnt;
    }
};

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

int g[MAX][MAX];
bool used[MAX][MAX];

int t, n;


int main(void){
    while(cin >> t >> n, t | n){
        for(int i = 0; i < MAX; i++) for(int j = 0; j < MAX; j++){g[i][j] = 0; used[i][j] = false;}
        for(int i = 0; i < n; i++){
            int x, y; cin >> x >> y; x += MAX_HALF; y += MAX_HALF;
            g[y][x] = 1;
        }
        int x, y, cnt = 0;
        cin >> x >> y;
        x += MAX_HALF; y += MAX_HALF;

        int ans = 0;
        queue< P > que;
        que.push( P(x, y, 0) );

        while(!que.empty()){
            P q = que.front(); que.pop();
            x = q.x; y = q.y; cnt = q.cnt;
            if(cnt > t) break;
            ans++;

            used[y][x] = true;
            for(int d = 0; d < 6; d++){
                int nx = x + dx[d], ny = y + dy[d];
                if(used[ny][nx] == true || g[ny][nx] == 1) continue;
                used[ny][nx] = true;
                que.push(P(nx, ny, cnt+1));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

int g[100][100];
bool used[100][100];

int t, n;

int dfs(int x, int y, int turn){
    if(used[y][x] || g[y][x] == 1 || turn > t ) return 0;
    used[y][x] = true;

    int res = 0;
    for(int d = 0; d < 6; d++){
        int nx = x + dx[d], ny = y + dy[d];
        res += dfs(nx, ny, turn+1);
    }
    used[y][x] = false;
    return res + 1;
}

int main(void){
    while(cin >> t >> n, t | n){
        for(int i = 0; i < 100; i++) for(int j = 0; j < 100; j++){g[i][j] = 0; used[i][j] = false;}
        for(int i = 0; i < n; i++){
            int x, y; cin >> x >> y; x += 50; y += 50;
            g[y][x] = 1;
        }
        int x, y;
        cin >> x >> y;
        x += 50; y += 50;
        cout << dfs(x, y, 0) << endl;
    }
    return 0;
}
*/

Measured memory_bytes: 6104
class Sequence
  def initialize(start_num)
    @start_num = start_num
  end

  attr_accessor :start_num

  def num(idx)
    even_num = idx / 2
    odd_num = (idx - 1) / 2
    return @start_num * 2 ** even_num / (3 ** odd_num)
  end
end

while start_num = gets
  sum = 0.0
  seq = Sequence.new(start_num.to_f)
  (1..10).each do |n|
    sum += seq.num(n)
  end
  puts sum.round(7)
end

Measured memory_bytes: 8788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  
  for ( int i = 0; i < N; i++ ) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M; 
  vector<string> t(M);
  
  for ( int i = 0; i < M; i++ ) {
    cin >> t.at(i);
  }
  
  vector<int> money(N+M);
  
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      if ( s.at(i) == s.at(j) ) {
        money.at(i)++;
      }
    }
    
    for ( int j = 0; j < M; j++ ) {
      if ( s.at(i) == t.at(j) ) {
        money.at(i)--;
      }
    }
  }
  
  for ( int i = 0; i < M; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      if ( t.at(i) == s.at(j) ) {
        money.at(i+N)++;
      }
    }
    
    for ( int j = 0; j < M; j++ ) {
      if ( t.at(i) == t.at(j) ) {
        money.at(i+N)--;
      }
    }
  }
  
  int max = 0;
  for ( int i = 0; i < N + M; i++ ) {
    if ( money.at(i) > max ) {
      max = money.at(i);
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
const int MAX = 200010;

typedef int W;
typedef pair<int, int> Pii;
const W INF = 1LL << 25;

struct edge {
	int to;
	W cost;
};

typedef vector<vector<edge>> Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue<Pii, vector<Pii>, greater<Pii>> que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(Pii(0, s));
	while (!que.empty()) {
		Pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(Pii(d[e.to], e.to));
			}
		}
	}
}


map<Pii, vector<int>> m;

int P[MAX];
int Q[MAX];
int C[MAX];
int dist[MAX];
set<int> G[MAX];
map<int, set<int>> vc_map;
map<Pii, int> vn_map;

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

	int N, M;
	cin >> N >> M;

	set<Pii> vset;
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> Q[i] >> C[i];
		vset.insert(Pii(P[i], C[i]));
		vset.insert(Pii(Q[i], C[i]));
		vc_map[P[i]].insert(C[i]);
		vc_map[Q[i]].insert(C[i]);
	}
	for (int i = 1; i <= N; i++) {
		vset.insert(Pii(i, -1));
	}
	int cnt = 0;
	for (Pii p : vset) {
		vn_map[p] = cnt++;
	}

	Graph graph(cnt);
	for (int i = 0; i < M; i++) {
		int n1 = vn_map[Pii(P[i], C[i])], n2 = vn_map[Pii(Q[i], C[i])];
		graph[n1].push_back(edge{n2, 0});
		graph[n2].push_back(edge{n1, 0});
	}

	for (int i = 1; i <= N; i++) {
		for (int c : vc_map[i]) {
			if (c == -1) continue;
			int n1 = vn_map[Pii(i, -1)], n2 = vn_map[Pii(i, c)];
			graph[n1].push_back(edge{n2, 1});
			graph[n2].push_back(edge{n1, 0});
		}
	}

	int s = vn_map[Pii(1, -1)], g = vn_map[Pii(N, -1)];
	vector<W> d(cnt);
	dijkstra(s, graph, d);

	if (d[g] == INF) d[g] = -1;
	cout << d[g] << endl;
}


Measured memory_bytes: 127740
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cout<<fixed;
//    cout<<setprecision(10);

    set<int>st;
    int n;
    cin>>n;
    int x;
    for (int i=0;i<n;i++)
    {
        cin>>x;
        st.insert(x);
    }
    if (st.size()!=n)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;
 
public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
 
    public static void main(String[] args) {
        String S = in.next();
        int N = S.length();
 
        int l = 0, c = 0;
        int[] result = new int[N];
        for (int i = 1; i < N; i++) {
            if (S.charAt(i) == 'R' && S.charAt(i - 1) == 'L') {
                int L = c - l, R = i - c;
                System.err.println("l: " + l + ", c: " + c + "L: " + L + ", R: " + R);
 
                result[c - 1] += L / 2 + L % 2;
                result[c - 1] += R / 2;
                result[c] += L / 2;
                result[c] += R / 2 + R % 2;
 
                l = i;
            } else if (S.charAt(i) == 'L' && S.charAt(i - 1) == 'R') {
                c = i;
            }
        }
 
        int L = c - l, R = N - c;
        System.err.println("l: " + l + "c: " + c + "L: " + L + ", R: " + R);
 
        result[c - 1] += L / 2 + L % 2;
        result[c - 1] += R / 2;
        result[c] += L / 2;
        result[c] += R / 2 + R % 2;
 
        for (int i : result) {
            out.print(i);
            out.print(" ");
        }
    }
}

Measured memory_bytes: 46428
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <typeinfo>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;



int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        int data[20][20]={};

        rep(i,n){
            rep(j,n){
                cin>>data[i][j];
            }
        }
        
        rep(i,n){
            int sum=0;
            rep(j,n)sum+=data[i][j];
            data[i][n]=sum;
        }
        
        rep(j,n+1){
            int sum=0;
            rep(i,n)sum+=data[i][j];
            data[n][j]=sum;
        }
        rep(i,n+1){
            rep(j,n+1){
                printf("%5d",data[i][j]);
            }
            cout<<endl;
        }
    }
    return 0;
 }

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define res register ll
#define ll long long
using namespace std;
ll n,x,ans;
inline void dfs(res l,res s){
  if(l%s==0){
    ans+=(l<<1)-s;
    return;
  }
  ans+=l/s*s*2;
  dfs(s,l%s);
}
int main(){
  scanf("%lld %lld",&n,&x);
  ans=n;
  if(x>=n-x) dfs(x,n-x);
  else  dfs(n-x,x);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int n;
ll D[404][404];
ll p[404];

int main(){
    fio;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
        p[i] += p[i-1];
    }
    for(int L = 2; L <= n; L++){
        for(int s = 1; s + L - 1 <= n; s++){
            int e = s + L - 1;
            ll &d = D[s][e];
            d = LLONG_MAX;
            for(int m = s; m < e; m++){
                d = min(d, D[s][m] + D[m+1][e] + p[e] - p[s-1]);
            }
        }
    }
    cout << D[1][n] << '\n';
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  if(a>=b&&a>=c)a=a*pow(2,k);
  if(b>=a&&b>=c)b=b*pow(2,k);
  if(c>=b&&c>=a)c=c*pow(2,k);
  cout << a+b+c;
}


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


int n,w,a,b,value;
	long long int dp[101][100009];
	vector<long long int> wt(101,0);
	vector<long long int> val(101,0);
	// vector<int> ans(100009,-1);
	// set<int> raand;

int main()
{
	cin>>n>>w;
	for (int i=0;i<n;i++){
		cin>>a>>b;
		wt[i]=a;
		val[i]=b;
	}
	for(int i=0;i<=w;i++){
		for(int j=0;j<n;j++){
			dp[j][i]=0;
		}
	}
	for(int i=0;i<=w;i++){
		if(wt[0] <= i){
			dp[0][i] =val[0];
		}
	}
	for(int i=0;i<n;i++){
		dp[i][0]=0;
	}
	for(int j=1;j<n;j++)
	{
		for(int i=1;i<=w;i++){
			dp[j][i]= dp[j-1][i];
			if(i-wt[j]>=0){
				dp[j][i]=max(dp[j-1][i],dp[j-1][i-wt[j]]+val[j]);
			}
		}
	}
	// for(int i=0;i<=w;i++){
	// 	for(int j=0;j<n;j++){
	// 		cout<<j<<","<<i<<":"<<dp[j][i]<<endl;
	// 	}
	// }
	cout<<dp[n-1][w];
	
	// ans[0]=0;
	// cin>>n>>w;
	// for (int i=0;i<n;i++){
	// 	cin>>a>>b;
	// 	wt[i]=a;
	// 	val[i]=b;
	// }
	// for(int i=1;i<=w;i++){
	// 	for(int j=0;j<n;j++){
	// 		if(i-wt[j]>=0){
	// 			if(raand.count(j) == 0 && ans[i-wt[j]]>-1 && i-wt[j] != wt[j]){
	// 				raand.insert(j);
	// 				value=ans[i-wt[j]]+val[j];
	// 				if(value>ans[i]){
	// 					ans[i]=value;
	// 				}
	// 			}
	// 		}
	// 	}
	// 	raand.clear();
	// 	cout<<i<<":"<<ans[i]<<endl;
	// }
	// cout<<ans[w];
  
  
  //int n;
  //int b;
  //cin>>n;
  //vector<int> ar(n,0);
  //vector<int> a(n,0);
  //  for (int k = 0; k < n ; k++){
  //      cin>>b;
  //      ar[k]=b;
  //  }
  //int i;
  //a[0]=0;
  //a[1]=abs(ar[0]-ar[1]);
  //i=2;
  //	for (i; i < n; i++){
  //   if(abs(ar[i-1]-ar[i])+a[i-1]<abs(ar[i-2]-ar[i])+a[i-2]){
  //     a[i]=abs(ar[i-1]-ar[i])+a[i-1];
  //   }
  //    else{
  //      a[i]=abs(ar[i-2]-ar[i])+a[i-2];
  //    }
  //	}
  //    cout<<a[n-1];
}


Measured memory_bytes: 78336
<?php
$array = array();
//$arrayintarray[] = array();

while(true){
	$input = array();

	$stdin = trim(fgets(STDIN));
	(int)$input = explode(" ", $stdin);

	if($input[0] == 0 && $input[1] == 0) break;

	sort($input);

	$arrayintarray[] = $input;

}

$count = count($arrayintarray);

for($i = 0; $i < $count; $i++){

	$output = $arrayintarray[$i];

	if($i != $count - 1) echo("$output[0]".' '."$output[1]"."\n");
	else echo("$output[0]".' '."$output[1]");

}
//foreach ($arrayintarray as $value){
//echo("$value[0]".' '."$value[1]"."\n");
//print("$value[0]".' '."$value[1].");
//}
?>

Measured memory_bytes: 10420
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  string A,B,C;cin>>A>>B>>C;
  
  char a=A[0]-32;
  char b=B[0]-32;
  char c=C[0]-32;
  
  cout<<a<<b<<c<<endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

#define N 1000

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ N ] = { 0 };
    int p;
    int n, m;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      d[ i ] = i + 1;
    }
    p = n - 1;
    d[ p ] = 0;

    while ( d[ p ] != p )
    {
      for ( i = 0; i < m - 1; ++i )
      {
        p = d[ p ];
      }

      d[ p ] = d[ d[ p ] ];
    }

    printf ( "%d\n", p + 1 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<long long> dp(88, -1);
long long rec(int n) {
  if (dp[n] != -1) {
    return dp[n];
  }
  dp[n] = rec(n-1) + rec(n-2);
  return dp[n];
}

int main()
{
  dp[0] = 2;
  dp[1] = 1;

  int N;
  cin >> N;
  
  cout << rec(N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 1000006
ll dex[N], f[N];
ll C(int n, int m){
	return f[n]*power(f[n-m],mo-2)%mo*power(f[m],mo-2)%mo;
}
int main(){
	ll n=read();
	ll ans=1, p=1;
	dex[0]=f[0]=1;
	for (int i=1;i<=n;i++) dex[i]=dex[i-1]*8%mo, f[i]=f[i-1]*i%mo;
	ans=(power(10,n)-power(8,n))%mo;
	for (int i=1;i<=n;i++)
		ans=(ans-2ll*C(n,i)*dex[n-i])%mo;
	ans=(ans+mo)%mo;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19188
#include <iostream>
#include <string>

using namespace std;

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

		for (int i = 0; i < K; i++) {
				if (S[i] != '1') {
						cout << S[i] << endl;
						return 0;
				}
		}

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int k;
ll a[SZ];
int main()
{
	scanf("%d",&k);
	for(int i=1;i<=k;++i) scanf("%lld",a+i);
	if(a[k]!=2)
	{
		puts("-1");
		return 0;
	}
	pair<ll,ll> g(2,3);
	for(int i=k-1;i>=1;--i)
	{
		if(g.se/a[i]==(g.fi-1)/a[i])
		{
			puts("-1");
			return 0;
		}
		g.fi=((g.fi-1)/a[i]+1)*a[i];
		g.se=g.se/a[i]*a[i];
		g.se+=a[i]-1;
	}
	printf("%lld %lld\n",g.fi,g.se);
}


Measured memory_bytes: 1024