akhauriyash/Code-Regression huggingface dataset:
arr = Array.new(4){ Array.new(3) { Array.new(10, 0) } }
n = gets.to_i
for i in 1..n
   b, f, r, v = gets.split.map{|v|
      v.to_i
   }
   arr[b-1][f-1][r-1] += v
end
for i in 0..3
  for j in 0..2
    for k in 0..9
      print " ",arr[i][j][k]
      end
    print "\n"
  end
  if i != 3
    print "####################", "\n"
  end
end


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    stack<int> s;
    queue<int> q;
    rep (i, n) {
      int a;  cin >> a;
      if (n % 2) {
        if (i % 2) {
          q.push(a);
        } else {
          s.push(a);
        }
      } else {
        if (i % 2) {
          s.push(a);
        } else {
          q.push(a);
        }
      }
    }
    while (!s.empty()) {
      cout << s.top() << " ";
      s.pop();
    }
    while (!q.empty()) {
      cout << q.front() << " ";
      q.pop();
    }

    return 0;
}


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

using namespace std;

int main(void)
{
  int n, m;
  cin >> n >> m;

  vector<int> s(m);
  vector<char> c(m);

  for (int i = 0; i < m; i++)
    cin >> s[i] >> c[i];

  for (int i = 0; i < 1000; i++) {
    bool flag = true;
    string str = to_string(i);
    if (str.length() < n)
      continue;
    for (int j = 0; j < m; j++) {
      if (str[s[j] - 1] != c[j])
        flag = false;
    }
    if (flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

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

ll dp[4000][4000];

int main()
{
    int n,s;
    cin>>n>>s;
    vector<int>a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    dp[0][0]=1;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=s;++j){
            dp[i][j]=dp[i-1][j]*2;
            if(j-a[i-1] >= 0)dp[i][j]+=dp[i-1][j-a[i-1]];
            dp[i][j]%=998244353;
        }
    }
    cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 86140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool powtwo(int N) {
    if(N & 1) {
        return N == 1;
    }
    return powtwo(N >> 1);
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(powtwo(N)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << "1 2" << endl;
    cout << "2 3" << endl;
    for(int i = 4; i < N; i += 2) {
        cout << N + 1 << " " << i + 1 << endl;
        cout << i << " " << i + 1 << endl;
    }
    cout << "3 " << N + 1 << endl;
    for(int i = N + 2; i < 2 * N; i += 2) {
        cout << i << " " << N + 1 << endl;
        cout << i << " " << i + 1 << endl;
    }
    if(N % 2 == 0) {
        bool ok = false;
        for(int i = 2; i < N; i+= 2) {
            if(ok) break;
            int j = (N ^ 1 ^ i);
            if(j < N && j > 1) {
                ok = true;
                cout << N << " " << i + N << endl;
                cout << N + N << " " << j << endl;
            }
        }
    }
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;



int main(){
  int n,k;
  cin >> n >> k;
  ll l = n/k,l2 = (n+k/2)/k;
  if(k%2!=0){
    cout<<l*l*l<<endl;
  }else{
    cout<<l*l*l+l2*l2*l2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}

string k;
int d;
ll dp[10005][105][2][2];

ll solve(int index, int sum, int close, int used) {
    if (index == k.length()) {
        if (!sum && used)
            return 1;
        else
            return 0;
    }
    if (dp[index][sum][close][used] != -1)
        return dp[index][sum][close][used];
    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        if (close && ((i + '0') > k[index])) break;
        int zeroes = i?1:used;
        if (close && (i + '0') == k[index]) ans = (ans + solve(index + 1, (sum + i)%d, close, zeroes))%MOD;
        else ans = (ans + solve(index + 1, (sum + i)%d, 0, zeroes))%MOD;
    }
    return dp[index][sum][close][used] = ans;
}

int main() {
    IO;
    cin >> k;
    cin >> d;
    for (int i = 0; i < k.length(); i++) {
        for (int j = 0; j < d ;j++) {
            dp[i][j][0][0] = -1, dp[i][j][1][1] = -1, dp[i][j][0][1] = -1, dp[i][j][1][0] = -1;
        }
    }
    cout << solve(0,0,1,0) << "\n";
    return 0;
}


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

int main()
{
    int a, b;
    int judge = 1, i;
    string s;
    
    cin >> a >> b >> s;
    
    for(i = 0; i <= a + b; i++) {
        if(i == a) {
            if(s[i] != '-') {
                judge = 0;
                break;
            }
        } else {
            if((48 > int(s[i])) || (int(s[i]) > 57)) {
                judge = 0;
                break;
            }
        }
    }
    
    if(judge == 0) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        
    }
    return 0;
}

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

using namespace std;

void lcs(string x,string y){
  int m=x.length();
  int n=y.length();
  int c[m+1][n+1];
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(x[i-1]==y[j-1]){
        c[i][j]=c[i-1][j-1]+1;
      }else{
        c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
    }
  }
  cout << c[m][n] << endl;
}

int main(){
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    string x,y;
    cin >> x >> y;
    lcs(x,y);
  }
}

Measured memory_bytes: 7100
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
prev = 0
s = 0
for i in range(n):
    if a[i] == i+1:
        s+=1
        if prev:
            s-=1
            prev = 0
        else:prev = 1
    else:prev = 0
print(s)

Measured memory_bytes: 24468
public class Main {
    public static void main(String[] args) {
 
        // ??????????????????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);
 
        // ????????????????????????´???° (???????????????°???¨??¨????°) ???????????????.
        int tate = sc.nextInt();
        int yoko = sc.nextInt();
 
        // ????????????????????????´???° (??????????????´?) ??????????????????§???¨?????????.
        // ??????????????????¨?????????.
        // ?????????????????§????????????¨????????????????.
        int[][] matrix = new int[tate][yoko];
        int sum = 0;
        int kado = 0;
        for (int i = 0; i < tate; i ++) {
            sum = 0;
            for (int j = 0; j < yoko; j ++) {
                matrix[i][j] = sc.nextInt();
                System.out.print(matrix[i][j] + " ");
                sum += matrix[i][j];
            }
            kado += sum;
            System.out.println(sum);
        }
 
        // ??????????????????¨?????????.
        for (int i = 0; i < yoko; i ++) {
            sum = 0;
            for (int j = 0; j < tate; j ++) { sum += matrix[j][i]; }
            System.out.print(sum + " ");
        }
        System.out.println(kado);
    }
}

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

int main(){
  int k; cin >> k;
  queue<long long> a;
  for(int i = 1; i < 10; i++){
  	a.push(i);
  }
  
  for(int i = 1; i < k; i++){
  	long long x = a.front(); a.pop();
  	if(x%10 != 0) a.push(10*x+x%10-1);
  	a.push(10*x+x%10);
  	if(x%10 != 9) a.push(10*x+x%10+1);
  }
  cout << a.front() << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int m,f,r;
  int su;
 
  do{
    scanf("%d%d%d",&m,&f,&r);
    su = m + f;
    
    if(m == -1 && f == -1 && r == -1)
      break;
    else if(m == -1 || f == -1)
      putchar('F');
    else if(su >= 80)
      putchar('A');
    else if(su >= 65 && su < 80)
      putchar('B');
    else if(su >= 50 && su < 65)
      putchar('C');
    else if(su >= 30 && su < 50){
      if(r >= 50)
	putchar('C');
      else
	putchar('D');
    }
    else
      putchar('F');

    puts("");

  }while(1);


  return(0);
}

Measured memory_bytes: 1016
class UnionFind:
    def __init__(self, n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        elif self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    com, x, y = map(int, input().split())

    if com == 0:
        uf.merge(x, y)
    else:
        print(1 if uf.same(x, y) else 0)


Measured memory_bytes: 6048
#include <iostream>
#include <string>
using namespace std;
int main(){
    string cards, s;
    int m, h, i;
    while(cin>>cards,cards != "-"){
      cin>>m;
        for(int i = 0; i < m; i++){
            cin >> h;
            s.assign(cards, 0, h);
            cards.erase(0, h);
            cards += s;
        }
        cout << cards << endl;
    }

    return 0;
}

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

int main(){
	string g;
	int y, m, d;
	while(1){
		cin >> g;
		if(g=="#")break;
		cin >> y >> m >> d;
		if(y>31||(y==31&&m>=5)){
			g = "?";
			y -= 30;
		}
		cout << g+" " << y << " " << m << " " << d << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k,c=0;
    cin>>s;

    cin>>k;

    for(int i = 0; i<s.size(); i++)
    {
        if(s[i]!='1')break;
        c++;
    }

    if(k <= c)
        cout<<"1\n";
    else
        cout<<s[c]<<endl;
    return 0 ;
}



Measured memory_bytes: 256
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
x,y = 0,0
arg = 90
for l in range(len(N)):
    d,a = [int(i) for i in N[l].split(",")]
    if d == 0 and a == 0:
        break
    x = x + d * math.cos(math.radians(arg))
    y = y + d * math.sin(math.radians(arg))
    arg = arg - a
print(math.trunc(x))
print(math.trunc(y))



Measured memory_bytes: 5716
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

string s = "AKIHABARA";

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    vi oc;
    F0R(i,sz(s)) if (s[i] == 'A') oc.pb(i);
    
    string T; cin >> T;
    F0R(i,1<<sz(oc)) {
        string S = s;
        F0Rd(j,sz(oc)) if (i&(1<<j)) S.erase(S.begin()+oc[j]);
        if (S == T) {
            cout << "YES";
            exit(0);
        }
    }
    cout << "NO";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine();
		for(int i = n.Length - 2; 0 < i; i -= 2)
		{
			var a = n.Substring(0, i / 2);
			var b = n.Substring(i / 2, i / 2);
			if(a == b)
			{
				WriteLine(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 17488
#include<stdio.h>
#include<math.h>
 
double area(double a,double b,double c)
{
 double t = (a + b + c)/2;
 return sqrt(t*(t-a)*(t-b)*(t-c));
}
 
int main()
{
 double x1,y1,x2,y2,x3,y3,xp,yp;
 double a,b,c; //ツ陛督づ個陳キツつウ
 double x,y,z; //ツ点Pツづ各ツ点ツづ慊づづ個仰猟猟」
 double S1,S2,S3,S;
 
 while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF)
 {
  x = sqrt(pow(x1-xp,2)+pow(y1-yp,2));
  y = sqrt(pow(x2-xp,2)+pow(y2-yp,2));
  z = sqrt(pow(x3-xp,2)+pow(y3-yp,2));
 
  a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  b = sqrt(pow(x3-x1,2)+pow(y3-y1,2));
  c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
 
  S1 = area(a,x,y);
  S2 = area(b,x,z);
  S3 = area(c,y,z);
  S = area(a,b,c);
 
  if((S > S1 + S2)&&(S > S2 + S3)&&(S > S1 + S3))
   printf("YES\n");
  else printf("NO\n");
 }
 return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a1[110000],b1[110000],c[110000];
int main(){
  ll a,b,m,ans=1e9;
  cin>>a>>b>>m;
  ll am=1e9,bm=1e9;
  rep(i,0,a){cin>>a1[i];am=min(am,a1[i]);}
  rep(i,0,b){cin>>b1[i];bm=min(bm,b1[i]);}
  ans=am+bm;
  ll tmp1,tmp2,tmp3;
  rep(i,0,m){
    cin>>tmp1>>tmp2>>tmp3;
    ans=min(ans,a1[tmp1-1]+b1[tmp2-1]-tmp3);
  }
  cout<<ans;
}

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

int main() {
    long long n;cin>>n;
    long long min=100000000000000;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(min>(n/i)+i) min=i+(n/i);
        }
    }
    cout<<min-2<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readLn >>= putStrLn . ( iterate ( ++ " Eve" ) "Christmas" !! ) . ( 25 - )

Measured memory_bytes: 508
#include <iostream>

using namespace std;

typedef long long ll;

ll n, ans;
ll a[500000];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        cnt++;
        ans = max(ans, (ll)cnt);
        if (i == 0 || a[i - 1] < a[i])
        {
            cnt = 0;
        }
    }
    cout << ans - 1;
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b  >> h;
    cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int a, b, c, d;
	cin >> a>>b>>c >> d;
	int ans = 0;
	ans = min(b, d) - max(a, c);
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, ans;
int a[maxn];
priority_queue<int> Q;
int main()
{
	scanf("%d", &n); 
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, greater<int>());
	for(int i = 1; i <= n; ++i)
	{
		while(!Q.empty() && Q.top() > a[i]) Q.pop();
		if(!Q.empty() && Q.top() == a[i])
		{
			++ans;
			Q.pop();
			continue;
		}
		int k = 1 << (32 - __builtin_clz(a[i]));
		Q.push(k - a[i]);
	}
	printf("%d\n", ans);
	return 0;
}
		

Measured memory_bytes: 4756
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	set<int> sa;
	for (int i = 0; i < n; i++) {
		cini(a);
		if (sa.count(a)) {
			cout << "NO" << endl;
			return;
		}
		sa.insert(a);
	}
	cout << "YES" << endl;
}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
const ll MAXN=1e5+10;
ll dp[MAXN],h[MAXN],i;
ll jump(ll  n)
{
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	REP(i,2,n)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	return dp[n-1];
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n;
	cin>>n;
	rep(i,n)
	cin>>h[i];
	cout<<jump(n);
	return 0;
}

Measured memory_bytes: 1792
(h,n),*c=[[*map(int,i.split())]for i in open(0)]
dp=[10**9]*(2*10**4+1)
c.sort()
dp[0]=0
for i in range(h):
    for a,b in c:
        if i+a<=2*10**4:
            dp[i+a]=min(dp[i+a],dp[i]+b)
        else:break    
print(min(dp[h:]))

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

#define MAX 20

bool solve(int , int);

int A[MAX];
int n;

int main(void) {
  int q, m, i = 0;

  scanf("%d", &n);
  while(i<n) scanf("%d", &A[i++]);
  scanf("%d", &q);

  while(q--) {
    scanf("%d", &m);
    if(solve(0, m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

bool solve(int i, int m) {
  bool res;
  if (m == 0) return true;
  if (i >= n) return false;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



Measured memory_bytes: 2112
#!/usr/bin/env python3

#import
#import math
#import numpy as np
X = int(input())

li = [i ** 5 for i in range(1005)]

for a in range(1000):
    for b in range(1000):
        t1 = li[a] - li[b]
        t2 = li[a] + li[b] if b % 2 == 1 else t1
        if t1 == X:
            print(a, b)
            exit()
        elif  t2 == X:
            print(a, -b)
            exit()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005];
char s[100005];

int main() {
    scanf("%d", &n);
    forn(i, n) {
        if (i == 0) {
            s[i] = '+';
        } else {
            scanf(" %c", s + i);
        }
        scanf("%d", a + i);
    }
    LL ans = 0;
    forn(i, n) {
        ans += a[i];
    }
    bool ok = true;
    forn(i, n) if (s[i] == '-') {
        ok = false;
        break;
    }
    if (ok) {
        cout << ans << endl;
        return 0;
    }
    LL sum = ans;
    ans *= -1;
    forn(i, n) if (s[i] == '-') {
        LL cur = a[i];
        for (int j = i + 1; j < n; ++j) {
            if (s[j] == '-') {
                break;
            }
            cur += a[j];
        }
        ans = max(ans, sum - 2ll * cur);
        sum -= 2ll * a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<int64_t> S = {N};
    for(int i=0; i<Q; i++){
        int64_t q;
        cin >> q;
        while(S.size() && S.back() >= q) S.pop_back();
        S.push_back(q);
    }
    int N_org = N;
    N = S[0];
    Q = S.size();

    vector<int64_t> num(Q);
    vector<int> tail(Q);
    vector<int> follow(Q);
    bitset<100000> dup;
    num[Q-1] = 1;
    tail[0] = N-1;
    multiset<pair<int64_t, int>> st;

    for(int i=Q-1; i>=0; i--){
        while(st.size()){
            auto it = prev(st.end());
            int64_t len = it->first;
            int idx = it->second;
            if(len >= S[i]){
                int64_t times = len / S[i];
                num[i] += num[idx] * times;
                int64_t rem = len % S[i];
                if(rem){
                    st.insert({rem, idx});
                }else{
                    dup[idx] = 1;
                    follow[idx] = i;
                }
                st.erase(it);
            }else{
                break;
            }
        }
        st.insert({S[i], i});
    }

    for(auto& p : st){
        int len = p.first, idx = p.second;
        tail[idx] = (len + N - 1) % N;
    }

    for(int i=0; i<Q; i++) if(dup[i]) tail[i] = tail[follow[i]];
    
    vector<int64_t> ans(N_org);
    for(int i=0; i<Q; i++) if(!dup[i]) ans[tail[i]] += num[i];
    for(int i=N-2; i>=0; i--) ans[i] += ans[i+1];
    for(int i=0; i<N_org; i++) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 11124
a, b = map(int, input().split())
zero = (a == 0 | b == 0) | (a < 0 and 0 < b) | (b < 0 and 0 < a)
negative_a = (a < 0 and 0 < b) and (a + b + 1) % 2 != 0
negative_b = (a < 0 | b < 0) and (a + b + 1) % 2 != 0
if zero:
    print("Zero")
elif negative_a | negative_b:
    print("Negative")
else:
    print("Positive")

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

vector<vector<pair<int, int>>> g(1e5);

void dfs ( int now, int prev, vector<int>& color, int col ) {
    color[now] = col;
    for ( auto tmp_num : g[now] ) {
        if ( tmp_num.first != prev ) {
            dfs(tmp_num.first, now, color, col ^ ( tmp_num.second&1) );
        }
    }
}

int main(){
    int n;
    cin >> n;
    rep(i, n-1) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        --u, --v;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    vector<int> color(n, 1e8);
    dfs(0, -1, color, 0);
    rep(i, color.size()) {
        cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 9088
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
D = {str(i):0 for i in range(1,N+1)}
for j in range(M):
    p,s = A[j]
    if s=="AC" and C[p]==0:
        C[p] += 1
wa = 0
for j in range(M):
    p,s = A[j]
    if s=="WA":
        if C[p]==1 and D[p]==0:
            wa += 1
    else:
        if D[p]==0:
            D[p] += 1
ac = 0
for i in range(1,N+1):
    ac += C[str(i)]
print(ac,wa)

Measured memory_bytes: 147248
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    if (h < w)
        swap(h, w);
    cout << (n + h - 1) / h << "\n";
    return 0;
}

Measured memory_bytes: 256
// ABC083_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    ll num = M/N;
    vector<ll> vec;
    for (ll i = 1; i <= num; i *= 2) {
        vec.push_back(i*N);  // N の倍数
    }
    
    cout << vec.size() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, tmp int
	fmt.Scan(&N)
	L := []int{}
	for n := 0; n < N; n++ {
		fmt.Scanf("%d", &tmp)
		L = append(L, tmp)
	}
	sort.Sort(sort.IntSlice(L))
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			lower := L[i] + L[j]
			k := sort.Search(len(L), func(t int) bool { return lower <= L[t] })
			ans += k - j - 1
		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int cnt[2] = {0};
int n, p;

int main()
{
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; ++i)
    {
      int a;
      scanf("%d", &a);
      cnt[a%2] += 1;
    }
  ll ans;
  if (p == 1 && cnt[1] == 0)
    ans = 0;
  else if (cnt[1] == 0)
    ans = (1ll<<(n));
  else 
    ans = (1ll<<(n-1));
  printf("%lld\n", ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    string S = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size()){
        if (s[i] != S[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

int main() {
  int N, i, tmp = 0, result = 0;
  cin >> N;
  long long H[N];
  for (i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (i = 0; i < N-1; i++) {
    if (H[i] >= H[i+1]) {
      tmp++;
    } else {
      if (tmp > result) result = tmp;
      tmp = 0;
    }
  }
  if (tmp > result) result = tmp;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
long long a, b;
long long counto;
long long ans[109];
char bb[5];
int main() {
	long double W = 0, H = 0, x = 0, y = 0;
	int counto = 0;
	cin >> W >> H >> x >> y;
	cout << setprecision(9) << W * H / 2 << " ";
	 if (x == W / 2 && y == H / 2) {
		cout << '1' << endl;
		return 0;
	}
	else{
		cout << '0' << endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

void dp(int p, int q, vector<vector<int>> &V, vector<LL> &s, LL mod){
	for(auto u : V[q]) if(u != p){
		dp(q,u,V,s,mod);
		(s[q] *= (s[u]+1)) %= mod;
	}
}

void solve(int p, int q, LL x, vector<vector<int>> &V, vector<LL> &s, vector<LL> &ans, LL mod){
	ans[q] = s[q]*x%mod;
	vector<LL> b(V[q].size(),1);
	repm(i,V[q].size()-1,0) b[i-1] = b[i]*(V[q][i]==p?1:(s[V[q][i]]+1))%mod;
	LL a = 1;
	repp(i,0,V[q].size()) if(V[q][i] != p){
		solve(q,V[q][i],x*a%mod*b[i]%mod+1,V,s,ans,mod);
		a = a*(s[V[q][i]]+1)%mod;
	}
}

int main(){
	int N; LL M; cin >> N >> M;
	vector<vector<int>> V(N);
	repp(i,1,N){
		int x,y; cin >> x >> y;
		--x; --y;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	vector<LL> s(N,1),ans(N,0);
	dp(-1,0,V,s,M);
	solve(-1,0,1,V,s,ans,M);
	repp(i,0,N) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define m_p make_pair
#define mod 1000000007
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



signed main() {
	int n, a1, a2, a3, t = 0;
	cin >> n;
	vector<int>vec(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
	}
	sort(all(vec));
	reverse(all(vec));
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if (vec[i] >= vec[j] + vec[j + 1])continue;
			if (vec[i] < vec[j] + vec[n - 1]) {
				a1 = n - 1;
				goto skip;
			}
			a1 = j + 1;
			a2 = n;
			while (a1 + 1 < a2) {
				a3 = (a1 + a2) / 2;
				if (vec[i] < vec[j] + vec[a3]) {
					a1 = a3;
				}
				else {
					a2 = a3;
				}
			}
		skip:
			t += (a1 - j);
		}
	}
	cout << t << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back;
#define mod 1000000007
#define test cout<<"#"


int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ll k;
   cin>>k;
   ll sum = 0;
   for(ll x = 1; x <=k; x++)
   {
      for(ll y = 1; y<=k; y++)
      {
         for(ll z = 1; z <=k; z++)
         {
            sum = sum + __gcd(x, __gcd(y,z));
         }
      }
   }
   cout<<sum;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;
    if (min(b, d) >= max(a, c)) ans = min(b, d) - max(a, c);
    else ans = 0;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
(n, a, b, c, d) = parse.([Int], split(readline()))

ans = "NO"
l = 0
r = n - 1
cnt = 0
while cnt < 20
    m = div((l + r), 2)
    if b < a + m * c - (n - 1 - m) * d
        r = m
    elseif a + m * d - (n - 1 - m) * c < b
        l = m
    else
        ans = "YES"
        break
    end
    cnt += 1
end
println(ans)

Measured memory_bytes: 176560
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    ll n;cin>>n;
    vector<ll> a(n),b(n);
    ll s=0;
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        s-=b[i];
    }
    if(s<0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0,w=0;
    rep(i,n){
        if(a[i]<b[i]){
            w+=b[i]-a[i];
            ans++;
        }
    }
    if(w==0){
        cout<<0<<endl;return 0;
    }
    vector<ll> v;
    rep(i,n){
        if(a[i]>b[i]){
            v.push_back(a[i]-b[i]);
        }
    }
    sort(ALL(v),greater<ll>());
    rep(i,v.size()){
        w-=v[i];
        if(w<=0){
            cout<<ans+i+1<<endl;return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2428
/*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define gcd(X,Y) __gcd(X,Y)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define ifpresent(CON,VAL) (CON.find(VAL) != CON.end())
#define all(x) x.begin(),x.end()
#define at(X,N) get<N>(X)
#define ins insert
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define count_ones __builtin_popcountl
#define nl cout<<"\n";
#define name(X) (#X)
#define watch(X) cout << (#X) << " is " << (X) << "\n"
#define sqr(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mem(x,val) memset((x),(val),sizeof(x))
#define rite(X) freopen(X,"w",stdout)
#define read(X) freopen(X,"r",stdin)
//FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it, end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X,C) for( auto & X : C )
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
using st = string; typedef long long int li; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef tuple<int,int> i2; typedef tuple<int,int,int> i3; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<i2> vi2; typedef vector<i3> vi3; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<li, li> ll; typedef pair<li, ll> lll; typedef tuple<li,li> l2; typedef tuple<li,li,li> l3; typedef vector<li> vl; typedef vector<ll> vll; typedef vector<l2> vl2; typedef vector<l3> vl3; typedef vector<lll> vlll; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef double db; typedef complex<db> cd; typedef vector<cd> vcd; template <class S> using ve = vector<S>; template <class S> using gr = greater<S>; template <class S> using le = less<S>;

const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0/0.0;

int main() {
    ios_base::sync_with_stdio(0);
    // read("rr.txt");
    multiset<int,greater<int>> s; int n; cin>>n; vi v(n,0); FOR(i,0,n) cin>>v[i], s.insert(v[i]);
    FOR(i,0,n) {
        s.erase(s.find(v[i]));
        cout<<*s.begin()<<"\n";
        s.insert(v[i]);
    }
    return 0;
}


Measured memory_bytes: 11776
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def gauss_jordan(A, extended=False):
    """ ガウス・ジョルダン法(連立方程式の解) """

    N, M = len(A), max(A).bit_length()
    res = A[:]
    rank = 0
    for col in range(M):
        if extended and col == M-1:
            break
        pivot = -1
        for row in range(rank, N):
            if res[row]>>col & 1:
                pivot = row
                break
        if pivot == -1:
            continue
        res[rank], res[pivot] = res[pivot], res[rank]
        for row in range(N):
            if row != rank and res[row]>>col & 1:
                res[row] ^= res[rank]
        rank += 1
    # 解があるか確認
    for row in range(rank, N):
        if res[row]>>(M-1) & 1:
            return (-1, [])
    return (rank, res)

for _ in range(INT()):
    N = INT()
    A = LIST()
    S = input()
    M = max(A).bit_length()

    mat = [0] * M
    collen = 1
    for i in range(N-1, -1, -1):
        # 先手番なら今回のA[i]を左辺に取り込む
        if S[i] == '0':
            for k in range(M):
                mat[k] |= (A[i]>>k & 1) << collen
            collen += 1
        # 後手番なら今回のA[i]を右辺として、解があるか確かめる
        else:
            cur = mat[:]
            for k in range(M):
                cur[k] |= (A[i]>>k & 1) << collen
            # これまでの値の集合matでA[i]を作れるかどうか
            rank, res = gauss_jordan(cur, extended=True)
            if rank == -1:
                print(1)
                break
    else:
        print(0)


Measured memory_bytes: 75364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC49
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var split = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var h = int.Parse(split[0]);
            //var w = int.Parse(split[1]);

            for (var i = 0; i < h; i++)
            {
                line = Console.ReadLine();
                Console.WriteLine(line);
                Console.WriteLine(line);
            }
        }
    }
}


Measured memory_bytes: 2776
from fractions import gcd
n = int(input())
a = list(map(int, (input().split())))

if n == 2:
    print(max(a[0], a[1]))
    exit()

noskip = gcd(a[0], a[1])
skipped = max(gcd(a[0], a[2]), gcd(a[1], a[2]))

for i in range(2, n):
    skipped = max(gcd(skipped, a[i]), noskip)
    noskip = gcd(noskip, a[i])

print(max(noskip, skipped))

Measured memory_bytes: 16068
#include<iostream>

using namespace std;

int main(){
	
	int a, b, c;
	int count;
	
	for (;cin >> a >> b;){
		c = a + b;
		for(count = 0; c != 0; count++){
			c = c / 10;
		}
		cout << count << endl;
	}
	
	return 0;
}


Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define vi vector<int>
#define vii vector<pair<int,int>>
#define all(x) (x).begin,(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
using namespace std;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
bool isPrime(int n) {
    
    if (n == 1) {
        return false;
    }

    int i = 2;
  
    while (i*i <= n) {
        
        if (n % i == 0) {
            
            return false;
        }
        i += 1;
    }
    
    return true;
}
void solve(){
     int a,b;
     cin>>a>>b;
     cout<<a*b<<endl;
}
int main()
{   ios::sync_with_stdio(0);
    
    cin.tie(0);
    cout.tie(0);
    int p;
    p=1;
    
    while(p--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

class Polygon{
	int m;
	int x[] = new int[10];
	int y[] = new int[10];

	Polygon(int m){this.m = m;}

	void toPointO(){
		int difx = x[0], dify = y[0];

		for(int i=0;i<m;i++){
			x[i] -= difx;
			y[i] -= dify;
		}
	}

	void turn(){
		int i,tmp;

		if(y[1] > 0){
			for(i=1;i<m;i++){
				tmp = x[i];
				x[i] = y[i];
				y[i] = -tmp;
			}
		}
		else if(x[1] < 0){
			for(i=1;i<m;i++){
				x[i] = -x[i];
				y[i] = -y[i];
			}
		}
		else if(y[1] < 0){
			for(i=1;i<m;i++){
				tmp = x[i];
				x[i] = -y[i];
				y[i] = tmp;
			}
		}
	}

	void reversePoint(){
		int tx[] = x.clone();
		int ty[] = y.clone();

		for(int i=0;i<m;i++){
			x[i] = tx[m-i-1];
			y[i] = ty[m-i-1];
		}
	}

	boolean equals(Polygon b){
		for(int i=0;i<m;i++)
			if(this.x[i] != b.x[i] || this.y[i] != b.y[i])
				return false;
		return true;
	}
}

public class Main{
	public static void main(String[] args){
		int i,j,n;
		boolean flg;
		Polygon a,b;
		Scanner scan = new Scanner(System.in);

		while((n=scan.nextInt()) != 0){
			a = new Polygon(scan.nextInt());
			for(i=0;i<a.m;i++){
				a.x[i] = scan.nextInt();
				a.y[i] = scan.nextInt();
			}
			a.toPointO();
			a.turn();

			for(i=1;i<=n;i++){
				b = new Polygon(scan.nextInt());
				for(j=0;j<b.m;j++){
					b.x[j] = scan.nextInt();
					b.y[j] = scan.nextInt();
				}

				flg = true;
				b.toPointO();
				b.turn();
				if(!a.equals(b)){
					b.reversePoint();
					b.toPointO();
					b.turn();
					if(!a.equals(b)) flg = false;
				}

				if(flg) System.out.println(i);
			}
			System.out.println("+++++");
		}
	}
}

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

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

Measured memory_bytes: 256