akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    vector<ll> z(26);
    for (int i = 0; i < 26; i++) {
        cin >> z[i];
    }
    vector<vector<ll>> x(d, vector<ll>(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> x[i][j];
        }
    }
    vector<ll> ans(d);
    for (int j = 0; j < d; j++) {
        ll mx = 0;
        ll atai = 0;
        for (int k = 0; k < 26; k++) {
            mx = max(x[j][k], mx);
            if (mx == x[j][k])atai = k;
        }
        ans[j] = atai + 1;
    }
    for (int i = 0; i < d; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n, t, a;
    cin >> n >> t >> a;
    a *= 1000;
    int ans;
    int diff = 1000000;
    for(int i = 1; i <= n; i++){
        int h;
        cin >> h;
        int tmp = 1000 * t - h * 6;
        if(diff > abs(a - tmp)){
            diff = abs(a - tmp);
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
int n, m;
vector<pair<int, p> > c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>n>>m ;
    for(int i=0;i<m;i++) {
        int a, b;
        cin>>a>>b;
        c.push_back(make_pair(b,make_pair(a,i)));
    }
    sort(c.begin(),c.end());
    int count[n+1];
    for(int i=1;i<n+1;i++){
        count[i]=1;
    }
    vector<p> ans(m);
    for(int i=0;i<m;i++){
        int pref=c[i].second.first;
        int number=count[pref];
        count[pref]++;
		ans[c[i].second.second].first=pref;
        ans[c[i].second.second].second=number;
    }
    for(int i=0;i<m;i++){
    printf("%06d%06d\n", ans[i].first,ans[i].second);
    }
}

Measured memory_bytes: 3956
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

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

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}



Measured memory_bytes: 20552
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    map<int, int> D;
    map<int, int> T;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        D[a]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        T[a]++;
    }
    for(auto x : T) {
        if (D[x.first] < x.second) {
            cout << "NO" << std::endl;
            return 0;
        }
    }
    cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ans = 0
flag = False
while sum(h) > 0:
    ans += 1
    flag = False
    for x in range(n):
        if h[x] > 0:
            h[x] -= 1
            flag = True
        elif flag is True:
            break
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

int get_greatest_common_divder(int x, int y) {
  int max_num = max(x, y);
  int min_num = min(x, y);
  int remainder = max_num % min_num;
  int res;

  if (remainder == 0) {
    return min_num;
  }

  for (int i = 1; i <= remainder; i++) {
    if (!(min_num % i) && !(remainder % i)) {
      res = i;
    }
  }

  return res;
}

int main() {
  int x, y;

  cin >> x >> y;

  cout << get_greatest_common_divder(x, y) << endl;

  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll n;
ld dp[300][300][300];
void f(ll i, ll j, ll k){
    if(i==0 && j==0 && k==0){
        dp[i][j][k]=0; return ;
    }
    if(i>0)
    if(dp[i-1][j][k]==-1) f(i-1,j,k);
    if(j>0)
    if(dp[i+1][j-1][k]==-1) f(i+1,j-1,k);
    if(k>0)
    if(dp[i][j+1][k-1]==-1) f(i,j+1,k-1);
    dp[i][j][k]=((ld)n/(i+j+k))*( (ld)1 + (i>0 ? ((ld)i/n)*dp[i-1][j][k]:(ld)0 ) + (j>0 ? ((ld)j/n)*dp[i+1][j-1][k]:(ld)0 )+ (k>0 ? ((ld)k/n)*dp[i][j+1][k-1]:(ld)0 ) );
}
int main() {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    cout << std::fixed;
    cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    int l1=0,l2=0,l3=0;
    for(int i=0;i<n;i++){

        int a; cin>>a;
        if(a==1) l1++;
        else if(a==2) l2++;
        else l3++;
    }
     for(int i=0;i<300;i++){
        for(int j=0;j<300;j++){
            for(int k=0;k<300;k++){
                dp[i][j][k]=-1;
            }
        }
    }
    f(l1,l2,l3);
    cout<<dp[l1][l2][l3];
}

Measured memory_bytes: 422272
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define mp(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define all(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
	ll a, b;
	
	cin >> a >> b;
	cout << a*b/__gcd(a, b);
}




Measured memory_bytes: 256
#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;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=1e18;
const ll maxs = 1e5;
const ll mod = 1e9+7;
const ll oo = (ll) 1e18;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n;
ll a[1003];
ll dp[500][500];
ll pre[1003];
ll solve(ll l,ll r)
{
    if(l==r)
        return 0;
    if(dp[l][r]!=-1)
        return dp[l][r];
    ll ans=oo;
    for(ll i=l;i<r;i++)
    {
        ll sum = pre[r];
        if(l!=0)sum -= pre[l-1];
        ll curr = sum + solve(l,i) + solve(i+1,r);
        ans = min(curr,ans);
    }
    return dp[l][r] = ans;
    
}


int main() 
{
    fastio();
	ll t=1;
    //cin>>t;
    while(t--)
	{
        cin>>n;
        for(ll i=0;i<n;i++)
        {   cin>>a[i];
            if(i>0)pre[i]=pre[i-1]+a[i];
            else pre[i]=a[i];
        }
        memset(dp,-1,sizeof dp);
        cout<<solve(0,n-1);
    }
	
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
typedef unsigned int uint;

inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}
#define H 200000
uint v[H] __attribute__((aligned(64)));
int main(void){
    const uint h = gl();
    gl();
    const uint n = gl();
    for(uint i=0; i<H; i++){ v[i] = 0x33333333; }
    for(uint i=0; i<n; i++){
        const uint x = gl()-1;
        const uint y = gl()-1;
        v[x] = y<v[x] ? y : v[x];
    }
    uint right = 0;
    for(uint x=1; x<h; x++){
        const auto b = v[x];
        const auto r = right+1;
        if(b<r){
            printf("%d\n", x);
            return 0;
        }else if(b>r){
            right=r;
        }
    }
    printf("%d\n", h);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
vector<bool> seen;


int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;

    Graph G(n);

    rep(i,n-1){
        G[i].push_back(i+1); G[i+1].push_back(i);
    }

    G[x].push_back(y); G[y].push_back(x);


    /*
    rep(i,n){
        seen.assign(n,false);
        dfs(G, i, 0);
    }
    */
    seen.assign(n,false);

    vector<ll> dist(n, -1);
    map<ll,ll> ans;


    rep(i,n){

        //vector<ll> dist(n, -1);
        dist.assign(n,-1);
        rep(j,n){
            if(dist[j] != -1){
                cout << "ng" << endl;
            }
        }
        queue<ll> que;
        dist[i] = 0;
        que.push(i);

        while(!que.empty()){
            ll now_pos = que.front();
            que.pop();

            for(ll next_node : G[now_pos]){
                //既に訪問済みなら何もしない
                if(dist[next_node] != -1){
                    continue;
                }
                //now_posから訪問できるノードをqueに追加
                dist[next_node] = dist[now_pos] + 1;
                ans[dist[next_node]]++;
                que.push(next_node);
            }

        }

    }

    /*
    rep(i,n){
        cout << "i = " << i << " "<< dist[i] << endl;
    }
    */







   ll count = 0;
    for(auto i: ans){
        count++;
        //cout << i.first << " " << i.second << endl;  //key
        cout << i.second / 2 << endl;
    }
    for(ll i = count; i < n-1; i++){
        cout << 0 << endl;
    }
    
}


Measured memory_bytes: 512
using System;

namespace ABC_160_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            if (S[2] == S[3] && S[4] == S[5]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
typedef long long int lli;

lli ncr(lli n)
{
    lli res=1,i,r=2;

    if(r>n-r)
        r = n-r;

    for(i=0;i<r;i++)
    {
        res = res*(n-i);
        res = res/(i+1);
    }

    return res;
}
int main()
{
    lli n,m,a,b;
    scanf("%lld %lld",&n,&m);

    if(n>1)
        a = ncr(n);
    else
        a = 0;

    if(m>1)
        b = ncr(m);
    else
        b = 0;

    printf("%lld",a+b);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>	
#include<unordered_set>
#define pb emplace_back
#define rt(v) return cout<<v,0
#define sz(v) (int)(v.size())
#define all(a) a.begin(),a.end()
#define endl '\n'
#define space " "
typedef long long ll;
typedef unsigned long long ull;
const int N = 10 + 1e5;
const int mod = 1e9 + 7;
/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Ferrari() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
char img[55][55];
char temp[55][55];
char ans[55][55];
int n, m;
bool check() {
	bool ok = 1;
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < m; ++j)
			if (ans[i][j] != temp[i][j])
			{
				ok = 0; break;
			}
	return ok;
}
int main() {
	Ferrari();
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> img[i][j];
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < m; ++j)
			cin >> temp[i][j];
	bool ok = 0;
	for (int i = 0; i <= n - m; ++i) {
		for (int a = i; a < i + m; ++a)
			for (int j = 0; j < m; ++j)
				ans[a][j] = img[a][j];
		if (check()) ok = 1;
		for (int c = m; c < n; ++c) {
			for (int a = 1; a < m; ++a)
				for (int j = 0; j < m; ++j)
					ans[j][a - 1] = ans[j][a];
			for (int a = 0; a < m; ++a)
				ans[a][m - 1] = img[i + a][c];
			if (check()) ok = 1;
		}
	}
	cout << (ok ? "Yes" : "No");
	return 0;
}





/* stuff you should look for
	* keepin sharp mind.
	* int overflow, array bounds.
	* special cases (n=1?), set tle , make sure you understand the proble correctly.
	* don`t stuck in a problem.
	* test the idea on samples.
	*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

long long modinv(long long a) {
    long long m = MOD;
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(){
  int s;
  cin >> s;
  if(s<=2){
    cout << 0 << endl;
    return 0;
  }

  int mods[s+1];
  int modi[s+1];
  mods[0] = 1;
  modi[0] = 1;
  LOOP1(i,s){
    mods[i] = mods[i-1]*i;
    modi[i] = modinv(mods[i]);
    mods[i]%=MOD;
    modi[i]%=MOD;
  }
  int ans = 0;
  int cnt = 0;
  ans += 1;
  s-=6;//ボールの数
  cnt++;//仕切りの数
  while(true){
    if(s<0)break;
    int t = mods[s+cnt] * modi[s];
    t%=MOD;
    ans += t * modi[cnt];
    // cerr << s << ":" << cnt << endl;
    ans%=MOD;
    s-=3;
    cnt++;
  }
  cout << ans<< endl;
}


Measured memory_bytes: 3636
def calc(a, b):
    m = min(a, b)
    l = max(a, b)
    while m != 0:
        s = m
        m = l % m
        l = s
    return l

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += calc(calc(i+1, j+1), k+1)

print(ans)

Measured memory_bytes: 75076
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    q=II()
    mx=10**5+5
    cnt=[0]*mx
    for a in aa:cnt[a]+=1
    s=sum(aa)
    for _ in range(q):
        b,c=MI()
        s+=(c-b)*cnt[b]
        cnt[c]+=cnt[b]
        cnt[b]=0
        print(s)

main()

Measured memory_bytes: 20336
import numpy as np
if __name__ == "__main__":
    N, Y = map(int, input().split())
    ans = [-1, -1, -1]
    for i in range(N+1):
        for j in range(N+1-i):
            k = N - i - j
            y = 10000 * i + 5000 * j + 1000 * k
            if y == Y:
                ans = [i, j, k]
    print("{} {} {}".format(ans[0], ans[1], ans[2]))

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

static class Program
{
    static void Main(string[] args)
    {
        //入力
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine().ToCharArray();

        var q = new Queue<char>();
        var list = new List<int>(){0};
        var x = 0;
        foreach(var c in S){
            q.Enqueue(c);
        }
        
        //処理
        for(var i = 0; i < N; i++){
            list.Add(q.Dequeue() == 'I' ? ++x : --x);
        }
        
        

        //出力
        Console.WriteLine(list.Max());
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[100005][13];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    dp[0][0] = 1;
    rep(i,0,SZ(s)){
        rep(j,0,13){
            if(s[i] != '?'){
                int c = chartoint(s[i]);
                dp[i+1][(j*10+c)%13] = (dp[i+1][(j*10+c)%13] + dp[i][j]) % MOD;
            }else{
                rep(k,0,10){
                    dp[i+1][(j*10+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j]) % MOD;
                }
            }
        }
    }

    cout << dp[SZ(s)][5] << endl;
    return 0;
}


Measured memory_bytes: 13868
Public Class Compiler
    Shared Sub Main()
        Dim input As String() = Console.ReadLine().Split(" ")
        Dim a As Integer = Integer.Parse(input(0))
        Dim b As Integer = Integer.Parse(input(1))
        Dim output As Integer = b - a
        If b Mod a = 0 Then output = a + b
        Console.WriteLine(output)
    End Sub
End Class

Measured memory_bytes: 11092
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M: print(0)
else:
    X.sort()
    L = [abs(X[i]-X[i-1]) for i in range(1,M)]
    L.sort(reverse=True)
    print(X[-1]-X[0]-sum(L[:N-1]))

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int n;
int col[201];
string b[201];
bool dfs(int current){
  bool flag = true;
  rep(i,n){
    if(b[current][i] == '1'){
      if(col[i] == 0) {
        col[i] = (col[current]==0)?1:0;
        flag &= dfs(i);
      }
      else if(col[i] == col[current]) return false;
      else continue;
    }
  }
  return flag;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n;

  rep(i,n) cin >> b[i];

  if (dfs(0) == false){
    cout << -1 << endl;
    return 0;
  }
  ll dist[n][n];
  rep(i,n) rep(j,n) {
    if(i == j ) dist[i][j] = 0;
    else if(b[i][j] == '1') dist[i][j] = 1;
    else dist[i][j] = INT_MAX;
  }

  rep(k,n) rep(i,n) rep(j,n)  {
    dist[i][j] = min(dist[i][k]+dist[k][j], dist[i][j]);
  }
  // rep(i,n){
  //   rep(j,n) cout << dist[i][j] << " ";
  //   cout << endl;
  // }
  ll ans = 0;
  rep(i,n){
    ll tmp = 0;
    rep(j,n){
      tmp = max(tmp,dist[i][j]);
    }
    ans = max(ans,tmp);
  }
  cout << ans + 1<< endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,last=0,k;
    ll ans=0;
    cin>>n;
    while (n--)
    {
        cin>>k;
        ans+=max(0,last-k);
        last=max(k,last);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll d,t,s;
    cin >> d >> t >> s;
    double t1 = d/(double)s;
    if(t>=t1)    cout<<"Yes\n";
    else         cout<<"No\n";
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3648
#include <iostream>


using namespace std;


int main() {

	int n;
	cin >> n;
	int prev = -1;
	int count=0;
	while(n){
		if(prev==n%10)
			count++;
		else{
			prev = n%10;
			count=1;
		}
		if(count==3){
			cout << "Yes";
			return 0;
		}
		n/=10;
	} 
	cout << "No";

}

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

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
vector<vector<int>> v(100011);
// bool visited[10001]={false};
int dp[100011];
int n, m;
int ans = 0;
int dfs(int id)
{
    if (v[id].size() == 0)
        return 0;
    if (dp[id] != -1)
        return dp[id];
    int t = -1;
    for (int i : v[id])
        t = max(t, dfs(i) + 1);
    ans = max(ans, t);
    return dp[id] = t;
}
void mysol()
{
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
    }
    for (int i = 1; i <= n; i++)
    {

        dfs(i);
    }
    cout << ans;
}

int32_t main()
{
    //fast();
    // w(t)
    {
        mysol();
    }
    return 0;
}


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

w = []
for i in range(n):
    word = input()
    if i==0:
        before = word
    else:
        if before[-1] != word[0]:
            print('No')
            exit()
        else:
            before = word
    w.append(word)

if len(set(w)) != len(w):
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  string a;
  cin>>a;
 if(a=="hi"||a=="hihi"||a=="hihihi"||a=="hihihihi"||a=="hihihihihi")
   cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 256
# from math import sqrt
from decimal import *

a, b, c = map(int, input().split())
# ra, rb, rc = sqrt(a), sqrt(b), sqrt(c)
ra, rb, rc = Decimal(a).sqrt(), Decimal(b).sqrt(), Decimal(c).sqrt()

if ra + rb < rc:
    print("Yes")
else:
    print("No")

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


int main() {
    long long n;
    cin>>n;
    string s;
    cin>>s;
    map<char, long long> cnt;
    for(int i=0; i<n; i++) cnt[s[i]]++;

    long long ans = cnt['R'] * cnt['G'] * cnt['B'];
    for(int i=0; i<n; ++i) {
        for(int j=i+1; 2*j-i<n; j++) {
            if(s[i] != s[j] && s[i] != s[2*j-i] && s[j] != s[2*j-i]) --ans;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,k;
  cin>>n>>k;
  vi a(n);
  REP(i,n)cin>>a[i];
  sort(ALL(a));
  reverse(ALL(a));
  cout<<accumulate(a.begin(),a.begin()+k,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.TreeMap;
/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		Map<Integer, Integer> students = new TreeMap<Integer, Integer>();
		for(int i=1;i<=N;i++){
			students.put(sc.nextInt(),i);
		}
		for (Integer nKey : students.keySet())
        {
            System.out.println(students.get(nKey));
        }
		sc.close();
	}
};

Measured memory_bytes: 71136
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<string>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
		sort(A.at(i).begin(), A.at(i).end());
	}
	sort(A.begin(), A.end());
	vector<long long>B(N, 0);
	for (long long i = 1; i < N; i++) {
		if (A.at(i - 1) == A.at(i)) B.at(i) = B.at(i - 1) + 1;
		else B.at(i) = 0;
	}
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		ans += B.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
/*
 * count.cpp
 *
 *  Created on: 2019/05/17
 *      Author: MEIP-users
 */

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <ctype.h>
#include <bits/stdc++.h>

using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(){

	int r,d,x;
	cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



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

    if (n == k)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;

}


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

int main() {
    int temp = 0;
    for (int i = 0; i < 3; i++) {
        temp += cin.get();
    }
    if (temp == (int)'a'+(int)'b'+(int)'c') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE Strict #-}
import qualified Data.Array.Unboxed as A


main :: IO ()
main = do
  [n, x, y] <- map read . words <$> getLine
  putStr . unlines . map show $ solve n x y

solve :: Int -> Int -> Int -> [Int]
solve n x y = A.elems xs
  where f i j = minimum [ j - i
                        , abs (x - i) + 1 + abs (y - j)
                        , abs (y - i) + 1 + abs (x - j)]
        xs = A.accumArray (+) 0 (1, n - 1) [(f i j, 1) | i <- [1 .. n - 1]
                                                     , j <- [i + 1 .. n]]
             :: A.UArray Int Int


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

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    int left[1001],right[1001];
    for(int i=0;i<=n;i++){
      left[i] = i-1;
      right[i] = i+1;
    }
    left[1] = n;
    right[n] = 1;
    int now = 0;
    int cou = n;
    while(cou != 0){
      for(int i=0;i<m;i++){
	now = right[now];
      }
      right[left[now]] = right[now];
      left[right[now]] = left[now];
      cou--;
    }
    cout << now << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;	cin>>N;
	if(N%1000!=0)	cout<<1000-N%1000<<endl;
	else cout<<"0"<<endl;


    return 0;
}




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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int n, y;

    cin >> n >> y;

    REP(i, n+1){
        REP(j, n+1-i){
            int k = n - (i + j);
            int sum = 10000*i + 5000*j + 1000*k;

            if (sum == y) {
                cout << i << " " << j << " " << k << endl;
                exit(0);
            }
        }
    }

    cout << -1 << " " << -1 << " "  << -1 << endl;
}

Measured memory_bytes: 256
import heapq


def dijkstra(n):
    inf = 10 ** 6 + 1
    dist = [0] + [inf] * (n - 1)
    q = [(0, 0)]
    while q:
        u = heapq.heappop(q)[1]
        for (v, c) in edge[u]:
            alt = dist[u] + c
            if dist[v] > alt:
                dist[v] = alt
                heapq.heappush(q, (alt, v))
    return dist

n = int(input())
edge = [[]] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edge[l[0]] = (e for e in zip(l[2::2], l[3::2]))
for i, c in enumerate(dijkstra(n)):
    print(i, c)

Measured memory_bytes: 42456
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    ll n;
    vector<ll> x; x.resize(5);
    vector<ll> mv; mv.resize(5);

    cin >> n;
    REP(i, 5){
        cin >> x[i];
    }
    mv[0] = x[0];
    REP(i, 4){
        mv[i+1] = min(mv[i], x[i+1]);
    }

    vector<ll> tau; tau.resize(5);
    tau[0] = 0;

    tau[0] = (n-1) / mv[0];
    ll last_mv = (n-1) % mv[0] + 1;
    REP(i, 4){
        ll state = mv[i] + (mv[i]-mv[i+1])*(tau[i]-i-1) + last_mv - mv[i+1];
        tau[i+1] = tau[i] + 1 + (state-1) / mv[i+1];
        last_mv = (state-1) % mv[i+1] + 1;
    }

    ll ans = tau[4] + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecint a(n);
  REPe(e, a) {
    cin >> e;
    e--;
  }
  int ans = 0;
  REP(i, n) {
    if (a[a[i]] == i) {
      ans++;
    }
  }
  cout << ans / 2 << endl;
}
////////////////////////////////////////////////


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
i64 hp;

//inputします
void input() {
	cin >> hp;
}

//ライブラリ置き場
i64 car(i64 hh) {
	i64 ans;
	if (hh == 1)ans = 1;
	else ans = 2 * car(hh / 2) + 1;
	return ans;
}

//main
int main() {
    input();
	cout << car(hp) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()

def fanc(n, a):
    if n == 1: 
        print(1)
        return 0
    cnt = 0
    while len(a) > 1:
        same_cnt = 0
        j = 1
        while a[0] == a[j]:
            same_cnt += 1
            if j == len(a) - 1:
                break
            j += 1
        if same_cnt  % 2 == 0:
            cnt += 1
        del a[0:same_cnt+1]
    if len(a) == 1: cnt += 1
    print(cnt)
    return 0

fanc(n, a)

Measured memory_bytes: 7512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	cin >> N;
	vector<double> A(N);
	double P = 0;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		double q = 1;
		P += q / A[i];
	}
	double r = 1;
	cout << setprecision(14) << r / P;

}

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

ll calc(vector<vector<ll>> &dp, vector<ll> &in, int start, int end){
    if(start > end){
        return 0;
    }
    if(dp[start][end] != -1){
        return dp[start][end];
    }
    if(start == end){
        return dp[start][end] = in[start];
    }
    return dp[start][end] = max(in[start] - calc(dp, in, start + 1, end), in[end] - calc(dp, in, start, end - 1));
}



int main(){
    ll n;
    cin>>n;
    vector <ll> in(n);
    for(auto &it : in){
        cin>>it;
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -1));
    cout<<calc(dp, in, 0, n - 1);
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;


int pow_mod(ll a, int b) {
	ll pow = 1;
	while (b > 0) {
		if (b & 1) pow = pow * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return pow;
}

ll inv_mod(ll n) {
	return pow_mod(n,MOD-2);
}

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

	vector<ll>  a(n);
	rep(i,n) cin >> a[i];

	sort(a.begin(),a.end());

	vector<int> comb(n,1); //comb[i] = i C (k-1)

	for (ll i = k-1; i < n-1; i++) {
	  comb[i+1] = comb[i]*(i+1) %MOD *inv_mod(i+1-k+1) % MOD;
	}

	ll ans = 0;

	for (int i = k - 1; i < n; i++) {
		ans += (a[i] * comb[i]) % MOD;
		ans %= MOD;
	}

	rep(i,n-k+1) {
	  ans -= a[i]*comb[n-i-1] % MOD;
		ans %= MOD;
	}

	cout << (ans+MOD)%MOD << endl;

}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N,A,B;
int main(){
	cin>>N>>A>>B;
	cout<<((B-A)%2 ? "Borys" : "Alice")<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var N int
var S []string

func main() {
	fmt.Scanf("%d", &N)

	S = make([]string, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S[i])
	}

	m := make(map[rune]int)
	for i := 0; i < N; i++ {
		c := []rune(S[i])[0]
		if c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H' {
			if _, ok := m[c]; ok {
				m[c]++
			} else {
				m[c] = 1
			}
		}
	}

	ans := 0
	march := []rune{'M', 'A', 'R', 'C', 'H'}
	for i := 0; i < len(march); i++ {
		for j := i + 1; j < len(march); j++ {
			for k := j + 1; k < len(march); k++ {
				ans += m[march[i]] * m[march[j]] * m[march[k]]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 4736
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  la = [int(input()) for _ in range(n)]
  cnt = 0
  for i in range(n):
    cnt += (la[i]//2)
    la[i] -= 2*(la[i]//2)
    if i < n-1:
      n_pair = min(la[i], la[i+1])
      cnt += n_pair
      la[i] -= n_pair
      la[i+1] -= n_pair
  print(cnt)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 7072
import statistics
n=int(input())
 
la, lb = [], []
for _ in range(n):
  a, b = map(int, input().split())
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print(d-c+1)
else:
  print(int(2*d-2*c+1))

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

int main() {
  int k, x;
	  cin >> k >> x;
	  for(int i = x - k + 1; i <= k + x - 1; i++) {
		  if(i != k + x - 1){
		 cout << i << " ";
		  }else {
			  cout << i;
		  }
	  }
  }
    

Measured memory_bytes: 256
#include<iostream> 
#include<vector> 
#include<cmath> 
using namespace std; 
#define lld long long int
#define X 1000000007
int arr[100001]={0}; 
int main()
{ios_base::sync_with_stdio(false); 
cin.tie(0); 
int n,x,y,i; 
cin>>n;
int h[n]; 
for( i=0; i<n;i++) 
 cin>>h[i]; 
 arr[1]=abs(h[0]-h[1]); 
 for(i=2;i<n;i++) 
 { x=abs(h[i]-h[i-1])+arr[i-1]; 
   y=abs(h[i]-h[i-2])+ arr[i-2]; 
   if(x<y) 
    arr[i]=x; 
   else 
     arr[i]=y; 
 } 
cout<<arr[n-1]<<endl; 
	return 0;
}

Measured memory_bytes: 1024