akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 
import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	char[] S = sc.next().toCharArray();
    	char[] T = sc.next().toCharArray();
    	for (int i = 0; i < N; i++) {
    		out.print(S[i]);
    		out.print(T[i]);
		}
    	out.println("");
    }
}

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

int main(){
  ll n,m=0;
  cin >> n;
  R(i,n){
    m+=i;
    if(m>=n){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    while (true) {

      int n = scan.nextInt();
      int x = scan.nextInt();
      int cnt = 0;

      if ((n == 0) && (x == 0)) {
        break;
      }

      for (int i = 1; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
          for (int k = j + 1; k <= n; k++) {
            if (i + j + k == x) {
              cnt++;
            } else if (i + j + k > x) {
              break;
            }
          }
        }
      }

      System.out.println(cnt);

    }

  }

}


Measured memory_bytes: 26820
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

ll dp[25][1 << 22];
ll done;
ll solve1(vector<vi> &a, ll id, ll mask, ll n) {

	if (mask == done) {
		return 1;
	}
	if (id == n) {
		return 0;
	}

	if (dp[id][mask] != -1) {
		return dp[id][mask];
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		bool ava = ((1 << i)&mask);
		if (ava == 0 && a[id][i] == 1) {
			ans = (ans + solve1(a, id + 1, (mask | (1 << i)), n)) % mod;
		}
	}
	return dp[id][mask] = ans;

}
void solve() {

	ll n;
	cin >> n;
	vector<vi> a(n, vector<ll>(n));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	done = ((1 << n)) - 1;
	memset(dp, -1, sizeof(dp));
	cout << solve1(a, 0, 0, n);

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 822848
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

import static java.lang.System.out;
import static java.lang.Integer.parseInt;

public class Main {
    static class Element {
        long t, c;

        Element(long t, long c) {
            this.t = t;
            this.c = c;
        }
    }

    static int NN = 100007;
    static ArrayList<Long>[] G;
    static long z[];

    static void dfs(int v, long u, int p) {
        z[v] = u;
        for (int i = 0; i < G[v].size(); i++) {
            long qaq = G[v].get(i);
            int w = (int) (qaq >>> 32);
            if (w == p) continue;
            dfs(w, u + (int) qaq, v);
        }
    }

    public static void main(String[] args) throws IOException {
        //for(int i=0;i<NN;i++) G[i]=new ArrayList<Element>();
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        G = new ArrayList[n];
        z = new long[n];
        for (int i = 0; i < n; i++) G[i] = new ArrayList<Long>();

        for (int i = 0; i < n - 1; i++) {
            long a = sc.nextLong() - 1;
            long b = sc.nextLong() - 1;
            long c = sc.nextLong();

            G[(int) a].add(b << 32 | c);
            G[(int) b].add(a << 32 | c);
        }
        int q = sc.nextInt();
        n = sc.nextInt();
        dfs(n - 1, 0, -1);
        for (int j = 0; j < q; j++) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            out.println(z[a - 1] + z[b - 1]);
        }
    }
}


Measured memory_bytes: 187556
import numpy as np
n = int(input())
s = input()

alp = [chr(i) for i in range(65,65+26)]
ind = np.arange(len(alp))

dic = dict(zip(alp, ind))

st = ''
for m in s:
    idx = dic[m]
    idx = (idx+n) % 26
    st += alp[idx]

print(st)

Measured memory_bytes: 14304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define VLA valarray
#define VCT vector

using namespace std;

int sumC(VCT<VLA<int> > &a, int n) {
    int ans = 0;
    REP(i, a.size()) ans += a.at(i)[n];
    return ans;
}

int main() {
    int r, c;
    cin >> r >> c;
    VCT<VLA<int> > s(r, VLA<int>(c));
    int al = 0;
    REP(i, r) REP(j, c) {
        cin >> s.at(i)[j];
        cout << s.at(i)[j] << " ";
        if (j == c-1) {
            cout << s.at(i).sum() << endl;
            al += s.at(i).sum();}}
    REP(j, c) cout << sumC(s, j) << " ";
    cout << al << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <climits>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int ans=0;
	char now='A';
	for(char c:s){
		if(c<=now)ans++;
		now=c;
	}
	cout << ans << endl;
}


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

const int maxn = 1e5+5;
int n,m;
int l[maxn],r[maxn];

int main()
{
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d",&l[i],&r[i]);
    }
    sort(l,l+m);
    sort(r,r+m);
    int ans = r[0]-l[m-1];
    printf("%d\n",ans>=0?ans+1:0);
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,a[n+1],ans=0;
    map<lli,lli> mp;
    
    for(i=1;i<=n;i++) cin>>a[i];
    
    for(i=1;i<=n;i++)
    {
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll x[n];
	ll xx[n];
	for(int i = 0; i < n; i++)cin >> x[i], xx[i] = x[i];
	sort(xx, xx+n);
	ll a = xx[n/2];
	ll b = xx[n/2-1];
	for(int i = 0; i < n; i++){
		if(x[i] >= a)cout << b << endl;
		else cout << a << endl;
	}
    return 0;
}

Measured memory_bytes: 5248
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main() {
	int n,ans=1;
	cin >> n;
	vector<char>s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	char check=s[0];
	for (int i = 0; i < n; i++) {
		if (check != s[i]) {
			ans++;
			check = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import re
while True:
    try:
       f = input().split()
    except:
        break
    stack = []
    for c in f:
        if re.match("-*[0-9]", c) is None:
            b, a = str(stack.pop()), str(stack.pop())
            stack.append(float(eval(a+c+b)))
        else:
            stack.append(c)
    print(stack[0])

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int> X_city(N);
    vector<int> Y_city(M);

    for(auto &x:X_city){
        cin>>x;
    }
    for(auto &y:Y_city){
        cin>>y;
    }

    X_city.emplace_back(X);
    Y_city.emplace_back(Y);

    int max,min;
    max=*max_element(X_city.begin(),X_city.end());
    min=*min_element(Y_city.begin(),Y_city.end());

    if(min>max){
        cout<<"No War";
    }else{
        cout<<"War";
    }

    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
probnum = 1

while (n=gets.to_i)>0
  map = {}

  n.times{
    x,y,r = gets.split.map(&:to_f)
    map[x-r] ||= []
    map[x-r] << [y-r,y+r,1]
    map[x+r] ||= []
    map[x+r] << [y-r,y+r,-1]
  }

  ans = 0

  prei = 0
  sum = 0

  line = {}
  map.keys.sort.each{|i|
    #p [sum*(i-prei),map[i],i,sum]
    ans += sum*(i-prei)

    map[i].each{|s,e,j|
      line[s] ||= 0
      line[s] += j
      line[e] ||= 0
      line[e] -= j
    }

    sum = 0
    cnt = 0
    ind = 0
    line.keys.sort.each{|j|
      if cnt > 0
        sum += j-ind
      end
      cnt += line[j]
      ind = j
    }

    prei = i
  }

  puts "%d %.2f"%[probnum,ans]
  probnum += 1
end

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

int main() {
    string s, t, ans = "Yes";
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define SP << " " <<

signed main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll AB[2], K; cin >> AB[0] >> AB[1] >> K;

    rep(i, K) {
        AB[i%2] = (AB[i%2] & 0xfffffffffffffffe) >> 1;
        AB[(i+1)%2] += AB[i%2];
    }

    cout << AB[0] SP AB[1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    vector <ll> dp(n);
    for (int i = 1; i < n; i++) {
        dp[i] = 1e18;
        for (int j = i, c = 1; j > 0 && c <= k; j--, c++) {
            umin(dp[i], dp[j - 1] + abs(a[i] - a[j - 1]));
        }
    }
    cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; cin >> a[i], a[i++]--);
  vector<bool> b(N);
  for (int i = 0, j = 0; !b[i]; i = a[i], j++) {
    b[i] = true;
    if (i == 1) {
      cout << j;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 4032
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

// {value, weight}
vector<pair<int, int>> items;

int main(void) {
    int N, W;
    cin >> N >> W;

    items.resize(N + 1);
    for (int i = 0; i < N; i++) {
        int v, w;
        cin >> v >> w;
        items[i + 1] = {v, w};
    }

    vector<int> dp(W + 1, 0);

    for (int i = 0; i < N; i++) {
        auto item = items[i + 1];
        vector<int> tmp_dp = dp;
        for (int j = 0; j <= W; j++) {
            if (j - item.second >= 0) {
                chmax(tmp_dp[j], dp[j - item.second] + item.first);
            }
        }
        dp = move(tmp_dp);
    }

    cout << dp[W] << endl;

    return 0;
}



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

#define MOD 1000000007LL
const long long INF = 1LL << 60;

typedef long long ll;

ll addm(ll a, ll b){
    ll x = (a%MOD+b%MOD)%MOD;
    if (x < 0) x+=MOD;
    return x;
}

ll mulm(ll a, ll b){
    return(a%MOD*b%MOD)%MOD;
}

int main(){
    int N, K;
    ll ans=0;
    scanf("%d %d",&N,&K);
    for(ll i = K;i<N+2;i++){
        ans = addm(ans, addm( addm(mulm(N,i),-mulm(i,i)), addm(i,1LL)));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
  string sa,sb,sc;
  cin>>sa;
  cin>>sb;
  cin>>sc;
  int lena=sa.length();
  int lenb=sb.length();
  int lenc=sc.length();
  int na=0,nb=0,nc=0;
   char tmp=sa[0];
   na++;
while(na!=lena+1&&nb!=lenb+1&&nc!=lenc+1){
  switch(tmp){
    case 'a':
    if(na!=lena){
    tmp=sa[na];
  }
    na++;
    break;
    case 'b':
    if(nb!=lenb){
    tmp=sb[nb];
  }
    nb++;
    break;
    case 'c':
    if(nc!=lenc){
    tmp=sc[nc];
  }
    nc++;
    break;
  }
}
if(na==lena+1){
  cout<<'A'<<endl;
}
if(nb==lenb+1){
  cout<<'B'<<endl;
}
if(nc==lenc+1){
  cout<<'C'<<endl;
}
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

while True:
    if len(a) == 1:
        break
    a.sort()
    for i in range(len(a)-1, 0, -1):
        a[i] %= a[0]
        if a[i] == 0:
            del a[i]
print(a[0])

Measured memory_bytes: 14252
def main():
    from sys import stdin
    #input = sys.stdin.readline
    #sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    S = input()
    Q = int(input())
    mae = ''
    usiro = ''
    s = True
    for _ in range(Q):
        q = stdin.readline()
        if q[0]=='1':
            s = not s
        else:
            if q[2]=='1' and s:
                mae = q[4] + mae
            elif q[2]=='2' and s:
                usiro = usiro + q[4] 
            elif q[2]=='2' and not s:
                mae = q[4] + mae
            else:
                usiro = usiro + q[4]
    if s:
        print(mae+S+usiro)
    else:
        print(usiro[::-1]+S[::-1]+mae[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4744
X = int(input())

if 400 <= X and X <= 599:
    print(8)
if 600 <= X and X <= 799:
    print(7)
if 800 <= X and X <= 999:
    print(6)
if 1000 <= X and X <= 1199:
    print(5)
if 1200 <= X and X <= 1399:
    print(4)
if 1400 <= X and X <= 1599:
    print(3)
if 1600 <= X and X <= 1799:
    print(2)
if 1800 <= X and X <= 1999:
    print(1)

Measured memory_bytes: 9192
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int x[5];
  for (int i = 0; i < 5; ++i)
  {
    cin >> x[i];
  }

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 10000000

int main()
{
    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 if(s=="SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 1000000000000000000
#define PI 3.14159265359
#define ull unsigned long long
#define MYPOW_t int

int main(){
    char str[22]={};
    scanf("%s",str);
    printf("%c%c%c",str[0],str[1],str[2]);
    return 0;
}





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

#define ll long long

int main(){

    int x, y;
    queue<int> left;
    queue<int> right;

    while(1){
        cin >> x >> y;
        if((x ==0) && (y == 0)){
            break;
        }
        left.push(x);
        right.push(y);
    }    

    int length = left.size();

    for(int i=0; i<length; i++){
        if(left.front() > right.front()){
            cout << right.front() << " " << left.front() << endl;
        }else{
            cout << left.front() << " " << right.front() << endl;
        }
        left.pop();
        right.pop();

    }

    return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

void insertionSort(vector<int>& a, int n, int g, int& cnt) {
  for (int i = g; i < n; ++i) {
    const int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j+g] = a[j];
      j = j-g;
      ++cnt;
    }
    a[j+g] = v;
  }
}

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

  int cnt = 0;
  vector<int> g;
  for(int h=1;;) {
    if (h > n) {
      break;
    }
    g.push_back(h);
    h = 3*h + 1;
  }
  reverse(g.begin(), g.end());

  int m = (int)g.size();
  rep(i,m) {
    insertionSort(a, n, g[i], cnt);
  }

  cout << m << endl;
  rep(i,m) {
    if (i > 0) cout << " ";
    cout << g[i];
  }
  cout << endl << cnt << endl;
  rep(i,n) {
    cout << a[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 6808
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
# dp=[[float('inf')]*2 for i in range(keta+1)]
dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

Measured memory_bytes: 223760
#include<stdio.h>
int main(){
    int n;
    int count=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C')
                count++;

            }
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 1732
#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:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    if(N%2 == 1) return 0;
    ll base = 5;
    while(N >= base){
        res += N/base/2;
        base *= 5;
    }
    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
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_081_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(1).
    01 INP    PIC X(3).
    01 cnt    PIC 9(1).
    01 ZS     PIC Z(1)9.
    01 ans    PIC X(1).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    MOVE 0 TO cnt.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 3 < i
        IF INP(i:1) = '1' THEN
            ADD 1 TO cnt
        END-IF
    END-PERFORM.

    MOVE cnt TO ZS

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include<queue>
#include<map>
using namespace std;
#define INFTY (1<<21)

bool isSameColor( string state ){
    for ( int i = 1; i < state.size(); i++ ){
        if ( state[i-1] != state[i] ) return false;
    }
    return true;
}

char getColor( char c1, char c2 ){
    if ( c1 == 'g' ) return (c2=='r' ? 'b' : 'r');
    else if ( c1 == 'b' ) return (c2=='r' ? 'g' : 'r');
    else if ( c1 == 'r' ) return (c2=='b' ? 'g' : 'b');
}

int bfs(string s){
    queue<string> Q;
    map<string, bool> V;
    map<string, int> D;

    Q.push(s);
    V[s] = true;
    D[s] = 0;
    string u, v;
    
    while(!Q.empty()){
        u = Q.front(); Q.pop();
        if ( isSameColor(u) ) return D[u];
        for ( int i = 1; i < u.size(); i++ ){
            if ( u[i-1] != u[i] ){
                v = u;
                v[i-1] = v[i] = getColor(u[i-1], u[i]);
                if ( !V[v] ){
                    V[v] = true;
                    D[v] = D[u] + 1;
                    Q.push(v);
                }
            }
        }
    }

    return INFTY;
}

int main(){
    string initial;
    while( cin >> initial ){
        if ( initial == "0" ) break;
        int cost = bfs( initial );
        if ( cost == INFTY ) cout << "NA" << endl;
        else cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 2748
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

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

int main(){
	int cnt1=0,cnt2=0,tmp=0,anss1=0,anss2=0;
	string str,ans1,ans2,a;
	vector<string> v;

	getline(cin,str);
	for(int i=0;i<str.size()+1;i++){
		if(str[i]==' ' || i==str.size()){
			a=str.substr(tmp,i-tmp);
			v.push_back(a);
			tmp=i+1;
			cnt1++;
		}
	}
	for(int i=0;i<cnt1;i++){
		for(int j=0;j<cnt1;j++){
			if(v[i]==v[j]){
				cnt2++;
			}
		}
		if(anss1<cnt2){
			anss1=cnt2;
			ans1=v[i];
		}
		if(anss2<v[i].length()){
			anss2=v[i].length();
			ans2=v[i];
		}
		cnt2=0;
	}
	cout << ans1 << ' ' << ans2 << endl;
	return 0;
}

Measured memory_bytes: 1192
n,x = map(int,input().split())

li = list(map(int,input().split()))

ans = [0]

d = 0

for i in li:
    d += i
    ans.append(d)
    
cnt = 0

for i in ans:
    if i <= x:
        cnt += 1
    else:
        break
    
print(cnt)
    


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int sum = X;  //余りはすでに考えた
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int n = 1;
    int count = 0;
    while (n <= D) {
      count++;
      n = n + A;
    }
    sum += count;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a < b) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}


Measured memory_bytes: 22996
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

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

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 200000;
const int ADD = 500107;

int n;
int A[MAX];
VI B;


int main()
{
	//freopen("in.txt", "r", stdin);
	
	cin >> n;
	FOR (i,0,n)
	{
	    scanf("%d", &A[i]);
	    B.PB(A[i]);
	}
	
	sort(ALL(B));
	int res = 0;
	
	FOR (i,0,n)
	{
	    int x = lower_bound(ALL(B), A[i]) - B.begin();
	    if ((x % 2) != (i % 2)) ++ res;
	}
    
    
    cout << res/2 << endl;
	   
    return 0;
}

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

using namespace std;
using ll = long long int;
#define INF 20000000000000000
#define MOD 1000000007

int main(void){
  string str;
  cin >> str;
  bool ok = true;
  
  int check[26] = {0};
  
  for(int i = 0;str[i] != '\0';i++) check[str[i]-'a']++;
  
  for(int i = 0;i < 26;i++) if(check[i] >= 2) ok = false;
  
  cout << (ok?"yes":"no") << endl;
}

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

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

    int q;
    cin>>q;

    vector<int> a;
    for(int i=1;i<=q;i++){
        int qr;
        cin>>qr;

        if(qr==0){
            int x;
            cin>>x;

            a.push_back(x);
        }

        else if(qr==1){
            int p;
            cin>>p;

            cout<<a[p]<<"\n";
        }

        else{
            a.pop_back();
        }
    }
    
    return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define rep(i,a,n) for (register int i=a;i<=n;i++)
#define per(i,a,n) for (register int i=n;i>=a;i--)
#define FOR(i,a,n,x) for (register int i=a;i<=n;i+=x)
#define ROF(i,a,n,x) for (register int i=n;i>=a;i-=x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

template <typename T>

inline void read(T &X) {
  X = 0; char ch = 0; T op = 1;
  for(; ch > '9' || ch < '0'; ch = getchar())
    if(ch == '-') op = -1;
  for(; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n;

int main() {
#ifdef WiLe
  freopen ("input.txt", "rt", stdin);
#endif

  read(n);
  ll sum= 0;
  rep (i, 1, n) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;

#ifdef WiLe
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
/*
# author : WiLe
# date : 2020/04/16
*/

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
const int MAX = 1e6+5;
vector<int> lp, primes;
void factor_sieve()
{
    lp.resize(MAX);
    lp[1] = 1;
    for (int i = 2; i < MAX; ++i)
    {
        if (lp[i] == 0)
        {
            lp[i] = i;
            primes.emplace_back(i);
        }
        for (int j = 0; j < primes.size() && primes[j] <= lp[i]; ++j)
        {
            int x = i * primes[j];
            if (x >= MAX)
                break;
            lp[x] = primes[j];
        }
    }
}
int32_t main(){
    factor_sieve();
  int n; cin>>n;
  vector<int> v(n);
  rep(i,0,n)cin>>v[i];
  set<int> s;
  int ok=1;
    rep(i,0,n){
        set<int> st;
        int x=v[i];
        while(x!=1){
             st.insert(lp[x]),x/=lp[x];
        }
        rr(st){
            if(s.find(val)!=s.end()){
                ok=0;
                break;
            }
            s.insert(val);
        }
    }
    int gcd=0;
    rep(i,0,n){
        gcd=__gcd(gcd,v[i]);
    }
    if(!ok){
        if(gcd==1)cout<<"setwise coprime\n";
        else cout<<"not coprime\n";
        return 0;
    }
    cout<<"pairwise coprime\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool pred = s[0] == s[1] or s[1] == s[2] or s[2] == s[3];
    print(pred ? "Bad" : "Good");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int found= 0;
        char[] ch= new char[S.length()];
        for(int i=0; i<N-2;i++){
            String check = Character.toString(S.charAt(i));
            if(check.equals("A") ){
                check = Character.toString(S.charAt(i+1));
                if(check.equals("B")){
                    check = Character.toString(S.charAt(i+2));
                    if(check.equals("C")){
                        found++;
                    }
                }
            }
        }
        System.out.println(found);
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int b, f, r, v;
  int house[4][3][10] = {};
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;

    house[b - 1][f - 1][r - 1] += v;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << house[i][j][k];
      }

      cout << endl;
    }

    if (i != 3) {
      cout << "####################" << endl;
    }
  }
  
  return 0;
}


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] a = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                a[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, a);
    }
}

class Solver {
    public void solve(long N, long[] a) {
        int current = 1;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (current != a[i]) {
                ans++;
            }
            else {
                current++;
            }
        }
        if (N == ans) {
            System.out.println(-1);
        }
        else {
            System.out.println(ans);
        }
    }
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int j, k;
    cin >> j >> k;
    vec.at(j - 1) += 1;
    vec.at(k - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 3608
#include "stdio.h"

int main(void){
  int x;
  scanf("%d", &x);
  int hour = x /3600;
  int min = (x - hour * 3600) / 60;
  int sec = (x - hour * 3600 - min * 60);
  printf("%d:%d:%d\n", hour, min, sec);
}



Measured memory_bytes: 2076
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
#define INF (1<<29)

int main() {
    int n,tmp;
    int a=0,b=0,c=0;

    cin>>n;
    for(int i=0; i<n; i++) {
        cin >> tmp;
        if (tmp % 4 == 0){
            a++;
        } else if (tmp % 2 == 0){
            b++;
        } else {
            c++;
        }
    }

    if(a==0&&c==0){
        cout<<"Yes"<<endl;
        return 0;
    }

    if(b>0)c++;//2の集合を1とみなす
    if(a-c>=-1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

int L;

long double val;
int main(void) {

	cin >> L;

	val = ((long double)L) / 3.0;

	long double ans = val*val*val;

	cout << setprecision(12) <<fixed<< ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,i,t;
	scanf("%d",&n);
	int A[n],a[n];
	for(i=0;i<n;i++)
	{
		scanf(" %d",&A[i]);
		t=A[i];
		a[t-1]=i+1;
	}
	for(i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
}


Measured memory_bytes: 1536
//programmingEducation.cpp
#include <iostream>
using namespace std;

int main () {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World";
  } else {
  int a; int b;
  cin >> a;
  cin >> b;
  cout << a + b;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
# print(N)

X = N
shou = 0
amari = 0
keta_sum = 0

while X != 0:
    shou = X // 10
    amari = X % 10
    # print(shou)
    # print(amari)
    keta_sum = keta_sum + amari
    X = shou

# print(keta_sum)
if N % keta_sum == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    int N,R;
    cin>>N>>R;
    if(N >= 10)
    {
        cout<<R<<endl;
    }else
    {
        cout<<R + 100*(10-N)<<endl;
    }
    return 0;
}


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

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();
        Arrays.sort(a);
        int mid=a[n/2];
        int prev = a[n/2-1];
       // System.out.println(mid +" " + prev);
        if(mid==prev)
            System.out.println(0);
        else{
            int ans=mid-prev;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 50600
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

const ll maxN = 2e5+5;
const ll inf = 1e9+5;
vector<ll> adj[maxN];
ll a[maxN];
ll ans[maxN];
vector<ll> dp(maxN+1, inf);

void dfs(ll u, ll p) {
    ll idx = upper_bound(all(dp), a[u]) - dp.begin();
    ll before = dp[idx];
    if(a[u] > dp[idx-1])
        dp[idx] = a[u];
    ans[u] = lower_bound(all(dp), inf) - dp.begin() - 1;
    for(auto v : adj[u]) {
        if(v != p) {
            dfs(v, u);
        }
    }
    dp[idx] = before;
}

void solve(ll tc) {
    ll n;
    cin>>n;
    for(ll i=0; i<n; ++i)
        cin>>a[i];
    for(ll i=0; i<n-1; ++i) {
        ll u, v;
        cin>>u>>v;
        adj[u-1].pb(v-1);
        adj[v-1].pb(u-1);
    }
    dp[0] = -inf;
    dfs(0, -1);
    for(ll i=0; i<n; ++i)
        cout<<ans[i]<<"\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    for(ll tc=1; tc<=t; ++tc) {
        solve(tc);
    }    
    return 0;
}

Measured memory_bytes: 30312
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
char tmp[maxn];
int n;
string s;

bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  return true;
}

int dp[maxn][2];

void solve() {
  memset(dp, -1, sizeof(dp));
  dp[1][0] = 1;
  if (n >= 2) {
    dp[2][1] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int l = 0; l < 2; l++) {
      auto cur = dp[i][l];
      if (cur == -1) {
        continue;
      }
      if (l == 1 || (l == 0 && s[i - 1] != s[i])) {
        dp[i + 1][0] = max(dp[i + 1][0], cur + 1);
      }
      if (i + 1 < n && (l == 0 || (l == 1 && (s[i - 2] != s[i] || s[i - 1] != s[i + 1])))) {
        dp[i + 2][1] = max(dp[i + 2][1], cur + 1);
      }
    }
  }
  int res = max(dp[n][0], dp[n][1]);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

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

using namespace std;

int main(){
  string maxs="zyxwvutsrqponmlkjihgfedcba";
  string rmaxs="abcdefghijklmnopqrstuvwxyz";
  string s;cin>>s;
  if(s==maxs){
    cout<<-1<<endl;
    return 0;
  }

  if(s.size()!=26){
    //未使用のから最小を選んで末尾に足す
    set<char> used;
    rep(i, s.size()) used.insert(s[i]);

    rep(i, rmaxs.size()){
      if(!used.count(rmaxs[i])){
        cout<<s<<rmaxs[i];
        break;
      }
    }
    return 0;
  }


  vector<char> removed;
  rep(i, s.size()){
    if(removed.size()>0 && s[26-1-i]<removed[removed.size()-1]){
      // iは1以上であることが保証されている
      cout<<s.substr(0, 26-1-i);
      // 最後は削った文字の中で今見ている文字よりも大きい最小の文字を表示する
      sort(removed.begin(), removed.end());
      auto c = s[26-1-i];
      rep(j, removed.size())if(c<removed[j]){
        cout<<removed[j];
        break;
      }

      return 0;
    }
    removed.push_back(s[26-1-i]);
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
 main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
    string s;
	int n,k;
	cin>>n>>k;
	cin>>s;
	char c;
	c=s[k-1];
	c=tolower(c);
	s[k-1]=c;
	cout<<s;
}


Measured memory_bytes: 256