akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
  ll N, K;
  cin>>N>>K;
  ll ans;
  if(K%2LL==1LL){
    ll t = N/K;
    ans = t*t*t;
  }
  if(K%2LL==0LL){
    ll t = N/K;
    ll s = (N+(K/2LL))/K;
    ans = t*t*t+s*s*s;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    std::string s, t;
    std::cin >> s >> t;

    for (auto i = 0; i < n; i++)
    {
        std::cout << s[i] << t[i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const ll HMAX=1e9;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,A,B;
ll h[MAX+2];

bool f(ll x){
    ll cunt=0ll;
    for(int i=0;i<N;i++){
        if(h[i]>B*x)
            cunt+=((h[i]-B*x) % (A-B) ? (h[i]-B*x) / (A-B) +1ll:(h[i]-B*x) / (A-B));
    }
    return cunt <= x;
}

/*整数~整数
 l:範囲最小値,r:範囲最大値
 x<rでf=false,x>=rでtrue
 */
ll binary_search2(ll l,ll r){
    while(r-l>1ll){ //r=l+1になるまで
        ll m=(l+r)/2ll; //平均値かその左の整数
        if(f(m))r=m; //カッコ内の条件式は任意
        else l=m; //解x>m
    }
    return r;
}

void solve(){
    cout<<binary_search2(0ll,HMAX)<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>A>>B;
    for(int i=0;i<N;i++) cin>>h[i];
    solve();
    
    return 0;
}


Measured memory_bytes: 1024
// Kを始点とした深さ優先探索
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define print(x) (cout<<(x)<<"\n")

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n; cin>>n;
    int c4 = 0;
    int c2 = 0;
    rep(i, n) {
        int a; cin>>a;
        if (a%4==0) c4++;
        else if (a%2==0) c2++;
    }
    n -= c4*2+1;
    n -= (c2/2)*2;
    if (n<=0) print("Yes");
    else print("No");
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if a.count(0)>0:
  print(0)
else:
  ans=a[0]
  flag=0
  for i in range(1,N):
    ans*=a[i]
    if ans>10**18:
      flag+=1
      print(-1)
      break
  if flag==0:
    print(ans)

Measured memory_bytes: 21476
#include <iostream>
#include <cmath>

int main(int argc, char *argv[])
{
    int x;
    int ans = 0;

    std::cin >> x;

    int a = x / 100;
    int b = x % 100;

    if ((x >= 100)&&(b <= a * 5)) {ans = 1;}

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
# Python program to find  
# maximum XOR subset 
  
# Number of bits to  
# represent int 
INT_BITS=61
   
# Function to return 
# maximum XOR subset 
# in set[] 
def maxSubarrayXOR(set,n): 
  
    # Initialize index of 
    # chosen elements 
    index = 0
   
    # Traverse through all 
    # bits of integer  
    # starting from the most 
    # significant bit (MSB) 
    for i in range(INT_BITS-1,-1,-1): 
      
        # Initialize index of 
        # maximum element and 
        # the maximum element 
        maxInd = index 
        maxEle = -2147483648
        for j in range(index,n): 
          
            # If i'th bit of set[j] 
            # is set and set[j] is  
            # greater than max so far. 
            if ( (set[j] & (1 << i)) != 0 
                     and set[j] > maxEle ): 
                  
                maxEle = set[j] 
                maxInd = j 
          
        # If there was no  
        # element with i'th 
        # bit set, move to 
        # smaller i 
        if (maxEle ==-2147483648): 
            continue
   
        # Put maximum element 
        # with i'th bit set  
        # at index 'index' 
        temp=set[index] 
        set[index]=set[maxInd] 
        set[maxInd]=temp 
   
        # Update maxInd and  
        # increment index 
        maxInd = index 
   
        # Do XOR of set[maxIndex] 
        # with all numbers having 
        # i'th bit as set. 
        for j in range(n): 
          
            # XOR set[maxInd] those 
            # numbers which have the 
            # i'th bit set 
            if (j != maxInd and
               (set[j] & (1 << i)) != 0): 
                set[j] = set[j] ^ set[maxInd] 
          
   
        # Increment index of 
        # chosen elements 
        index=index + 1
      
   
    # Final result is  
    # XOR of all elements 
    res = 0
    for i in range(n): 
        res =res ^ set[i] 
    return res 
  
  
# This code is contributed 
# by Anant Agarwal. 


# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
#n,k = [int(i) for i in readline().split()]

n = int(input())
a = [int(i) for i in readline().split()]

res = [0]*60
for i in a:
    b = bin(i)[:1:-1]
#    print(b)
    for j,c in enumerate(b):
        if c == "1": res[j] += 1

omask = 0
emask = 0
for i,c in enumerate(res):
    if c%2: omask |= 1<<i
    elif c: emask |= 1<<i

#print(bin(omask)[2:])
#print(bin(emask)[2:])
for i in range(n):
    a[i] &= emask

res = maxSubarrayXOR(a, n)
#print(bin(res)[2:]) 


print(omask + res*2)










Measured memory_bytes: 69536
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N,k,p;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&k,&p);
        if(k%p==0)printf("%d\n",p);
        else printf("%d\n",k%p);
    }
    return 0;
}

Measured memory_bytes: 1188
import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  s <- getLine
  traceShowM (s)
  print $ f s

f s
  | length gr < 2 = 0
  | otherwise = (* 2) . minimum . map length $ gr
  where
    gr = group . sort $ s


Measured memory_bytes: 15740
#include <stdio.h>

int digsum_rec(int x){
    if(x == 0){
        ////printf("reached 0\n");
        return 0;
    }else{
        ////printf("when %d is divided by 10: q = %d, r = %d\n", x, x / 10, x % 10);
        return digsum_rec(x / 10) + x % 10;
    }
}

int main(void){
    int n;
    scanf("%d", &n);

    int a, b, da, db;
    int minimum = 9 * 6;

    for(a = 1; a <= n / 2; a++){
        b = n - a;
        //printf("a = %d, b = %d, minimum = %d\n", a, b, minimum);
        da = digsum_rec(a);
        db = digsum_rec(b);
        //printf("digsum(a) = %d, digsum(b) = %d, sum of those = %d\n", da, db, da + db);
        if(da + db < minimum){
            minimum = da + db;
            //printf("new minimum = %d\n", minimum);
        }
    }
    printf("%d\n", minimum);
    return 0;
}

Measured memory_bytes: 128
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s = cin.next!string, t = cin.next!string;
  int n = (s ~ t).to!int;
  foreach (i; 1 .. 1000) {
    if (i * i == n) {
      writeln("Yes");
      return ;
    }
  }
  writeln("No");
}


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

int main() {
  string o,e; cin >> o >> e;
  REP(i, (o+e).size()) {
    if (i%2) cout << e[i/2];
    else cout << o[i/2];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
s, k = input(), int(input())

if len(set(list(s))) == 1:
    print(len(s) * k // 2)
    exit()

ans, cnt = [], 1
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 1
else:
    ans.append(cnt)

if s[0] != s[-1]:
    ans = [i//2 for i in ans]
    print(sum(ans) * k)
elif s[0] == s[-1]:
    f, m, l = ans[0] // 2, (ans[0] + ans[-1]) // 2, ans[-1] // 2
    ans = [i//2 for i in ans[1:-1]]
    print(f + sum(ans) * k + m * (k - 1) + l)


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

int main() {
    int a, b, count; std::cin >> a >> b;
    
    if (a > b) {
        count = a;
        a -= 1;
    } else {
        count = b;
        b -= 1;
    }

    count += std::max(a, b);

    printf("%d\n", count);

    return 0;
}

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

int main(){

  int n; cin>>n;

  vector<int> ca(n);

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

    cin>>ca.at(i);
  }

  sort(ca.begin(),ca.end());

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

  int asum =0,bsum =0,ans=0;

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

    if(i % 2 == 0) asum += ca.at(i);

    else bsum += ca.at(i);
  }

  ans = asum- bsum;

  cout<<ans<<endl;

  return 0;

  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int a, pi;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>pi;
    pi=3*a+pi;
    int ans=pi/2;

    cout << ans << "\n";
}

Measured memory_bytes: 256
x,y = [int(i) for i in input().split()]
 
if x < y:
    if x*y < 0:
        print(1 + abs(abs(x) - y))
    else:
        print(y - x)
else:
    if x*y <= 0:
        print(1 + abs(x - abs(y)))
    else:
        print(2 + abs(x - y))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
string slove(){
  if(s.size()==2)return s;
  reverse(s.begin(),s.end());
  return s;
}
int main(){
  cin>>s;
  cout<<slove()<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    a = list(map(int, input().split()))

    ans = float("inf")
    for c in range(-100, 100+1):
        s = 0
        for _a in a:
            s += (c - _a)**2
        if s < ans:
            ans = s

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
<?php
/**
 * ABC119
 * A - Still TBD
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

$s = trim(fgets(STDIN));
if (strtotime($s) <= strtotime('2019/04/30')) {
    echo 'Heisei', PHP_EOL;
} else {
    echo 'TBD', PHP_EOL;
}


Measured memory_bytes: 5492
# -*- coding: utf-8 -*-

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 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

M = max(A+[K]).bit_length()

bitcnt = [0] * M
for a in A:
    # ビット毎に立っている数を数える
    i = 0
    while (a>>i) > 0:
        bitcnt[i] += a >> i & 1
        i += 1

# 最大値を作るようなxの作成
x = 0
# 大きい方から貪欲に見ていく
for i in range(M-1, -1, -1):
    bit = 1 << i
    # 数列中のこのビットが立っている数が半分以下で、これを足してもxがKを超えないなら、このビットを立てる
    if bitcnt[i] <= N // 2 and x + bit <= K:
        x += bit

ans = 0
for a in A:
    ans += a ^ x
print(ans)


Measured memory_bytes: 14748
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < h-b; i++){
            for(int j = 0; j < a; j++){
                sb.append('0');
            }
            for(int j = a; j < w; j++){
                sb.append('1');
            }
            System.out.println(sb.toString());
            sb.setLength(0);
        }
        for(int i = h-b; i < h; i++){
            for(int j = 0; j < a; j++){
                sb.append('1');
            }
            for(int j = a; j < w; j++){
                sb.append('0');
            }
            System.out.println(sb.toString());
            sb.setLength(0);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 24020
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    int ans;
    ans = a + (a > b? -1: 0);
    cout << ans << endl;
    return 0;
}



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

	static int[] dx = {0,0,-1,1};
	static int[] dy = {-1,1,0,0};
	static int[][] map;
	static int n, m;

	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		while (true) {
			m = Integer.valueOf(s.readLine());
			n = Integer.valueOf(s.readLine());
			if (m == 0 && n == 0) break;
			map = new int[n][m];
			for (int i = 0 ; i < n ; i++) {
				String[] data = s.readLine().split(" ");
				for (int j = 0 ; j < m ; j++)
					map[i][j] = Integer.valueOf(data[j]);
			}
			int max = 0;
			for (int i = 0 ; i < n ; i++) {
				for (int j = 0 ; j < m ; j++) {
					if (map[i][j] == 1) {
						boolean[][] broken = new boolean[n][m];
						max = Math.max(max, dfs(i, j, broken));
					}
				}
			}
			out.println(max);
		}
		out.flush();
	}

	private static int dfs(int y, int x, boolean[][] brk) {
		int ret = 0;
		for (int d = 0 ; d < 4 ; d++) {
			int tx = x + dx[d];
			int ty = y + dy[d];
			if (tx < 0 || ty < 0 || tx >= m || ty >= n || map[ty][tx] == 0 || brk[ty][tx]) {
				continue;
			}
			brk[ty][tx] = true;
			ret = Math.max(ret, 1 + dfs(ty, tx, brk));
			brk[ty][tx] = false;
		}
		return ret;
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int sum=0;
    char ch;
    while(1){

        while((ch = getchar())!='\n'){
            sum +=ch - '0';
        }
        if(sum == 0)break;
        else{
            printf("%d\n",sum);
            sum=0;
        }
    }
}


Measured memory_bytes: 3240
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(" ");
        int A = getInt(s[0]);
        int B = getInt(s[1]);
        int C = getInt(s[2]);
        int max = Math.max(A,B);
            max = Math.max(max,C);

        // maxとABCの差を2で割ってあまりを取得
        int remA = (max - A) % 2;
        int remB = (max - B) % 2;
        int remC = (max - C) % 2;

        // あまりを取り除いて2の倍数で何回操作が必要か計算する
        int result = 0;
        result += (max - A - remA) != 0 ? (max - A - remA) / 2 : 0;
        result += (max - B - remB) != 0 ? (max - B - remB) / 2 : 0;
        result += (max - C - remC) != 0 ? (max - C - remC) / 2 : 0;

        // あまりがすべて0でない場合は追加の操作が必要なので+1
        if(remA != 0 || remB != 0 || remC != 0 ) result++;
        // 奇数が一つだけの場合は更に追加の操作が必要なので+1
        if((remA + remB + remC) % 2 != 0 ) result++;
        System.out.println(result);
        sc.close();
    }
    static int getInt(String val) {
        return Integer.parseInt(val);
    }
    static long getLong(String val) {
        return Long.parseLong(val);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#define MAX 101
int main(){
 
  int n,k,u,v,i,j,d[MAX][MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      d[i][j]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      d[i][v-1]=1;
    }
  }
    for(i=0;i<n;i++){
      if(i!=0)printf("\n");
      for(j=0;j<n;j++){
        printf("%d",d[i][j]);
    if(j!=n-1)printf(" ");
      }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2088
until(h, w = gets.split.map(&:to_i)) == [0,0]
  h.times do |i|
    if i.even?
      if w.odd?
        puts "#{"#." * (w/2)}#"
      else puts "#{"#." * (w/2)}"
      end
    elsif w.odd?
      puts "#{".#" * (w/2)}."
    else puts "#{".#" * (w/2)}"
    end
  end
    puts ""
end

Measured memory_bytes: 8924
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
const int MOD=100000;
int a[100100];
int n,m;
int main()
{
	cin >> n >> m;
	for(int i=1;i<n;i++)cin >> a[i];
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	int ans=0;
	int cur=0;
	for(int i=0;i<m;i++)
	{
		int k;
		cin >> k;
		ans+=abs(a[cur+k]-a[cur]);
		ans%=MOD;
		cur+=k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1552
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#
using namespace std;

map<string,int>mp;
int main()
{
     int n;
     scanf("%d",&n);
     printf("%d\n",24+24-n);
    //cout << "Hello world!" << endl;
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define INF 1000000000

int main(){
	IO
	long double r, cir, PI = 3.14159265;
	cin >> r;
	cir = 2.0*PI*r;
	cout << setprecision(6) << fixed << cir << endl;
	return 0;
}


Measured memory_bytes: 3808
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Double price = 0.0;
		String u = null;
		double sum = 0;
		for(int i = 0; i < N; i++) {
			price = sc.nextDouble();
			u = sc.next();
			if(u.equals("JPY")) {
				sum += price;
			}else{
				sum += price * 380000.0;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
}
int n,m;
void input()
{
	n=read<int>(),m=read<int>();
}
int num[N],may[N];
void work()
{
	int x,y;
	For(i,1,n)num[i]=1;
	may[1]=1;
	For(i,1,m)
	{
		x=read<int>(),y=read<int>();
		--num[x],++num[y];
		if(may[x])may[y]=1;
		if(!num[x])may[x]=0;
	}
	int ans=0;
	For(i,1,n)ans+=may[i];
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}

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

#define N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N+1);
  int *d = (int*)malloc(sizeof(int)*N+1);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2444
#include <iostream>

int main(void){
  int N, A, B, T;
  std::cin >> N >> A >> B;
  T = B - A - 1;
  if (T & 1)
    std::cout << "Alice" << std::endl;
  else
    std::cout << "Borys" << std::endl;
  return 0;
}


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

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_B&lang=jp

struct Edge {
  int dst,weight;
};

int ChinesePostmanProblem(int V,int E,vector<int> s,vector<int> t,vector<int> d) {
  int mini = 0;
  vector<vector<Edge> > G(V);
  vector<vector<int> > wf(V,vector<int>(V,INT_MAX));
  for(int i=0;i<V;++i) wf[i][i] = 0;
  for(int i=0;i<E;++i) {
    G[s[i]].push_back((Edge){t[i],d[i]});
    G[t[i]].push_back((Edge){s[i],d[i]});
    wf[s[i]][t[i]] = wf[t[i]][s[i]] = min(wf[s[i]][t[i]],d[i]);
    mini += d[i];
  }
  for(int k=0;k<V;++k) for(int i=0;i<V;++i) for(int j=0;j<V;++j) if( wf[i][k] != INT_MAX && wf[k][j] != INT_MAX ) wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j]);
  vector<int> odd;
  for(int i=0;i<V;++i) if( (int)G[i].size() & 1 ) odd.push_back(i);
  int n = (int)odd.size();
  vector<int> dp((1<<n),INT_MAX);
  dp[0] = 0;
  for(int state=0;state<(1<<n);++state) {
    for(int sp=0;sp<n;++sp) if( !( (state>>sp) & 1 ) ) {
        for(int ep=0;ep<n;++ep) if( sp != ep && !( (state>>ep) & 1 ) )  {
            dp[state|(1<<sp)|(1<<ep)] = min(dp[state|(1<<sp)|(1<<ep)],
                                            dp[state]+wf[odd[sp]][odd[ep]]);
          }
      }
  }
  return mini + dp[(1<<n)-1];
}

int main() {
  int V,E;
  cin >> V >> E;
  vector<int> s(E),t(E),d(E);
  for(int i=0;i<E;++i) cin >> s[i] >> t[i] >> d[i];
  cout << ChinesePostmanProblem(V,E,s,t,d) << endl;
  return 0;
}



Measured memory_bytes: 3168
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

# 入力
n, k = li()
v = list(li())

# 個数m決め打ち
ans = 0
for m in range(n+1):
    rest = k
    rest -= m

    if rest < 0:
        continue

    # 左からi個、右からm-i個
    for i in range(m+1):
        a = v[:i] + v[n-m+i:]
        a.sort()
        suma = sum(a)

        # kを超えないようにマイナスを詰める
        for j in range(rest):
            if j >= len(a):
                break

            if a[j] < 0:
                suma += abs(a[j])
            else:
                break

        ans = max(ans, suma)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int h, w; cin >> h >> w;
	char m[110][110];
	bool hp[110], wp[110];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cin >> m[i][j];
	}

	for (int i = 0; i < h; i++) {
		hp[i] = false;
		for (int j = 0; j < w; j++)if (m[i][j] == '#')hp[i] = true;
	}
	for (int i = 0; i < w; i++) {
		wp[i] = false;
		for (int j = 0; j < h; j++)if (m[j][i] == '#')wp[i] = true;
	}

	for (int i = 0; i < h; i++) {
		if (hp[i]) {
			for (int j = 0; j < w; j++) {
				if (wp[j])cout << m[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    int A, B; cin >> A >> B;
    int K; cin >> K;
    int iter = 0;
    int num = 101;
    while (iter < K) {
        num--;
        if (A % num == 0 && B % num == 0) iter++;
    }   
    cout << num << endl;
}

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



int main(){
  int n;
  int i,k;
  long long sum;
  string a;
  cin >> n;
  map<string,int>mp;
  for(i=0;i<n;i++){
    cin >> a;
    sort(a.begin(),a.end());
    mp[a]++;
  }

  sum=0;

  for(auto p : mp){
    k = p.second;
    sum += (long long)k*(k-1)/2;
  }

  cout << sum << endl;




  return 0;

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
signed main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[5]=='0'&&(s[6]=='1'||s[6]=='2'||s[6]=='3'||s[6]=='4')){
            cout<<"Heisei"<<endl;
            return 0;
        }
    }
    cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    mod = 10 ** 9 + 7

    ans = pow(2, n, mod) - 1

    nca, ncb = 1, 1

    for i in range(b):
        ncb = ncb * (n - i) % mod
        ncb *= pow(i + 1, mod - 2, mod)
        if i + 1 == a:
            nca = ncb

    print((ans - (nca + ncb)) % mod)


if __name__ == '__main__':
    main()


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

bool match( char a, char b ) {
  if ( a=='?' || b=='?' || a == b ) return true;
  else return false;
}


int main() {
  string a,b,c;
  cin >> a >> b >> c;

  vector<bool> ab(6000,true), bc(6000,true), ca(6000,true);
  vector<bool> ba(6000,true), cb(6000,true), ac(6000,true);

  // 文字数を a < b < c にする
  int la = a.length();
  int lb = b.length();
  int lc = c.length();
  if ( la > lb ) swap(a,b);
  if ( la > lc ) swap(a,c);
  if ( lb > lc ) swap(b,c);
//  cout << a << endl;
//  cout << b << endl;
//  cout << c << endl;
  la = a.length();
  lb = b.length();
  lc = c.length();
  
  // a-b
  REP(i, la)
    REP(j, min( la-i, lb))
      if (!match(a[i+j],b[j])) { ab[i] = false; break; }
  // a-c
  REP(i, la)
    REP(j, min( la-i, lc))
      if (!match(a[i+j],c[j])) { ac[i] = false; break; }
  // b-c
  REP(i, lb)
    REP(j, min( lb-i, lc))
      if (!match(b[i+j],c[j])) { bc[i] = false; break; }
  // b-a
  REP(i, lb)
    REP(j, min( lb-i, la))
      if (!match(b[i+j],a[j])) { ba[i] = false; break; }
  // c-a
  REP(i, lc)
    REP(j, min( lc-i, la))
      if (!match(c[i+j],a[j])) { ca[i] = false; break; }
  // c-b
  REP(i, lc)
    REP(j, min( lc-i, lb))
      if (!match(c[i+j],b[j])) { cb[i] = false; break; }

  int ans = la + lb + lc;
  // a-b-c
  REP(j,la+lb) REP(i,j+1) if( ab[i] && bc[j-i] && ac[j])  {
    ans = min( max({la,j+lc,i+lb}), ans );
//    cout << i << " " << j << endl;
//    break;
  }
  // a-c-b
  REP(j,la+lc) REP(i,j+1) if( ac[i] && cb[j-i] && ab[j])  ans = min( max({la,i+lc,j+lb}), ans );
  // b-a-c
  REP(j,lb+la) REP(i,j+1) if( ba[i] && ac[j-i] && bc[j] )  ans = min( max({lb,i+la,j+lc}), ans );
  // b-c-a
  REP(j,lb+lc) REP(i,j+1) if( bc[i] && ca[j-i] && ba[j] )  ans = min( max({lb,i+lc,j+la}), ans );
  // c-a-b
  REP(j,lc+la) REP(i,j+1) if( ca[i] && ab[j-i] && cb[j] )  ans = min( max({lc,i+la,j+lb}), ans );
  // c-b-a
  REP(j,lc+lb) REP(i,j+1) if( cb[i] && ba[j-i] && ca[j] )  ans = min( max({lc,i+lb,j+la}), ans );

  cout << ans << endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
  
int main(){
    ll N, M;
    cin >> N >> M;
    if (N >= 2) N -= 2;
    if (M >= 2) M -= 2;
    cout << N * M << endl;
    return 0;
}

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

int main(){
    int S[14],H[14],C[14],D[14];
    S[0]=H[0]=C[0]=D[0]=1;
    for(int i=1;i<14;i++) S[i]=H[i]=C[i]=D[i]=0;
    int n;
    cin>>n;
    for(int j=0;j<n;j++){
        char suit;
        int value;
        cin>>suit>>value;
        if(suit=='S') S[value]=1;
        else if(suit=='H') H[value]=1;
        else if(suit=='C') C[value]=1;
        else if(suit=='D') D[value]=1;
    }
    for(int k=1;k<14;k++){
        if(S[k]!=1) cout<<"S "<<k<<endl;
    }
    for(int k=1;k<14;k++){
        if(H[k]!=1) cout<<"H "<<k<<endl;
    }
    for(int k=1;k<14;k++){
        if(C[k]!=1) cout<<"C "<<k<<endl;
    }
    for(int k=1;k<14;k++){
        if(D[k]!=1) cout<<"D "<<k<<endl;
    }
}


Measured memory_bytes: 3096
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var max = 0;
  var lastMax = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i+1);
    if(tmp == "A" || tmp == "C" || tmp == "G" || tmp == "T"){
       max++;
    }else{
       lastMax = Math.max(lastMax,max);
       max = 0;
    }
  }
  lastMax = Math.max(lastMax,max);
  myout(lastMax);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n = STDIN.gets.to_i
unless (2 <= n and n <= 200000)
  p ("erro: 0 <= n <= 200000")
  exit
end

xs = (0...n.to_i).map {|x| STDIN.gets.to_i }
min = nil
diff_max = -1000000001

xs.each_with_index {|x, i|
  if (i == 0)
    min = x
  else
    diff = x - min
    if (diff > diff_max)
      diff_max = diff
    end
    if (x < min)
      min = x
    end
  end
}

puts diff_max

Measured memory_bytes: 10592
import math


def ag(li):
    return (li[0][0] and li[0][1] and li[0][2]) \
        or (li[1][0] and li[1][1] and li[1][2]) \
        or (li[2][0] and li[2][1] and li[2][2]) \
        or (li[0][0] and li[1][0] and li[2][0]) \
        or (li[0][1] and li[1][1] and li[2][1]) \
        or (li[0][2] and li[1][2] and li[2][2]) \
        or (li[0][0] and li[1][1] and li[2][2]) \
        or (li[0][2] and li[1][1] and li[2][0])


card = [list(map(int, input().split())) for i in range(3)]
n = int(input())
bList = [input() for _ in range(n)]
tList = [[False, False, False], [False, False, False], [False, False, False]]

for i, b in enumerate(bList):
    for j, c1 in enumerate(card):
        for k, c2 in enumerate(c1):
            if c2 == int(b):
                tList[k][j] = True

if ag(tList):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
(defun split (delimiter target-string)
  (let (
      (delimiter-position (search delimiter target-string))
      (delimiter-size (length delimiter)))
    (if delimiter-position
      (cons (subseq target-string 0 delimiter-position)
            (split delimiter (subseq target-string (+ delimiter-position delimiter-size))))
      (list target-string))))

(let ((seqstring "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51")
      (n (read)))
  (princ (nth (- n 1) (split ", " seqstring))))

Measured memory_bytes: 10976
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, ans = 0;
  char s[100];
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
      ans++;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
import itertools
import math
n=int(input())
xy=[tuple(map(int,input().split())) for _ in range(n)]
path_length=0
for p in itertools.permutations(xy):
    for (x1,y1),(x2,y2) in zip(p,p[1:]):
        path_length+=math.sqrt((x1-x2)**2+(y1-y2)**2)
print(path_length/len(list((itertools.permutations(xy)))))

Measured memory_bytes: 7972
c_list = [input() for i in range(2)]

reversed_c_list = []
for s in reversed(c_list[0]):
    reversed_c_list.append(s)

normal_c_list = []
for s in c_list[1]:
    normal_c_list.append(s)


if reversed_c_list == normal_c_list:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <map> 
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int main()
{
	fast;
	cin>>s;
	if (s.size()==2)
	   cout<<s<<endl;
	else
	    reverse(s.begin(),s.end()),cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
// Last Change:           11/26/2018 18:18:13.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

struct Card {
  char mark;
  int num;
};

int Partition(Card card[], int p, int r) {
  Card x = card[r];
  int i = p - 1;
  Card tmp;
  for (int j = p; j < r; j++) {
    if (card[j].num <= x.num) {
      i++;
      tmp = card[j];
      card[j] = card[i];
      card[i] = tmp;
    }
  }
  tmp = card[i + 1];
  card[i + 1] = card[r];
  card[r] = tmp;
  return i + 1;
}

void QuickSort(Card card[], int p, int r) {
  if (p < r) {
    int q = Partition(card, p, r);
    QuickSort(card, p, q - 1);
    QuickSort(card, q + 1, r);
  }
}

#define INFTY 1000000010
int countNum;
Card L[250005];
Card R[250005];
void Merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1].num = INFTY;
  R[n2].num = INFTY;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].num <= R[j].num) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
    countNum++;
  }
}

void MergeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

int main() {
  int N;
  Card card[100000], A[100000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> card[i].mark >> card[i].num;
    A[i] = card[i];
  }
  QuickSort(card, 0, N - 1);
  MergeSort(A, 0, N);

  bool isStable = true;
  for (int i = 0; i < N; i++) {
    if (card[i].mark != A[i].mark) { // structの比較はそのままでは行えない
      isStable = false;
      break;
    }
  }
  if (isStable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (int i = 0; i < N; i++) {
    cout << card[i].mark << " " << card[i].num << "\n";
  }
  cout << flush;
}



Measured memory_bytes: 5348
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const  void*b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    long long sub=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sub+=a[i];
    }
    qsort(a,n,sizeof(int),compare);
    int ans=1;
    for(int i=n-1;i>=0;i--){
        sub-=a[i];
        if(a[i]>2*sub){
            break;
        }else{
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 892
while True:
  D = int(input())
  if D==0: exit()
  N = int(input())
  M = int(input())
  shops = [0]
  for _ in range(N-1):
    shops.append(int(input()))
  shops.append(D)
  shops.sort()

  res = 0
  for _ in range(M):
    x = int(input())
    ok,ng = -1,len(shops)
    while abs(ok-ng)>1:
      mid = (ok+ng)//2
      if shops[mid] <= x:
        ok = mid
      else:
        ng = mid
    res += min(x-shops[ok], shops[ok+1]-x)

  print(res)



Measured memory_bytes: 9924
#include<iostream>
#include<list>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0

void print(list<pair<int,int>>& que){
  for(auto x:que) printf("(%d %d)",x.first,x.second);
  printf("\n");
}
void print(vector<int>& v){
  for(auto x: v) printf("%2d",x);
  printf("\n");
}
void print(vector<vector<int>>& s){
  for(auto x: s) print(x);
}
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }


int main(){
  int h,w; cin >>h >>w;
  vector<vector<int>> seen(h,vector<int>(w,-1));
  vector<string> s(h);
  for(auto& x: s) cin >>x;
  list<pair<int,int>> que;
  seen[0][0]=(s[0][0]=='#');
  que.push_back({0,0});
  if(df)print(que);

  auto shori
    =[&](const pair<int,int>& x,const pair<int,int>& y){
       if(seen[y.first][y.second]!=-1) return;
       if(s[x.first][x.second]==s[y.first][y.second]){
         seen[y.first][y.second]=seen[x.first][x.second];
         que.push_front(y);
       }else{
         seen[y.first][y.second]=seen[x.first][x.second]
           +(s[y.first][y.second]=='#');
         que.push_back(y);
       }
       if(df)print(que);
     };
  
  while(que.size()){
    auto x=que.front();
    que.pop_front();
    if(x.first==h-1){
      if(x.second==w-1) break;
      pair<int,int> y=x; y.second++;
      shori(x,y);
    }else{
      pair<int,int> y=x; y.first++;
      shori(x,y);
      if(x.second==w-1) continue;
      y.first--; y.second++;
      shori(x,y);
    }
  }
  if(df)print(seen);

  print(seen[h-1][w-1]);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  int j=0;
  cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if(c%i==0){
      j=j+1;
    }
  }
  cout << j <<endl;
  return(0);
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    ll ans = 0;
    map<ll, int> cnt;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;

        ll tar = i - a;
        if (cnt.find(tar) != cnt.end()) {
            ans += cnt[tar];
        }

        ++cnt[i + a];
    }

    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++) {
        scanf("%d",&a[i]);
    }
    int ans=-1;
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
            int p=a[i]*a[j];
            string s=to_string(p);
            bool OK=1;
            for(int i=1;i<s.size();i++) {
                if(s[i]-s[i-1]!=1) OK=0;
            }
            if(OK) ans=max(ans,p);
        }
    }
    printf("%d\n",ans);
}

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


int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	int s = 0;

	for (int i = 0; i < k; i++) {
		s += a[i];
	}

	cout << s << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>

using namespace std;

int f[501][501],n,m,q; 
int main ()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>q;
    for(int i=1,l,r; i<=m; i++)
    {
    	cin>>l>>r;
    	f[l][r]++;
	}
	for(int l=n; l>=1; l--)
		for(int r=l; r<=n; r++)
		{
			f[l][r]=f[l][r]+f[l+1][r]+f[l][r-1]-f[l+1][r-1];
		}
	for(int i=1,l,r; i<=q; i++)
	{
		cin>>l>>r;
		cout<<f[l][r]<<endl;
	}
    return 0;
 } 

Measured memory_bytes: 1920
a = int(input())
b = list(map(int, input().split()))
sumroute = 0
ever = 0

for i in range(len(b)):
    sumroute += abs(b[i] - ever)
    ever = b[i]
sumroute += abs(b[-1])
b.insert(0,0)
b.append(0)
for i in range(len(b)-2):
    if (b[i+1]-b[i]) * (b[i+2]-b[i+1]) < 0:
        print(sumroute-2*min(abs(b[i+1]-b[i]),abs(b[i+2]-b[i+1])))
    else:
        print(sumroute)

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
int main(){
set<char>s;
string S;
cin>>S;
for(int i=0;i<S.size();i++){
    s.insert(S[i]);
}
if(S.size()==s.size())cout<<"yes";
else cout<<"no";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
int n;
vi a;

int32_t main(){
    ios::sync_with_stdio(false);
    cin>>n;
    a.resize(n);
    int ct=0;
    int sum=0;
    int small=(1e10);
    REP(i,0,n){
        cin>>a[i];
        sum+=abs(a[i]);
        if(abs(a[i])<small){
            small=abs(a[i]);
        }
        if(a[i]<0){
            ct++;
            
        }
    }
    if(ct%2==0){
        cout<<sum<<"\n";
    }
    else{
        cout<<(sum-2*small)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1024