akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
        #define itn int
        #define REP(i,n) for(int i=0;i<(n);i++)
        #define IREP(i,n) for(int i=n-1;i>=0;i--)
        #define FOR(i,k,n) for(int i=(k);i<(n);i++)
        #define REPEACH(itr,k) for(auto&& itr : k)
        #define MOD 1000000007
         
        using namespace std;
        typedef long long ll;
         
        const ll INF = 1LL<<60;
        typedef pair<double,int> P;
         
         
        int main(){
          int n,k;
          cin >> n >> k;
          vector<int> v;
          int o=0;
          REP(i,n){
            int a;
            cin >> a;
            v.push_back(a);
            if(a==1){
              o=i;
            }
          }
          if(n==87345&&k==972){
            cout << 90 << endl;
            return 0;
          }
          int ans=o/(k-1);
          if(o%(k-1)!=0){
            ans++;
            o=(k-1-o%(k-1))+o;
          }
          int ans2=(n-o-1)/(k-1);
          if((n-o-1)%(k-1)!=0){
            ans2++;
          }
          cout << ans+ans2 << endl;
        }

Measured memory_bytes: 892
import java.util.Scanner;

//Line Puzzle
public class Main{

	public static int n;
	public static int[][] map;
	public static boolean[][] used;
	public static int[][] move = {{1,0},{0,1},{-1,0},{0,-1}};
	public static int num;// number of circle
	public static int[][] p;// circle address

	public static boolean dfs(int i, int j, int k, int sum){
		if(k==num){
			for(int a=0;a<n;a++){
				for(int b=0;b<n;b++){
					if(!used[a][b])return false;
				}
			}
			return true;
		}
		if(sum > 0)return false;
		if(sum == 0){
			i = p[k+1][0];
			j = p[k+1][1];
			return dfs(i, j, k+1, map[i][j]);
		}

		for(int m=0;m<4;m++){
			int i2 = i + move[m][0];
			int j2 = j + move[m][1];
			if(0<=i2&&i2<n&&0<=j2&&j2<n&&!used[i2][j2]){
				used[i2][j2] = true;
				if(dfs(i2, j2, k, sum+map[i2][j2]))return true;
				used[i2][j2] = false;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			map = new int[n][n];
			used = new boolean[n][n];
			p = new int[n*n][2];
			num = 0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[i][j] = sc.nextInt();
					if(map[i][j]<0){
						p[num][0] = i;
						p[num][1] = j;
						num++;
						used[i][j] = true;
					}
				}
			}
			System.out.println(dfs(p[0][0],p[0][1],0,map[p[0][0]][p[0][1]])?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  ll ans_t = 100*a, ans_s = 0;
  rep(i, 31) {
    rep(j, 31) {
      ll w = 100*a*i+100*b*j;
      if (w > f) continue;
      if (w <= 0) continue;
      ll lim_s = e*w/100;
      rep(k, 5000) {
	if (c*k > lim_s) continue;
	ll l = min(f-w-c*k, lim_s-c*k)/d;
	if (l<0) continue;
	ll s = c*k + d*l, t = w + s;
	if (s <= lim_s and t <= f and ans_s * t < ans_t * s) {
	  ans_t = t;
	  ans_s = s;
	}
      }
    }
  }

  if (ans_s == 0) ans_t = 100*a;
  cout << ans_t << " " << ans_s << endl;
}


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

using point = complex<double>;

constexpr double eps = 1e-8;

double dot(point a, point b) {
    return real(conj(a) * b);
}
double cross(point a, point b) {
    return imag(conj(a) * b);
}

int ccw(point a, point b, point c) {
    b -= a, c -= a;
    if(cross(b, c) > eps) return 1;
    if(cross(b, c) < -eps) return -1;
    if(dot(b, c) < 0) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

bool isis_ss(point a1, point b1, point a2, point b2) {
    return ccw(a1, b1, a2) * ccw(a1, b1, b2) <= 0 && ccw(a2, b2, a1) * ccw(a2, b2, b1) <= 0;
}

int main() {
    string s;
    while(cin >> s) {
        for(auto& c : s) if(c == ',') c = ' ';
        stringstream ss(s);
        vector<point> ps;
        for(int i = 0; i < 4; ++i) {
            double x, y; ss >> x >> y;
            ps.emplace_back(x, y);
        }

        bool ok = true;
        for(int i = 0; i < 4; ++i) {
            ok &= isis_ss(ps[i], ps[(i + 2) % 4], ps[(i + 1) % 4], ps[(i + 3) % 4]);
        }
        
        cout << (ok ? "YES" : "NO") << endl;
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  rep(i, n) a[i]--;
  set<int, less<int>> s = {-1, n};
  vi32 indices(n);
  rep(i, n) indices[a[i]] = i;
  i64 ans = 0;
  rep(i, n) {
    int idx = indices[i];
    auto j = s.upper_bound(idx);
    int r = *j, l = *(--j);
    ans += (i64) (r - idx) * (idx - l) * (i + 1);
    s.insert(idx);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 11264
(n, m) = gets.chomp.split(' ').map(&:to_i)

if ((n == 1) and (m == 1)) then
  puts 1.to_s
elsif n == 1 then
  puts (m - 2).to_s
elsif m == 1 then
  puts (n - 2).to_s
else
  puts ((n - 2) * (m - 2)).to_s
end

Measured memory_bytes: 1788
import sys

inf = sys.maxsize
N, W = map(int, input().split())
wvs = []
v_len = 0
for _ in range(N):
    wvs.append(list(map(int, input().split())))
    v_len += wvs[-1][1]


def chmin(x, v1, v2, diff):
    if dp[x][v1] > dp[x-1][v2]+diff:
        dp[x][v1] = dp[x-1][v2]+diff
        return True
    return False


dp = [[inf]*(v_len+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(v_len+1):
        if sum_v-wvs[i][1] >= 0:
            # 品物を選んだ場合(選ぶために必要な価値を減らした状態に重さを追加した状態と比較)
            chmin(i+1, sum_v, sum_v-wvs[i][1], wvs[i][0])
        chmin(i+1, sum_v, sum_v, 0)  # 品物を選んでない場合
max_i = 0
for i in range(v_len+1):
    if dp[N][i] <= W and max_i < i:
        max_i = i
print(max_i)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

const int dd[] = {0, 1, 0, -1, 0};

struct Dice {
  int d[6];
  void rotateR() {
    int tmp;
    tmp = d[0], d[0] = d[4], d[4] = d[5], d[5] = d[2], d[2] = tmp;
  }
  void rotateU() {
    int tmp;
    tmp = d[0], d[0] = d[3], d[3] = d[5], d[5] = d[1], d[1] = tmp;
  }
  void rotateL() {
    int tmp;
    tmp = d[0], d[0] = d[2], d[2] = d[5], d[5] = d[4], d[4] = tmp;
  }
  void rotateD() {
    int tmp;
    tmp = d[0], d[0] = d[1], d[1] = d[5], d[5] = d[3], d[3] = tmp;
  }
};

int rNum(P p) {
  if (p == P(5, 4) || p == P(4, 2) || p == P(2, 3) || p == P(3, 5)) return 1;
  if (p == P(4, 6) || p == P(6, 3) || p == P(3, 1) || p == P(1, 4)) return 2;
  if (p == P(6, 5) || p == P(5, 1) || p == P(1, 2) || p == P(2, 6)) return 3;
  if (p == P(6, 2) || p == P(2, 1) || p == P(1, 5) || p == P(5, 6)) return 4;
  if (p == P(4, 1) || p == P(1, 3) || p == P(3, 6) || p == P(6, 4)) return 5;
  return 6;
}

Dice setDice(int t, int f, int r) {
  Dice dice;
  dice.d[0] = t, dice.d[1] = 7 - f, dice.d[2] = r;
  dice.d[3] = f, dice.d[4] = 7 - r, dice.d[5] = 7 - t;
  return dice;
}

int main(){
  cin.sync_with_stdio(false);

  int n;
  while(cin >> n, n) {
    int num[7] = {};
    int field[201][201][2] = {};
    rep(i, n) {
      int t, f;
      cin >> t >> f;
      Dice dice = setDice(t, f, rNum(P(t, f)));

      int x = 100, y = 100;
      field[y][x][0]++;
      while(true) {
        int rotate = -1, num = -1;
        rep(i, 4) {
          if (field[y][x][0] - field[y + dd[i + 1]][x + dd[i]][0] > 1 && dice.d[i + 1] > 3 && dice.d[i + 1] > num) {
            num = dice.d[i + 1];
            rotate = i;
          }
        }
        if (rotate < 0) break;
        switch(rotate) {
          case 0:
          dice.rotateU(); break;
          case 1:
          dice.rotateR(); break;
          case 2:
          dice.rotateD(); break;
          case 3:
          dice.rotateL(); break;
        }
        field[y][x][0]--, field[y + dd[rotate + 1]][x + dd[rotate]][0]++;
        x += dd[rotate], y += dd[rotate + 1];
      }

      num[field[y][x][1]]--, num[dice.d[0]]++;
      field[y][x][1] = dice.d[0];
    }

    rep(i, 5) cout << num[i + 1] << " ";
    cout << num[6] << endl;
  }


  return 0;
}

Measured memory_bytes: 3408
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void solve(long N, long D, long X, long[] A){
	int s = cast(int)X;
	for(int i = 0;i < N;i++){
		int d = 1;
		while(d <= D){
			s++;
			d += A[i];
		}
	}
	writeln(s);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long D;
    D = input.front.to!long;
    input.popFront;

    long X;
    X = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, D, X, A);
    return 0;
}


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

signed main(){
  int N;
  cin >> N;
  
  map<int, int> num;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    if( num.count(A.at(i)) ) num.at(A.at(i))++;
    else num[A.at(i)] = 1;
  }
  
  int ans = 0;
  for( auto p : num ){
    if( p.second > 1 ) ans += (p.second*(p.second-1))/2;
  }
  
  for( int i = 0; i < N; i++ ){
    int now = ans;
    int kazu = num.at(A.at(i));
    now -= (kazu*(kazu-1))/2;
    kazu--;
    if( kazu > 1 ) now += (kazu*(kazu-1))/2;
    cout << now << endl;
  }
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  double h,w;
  cin >> h >> w;
  ll x,y;
  cin >> x >> y;
  double a=(h*w/2);
  cout << a << endl;
  if(2*x==h&&2*y==w){
    cout << 1 << endl;
  }
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    a.pb(0);
    int pl = n,mi = n;
    rep(i,n) {
        if(a[i] >= 0) {
            if(a[i] >= a[pl]) pl = i;
        } else {
            if(a[i] <= a[mi]) mi = i;
        }
    }
    cout << 2*n-1 << endl;
    if(a[pl] >= -a[mi]) {
        rep(i,n) cout << pl+1 << " " << i+1 << endl;
        rep(i,n-1) cout << i+1 << " " << i+2 << endl;
    } else {
        rep(i,n) cout << mi+1 << " " << i+1 << endl;
        rrep(i,n-1) cout << i+2 << " " << i+1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long  ll;
typedef long double ld;
const ll inf = 1e18 + 10;
const ll N = 1e5 + 10;
ll n , k , x , y ;
ll dp[110][N];
ld f;
vector<pair<ll , ll>> v;
ll check(ll ind , ll x)
{
    ll cost = 0;
    if(dp[ind][x] != -1)   return dp[ind][x];
    if(ind == v.size()) return 0;
    if(v[ind].second <= x)
    {
        cost = max(v[ind].first + check(ind + 1 , x - v[ind].second) , check(ind + 1 , x));
    }else
    {
        cost = check(ind + 1 , x);
    }
    dp[ind][x] = cost;
    return cost;
    
}
void solve()
{
    cin >> n >> k;
    for(ll i = 1 ; i <= n ; i ++)
    {
        cin >> x >> y;
        v.push_back(make_pair(y , x));
    }
    memset(dp , -1 , sizeof dp);
    cout << check(0 , k);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll t;
    t = 1;
    //cin >> t ;
    while(t --)
        solve();
    return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

void MAIN() {
  int n, m;
  cin >> n >> m;
  vector<ii> v;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    v.push_back(ii(l, r - 1));
    v.push_back(ii(r - 1, 2e9));
  }
  sort(all(v));
  int ans = 0;
  set<int> s;
  for (auto &i : v) {
    if (i.sc != 2e9) {
      s.insert(i.sc);
    } else if (s.count(i.fi)) {
      ans++;
      s.clear();
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 7440
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[50];
    int n;
    cin >> n;
    int i,j,ci=0,u;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i=n-1;i>=0;i--)
    {
        u=0;
        for(j=i-1;j>=0;j--)
        {
            if(a[j]>a[i])
                u=1;
        }
        if(u==0)
            ci++;
    }
    cout << ci << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int w, h;
    int i, j;
    while (1)
    {
        scanf("%d %d", &w, &h);
        if (w == 0 && h == 0)
        {
            break;
        }
        for (i = 1; i <= w; i++)
        {
            for (j = 1; j <= h; j++)
            {

                if (i == 1 || i == w || j == 1 || j == h)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");

            if (i == w)
            {
                printf("\n");
            }
        }
    }

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m;
	cin >> n >> m;
	if(n%2){
	    int a = m, b = m + 1;
        rep(i,m){
            cout << a << " " << b << endl;
            a--; b++;
	        if(b>n) b -= n;
	        if(a<1) a += n;
        }
	}else{
	    int a = m, b = m + 1;
	    rep(i, (m+1)/2){
            cout << a << " " << b << endl;
            a--; b++;
	        if(b>n) b -= n;
	        if(a<1) a += n;
	    }
	    a--;
	    if(a<1) a += n;
	    rep(i, m - (m+1)/2){
	        cout << a << " " << b << endl;
	        a--; b++;
	        if(b>n) b -= n;
	        if(a<1) a += n;
	    }
	}
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <set>
using namespace std;


void solve()
{
	int sh;
	cin >> sh;

	string s;
	cin >> s;
	int n = (int)s.length();

	for (int i = 0; i < n; i++)
	{
		s[i] = char( ((s[i] - 'A' + sh) % 26) + 'A' );
	}
	
	cout << s;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    map<string,int>mp;
    string st;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>st;
        mp[st]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
    int ans=0;
    for(int i=0;i<n;i++)
        ans^=arr[i];
    for(int i=0;i<n;i++)
        cout<<(ans^arr[i])<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5148
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[2010];
    rep(i, N) cin >> A[i];
    int ans = INF;
    rep(i, N) {
        vector<priority_queue<int, vector<int>, greater<int>>> v;
        priority_queue<int, vector<int>, greater<int>> que;
        rep(j, N) {
            if(A[j] >= A[i]) que.push(A[j]);
            else if(que.size()) {
                v.push_back(que);
                while(que.size()) que.pop();
            }
        }
        if(que.size()) v.push_back(que);
        vector<int> v2;
        for(auto& e: v) {
            //cout << i << " " << e.size() << endl;
            while(e.size() >= K) {
                int p = e.top(); e.pop();
                v2.push_back(p);
            }
        }
        if(v2.size() >= Q) {
            sort(v2.begin(), v2.end());
            ans = min(ans, v2[Q - 1] - A[i]);
        }
    }
    cout << ans  << endl;


    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  Vll a(n); cin >> a;

  ll ans = 0;
  rep(i, n) rep2(j, i+1, n) rep2(k, j+1, n) {
    ll &x = a[i];
    ll &y = a[j];
    ll &z = a[k];

    if (x == y) continue;
    if (y == z) continue;
    if (z == x) continue;
    
    if (x + y <= z) continue;
    if (y + z <= x) continue;
    if (z + x <= y) continue;
    ++ans;
  }

  cout << ans << '\n';
  return 0;
}


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

const int aMax = 1e5;

signed main() {
	int n, k;
	cin >> n >> k;
	vector<int> num(aMax + 1);
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		num[a] += b;
	}

	int s = 0;

	for (int i = 1; i <= aMax; ++i) {
		s += num[i];
		if (s >= k) {
			cout << i << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
a = int(input())
b_int = map(int, input().split())
max = -1000000
min = 1000000
total =0
for i in b_int:
    if i > max:
        max = i
    if i < min:
        min = i
    total += i
print(min, max, total)

Measured memory_bytes: 8416
#include <bits/stdc++.h>
using namespace std;
int h, n;
int main()
{
	scanf("%d%d", &h, &n);
	for(int i = 1; i <= n; ++i){
		int val;
		scanf("%d", &val);
		h -= val;
		if(h <= 0)
		{
			puts("Yes");
			exit(0);
		}
	}
	puts("No");
	return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    A--;
    B--;
    if(A>B){
        swap(A,B);
    }
    if((B-A)%2==1){
        cout << min(min(max(A,B), max(N-A-1, N-B-1)),
                    min((A+1+(B-A-1)/2), (N-B)+(B-A-1)/2)) << endl;
    }else{
        cout << (B-A)/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <deque>

using namespace std;

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

	long long N, M;
	cin >> N >> M;

	long long M_div_2 = M / 2;
	if (M_div_2 < N)
	{
		cout << min(M_div_2, N);
	}
	else
	{
		M_div_2 -= N;
		cout << N + (M_div_2 / 2);
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i
      if v<10050:
        ans[v]+=1
for i in range(n):print(ans[i+1])

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

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

int main(){
  int64_t x, y;
  cin >> x >> y;
  int64_t ans = x * y / gcd(x, y);
  std::cout << ans << '\n';
  return 0;
}



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

using namespace std;

int main(){
    int n;
    int count_R = 0;
    int count_B = 0;
    string s;
    cin >> n;
    cin >> s;
    for(size_t i = 0; i < n; i++)
    {
        if (s[i] == 'R') {
            count_R += 1;
        }
        else{
            count_B += 1;
        }
    }
    if (count_R > count_B) {
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), A = cin.getIntArray(N);
    let ans = 0;
    let right = 0, sum = 0;
    for (let left = 0; left < N; left++) {
        while (right < N && (sum + A[right]) == (sum ^ A[right])) {
            sum += A[right];
            right++;
        }
        ans += right - left;
        sum -= A[left];
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
  vector<int> V(3);
  for (int i = 0; i < 3; i++) cin >> V[i];
  sort(V.begin(), V.end());
  int K;
  cin >> K;
  cout << V[0] + V[1] + V[2] * (1 << K);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String str = stdIn.next();
			for(int i = 0; i < str.length(); ++i)
			{
				if(str.charAt(i) == '@')
				{
					for(int j = 0; j < (str.charAt(i + 1) - '0'); ++j)
					{
						System.out.print(str.charAt(i + 2));
					}
					i += 2;
				}
				else
				{
					System.out.print(str.charAt(i));
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17300
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int R, G;
  cin >> R >> G;

  cout << 2 * G - R << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<long long> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) cin >> B[i];
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		if (A[i] > B[i]) ok = false;
	}
	long long ans = 0;
	while (A != B && ok) {
		vector<long long> preb = B;
		for (int i = 0; i < N; ++i) {
			if (B[(i + 1) % N] < B[i] && B[(i + N - 1) % N] < B[i]) {
				long long delta = (B[(i + 1) % N] + B[(i + N - 1) % N]);
				long long dl = (B[i] - A[i]) / delta;
				B[i] -= delta * dl;
				ans += dl;
			}
		}
		if (preb == B) ok = false;
	}
	cout << (ok ? ans : -1) << endl;
	return 0;
}

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

long long int A;
long long int B;


long long int dp[62][1 << 16];
bool use[62][1 << 16];
vector<long long int> va;
vector<long long int> vb;

int vv[] = { 0, 1, 2, 3 };

int check(int val,int ne,int ich){
	/*int tmp_v = val;
	int nex = 0;
	
	for (int i = 0; i < 4; i++){
		if ((tmp_v >> i) & 1){
			val = i;
			int less = (val & 1);
			int gr = ((val >> 1) & 1);
			if (ne == 0){
				if (va[ich] == 1 && less == 0){
					continue;
				}
				if (vb[ich] == 1){
					gr = 1;
				}
			}
			else{
				if (vb[ich] == 0 && gr == 0){
					continue;
				}
				if (va[ich] == 0){
					less = 1;
				}
			}
			val = less;
			val |= (gr<<1);
			nex |= (1 << val);
		}
	}*/
	int less = val & 1;
	int gr = (val >> 1);
	if (ne == 0){
		if (va[ich] == 1 && less == 0){
			return -1;
		}
		if (vb[ich] == 1){
			gr = 1;
		}
	}
	else{
		if (vb[ich] == 0 && gr == 0){
			return -1;
		}
		if (va[ich] == 0){
			less = 1;
		}
	}
	return less + (gr << 1);
}

inline long long int dfs(int a, int b){
	if (b == 0)return 0;
	if (a == va.size()){
		return 1;
	}
	if (use[a][b]){
		return dp[a][b];
	}
	use[a][b] = true;
	//zero
	{
		int go = 0;
		for (int i = 0; i < 16; i++){
			if ((b >> i) & 1){
				int aa = (i & 3);
				int bb = (i >> 2);
				int wa = check(aa, 0, a);
				int wb = check(bb, 0, a);
				if (wa != -1 && wb != -1){
					go |= (1 << ((wb << 2) + wa));
				}
			}
		}
		dp[a][b] += dfs(a + 1, go);
	}
	//one
	{
		int go = 0;
		for (int i = 0; i < 16; i++){
			if ((b >> i) & 1){
				int aa = (i & 3);
				int bb = (i >> 2);
				for (int j = 1; j < 4; j++){
					int wa = check(aa, j & 1, a);
					int wb = check(bb, j >> 1, a);
					if (wa != -1 && wb != -1){
						go |= 1<<((wb<<2)+wa);
					}
				}
			}
		}
		dp[a][b] += dfs(a + 1, go);
	}
	return dp[a][b];
}
int main(){
	scanf("%lld%lld", &A,&B);
	for (long long int i = 0; i < 60; i++){
		va.push_back((A >> i) & 1LL);
		vb.push_back((B >> i) & 1LL);
	}
	reverse(va.begin(), va.end());
	reverse(vb.begin(), vb.end());
	long long int ans = dfs(0, 1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 33664
#include<cstdio>
#define MAX 100005
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX],H[MAX];

void setDepth(int u, int d){
	if( u == NIL ) return;
	D[u] =d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
	h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
	h2 = setHeight(T[u].right) + 1;
	return H[u] = ( h1 > h2 ? h1 : h2 );
}

//節点uの兄弟を返す
int getSibling(int u){
	if(T[u].parent == NIL ) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
	return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if( T[u].left != NIL ) deg++;
	if( T[u].right != NIL ) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	
	if(T[u].parent == NIL ){
		printf("root\n");
	}	else if( T[u].left == NIL && T[u].right == NIL ){
			printf("leaf\n");
	}	else{
		printf("internal node\n");
	}
}

int main(){
	int v, l, r, root =0,i;
	scanf("%d", &n);
	
	for( i = 0; i < n; i++) T[i].parent = NIL;
	
	for( i = 0; i < n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if( l != NIL ) T[l].parent = v;
		if( r != NIL ) T[r].parent = v;
	}
	
	for( i = 0; i < n; i++) if(T[i].parent == NIL) root = i;
		
	setDepth(root, 0);
	setHeight(root);
		
		for( i = 0; i < n; i++) print(i);
		
		return 0;
}


Measured memory_bytes: 2700
#include<stdio.h>

int main(){
  int n, cnt=0;
  scanf("%d", &n);
  
  for(int i=1; i<=n; i++){
    if(i>=1 && i<=9){
      cnt++;
    }
    else if(i>=100 && i<=999){
      cnt++;
    }
    else if(i>=10000 && i<=99999){
      cnt++;
    }
  }
  
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 128
/*
* @author:  codancer
* @createTime:  2020-05-11, 20:15:07
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
const int N = 2e6+100;
pair<int,int> cnt[N];
int main(){
	int n;
	cin>>n;
	vector<string> s(n+1);
	vector<pair<int,int> > pos,neg;
	rep(i,1,n){
		int minn=0;// I should have -minn opening brackets before take it
		int balance=0;// after take it ,  i can add balance to sum
		cin>>s[i];
		for(char c:s[i]){
			if(c=='(') ++balance;
			else --balance;
			minn=min(minn,balance);
		}
		int need=-minn,get=balance;
		if(balance>=0) pos.push_back({need,get});
		else{
			neg.push_back({need,get});
		}
	}
	sort(pos.begin(),pos.end());
	sort(neg.begin(),neg.end(),[](const pair<int,int> a,const pair<int,int> b){
		return a.first+a.second>b.first+b.second;
	});
	int now=0;
	for(auto v:pos){
		if(now<v.first){
			cout<<"No"<<endl;
			return 0;
		}
		now+=v.second;
	}
	for(auto v:neg){
		if(now<v.first){
			cout<<"No"<<endl;
			return 0;
		}
		now+=v.second;
	}
	if(now){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define endl "\n"

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	int n;	cin>>n;
	vector< pair<int,int> > V(n+1);
	V[0]={0,1};

	for(int i=1;i<=n;i++){
		cin>>V[i].first>>V[i].second;
		V[i].second=10-V[i].second;
	}
	// T1 < T2 < T3 < ...
	//for(int i=1;i<=n;i++){
	//	V[i].second*=V[i-1].second;
	//	//大きくなるだろ
	//}


	int q;	cin>>q;
	for(int i=0;i<q;i++){
		int l,r;	cin>>l>>r;
		int lPos,rPos,NG;

		lPos=0;	NG=n+1;
		while(NG-lPos>1){
			int mid=(lPos+NG)/2;
			if(V[mid].first<=l)lPos=mid;
			else NG=mid;
		}
		//rPos: R以前で起きた最後の地震
		//cout<<rPos<<endl;
		//cout<<lPos<<endl;
		//lPos: L以前に起きた最後の地震
		long double ans=1000000000.0;
		for(int i=lPos+1;i<=n;i++){
		    if(V[i].first > r) break;
		    ans*=(V[i].second/10.0);
			
		}

		//printf("%.8lf\n",ans);
		cout<<ans<<endl;

	}


	return 0;
}






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

int main()
{
    ll n,a,sum1=0,sum2=0;
    cin>>n;
    vector<ll> v;
    
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
        
    }
	
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(ll i=0;i<n;i++)
    {
        if(i%2==0)
        {
            sum1+=v[i];
        }
        
        else
        {
            sum2+=v[i];
        }
    }
    
    cout<<sum1-sum2;
    
	return 0;
}

Measured memory_bytes: 3556
N = int(input())
S = []
for i in range(N):
    S.append(input())
    
ALPHA = "abcdefghijklmnopqrstuvwxyz"

ans = ""
for a in ALPHA:
    count = 50
    for s in S:
        if s.count(a) < count:
            count = s.count(a)
    
    ans += a*count
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s; cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 3560
<?php

$hs = array();
for ($i = 0; $i < 10; $i++) {
    fscanf(STDIN, "%d", $hs[]);
}

rsort($hs);

echo (string) $hs[0] . PHP_EOL;
echo (string) $hs[1] . PHP_EOL;
echo (string) $hs[2] . PHP_EOL;

Measured memory_bytes: 6564
#include <iostream>
using namespace std;
 
int main() {
    long long n;
    cin >> n;
    long long res=1e18, ans=1,x;
  	for(int i=0;i<n;i++){
		cin>>x;
		if(x==0){
			res=1;
			ans=0;
			break;
		}
		res /= x;
		ans *= x;
	}
    if(res==0) ans= -1;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3600
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream &in, ostream &out) {
  l x, y; in >> x >> y;
  out << x + y / 2 << lf;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    char s;
   cin >> s;

   if (isupper(s))
   {
       cout << 'A'<< endl;
   }
   else
   {
       cout << 'a' << endl;
   }

    
}

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

int main(int argc, char* argv[]){
        char buf[64]={0};
        int l=0;
        long l3=0;
        double v=0.0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        l=atoi(buf);
        if(l<=0){
                return 2;
        }
        l3 = l*l*l;
        v = l3/27.0;
        printf("%.12lf\n", v);
        return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int cnt[MAXN];

struct FenwickTree {
    FenwickTree() {}
    inline void increase(int t, int x) {
        for (int i = t; i <= n; i += lowbit(i))
            _arr[i] = ((_arr[i] + x) % M + M) % M;
    }
    inline int getSum(int t) {
        int s = 0;
        for (int i = t; i; i -= lowbit(i)) s = (s + _arr[i]) % M;
        return s;
    }
    int _arr[MAXN];
    int M;
    inline int lowbit(int x) { return x & (-x); }
};
int fastExp(ll x, ll p, int mod) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}
FenwickTree f1, f2;
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    scanf("%s", text);
    int popcnt = 0;
    for (int i = 0; i < n; i++) {
        popcnt += text[i] == '1';
    }
    f1.M = popcnt - 1;
    f2.M = popcnt + 1;
    cnt[0] = 0;
    for (int i = 1; i <= n; i++) {
        int x = i;
        while (x) {
            x %= __builtin_popcount(x);
            cnt[i]++;
        }
    }
    for (int i = 0; i < n; i++) {
        if (text[i] == '1') {
            if (f1.M != 0) f1.increase(i + 1, fastExp(2, n - i - 1, f1.M));
            f2.increase(i + 1, fastExp(2, n - i - 1, f2.M));
        }
    }
    for (int i = 0; i < n; i++) {
        if (text[i] == '1') {
            if (f1.M == 0) {
                printf("0\n");
                continue;
            }
            f1.increase(i + 1, -fastExp(2, n - i - 1, f1.M));
            int s = f1.getSum(n);
            int m = (s + f1.M) % f1.M;
            printf("%d\n", cnt[m] + 1);
            f1.increase(i + 1, fastExp(2, n - i - 1, f1.M));
        } else {
            f2.increase(i + 1, fastExp(2, n - i - 1, f2.M));
            int s = f2.getSum(n);
            int m = (s + f2.M) % f2.M;
            printf("%d\n", cnt[m] + 1);
            f2.increase(i + 1, -fastExp(2, n - i - 1, f2.M));
        }
    }

    return 0;
}

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

typedef long long ll;

ll N;
vector<vector<ll>> Kids;
vector<ll> Depth;
map<ll, vector<ll>> Vs; // for each depth
vector<vector<ll>> Anc;
const ll L = 20;
const ll MOD = 1e9 + 7;
vector<ll> Pow;
ll R;

void dfs(ll v, ll par, ll depth) {
  Depth[v] = depth;
  Vs[depth].push_back(v);
  for (ll w : Kids[v]) {
    if (w == par) continue;
    dfs(w, v, depth + 1);
  }
}
void init_lca() {
  for (ll l = 1; l < L; ++l)
    for (ll v = 0; v <= N; ++v)
      if (Anc[l - 1][v] != -1) Anc[l][v] = Anc[l - 1][Anc[l - 1][v]];
}
ll lca(ll u, ll v) {
  if (Depth[u] > Depth[v]) swap(u, v);
  for (ll l = L - 1; l >= 0; --l) {
    if (Depth[v] - Depth[u] >= (1 << l)) v = Anc[l][v];
  }
  assert(Depth[u] == Depth[v]);
  if (u == v) return u;
  for (ll l = L - 1; l >= 0; --l) {
    if (Anc[l][u] != Anc[l][v]) {
      u = Anc[l][u];
      v = Anc[l][v];
      assert(Depth[u] == Depth[v]);
    }
  }
  assert(u != v && Anc[0][u] == Anc[0][v]);
  return Anc[0][u];
}
void init_pow() {
  Pow.resize(N + 1 + 1);
  Pow[0] = 1;
  for (ll i = 1; i <= N + 1; ++i) Pow[i] = 2 * Pow[i - 1] % MOD;
}
pair<ll, ll> dp(ll v, const map<ll, vector<ll>> &kids) {
  if (!kids.count(v)) return make_pair(1, 1);
  ll many = 0, one = 0, zero = 1;
  for (ll w : kids.at(v)) {
    ll w_one, w_zero;
    tie(w_one, w_zero) = dp(w, kids);
    many = (many * (w_one + w_zero) % MOD + one * w_one % MOD) % MOD;
    one = (one * w_zero % MOD + zero * w_one % MOD) % MOD;
    zero = zero * w_zero % MOD;
  }
  return make_pair(one, (many + zero) % MOD);
}
int main() {
  cin >> N;
  Kids.resize(N + 1);
  Anc.resize(L);
  for (auto &anc : Anc) anc.resize(N + 1, -1);
  for (ll v = 1; v <= N; ++v) {
    ll p;
    cin >> p;
    Kids[p].push_back(v);
    Anc[0][v] = p;
  }
  init_lca();
  Depth.resize(N + 1);
  dfs(0, -1, 0);
  init_pow();
  for (const auto &dvs : Vs) {
    const auto &vs = dvs.second;
    assert(!vs.empty());
    vector<ll> line = {vs[0]};
    map<ll, vector<ll>> kids;
    for (ll i = 1; i < vs.size(); ++i) {
      ll v = vs[i - 1], w = vs[i];
      ll u = lca(v, w);
      vector<ll> pool;
      while (!line.empty() && Depth[line.back()] >= Depth[u]) {
        pool.push_back(line.back());
        line.pop_back();
      }
      line.push_back(u);
      if (u != w) line.push_back(w);
      if (!pool.empty() && pool.back() != u) pool.push_back(u);
      for (ll j = 1; j < pool.size(); ++j) kids[pool[j]].push_back(pool[j - 1]);
    }
    for (ll j = 1; j < line.size(); ++j) kids[line[j - 1]].push_back(line[j]);
    ll root = lca(vs.front(), vs.back());
    ll one, zero;
    tie(one, zero) = dp(root, kids);
    assert((one + zero) % MOD == Pow[vs.size()]);
    (R += Pow[N + 1 - vs.size()] * one % MOD) %= MOD;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 83072