akhauriyash/Code-Regression huggingface dataset:
class RankInADynamicSubset {
    constructor(keys) {
        keys = Array.from(new Set(keys));
        keys.sort((a, b) => {
            if (a < b) return -1;
            if (b < a) return 1;
            return 0;
        });
        const raw = new Array(keys.length);
        let sp = 0;
        (function lp(p) {
            if (p >= raw.length) return;
            lp(p * 2 + 1);
            raw[p] = [keys[sp++], 0];
            lp(p * 2 + 2);
        })(0);
        this.raw = raw;
    }

    currentRankOf(key) {
        const raw = this.raw;
        return (function lp(p) {
            if (p >= raw.length) return 0;
            if (key < raw[p][0]) {
                return lp(p * 2 + 1);
            } else if (raw[p][0] < key) {
                return Math.max(raw[p][1], lp(p * 2 + 2));
            } else {
                return raw[p][1];
            }
        })(0);
    }

    add(key, value) {
        const raw = this.raw;
        (function lp(p) {
            if (p >= raw.length) return 0;
            if (key < raw[p][0]) {
                return (raw[p][1] = Math.max(raw[p][1], lp(p * 2 + 1)));
            } else if (raw[p][0] < key) {
                return lp(p * 2 + 2);
            } else {
                raw[p][1] = value;
                return value;
            }
        })(0);
    }

    [Symbol.iterator]() {
        return this.raw[Symbol.iterator]();
    }
}

new Promise(function(resolve, reject) {
    let cin = "";
    process.stdin
        .on("data", chunk => { cin += chunk; })
        .on("end", () => { resolve([cin, process.stdout]); });
}).then(function([cin, cout]) {
    const [n, ...d] = cin.split("\n").map(elt => parseInt(elt));
    d.length = n;
    const rids = new RankInADynamicSubset(d);
    for (const e of d) {
        rids.add(e, rids.currentRankOf(e - 1) + 1);
    }
    cout.write(`${[...rids].reduce((cdr, car) => Math.max(cdr, car[1]), 0)}\n`);
});



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

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (z >= 0 && z <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {

    static int[][] d;
    static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        d = new int[n][2];
        int min= 12;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            d[i][0] = x;
            d[i][1] = x == 0 ? 0 : 24 - x;
            if(x < min) min = x;
        }
        int ans = 0;
        if(23 < n) System.out.println(0);
        else{
            for (int i = 1; i <= min; i++) {
                boolean[] used = new boolean[24];
                used[0] = true;
                if(dfs(used, 0, i)) ans = i;
                else break;
            }
            System.out.println(ans);
        }
        sc.close();

    }

    private static boolean dfs(boolean[] used, int i, int diff) {
        if(i == n) return true;
        for(int a : d[i]){
            if(used[a])continue;
            boolean able = true;
            for (int j = 1; j < diff; j++) {
                int b = 23 < a+j ? a+j - 24 : a+j;
                if(used[b]) {able = false; break;}
                int c = a-j < 0 ? 24 + a-j : a-j;
                if(used[c]) {able = false; break;}
            }
            if(able){
                used[a] = true;
                boolean ret = dfs(used, i+1, diff);
                if(ret) return true;
                else used[a] = false;
            }
        }
        return false;
    }

}


Measured memory_bytes: 22100
a, b, c, d, e, k = readlines.map(&:to_i)
if b-a <= k && c-a <= k && d-a <= k && e-a <= k && c-b <= k && d-b <= k && e-b <= k && d-c <= k && e-c <= k && e-d <= k
  puts "Yay!"
else
  puts ":("
end

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


def solve(n, m):
    x = min(m // 2, n)
    y = (m - 2 * x) // 4
    return x + y


def main():
    n, m = (int(x) for x in input().split())
    print(solve(n, m))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
s = input()
n = len(s)
a = 0
b = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == '0':
            a += 1
        else:
            b += 1
    else:
        if s[i] == '0':
            b += 1
        else:
            a += 1
print(min(a,b))

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define all(x) x.begin(), x.end()
#define watch(x) cout<<#x<<" : "<<x<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define testCases int tt;cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef vector<string> vs;

int main() {
    fastio;
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int flag = 0;
    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i-1]) {
            flag = 1;
            //cout << i << endl;
            break;
        }
    }
    if (flag) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    double ans = (N+1)/2 / (double)N;
    print(setprecision(20) << ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <list>
#include <unordered_set>
#include <vector>

#define ll long long


using namespace std;

ll N, M;
bool isUsed[200000];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        ll a, b;
        cin >> a >> b;
        if (a != 1 && b != N) {
            continue;
        } else if (a == 1) {
            if (isUsed[b]) {
                cout << "POSSIBLE" << endl;
                return 0;
            } else {
                isUsed[b] = true;
            }
        } else {
            if (isUsed[a]) {
                cout << "POSSIBLE" << endl;
                return 0;
            } else {
                isUsed[a] = true;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 384
# C Sum of gcd of Tuples (Easy)

import math
from itertools import combinations_with_replacement as C

K = int(input())

ans = 0
ABC = list(C(range(1, K+1), 3))
for a, b, c in ABC:
  if a == b == c:
    ans += math.gcd(math.gcd(a, b), c)
  elif a == b or b == c or c == a:
    ans += math.gcd(math.gcd(a, b), c) * 3
  else:
    ans += math.gcd(math.gcd(a, b), c) * 6
print(ans)

Measured memory_bytes: 105516
N, Q = map(int, input().split())

nodes = [0 for _ in range(N + 1)]

branches = []
for j in range(N - 1):
    parent, child = map(int, input().split())
    branches.append([parent, child])

for _ in range(Q):
    parent, number = map(int, input().split())
    nodes[parent] += number

branches.sort()

for branch in branches:
    parent = branch[0]
    child = branch[1]
    nodes[child] += nodes[parent]

print(*nodes[1:], sep=' ')

Measured memory_bytes: 51052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    vector <long long> vect(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>vect[i];
    }
    long long lcm=1;
    for(int i=0;i<n;i++)
    {
        lcm=(vect[i]*lcm)/__gcd(vect[i],lcm);
    }
    float sum=0,l=(float)lcm;
    for(int i=0;i<n;i++)
    sum+=lcm/vect[i];
    cout<<setprecision(10)<<l/sum<<endl;
    return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()
#define Pb(i) push_back(i)

ll digits_num(ll a,ll b){
    ll num1=0,num2=0,ans;
    while(a > 0){
        a /= 10;
        num1++;
    }
    while(b > 0){
        b /= 10;
        num2++;
    }
    ans = max(num1,num2);
    return ans;
}

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

    ll n,root,ret,ans=100,j; Cin(n);
    root = sqrt(n);
    REP(i,1,root+1){
        if(n%i==0) j = n / i;
        ret = digits_num(i,j);
        ans = min(ans,ret);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int menunum;
    int menu[100];
    int satisfy[100];
    int extra[100];
    int ans=0;
    int num;

    scanf("%d",&menunum);

    for(int n=0;n<menunum;n++){
        scanf("%d",&menu[n]);
    }
    for(int m=0;m<menunum;m++){
        scanf("%d",&satisfy[m]);
    }
    for(int o=0;o<menunum-1;o++){
        scanf("%d",&extra[o]);
    }
    num=menu[0]-1;
    ans=ans+satisfy[num];
    for(int i=1;i<menunum;i++){
        num=menu[i]-1;
        ans=ans+satisfy[num];
        if(menu[i]==menu[i-1]+1){
            ans=ans+extra[num-1];
        }
    }

    printf("%d",ans);


    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
using namespace std;
bool Prime(int x){
    int i;
    if(x<2) return false;
    else if(x==2) return true;
    if(x%2==0) return false;
    for(i=3;i*i<=x;i+=2){
        if(x%i==0) return false;
    }
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    int N[n];
    for(int i=0;i<n;i++){
        scanf(" %d",&N[i]);
    }
    int cnt;
    for(int i=0;i<n;i++){
        if(Prime(N[i])){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2588
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()

time=T[0]
count = 1
ans = 0

for i in range(1,N):
  if T[i]-time>K or count==C:
    time = T[i]
    count = 1
    ans += 1
  else:
    count += 1
if count>0:
  ans += 1
print(ans)

Measured memory_bytes: 7384
//
// B - Increment Decrement
//

#include <iostream>

using namespace std;

int main() {

    int N;
    string S;

    cin >> N;
    cin >> S;

    int x = 0, max_ = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') {
            x++;
            max_ = max(max_, x);
        } else {
            x--;
        }
    }

    cout << max_ << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 10001

struct Info{
	Info(int arg_have_lock,int arg_next){
		have_lock = arg_have_lock;
		next = arg_next;
	}
	int have_lock,next;
};

int POW[11];
int length;
bool check[1024][10];
char buf[NUM];
vector<Info> V;


void func(){

	for(int i = 0; i < POW[10]; i++){
		for(int k = 0; k < 10; k++)check[i][k] = false;
	}

	scanf("%s",buf);

	int have_lock = 0,next;
	V.clear();

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

		if(buf[i] == 'u'){

			have_lock = 0;

		}else{

			next = buf[i]-'0';

			if(have_lock & (POW[next])){
				printf("UNSAFE\n");
				return;
			}
			if(!check[have_lock][next]){
				V.push_back(Info(have_lock,next));
				check[have_lock][next] = true;
			}
			have_lock += POW[next];
		}
	}

	vector<Info> ADD;
	int new_have_lock,new_next;
	bool FLG;

	while(true){

		for(int i = 0; i < V.size(); i++){
			for(int k = 0; k < V.size(); k++){

				if(i == k || (V[i].have_lock & V[k].have_lock) != 0)continue;

				if((POW[V[i].next] & V[k].have_lock) != 0 && (POW[V[k].next] & V[i].have_lock) != 0){
					printf("UNSAFE\n");
					return;
				}

				FLG = false;

				if((POW[V[i].next] & V[k].have_lock) != 0 && (POW[V[k].next] & V[i].have_lock) == 0){

					new_next = V[k].next;
					FLG = true;

				}else if((POW[V[k].next] & V[i].have_lock) != 0 && (POW[V[i].next] & V[k].have_lock) == 0){

					new_next = V[i].next;
					FLG = true;
				}

				if(FLG){
					new_have_lock = V[i].have_lock|V[k].have_lock;
					if(!check[new_have_lock][new_next]){
						ADD.push_back(Info(new_have_lock,new_next));
						check[new_have_lock][new_next] = true;
					}
				}
			}
		}

		if(ADD.size() == 0)break;

		for(int i = 0; i < ADD.size(); i++){
			V.push_back(ADD[i]);
		}
		ADD.clear();
	}

	printf("SAFE\n");
}

int main(){

	for(int i = 0; i < 11; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d",&length);
		if(length == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3344
ns = gets.chomp.split('').map{|m| m == '?' ? '?' : m.to_i}

dp = Array.new(13, 0)

if ns[0] == '?'
  10.times{|t| dp[t] = 1 }
else
  dp[ns[0]] = 1
end

(1..ns.size-1).each do |i|
  n = ns[i]
  dp_n = Array.new(13, 0)
  dp.each_with_index {|b, bi|
    if n == '?'
      10.times {|t|
        dp_n[ (bi * 10 + t) % 13 ] += b
      }
    else
      dp_n[ (bi * 10 + n) % 13 ] += b
    end
  }
  13.times{|t|
    dp_n[t] %= 1_000_000_007
  }
  dp = dp_n
end

p dp[5]


Measured memory_bytes: 18940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int ans = n%10;
  if( ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9){
    cout << "hon" << endl;
  }
  else if(ans == 0 || ans == 1 || ans == 6|| ans ==8){
    cout << "pon" << endl;
  }
  else if(ans == 3){
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int f(int A) {
    if (A % 4 == 1) return 1;
    else if (A % 4 == 3) return 0;
    else if (A % 4 == 0) return A;
    else return A + 1;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;cin >> A >> B;
    int sum = 0;
    cout << (f(max(0LL, A - 1)) ^ f(B)) << endl;
    return 0;
}


Measured memory_bytes: 256
require 'matrix'

n, y = *ARGF.gets.split(/\s+/).collect{|i| i.strip.to_i}

a = Matrix[
      [ 5000, 1000 ],
      [    1,    1 ]
    ]

max_number_of_yukichi = [n, y / 10_000].min

solved = false

(max_number_of_yukichi..0).step(-1).each do |number_of_yukichi|
  balance = y - number_of_yukichi * 10_000
  rest_of_number_of_bills = n - number_of_yukichi

  b = [balance, rest_of_number_of_bills]
  x = a.lup.solve(b)

  if x.map(&:to_f) == x.map(&:to_i) and x.map(&:to_i).all?{|i| i >= 0}
   puts [number_of_yukichi, x.map(&:to_i).to_a].flatten.join(' ')
    solved = true
    break
  end
end

unless solved
  puts "-1 -1 -1"
end


Measured memory_bytes: 15040
#include<stdio.h>
int main(void)
{
	int r, d, x;
	scanf("%d%d%d", &r, &d, &x);
	for(int i=0; i<10; ++i){
		x=r*x-d;
		printf("%d\n", x);
	}
	
	return 0;
}

Measured memory_bytes: 128
public class Main {


  private static void solve() {
    int[] cnt = new int[5];
    for (int i = 0; i < 3; i ++) {
      cnt[ni()] ++;
      cnt[ni()] ++;
    }
    
    for (int i = 1; i <= 4; i ++) {
      if (cnt[i] >= 3) {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22996
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main{
	public static long mod(long x, long e, long m){
		String bi = Long.toBinaryString(e);
		long y = 1;
		for(int i = 0; i < bi.length(); i++){
			if(bi.charAt(i) == '1'){
				y = (y*y*x)%m;
				System.out.println(y);
			}else{
				y = (y*y)%m;
				System.out.println(y);
			}
		}
		return y;
	}
    
	public static void main(String[] $){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int min = Integer.MAX_VALUE;
		for(int i = 1; i <= 10; i++){
			if(1000*i-N >= 0){
				min = Math.min(min, 1000*i-N);
			}
		}
		System.out.println(min);
		
	}
} 

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(auto &h : H) cin >> h;
  for(int i = N-2; i > 0; --i){
    if(H[i] > H[i+1]){
      --H[i];
    }
    if(H[i] > H[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 640
class c:
    def __init__(self, v):
        self.value = v
    def __str__(self):
        return str(self.value)
    def __add__(self, other):
        return c(self.value + other.value)
    def __sub__(self, other):
        return c(self.value - other.value)
    def __mul__(self, other):
        return c(self.value * other.value)
    def __truediv__(self, other):
        return c(int(self.value / other.value))

import re

n = int(input())

ans = (str(eval(re.sub(r'(\d+)', r'c(\1)', input()[:-1]))) for i in range(n))

print('\n'.join(ans))



Measured memory_bytes: 6612
#include<bits/stdc++.h>
using namespace std;
 
int main (){
  int N,b,c;
  double f;
  cin>>N;
  b=N/2;
  c=b+1;
  f=(double)c/(double)N;
  if(N%2==0){
    cout<<"0.5000000000";
  }else{
    printf("%.10lf\n",f);
  }
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
a, b = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

if a <= 5:
    print(0)
elif a >= 13:
    print(b)
else:
    print(b//2)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C && A % 2 == 0) {
        cout << "-1" << endl;
    } else {
        int count = 0;
        while (true) {
            if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
                break;
            }

            int tmp_a = A / 2;
            int tmp_b = B / 2;
            int tmp_c = C / 2;
            A = tmp_b + tmp_c;
            B = tmp_a + tmp_c;
            C = tmp_a + tmp_b;
            count += 1;
        }

        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    if(a<=b&&b<=c){
        printf("%d %d %d\n",a,b,c);
    }else if(a<=c&&c<=b){
        printf("%d %d %d\n",a,c,b);
    }else if(b<=a&&a<=c){
        printf("%d %d %d\n",b,a,c);
    }else if(b<=c&&c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if(c<=a&&a<=b){
        printf("%d %d %d\n",c,a,b);
    }else
        printf("%d %d %d\n",c,b,a);


    }



Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	 	Scanner scanner = new Scanner(System.in);
	 	String S = scanner.next();
	 	int N = S.length();
	 	int count = 0;
		String[] splitArray = S.split("");
		String[] splitArray1 = new String[N];
		String[] A1 = new String[N/2];
		String[] A2 = new String[N/2];
		String[] B1 = new String[N/2];
		String[] B2 = new String[N/2];

		for (int i = 0; i < N; i++) {
			splitArray1[N-1-i] = splitArray[i];
		}

		for (int i = 0; i < N/2; i++) {
			A1[i] = splitArray[i];
		}

		for (int i = 0; i < N/2; i++) {
			A2[i] = A1[N/2-1-i];
		}

		for (int i = 0; i < N/2; i++) {
			B1[i] = splitArray1[i];
		}

		for (int i = 0; i < N/2; i++) {
			B2[i] = B1[N/2-1-i];
		}

		for (int i = 0; i < N; i++) {
			if (splitArray[i].equals(splitArray1[i])) {
				count += 0;
			} else {
				/*
				System.out.println("最初");
			    System.out.println(i);
			    System.out.println(splitArray[i]);
			    System.out.println(splitArray1[i]);
			    */
				count += 1;
				break;
			}
		}

		for (int i = 0; i < N/2; i++) {
			if (A1[i].equals(A2[i])) {
				count += 0;
			} else {
				/*
				System.out.println("A");
			    System.out.println(i);
			    System.out.println(A1[i]);
			    System.out.println(A2[i]);
			    */
				count += 1;
				break;
			}
		}

		for (int i = 0; i < N/2; i++) {
			if (B1[i].equals(B2[i])) {
				count += 0;
			} else {
				/*
				System.out.println("B");
			    System.out.println(i);
			    System.out.println(B1[i]);
			    System.out.println(B2[i]);
			    */
				count += 1;
				break;
			}
		}

		if (count != 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
 	}
}

Measured memory_bytes: 21716
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
  //
  return 0;
}


Measured memory_bytes: 888
n=int(input())
while n:
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6.0
    s=30.0*(h+(m/60.0))
    if l<s:l,s=s,l
    if l-s>180.0:d=360-l+s
    else:d=l-s
    if d<30: print("alert")
    elif d<90: print("warning")
    else: print("safe")
    n-=1

Measured memory_bytes: 7488
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    boolean b = isPrime(a);
    if(b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  public static boolean isPrime(int a){
    for(int i=1;i<10;i++){
      if(a%i==0&&a/i<10){
        return true;
      }
    }
    return false;
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int h = (x-x%3600)/3600;
		int m = ((x%3600)-((x%3600)%60))/60;
		int s = (x%3600)%60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26340
A, B = map(int,input().split())

flg =False #flgを初期化
for C in range(1,4):
    if A*B*C %2 ==1:
        flg = True#flgと言う変数にTrueを代入する
        break #この時点で繰り返しを中断、終了する
        
if flg:#(if文にはじつは、後ろに＝＝trueが省略されているので、これだけで、flg=trueならば、、と言う意味になる)
    print("Yes")
else:#（flg=true では無いならば、）
    print("No")
    

Measured memory_bytes: 2940
/* ex4_3
   kohei_suzuki */

#include <stdio.h>

/* プロトタイプ宣言 */
int snowfall(int height1, int height2); //積雪量を求める関数

int main(void){

    int low_height, high_height; //低い塔,高い塔 の高さ
    int ans; //答え
    scanf("%d %d",&low_height, &high_height) ; //入力受取

    ans = snowfall(low_height, high_height); //関数snowfallで積雪量を求める
    printf("%d\n",ans); //答えを出力
}

/* 関数の定義 */
int snowfall(int height1, int height2){
    int diff, snow_height=0; //塔の高さの差,積雪量


    for(diff = height2 - height1; diff !=0; diff--){ //繰り返しで高いほうの塔の高さ(1+2+3…+diff)を求める
        snow_height += diff;
    }
    snow_height = snow_height - height2; 
    return snow_height; //積雪量を返す
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
const int N = 100000 + 5;

int a[ N ], s[ N ];
lld bit[ N << 1 ];

lld query( int p ) {
	lld ret = 0;
	while ( p ) {
		ret += bit[ p ];
		p -= p & -p;
	}
	return ret;
}

void add( int p ) {
	while ( p < N + N ) {
		bit[ p ]++;
		p += p & -p;
	}
}

lld count( int m, int n ) {
	for ( int i = 1 ; i <= n ; ++ i )
		if ( a[ i ] >= m ) s[ i ] = s[ i - 1 ] + 1;
		else s[ i ] = s[ i - 1 ] - 1;
	memset( bit, 0, sizeof( bit ) );
	lld ret = 0;
	for ( int i = 0 ; i <= n ; ++ i ) {
		ret += query( s[ i ] + N );
		add( s[ i ] + N );
	}
	return ret;
}

int main() {
	int n; scanf( "%d", &n );
	for ( int i = 1 ; i <= n ; ++ i )
		scanf( "%d", a + i );
	lld tot = ( ( lld )( n ) ) * ( n + 1 ) / 2;
	int l = 1, r = 1000000001;
	while ( r - l > 1 ) {
		int m = ( l + r ) >> 1;
		if ( count( m, n ) >= ( tot + 1 ) / 2 ) l = m;
		else r = m;
	}
	cout << l << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
 


int main() {
    int p = 37;
    int K = p+1;
    int N = K*K - K + 1;
    vector<vector<int> > part(p, vector<int>(p, 0));
    for (int i = 0; i < p; ++i) {
        for (int j = 0; j < p; ++j) {
            part[i][j] = p+2 + i*p + j;
        }
    }
    
    //COUT(part);
    
    vector<vector<int> > res(N);
    for (int i = 0; i < p+1; ++i) {
        res[i].push_back(1);
        for (int j = 0; j < p; ++j) {
            res[i].push_back(i*p + j + 2);
        }
    }
    
    for (int dif = 0; dif < p; ++dif) {
        int base = p+1 + dif*p;
        for (int i = 0; i < p; ++i) {
            int x = base + i;
            res[x].push_back(dif + 2);
            for (int j = 0; j < p; ++j) {
                int y = (dif * j + i) % p;
                res[x].push_back(part[j][y]);
            }
        }
    }

    cout << N << " " << K << endl;
    for (int i = 0; i < res.size(); ++i) {
        for (int j = 0; j < res[i].size(); ++j) {
            cout << res[i][j];
            if (j != (int)res[i].size() - 1) cout << " ";
        }
        cout << endl;
    }
    
}













Measured memory_bytes: 896
def gen(n):
    g = '#.'
    while True:
        yield g[n%2]
        n += 1

while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0:
        break
    for i in xrange(H):
        g = gen(i)
        print ''.join([g.next() for j in xrange(W)])
    print 

Measured memory_bytes: 6368
N,K=map(int, input().split())

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

ans=10**9
for i in range(N-K+1):
  L=A[i]
  R=A[i+K-1]
  ans=min(ans, R-L+min(abs(R), abs(L)))
  
print(ans)

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

int main(){
  int a,b,array[101],c,i=0,d;
  cin>>a>>b>>c;
  a-=c;
  while(a>=0){
    a-=b+c;
    i++;
  }
  cout<<i-1<<endl;
}

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

int main(){
    int A,B,C,k,r,tmp,ans=0,a,b,c;
    char token[300]={};
    fgets(token, sizeof(token), stdin);k=atoi(token);
    for (A=1; A<=k; A++) {
        for (B=1; B<=k; B++) {
            for (C=1; C<=k; C++) {
                a=A;b=B;c=C;
                if(a<b){tmp=a;a=b;b=tmp;}
                r=a%b;
                while(r!=0){
                    a = b;
                    b = r;
                    r = a % b;
                }
                if(c<b){tmp=c;c=b;b=tmp;}
                r=c%b;
                while(r!=0){
                    c = b;
                    b = r;
                    r = c % b;
                }
                ans+=b;
            }
        }
    }
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 1656
N = int(input())
A = list(map(int, input().split()))

while len(A) > 1:
    A = sorted(A)
    min_A = A[0]
    next_A = [min_A]
    for i in range(1, len(A)):
        A[i] %= min_A
        if A[i] != 0:
            next_A.append(A[i])
    A = next_A

print(A[0])

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    ll cur = 0;
    ll sum = 0;
    REP(i, N){
        ll h;
        cin >> h;
        if( cur > h ){
            sum += (cur - h);
        }else{
            cur = h;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;
const int MAX = 300000;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

//------------------------------------------------------------------------------------------------------------------------------

vector<vector<int>> G;
bool visit[10000], finded[10000];
bool dfs(int chi, int par = -1) {
    bool ret = 0;
    visit[chi] = 1;
    for (auto nv : G[chi]) {
        if (nv == par) {
            continue;
        }
        if (visit[nv]) {
            if (!finded[nv]) {
                return 1;
            }
            continue;
        }
        ret |= dfs(nv, chi);
        if (ret) {
            return ret;
        }
    }
    finded[chi] = 1;
    return ret;
}

int main(void) {
    int V, E;
    cin >> V >> E;
    G.resize(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    bool ans = 0;
    for (int i = 0; i < V; i++) {
        if (!visit[i]) {
            ans |= dfs(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')f=-1;chr=getchar();}
	while(isdigit(chr)) {ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}int ans=0,n;
signed main(){
	n=read();
	cout<<n*n*n;
	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector< int > P(A), Q(B), R(C);
  cin >> P >> Q >> R;
  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  while(P.size() > X) P.pop_back();
  while(Q.size() > Y) Q.pop_back();
  vector< int > con{P};
  for(auto &p: Q) con.emplace_back(p);
  sort(begin(con), end(con));
  int64 add = 0;
  sort(R.rbegin(), R.rend());
  for(int i = 0; i < C && i < con.size(); i++) {
    add += max(R[i] - con[i], 0);
  }
  cout << add + accumulate(begin(P), end(P), 0LL) + accumulate(begin(Q), end(Q), 0LL) << endl;
}

Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll ans=min(n,m/2);
  m-=ans*2;
  pr(ans+m/4);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());
#define vnn(x,y,name) vector<vector<int>> name(x, vector<int>(y));

string yes="Yes",no="No";

int main() {
    ll k;
    cin>>k;
    ll cnt=0;
    queue<ll> s;
    rell(i,9){
        s.push(i+1);
        cnt++;
        if(cnt==k){
            cout<<k<<endl;
            return 0;
        }
    }
    while(!s.empty()){
        ll j=s.front();
        if(j%10!=0){
            s.push(10*j+j%10-1);
            cnt++;
            if(cnt==k){
                cout<<10*j+j%10-1<<endl;
                return 0;
            }
        }
        s.push(10*j+j%10);
        cnt++;
        if(cnt==k){
            cout<<10*j+j%10<<endl;
            return 0;
        }
        if(j%10!=9){
            s.push(10*j+j%10+1);
            cnt++;
            if(cnt==k){
                cout<<10*j+j%10+1<<endl;
                return 0;
            }
        }
        s.pop();
    }
    
    
}


Measured memory_bytes: 4156
#include<bits/stdc++.h>
using namespace std;
int n, arr[1000000];
long dp[1000000];

long solve(int i) {
	dp[0]=0;
  	dp[1]=abs(arr[0]-arr[1]);
  
  	for(int i=2;i<n;i++){
      dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
      
      return dp[n-1];
	
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0);

	return 0;
}


Measured memory_bytes: 11764
#include <stdio.h>

int main(void)
{
    int n;
    int p[128];
    int i, j;
    int score;
    scanf("%d", &n);

    for (i = 0; i < n; ++i) scanf("%d", p + i);

    for (i = 0; i < n - 1; ++i){
        for (j = 0; j < n - i - 1; ++j){
            if (p[j] < p[j + 1]){
                int t = p[j];
                p[j] = p[j + 1];
                p[j + 1] = t;
            }
        }
    }

    score = 0;
    for (i = 0; i < n; ++i){
        if (i + 1 <= p[i]) score = i + 1;
    }
    printf("%d\n", score);

    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(){
   char s[16];
   int i,n;
    
   scanf("%s",s);
   for (i=n=0;s[i]!='\0';i++)
      if (s[i]=='x') n++;
   if (15-n>=8) puts("YES");
   else         puts("NO");
   return 0;
}


Measured memory_bytes: 128
n = int(input())
r = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
rb = set(r+b)
ans = 0

for w in rb:
    x = r.count(w)
    y = b.count(w)
    if x-y > ans:
        ans = x-y

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<ll> H(N);
    vector<ll> hcp(N);
    rep (i,N) cin >> H.at(i);
    ll hoge = 0;
    for (int i = 0; i < N; i++) {
        hoge = max(hoge,H.at(i));
        hcp.at(i) = hoge;
    }
    bool ans = false;
    for (int i = 0; i < N; i++) {
        if (hcp.at(i) - H.at(i) > 1) ans = true;
    }
    cout << (ans ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 4844
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i,j;
        
        while(true){
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n==0 && m==0){
            break;
        }
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(((j+i)%2)==0){
                    System.out.printf("#");
                }else{
                System.out.printf(".");
                }
                
            }
            System.out.println();
        }
        System.out.println();
    }
    }
}


Measured memory_bytes: 58988
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n;

int main(){
    scanf("%ld", &n);
    printf("%ld\n", (n+1)/2);
}


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

using namespace std;

const int MAXN = 2e5 + 20, MAXM = 124, SZ = 26, L = 32;
const long long inf = 1e18 + 100, mod = 1e9 + 7;
mt19937 rnd;

long long cnt_val(vector <long long>& x, long long p) {
    long long sum = 0;
    for (auto xi: x) {
        sum += (p - xi) * (p - xi);
    }
    return sum;
}

void solve() {
    int n;
    cin >> n;
    vector <long long> x(n);
    for (int j = 0; j < n; ++j) {
        cin >> x[j];
    }
    sort(x.begin(), x.end());
    long long mn = inf;
    for (int j = x[0]; j <= x.back(); ++j)
        mn = min(mn, cnt_val(x, j));
    cout << mn << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

int page;
string word;
map<string, VI> mp;

int main() {
	while ( !!( cin >> word >> page ) ) {
		mp[ word ].push_back( page );
	}
	for( map<string, VI>::iterator it = mp.begin(); it != mp.end(); ++it ) {
		printf( "%s\n", it->first.c_str() );
		VI pages = it->second;
		sort( pages.begin(), pages.end() );
		for ( int i = 0; i < pages.size() - 1; i++ ) {
			printf( "%d ", pages[ i ] );
		}
		printf( "%d\n", pages[ pages.size() - 1 ] );
	}
	return 0;
}

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

using namespace std;

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

using Graph = vector<vector<int>>;

int main(){
    int k, n, max_dist = 0;
    cin >> k >> n;
    int a[200200], b[200200];
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i >= 1){
            max_dist = max(max_dist, a[i]-a[i-1]);
        }
    }
    max_dist = max(max_dist, k-a[n-1]+a[0]);

    cout << k - max_dist << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    set<int> d;
    for (int i = 0; i < n; i++) {
        int w;
        cin >> w;
        d.insert(w);
    }
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 256