akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ans;
  if (n % 2 == 0) {
    int med_a = a.at(n/2-1) + a.at(n/2), med_b = b.at(n/2-1) + b.at(n/2);
    ans = med_b - med_a + 1;
  } else {
    int med_a = a.at(n/2), med_b = b.at(n/2);
    ans = med_b - med_a + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0,a[101];
    scanf("%d",&n);
    
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]%2==0){
        if(a[i]%3==0||a[i]%5==0) c=1;
            else{
c=0;
break;
}
            
    }
        else c=1;
    
        
}
    if(c==1) printf("APPROVED\n");
    else printf("DENIED\n");

    }

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc147/submissions/8871745
# 写経
# bitset 高速化

def main():
    import numpy as np

    H, W = map(int, input().split())
    A = np.array([[int(x) for x in input().split()] for _ in range(H)])
    B = np.array([[int(x) for x in input().split()] for _ in range(H)])
    D = np.abs(A - B)

    MAX_BIAS_PER_CELL = 80
    UPPER_BOUND_TOTAL_BIAS = MAX_BIAS_PER_CELL * (H + W - 1) + 1

    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 << UPPER_BOUND_TOTAL_BIAS
    # dp[r][c]:(r,c)で値の加減を行った後、
    # 達成可能なbiasに該当するbitを立てたbit表現
    # 2**UPPER_BOUND_TOTAL_BIASの位をbias=0とみなす

    # -UPPER_BOUND_TOTAL_BIAS, ..., 0, ...UPPER_BOUND_TOTAL_BIAS [意味するbias]
    # 0, ..., UPPER_BOUND_TOTAL_BIAS, ..., UPPER_BOUND_TOTAL_BIAS*2 [dpに代入されるbit表現の桁]

    # numpyのndarrayを使用しなかった理由
    # dtypeでuint64を採用しても、
    # 2**(UPPER_BOUND_TOTAL_BIAS*2)は収まらない
    # pythonのintなら収まる

    for r in range(H):
        for c in range(W):
            x = dp[r][c]
            if r > 0:
                x |= dp[r - 1][c]
            if c > 0:
                x |= dp[r][c - 1]
            # x:(r,c)到達可能なbiasのbit表現

            d = D[r][c]
            dp[r][c] = (x << d) | (x >> d)
            # (r,c)マスでのbias変化を加味したbit表現

    ret = min(
        abs(UPPER_BOUND_TOTAL_BIAS - shift)
        for shift in range(UPPER_BOUND_TOTAL_BIAS * 2)
        if (dp[H - 1][W - 1] & (1 << shift)) > 0)

    print(ret)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/06/03  Problem: ARC 075 C / Link: http://arc075.contest.atcoder.jp/tasks/arc075_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N,K;
ll a[200010];
ll ans = 0LL;
ll sum[200010];

template<class V, int ME> class BIT {
public:
	V bit[1 << ME], val[1 << ME];
	V total(int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
	V add(int e, V v) { val[e++] += v; while (e <= 1 << ME) bit[e - 1] += v, e += e&-e; }
	V set(int e, V v) { add(e, v - val[e]); }
	int lower_bound(V val) {
		V tv = 0; int i, ent = 0;
		for (i = ME - 1; i >= 0; i--) if (tv + bit[ent + (1 << i) - 1]<val) tv += bit[ent + (1 << i) - 1], ent += (1 << i);
		return ent;
	}
};


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

  cin >> N>>K;
  FOR(i, 0, N)cin >> a[i];
  FOR(i, 0, N)a[i] -= K;
  
  vector < ll >v;
  v.push_back(-1LL<<60);
  v.push_back(0);
  FOR(i, 1, N + 1) {
	  sum[i] += sum[i - 1] + a[i-1];
	  v.push_back(sum[i]);
  }
  sort(v.begin(), v.end());
  
  
  int added = 0;
  BIT<int, 20>bit;
  for (int i = N - 1; i >= 0; i--) {
	  int x = lower_bound(v.begin(), v.end(), sum[i + 1]) - v.begin();
	  added++;
	  bit.add(x, 1);
	  int y = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
	  ans += added - bit.total(y - 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9968
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h,k;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(h<a){
      h=a;
      k=b;
    }
  }
  cout<<h+k<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  int k = 0;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    if(A[i] == 1) k = i;
  }
  
  if(N == K) {
    cout << 1 << endl;
    return 0;
  } else if(N < 2*K) {
    cout << 2 << endl;
    return 0;
  }
  
  if(k == 0 || k == N-1) {
    cout << (N-1+K-2)/(K-1) << endl;
    return 0;
  }
  
  int ans = 1;
  ans += (int)(k/(K-1)) + (int)((N-k-1)/(K-1));
  ans += (k%(K-1)+(N-k-1)%(K-1)-K+1) > 0 ? (k%(K-1)+(N-k-1)%(K-1)-K+1)/(K-1)+1 : (k%(K-1)+(N-k-1)%(K-1)-K+1)/(K-1);
  
  
  cout << ans << endl;

}

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

using namespace std;

int main()
{
    int n, w;
    scanf("%i%i", &n, &w);
    vector<pair<int,int>> arr(n+1);
    for (int x = 1; x <= n; x++)
        scanf("%i%i", &arr[x].first, &arr[x].second);
    vector<vector<long long>> dp(105, vector<long long>(100005, LONG_MAX));
    dp[0][0] = 0;
    long long ans = 0;
    for (int x = 1; x <= n; x++)
    {
        for (int y = 0; y < 100005; y++)
        {
            if (y >= arr[x].second && dp[x-1][y-arr[x].second] < LONG_MAX)
                dp[x][y] = min(dp[x-1][y-arr[x].second]+arr[x].first, dp[x-1][y]);
            else
                dp[x][y] = dp[x-1][y];
            if (dp[x][y] <= w)
                ans = max(ans, (long long)y);
        }
    }
    printf("%lli\n", ans);
}


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

int main()
{
    int64_t N, K;
    cin >> N >> K;
    int64_t div = N % K;
    div = min(div, abs(div - K));
    cout << div << endl;
}

Measured memory_bytes: 256
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar(); 
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
int n,k;
int x[maxn];
ll ans=Inf; 

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d",&x[i]);
	rep(i,n-k+1){
		ll cur=0,st=x[i],en=x[i+k-1];
		if(en<0)cur=-st;
		else if(st>0)cur=en;
		else cur=min((-st)*2+en,en*2+(-st));
		ans=min(ans,cur);
	}
	printf("%lld",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/

int main(){
    int H,A;
    cin>>H>>A;
    int ans=H/A;
    if (H%A==0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans+1<<endl;
    }
}

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

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.length()==2) cout << s << endl;
    else {
        reverse(s.begin(),s.end());
        cout << s << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//N個のボタンがついたダイヤルを回すと考えると分かりやすい。最初, 位置jにあるボタンをボタンjとして、
//位置iではa_i秒でインクを付けることができると読み替える。「ボタンにインクをつける→ダイヤルを回す」を繰り返すイメージをすれば、
//インクをつけられる範囲、回すコストともに固定できる変量として「回す回数」が使えると気付ける。
#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, x;
int a[4000];
int minA[4000];

signed main() {
	int i, j, k;
	
	cin >> n >> x;
	rep(i, n) cin >> a[i];
	rep(i, n) a[i + n] = a[i];
	rep(i, n) minA[i] = 1e+15;
	
	int ans = 1e+15;
	rep(i, n) {
		int cst = 0;
		rep(j, n) {
			minA[j] = min(minA[j], a[j + i]);
			cst += minA[j];
		}
		ans = min(ans, cst + i * x);
	}
	cout << ans << endl;
	return 0;
}

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

#define LL long long
#define lowbit(x) ((x) & -(x))

const int maxn = (int) 1e5 + 20;
const int MOD = 998244353;

LL fp(LL a, LL n, LL m = MOD)
{
    LL res = 1;
    for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m;
    return res;
}

void work()
{
    int n, x;
    cin >>n >>x;
    int sum = 0, ans = 0;
    for(int i = 0; i < n; i++)
    {
        int y; cin >>y;
        sum += y;

        if(sum <= x) ans++;
    }
    cout <<ans + 1 <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
int a,b,c;
 
scanf("%d %d %d",&a,&b,&c);
 
if(a < b && b < c){
 
  printf("Yes\n");
 
}else{
 
  printf("No\n");
 
}
return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, p;
string s;
vector <pair<string, pair<int,int> > > v;

int main() {
	ios_base::sync_with_stdio(false);	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s >> p;
		v.push_back({s, {-p, i}});
	}
	sort(v.begin(), v.end());
	for(auto i : v) cout << i.nd.nd << '\n';
}	


Measured memory_bytes: 256
N,K=map(int,input().split())
sz=max(N-K+2,K)
c=[ [0 for _ in range(K+1)] for _ in range(sz)]
mod=10**9+7
c[1][1]=1
c[1][0]=1
for n in range(2,sz):
    c[n][0]=1
    c[n][1]=n
    for r in range(2,K+1):
        c[n][r]=(c[n-1][r]+c[n-1][r-1])%mod
#print(c[4][0],c[4][1],c[4][2],c[4][3],c[4][4])
c[0][0]=1
ans=0
for i in range(1,K+1):
    ans=0 
    #print(i,N-K+1,i,c[N-K+1][i],c[K-1][i-1])
    if i<=N-K+1:
        ans=(c[N-K+1][i]*c[K-1][i-1])%mod
    print(ans)



Measured memory_bytes: 99200
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 X;
  cin >> X;

  i64 m = 100;
  int result = 0;
  while (m < X) {
    m += m / 100;
    result++;
  }
  cout << result;
}
#endif


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		sc.close();
		
		X = X - Z * 2;
		int result = 0;
		for (int i = 1;;i++) {
			if (Y * i + Z * (i - 1)> X) {
				result = i - 1;
				break;
			}
		}
		
		System.out.println(result);
	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int a,b;

int main(){
	cin >> a >> b;
	
	if(500*a >= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

#define REP(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    VI;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int>> VVI;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

struct edge {int to, cost;};

/*
class Graph{
public:
    vector<vector<edge>> G;
    vector<int> d;
    vector<int> prev;
    int V, E;
    Graph(){
        G = vector<vector<edge>>(V);
    }
    void add(int from, int to) {
        G
    }
}*/

VVI E ;
vector<int> G(700,-1);//color
VI C = VI(700, -1);
VVI cn = VVI(700, VI(2,0));
int N;
bool dfs(int i, int g, int c){
    //cout << "ni" << i << " " << g << " " << c <<endl;
    G[i] = g;
    C[i] = c;
    cn[g][c]++;
    REP(j, N){
        if(E[i][j] == 1 && i != j){
            //cout << j << endl;
            if(C[j] == c)return false;
            if(G[j] == g)continue;
            if(!dfs(j, g, 1-c)){
                return false;
            }
        
        }
    }
    return true;
}

int main(){
    int M;
    cin >> N >> M ;
    /*REP(i, 5){
        REP(j,5)cout << E[i][j];
        cout << endl;
    }*/
    E = VVI(N, VI(N, 1));
    REP(i, M){
        int a, b;
        cin >>a >> b;
        a = a-1;
        b = b-1;
        E[a][b] = 0;
        E[b][a] = 0;
    }
    
    int g = 0;
    for(int i = 0; i < N; i++){
    //cout << "i" << i << endl;
        if(G[i] != -1)continue;
        if(!dfs(i, g, 0)){
            cout << -1 << endl;
            return 0;
        }
        g++;
    }
    //cout << "dp" << endl;
    int maxe = N*(N-1)/2;
    bool mem[N][maxe];
    REP(i, N)REP(j, maxe)mem[i][j] = false;
    mem[0][cn[0][0]] = cn[0][1];
    mem[0][cn[0][1]] = cn[0][0];
    //cout << "dp2" << endl;
    for(int i = 1; i < g; i++){
        REP(j,N){
            int a = cn[i][0];
            int b = cn[i][1];
            if(!mem[i-1][j])continue;
            mem[i][j+a] = true;
            mem[i][j+b] = true;   
        }
    }
    int ma = 0;
    REP(i, N){
        if(mem[g-1][i] > 0){
            int r = N - i;
            ma = max(ma, i*r-N*(N-1)/2+M);
        //cout << i << " " << j << endl;
        }
    }
    cout << M - ma << endl;
    return 0;
}

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

int main() {
	string w;
	int charactor[26];
	for (int i = 0; i < 26; i++) charactor[i] = 0;
	cin >> w;
	for (int pos = 0; pos < w.length(); pos++) charactor[w[pos]-97]++;

	for (int i = 0; i < 26; i++) {
		if ((charactor[i] % 2) != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<i64> a(n), b(n);
	for(int i = 0; i < n; i++) scanf("%lld%lld", &a[i], &b[i]);
	
	auto f = [&](i64 t) {
		i64 cnt = 0;
		for(int i = 0; i < n; i++) {
			if(t < a[i]) continue;
			
			cnt += (t - a[i]) / b[i] + 1;
			if(cnt >= k) return true;
		}
		return false;
	};
	
	i64 ok = 1LL << 62, ng = 0;
	while(std::abs(ok - ng) > 1) {
		i64 mid = (ok + ng) >> 1;
		
		if(f(mid)) ok = mid;
		else ng = mid;
	}
	
	printf("%lld\n", ok);
	return 0;
}


Measured memory_bytes: 1792
def rem(x,r):
  if (x,r) == (1,0):
    return [[1]]
  if x <= 2*r:
    return -1
  ret = []
  for i in range(1,x+1):
    if x%i == r:
      ret.append([i])
    else:
      s = rem(x%i,r)
      if s == -1:
        continue
      else:
        for j in s:
          if j == -1:
            continue
          elif j[-1] < i:
            ret.append([i]+j)
          else:
            ret.append([i]+j)
  return ret
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for xx,yy in zip(x,y):
  if xx != yy and rem(xx,yy) == -1:
    print(-1)
    exit()
ls = [rem(xx,yy) if xx != yy else 0 for xx,yy in zip(x,y)]
flg = [0]*n
def findmx(lsi,ansst,mx):
  ret = 100
  if lsi == 0:
    return 0
  for lsls in lsi:
    for j in lsls:
      if j > mx:
        return min(j,ret)
      elif j in ansst:
        continue
      else:
        ret = min(j,ret)
        break
    else:
      return 0
  else:
    return ret
    
mxls = [ls[i][0][0] if type(ls[i]) == list else 0 for i in range(n)]
mx = max(mxls)
ansst = set((mx,))
mxcand = mx
while mxcand:
  for i in range(n):
    t = findmx(ls[i],ansst,mx)
    mxls[i] = t
    if t == 0:
      flg[i] = 1
  mxcand = max(mxls)
  ansst.add(mxcand)
  if flg.count(1) == n:
    break
ans = 0
for b in ansst:
  if b:
    ans += 2**b
print(ans)

Measured memory_bytes: 48732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();

		if (1 <= a && a <= 10000 && 1 <= b && b <= 10000 && 1 <= c && c <= 10000) {
			if (a <= b && b <= c) {
				System.out.println(a + " " + b + " " + c);
			} else if (a <= c && c <= b) {
				System.out.println(a + " " + c + " " + b);
			} else if (b <= a && a <= c) {
				System.out.println(b + " " + a + " " + c);
			} else if (b <= c && c <= a) {
				System.out.println(b + " " + c + " " + a);
			} else if (c <= a && a <= b) {
				System.out.println(c + " " + a + " " + b);
			} else if (c <= b && b <= a) {
				System.out.println(c + " " + b + " " + a);
			}
		}

	}

}

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

int hex_to_degit(char x)
{
    if (x == 'F')
        return 15;
    if (x == 'E')
        return 14;
    if (x == 'D')
        return 13;
    if (x == 'C')
        return 12;
    if (x == 'B')
        return 11;
    if (x == 'A')
        return 10;
    return (int)x;
}

int main()
{
    char x, y;
    cin >> x >> y;
    int nx = hex_to_degit(x), ny = hex_to_degit(y);
    if (nx < ny)
    {
        cout << "<" << endl;
    }
    else if (nx > ny)
    {
        cout << ">" << endl;
    }
    else if (nx == ny)
    {
        cout << "=" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}


ll run() {
    int n,k;
    cin>>n>>k;
    int h[n];
    int dp[n]={0};

    for (int i=0;i<n;i++){
        cin>>h[i];
    }

    for(int i=1;i<n;i++) {
        dp[i]=1e9;
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
            }
        }
    }
    cout<<dp[n-1];
}


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

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
  if (A.size() == n+1){
    int now=0;
    for(int i=0;i<q;i++){
      if(A[b[i]]-A[a[i]] ==c[i]) now+= d[i];
    }
    ans =max(ans,now);
    return;
  }
  
  A.push_back(A.back());
  while (A.back() <=m){
    dfs(A);
    A.back()++;
  }
}
    
int main(){
  cin >>n>>m>>q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  dfs(vector<int>(1,1));
  cout<<ans<<endl;
  return 0;
}
  
  
  
  
  

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r;
    cin >> r;
    const double pi = acos(-1.0);
    double ans = 2 * pi * r;
    cout << setprecision(20) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 3776
MAX = 1000001

mod = 1000000007

prime = [0 for i in range(MAX)]

max_map = dict()

# function to return a^n

def power(a, n):

    if n == 0:
        return 1
    p = power(a, n // 2) % mod
    p = (p * p) % mod

    if n & 1:
        p = (p * a) % mod
    return p

# function to find the smallest prime
# factors of numbers upto MAX


def sieve():
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX):
        if prime[i] == 0:
            for j in range(i * 2, MAX, i):
                if prime[j] == 0:
                    prime[j] = i
            prime[i] = i

# function to return the LCM modulo M


def lcmModuloM(arr, n):

    for i in range(n):
        num = arr[i]

        temp = dict()

        # temp stores mapping of prime factors
        # to its power for the current element
        while num > 1:

            # factor is the smallest prime
            # factor of num
            factor = prime[num]

            # Increase count of factor in temp
            if factor in temp.keys():
                temp[factor] += 1
            else:
                temp[factor] = 1

            # Reduce num by its prime factor
            num = num // factor

        for i in temp:
            # store the higest power of every prime
            # found till now in a new map max_map
            if i in max_map.keys():
                max_map[i] = max(max_map[i], temp[i])
            else:
                max_map[i] = temp[i]

    ans = 1

    for i in max_map:

        # LCM is product of primes to their
        # higest powers modulo M
        ans = (ans * power(i, max_map[i])) % mod
    return ans


def rep_sqr(base, k, mod):
    if k == 0:
        return 1
    elif k % 2 == 0:
        return (rep_sqr(base, k / 2, mod) ** 2) % mod
    else:
        return (rep_sqr(base, k - 1, mod) * base) % mod

# a^(-1) == a^(m-2)


def flt(a, mod):
    return rep_sqr(a, mod-2, mod)

# Driver code
sieve()

# python > pypy
MOD = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))

lcm_ = lcmModuloM(a, n)

b = list(map(lambda x: lcm_ * flt(x, mod), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 14708
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;



int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for(int i = 0; i < N; i++){
    cin >> A[i];
   }

for(int i = 0; i < N; i++){
    int cnt = 0;
    while(A[i] %2 == 0){
        A[i] /= 2;
        cnt++;
    }
A[i] = cnt;
}
cout << *min_element(A.begin(), A.end()) << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >>N >>M;
  long long ans=1;
  if(abs(N-M)>1){
    ans=0;
    cout <<ans <<endl;
    return 0;
  }
  int C=1e9+7;
  for(int i=N; i>0; i--){
    ans*=i;
    ans%=C;
  }
  for(int i=M; i>0; i--){
    ans*=i;
    ans%=C;
  }
  if(N==M) ans*=2, ans%=C;
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s.size() < 26) {
    int a[26] = {0};
    for (int i = 0; i < s.size(); i++) {
      a[s[i] - 97] = 1;
    }
    for(int i = 0; i < 26; i++) {
      if (a[i] == 0) {
        cout << s << char(i + 97) << '\n';
        return 0;
      }
    }
  }
  else if ("zyxwvutsrqponmlkjihgfedcba" == s) {
    cout << -1 << '\n';
    return 0;
  }
  else {
    for (int i = 0; i < 25; i++) {
      char p = s[s.size()-1-i];
      char q = s[s.size()-2-i];
      char t = 'z';
      if (p > q) {
        cout << s.substr(0,24-i);
        for (int j = 0; j < i+1; j++) {
          if (char(s[25-j]) > char(s[24-i])) {
            t = min(t, char(s[25-j]));
          }
        }
        cout << t << '\n';
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, h[200005], b[200005], dp[200005];

int main(){
	cin >> n;
	int base = 1;
	while( base <= n )
		base *= 2;
	vector< ll > tree(base * 2, 0);
	for(int i = 0 ; i < n ; i++)
		cin >> h[i];
	for(int i = 0 ; i < n ; i++)
		cin >> b[i];
	for(int i = 0 ; i < n ; i++){
		ll query = base + h[i];
		ll yet_best = 0;
		while( query > 1 ){
			if( query % 2 )
				yet_best = max(yet_best, tree[query - 1]);
			query /= 2;
		}
		dp[h[i]] = yet_best + b[i];
		for(int j = base + h[i] ; j > 0 ; j /= 2)
			tree[j] = max(tree[j], dp[h[i]]);
	}
	ll ans = 0;
	for(int i = 0 ; i <= n ; i++)
		ans = max(ans, dp[i]);
	cout << ans << endl;
	return(0);
}

Measured memory_bytes: 9088
from collections import deque, defaultdict


def main():
    N, M = map(int, input().split())
    childs = defaultdict(list)
    parents = defaultdict(int)
    for i in range(N+M-1):
        a, b = map(int, input().split())
        childs[a].append(b)
        parents[b] += 1
    q = deque(x for x in range(1, N+1) if parents[x] == 0)
    ans = defaultdict(int)
    while(len(q)):
        n = q.popleft()
        for c in childs[n]:
            parents[c] -= 1
            if parents[c] == 0:
                q.append(c)
                ans[c] = n
    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 95316
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }

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

Measured memory_bytes: 3568
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
  int64_t x;
  cin >> x;
  
  int64_t seed = 100;
  int years = 0;
  int64_t resoku;
  while (seed < x)
  {
    resoku = seed / 100;
    seed += resoku;
    years ++;
  }
  
  cout << years << endl;
  return 0;
}


Measured memory_bytes: 3632
package main

import "fmt"

func main() {
  a := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  var n, b, i, j int
  var s string
  fmt.Scan(&n, &s)
  for i = 0; i < len(s); i++ {
    for j = 0; s[i] != a[j]; j++ {}
    b = (n + j) % 26
    fmt.Printf(string(a[b]))
  }
}

Measured memory_bytes: 640
import math
n, m = map(int, input().split())
an = list(map(int, input().split()))
maxi = max(an)
p = math.floor(math.log2(maxi))+1
ps = [0 for _ in range(p)]
for a in an:
  ps[math.floor(math.log2(a))] += 1

an.sort(reverse=True)

sum = 0
subtotal = 0
for p in ps[::-1]:
  if sum + subtotal + p > m:
    break
  subtotal += p
  an[:subtotal] = [a/2 for a in an[:subtotal]]
  sum += subtotal
# print(an)
an.sort(reverse=True)
p = m - sum
an[:p] = [a/2 for a in an[:p]]
# print(an)

sum = 0
for a in an:
  sum += math.floor(a)
print(sum)


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i++) {
    if(i % 2 == 0) Alice += a.at(i);
    else Bob += a.at(i);
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int n;

  int quo;
  int digit[20];

  int i,num;

  while(1) {

    scanf("%d",&n);

    if(n==-1) break;

    quo=n;
    num=0;

    if(quo==0) {
      
      printf("0\n");
      continue;

    }

    while(quo>0) {

      digit[num]=quo%4;
      quo/=4;

      num++;

    }
    
    for(i=num-1;i>=0;i--) printf("%d",digit[i]);

    puts("");

  }

  return 0;

}

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

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N) {
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, 0, k) {
            int v; cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    vector<int> dist(N, -1);
    queue<int> Q;
    Q.push(0);
    dist[0] = 0;
    while(!Q.empty()) {
        int cur = Q.front(); Q.pop();
        for(auto &to : G[cur]) {
            if(dist[to] != -1) continue;
            Q.push(to);
            dist[to] = dist[cur] + 1;
        }
    }
    rep(i, 0, N) cout << i + 1 << " " << dist[i] << '\n';
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 30005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL;

int n,m,k,ans;
struct Node{int to,next;}node[5005];
int head[2010],hcnt;
inline void add(int x,int y){
    node[hcnt].to=y;node[hcnt].next=head[x];
    head[x]=hcnt++;
}
int ct(int u,int fa,int num){
    if(num==0)return 1;
    int temp=1;
    for(int i=head[u];~i;i=node[i].next){
        int e=node[i].to;
        if(e==fa)continue;
        temp+=ct(e,u,num-1);
    }
    return temp;
}
int main(){
    //freopen("in.txt","r",stdin);
    int i,j,x,y;
    mst(head,-1);
    scanf("%d%d",&n,&k);
    for(i=2;i<=n;++i){
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    ans=1;
    for(LL i=0;i<2000000000*1000000000;++i)
        ans=ans*5%MOD+MOD;
    ans=0;
    if(k&1){
        for(i=1;i<=n;++i){
            for(int l=head[i];~l;l=node[l].next){
                int e=node[l].to;
                if(e<=i)continue;
                int temp=ct(i,e,k/2)+ct(e,i,k/2);
                ans=max(ans,temp);
            }
        }
    }
    else{
        for(i=1;i<=n;++i){
            ans=max(ans,ct(i,-1,k/2));
        }
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,ans=0; cin>>n>>m;
  int k[11],bulb[11][11],p[11];
  for(int i=0;i<m;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++) cin>>bulb[i][j],bulb[i][j]--;
  }
  for(int i=0;i<m;i++) cin>>p[i];
  for(int ptn=0;ptn<1<<n;ptn++){
    int sum[11]={0};
    bool light=true;
    for(int i=0;i<m;i++){
      for(int j=0;j<k[i];j++){
        if(ptn&1<<bulb[i][j]) sum[i]++;
      }
    }
    for(int i=0;i<m;i++) if(p[i]!=sum[i]%2) light=false;
    if(light) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int k;
    cin >> k;
    cout << (k / 2) * (k % 2 == 0 ? (k / 2) : (k / 2 + 1)) << endl;
    return 0;
}


Measured memory_bytes: 256
//file_name:ABC93_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a;
    scanf("%d",&a);
    int b;
    scanf("%d",&b);
    int c;
    scanf("%d",&c);

    if(b-a<=2*(c-1)){
        for(int i=a;i<=b;++i){
            cout << i << endl;
        }
    }else{
        srep(i,a,a+c){
            cout<<i<<endl;
        }
        srep(i,b-c+1,b+1){
             cout<<i<<endl;
        }
    }



    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int count=0;
  for(char i:s)
  {
    if(i=='R')
    {
      count++;
    }
   	else if(i=='S' &&count>0)
   	{
   		break;
	   }
  }
  cout<<count<<"\n";
 }


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>
#include <tuple>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int N, M, L;

vector<tuple<int, int, int>> vs;

double P[111][111];
double T[111][111];

namespace math { namespace combination {

#define COMBINATION_MAX 200
using return_type = ll;

namespace memorized { namespace combination { enum { max_value = COMBINATION_MAX }; bool __computed = false; inline bool computed() {if(__computed) { return true; } else { __computed = true; return false; }} return_type dp[max_value][max_value];} }

return_type comb(int N, int K) {
  using memorized::combination::dp;
  if(memorized::combination::computed()) { return dp[N][K]; }

  rep(i, memorized::combination::max_value) {
    dp[i][0] = 1;
    REP(j, 1, i+1) {
      dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
//      dp[i][j] %= MOD;
    }
  }
  return dp[N][K];
}}}

void solve() {
  rep(i, N) {
    rep(j, M+1) {
      P[i][j] = pow(get<0>(vs[i]) * 0.01, j) * pow((100-get<0>(vs[i])) * 0.01, M - j) * math::combination::comb(M, j);
      if(j) T[i][j] = T[i][j-1] + get<2>(vs[i]);
      else T[i][0] = 1.0 * L / get<1>(vs[i]);
    }
  }

  rep(i, N) {
    double res = 0;

    if(get<1>(vs[i]) == 0) {
      cout << "0\n";
      continue;
    }

    rep(j, M+1) {
      double losers_prob = 1.0;
      rep(k, N) {
        if(i == k) continue;
        double sum = 0.0;
        rep(l, M+1) {
          if(T[i][j] < T[k][l]) sum += P[k][l];
        }
        losers_prob *= sum;
      }
      res += losers_prob * P[i][j];
    }
    printf("%.10f\n", res);
  }
}

int main() {

  cin >> N >> M >> L;
  rep(i, N) {
    int p, t, v; cin >> p >> t >> v;
    vs.push_back(make_tuple(p, v, t));
  }

  N = vs.size();
  solve();
  
  return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    string s;
    cin >> s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        } else{
            c++;
        }
    }
    if(abs(a-b)<=1&&abs(b-c)<=1&&abs(c-a)<=1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    }

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            char c;
            if (S.charAt(i)+N <= 90)
                c= (char) (S.charAt(i) + N);
            else
                c= (char) (S.charAt(i) - (26 - N));
            ans.append(c);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
n = int(input())
s = 1
ans = 1
for i in range(1, n+1):
  s *= i
for i in range(2, n+1):
  k = 1
  while s % i == 0:
    s = s // i
    k += 1
  ans *= k
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,M=16,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ga[1<<(M+1)];
int *g[M+1];
bitset<N> bit[N];
unordered_map<bitset<N>,int> h[N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int pl(int x,int y){return (x+y<p) ? (x+y) : (x+y-p);}
char ch[N];
void reset(){
	n=100;
	for (int i=0;i<=M;i++) g[i]=ga+(1<<i);
	for (int i=1;i<n;i++)
	for (int j=0;j<i;j++) bit[i][j]=1;
	n=0;
}
int calc(int n,bitset<N> a){
	if (n<=M){
		int t=0;
		for (int i=0;i<n;i++)
		if (a[i]) t+=1<<i;
		return g[n][t];
	}
	if (h[n].count(a)) return h[n][a];
	int ans=calc(n-1,a>>1)*(1+a[0])%p;
	bitset<N> cur,res;
	for (int d=1;d*2<=n;d++){
		cur=a&bit[d];res=a>>d;int l=n-d;
		while (l>=d){
			l-=d;
			cur&=res;res>>=d;
			check(ans,(ll)calc(d,cur)*calc(l,res)%p);
		}
	}
	return h[n][a]=ans;
}
int main(){
	reset();
	g[0][0]=1;
	for (int i=1;i<=M;i++)
	for (int k=0;k<(1<<i);k++){
		check(g[i][k],g[i-1][k>>1]*((k&1)+1)%p);
		for (int d=1;d*2<=i;d++){
			int cur=k&((1<<d)-1),res=k>>d,l=i-d;
			while (l>=d){
				l-=d;
				cur&=res;res>>=d;
				check(g[i][k],(ll)g[d][cur]*g[l][res]%p);
			}
		}
	}
	
	scanf("%s",ch);
	n=strlen(ch);
	
	bitset<N> t;t.reset();
	for (int i=0;i<n;i++) t[i]=(ch[i]=='1');
	printf("%d\n",calc(n,t));
	return 0;
}

Measured memory_bytes: 1920
s=input()
n=len(s)
n_1=int((n-1)/2)
n_2=int((n+1)/2)

s_1=s[:n_1]
s_2=s[n_2:]

if s==s[::-1] and s_1==s_1[::-1] and s_2==s_2[::-1]:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 9112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a * b);
	}
}


Measured memory_bytes: 35896
import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
count = 0
for i in range(1, n // 3 + 1):
  #print(i)
  kazu = n - (i * 3)
  count += cc(i + kazu - 1, i - 1)
  count %= 10 ** 9 + 7
print(count)

Measured memory_bytes: 9208
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

values = [0] * (N+1)
for p,x in PX:
    values[p] += x
def dfs(v,parent,add):
    values[v]+=add
    for x in graph[v]:
        if x==parent:
            continue
        dfs(x,v,values[v])
        
dfs(1,0,0)
answer=' '.join(map(str,values[1:]))
print(answer)

Measured memory_bytes: 285828
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,d,ans;
	cin>>a>>b>>c>>d;
	if(b==0&&d==0)
	   cout<<a*c<<"\n";
	else
	{
		ans=max(a*c,a*d);
		ans=max(ans,b*c);
		ans=max(ans,b*d);
		cout<<ans<<"\n";
	}
	return 0;
}

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

int main() {
    long long N;
    cin>>N;
    long long ans=0;
    vector<long long>a(N);
    rep(i,N)cin>>a[i];
    sort(a.rbegin(),a.rend());
    long long t=N-1;
    rep(i,N){
        int lim=2;
        if(i==0)lim=1;
        rep(j,lim){
            if(t >0){
                ans+=a[i];
                t--;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,x;
  scanf("%d%d",&n,&x);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<n;i++){
    if(a[i]>x) break;
    x-=a[i];
  }
  if(i==n && x>0) i--;
  printf("%d\n",i);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128