akhauriyash/Code-Regression huggingface dataset:
def merge(A, left, mid, right):
    global c
    L=A[left:mid]+[1e10]
    R=A[mid:right]+[1e10]
    i=j=0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
        c+=1
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
c=0
n=int(input())
A=list(map(int,input().split()))
mergeSort(A, 0, n)
print(*A)
print(c)


Measured memory_bytes: 61656
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  ll N, K, d, A;
  cin >> N >> K;
  vector<bool> vec;
  vec.reserve(N);
  for (auto i = 0; i < N;i ++) {
    vec.push_back(false);
  }
  for (auto i = 0; i < K;i ++) {
    cin >> d;
    for (auto k = 0; k < d; k ++) {
      cin >> A;
      vec[A-1] = true;
    }
  }
  ll ret = 0;
  for (auto i = 0; i < N;i ++) {
    if (!vec[i]) {
      ret ++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        String mojiA = "";
        String mojiB = "";

        for(int i = 0; i < A; i++){
            mojiB = mojiB + String.valueOf(B);
        }
        for(int i = 0; i < B; i++){
            mojiA = mojiA + String.valueOf(A);
        }

        if(mojiA.compareTo(mojiB) < 0){
            System.out.println(mojiA);
        }else{
            System.out.println(mojiB);
        }
        
        sc.close();

    }
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
#define MAX 10000000
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){

int i,j;
int n;
scanf("%d",&n);
  if(n==0)printf("1");
  else printf("0");


return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 4");
            WillReturn.Add("4 10");
            WillReturn.Add("3 4");
            //11
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 7");
            WillReturn.Add("4 10");
            WillReturn.Add("3 6");
            //13
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 10");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            //400
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4 1");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct NimotuDef
    {
        internal int W;
        internal int V;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();

            int[] wkArr = { };
            Action<string> SplitAct = pStr =>
                wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

            SplitAct(InputList[0]);
            int W = wkArr[1];

            var NimotuList = new List<NimotuDef>();
            foreach (string EachStr in InputList.Skip(1)) {
                SplitAct(EachStr);
                NimotuList.Add(new NimotuDef() { W = wkArr[0], V = wkArr[1] });
            }
            //重さの昇順でソートしておく
            NimotuList.Sort((A, B) => A.W.CompareTo(B.W));

            //最大の価値[重さ合計]なDP表
            var DPDict = new Dictionary<long, long>();
            DPDict[0] = 0;

            foreach (NimotuDef EachNimotu in NimotuList) {
                foreach (int EachKey in DPDict.Keys.OrderByDescending(A => A).ToArray()) {
                    long NewKey = EachKey + EachNimotu.W;
                    if (NewKey > W) continue;

                    long NewVal = DPDict[EachKey] + EachNimotu.V;

                    if (DPDict.ContainsKey(NewKey)) {
                        if (DPDict[NewKey] < NewVal) {
                            DPDict[NewKey] = NewVal;
                        }
                    }
                    else DPDict[NewKey] = NewVal;
                }

                //Console.WriteLine("DP結果");
                //foreach (var EachPair in DPDict) {
                //    Console.WriteLine("PrevDP[{0}]={1}", EachPair.Key, EachPair.Value);
                //}
            }
            Console.WriteLine(DPDict.Values.Max());
        }
    }
}


Measured memory_bytes: 16480
import sys

inf = 1<<60

def solve():
    H, W = map(int, input().split())

    ans = inf

    # 縦(H)を固定
    for a in range(1, W):
        Ws = W - a
        s0 = H * a

        if Ws % 2 == 0 or H % 2 == 0:
            s1 = Ws * H // 2
            ans = min(ans, abs(s0 - s1))
        else:
            c = max(Ws, H)
            d = min(Ws, H)

            s1 = d * ((c + 1) // 2)
            s2 = d * (c // 2)

            ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))
            # print(s0, s1, s2)

        # print(ans)

    # 横(W)を固定
    for b in range(1, H):
        Hs = H - b
        s0 = W * b

        if Hs % 2 == 0 or W % 2 == 0:
            s1 = Hs * W // 2
            ans = min(ans, abs(s0 - s1))
        else:
            c = max(Hs, W)
            d = min(Hs, W)

            s1 = d * ((c + 1) // 2)
            s2 = d * (c // 2)

            ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

    print(ans)
    pass

if __name__ == '__main__':
    solve()

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

int P[int(2e5+5)]={};
bool used[int(2e5+5)];

int main() {
	int N,x;
	scanf("%d%d",&N,&x);
	if(x == 1 || x == 2*N-1) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	P[N] = x, used[x] = true;
	P[N+1] = x+1, used[x+1] = true;
	P[N-1] = x-1, used[x-1] = true;
	if(x > 2) P[N+2] = x-2, used[x-2] = true;
	if(x < 2*N-2) P[N-2] = x+2, used[x+2] = true;
	int r = 0;
	for(int i = 1; i <= 2*N-1; ++i) {
		if(P[i] != 0) continue;
		++r;
		while(used[r]) ++r;
		P[i] = r;
	}
	for(int i = 1; i <= 2*N-1; ++i)
		printf("%d\n",P[i]);
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long a[100010]={};
  int n;cin>>n;
  for(int i=0;i<n;++i)cin>>a[i];
  bool f=true;
  while(f){
	f=false;
	sort(a,a+n);
	for(int i=1;i<n;++i){
	  if(a[i]!=a[0]){
		a[i]=a[i]%a[0]?a[i]%a[0]:a[0];
		f=true;
	  }
	}
  }
  cout<<a[0]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    string S, T;
    int A, B;
    cin >> S >> T;
    
    for(int i = 0; i < N; i++){
        cout << S[i] << T[i];
    }
    cout << "\n";
    return 0;
}


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

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

    map<int,int> appear;
    for(int i = 0; i < n; i++){
        cin >> a;
        appear[a]++;
    }

    int ans = 0;
    for(map<int,int>::iterator it = appear.begin(); it != appear.end(); it++){
        pair<int,int> p = *it;
        if(p.second < p.first)  ans += p.second;
        else                        ans += p.second - p.first;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, A, N);
  map<ll, int> m;
  each(x, A) {
    m[x] ^= 1;
  }
  int ans = 0;
  each(x, m) {
    ans += x.second;
  }
  print(ans);
}


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

using namespace std;
const int N = 1e5 + 5, M = 16, inf = 1e9;
int a[N], cnt[M], p[M], dp[1<<M], Xor[1<<M];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v, x; cin >> u >> v >> x;
        a[u] ^= x, a[v] ^= x;
    }
    for (int i = 0; i < n; i++) cnt[a[i]]++;
    int res = cnt[0], m = 0;
    for (int i = 1; i < M; i++) {
        res += (cnt[i]>>1);
        if (cnt[i]&1) p[m++] = i;
    }
    fill(dp + 1, dp + M, -inf);
    for (int mask = 1; mask < (1<<m); mask++) {
        Xor[mask] = p[__builtin_ctz(mask)] ^ Xor[mask^(mask&(-mask))];
        for (int sub = mask; sub; sub = (sub - 1)&mask) if (Xor[sub] == 0)
            dp[mask] = max(dp[mask], dp[mask^sub] + 1);
    }
    cout << n - res - dp[(1<<m) - 1] << "\n";

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n, ans = 0;
	string s[2000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == "E869120") {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll K,A,B;
    cin >>K>>A>>B;

    for(int i = A;i<=B;i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    
    cout << "NG" << endl;

    return 0;
    

}

Measured memory_bytes: 3596
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
map<string,int> m;
int main(){
	fastio;
	int n;
	cin>>n;
	int res=0;
	rb(i,1,n)
	{
		string s;
		cin>>s;
		m[s]++;
		if(m[s]==1){
			res++;
		} 
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 19272
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

// 順番に読む意味は無いから、Aをx冊呼んで、Bをk-x冊読むのが最善
// xは最大10^5だから全託作
int main() {
  ll n, m, k; cin >> n >> m >> k;
  vector<ll> A(n), B(m);
  loop(i,0,n) cin >> A[i];
  loop(i,0,m) cin >> B[i];
  vector<ll> acc_a(n+1, 0), acc_b(m+1, 0);
  loop(i,0,n) acc_a[i+1] = acc_a[i] + A[i];
  loop(i,0,m) acc_b[i+1] = acc_b[i] + B[i];
  
  ll max_ = 0;
  // x = [0:n]
  loop(x,0,n+1) {
    if (acc_a[x] > k) break;
    ll k_rem = k - acc_a[x];
    ll y = lower_bound(acc_b.begin(), acc_b.end(), k_rem) - acc_b.begin();
    if (acc_b[y]>k_rem)y--;
    y = min(y, m); // すべて読める
    if (max_ < x+y) max_ = x + y;
  }
  cout << max_ << endl;
  return 0;
}


Measured memory_bytes: 9596
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    long long ans = 0;
    forn (i, 1, n) {
        if (a[i] < a[i - 1]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans;
    return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    string s;
    cin>>s;
    ll mod=1e9+7;
    int n=s.size();
    ll dp[n+1][13]={};
    dp[0][0]=1;

    reverse(s.begin(),s.end());


    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            ll t=1;
            for(int y=0;y<i%3;y++) t*=10;

            if((i%6)<=2){
                if(s[i]!='?'){
                    dp[i+1][j] += dp[i][(13000 + j - ((int)s[i]-'0')*t)%13];
                }
                else {
                    for(int k=0;k<=9;k++){
                        dp[i+1][j] += dp[i][(1300 + j - k*t) %13 ];
                        dp[i+1][j]%=mod;
                    }
                }
                dp[i+1][j]%=mod;
                
            }
            else {
                if(s[i]!='?') dp[i+1][j] += dp[i][(j+((int)s[i]-'0')*t%13)%13];
                else {
                    for(int k=0;k<=9;k++){
                        dp[i+1][j] += dp[i][(j+k*t)%13];
                        dp[i+1][j]%=mod;
                    }
                }
                dp[i+1][j]%=mod;
            }
            dp[i+1][j]%=mod;
        }
    }
    cout << dp[n][5] << endl;

    
    
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'a'&& s[1] == 'b'&& s[2] == 'c') cout << "Yes";
    else if (s[0] == 'a'&& s[1] == 'c'&& s[2] == 'b') cout << "Yes";
    else if (s[0] == 'b'&& s[1] == 'a'&& s[2] == 'c') cout << "Yes";
    else if (s[0] == 'b'&& s[1] == 'c'&& s[2] == 'a') cout << "Yes";
    else if (s[0] == 'c'&& s[1] == 'a'&& s[2] == 'b') cout << "Yes";
    else if (s[0] == 'c'&& s[1] == 'b'&& s[2] == 'a') cout << "Yes";
	
    else cout << "No";
    return 0;
}

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

using namespace std;

#define MAX 1010

bool dp[MAX][MAX];
int dp2[MAX][MAX];
int H, W, N;

bool get_dir(int n, bool dir)
{
  if (n % 2 == 0) {
    return dir;
  } else {
    return !dir;
  }
}

void find_last_point()
{
  int x = 0, y = 0;
  while (true) {
    if (dp[y][x] == 1) {
      x++;
    } else {
      y++;
    }
    if (x >= W || y >= H) break;
  }
  cout << y+1 << " " << x+1 << endl;
}

void print()
{
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

void print2()
{
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << dp2[i][j] << " ";
    }
    cout << endl;
  }
}


int main()
{
  while (cin >> H >> W >> N, H) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
	cin >> dp[i][j];
      }
    }
    memset(dp2, 0, sizeof(dp2));

    dp[0][0] = get_dir(N-1, dp[0][0]);
    dp2[0][0] = N-1;

    for (int i = 0; i < H; i++) {
      if (dp2[i][0] == 0) continue;
      if (dp2[i][0] % 2 == 1) {
	if (dp[i][0] == 0) {
	  dp2[i+1][0] += dp2[i][0]/2;
	  if (i > 0) dp2[i][1] += dp2[i][0]/2+1;
	} else {
	  dp2[i+1][0] += dp2[i][0]/2+1;
	  if (i > 0) dp2[i][1] += dp2[i][0]/2;
	}
      } else {
	dp2[i+1][0] += dp2[i][0]/2;
	if (i > 0) dp2[i][1] += dp2[i][0]/2;
      }
      dp[i+1][0] = get_dir(dp2[i+1][0], dp[i+1][0]);
    }    

    for (int j = 0; j < W; j++) {
      if (dp2[0][j] == 0) continue;
      if (dp2[0][j] % 2 == 1) {
	if (dp[0][j] == 0) {
	  dp2[0][j+1] += dp2[0][j]/2+1;
	  if (j > 0) dp2[1][j] += dp2[0][j]/2;
	} else {
	  dp2[0][j+1] += dp2[0][j]/2;
	  if (j > 0) dp2[1][j] += dp2[0][j]/2+1;
	}
      } else {
	dp2[0][j+1] += dp2[0][j]/2;
	if (j > 0) dp2[1][j] += dp2[0][j]/2;
      }
      dp[0][j+1] = get_dir(dp2[0][j+1], dp[0][j+1]);
    }

    for (int i = 1; i < H; i++) {
      for (int j = 1; j < W; j++) {
	if (dp2[i][j] == 0) continue;
	if (dp2[i][j] % 2 == 1) {
	  if (dp[i][j] == 1) {
	    dp2[i+1][j] += dp2[i][j]/2;
	    dp2[i][j+1] += dp2[i][j]/2+1;
	  } else {
	    dp2[i+1][j] += dp2[i][j]/2+1;
	    dp2[i][j+1] += dp2[i][j]/2;
	  }
	} else {
	  dp2[i+1][j] += dp2[i][j]/2;
	  dp2[i][j+1] += dp2[i][j]/2;
	}
	dp[i][j] = get_dir(dp2[i][j], dp[i][j]);
      }
    }
    find_last_point();
  }
  return 0;
}

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

vector<int> input;
bool fin=false;

void print(vector<char> &sign){
    for(int i=0;i<4;i++){
        cout << input.at(i);
        if(i<3){
            cout << sign[i];
        }
    }
    cout << "=7"<< endl;
    fin = true;
    return;
}

void dfs(int sum,int d,vector<char> &sign){
    if(fin) return;
    if(d==3){
        if(sum==7) print(sign);
        return;
    }
    //dの更新
    d++;
    //+
    sign[d-1] = '+';
    dfs(sum+input[d],d,sign);
    //-
    sign[d-1] = '-';
    dfs(sum-input[d],d,sign);
}

int main() {
    vector<char> sign(3);
    string s;
    cin >> s;
    int n = s.size();
    input.resize(n);
    for(int i=0;i<n;i++){
        input[i] = s[i]-'0';
    }
    dfs(input[0],0,sign);
    return 0;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans;
    ans = (double)w * (double)h / 2.0;
    cout << fixed << setprecision(10);
    cout << ans << " ";
    if (x == 0 || y == 0) {
        cout << "0" << endl;
    }
    else if (w/x == 2 && h/y == 2) {
        cout << "1" << endl;
    }
    else cout << "0" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int c11, c12, c13, c21, c22, c23, c31, c32, c33;
	cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
	if ((c11-c12==c21-c22)&&(c21-c22==c31-c32)&&
		(c12-c13==c22-c23)&&(c22-c23==c32-c33)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] value = new char[3];

		value = sc.next().toCharArray();
		if(value[0] != value[1] || value[1] != value[2])
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;

    map<int, int> m;
    each(x, a)m[x];
    auto itr = m.begin();
    for (int i = 0; itr != m.end(); ++i, ++itr) {
        itr->second = i;
    }
    VL tnum(m.size()), cnt(m.size());
    VI mitr(m.size(), n);
    FOR(i, 0, n) {
        tnum[m[a[i]]] = a[i];
        a[i] = m[a[i]];
        ++cnt[a[i]];
        chmin(mitr[a[i]], i);
    }

    VL ans(n);
    rFOR(x, 0, m.size()) {
        if (0 < x)ans[mitr[x]] += cnt[x] * (tnum[x] - tnum[x - 1]);
        else ans[mitr[x]] += cnt[x] * tnum[x];
        if (0 < x) {
            cnt[x - 1] += cnt[x];
            chmin(mitr[x - 1], mitr[x]);
        }
    }
    FOR(i, 0, n)cout << ans[i] << "\n";
}

Measured memory_bytes: 8960
import Data.List
import Data.Char (isSpace)
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  b <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- b_i >= max a_i a_{i+1}
  -- a_i についての条件：
  -- - b_i >= a_i     (1 <= i <= n-1)
  -- - b_{i-1} >= a_i (2 <= i <= n)
  -- 言い換えると
  -- - min b_i b_{i-1} >= a_i  (2 <= i <= n-1)
  -- a_1 := b_1
  -- a_i := min b_i b_{i-1}  (2 <= i <= n-1)
  -- a_n := b_n

  print $ head b + sum (zipWith min b (tail b)) + last b


Measured memory_bytes: 508
import java.io.*;
import java.util.*;


public class Main {
    public static void main (String[]args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int ct = 0;
        int arr[] = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        for(int i = arr[0];i<arr[1]+1;i++){
            if(i%arr[2]==0){
                ct++;
            }
        }
            System.out.println(ct);
    }

}


Measured memory_bytes: 31332
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        // 配列
        int[] a = new int[n];
        int sum = 0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            sum+=a[i];
        }
        Arrays.sort(a);

        for (int i = n-1;i > n-1-m;i--) {
            if(a[i] * 4 * m < sum) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


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

int main()
{
  int n,k;
  cin >> n>>k;
  int s=1;
  for(int i=1; i<=n; i++){
  if ((s+k)<(2*s)) s+=k;
  else s*=2;
  }
  cout << s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int a[MAX], b[MAX];
vector<int> num;
int pd[MAX];
char s[MAX];

void aux(int i) {
	rep(k, 0, num.size())
		pd[num[k]] = i;
	num.clear();
}

void solve(int i, int v) {
	if(pd[i] != -1) a[i]--, a[pd[i]]++, solve(pd[i], v + abs(pd[i]-i));
	else if(s[i] == 'R' && s[i+1] == 'R') num.pb(i), a[i]--, a[i+1]++, solve(i+1, v+1);
	else if(s[i] == 'L' && s[i-1] == 'L') num.pb(i), a[i]--, a[i-1]++, solve(i-1, v+1);
	else if(s[i] == 'R' && (v&1)) aux(i), a[i]--, a[i+1]++;
	else if(s[i] == 'L' && (v&1)) aux(i), a[i]--, a[i-1]++;
}

int main(int argc, char ** argv) {
	cin >> s;
	int sz = strlen(s);
	rep(i, 0, sz) a[i] = 1;
	memset(pd, -1, sizeof pd);
	rep(i, 0, sz) solve(i, 0);
	printf("%d", a[0]);
	rep(i, 1, sz) printf(" %d", a[i]);
	printf("\n");
	return 0;
}



Measured memory_bytes: 5752
#include <iostream>

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	int a, b;
	int city[51];
	for (int i = 0; i < 51; i++) {
		city[i] = 0;
	}

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		city[a] += 1;
		city[b] += 1;
	}
	for (int i = 1; i <= N; i++) {
		cout << city[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;


int main() {
    char l;
    cin >> l;
    if(l == 'a' || l == 'e' || l == 'o' || l == 'u' || l == 'i'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant"<< endl;
    }
}

Measured memory_bytes: 256
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var cards = { "S":[] , "H":[], "C":[], "D":[] };
  var shcd = [ 'S', 'H', 'C', 'D' ];
  for( var key in cards ) {
    for( var i=1; i<=13; i++ ) {
      cards[key].push( i );
    }
  }
  var data = input.split( '\n' );
  
  for( var i=1; i<data.length; i++ ) {
    var p = data[i].split( ' ' );

    k = p[0].toString();
    var k = 'S';
    if( 'S' == p[0] ) {
      k = 'S';
    } else if( 'H' == p[0] ) {
      k = 'H';
    } else if( 'C' == p[0] ) {
      k = 'C';
    } else if( 'D' == p[0] ) {
      k = 'D';
    }
    var res = cards[k].indexOf( Number( p[1] ) );
    if( -1 != res ) {
        cards[k].splice( res, 1 );
    }
  }
  for( var i=0; i<4; i++ ) {
    for( var j = 0; j<cards[ shcd[i] ].length; j++ ) {
      console.log( shcd[i]+" "+cards[ shcd[i] ][j] );
    }
  }
});
 

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

int main(void){
    string s;
    cin >> s;
    
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else cout << 1 << endl;
      
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

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

  int n;
  cin >> n;
  vector<int> S(n);
  REP(i, n) { cin >> S.at(i); }
  sort(ALL(S));
  int q;
  cin >> q;
  vector<int> T(q);
  REP(i, q) { cin >> T.at(i); }

  int ans = 0;
  REP(i, q) {
    int ok = 0;
    int ng = n;
    while (abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;
      if (S.at(mid) <= T.at(i)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    if (S.at(ok) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, m, a, b, p[100005];
set<int> s;

int fs(int x) {
	if (p[x] == x) return x;
	return p[x] = fs(p[x]);
}

int main() {
	fastio; cin >> n >> m;
	FOR(i, 1, n) p[i] = i;
	FOR(i, 1, m) {
		cin >> a >> b;
		p[fs(a)] = fs(b);
	}
	FOR(i, 1, n) s.insert(fs(i));
	cout << s.size() - 1;
}


Measured memory_bytes: 7852
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc128/tasks/abc128_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 問題文通りにソートして順番を出力
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<tuple<string,int,int>> SP(N);
    for(int i = 0; i < N;i++){
        string S; int P; cin >> S >> P;
        SP[i] = tuple<string,int,int>{S,-P,i+1};
    }
    sort(SP.begin(),SP.end());
    for(auto v:SP){
        cout << get<2>(v) << endl;
    }


    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var cnt = 0
    for(i in 0 until n - 2){
        if(s.substring(i,i + 3) == "ABC") cnt++
    }
    println(cnt)
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var siritori = Console.ReadLine().Split(' ');            

            var siritori1 = siritori[0];
            var siritori2 = siritori[1];
            var siritori3 = siritori[2];

            if(siritori1[siritori1.Length - 1] == siritori2[0] && siritori2[siritori2.Length - 1] == siritori3[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<map>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>d(n),k(n);
    map<int,int>values;
    for(int i=0;i<n;i++){
        cin>>d[i];
        k[i]=d[i];
        values[d[i]]++;
    }
    sort(d.begin(),d.end());
    for(int i=0;i<n;i++){
        if(values[d[n-1]]>1)cout<<d[n-1]<<endl;
        else{
            if(k[i]==d[n-1])cout<<d[n-2]<<endl;
            else cout<<d[n-1]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 10256
import java.util.*;
import java.io.*;
public class Main{

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		ArrayList<Integer> array = new ArrayList<Integer>();
 		int min = Integer.MAX_VALUE;
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		for(int i = 0;i<n;i++){
 			array.add(Integer.parseInt(st.nextToken()));
 		}
 		for(int i = 1;i<=100;i++){
 			int sum = 0;
 			for(int j= 0;j<array.size();j++){
 				sum+= (array.get(j)-i)*(array.get(j)-i);
 			}
 			min = Math.min(sum,  min);
 		}
 		
 		
 		out.println(min);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




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

int main(void) {
    int m500, m100, m50, x;
    cin >> m500 >> m100 >> m50 >> x;
    int ans = 0;
    for (int c500 = min(x / 500, m500); c500 >= 0; c500--) {
        int r500 = x - 500 * c500;
        for (int c100 = min(r500 / 100, m100); c100 >= 0; c100--) {
            int r100 = r500 - 100 * c100;
            for (int c50 = min(r100 / 50, m50); c50 >= 0; c50--) {
                int r50 = r100 - 50 * c50;
                if (r50 == 0) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

ll N;
ll field[205][205];
ll g[205];

ll bfs(ll x){
    queue<ll> que;
    rep1(i,N) g[i]=INF;
    que.push(x);
    g[x]=1;

    while(!que.empty()){
        ll Q=que.front(); que.pop();
        rep1(i,N){
            if(field[Q][i]==1){
                if(g[i]==INF){
                    g[i]=g[Q]+1;
                    que.push(i);
                }
                else if(g[i]!=g[Q]-1 && g[i]!=g[Q]+1){
                    return -1;
                }
            }
        }

        /*
        rep1(i,N){
            cout<<"x:"<<x<<" i:"<<i<<" g[i]:"<<g[i]<<endl;
        }
        */
    }
    return 1;
}

int main(){
    cin>>N;

    rep1(i,N){
        string tmp; cin>>tmp;
        rep1(j,N) field[i][j]=tmp[j-1]-'0';
    }

    ll ans=0;
    rep1(i,N){
        if(bfs(i)==1){
            rep1(j,N) chmax(ans,g[j]);
        }
    }
    if(ans==0) cout<<-1;
    else cout<<ans;
}


Measured memory_bytes: 640
k = int(input())

a,b = map(int,input().split(' '))

count = 0
for i in range(b-a+1):
    if (a + i) % k == 0:
        count += 1
if (b-a) / k >= 1:
    print('OK')
elif count == 1:
    print('OK')
else:
    print('NG')


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

int main(void) {

	int N;
	int a[102];

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	int magic = 0;
	int count = 0;
	int bef = 0;

	for (int i = 1; i <= N; i++) {
		if (a[i] == bef) {
			count++;
		}
		else {
			magic += count / 2;
			count = 1;
			bef = a[i];
		}
	}
	magic += count / 2;
	cout << magic << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

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

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a + b < c)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <unordered_map>
using namespace std;

namespace fastinput
{
	/** Interface */

	inline long long readChar();
	template <class T = long long> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(long long x);
	inline void writeWord(const char *s);

	/** Read */

	static const long long buf_size = 16384;

	inline long long getChar() {
		static char buf[buf_size];
		static long long len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline long long readChar() {
		long long c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		long long s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static long long write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(long long x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		long long n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

const int N = 1e5;

int a[N];

int main()
{
	::ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n = readInt();
	int L = readInt();
	for (int i = 0; i < n; ++i)
		a[i] = readInt();
	int start = -1;
	for (int i = 0; i < n - 1; ++i)
		if (a[i] + a[i + 1] >= L)
		{
			start = i;
			break;
		}
	if (start == -1)
	{
		cout << "Impossible" << endl;
		return 0;
	}
	else
	{
		cout << "Possible\n";
		for (int i = 0; i < start; ++i)
			cout << i + 1 << "\n";
		for (int i = n - 2; i > start; --i)
			cout << i + 1 << "\n";
		cout << start + 1 << "\n";
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int x[3] = {3,5,7};

bool check(int n){
  int c3=0;
  int c5=0;
  int c7=0;

  while(n>0){
    if(n%10==3)c3++;
    else if(n%10==5)c5++;
    else if(n%10==7)c7++;

    n/=10;
  }
  return c3!=0 && c5!=0 && c7!=0;
}

int main(){
  int N;
  cin >> N;
  bool ok=true;
  VI s,t;
  s.emplace_back(0);

  int ans=0;
  while(ok && s.size()>0){
    for(auto v: s){
      REP(i,3){
        int n = v * 10 + x[i];

        t.emplace_back(n);
        if(!check(n))continue;

        if(n <= N){
          ans++;
        }else{
          ok=false;
        }
      }
    }
    s.clear();
    s.resize(t.size());
    copy(ALL(t),s.begin());
    t.clear();
  }
  cout << ans << endl;
}



Measured memory_bytes: 896
using System;
using System.Linq;

namespace code_festival_2017_qualc_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 1;
            for (int i = 0; i < n; i++) ret *= 3;
            int kisuu = 1;
            for (int i = 0; i < n; i++)
            {
                if (x[i] % 2 == 0) kisuu *= 2;
            }
            Console.WriteLine(ret - kisuu);
        }
    }
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if(A>=13){
        cout << B << endl;
    }else if(6 <= A &&  A <= 12){
        cout << B/2 << endl;
    }else {
        cout << 0 << endl;
    }
}


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

#define fi first
#define se second
#define all(X) X.begin(),X.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 1e5 +5;
const int lg = 20;
const int mod = 1e9 + 7;

template<class T>
void smin(T &_x, const T &_y){
	_x = min(_x, _y);
}
template<class T>
void smax(T &_x, const T &_y){
	_x = max(_x, _y);
}

int a[maxn];

int main(){
	ios_base::sync_with_stdio(false);cin.tie();
	int n;
	cin>>n;
	ll sum = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		if(a[i] == 0){
			ans += sum / 2;
			sum = 0;
		}
		else sum += a[i];
	}
	ans += sum / 2;
	cout<<ans<<endl;
}

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

vector<int> to[100005];
int main(){
	int n,u,v;
	cin >> n >> u >> v;
	u--;v--;
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int> t(n, -1);
	vector<int> a(n, -1);
	
	queue<int> que1;
	que1.push(u);
	t[u] = 0;
	while(!que1.empty()){
		auto p = que1.front();
		que1.pop();
		for (auto nextp: to[p]){
			if(t[nextp] != -1) continue;
			t[nextp] = t[p] + 1;
			que1.push(nextp);
		}
	}
	
	queue<int> que2;
	que2.push(v);
	a[v] = 0;
	while(!que2.empty()){
		int p = que2.front();
		que2.pop();
		for (auto nextp: to[p]){
			if(a[nextp] != -1) continue;
			a[nextp] = a[p] + 1;
			que2.push(nextp);
		}
	}
	
	int ans = 0;
	rep(i,n){
		if(t[i] < a[i]){
			ans = max(ans, a[i]-1);
		}
	}
	cout << ans<< endl;
    return 0;
}



Measured memory_bytes: 6656