akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long f[101][100001],w[100001],v[100001];
int main()
{
	long long n,m,j,i;
	scanf("%lld %lld",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%lld %lld",&w[i],&v[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=w[i])
			{
				f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%lld",f[n][m]);
}

Measured memory_bytes: 78720
import java.util.*; 

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        
        int[] a = new int[q];
        int[] b = new int[q];
        int[] c = new int[q];
        int[] d = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        
        // array: m個のボールとn個の仕切りを考える
        // (m, n) = (6, 4) => [0,0,0,0,0,0,1,1,1,1]
        int[] array = new int[m + n];
        for (int i = m; i < m + n; i++) {
            array[i] = 1;
        }
        
        // ボールと仕切りの配置を全探索する
        int ans = 0;
        do {
            // array2[i]: i個目の仕切りより左にあるボールの数
            // 0010100011 -> [2, 3, 6, 6]
            // = 0以上m以下の広義単調増加数列
            int[] array2 = new int[n];
            int ball = 0;
            int now = 0;
            for (int i = 0; i < m + n; i++) {
                if (array[i] == 1) {
                    array2[now] = ball;
                    now++;
                } else {
                    ball++;
                }
            }
            // System.out.println(Arrays.toString(array2));
            
            // 初項が1以上でない数列は無視
            if (array2[0] == 0) continue;
            
            int score = 0;
            for (int i = 0; i < q; i++) {
                if (array2[b[i]] - array2[a[i]] == c[i]) score += d[i];
            }
            ans = Math.max(ans, score);
            
        } while (nextPermutation(array));
        
        System.out.println(ans);
    }
    
    public static boolean nextPermutation(int[] array) {
        for (int i = array.length - 1; i > 0; i--) {
            if (array[i - 1] < array[i]) {
                int j = find(array, array[i - 1], i, array.length - 1);
                int temp = array[j];
                array[j] = array[i - 1];
                array[i - 1] = temp;
                Arrays.sort(array, i, array.length);
                return true;
            }
        }
        return false;
    }
	 
    private static int find(int[] array, int dest, int f, int l) {
        if (f == l) return f;
        
        int m = (f + l + 1) / 2;
        return (array[m] <= dest) ? find(array, dest, f, m - 1) : find(array, dest, m, l);
    }
}

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

using namespace std;


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int one = 0, two = 0, three = 0;
    for(int i = 0; i < n; i++) {
        if(p[i] <= a) {
            one++;
        }
        else if(b + 1 <= p[i]) {
            three++;
        }
        else {
            two++;
        }
    }
    cout << min({one, two, three}) << "\n";
    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k <= a){
        cout << k << endl;
    }else if(k <= a + b){
        cout << a << endl;
    }else{
        k -= (a + b);
        cout << a - k << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a == 0) {
		cout << 1 << endl;
	}
	else if (b == 0) {
		cout << 2 << endl;
	}
	else if (c == 0) {
		cout << 3 << endl;
	}
	else if (d == 0) {
		cout << 4 << endl;
	}
	else if (e == 0) {
		cout << 5 << endl;
	}

	return 0;
}

Measured memory_bytes: 3560
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B.insert(0,0)
C = list(map(int,input().split()))
C.insert(0,0)
cnt = 0
for i in range(N-1):
    cnt += B[A[i]]
    if A[i+1] == A[i]+1:
        cnt += C[A[i]]
cnt += B[A[N-1]]
print(cnt)

Measured memory_bytes: 3064
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
int val[maxn];
void solve()
{
	sa(n);
	int ans=0;
	repp(i,1,n)
	{
		sa(val[i]);
		ans+=val[i];
	}
	int maxx=0;
	if(ans%10)
	{
		printf("%d\n", ans);
		return;
	}
	repp(i,1,n)
	{
		int sum=ans-val[i];
		if(sum%10)maxx=max(maxx,sum);
	}
	printf("%d\n", maxx);
}

int main()
{
	solve();
	//system("pause");
	return 0;
}







Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    F0R(i, 3) {
        if (S[i] == '7') {
            cout << "Yes" << nl;
            return 0;
        }
    } 
    cout << "No" << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3644
#include<stdio.h>

int main(void){

 int a,b;

 scanf("%d %d",&a,&b);

 if(a<b){

  printf("a < b\n");

 }

  else if(a>b){

   printf("a > b\n");

  }

   else printf("a == b\n");

 return 0;

}

Measured memory_bytes: 580
from collections import defaultdict, deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    parents = [-1]*N
    G = defaultdict(list)
    for _ in range(M):
        a, b = read_ints()
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    Q = deque([(0, 0)])
    count = 0
    while len(Q) != 0:
        node, parent = Q.popleft()
        for child in G[node]:
            if child != parent and parents[child] == -1:
                parents[child] = node
                count += 1
                Q.append((child, node))
    if count == N-1:
        print('Yes')
        for p in parents[1:]:
            print(p+1)
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42292
#!/usr/bin/env python3

import array


def main():
    n, m = map(int, input().split())
    deg = array.array("l", (0 for _ in range(n)))
    can_have_red = array.array("B", (False for _ in range(n)))
    can_have_red[0] = True
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        deg[x] -= 1
        deg[y] += 1
        if can_have_red[x]:
            can_have_red[y] = True
        if deg[x] < 0:
            can_have_red[x] = False
    print(sum(can_have_red))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4004
from functools import reduce
import operator
def solve():
    L = 4; M = 5
    MP = [list(map(int, input().split())) for i in range(L)]
    memo = {(0,)*(L**2): 0}
    dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
    INF = 10
    def dfs(k, R):
        key = reduce(operator.add, map(tuple, R))
        if key in memo:
            return memo[key]
        if k == 0:
            return INF
        r = INF
        for i in range(L):
            for j in range(L):
                v = R[i][j]
                R0 = [e[:] for e in R]
                if R0[i][j] < 4:
                    R0[i][j] += 1
                    r = min(r, dfs(k-1, R0) + 1)
                    continue
                R0[i][j] = 0
                S = [(j, i, a) for a in range(4)]
                cnt = 1
                while S:
                    T = []
                    for x, y, d in S:
                        dx, dy = dd[d]
                        nx = x + dx; ny = y + dy
                        if not 0 <= nx < L or not 0 <= ny < L:
                            continue
                        if R0[ny][nx]:
                            R0[ny][nx] += 1
                        else:
                            T.append((nx, ny, d))
                    for y in range(L):
                        for x in range(L):
                            if R0[y][x] >= 5:
                                R0[y][x] = 0
                                cnt += 1
                                T.extend((x, y, a) for a in range(4))
                    S = T
                r = min(r, dfs(k-1, R0) + 1)
        memo[key] = r
        return r
    res = dfs(5, MP)
    print(res if res < INF else -1)
solve()


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

int main(){
    int a,b,max;
    scanf("%d %d",&a,&b);
    max = a+b;
    if((a-b) > max)
        max = a-b;
    if((a*b) > max)
        max = a*b;
    printf("%d",max); 
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

ans = set()
for i in range(N):
    ans.add(i+1)

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        if a in ans:
            ans.remove(a)

print(len(ans))

Measured memory_bytes: 67692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> dfs(int i, vector<vector<int>> &G){
    auto n = G.size();
    vector<int> dist(n);
    stack<pair<int, int>> s;
    int cnt = 0;
    vector<int> visited(n, 0);
    s.emplace(i, 0);
    while(!s.empty()){
        int a, d; tie(a, d) = s.top(); s.pop();
        visited[a]++;
        dist[a] = d;
        for (auto &&j : G[a]) {
            if(!visited[j]) s.emplace(j, d+1);
        }
    }
    return dist;
}


int main() {
    int Dmax = 0;
    int n;
    cin >> n;
    vector<vector<int>> A(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        A[a-1].emplace_back(b-1);
        A[b-1].emplace_back(a-1);
    }
    vector<int> da = dfs(0, A);
    int p = static_cast<int>(max_element(da.begin(), da.end()) - da.begin());
    vector<int> dc = dfs(p, A);
    int q = static_cast<int>(max_element(dc.begin(), dc.end()) - dc.begin());
    da = dfs(q, A);
    for (int i = 0; i < n; ++i) {
        da[i] = max(da[i], dc[i]);
        Dmax = max(Dmax, da[i]);
    }
    cout << (Dmax%3 == 1 ? "Second" : "First") << "\n";
    return 0;
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

using namespace std;

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

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

    constexpr int D_MAX = 10;

    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    REP(_, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int Q;
    cin >> Q;
    vector<int> v(Q), d(Q), c(Q);
    REP(i, Q) {
        cin >> v[i] >> d[i] >> c[i];
        --v[i];
    }

    auto used = vec2_init<bool>(N, D_MAX + 1);
    vector<int> color(N);

    function<void(int, int, int)> f = [&](int u, int d, int c) {
        if (color[u] == 0) {
            color[u] = c;
        }
        if (d > 0) {
            if (!used[u][d - 1]) {
                used[u][d - 1] = true;
                f(u, d - 1, c);
            }
            for (int v : g[u]) {
                if (!used[v][d - 1]) {
                    used[v][d - 1] = true;
                    f(v, d - 1, c);
                }
            }
        }
    };

    RREP(i, Q) {
        f(v[i], d[i], c[i]);
    }

    REP(i, N) {
        cout << color[i] << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 17764
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * (n+1)
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  ans=sum-d[a[i]]+1
  print(ans)


Measured memory_bytes: 34172
/* #pragma GCC optimize("O3") */
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

vector<int> h;
int dp[100001];

int solve(int n, int k){
    if(n==1) return 0;
    if(n==2) return abs(h[1]-h[0]);
    if(dp[n] != -1) return dp[n];
    dp[n] = INT_MAX;
    for(int i=1; i<=k; i++){
        if(n-i>=1) dp[n] = min(dp[n], abs(h[n-1]-h[n-i-1])+solve(n-i, k));
    }
    return dp[n];
}

/* int solve(int n, int k){ */
/*     dp[1] = 0; */
/*     dp[2] = abs(h[1]-h[0]); */
/*     for(int i=3; i<=n; i++){ */
/*         dp[i] = abs(h[i-1]-h[i-2])+dp[i-1]; */
/*         for(int j=2; j<=k; j++){ */
/*             if(i-j >= 1) dp[i] = min(dp[i], abs(h[i-1]-h[i-j-1]) + dp[i-j]); */
/*         } */
/*     } */
/*     return dp[n]; */
/* } */


inline void test_case(){
    memset(dp, -1, sizeof dp);
    int n,k;
    cin>>n>>k;
    h.resize(n);
    for(int& i : h) cin>>i;
    cout<<solve(n, k)<<"\n";
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    tt = 1;
    for(int qq=1; qq<=tt; qq++){
        /* cout<<"Case #"<<qq<<": "; */
        test_case();
    }
}   



Measured memory_bytes: 7296
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii; 
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n;
ll a[101];
int main (){
    cin >> n;
    ld ans = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i], ans += (1.0 / a[i]);
    ans = 1.0 / ans;
    cout << fixed << setprecision(11) << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int store[50];
	int pos;
	int move;

	int cnum;
	int snum;

	int stop = 0;
	for (;;) {
		cin >> cnum >> snum;

		if ( cnum == 0 ) break;

		pos = 0;
		move = snum;
		for ( int i=0; i<cnum; i++ ) {
			store[i] =0;
		}

		for ( int i=0;;i++) {
			if ( move > 0 ) {
				for ( int j=0; j<cnum; j++ ) {
				store[(i+j)%cnum]+=move/cnum;
				}
				for ( int j=0; j<(move%cnum);j++) {
					store[(i+j)%cnum]++;
				}
				i+=move-1;
				move = 0;
			}
			else {
				if ( store[i%cnum] == snum ) {
					pos = i % cnum;
					break;
				} else {
					move = store[i%cnum];
					store[i%cnum] = 0;
				}
			}
		}
		cout << pos << endl;
	}
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<tuple<string, int, int>> sp(N);
    rep(i, N)
    {
        string s;
        int p;
        cin >> s >> p;
        p *= -1;
        get<0>(sp[i]) = s;
        get<1>(sp[i]) = p;
        get<2>(sp[i]) = i + 1;
    }
    sort(sp.begin(), sp.end());
    for (auto s : sp)
    {
        cout << get<2>(s) << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 100008

signed main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n, k, sum=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    sort(a, a+n);
    for(int i=0;i<n-k;i++){
    	sum+=a[i];
    }
    cout<<sum<<endl;
}

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

int gcd(int a, int b){
	while(b){
		int tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

int main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	if(*max_element(a, a + n) < k){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	int g = a[0];
	for(int i = 0; i < n; i++) g = gcd(g, a[i]);
	cout << (k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void){
    int n,sum=0;
    cin>>n;
    vector<int> a;
    a.push_back(0);
    rep(i,1,n+1){
        int in;
        cin>>in;
        a.push_back(in);
        sum+=abs(a[i]-a[i-1]);
    }
    a.push_back(0);
    sum+=abs(a[n+1]-a[n]);
    //cout<<sum<<endl;
    rep(i,1,n+1){
        int ans=sum-(abs(a[i]-a[i+1])+abs(a[i]-a[i-1]))+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
    return 0;

}

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

int main(){
	int n, a, b, c;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a >> b >> c;
		if( b > a ) swap( a, b );
		if( c > b ) {
			swap( b, c );
			if( b > a ) swap( a, b );
		}
		cout << (( a * a == b * b + c * c ) ? "YES\n" : "NO\n");
	}	
	return 0;
}

Measured memory_bytes: 1120
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

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

const ll linf = 1LL << 60;

int n;
Vl a;
ll tot = 0;

int main()
{
	cin >> n;
	a.resize(n);
	REP(i, n) {
		cin >> a[i];
		tot += a[i];
	}

	int i = 0;
	ll left = 0;
	ll ans = linf;

	do {
		left += a[i++];
		ll right = tot - left;

		ll cost = abs(left - right);
		chmin(ans, cost);
	} while (i < n - 1);

	cout << ans << endl;
}


Measured memory_bytes: 1792
from operator import itemgetter
N=int(input())
A=list(map(int,input().split()))

differences=[]
for index, item in enumerate(A):
    differences.append(item-(index+1))
differences.sort()

if len(differences)%2==1:
    b=differences[int(len(differences)/2)-1+1]
else:
    b=differences[int(len(differences)/2)-1]

answer=0
for index,item in enumerate(differences):
    answer+=abs(item-b)
print(answer)


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll s, c; cin >> s >> c;
  ll ans = min(s, c / 2);
  s -= ans;
  c -= ans * 2;
  ans += c / 4;
  fin(ans);
}

//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll x, y;
  cin >> x >> y;
  ll cnt = 1;
  while (x * 2 <= y) {
    cnt++;
    x *= 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
/* *********************************
Author        :clogos
Created Time  :2016/10/29 20:24:43
File Name     :A.cpp
********************************** */

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);
using namespace std;
const int N = 100 + 10;
char s[N], t[N];
int n;

bool cheak(int x) {
	for(int i = 0; i < x; ++i) if(s[n-x+i] != t[i]) return false;
	return true;
}

int main()
{
	scanf("%d%s%s", &n, s, t);	
	int ans = 2 * n;
	for(int i = 1; i <= n; ++i) {
		if(cheak(i)) ans = 2 * n - i;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = (ll)1 << 60;
vector<ll> num;
vector<ll> p;

ll ans(ll n, ll x) {
    if (n==0) {
        if(x>0) return 1;
        else return 0;
    } else if (x <= num[n-1]+1) {
        return ans(n-1, x-1);
    } else {
        return p[n-1] + 1 + ans(n-1, x-2-num[n-1]);
    }
}

int main() {
    ll N, X;
    cin >> N >> X;
    num.resize(N+1);
    p.resize(N+1);
    num[0]=1;
    p[0]=1;
    rep(i, N) {
        num[i+1] = 2*num[i] + 3;
        p[i+1] = 2*p[i] + 1;
    }
    cout << ans(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<string>
#include<sstream>
using namespace std;
int data[12][12];
vector<string> s(12);
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, -1, 0, 1 };

void dfs(int x, int y) {
	s[y][x] = '0';
	for (int i = 0; i < 4; ++i) {
		int px = x + dx[i];
		int py = y + dy[i];
		if (px < 0 || px >= 12 || py < 0 || py >= 12)
			continue;
		if (s[py][px] == '0')
			continue;
		dfs(px, py);
	}
}

int main() {
	while (1) {
		int ans=0;

		for (int i = 0; i < 12; ++i) {
			cin>>s[i];
			if(cin.eof())return 0;
		}
		for (int i = 0; i < 12; ++i) {
			for (int j = 0; j < 12; ++j) {
				if (s[i][j] == '0')
					continue;
				dfs(j, i);
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

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

namespace Dwango_Thumbnail
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' ');
			List<double> alist = new List<double>();

			for (int i = 0; i < n; i++) {
				alist.Add(int.Parse(input[i]));
			}

			double aAvg = alist.Average();
			int resultIndex = 0;
			double minAbs = Math.Abs(aAvg - alist[0]);
			for (int i = 0; i < n; i++)
			{
				double abs = Math.Abs(aAvg - alist[i]);
				if (abs == 0)
				{
					resultIndex = i;
					break;
				}else if (minAbs > abs)
				{
					minAbs = abs;
					resultIndex = i;
				}
			}
			
			Console.WriteLine(resultIndex);
		}
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <string.h>

int main(int argc,const char *argv[]){
    int a,b,keta,c,i;
    while(scanf("%d %d",&a,&b)!=EOF){
        keta=0;
        a=a+b;
        for(i=0;i<=1000000;i=i*10){
            a=a/10;
            if(a==0){
                keta++;
                break;
            }
            keta++;
            }
        printf("%d\n",keta);
        }
    return 0;
    }

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int clz(ll x){return 64 - __builtin_clzll(x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,a,b,cur;
	cin>>k>>a>>b;
	cur=a;
	if(a>=k)cout<<1<<endl;
	else if(a-b<=0)cout<<-1<<endl;
	else{
		cout<<1+((max(0,k-a)+(a-b)-1)/(a-b))*2<<endl;
	}
}



Measured memory_bytes: 256
n, m, c = map(int, input().split(' '))
b = list(map(int, input().split(' ')))
a = [list(map(int, input().split(' '))) for _ in range(n)]
result = 0
for i in range(n):
    counter = c
    for s in range(m):
        counter += a[i][s]*b[s]
    if counter > 0:
        result += 1
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin >> n;
    int a[100000];
    int cur = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cur = cur ^ a[i];
    }
    if (cur == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	int n; cin>>n;
	vector<int> a(n);
	cinf(n,a);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[a[i]-1]==i+1){
			cnt++;
		}
	}
	cout << cnt/2 << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 998244353;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n,s;
	cin>>n>>s;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];

	vector<vector<ll>> dp(n+1, vector<ll>(s+1,0));

	dp[0][0]=1;

	rep(i,n){
		rep(j,s+1){
			dp[i+1][j] += 2*dp[i][j];
			dp[i+1][j] %= mod;

			if(j+a[i]<=s){
				dp[i+1][j+a[i]] += dp[i][j];
				dp[i+1][j+a[i]] %= mod;
			}
		}
	}

	cout<<dp[n][s]<<endl;

	return 0;
}

Measured memory_bytes: 73652
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,i,j;
	scanf("%d%d%d",&a,&b,&c);
	i=max(a,b);
	j=max(a,c);
	i=max(i,j);
	if((i-a+i-b+i-c)%2==0)
		printf("%d",(i-a+i-b+i-c)/2);
	else
		printf("%d",(i-a+i-b+i-c+3)/2);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
int num[150]={0};
int index=0;

void push(int x){//向栈顶添加元素
    //printf("\npush: %d", x);
    num[index++]=x;
    //printf("\t\tindex: %d\n", index);
}

int pop(){//从栈顶取出元素
    //printf("\npop: %d", num[index-1]);
    //printf("\t\tindex: %d\n", index);
    return num[--index];
}

int main(){
    char ch[12];
    while(scanf("%s", ch)!=EOF){
        if(ch[0]=='+'){
            push(pop()+pop());
        }else if(ch[0]=='-'){
            int a = pop();
            int b = pop();
            push(b-a);
        }else if(ch[0]=='*'){
            push(pop()*pop());
        }else{
            push(atoi(ch));
        }
    }
    printf("%d\n", pop());
    return 0;
}



Measured memory_bytes: 3212
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
N = int(input())
prime = primes(55555)
ans = [0]*N
for i in range(N):
    for k in prime:
        if k % 5 == 1 and k not in ans:
            ans[i] = k
            break
print(*ans)


Measured memory_bytes: 39536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <typeinfo>
#include <cstdlib>

int main(){
    std::string s;
    std::cin >> s;
    int n = (int)s.size();
    int counter = 0;
    int t;
    for(int i=0; i<n; i++){
        if(s[i]=='0') t=2;
        else t=1;
        if((t+i)%2==0) counter++;
    }
    std::cout << std::min(counter, n-counter) << std::endl;
	return 0;
}


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

def main():
    base_array=[]
    similar_array=[]
    odd_num_array=[]
    counter=0
    ans=1
    array_length = int(input())
    base_array=list(map(int,input().split()))
    for i in base_array:
        data = [i-1,i,i+1]
        similar_array.append(data)
    for array in similar_array:
        for i in array:
            if i % 2 !=0:
                counter+=1
        odd_num_array.append(counter)
        counter=0
    for number in odd_num_array:
        ans*=number
    print(3**array_length-ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
bool praime_numbers[100001];


static const int MOD = 1000000007;

const int int_inf = 2147483647;
const ll long_inf = 9223372036854775807ll;

#define rep(i,n) for(int i = 0;i<n;i++)
//#define rep(j,n) for(int j = 0;j<n;j++)
#define defvi(a,c) vector<int>(a,c)
#define defvvi(a,b,c) vector<vector<int>>(a, vector<int>(b, c))

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



void check_1D(vector<int>& ls);
void check_2D(vector<vector<int>>& ls);


int main() {
	ios::sync_with_stdio(false);
	//ここからコードを書く
	int n, k,check = 1,count = 0,ans = 0,change,beforCheck = -1;
	string s;
	cin >> n >> k;
	cin >> s;

	if (s.back() == '0') s += '1';
	else s += '0';

	if (n == 1) {
		cout << 1 << endl;
		exit(0);
	}

	for (int i = 0; i < n; i++) {
		if (s[i] == '0')change = k * 2;
		else change = k * 2 + 1;
		if (i != 0) {
			if (s[i] != s[i - 1])count--;
		}
		for (; check < n+1; check++) {
			if (s[check] != s[check - 1] && beforCheck != check)count++;
			if (count >= change || check >= n) {
				ans = max(ans, check - i);
				beforCheck = check;
				//cout << check << ' ' << count << ' ' << change << endl;
				break;
			}
		}
	}

	cout << ans << endl;
	//ここまで
}

//デバック用関数
//一次元の配列を出力する関数
void check_1D(vector<int>& ls) {
	int length = ls.size();
	for (int i = 0; i < length; i++) {
		cout << ls[i] << ' ';
	}
	cout << endl;
}
//二次元配列を出力する関数
void check_2D(vector<vector<int>>& ls) {
	for (int i = 0; i < ls.size(); i++) {
		for (int j = 0; j < ls[0].size(); j++) {
			cout << ls[i][j] << ' ';
		}
		cout << endl;
	}
}



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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    if (n / 10 == 9 || n % 10 == 9) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, r, c;

  int cell[110][110];
  cin >> r >> c;
  rep0(i,r){
    cell[i][c] = 0;
    rep0(j,c) cin >> cell[i][j], cout << cell[i][j] << " ", cell[i][c] += cell[i][j];
    cout << cell[i][c] << endl;
  }
  rep0(j,c+1) {
    cell[r][j] = 0;
    rep0(i,r) cell[r][j] += cell[i][j];
    cout << cell[r][j] << sep[j == c];
  }
  cout << flush;


  return 0;
}
  

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

int main()
{
    bool flag=false;
    ll N;
    cin >> N;

    for(ll i = 1; i < 10; i++)
    {
        for(ll j = 1;j<10;j++)
        {
            if(i*j == N)
            {
                flag=true;
                break;
            }
        }
        if(flag)break;
    }

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

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){

        int n,i,j,k,l;
        int s1,s2,s3,s4;
        int count=0;
        int a[51];
        int r=0;

        while(scanf("%d",&n)!=EOF){

                for(i=0;i<=9;i++){
                        for(j=0;j<=9;j++){
                                for(k=0;k<=9;k++){
                                        for(l=0;l<=9;l++){
                                        if(i+j+k+l==n) count++;
                                        }
                                }
                        }
                }

                a[r]=count;
                r++;
                count=0;
        }

        for(i=0;i<r;i++){
                printf("%d\n",a[i]);
        }

        return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll A, B, K;
	cin >> A >> B >> K;

	//ll k = 0;

	vector<ll> v;

	for (ll i = 1; i < A * B + 1; ++i)
	{
		if (A % i == 0 && B % i == 0)
		{
			v.push_back(i);
		}
	}

	cout << v[v.size() - K] << endl;

	//system("pause");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//h
int main() {
    char a[11], b[11], c[11];
    int d, e;
    scanf("%s %s\n", &a, &b);
    scanf("%d %d\n", &d, &e);
    scanf("%s", &c);

    if(strcmp(a, c) == 0) {
        printf("%d %d\n", d - 1, e);
    } else if (strcmp(b, c) == 0) {
        printf("%d %d\n", d, e - 1);
    }

    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main(){
	int N,M,C;
	scanf("%d %d %d",&N,&M,&C);
	int num[N][M];
	int nm[M];
	int nn=0;
	int count=0;
	for(int i=0;i<M;i++){
		scanf("%d",&nm[i]);
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			scanf("%d",&num[i][j]);
		}
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
				nn+=num[i][j]*nm[j];
			}
			if((nn+C)>0){
				count++;
			}
			nn=0;
		}

		printf("%d\n",count);
		return 0;
	}

Measured memory_bytes: 128
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    H = list(map(int, args[1].split()))
    H.sort(reverse=True)

    return str(sum(H[k:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 27300
digit = int(input())
li = list(input().split(" "))
li = [int(i) for i in li]

count = 0
flag = False

while flag==False:
  for i in range(digit):
    if li[i]%2==0:
      li[i]=li[i]/2
    else:
      flag=True
        
  if flag==False:
    count+=1

print(count)

Measured memory_bytes: 9060
#include<cstdio>
using namespace std;
struct node{
	int a,b;
}c[100100];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&c[i].a,&c[i].b);
	int st;
	long long ans=0,sum=0;
	for(int i=1;i<=n;i++)
		if((c[i].a|k)==k) sum=sum+c[i].b;
	if(sum>ans) ans=sum;
	for(int i=30;i>=0;i--){
		if((k&(1<<i)))
		{
			st=(k^(1<<i))|((1<<i)-1);
			sum=0;
			for(int j=1;j<=n;j++)
				if((c[j].a|st)==st) sum=sum+c[j].b;
			if(sum>ans) ans=sum;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
package main

import "fmt"
import "math"

func main() {
	var h float64
	var x float64
	fmt.Scan(&h)

	x = math.Floor(math.Log2(h))
	m := math.Pow(2, x)
	l := int64(m)
	a := l * 2 - 1

	fmt.Println(a)
}


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

const int N = 3e5 + 5;
vector< vector<int> > adj(N);
vector<int> vis(N), d(N);

void dfs(int v) {
  vis[v] = 1;
  for(int u : adj[v]) {
    if(!vis[u]) {
      d[u] += d[v];
      dfs(u);
    }
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  for(int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  while(q--) {
    int a, x;
    cin >> a >> x;
    d[a] += x;
  }
  dfs(1);
  for(int i = 1; i <= n; i++)
    cout << d[i] << ' ';
  return 0;
}


Measured memory_bytes: 25472
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 02:34:54 2019

@author: yuta
"""

N,K = map(int,input().split())
L = list(map(int,input().split()))

def main(n,k,l):
    l_sort = sorted(l,reverse = True)
    print(sum(l_sort[:k]))

main(N,K,L)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

ll fact(ll x)
{
    if(x <= 0) return 1;
    else return x * fact(x-1);
}

ll combi(ll n, ll r)
{
    return fact(n) / (fact(r)*fact(n-r));
}

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

    ll A, B; cin >> A >> B;
    ll ans = 0;
    if(A % 2 == 1)
    {
        ans = A;
        A++;
    }
    ll n = B-A+1;
    ll z = n/2, r = n%2;
    if(z % 2 == 0)
    {
        if(r == 1)
        {
            ans = ans ^ 0 ^ B;
        }
        else
        {
            ans = ans ^ 0;
        }
    }
    else
    {
        if(r == 1)
        {
            ans = ans ^ 1 ^ B;
        }
        else
        {
            ans = ans ^ 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256