akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

const ll INF=1e18;

int n;
vector<iii> val;
ll memo[20005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	int a,b,c;
	rep(x,0,n){
		cin>>a>>b>>c;
		val.push_back(iii(ii(a,b),c));
	}
	
	sort(all(val),[](iii &i,iii &j){
		if (i.fi.fi+i.fi.se==j.fi.fi+j.fi.se) return i.fi.fi<j.fi.fi;
		else return i.fi.fi+i.fi.se<j.fi.fi+j.fi.se;
	});
	
	rep(x,1,20005) memo[x]=-INF;
	
	for (auto &it:val){
		//cout<<it.fi.fi<<" "<<it.fi.se<<" "<<it.se<<endl;
		
		rep(x,min(it.fi.se+1,20005-it.fi.fi),0){
			memo[x+it.fi.fi]=max(memo[x+it.fi.fi],memo[x]+it.se);
			//cout<<x+it.fi.fi<<" "<<memo[x]+it.se<<endl;
		}
	}
	
	ll ans=0;
	rep(x,0,20005) ans=max(ans,memo[x]);
	
	cout<<ans<<endl;
}


Measured memory_bytes: 512
def isACGT(a):
    return a in ['A', 'C', 'G', 'T']

def main():
    n = input()
    max_len = 0
    for i in range(len(n)):
        cnt_len = 0
        if isACGT(n[i]):
            cnt_len += 1
            for j in range(i+1, len(n)):
                if isACGT(n[j]):
                    cnt_len += 1
                else:
                    break
        if cnt_len > max_len:
            max_len = cnt_len
    print(max_len)
if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int n; cin >> n;
  vector<pi> v(n);

  for(int i = 0; i< n; i++){

    int a, b; cin >> a >> b;
    v[i].first = b;
    v[i].second = a;

  }

  sort(all(v));

  ll sum = 0;

  for(int i = 0; i < n; i++){
    sum += v[i].second;
    if(sum > v[i].first){
      pr("No");
      return 0;
    }
  }

  pr("Yes");

  // for(int i = 0; i < n; i++){
  //   cout <<  v[i].first << ' ' << v[i].second << endl;
  // }

  return 0;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define ump unordered_map<ll , ll>

void doit(){
	ll a,b,ans;
	long double c;
	cin >> a >> c;
	b = (c * 100 + 0.5);
	ans = a * b;
	ans/=100;
	cout << ans << "\n";
	
	}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	//cin>>t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


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

long long solve(long long H){
    if(H == 1) return 1;
    return 2 * solve(H / 2) +  1;
}

int main(){
    long long h;
    cin >> h;
    cout << solve(h) << endl;

    return 0;
}

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

// (b ^ p) % mod
long long modpow(long long b, long long p, long long mod) {
    long long res = 1;
    while (p > 0) {
        if (p & 1) {
            res = res * b % mod;
        }
        b = b * b % mod;
        p >>= 1;
    }
    return res;
}

// find the modular inverse using extended Euclidean algorithm
long long modinv(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long q = a / b;
        a -= q * b;
        swap(a, b);
        u -= q * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0) {
        u += mod;
    }
    return u;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    long long mod = 998244353;
    long long inv = modinv(2, mod);
    // sum, size, * 2^(N - size)
    vector<long long> DP(S + 1, 0); // sum, f
    DP[0] = modpow(2, N, mod);
    for (int i = 0; i < N; ++i) {
        vector<long long> prev(DP);
        for (int sum = 0; sum <= S; ++sum) {
            if (sum + A[i] <= S) {
                DP[sum + A[i]] = (DP[sum + A[i]] + prev[sum] * inv) % mod;
            }
        }
    }
    cout << DP[S] << '\n';
    return 0;
}

Measured memory_bytes: 3712
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map{it.toInt()}
    val k = p.zip((1 .. n)).filter{it.first != it.second}.size
    println(if(k == 2 || k == 0) "YES" else "NO")
}


Measured memory_bytes: 37744
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, e, f;
int c[2];
bool dp[31][2][3001];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c[0] >> c[1] >> e >> f;

  dp[0][0][0] = true;
  dp[0][1][0] = true;
  FOR(i, 1, 31) {
    REP(j, 2) {
      REP(k, e * i + 1) {
        if(j == 0) {
          if(k >= c[j] && dp[i - 1][1][k - c[j]] || k >= c[j] && dp[i][0][k - c[j]] || dp[i - 1][1][k]) dp[i][j][k] = true;
        } else {
          if((k >= c[j] && dp[i][0][k - c[j]]) || k >= c[j] && dp[i][1][k - c[j]] || dp[i][0][k]) dp[i][j][k] = true;
        }
      }
    }
  }

  int ans_w = 0, ans_s = 0;
  double ma = -100.0;
  for(int i=0; a*100*i <= f; i++) {
    for(int j=0; (a*100*i)+(b*100*j)<=f; j++) {
      int water = (a * 100 * i) + (b * 100 * j);
      RREP(k, 3001) {
        if(dp[(a * i) + (b * j)][1][k] && k + water <= f) {
          double l = ((double)(k) / (double)(water + k)) * 100;
          if(l > ma) {
            ans_w = water + k, ans_s = k;
            ma = l;
          }
          break;
        }
      }
    }
  }

  cout << ans_w << " " << ans_s << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	long long int x, k, d, i, n, m, j,min=0;
	scanf("%lld%lld%lld", &x, &k, &d);
	if (x < 0)
	{
		x = -x;
	}
	n = x / d;
	m = x % d;
	if (m >= d - m)
	{
		j = 1;
		min = d - m;
	}
	else
	{
		j = 0;
		min = m;
	}
	n = n + j;
	if (n >= k)
	{
		i = x - k * d;
		if (i < 0)
		{
			i = -i;
		}
		printf("%lld",i);
	}
	else
	{
		if ((k - n) % 2 == 0)
		{
			printf("%lld", min);
		}
		else
		{
			printf("%lld", d - min);
		}
	}
	return 0;
}

Measured memory_bytes: 1724
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int L = stdIn.nextInt();
        int minAbs = 100 + 200 - 1;
        int t = 0;
        if(L <= 0){
            if(L + n - 1 >= 0);
            else t = L + n - 1;
        }else{
            t = L;
        }
        System.out.println( n * (n + 2 * L -1) / 2 - t );
    }
}

Measured memory_bytes: 21844
#define aaaa 1
#ifdef aaaa
    #include <bits/stdc++.h>
    #ifdef LOCAL
        #include "cxx-prettyprint-master/prettyprint.hpp"
        #define print(x) cout << x << endl
    #else
        #define print(...) 42
    #endif
    using namespace std;
    using ll = long long;
    #define INF 1'010'000'000'000'000'017LL
    #define mod 1000000007LL
    #define eps 0.0001
    #define all(x) (x).begin(), (x).end()
    #define reverse(x) (x).rbegin(), (x).rend()
    #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
    #define rep(i,n)  FOR(i,0,n)
    #define SZ(x) ((ll)(x).size())
    #define sum(x) accumulate(ALL(x), 0LL)//?
    #define pb(x) push_back(x)
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
    public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

#endif
int main() { 
    ll H, W;
    cin >> H >> W;
    ll ans = INF;
    ll a, b, c;
    FOR(x, 1, W+1){
        a = x*H;
        b = (W-x)*(H/2);
        c = (W-x)*(H-H/2);
        chmin(ans, max({a, b, c})-min({a, b, c}));
        b = H*((W-x)/2);
        c = H*((W-x)-(W-x)/2);
        chmin(ans, max({a, b, c})-min({a, b, c}));
    }
    swap(H, W);
    FOR(x, 1, W+1){
        a = x*H;
        b = (W-x)*(H/2);
        c = (W-x)*(H-H/2);
        chmin(ans, max({a, b, c})-min({a, b, c}));
        b = H*((W-x)/2);
        c = H*((W-x)-(W-x)/2);
        chmin(ans, max({a, b, c})-min({a, b, c}));
    }
    cout << ans << endl;
}

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

using namespace std;
int main(void){

	int n,m;
	int a[200];
	int b[200];
	cin >> n;
	cin >> m;
	for(int i=1;i<=2*n;i++){
        a[i]=i;
	}
	int k;
	for(int j=1;j<=m;j++){
        cin >> k;
        if(j%2==1){

            if(k!=0){
                for(int i=1;i<=2*n;i++){
                    if(i<=k)b[i+2*n-k]=a[i];
                    else b[i-k]=a[i];

                }
            }

            else{
                for(int i=1;i<=2*n;i++){
                    if(i<=n)b[2*i-1]=a[i];
                    else if(i>n)b[(i-n)*2]=a[i];
                    }


            }
        }
        else if(j%2==0){
            if(k!=0){
                for(int i=1;i<=2*n;i++){
                    if(i<=k)a[i+2*n-k]=b[i];
                    else a[i-k]=b[i];

                }
            }
            else{
                for(int i=1;i<=2*n;i++){
                    if(i<=n)a[2*i-1]=b[i];
                    else if(i>n)a[(i-n)*2]=b[i];
                    }
            }
        }
	}
	for(int i=1;i<=2*n;i++){


        if(m%2==1)cout << b[i]<<endl;
        else if(m%2==0)cout << a[i]<<endl;
	}


	return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 == 0:
    A_list = []
    for i in range(1, N, 2):
        A_list.extend([i, i])
else:
    A_list = [0]
    for i in range(2, N, 2):
        A_list.extend([i, i])
if A != A_list:
    print(0)
else:
    print(2**(N//2) % (10**9+7))

Measured memory_bytes: 56044
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	map<ll, int> mp;
	rep (i, n) mp[a[i]]++;

	vector<ll> canuse;
	for (auto x: mp) {
		if (x.se >= 4) rep (i, 2) canuse.pb(x.fi);
		else if (x.se >= 2) canuse.pb(x.fi);
	}

	sort(rrng(canuse));

	if (canuse.size() < 2) {
		cout << 0 << endl;
		return 0;
	}
	cout << (ll) canuse[0] * canuse[1] << endl;
	return 0;
}

Measured memory_bytes: 7296
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }.toIntArray()

  val map = mutableMapOf<Int, Int>()
  for (i in 1..n) {
    map.put(i, a[i-1])
  }

  var tmp = 1
  val pushed = mutableSetOf<Int>()
  while (true) {
    if (pushed.contains(tmp)) {
      println(-1)
      return
    }
    pushed.add(tmp)
    tmp = map.get(tmp)!!

    if (tmp == 2) {
      println(pushed.size)
      return
    }

  }

}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int ans = 1, cur = 1;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		ans *= 3;
		if (x & 1) cur *= 1;
		else cur *= 2;
	}
	cout << ans - cur << endl;
	return 0;
}



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

int main(){
  double n,sum=0;
  cin>>n;
  vector<double> num(n);
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>num[i]>>s[i];
    if(s[i]=="JPY") sum+=num[i];
    else sum+=num[i] * 380000.0;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define ALL_OF(v) (v).begin(), (v).end()

int main() {

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

    auto unq = a;
    sort(ALL_OF(unq));
    unq.erase(unique(ALL_OF(unq)), unq.end());
    for (ll &x : a) x = lower_bound(ALL_OF(unq), x) - unq.begin();
    ll diff = 0;
    vector<ll> dp(n, 0), dq(n, 0);
    vector<ll> ans;
    REP(i, n) {
        ll r = n-1-i;
        if (a[i] == a[r]) {
            int si = dp[a[i]] == dq[a[i]];
            dp[a[i]]++;
            dq[a[r]]++;
            diff += (dp[a[i]] == dq[a[i]]) - si;
        } else {
            int si = dp[a[i]] == dq[a[i]];
            int sr = dp[a[r]] == dq[a[r]];
            dp[a[i]]++;
            dq[a[r]]++;
            diff += (dp[a[i]] == dq[a[i]]) - si;
            diff += (dp[a[r]] == dq[a[r]]) - sr;
        }
        if (diff == 0) {
            ans.push_back(i + 1);
        }
    }

    REP(i, ans.size()) cout << ans[i] << " \n"[i+1==ans.size()];

}


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

using namespace std;

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> vec(h+1,vector<char>(w+1));
  for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>vec[i][j];
  rep(i,h+2)rep(j,w+2){
    if(i==0||i==h+1||j==0||j==w+1)cout<<'#';
    else cout<<vec[i][j];
    if(j==w+1)cout<<endl;
  }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

typedef double Double;
const Double EPS = 1e-9;

typedef struct Point {
	Double x, y;
	Point(Double _x, Double _y) : x(_x), y(_y) {}
	
	Point operator + (const Point& a) const {
		return Point(x + a.x, y + a.y);
	}
	
	Point operator - (const Point& a) const {
		return Point(x - a.x, y - a.y);
	}
	
	Point operator * (Double a) const {
		return Point(x * a, y * a);
	}
	
	Point operator / (Double a) const {
		return Point(x / a, y / a);
	}
} Vector;

Double norm(const Point& a) {
	return a.x * a.x + a.y * a.y;
}

Double abs(const Point& a) {
	return sqrt(norm(a));
}

Double dist(const Point& a, const Point& b) {
	return abs(a - b);
}

Vector unit_vector(const Vector& a) {
	return a / abs(a);
}

Double sqr(Double x) {
	return x * x;
}

Double angle(Double a, Double b, Double c) {
	return acos((sqr(b) + sqr(c) - sqr(a)) / (2.0 * b * c));
}

Point rotate(const Point& a, Double s) {
	return Point(a.x * cos(s) - a.y * sin(s),
				 a.x * sin(s) + a.y * cos(s));
}

struct Circle {
	Point c; Double r;
	Circle(Point _c, Double _r) : c(_c), r(_r) {}
};

int circle_intersect(const Circle& a, const Circle& b) {
	Double d = dist(a.c, b.c);
	if (a.r + b.r + EPS < d) return 0;
	if (b.r + d + EPS < a.r) return -3;
	if (a.r + d + EPS < b.r) return -4;
	if (fabs(a.r + b.r - d) < EPS) return 1;
	if (fabs(b.r + d - a.r) < EPS) return 3;
	if (fabs(a.r + d - b.r) < EPS) return 4;
	return 2;
}

vector< Point > cross_point(const Circle& a, const Circle& b) {
	vector< Point > res;
	Point x = unit_vector(b.c - a.c) * a.r;
	int ci = circle_intersect(a, b);
	
	if (ci > 0) {
		if (ci != 2) {
			res.push_back(a.c + x);
		} else {
			Double s = angle(b.r, dist(a.c, b.c), a.r);
			res.push_back(a.c + rotate(x, s));
			res.push_back(a.c + rotate(x, -s));
		}
	}
	
	return res;
}

int N;
vector< Circle > vc;

bool inter(const Point& a, const Circle& c) {
	Double d = dist(a, c.c);
	return d < c.r + EPS;
}

void solve() {
	vector< Point > vp;
	for_(i,0,N) vp.push_back(vc[i].c);
	
	for_(i,0,N) for_(j,i+1,N) {
		vector< Point > add = cross_point(vc[i], vc[j]);
		for_(k,0,size_of(add)) vp.push_back(add[k]);
	}
	
	int ans = 0;
	for_(i,0,size_of(vp)) {
		int cnt = 0;
		for_(j,0,N) if (inter(vp[i], vc[j])) ++cnt;
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> N, N) {
		vc.clear();
		
		for_(i,0,N) {
			Double x, y; scanf("%lf,%lf", &x, &y);
			vc.push_back(Circle(Point(x, y), 1.));
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1368
import sys

N = int(input())
evid_lst = []
for i in range(N):
    tmp_a = int(input())
    tmp_lst = []
    for j in range(tmp_a):
        tmp_lst.append(tuple(map(int, input().split())))
    evid_lst.append(tmp_lst)

honest_sets = []
for i in range(2 ** N - 1, 0, -1):
    honest_expect = set()
    for j in range(N):
        if ((i >> j) & 1):
            honest_expect.add(j + 1)
    honest_sets.append(honest_expect)

honest_sets.sort(key=lambda x: -len(x))
for h in honest_sets:
    flag = False
    for i in h:
        for evid in evid_lst[i - 1]:
            if evid[1] == 0:
                if evid[0] in h:
                    flag = True
                    break
            else:
                if not evid[0] in h:
                    flag = True
                    break
        if flag:
            break
    if not flag:
        print(len(h))
        sys.exit()
print(0)


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int>er(n+1, 0), wr(n+1, 0);
  for(int i=1; i<=n; i++)wr[i]=wr[i-1]+(s[i-1]=='W');
  for(int i=n-1; i>=0; i--)er[i]=er[i+1]+(s[i]=='E');
  for(int i=0; i<=n; i++)cerr << wr[i] << ' ';
  cerr << endl;
  for(int i=0; i<=n; i++)cerr << er[i] << ' ';
  cerr << endl;
  int r=10000000;
  for(int i=0; i<n; i++)r=min(r, wr[i]+er[i+1]);
  cout << r;
  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  ll sum = 0;
  ll hsum = 0;
  REP(i, N){
    cin >> A[i];
    sum += A[i];
    if(i % 2 == 0){
      hsum += A[i];
    }
  }
  sum /=2;
  vector<ll> ans(N);
  ans[0] = hsum - sum;
  FOR(i, 1, N){
    ans[i] = A[i-1] - ans[i-1];
  }
  REP(i, N){
    cout << 2*ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2432
class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[2], dice[1], dice[3], dice[4] ]
    @bottom = dice[5]
  end

  def roll(action)
    b = @bottom
    u = @top
    case action
    when "N"
      @top   = @side[2]
      @bottom  = @side[0]
      @side[2] = b
      @side[0] = u
    when "E"
      @top   = @side[3]
      @bottom  = @side[1]
      @side[3] = b
      @side[1] = u
    when "S"
      @top   = @side[0]
      @bottom  = @side[2]
      @side[0] = b
      @side[2] = u
    when "W"
      @top   = @side[1]
      @bottom  = @side[3]
      @side[1] = b
      @side[3] = u
    end
  end

  def aaaaa(sub)
    i = 0
    while true
      if self.south == sub.south
        4.times do
          if self.all_num == sub.all_num
            puts "Yes"
            return
          end
          self.roll("E")
        end
      end
      if i > 6
        puts "No"
        return
      elsif i == 3
        self.roll("E")
        self.roll("N")
      else
        self.roll("N")
      end
      i += 1
    end
  end

  def top
    @top
  end

  def bottom
    @bottom
  end

  def north
    @side[0]
  end

  def east
    @side[1]
  end

  def south
    @side[2]
  end

  def west
    @side[3]
  end

  def all_num
    [@top, @bottom, @side[2], @side[1], @side[3], @side[4]]
  end
end

d = Dice.new(gets.split.map(&:to_i))
sub = Dice.new(gets.split.map(&:to_i))

d.aaaaa(sub)

Measured memory_bytes: 6128
#include <stdio.h>
int main(void){
	int x,a,b,s,t;
	scanf("%d%d%d",&x,&a,&b);
	s=(x>a ? x-a : a-x);
	t=(x>b ? x-b : b-x);
	s<t ? printf("A") : printf("B");
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vll = vector<long long>;

int main(){
  string s; cin >> s;
  int n = s.size();
 
    int cnt = 0;
    for(int i = 0; i < n/2; i++){
      if(s[i] != s[n-1-i]){cnt++;}
    }
    cout << cnt << endl;
  
  
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>

int main() {
	long long int i, j = 1, n, m, fibo = 1, fi = 1, f = 0, a[100000], sum = 1;
	bool flag = true;

	// 壊れている床の数
	scanf("%lld %lld", &n, &m);

	// 壊れている床の段
	a[0] = -1;
	for (i = 1; i <= m; i++) {
		scanf("%lld", &a[i]);
	}

	// 登れるかチェック
	for (i = 1; i <= m; i++) {
		if (a[i] - a[i - 1] == 1) {
			printf("0\n");
			return 0;
		}
	}

	for (i = 1; i <= n; i++) {
		flag = true;
		for (j = 1; j <= m; j++) {
			if (a[j] == i) {
				a[j] = 0;
				flag = false;
				sum = (sum * fibo) % 1000000007;
				fibo = 1;
				fi = 1;
				f = 0;
				i++;
				break;
			}
		}
		if (flag == true) {
			fibo = (fi + f) % 1000000007;
			f = fi;
			fi = fibo;
		}
	}
	sum = (sum * fibo) % 1000000007;

	printf("%lld\n", sum % 1000000007);

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int myfind(int a, vector<int>& relation) {
    if (relation[a] == a) return a;
    int res = myfind(relation[a], relation);
    relation[a] = res;
    return res;
}

void myunion(int a, int b, vector<int>& relation) {
    int ta = myfind(a, relation);
    int tb = myfind(b, relation);
    if (ta == tb) return;
    relation[ta] = tb;
}

int main() {        
    int n, m;
    cin >> n >> m;
    vector<int> relation(n + 1, 0);
    vector<vector<int>> lang(m + 1, vector<int>(0));
    for (int i = 1; i <= n; i++) {
        relation[i] = i;
    }
    for (int i = 1; i <= n; i++) {
        int k;
        cin >> k;
        for (int j = 1; j <= k; j++) {
            int curr;
            cin >> curr;
            lang[curr].push_back(i);
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < (int)lang[i].size() - 1; j++) {
            myunion(lang[i][j], lang[i][j + 1], relation);
        }
    }
    vector<int> res(n + 1, 0);
    int last = -1;
    for (int i = 1; i <= n; i++) {
        res[i] = myfind(i, relation);
        if (last != -1) {
            if (res[i] != last) {
                cout << "NO" << endl;
                return 0;
            }
        }
        last = res[i];
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9860
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000 + 7)



int main(void)
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    map<ll, vector<ll>> m;
    m[0].push_back(0);
    ll S = (A[0]+K-1)%K;
    m[S].push_back(1);
    SREP(i, 1, N) {
        S = (S + A[i] + K - 1) % K;
        m[S].push_back(i+1);
    }
    ll cnt = 0;
    for (auto &&i : m)
    {
        ll j = 0;
        REP(k, i.second.size()) {
            while(i.second[k] - i.second[j] >= K)
                j++;
            cnt += k - j;
        }
        
    }
    cout << cnt << endl;
}


Measured memory_bytes: 23680
import java.util.*;
import java.math.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int x = stdIn.nextInt();
    int[] l = new int[n];
    for(int i = 0;i<n;i++) {
      l[i] = stdIn.nextInt();
    }
    int count = 0;
    int current = 0;
     while(true) {
       if(current<=x) {
         count += 1;
         if(count-1==l.length) break;
         current = current + l[count-1];
       } else {
         break;
       }
     }
     System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main (void) {
   string a, b, c;
   cin >> a >> b >> c;
   
   int d = 'A' - 'a';
   
   string ans = "";

   ans += (a[0] + d);
   ans += (b[0] + d);
   ans += (c[0] + d);

   cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		while(sc.hasNext()){
			new aoj0062().doIt();
		}
	}
	void sum(int a[],int length){
		if(length > 1){
			for(int i = 0;i < length - 1;i++){
				a[i] = (a[i] + a[i+1])%10;
			}
			sum(a,length-1);
		}
	}
	class aoj0062 {	
		void doIt() {
			long str = sc.nextLong();
			int [] a = new int [10];
			for(int i = 9;i >= 0;i--){
				a[i] = (int) (str %10);
				str = str / 10;
			}
			sum(a,10);
			System.out.println(a[0]);
		}
	}
}

Measured memory_bytes: 17180
#include <iostream>
using namespace std;
 
int main() {
 
	//code_goes_here-->
 
	long long  x;
	cin>>x;
 
	long long k =  1;
 
	while((k*x) % 360 != 0){
		k++;
	}
 
	cout<<k;
 
	return 0;
}

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

class FordFullkerson{
    using type=int;
    const int INF=1e9;
    struct Edge{
        int to;
        type cap;
        int rev;
        Edge(int _t,type _c,int _r):to(_t),cap(_c),rev(_r){}
    };

    using Graph=vector<vector<Edge>>;
    int V;
    Graph G;

    vector<bool> usd;

    type dfs(int v,int t,type f){
        if(v==t) return f;
        usd[v]=true;
        for(auto &e:G[v]){
            if(!usd[e.to] && e.cap>0){
                auto d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    public:
    FordFullkerson(int _v) : V(_v),G(_v),usd(_v){}
    void add(int from,int to,type cap){
        G[from].push_back(Edge{to,cap,(int)(G[to].size())});
        G[to].push_back(Edge{from,0,(int)(G[from].size())-1});
    }

    type maxFlow(int s,int t){
        type ret=0;
        while(true){
            for(int i=0;i<(int)(G.size());i++){
                usd[i]=false;
            }
            type f=dfs(s,t,INF);
            if(f==0) return ret;
            ret+=f;
        }
    }

};

using Graph=vector<vector<int>>;

void dfs(int v,Graph& g,vector<int>& used){
    if(used[v]) return;
    used[v]=true;
    for(auto to:g[v]) dfs(to,g,used);
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> x(m),y(m);
    for(int i=0;i<m;i++) cin>>x[i]>>y[i],x[i]--,y[i]--;
    vector<vector<int>> xi(n);
    vector<vector<int>> yi(n);
    for(int i=0;i<m;i++) xi[x[i]].push_back(i);
    for(int i=0;i<m;i++) yi[y[i]].push_back(i);

    // partMax

    Graph g(m);
    for(int i=0;i<m;i++){
        for(auto to:xi[x[i]]){
            g[i].push_back(to);
        }
        for(auto to:yi[y[i]]){
            g[i].push_back(to);
        }
    }

    vector<int> used(m);
    int cnt=0;
    for(int i=0;i<m;i++){
        if(!used[i]){
            dfs(i,g,used);
            cnt++;
        }
    }
    int ansMax=m-cnt;

    // partMin
    int z=0;
    FordFullkerson flow(2*n+2);
    int S=2*n;
    int T=2*n+1;

    for(int i=0;i<n;i++){
        flow.add(S,i,1);
    }
    for(int i=0;i<n;i++){
        flow.add(n+i,T,1);
    }
    for(int i=0;i<m;i++){
        flow.add(x[i],n+y[i],1);
    }

    int ret=flow.maxFlow(S,T);
    int ansMin=m-ret;

    cout<<ansMin<<" "<<ansMax<<endl;

    return 0;
}


Measured memory_bytes: 7308
//#include"bits/stdc++.h"
#include<algorithm>
#include<cassert>
#include<cmath>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define MP make_pair
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl
const int INF=(int)2e9+9;
const int SIZE=(int)2e5+5;
//Brute force answers(BINARY SEARCH) symmetry
//Change perspective
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=n-1;
    while(1){
        while(r>l){
           if(s[l]=='W'){
                break;
           } 
           l++;
        }
        while(r>l){
           if(s[r]=='R'){
                break;
            } 
            r--;
        }
        swap(s[l],s[r]);
        //cout<<
        if(r==l)
            break;
        ans++;
    }
    cout<<ans;    
} 

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

int max_plus(vector<int> n){
  int a=-100;
  for(int i=0;i<n.size();i++){
    if(a<n.at(i))a=n.at(i);
  }
  return a+1;
}

int min(vector<int> n){
  int a=100;
  for(int i=0;i<n.size();i++){
    if(a>n.at(i))a=n.at(i);
  }
  return a;
}

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> X(n),Y(m);
  for(int i=0;i<n;i++)cin >> X.at(i);
  for(int i=0;i<m;i++)cin >> Y.at(i);
  if(max_plus(X)>min(Y)){
    cout << "War" << endl;
    return 0;
  }
  if(x>=max_plus(X) || max_plus(X)>=y){
    cout << "War" << endl;
    return 0;
  }
  cout << "No War" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int C;
  int D;
  
  int L;
  int R;
  
  cin >> A >> B >> C >> D;

  L = A+B;
  R = C+D;
  
 if(L>R){
    cout << "Left" << endl;
  }else if(L==R){
    cout << "Balanced" << endl;
  }else{
   cout << "Right" << endl;
 }
}

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

int counter(int x) {
    return x == 0 ? 0 : counter(x >> 1) + (x & 1);
}

int main() {
    int N;
    cin >> N;

    int X[N][N];
    int Y[N][N];
    int A[N];
    for (int i = 0; i < N ; ++i) {
        cin >> A[i];
        for (int j = 0; j < A[i]; ++j) {
            int x, y;
            cin >> x >> y;
            X[i][j] = x - 1;
            Y[i][j] = y;
        }
    }

    int ans = 0;
    // combination bits
    for (int bit=0; bit < (1 << N); ++bit) {
        bool ok = true;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                for (int j = 0; j < A[i]; ++j) {
                    if ( ((bit >> X[i][j]) & 1) ^ Y[i][j]) ok=false;
                }
            }
        }
        if (ok) ans = max(ans, counter(bit));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int pr(int a){
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return 0;
	}
	return 1;
}
int main(){
	int a;scanf("%d",&a);
	while(1){
		if(pr(a)){
			printf("%d\n",a);return 0;
		}
		a++;
	}
}

Measured memory_bytes: 128
function Main(input){
  var inp = input.split('\n');
  var inp1 = [];

// N, C, S, F を取得
  for(var i = 0; i < inp.length; i++){
    inp1.push(inp[i].split(' ').map((n) => { return parseInt(n) }));
  }
  var N = inp1[0][0];
  var C = [];
  var S = [];
  var F = [];
  for(var i = 1; i < inp1.length; i++){
    C.push(inp1[i][0]);
    S.push(inp1[i][1]);
    F.push(inp1[i][2]);
  }

// 
  for(var i = 0; i < N; i++){
    var t = 0;
    for(var j = i; j < N - 1; j++){
      if(t < S[j]){
        t = S[j];
      } else if(t % F[j] === 0){
        t = t;
      } else {
        t = t + F[j] - (t % F[j]);
      }
      t += C[j];
    }
    console.log(t);
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11168
n=int(input())
X=[]
i=0
while n!=0:
    t=2**i
    if n%(2*t)==0:
        X.append('0')
    else:
        X.append('1')
        if i%2:
            n+=t
        else:
            n-=t
    i+=1
if X==[]:
    print(0)
else:
    print(''.join(X[::-1]))

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

int N,A;
vector<ll> d;
ll dp[50][5001];

int i=0;

int main(){
    cin>>N>>A;
    for(int i=0;i<N;i++){
        ll x;
        cin>>x;
        x-=A;
        d.push_back(x);
    }

    dp[0][2500]++;
    dp[0][2500+d.at(0)]++;

    for(int i=1;i<N;i++){
        for(int j=0;j<5001;j++){
            dp[i][j]+=dp[i-1][j];
            if(0<=j-d.at(i) && j-d.at(i)<=5000) dp[i][j]+=dp[i-1][j-d.at(i)];
        }
    }

    cout<<dp[N-1][2500]-1<<endl;

    



}

Measured memory_bytes: 2176
x,k,d = map(int,input().split())

if k*d < abs(x):
    print(abs(x)-k*d)
else:
    t = abs(x)//d
    a = (k-t)%2
    b = abs(x) - t*d
    #print(t,a,b)
    if a == 0:
        print(b)
    else:
        if abs(b+d) < abs(b-d):
            print(abs(b+d))
        else:
            print(abs(b-d))

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

bool valid(vector<pair<int, int> >& a, vector<pair<int, int> >& b){
    rep(i, (int)a.size())if(a != b)return false;
    return true;
}

void roll90(vector<pair<int, int> >& poly){
    for(auto& x: poly)x = {x.second, -x.first};
}

vector<int> solve(vector<vector<pair<int, int> > >& polys){
    vector<int> res;
    for(int i=1; i<=(int)polys.size(); ++i){
        if(polys[0].size() != polys[i].size())continue;
        rep(j, 8){
            if(j == 4)reverse(all(polys[i]));
            if(valid(polys[0], polys[i])){
                res.push_back(i);
                break;
            }
            roll90(polys[i]);
        }
    }
    return res;
}

int main(){
    for(int n; cin >> n, n; cout << "+++++\n"){
        vector<vector<pair<int, int> > > polys(n+1);
        rep(i, n+1){
            int m, px, py;
            cin >> m >> px >> py;
            m--;
            rep(j, m){
                int x, y;
                cin >> x >> y;
                polys[i].emplace_back(px - x, py - y);
                px = x; py = y;
            }
        }
       for(auto x: solve(polys))cout << x << '\n';
    }
    return 0;
}

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

// https://atcoder.jp/contests/abc135/submissions/6583759 を参考

int main() {
    string s, t;
    cin >> s >> t;

    // KMP法でtをいっぱい並べた文字列の先頭から何文字が含まれるかを調べる
    string tk, sk;
    while(tk.size() < s.size() + t.size()){
        tk += t;
    }
    while(sk.size() < s.size() + t.size() * 2){
        sk += s;
    }
    // sk.size() > tk.size() >= 2 * t.size()

    // KMP_table を作成
    int n = tk.size();
    vector<int> table(n + 1, -1);
    int j = -1;
    for(int i = 0; i < n; ++i){
        while(j >= 0 && tk[i] != tk[j]){
            j = table[j];
        }
        j++;
        table[i+1] = j;
    }

    // KMP法
    int cur = 0, mx = 0;
    for(char x : sk){
        while(cur >= 0 && tk[cur] != x){
            cur = table[cur];
        }
        ++cur;
        mx = max(mx, cur);
        if(cur == n) break;
    }

    int ans = -1;
    if(mx < (s.size() + t.size())){
        ans = mx / t.size();
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11464
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N+2)
C = [0]*(N+2)
for i in range(1,N+1):
    B[i] = max(A[i-1], B[i-1])
    C[-i-1] = max(A[-i], C[-i])
for i in range(1,N+1):
    print(max(B[i-1], C[i+1]))

Measured memory_bytes: 16576
N=parse(readline())
KACHI=parse.(split(readline()))
KACHI=sort!(KACHI)
other=min(KACHI...)
global min_count=0
global new_g=0
for i in KACHI
    if i==other
       global base_g=i
       min_count+=1
    else
       global new_g=(base_g+i)/2
       base_g=new_g
    end
end
    if min_count==N
        println(other)
    else
        println(new_g)
    end
  



Measured memory_bytes: 178936
#include<stdio.h>
#include<string.h>
#define N 1046527
#define NIL -1
#define L 14

char H[N][L];

int get(char ch){
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

long long Key(char str[]){
    long long s=0,t=1,i;
    for(i=0;i<strlen(str);i++){
        s+=t*(get(str[i]));
        t*=5;
    }
    return s;
}

int h1(int key){return key%N;}

int h2(int key){return 1+(key%(N-1));}

int find(char str[]){
    long long key,h,i;
    key=Key(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%N;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,h,i;
    key=Key(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%N;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int n,i,h;
    char str[L],str2[9];
    for(i=0;i<N;i++) H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",str2,str);

        if(str2[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16104
#include<iostream>
#include<vector>
using namespace std;
int n,k,a[1000];
long sum[1001];
vector<long>s;
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)s.push_back(sum[j]-sum[i]);
	}
	long ans=0;
	for(int i=50;i>=0;i--)
	{
		vector<long>tmp;
		for(int j=0;j<s.size();j++)
		{
			if(s[j]>>i&1)tmp.push_back(s[j]);
		}
		if(tmp.size()>=k)
		{
			s=tmp;
			ans|=1LL<<i;
		}
	}
	cout<<ans<<endl;
}


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

long long n, k, a[100005], p;

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

Measured memory_bytes: 1024
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] mat = new int[n][n];
		int cost = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				mat[i][j] = in.nextInt();
			}
		}
		Set<Integer> mst = new HashSet<>();
		Set<Integer> target = new HashSet<>();
		mst.add(0);
		for (int i = 1; i < n; i++) {
			target.add(i);
		}

		while (!target.isEmpty()) {
			int min = Integer.MAX_VALUE;
			int nextVisitTo = -1;
			int nextVisitFrom = -1;
			for (int from : mst) {
				for (int to : target) {
					if (mat[from][to] != -1 && mat[from][to] <= min) {
						nextVisitFrom = from;
						nextVisitTo = to;
						min = mat[from][to];
					}
				}
			}
			target.remove(nextVisitTo);
			mst.add(nextVisitTo);
			cost += mat[nextVisitFrom][nextVisitTo];
		}
		System.out.println(cost);

	}

}



Measured memory_bytes: 42104
# ABC109C - Skip
def gcd(a: int, b: int) -> int:
    while a:
        a, b = b % a, a
    return b


def main():
    N, X, *A = map(int, open(0).read().split())
    ans = abs(X - A[0])
    for i in A:
        dif = abs(X - i)
        if dif % ans:
            ans = gcd(ans, dif)
    print(ans)


if __name__ == "__main__":
    main()

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

typedef long long LL;
const int maxn = 1e5+100;

int n;
LL L;
LL A[maxn];


bool solve()
{
    int p = -1;
    for(int i = 1;i <= n-1;++i)
        if(A[i] + A[i+1] >= L)
        {
            p = i;
            break;
        }

    if(p == -1) return false;
    puts("Possible");
    for(int i = 1;i < p;++i)
        printf("%d\n",i);
    for(int i = n-1;i > p;--i)
        printf("%d\n",i);
    printf("%d\n",p);
    return true;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %lld",&n,&L);
    for(int i = 1;i <= n;++i)
        scanf("%lld",&A[i]);


    if(!solve())
        puts("Impossible");
    else
    {
    }

    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	string str;
	cin >> str;
	int cnt = 0;
	if (str[0] == 'R' && str[1] == 'R' && str[2] == 'R')
		cnt = 3;
	else if (str[0] == 'R' && str[1] == 'R')
		cnt = 2;
	else if (str[1] == 'R' && str[2] == 'R')
		cnt = 2;
	else if (str[0] == 'R' || str[1] == 'R' || str[2] == 'R')
		cnt = 1;
	cout << cnt;
}

Measured memory_bytes: 3648
package main

import "fmt"

var array = [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

func main() {
	var K int
	fmt.Scanln(&K)
	result := array[K-1]
	fmt.Println(result)
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
using namespace std;

int main(){
    string str,sub_str;
    int n=0,t;
    stringstream ss;

    while(getline(cin,str)){
        for(int i=0;i<str.length();i++){
            if(isdigit(str[i])){
                t=i;
                while(isdigit(str[++t]));
                sub_str=str.substr(i,t-i);
                i=t;
                ss<<sub_str;
                ss>>t;
                ss.clear();
                n+=t;
            }
        }
    }

    cout<<n<<endl;
}

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

typedef long long ll;
 
 



int main()
{
    //freopen("in.txt", "r", stdin);
    
    int a,b,c;
    cin>>a>>b>>c;

    if(a+b+c>=22)
        cout<<"bust";
    else
        cout<<"win";


    return 0;
}




    

  

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

vector<int>graph[(int)2e6];
vector<int>cnt((int)2e6,0);
vector<int>visit((int)2e6,0);

void dfs(int s)
{
	visit[s]=true;
	for (int i=0;i<graph[s].size();i++)
	{
		if (!visit[graph[s][i]])
		{
			cnt[graph[s][i]]+=cnt[s];
			dfs(graph[s][i]);
		}
	}
}

int main()
{
	int N,Q;cin >> N >> Q;
	int a,b;
	for (int i=0;i<N-1;i++)
	{
		cin >> a >>b;
		a--;b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (int i=0;i<Q;i++)
	{
		cin >> a >>b;
		a--;
		cnt[a]+=b;
	}
	dfs(0);
	for (int i=0;i<N;i++) cout << cnt[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 80512
#include<iostream>
 using namespace std ;
 int main()
{
 int A,B,C;
 cin>>A;
 cin>>B;
 cin>>C;
 if ((A+B)>=C)
 {
 cout << "Yes"<< endl;
 }
 else {
 cout <<"No" << endl;
 }
 
}

Measured memory_bytes: 3620