akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int M = 1e5+10;
map<int,int> mp;
int a[M];
int main(){
    int n;
    while(cin>>n){
        mp.clear();
        for(int i=0;i<n;++i) cin>>a[i],++mp[a[i]];
        int ans=0;
        for(int i=0;i<n;++i){
            ans=max(ans,mp[a[i]]+mp[a[i]+1]+mp[a[i]-1]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];		
		for(int i = 0;i<N;i++) {
			 a[i] = sc.nextInt();			
		}
		int sum = 0;
		for(int i = 0;i<N-1;i++) {
			for(int j = i+1;j<N;j++) {
				sum += a[i]*a[j];
			}
		}
		System.out.println(sum);
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#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__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    map<ll, ll> m;
    ll sum = 0, ans = 0;
    rep(i, n) {
        m[sum]++;
        sum += a[i];
        ans += m[sum];
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created by martin-d28jp-love on 15/04/01.
 */
public class Main {

    public static void main(String[] args) {
        int[] input = input();
//        int[] input = mockuop();

        int inputLength = input.length;
        int minValue = Integer.MAX_VALUE;
        int maxValue = -Integer.MAX_VALUE;
        int minIndex = 0;
        int maxIndex = 0;
        for (int i=0; i < inputLength; i++) {
            int Ri = input[i];
            if (Ri < minValue) {
                minValue = Ri;
                minIndex = i;
            }
            if (Ri > maxValue) {
                maxValue = Ri;
                maxIndex = i;
            }
        }
        if (minIndex < maxIndex) {
            System.out.println(maxValue - minValue);
            return;
        }

        int maxSubtruction = -Integer.MAX_VALUE;
        int maxSubtructionIndex = 0;
        int beforeSubtructionRi = Integer.MAX_VALUE;
        for (int i = 0; i < inputLength - 1; i++) {
            int Ri = input[i];
            if (beforeSubtructionRi < Ri) {
                continue;
            }
            int start = maxSubtructionIndex > i + 1 ? maxSubtructionIndex : i + 1;
            for (int j = start; j < inputLength; j++) {
                int Rj = input[j];
                if (Rj - Ri > maxSubtruction) {
                    maxSubtruction = Rj - Ri;
                    maxSubtructionIndex = j;
                    beforeSubtructionRi = Ri;
                }
            }
        }
        System.out.println(maxSubtruction);
    }

    public static int[] mockuop() {
        int input[] = {20,100,99,95,86,85,76,75,71,70,61,52,48,47,43,42,38,37,33,32,28};
        return input;
    }

    public static int[] input() {
        Scanner in = new Scanner(System.in);
        int size = Integer.valueOf(in.nextLine());

        int[] input = new int[size];
        int i = 0;
        while(in.hasNext()) {
            input[i++] = Integer.valueOf(in.nextLine());
        }
        in.close();
        return input;
    }
}

Measured memory_bytes: 165448
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, X, Y = NMI()
    counts = [0] * N
    for i in range(1, N):
        for j in range(i+1, N+1):
            dist = min(abs(j-i), abs(i-X) + 1 + abs(Y-j))
            counts[dist] += 1

    for d in counts[1:]:
        print(d)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3828
#include <iostream>

using namespace std;
typedef long long ll;

const ll MAXN = 1e5+10;

ll n, k;
ll A[MAXN];

ll gcd(ll x, ll y) {
  if (x < y) {
    swap(x, y);
  }
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

void solve() {
  ll d = A[0];
  for (int i=0;i<n;i++) {
    d = gcd(d, A[i]);
  }
  for (int i=0;i<n;i++) {
    if (k <= A[i] && (k - A[i]) % d == 0) {
      cout << "POSSIBLE" << endl;
      return;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

int main() {
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> A[i];
  }
  solve();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
void solve(){
    string a,b; 
    cin>>a>>b;
    map<string,int>mp;
    int x,y; 
    cin>>x>>y;
    mp[a] = x; 
    mp[b] = y;
    string c; 
    cin>>c; 
    mp[c]--;
    cout<<mp[a]<<" "<<mp[b]<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--)solve();
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    int min2 = 1000000000;
    int A;
    for (int i = 0; i < N; i++){
        cin >> A;
        int cnt = 0;
        while (A % 2 == 0) {
            A /= 2;
            cnt++;
        }
        min2 = min(min2, cnt);
    }
    cout << min2 << endl;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	REP(i, n) cin >> a[i];
	REP(i, m) cin >> b[i];
	bool res = false, ch;
	REP(p, n){
		REP(q, n){
			if(p+m > n || q+m > n) continue;
			ch = true;
			REP(r, m){
				//cout << a[p].substr(q, m) << " " <<  b[r] << endl;
				if(a[p+r].substr(q, m) != b[r]) ch = false;
			}
			//cout << endl;
			if(ch) res = true;
		}
	}
	if (res) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from itertools import combinations


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


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


def LS(): return list(sys.stdin.readline().rstrip().split())


a, b = LI()
print(a // b, a % b, '{:.5f}'.format(a / b))



Measured memory_bytes: 5644
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
int main() {
  int n;
  ll L;
  cin >> n >> L;
  vector<ll> la(n);
  for (ll &a: la) {
    cin >> a;
  }
  int id = -1;
  for (int i = 0; i < n-1; ++i) { 
    if (la[i]+la[i+1] >= L) {
      id = i+1;
      break;
    }
  }
  if (id == -1) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for (int i = 1; i < id; ++i) { 
    cout << i << endl;
  }
  for (int i = n-1; i > id; --i) { 
    cout << i << endl;
  }
  cout << id << endl;
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;   
//typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n;
vector<ll> a;

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

	cin>>n;
	a.resize(n);
	REP(i, n) cin>> a[i];

	sort(ALL(a));

	int one = -1, two = -1, ans=-1;

	FOR(i,1,n) {
		int idx = lower_bound(ALL(a), a[i]/2) - a.begin();
		//cout << idx << ' ' << one << ' ' << two << ' ' << ans << endl;
		if(idx != n) {
			int dif = min(a[i]-a[idx], a[i]-(a[i]-a[idx]));
			//cout << dif << endl;
			if (dif >= ans) {
				ans = dif;
				one = a[i], two = a[idx];
			}
		}
		if (idx != 0) {
			idx--;
			int dif = min(a[i]-a[idx], a[i]-(a[i]-a[idx]));
			//cout << dif << endl;
			if (dif >= ans) {
				ans = dif;
				one = a[i], two = a[idx];
			}
		}
	}
	cout << one << ' ' << two << endl;

    return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int k;
    scanf("%d", &k);
    string str;
    cin >> str;
    int len = (int) str.length();
    if(len > k){
        string ans = str.substr(0, k);
        ans += "...";
        cout << ans << endl;
    }
    else cout << str << endl;
}



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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll X, A;
    cin >> X >> A;

    if(X<A){
        p(0);
    }else{
        p(10);
    }

    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

#define PUTLINE cout<<__LINE__<<endl;

int p,q,r;

int formula(string str){
	if(str=="0")return 0;
	if(str=="1")return 1;
	if(str=="2")return 2;
	if(str=="P")return p;
	if(str=="Q")return q;
	if(str=="R")return r;
	if(str[0]=='-')return 2-formula(str.substr(1,str.size()-1));
	int i,k=0;
	for(i=0;i<str.size();++i){
		if(str[i]=='(')++k;
		if(str[i]==')')--k;
		if(k==1&&str[i]=='*')return min(formula(str.substr(1,i-1)),formula(str.substr(i+1,str.size()-i-2)));
		if(k==1&&str[i]=='+')return max(formula(str.substr(1,i-1)),formula(str.substr(i+1,str.size()-i-2)));
	}
	return 0;
}

int main() {
	string str;
	for(;;){
		cin>>str;
		if(str==".")break;
		int res=0;
		for(p=0;p<3;++p)for(q=0;q<3;++q)for(r=0;r<3;++r){
			if(formula(str)==2)++res;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+6;
void solve(){
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 52

int main(void)
{
	bool cards[4][13];
	int	n,rank;
	char stamp;

	for (int i = 0;i < 4;i++) {
		for (int j = 0;j < 13;j++) {
			cards[i][j] = false;
		}
	}

	do {
		cin >> n;
	} while (n < 0 || n > MAX);

	int i = 0;

	while (1) {

		cin >> stamp >> rank;

		switch (stamp) {
		case 'S':
			cards[0][rank - 1] = true;
			break;
		case 'H':
			cards[1][rank - 1] = true;
			break;
		case 'C':
			cards[2][rank - 1] = true;
			break;
		case 'D':
			cards[3][rank - 1] = true;
			break;
		default:
			break;
		}
		if (i++ == n - 1) break;
	}

	for (int j = 0;j < 4;j++) {
		for (int i = 0;i < 13;i++) {
			if (cards[j][i] == false) {
				switch (j) {
				case 0:
					printf("S ");
					break;
				case 1:
					printf("H ");
					break;
				case 2:
					printf("C ");
					break;
				case 3:
					printf("D ");
					break;
				default:
					break;
				}
				printf("%d\n", i + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define int long long
#define double long double

//main.cpp-Sample


namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
}


using namespace std;
signed main (){
	string s;
	cin >> s;
	for (int i = 0; i < 3; ++i)
	{
		if(s[i]==s[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}




Measured memory_bytes: 256
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;
#define int long long

vector<vector<pair<int,int>>>adj(100009);
#define INF INT_MAX
void dijkstra(int s, vector<int> & d, vector<int> & p) {
    int n = adj.size();

    d[s] = 0;
    set<pair<int, int>> q;
    q.insert({0, s});
    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase(q.begin());

        for (auto edge : adj[v]) {
            int to = edge.first;
            int len = edge.second;

            if (d[v] + len < d[to]) {
                q.erase({d[to], to});
                d[to] = d[v] + len;
                p[to] = v;
                q.insert({d[to], to});
            }
        }
    }
}
int32_t main() {
    fio
    int n,m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int x,y;
        cin >> x >> y;
        adj[x].pb({y,1});
        adj[y].pb({x,1});
    }
    vi d(n+1,INF);
    d[0] = -2;
    vi p(n+1,-1);
    dijkstra(1,d,p);
    vi path;

    for (int i = 0; i < n+1; ++i) {
        if(d[i]==INF){cout << "No" << endl; goto end;}
    }

        cout << "Yes" << endl;
        for (int i = 2; i <=n ; ++i) {
            for (int j = i; ;) {
                    cout << p[j] << endl;
                    break;
            }
        }
        end:;
    }








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

S = input().rstrip()
Q = int(input())
head = ''
tail = ''
rev = False

for _ in range(Q):
    query = list(input().split())
    if query[0] == '1':
        if rev:
            rev = False
        else:
            rev = True
    elif query[0] == '2':
        f = query[1]
        c = query[2].rstrip()
        if f == '1':
            if rev:
                tail = tail + c
            else:
                head = c + head
        else:
            if rev:
                head = c + head
            else:
                tail = tail + c
if rev:
    tmp = head + S + tail
    print(tmp[::-1])
else:
    print(head + S + tail)


Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

vector<ll> fac(200005);
vector<ll> ifac(200005);

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

ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<200003; i++){
        fac[i+1] = fac[i]*(i+1) % mod; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll res = 0;
    ll small = 0;
    for(int i=0; i<k-1; i++){
        small += i;
    }
    ll large = 0;
    for(int i=0; i<k-1; i++){
        large += n-i;
    }
    for(ll i=k; i<=n+1; i++){
        small += i-1;
        large += n-(i-1);
        ll gap = large-small+1;
        res += gap;
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6320
var lines =[];


var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){

  var n = Number(lines.shift());
  var x=Array(n);
  var u=Array(n);

  var result=0;

  for(var i=0;i<n;i++){
     x[i]=Number(lines[i].split(" ")[0]);
     u[i]=lines[i].split(" ")[1];  
    if(u[i]==="BTC"){x[i]=x[i]*380000;}

     result += x[i];

    }


console.log(result);

  
});

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int r,d,x1,sum=0;
  cin>>r>>d>>x1;
  for(int i = 1;i<=10;i++){
    sum=(r*x1)-d;
    cout<<sum<<endl;
    x1 = sum;
  }
} 

Measured memory_bytes: 3568
def main():
    N, L = map(int, input().split())
    apple = [i+L for i in range(N)]
    if L >= 0:
        apple = apple[1:]
        print(sum(apple))
    elif 0 in apple:
        print(sum(apple))
    else:
        apple = apple[:N-1]
        print(sum(apple))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;

ll a[200000];

int main() {
    ll n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum=sum^a[i];
    }
    for(int i=0;i<n;i++){
        printf("%lld",sum^a[i]);
        if(i==n-1) printf("\n");
        else printf(" ");
    }
}


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

const int N = 200005;
double ara[N];

int main( )
{
    int n, k, i, j, l;
    cin >> n >> k;
    for (i = 1; i <= n; i++) {
        cin >> j;
        ara[i] = ((j * (j + 1)) / 2) / (j * 1.0);
    }
    for (i = 2; i <= n; i++) {
        ara[i] += ara[i - 1];
    }
    double mx = 0;
    for (i = k; i <= n; i++) {
        mx = max(mx, ara[i] - ara[i - k]);
    }
    cout << setprecision(10) << mx << '\n';
    return 0;
}

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

int main() {
    string line;
    while (cin >> line) {
        int count = 0;
        for (int i = 0, n = line.size(); 2 * i <= n - 1; i++) {
            int j = n - 1 - i;
            if (i == j) {
                if (line[i] != 'i' && line[i] != 'w') {
                    count++;
                }
            } else {
                switch (line[i]) {
                case 'i':
                    if (line[j] != 'i') {
                        count++;
                    }
                    break;
                case 'w':
                    if (line[j] != 'w') {
                        count++;
                    }
                    break;
                case '(':
                    if (line[j] != ')') {
                        count++;
                    }
                    break;
                case ')':
                    if (line[j] != '(') {
                        count++;
                    }
                    break;
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
using namespace std;
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
int n, m;
vector<int> g[maxn];
int deg[maxn];

int dp[maxn];

void ReadInput()
{
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        ++deg[y];
    }
}

void Solve()
{
    queue<int> Q;
    for(int i = 1; i <= n; ++i)
        if(deg[i] == 0)
        {
            dp[i] = 0;
            Q.push(i);
        }
    while(!Q.empty())
    {
        int u = Q.front(); Q.pop();
        for(int v: g[u])
        {
            dp[v] = max(dp[v], dp[u] + 1);
            --deg[v];
            if(deg[v] == 0) Q.push(v);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, dp[i]);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 6528
import bisect
N=int(input())
A=[int(x) for x in input().split()]
A.sort()
At=A[-1]
i=bisect.bisect_left(A,At/2)
if i==0:
  As=A[i]
elif i==N-1:
  As=A[i-1]
else:
  As=A[i] if A[i]-At/2<At/2-A[i-1] else A[i-1]
print(At,As)

Measured memory_bytes: 14052
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2019
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N + 1);
    for(int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<int> frontier = {1};
    vector<int> costs(N + 1, INF);
    costs[1] = 0;
    vector<int> parents(N + 1, -1);
    while(!frontier.empty()) {
        vector<int> next_level;
        for(int u : frontier) {
            for(int v : graph[u]) {
                if(costs[v] > costs[u] + 1) {
                    costs[v] = costs[u] + 1;
                    next_level.push_back(v);
                    parents[v] = u;
                }
            }
        }
        swap(next_level, frontier);
    }
    // for(int i = 2; i <= N; ++i) cout << parents[i] << endl;
    if(any_of(parents.begin() + 2, parents.end(), [](int x) {return x == -1;})) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for(int i = 2; i <= N; ++i) {
            cout << parents[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 10948
N = int(input())
*D, = map(int, input().split())
D.sort()

ans = 0
for k in range(0, 13):
    Q = [-k, -k]
    ok = 1
    for d in D:
        if Q[0]+k <= d <= 24-Q[1]-k:
            Q[0] = d
        elif Q[1]+k <= d <= 24-Q[0]-k:
            Q[1] = d
        else:
            ok = 0
    if ok:
        ans = k
print(min(ans, min(D)))


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

int main(){
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++){
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll count=0;
    for(auto p:mp){
        if(p.second>=2) count+=p.second-1;
    }
    ll res=n-((count+1)/2)*2;
    cout << res << endl;
}


Measured memory_bytes: 9780
# include <stdio.h>
# include <string.h>
# include <math.h>
# include <stdlib.h>
# define INF 1000000000
# define MAXN 10000 
# define MAXM 100000
# define MAX(a,b) (a)>(b)?(a):(b)
# define MIN(a,b) (a)<(b)?(a):(b)
//int comp(const void * a, const void * b)

char s1[105], s2[105], vis[105][105]; 
int main ()
{
	int n, i, j, max=0, cnt;
	scanf("%d%s%s",&n,s1,s2);
	for (i=0; i<n; ++i) for (j=0; j<n; ++j) if (s1[i]==s2[j]) vis[j][i]=1;
	for (i=0; i<n; ++i) {
		if (vis[0][i]==1) {
			cnt=0;
			for (j=i; j<n; ++j) {
				if (vis[j-i][j]) cnt++;
				else break;
			}
			max=MAX(max,cnt);
		}
	}
	printf("%d\n",2*n-max);
	return 0;
}

Measured memory_bytes: 128
X = input()
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])
kai = 0
for i in range(2):
  if kai == 7 : break
  for j in range(2):
    if kai == 7 : break
    for k in range(2):
      if kai == 7 : break
      for h in range(2):
        kai = A + B * ((-1) ** j)  + C * ((-1) ** k) + D * ((-1) ** h)
        if kai == 7:
          if i == 1:
            i = "-"
          else:
            i = "+"
          if j == 1:
            j = "-"
          else:
            j = "+"
          if k == 1:
            k = "-"
          else:
            k = "+"
          if h == 1:
            h = "-"
          else:
            h = "+"
          ans = str(A) + j + str(B) + k + str(C) + h + str(D) +  "=7"
          break
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char c = S.charAt(0);
		Moji first = new Moji(c, null, null);
		Moji head = first;
		Moji tail = null;
		if (S.length() == 1) tail = first;
		for (int i = 1; i < S.length(); i++) {
			c = S.charAt(i);
			Moji moji = new Moji(c, first, null);
			first.back = moji;
			first = moji;
			if (i == S.length()-1) {
				tail = moji;
				//System.out.println("test");
			}
		}
		//System.out.println(tail.front);
		int Q = sc.nextInt();
		boolean front = true;

		for (int i = 0; i < Q; i++) {
			int T = sc.nextInt();
			if (T == 1) {
				if (front) front = false;
				else front = true;
			} else {
				int F = sc.nextInt();
				c = sc.next().charAt(0);
				Moji moji = new Moji(c, null, null);
				if ((F == 1 && front )||F == 2 && !front) {
					head.front = moji;
					moji.back = head;
					head = moji;
				} else {
					tail.back = moji;
					moji.front = tail;
					tail = moji;
				}
			}
		}
		if (front) {
			//System.out.println("h"+head.c);
			while (head != null) {
				System.out.print(head.c);
				head = head.back;
			}
		} else {
			//System.out.println("t"+tail.c);
			while (tail != null) {
				System.out.print(tail.c);
				tail = tail.front;
			}
		}
	}
	static class Moji {

		char c;
		Moji front;
		Moji back;

		public Moji(char c, Moji front, Moji back) {
			this.c = c;
			this.front = front;
			this.back = back;
		}
	}
}

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

int main() {
    string s; cin >> s;
    int tmp = 0;
    int ans = 0;
    for(int i=0; i<3; i++){
        if(s[i] == 'R'){
            tmp++;
            ans = max(ans,tmp);
        }else{
            tmp = 0;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long k;

    cin >> k;

    long long A;

    cin >> A;

    long long B;

    cin >> B;

    for(long long i=A; i<=B; i++) {

        if(i%k==0) {

            cout << "OK" << '\n';

            return 0;

        }

    }

    cout << "NG" << '\n';

    return 0;

}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans=0;
  if(b-a<x){
    if(a%x>b%x){
      COUT(1);
    }
    else if(b%x==0||a%x==0){
      COUT(1);
    }
    else COUT(0);
  }
  else{
    ll k=x-a%x;
    if(a%x==0) k=0;
    a+=k;
    ans=(b-a)/x;
    COUT(ans+1);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=400005;
queue<int > Q;
int a[N],b[N],vis[N],dis[N],n,X,Y,c[N],d[N],flag[N];
struct Tree{
	int ne[N],tot,sd[N],fi[N],zz[N],fa[20][N],out[N],l,in[N];
	void jb(int x,int y){
		ne[++tot]=fi[x];
		fi[x]=tot;
		zz[tot]=y;
	}
	void dfs(int x,int y,int z){
		fa[0][x]=y;sd[x]=z;in[x]=++l;
		for (int i=fi[x];i;i=ne[i])
			if (zz[i]!=y)dfs(zz[i],x,z+1);
		out[x]=++l;	
	}
	int pd(int x,int y){
		if (!x)return 1;
		return in[x]<=in[y]&&out[x]>=out[y];
	}
	int lca(int x,int y){
		if (x==y)return x;
		if (sd[x]<sd[y])swap(x,y);
		for (int i=19;i>=0;i--)
			if (!pd(fa[i][x],y))x=fa[i][x];
		return fa[0][x];
	}
	int dis(int x,int y){
		return sd[x]+sd[y]-2*sd[lca(x,y)];
	}
	void init(){
		for (int i=1;i<=19;i++)
			for (int j=1;j<=n;j++)fa[i][j]=fa[i-1][fa[i-1][j]];
	}
}G1,G2;
int main(){
	scanf("%d%d%d",&n,&X,&Y);
	for (int i=1;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		G1.jb(a[i],b[i]);G1.jb(b[i],a[i]);
	}
	for (int i=1;i<n;i++){
		scanf("%d%d",&c[i],&d[i]);
		G2.jb(c[i],d[i]);G2.jb(d[i],c[i]);
	}
	G1.dfs(1,0,0);G2.dfs(1,0,0);
	G1.init();G2.init();
	int ans=0;
	for (int i=1;i<n;i++)
		if (G2.dis(a[i],b[i])>=3)flag[a[i]]=flag[b[i]]=1;
	Q.push(X);vis[X]=1;
	while (!Q.empty()){
		int k=Q.front();Q.pop();
		for (int i=G1.fi[k];i;i=G1.ne[i])
			if (!vis[G1.zz[i]]){
				dis[G1.zz[i]]=dis[k]+1;
				if (dis[G1.zz[i]]<G2.dis(G1.zz[i],Y))Q.push(G1.zz[i]),vis[G1.zz[i]]=1;
			}
	}
	for (int i=1;i<=n;i++)
		if (vis[i]){
			if (flag[i])ans=1e9;
			else ans=max(ans,G2.dis(i,Y)*2);
		}
	if (ans==1e9)puts("-1");
	else printf("%d\n",ans);	
}

Measured memory_bytes: 98048
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

count = 0
for i in range(N-1):
    X_i = X[i]
    for j in range(i+1, N):
        X_j = X[j]
        dis_list = [(X_i[k] - X_j[k])**2 for k in range(D)]
        dis = sum(dis_list) ** 0.5
        if dis.is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 3e7 + 5;
const int MOD = 1e9 + 7;

int n,d;
int a[110][110];

void dis(int i)
{

}

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n >> d;
   int ans = 0;
   for(int i = 0 ; i < n ; i++)
    for(int j = 0; j < d; j++)
       cin >> a[i][j];
   for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
            int dis = 0;
          for(int k = 0; k < d; k++){
              dis += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
          }
            int dist = sqrt(dis);
            if(dist * dist == dis) ans++;
      }
   }
   cout << ans << endl;
   return 0;

}

Measured memory_bytes: 256
n,x=map(int,input().split())

a=[1]
p=[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if x==0:
        return 0
    elif x==1:
        if n==0:
            return 1
        else:
            return 0

    elif 1<x<=(1+a[n-1]):
        return f(n-1,x-1)

    elif x==2+a[n-1]:
        return p[n-1]+1

    elif (2+a[n-1])<=x<=2+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

    else:
        return 2*p[n-1]+1

print(f(n,x))

Measured memory_bytes: 3064
/*
    Problem 95
    https://atcoder.jp/contests/abc149/tasks/abc149_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    ll tmp = A;
    A = max(A - K, 0LL);
    K = max(K - tmp, 0LL);
    B = max(B - K, 0LL);
    cout << A << ' ' << B << '\n';
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define F first
#define S second
typedef pair<string,int> psi;
psi ar[105];
psi ar2[105];
bool f(psi a, psi b){
	if(a.F!=b.F) return a.F<b.F;
		return a.S>b.S;
}
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i].F>>ar[i].S;ar2[i]=ar[i];
	}
	sort(ar+1,ar+n+1,f);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(ar2[j]==ar[i]){
				cout<<j<<"\n";
				break;
			}
		}
	}
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
md = np.median(x)
x_c = copy.copy(x)
x_c.sort()
a = x_c[int(n/2 - 1)]
b = x_c[int(n/2)]
for i in range(n):
    if x[i] < md:
        print(b)
    else:
        print(a)


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

int main(){
    string s;
    cin >> s;
    bool flg = true;
    map<char, int> mp;
    for(int i=0; i<26; i++){
        mp['a'+i] = 0;
    }
    for(int i=0; i<s.length(); i++){
        mp[s.at(i)]++;
        if(mp[s.at(i)]>1){
            flg = false;
            break;
        }
    }
    if(flg)
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}

Measured memory_bytes: 3616
n=int(input())
A=tuple(map(int,input().split()))
cnt=0
def merge_sort(A,n):
    if n == 1:
        return A
    else:
        global cnt
        mid=(n+1)//2
        nl=len(A[:mid])
        nr=len(A[mid:])
        L=merge_sort(A[:mid],nl)
        R=merge_sort(A[mid:],nr)
        nli=0
        nri=0
        ans=[0]*(nl+nr)
        i=0
        while i < n:
            if nli == nl:
                ans[i]=R[nri]
                nri += 1
            elif nri == nr:
                ans[i]=L[nli]
                nli += 1
            elif L[nli] <= R[nri]:
                ans[i]=L[nli]
                nli += 1
            else:
                ans[i]=R[nri]
                nri += 1
                cnt += nl-nli
            i += 1
        return tuple(ans)
                



merge_sort(A,n)
print(cnt)



Measured memory_bytes: 27728
#include<iostream> 
using namespace std;
int main()
{
	int N;
	cin>>N;
	int n=0;
	int *a=new int [N];
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
	}
	while(1)
	{
	int sum=0;
		for(int i=0;i<N;i++)
		{
			if(a[i]%2==0)
			{
				sum++;
			}
		}
		//cout<<sum<<endl;
		if(sum==N)
		{
			n++;
			for(int i=0;i<N;i++)
			{
				a[i]/=2;
			}
		}
		else break;
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int,int);

int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",gcd(a,b));

  return 0;
}

int gcd(int x,int y)
{
  return y ? gcd(y,x%y):x;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int ac[200002], wa[200002], n, k;
int main(){
	cin >> n >> k;
	for (register int tle=1; tle<=n; tle++) cin >> ac[tle];
	for (register int tle=1; tle<=k; tle++){
		for (register int uke=1; uke<=n; uke++) wa[uke]=0;
		for (register int uke=1; uke<=n; uke++) wa[max(1, uke-ac[uke])]++, wa[min(n+1, uke+ac[uke]+1)]--;
		int mle=0, re=1;
		for (register int uke=1; uke<=n; uke++){
			ac[uke]=mle+=wa[uke];
			if (ac[uke]<n) re=0;
		}
		if (re) break;
	}
	for (register int tle=1; tle<=n; tle++) cout << ac[tle] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 5156
#include <stdio.h>

int main(void)
{
	unsigned n, m;
	unsigned q[2];
	unsigned node[100000] = { 0 };
	unsigned i;
	
	/* ----- Input & To_do ----- */
	scanf("%d %d", &n, &m);		//要素数, クエリ数入力
	for(i=0; i<m; i++){
		scanf("%d %d", &q[0], &q[1]);	//クエリ入力
		
		node[q[0]-1]++;		//クエリで指定されたノードのカウント
		node[q[1]-1]++;		//根付き木で考える→根からクエリのノードまでのパスでカウント
	}
	
	/* ----- output ----- */
	for(i=0; i<n; i++){		//それぞれのカウントがすべて偶数であること
		if(node[i]%2 == 1){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int ans[100],n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<100;i++)ans[i]=0;
	for(int i=0;i<m;i++){
		cin>>a>>b;a--,b--;
		ans[a]++,ans[b]++;
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ha,n,m,i,j,x,y,w,k,mx,ans,sz[100010],f[50001][16],a[101][101];
int main(){
	scanf("%d%d",&n,&m);
	memset(f,-1,sizeof(f));
	f[1][0]=0;
	for(i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&w);
		x--;y--;
		a[x][y]=a[y][x]=w;
		ans+=w;
	}
	mx=1<<n;
	for(i=0;i<mx;i++){
		for(j=0;j<n;j++)if(i&(1<<j))
		 for(k=j+1;k<n;k++)if(i&(1<<k))sz[i]+=a[j][k];
	}
	for(i=1;i<mx-1;i++)
	 for(j=0;j<n;j++)if(f[i][j]!=-1){
	 //	printf("%d %d %d\n",i,j,f[i][j]);
	 	for(k=0;k<n;k++)if((!(i&(1<<k)))&&a[j][k])f[i|1<<k][k]=max(f[i|1<<k][k],f[i][j]+a[j][k]);
	 	for(k=(mx-1)^i;k;k=(k-1)&((mx-1)^i))if(!(k&(1<<n-1)))f[i|k][j]=max(f[i|k][j],f[i][j]+sz[k|1<<j]);
	 }
	//printf("%d\n",mx);
	for(i=1;i<mx;i++){
	  ha=max(ha,f[i][n-1]);
	  //printf("%d %d %d\n",i,n-1,f[i][n-1]);
}
	printf("%d",ans-ha);
}
/*
一道挺好想的dp，
最后的路径一定是一条从s到t的链和在链上的点向外挂出去的一些联通分量。
那么就可以dp表示到了i与s联通的集合为j 
*/

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}
ll nCr(ll n, ll r){
  ll m1=1,m2=1; r=min(r,n-r);
  for(int i=0; i<r; i++){
    m1=(m1*(n-i))%MOD; m2=(m2*(r-i))%MOD;
  }
  return (m1*modpow(m2,MOD-2))%MOD;
}

void solve(){
  int n; cin >>n;
  ll ans=0;
  for(int i=1; i<=n/3; i++) ans=(ans+nCr(n-2*i-1,i-1))%MOD;
  cout <<ans;
}

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

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

int main() {
  int a, b; cin >> a >> b;
  string x, y;

  for(int i = 0; i < a; i++) x.push_back(b + '0');
  for(int i = 0; i < b; i++) y.push_back(a + '0');

  cout << min(x, y) << endl;
}



Measured memory_bytes: 256
def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())
 
    used = [True]*(h*w)
 
    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False
 
 
    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 51584
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string s; cin >> s;
	int g = 0, p = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'p') p++;
	}
	cout << s.size() / 2 - p << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,a,b,c,d;
int main(){
  cin>>a>>b>>c;
  long long m=max(a,max(b,c));
  m*=3;
  d=a+b+c;
  if(m%2==d%2)cout<<(m-d)/2;
  else cout<<(m-d+3)/2;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<ll> cnt(7);
    for(int i=0; i<7; i++){
        cin >> cnt[i];
    }
    ll ans = 0;
    ans += cnt[1];
    string str = "034";
    if(cnt[0] && cnt[3] && cnt[4]){
        int odd = 0;
        for(int i=0; i<3; i++){
            odd += cnt[str[i]-'0']%2;
        }
        if(odd >= 2){
            ans += 3;
            for(int i=0; i<3; i++){
                if(cnt[str[i]-'0']%2==0){
                    cnt[str[i]-'0']--;
                }
                ans += cnt[str[i]-'0']/2 * 2;
            }
        }else{
            for(int i=0; i<3; i++){
                ans += cnt[str[i]-'0']/2 * 2;
            }
        }
    }else{
        for(int i=0; i<3; i++){
            ans += cnt[str[i]-'0']/2 * 2;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int n;
ll w,weight[110],value[110];
ll dp[110][100100]={0};
int main(){
  cin>>n>>w;
  for(int i=0;i<n;++i)cin>>weight[i]>>value[i];

 for(int i=0;i<n;++i){
    for(int sum_w=0;sum_w<=w;++sum_w){
      if(sum_w-weight[i]>=0){
        chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout<<dp[n][w];
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

vi a(5);
rep(i,5) cin >> a[i];
rep(i,5) {
    if(a[i] == 0) {
        cout << i+1 << endl;
    }
}

return 0;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AWeLoveGolf {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int K, A, B;
        cin >> K >> A >> B;

        int k = 1;
        while (K * k <= B) {
            if (K * k >= A) {
                cout << "OK" << endl;
                return;
            }
            k++;
        }
        cout << "NG" << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AWeLoveGolf solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3640