akhauriyash/Code-Regression huggingface dataset:
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

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

int main()
{
    int i;
    int N;
    int count = 0;
    cin >> N;
    vector<int> h(N);
    for(i=0;i<N;i++) cin >> h[i];
    
    i = 0;
    while(1){
        while(h[i]==0 && i<N) i++;
        if(i==N) break;
        
        count++;
        
        while(h[i]!=0 && i<N){
            h[i]--;
            i++;
        }
        i=0;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;
    int b,f,r,v;
    int room[4][3][10]={0};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        room[b-1][f-1][r-1]+=v;
    }
    for(int i=0;i<4;i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10;k++){
                printf(" %d",room[i][j][k]);
            }
            printf("\n");
        }
        if(i==3){
            break;
        }
        printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2740
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, x, t;
    
    scanf("%d%d%d", &n, &x, &t);
    
    if (n%x==0) {
        printf("%d", (n/x)*t);
    } else {
        printf("%d", ((n/x)+1)*t);
    }

    return 0;
}


Measured memory_bytes: 1732
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int g(int a,int b){

	int r=max(a,b)%min(a,b);
	if(r==0)  return min(a,b);
	else return g(min(a,b),r);
}

int main(){

	int p,n;
	while(true){

		cin >> p >> n;
		if(p==0 && n==0) break;

		int s1,s2,t1,t2;
		double d1=10000; double d2=10000;


		REP(i,1,n){

		int j=floor(i*sqrt((double)p));

		if(j<=n){
		if(d1>-(double)j/i+sqrt((double)p) && -(double)j/i+sqrt((double)p)>0){

		d1=-(double)j/i+sqrt((double)p);
		t1=i; t2=j;
					}
					}

		int k=ceil(i*sqrt((double)p));

		if(k<=n){
		if(d2>(double)k/i-sqrt((double)p) && (double)k/i-sqrt((double)p)>0){

		d2=(double)k/i-sqrt((double)p);
		s1=i; s2=k;
					}
					}

		}


		int g1=g(s1,s2);
		int g2=g(t1,t2);


		cout << s2/g1 << "/" << s1/g1 << " " << t2/g2 << "/" << t1/g2 << endl;

        s1=0; s2=0; t1=0; t2=0;

	}

	return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;

class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var N = int.Parse(Console.ReadLine());
            var nums = new List<string[]>();
            for (int n = 0; n < N; n++)
            {
                nums.Add(Console.ReadLine().Split(' '));
            }

            // 高橋君が知っている最低順位
            var minRank = 1;
            // 高橋君が知っている最低順位の人の配列番号
            var num = 0;

            // 高橋君が知っている中で最低順位の人を探す
            for (int n = 0; n < N; n++)
            {
                if (int.Parse(nums[n][0]) >= minRank)
                {
                    num = n;
                    minRank = int.Parse(nums[n][0]);
                }
            }

            // 答え
            var ans = minRank + int.Parse(nums[num][1]);
            Console.WriteLine(ans);
            }
    }

Measured memory_bytes: 33284
#include <bits/stdc++.h>
#define N 105
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

int n,m,a[N][N],sx,sy,f[2][N][N][N];
char str[N];

int get(int x1, int x2, int y1, int y2) {
  return a[x2][y2] - a[x2][y1 - 1] - a[x1 - 1][y2] + a[x1 - 1][y1 - 1];
}

inline void _max(int &a, int b) {
  a = max(a, b);
}

int main(int argc, char const *argv[]) {
  n = read(); m = read();
  for (int i = 1; i <= n; ++ i) {
    scanf("%s", str + 1);
    for (int j = 1; j <= m; ++ j) {
      if (str[j]=='E') sx = i, sy = j;
      if (str[j]=='o') ++ a[i][j];
      a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
    }
  }
  int ans = 0, now = 0;
  for (int i = 0; i < sx; ++ i) {
    now ^= 1;
    for (int j = 0; j < sy; ++ j) {
      for (int k = 0; k < n - sx + 1; ++ k) {
        for (int l = 0; l < m - sy + 1; ++ l) {
          f[now][j][k][l] = 0;
          if (i && sx - i > k) _max(f[now][j][k][l], f[now^1][j][k][l] + get(sx-i, sx-i, max(sy-j, l+1), min(sy+l, m-j)));
          if (j && sy - j > l) _max(f[now][j][k][l], f[now][j-1][k][l] + get(max(sx-i, k+1), min(sx+k, n-i), sy-j, sy-j));
          if (k && n-sx-k+1>i) _max(f[now][j][k][l], f[now][j][k-1][l] + get(sx+k, sx+k, max(sy-j, l+1), min(sy+l, m-j)));
          if (l && m-sy-l+1>j) _max(f[now][j][k][l], f[now][j][k][l-1] + get(max(sx-i, k+1), min(sx+k, n-i), sy+l, sy+l));
          _max(ans, f[now][j][k][l]);
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main()
{

    int N;
    cin >> N;
    int ans = 0;
    for (int i = N; N <= 999; ++i)
    {
        if( i%10 == (i/10)%10 and (i/10)%10 == (i/100)){
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

double L;

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

    cin >> L;
    cout << fixed << setprecision(20) << L * L * L / 27 << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans;


int main(void) {
    ll N, A, B;
    cin >> N >> A >> B; 
    ll t = N / (A+B);
    ll s = N % (A+B);

    ans = t*A;
    if (s>=A) ans += A;
    else ans += s;
    
   

  
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i32 = read();
    println!(
        "{}",
        match x {
            3 | 5 | 7 => "YES",
            _ => "NO",
        }
    )
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define For(i , j , k) for (int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i)
#define rep(i , j) for (int i = 0 , i##_end_ = j; i < i##_end_ ; ++ i)
#define Fordown(i , j , k) for (int i = (j) , i##_end_ = (k) ; i >= i##_end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Ha (1000000007)
#ifdef hany01
#define debug(...) fprintf(stderr , __VA_ARGS__)
#else
#define debug(...)
#endif

inline void file()
{
#ifdef hany01 
	freopen("a.in" , "r" , stdin);
    freopen("a.out" , "w" , stdout);
#endif
}

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

char c_; int _ , __;
inline int read()
{
    for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

ll X, Y;
int cnt;

int main()
{
	file();
    cin >> X >> Y;
    for ( ; X <= Y; X = X * 2) ++cnt;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
from collections import deque

def bfs(adj_mat, d):
    Q = deque()
    N = len(d)
    color = ["W" for n in range(N)]

    Q.append(0)
    d[0] = 0

    while len(Q) != 0:
        u = Q.popleft()

        for i in range(N):
            if adj_mat[u][i] == 1 and color[i] == "W":
                color[i] = "G"
                d[i] = d[u] + 1
                Q.append(i)

        color[u] = "B"

    for i in range(N):
        if color[i] != "B":
            d[i] = -1

def Main():
    N = int(input())

    adj_mat = [[0 for n in range(N)] for n in range(N)]
    d = [0] * N

    for n in range(N):
        u, k , *V = map(int, input().split())

        if k > 0:
            for i in V:
                adj_mat[n][i - 1] = 1

    bfs(adj_mat, d)

    for n in range(N):
        print("{} {}".format(n + 1, d[n]))
Main()


Measured memory_bytes: 6076
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var x = 0d;
        var y = 0d;
        var t = 0;
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(',');
            var d = int.Parse(line[0]);
            var a = int.Parse(line[1]);
            if (d == 0 && a == 0) break;
            y += d * Sin(t * PI / 180);
            x += d * Cos(t * PI / 180);
            t += a;
        }
        Console.WriteLine((int)y);
        Console.WriteLine((int)x);
    }
}



Measured memory_bytes: 15884
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	int N,K,out=0,count=0;
	cin>>N>>K>>S;
	int i=0,j=1;
	while(j<N){ 
		if(S[i]==S[j]){ 
		    j++;
		    out++;} 
		else 
		{i=j;
		j++;}}
	for(int t=K;t>0;t--)	
    out+=2;
    if(out>=N-1)
    out=N-1;
    cout<<out;
    return 0;
}

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

char grid[55][55];
int dis[55][55];

const int INF=INT_MAX;

int di[]={0,1,0,-1};
int dj[]={1,0,-1,0};

int main(){
  int h,w;
  cin>>h>>w;
  int cnt=0;
  rep(i,h)rep(j,w){
    cin>>grid[i][j];
    if(grid[i][j]!='#') cnt++;
    dis[i][j]=INF;
  }
  dis[0][0]=0;
  queue<P> q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    int pi,pj;
    tie(pi,pj)=q.front(); q.pop();
    int past = dis[pi][pj];
    rep(i,4){
      int ni=pi+di[i],nj=pj+dj[i];
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(grid[ni][nj]=='#') continue;
      if(dis[ni][nj] <= past+1) continue;
      dis[ni][nj]=past+1;
      q.push(make_pair(ni,nj));
    }
  }
  if(dis[h-1][w-1]==INF) cout<<-1<<endl;
  else{
    cout<< cnt - dis[h-1][w-1]-1 <<endl;
  } 
}


Measured memory_bytes: 3572
<?php
    for($i = 1; $i <= 9; $i++){
        for($j = 1; $j <= 9; $j++){
            echo $i ."x" .$j ."=" .$i*$j;
            if($i==9 && $j==9){
                continue;
            }
            echo "\n";
        }
    }
?>

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ull a;
    string s;
    cin >> a >> s;

    ull x = 0;
    ull p = 1;

    RREP(i, s.length()){
        if(s[i] == '.') continue;
        x += (s[i] - '0') * p;
        p *= 10;
    }

    cout << a * x / 100 << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

vector<vector<int>> tree(100001);
int dp[100001];

int dfs(int i) {
    if (dp[i] != -1) return dp[i];

    int res = 0;
    for (auto x : tree[i]) {
        res = max(res, dfs(x) + 1);
    }
    dp[i] = res;
    return res;
}

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

    for (int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
    }

    for (int i=0; i<100001; i++) {
        dp[i] = -1;
    }

    int ans = 0;
    for (int i=1; i<=n; i++) {
        ans = max(ans, dfs(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8192
N, K, Q = gets.split.map(&:to_i)
As = readlines.map(&:to_i)

as = As.each_with_object(Array.new(N + 1, 0)){|a, o| o[a] += 1 }
puts (1 .. N).map{|i| K - Q + as[i] > 0 ? 'Yes' : 'No'}

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

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

	if (a == 0) cout << 1 << endl;
	else if (b == 0) cout << 2 << endl;
	else if (c == 0) cout << 3 << endl;
	else if (d == 0) cout << 4 << endl;
	else cout << 5 << endl;
}

Measured memory_bytes: 3592
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))

def binarySearchA(i,lst):
	#[lb,ub)で持って、条件式を実現する最大のindexを求める
	#indexが小さいほど実現しやすいとき。
	lb=0
	ub=n
	if lst[0]>=i:
		return -1
	while ub-lb>1:
		mid=(lb+ub)//2
		if lst[mid]<i:
			lb=mid
		else:
			ub=mid
	return lb

def binarySearchB(i,lst):
	#(lb,ub]で持って、条件式を実現する最小のindexを求める
	lb=-1
	ub=n-1
	if lst[ub]<=i:
		return n
	while ub-lb>1:
		mid=(lb+ub)//2
		if lst[mid]>i:
			ub=mid
		else:
			lb=mid
	return ub

ans=0
for i in b:
	a_max=binarySearchA(i,a)
	c_min=binarySearchB(i,c)
	ans+=(a_max+1)*(n-c_min)
print(ans)

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

using namespace std;

typedef long long ll;

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

int main() {
	ll N, K;
	ll A[100000];
	
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> A[i];

	ll GCD = A[0];
	for (int i = 1; i < N; i++)GCD = gcd(A[i], GCD);
	if (K % GCD == 0 && K <= (*max_element(A, A + N)))cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 1024
from itertools import combinations, product
from math import factorial

def nCr(n, r):
  return int(factorial(n) / factorial(n - r) / factorial(r))

n = int(input())
k = int(input())
size = len(str(n))
count = 0 if k > size - 1 else nCr(size - 1, k) * (9 ** k)
if k == 1:
  count += sum(i * (10 ** (size - 1)) <= n for i in range(1, 10))
else:
  first = int(str(n)[0])
  count += 0 if k > size else (first - 1) * nCr(size - 1, k - 1) * (9 ** (k - 1))
  for digits in combinations(range(size - 1), k - 1):
    count += sum(
      sum(num * (10 ** digit) for num, digit in zip(nums, digits)) <= n % (10 ** (size - 1))
      for nums in product(range(1, 10), repeat = k - 1)
    )
print(count)


Measured memory_bytes: 3064
#include <string>
#include <iostream>

using namespace std;
int main( ) {
  
	string S;
	cin >> S;
  
  if( S[2]== S[3] && S[4]== S[5]) {

	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io::stdin;
use std::io::Error;
use std::io::Read;

#[derive(Debug)]
struct Input {
    s: String,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    let mut iter = input_str.split_whitespace();
    let s = iter.next().unwrap();
    let input = Input { s: s.to_string() };
    Ok(input)
}

fn mm(input: &String) -> bool {
    let mut iter = input.chars();
    let c1 = iter.next().unwrap();
    let c2 = iter.next().unwrap();
    if c1 == '0' {
        return c2 >= '1' && c2 <= '9';
    }
    if c1 == '1' {
        return c2 >= '0' && c2 <= '2';
    }
    false
}

fn yy(input: &String) -> bool {
    let mut iter = input.chars();
    let c1 = iter.next().unwrap();
    let c2 = iter.next().unwrap();
    c1 >= '0' && c1 <= '9' && c2 >= '0' && c2 <= '9'
}

fn handle_output(input: Input) -> Result<String, Error> {
    let tail = input.s.chars().skip(2).collect();
    if yy(&input.s) && mm(&tail) {
        if mm(&input.s) && yy(&tail) {
            return Ok("AMBIGUOUS".to_string());
        }
        return Ok("YYMM".to_string());
    }
    if mm(&input.s) && yy(&tail) {
        return Ok("MMYY".to_string());
    }
    Ok("NA".to_string())
}

fn main() {
    let mut input_str = String::new();
    stdin().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int x,y;
    cin>>x>>y;
    if(y&1) cout<<"No";
    else if(y>4*x||y<2*x) cout<<"No";
    else cout<<"Yes";
    return 0;
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		string s; cin>>s;
		if(s=="-"s)break;
		int m; cin>>m;
		for(int i=0;i<m;++i){
			int h; cin>>h;
			s=s.substr(h)+s.substr(0,h);
		}
		cout<<s<<"\n"s;
	}
}


Measured memory_bytes: 3216
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2484
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}


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

int n;
void dfs(string s,int m){
  int size = s.size();
  if(size == n){
    cout << s << endl;
    return;
  }
  int p = m+2;
  rep(i,0,p){
    char a = 'a'+i;
    string v = s+a;
    if(i == m+1) m++;
    dfs(v,m);
  }
}
  
int main() {
  cin >> n;
  dfs("a",0);
}

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

typedef long long ll;
const int N = 200054, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int p[N], size[N];
int f[N], g[N], inf[N];
char s[N];
ll ans = 1;

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline int min(const int x, const int y) {return x < y ? x : y;}

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x) {
	int i, y; size[x] = s[x] &= 1;
	inf[x] = (s[x] - 1) & INT_MAX;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != p[x]) {
			p[y] = x, dfs(y), size[x] += size[y];
			f[x] <= f[y] ? (g[x] = f[x], f[x] = f[y] + 1) : (up(g[x], f[y] + 1), 0);
			if (size[y]) down(inf[x], f[y] + 1);
		}
}

void dfs2(int x, int fy = -1) {
	int i, y, sup;
	f[x] <= fy ? (g[x] = f[x], f[x] = fy + 1) : (up(g[x], fy + 1), 0);
	if (size[x] < size[1]) down(inf[x], fy + 1);
	if (inf[x] <= (sup = min(f[x] - 1, g[x] + 1))) ans += sup - inf[x] + 1;
	for (i = first[x]; i; i = next[i])
		if (p[y = to[i]] == x)
			dfs2(y, f[y] + 1 == f[x] ? g[x] : f[x]);
}

int main() {
	int i, u, v;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	scanf("%s", s + 1), dfs(1), dfs2(1);
	printf("%lld\n", ans);
	return 0;
}

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

bool prime(int n) {
    bool is_prime = true;
    if (n == 2) return true;
    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int MAX = 100000000;
vector<bool> p(MAX+1, true);

void eratos() {
    p[0] = p[1] = false;
    for (int i = 2; i * i <= MAX; i++) {
        if (p[i]) {
            for (int j = i + i; j <= MAX; j += i) {
                p[j] = false;
            }
        }
    }
}

int main() {
    int n;
    scanf("%d", &n);
    // int count = 0;
    // rep(i, n) {
    //     int x;
    //     scanf("%d", &x);
    //     if (prime(x)) count++;
    // }
    // printf("%d\n", count);
    eratos();
    int cnt = 0;
    rep(i, n) {
        int x;
        scanf("%d", &x);
        if (p[x]) cnt++;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 14804
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = new int[n];
		for(int i = 0; i < n; i++){
		    v[i] = sc.nextInt();
		}

		// 計算
		int result = 0;
		for(int l = 0; l < k + 1; l++){
		    for(int r = 0; r < k - l + 1; r++){
		        if(l + r > n) break;
		        int sum = 0;
		        PriorityQueue<Integer> s = new PriorityQueue<Integer>();
		        //System.out.println("l: " + l + " r: " + r);
		        for(int i = 0; i < l; i++){
		            s.add(v[i]);
		            sum += v[i];
		            //System.out.println("add: " + v[i] + " sum: " + sum);
		        }
		        for(int i = r; i > 0; i--){
		            s.add(v[n - i]);
		            sum += v[n - i];
		            //System.out.println("add: " + v[i] + " sum: " + sum);
		        }
		        for(int d = 0; d < k - l - r; d++){
		            if(s.size() == 0) break;
		            if(s.peek() >= 0) break;
		            //System.out.println("del: " + s.peek());
		            sum -= s.poll();
		            
		        }
		        //System.out.println("result: " + result + " sum:" + sum);
		        result = max(result, sum);
		    }
		}

		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005

int n;
int a[MAXN];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int digit(int n,int d){
    if(d==4)return n/1000;
    if(d==3)return (n%1000)/100;
    if(d==2)return (n%100)/10;
    if(d==1)return n%10;
}

int main(void){
    int n;
    scanf("%d",&n);
    if((digit(n,1)==digit(n,2)&&digit(n,2)==digit(n,3))||(digit(n,3)==digit(n,4)&&digit(n,2)==digit(n,3)))
        printf("Yes\n");
    else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 128
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List as List

solve :: String -> String -> String
solve a b
    | lenA > lenB = solve a ("0" ++ b)
    | lenA < lenB = solve ("0" ++ a) b
    | a > b = "GREATER"
    | a < b = "LESS"
    | otherwise = "EQUAL"
    where
        lenA = length a
        lenB = length b

main :: IO()
main = do
    a <- getLine
    b <- getLine
    putStrLn $ solve a b


Measured memory_bytes: 508
#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};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
    ll N;
  	cin>>N;
    vector<ll> v(N);
    for(ll i = 0; i < N; i++) cin>>v[i];
    vector<ll> cnt;
    ll t = 0;
    for(ll i = 0; i < N; i++){
        t += v[i];
        if(i==N-1||v[i+1]==0) {
            cnt.push_back(t);
            t=0;
        }
    }
    ll ans = 0LL;
    for(auto x:cnt) ans+=x/2;
    cout<<ans<<endl;
}

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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  
  long ok = -2e18, ng = 2e18;
  while (ng - ok > 1) {
    long mid = (ok + ng) / 2, sum = 0;
    for (int i = 0; i < N; i++) {
      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), (long double) mid / A.at(i)) - A.begin();
      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), (long double) mid / A.at(i)) - A.begin());
      if (A.at(i) == 0) sum += (mid > 0) ? N : 0;
      if (A.at(i) * A.at(i) < mid) sum--;
    }
    (sum / 2 < K) ? ok = mid : ng = mid;
  }
  cout << ok << "\n";
}

Measured memory_bytes: 4820
oo = 1000000000 + 5
 
def main():
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    
    dp = [oo for _ in range(n)]
    dp[0] = 0
    for i in range(n):
        for j in range(i + 1, i + k + 1):
            if j < n:
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]))
                
    print(int(dp[n - 1]))
 
main()

Measured memory_bytes: 56544
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, M, lim;
    ll all = 0;
    ll c = 0;
    int i;

    cin >> N >> M;

    vector <int> A(N);

    for(i=0; i<N; i++) {
        cin >> A[i];
        all += A[i];
    }

    lim = (all + (4*M) - 1) / (4*M);

    for(i=0; i<N; i++) {
        if(A[i] >= lim) {
            c++;
        }
    }

    if (c>=M) {
        cout << "Yes";
    } else {
        cout << "No";
    }

}

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

int main()
{
    long long a,b,c,d;
    int i;
    cin >> a;
    cin >> b >> c;
    for(i=b;i<=c;i++)
    {
        if(i%a == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll g = gcd(a, b);
    
    if(c % g != 0) cout << "NO" << endl;
    else cout << "YES" << endl; 
    return 0;
}

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

#define int long long
#define INF 1e18

signed main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    string t = "0123456789";

    bool flag = true;
    for(int i = 0; i < s.size(); i++) {
        if(i == a) {
            if(s[i] != '-') {
                flag = false;
            }
        } else if((int)t.find(s[i]) == -1) {
            flag = false;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}


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

using namespace std;

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<int>h(n);
	for (int i = 0; i < n; i++)cin >> h[i];
	sort(h.begin(), h.end());
	int d = 1000000000;
	for (int i = 0; i + k - 1 < n; i++) {
		d = min(d, h[i + k - 1] - h[i]);
		//cout << d << endl;
	}
	cout << d;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  double ans = 0;
  rep(i, n){
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += x * 380000;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<sstream>
using namespace std;

double dist(double *, double *);

int main(){

	typedef struct{
		double x, y, norm;
	}_point;

	_point p1, p2, q, r, t, tq;
	string str;
	stringstream ss;

/*	
	while(getline(cin, str, ',')){
		ss << str;
		for(int i=0; i<5; i++){
			getline(cin, str, ',');
			ss << str;
		}		
		ss >> p1.x >> p1.y >> p2.x >> p2.y >> q.x >> q.y;
		ss.clear();
*/
	while(scanf("%lf, %lf, %lf, %lf, %lf, %lf", &p1.x, &p1.y, &p2.x, &p2.y, &q.x, &q.y) != EOF){		
		p2.x -= p1.x;
		p2.y -= p1.y;
		p2.norm = sqrt(pow(p2.x, 2) + pow(p2.y, 2));
		q.x -= p1.x;
		q.y -= p1.y;
		q.norm = sqrt(pow(q.x, 2) + pow(q.y, 2));
		t.norm = q.norm * (p2.x * q.x + p2.y * q.y) / (p2.norm * q.norm);
		t.x = p2.x * t.norm / p2.norm;
		t.y = p2.y * t.norm / p2.norm;
		tq.x = q.x - t.x;
		tq.y = q.y - t.y;
		r.x = t.x - tq.x + p1.x;
		r.y = t.y - tq.y + p1.y;
		
		printf("%.6lf %.6lf\n", r.x, r.y);
	}

	return 0;

}

Measured memory_bytes: 1256
#include<stdio.h>
int rec(int,int);
int a[2000],n;

int rec(int s,int t){
  if(a[s]==t) return 1;
  if(s+1==n) return 0;
  if(rec(s+1,t-a[s]) || rec(s+1,t)) return 1;
  return 0;
}

int main(void){
  int b[2000],i,m;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<m;i++){
    if(rec(0,b[i])==1)
      printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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

int main(){
  int b1,b2,b3;
  cin >> b1 >> b2 >> b3;
  
  if(b3==1 || (b1==1 && b2==1)){
    cout << "Open\n";
  }else{
    cout << "Close\n";
  }

  return 0;
}



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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	string s; cin >> s;
	int n = s.size();

	int sum = 0;
	REP(i, n)
		sum += s[i] - '0';

	if (sum % 9) cout << "No" << '\n';
	else cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] target = scanner.nextLine().split("");
		for (int i = target.length - 1; i > 0; i--) {
			System.out.print(target[i]);
		}
		System.out.println(target[0]);
	}
}

Measured memory_bytes: 17128
n, x = (int(x) for x in input().split())
l = list(map(int, input().split()))
d = 0
num = 0
for i in range(n + 1):
    d = 0 if i == 0 else d + l[i-1]

    if d <= x:
        num = num + 1

print(num)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
bool isPrime(int n){
    rep(i, 2, sqrt(n) + 1){
        if(i > 3){
            i++;
        }
        if(!(n % i)){
            return false;
        }
    }
    return true;
}
main(){
    INCANT;
    int q, l, r, tmp, res = 0;
    string s;
    int v[111111] = {};
    for(int i = 3; i < 111111; i += 2){
        v[i] = v[i - 2];
        if(isPrime(i) && isPrime(i / 2 + 1)){
            v[i]++;
        }
    }
    in(q);
    tmp = 111111 - q;
    while(q--){
        in(l, r);
        print(v[r] - v[max(0LL, l - 2)]);
    }
    while(tmp--){
        res*=2;
    }
}


Measured memory_bytes: 1536
def resolve():
    q = int(input())
    lr = list(list(map(int, input().split())) for _ in range(q))
    primes = sieve(10 ** 5)

    # accumulate
    acc = []
    now = 0
    for i in range(10 ** 5):
        if primes[i] and primes[(i + 1) // 2]:
            now += 1
        acc.append(now)

    for l, r in lr:
        print(acc[r] - acc[l - 1])


def sieve(n):
    is_prime = [True for _ in range(n + 1)]
    for p in range(2, int(n ** 0.5) + 1):
        if is_prime[p]:
            for i in range(2 * p, n + 1, p):
                is_prime[i] = False
    is_prime[0], is_prime[1] = False, False
    return is_prime


if __name__ == "__main__":
    resolve()


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

typedef long long ll;

ll ruijyo(ll a,ll n){
    if(n==0) return 1;
    ll x = ruijyo(a,n/2);
    x = x * x;
    if(n%2==1) x = x * a;
    return x;
}

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

    ll x; cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x -= x/500*500;
    ans += (x/5)*5;
    cout << ans << endl;
    return 0;
}

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

double dp[301][301][301];
double sushi(int x, int y, int z , int &n){
    if(x < 0 || y <0 || z<0)
       return 0;
    if(x == 0 && y == 0 && z == 0)
          return 0;

    if(dp[x][y][z] > -0.9){
        return dp[x][y][z];
    }

    double num = n + (x * sushi(x-1,y,z,n)) + (y * sushi(x+1,y-1,z,n)) + (z * sushi(x,y+1,z-1,n));
    return dp[x][y][z] = num/(x+y+z);
}


void solve(){
    int n;
    cin >> n;
    int x=0,y=0,z= 0;
    for(int i=0; i<n; i++){
        int no;
        cin >> no;
        if(no == 1)
           x++;
        if(no == 2)
           y++; 
        if(no == 3)
           z++;    
    }
    
    memset(dp, -1, sizeof(dp));
    cout <<fixed << setprecision(10)<<sushi(x,y,z,n);
    return;
}
int main(){
//  #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif 

 solve();

return 0;
}

Measured memory_bytes: 213376
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
    
fn bfs_dist_grid(H:usize,W:usize,Map:&Vec<Vec<bool>>,start:(usize,usize)) -> Vec<Vec<i32>>{
    let mut d = Vec::new();
    for i in 0..H{
        d.push(Vec::new());
        for _ in 0..W{
            d[i].push(-1);
        }
    }
    d[start.0][start.1] = 0;
    let mut q = vec![start];
    let mut qq;
    while q.len()>0{
        qq = Vec::new();
        while q.len()>0{
            let (i,j) = q.pop().unwrap();
            let dCur = d[i][j];
            for (di,dj) in vec![(-1,0),(1,0),(0,-1),(0,1)]{
                let i = di + i as isize;
                let j = dj + j as isize;
                if i<0 || i >= H as isize {continue;}
                if j<0 || j >= W as isize {continue;}
                let i = i as usize;
                let j = j as usize;
                if !Map[i][j] {continue;}
                if d[i][j]!=-1 {continue;}
                d[i][j] = dCur+1;
                qq.push((i,j));
            }
        }
        q = qq;
    }
    d
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let H = iter.next().unwrap().parse().unwrap();
    let W:usize = iter.next().unwrap().parse().unwrap();
    let mut C = Vec::new();
    for i in 0..H{
        let m:Vec<char> = iter.next().unwrap().chars().collect();
        C.push(Vec::new());
        for &n in m.iter(){
            C[i].push(n != '#');
        }
    }
    let d = bfs_dist_grid(H, W, &C, (0,0))[H-1][W-1];
    let ans = if d>0 {
                C.iter().map(|x| x.iter().filter(|&&y| y).count()).sum::<usize>() as i32
                - d - 1}
                else {-1};
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#define N 5000000

void maxHeapify(int);
void AB();

int H,A[N];

int main(){
  int i;
  scanf ("%d", &H);
  for (i=1; i<=H; i++) scanf("%d", &A[i]);

  AB();

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

  return 0;
}

void maxHeapify(int i){
  int a, l, r, largest;
  l = i * 2;
  r = i * 2 + 1;
  if (l <= H && A[i] < A[l]) largest = l;
  else largest = i;
  if (r <= H && A[largest] < A[r]) largest = r;
  if (largest != i) {
    a = A[i];
    A[i] = A[largest];
    A[largest] = a;
    maxHeapify(largest);
  }
}

void AB(){
  int i;
  for(i=H/2; i>0; --i)maxHeapify(i);
}



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

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

  if (R < 1200)
    printf("ABC");
  else if (1200 <= R && R < 2800)
    printf("ARC");
  else {
    printf("AGC");
  }
  return 0;
}




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

int main(){
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);

  int x = max({a,b,c});
  for(int i = 0;i < k;i++) x *= 2;

  int ans = a + b + c - max({a,b,c}) + x;
  printf("%d\n", ans);

  return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin >> x.at(i);
  }
  
  int l=0;
  
  for(int i=0; i<n; i++){
    l += min(abs(2*x.at(i)),abs(2*(k-x.at(i))));
  }
  
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};
int h, w, sy, sx, max_size;
map<string, int> mp;
string table[15];
string str;
void solve(char ch)
{
	for(int i = 0; i < 8; i++)
	{
		int ny = sy;
		int nx = sx;
		str = "";
		while(1)
		{
			str += table[ny][nx];
			mp[str]++;
			if(mp[str] >= 2)
				max_size = max(max_size, (int)str.size());
			//printf("(%d, %d): %c\n", ny, nx, table[ny][nx]);
			int tmp_y = ny + dy[i];
			int tmp_x = nx + dx[i];
			if(tmp_y < 0) tmp_y = h - 1;
			if(tmp_x < 0) tmp_x = w - 1;
			if(tmp_y >= h) tmp_y = 0;
			if(tmp_x >= w) tmp_x = 0;
			ny = tmp_y;
			nx = tmp_x;
			if(tmp_y == sy && tmp_x == sx)
				break;
		}
		//cout << endl;
	}
}	
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin >> h >> w, h | w)
	{
		mp.clear();
		str = "";
		max_size = 2;
		for(int i = 0; i < h; i++)
		{
			cin >> table[i];
		}
		for(int i = 0; i < h; i++)
		{
			for(int j = 0; j < w; j++)
			{
				sy = i; sx = j;
				solve(table[i][j]);
			}
		}
		bool flag = false;
		for(auto itr = mp.begin(); itr != mp.end(); itr++)
		{
			if(itr->second >= 2 && itr->first.size() == max_size)
			{
				flag = true;
				cout << itr->first << endl;
				break;
			}
		}
		if(!flag)
			cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 38016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N, W, i, j, wet[100001] = {0}, v[100001] = {0}, ans[100001] = {0};
	cin >> N >> W;
	for(i = 0; i < N; i++)
		cin >> wet[i] >> v[i];
	for(i = 0; i < 100001; i++)
		ans[i] = 1000000000000;
	ans[0] = 0;
	for(i = 0; i < N; i++)
	{
		for(j = 100000; j >= 0; j--)
		{
			if(j - v[i] >= 0 && ans[j - v[i]] != 1000000000000)
				ans[j] = min(ans[j], ans[j - v[i]] + wet[i]);
		}
	}
	for(i = 100000; i >= 0; i--)
	{
		if(ans[i] <= W)
		{
			cout << i;
			break;
		}
	}
}

Measured memory_bytes: 2560
import sys

l = []
for i in sys.stdin:
    l.append(i)

for i in range(1,len(l),2):
    a = l[i].split()
    a = a[::-1]
    for j in range(0,len(a)):
        print(int(a[j]),end='')
        if j < len(a) - 1:
            print(" ",end='')
    print()


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;
static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u)
{
    V[u] = true;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (!V[v]) {
            dfs(v);
        }
    }
    out.push_front(u);
}

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

    int s, t, M;

    cin >> N >> M;

    for (int i = 0; i < N; i++) {
        V[i] = false;
    }

    for (int i = 0; i < M; i++) {
        cin >> s >> t;
        G[s].push_back(t);
    }

    for (int i = 0; i < N; i++) {
        if (!V[i]) {
            dfs(i);
        }
    }

    for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
        cout << *it << endl;
    }

    return 0;
}


Measured memory_bytes: 6180
#include<stdio.h>

struct test{
    signed short ssW_D_mid;
    signed short ssW_D_fin;
    signed short ssW_D_re;
    unsigned char eval;
};

unsigned char evaluate(signed short ssW_D_mid, signed short ssW_D_fin, signed short ssW_D_re);

int main(){
    struct test test[50];
    unsigned short usW_C_i;
    unsigned short usW_C_count = 0;

    for(usW_C_i = 0;usW_C_i < 50;usW_C_i++){
        scanf("%d %d %d", &test[usW_C_i].ssW_D_mid, &test[usW_C_i].ssW_D_fin, &test[usW_C_i].ssW_D_re);
        if(test[usW_C_i].ssW_D_mid == -1 && test[usW_C_i].ssW_D_fin == -1 && test[usW_C_i].ssW_D_re == -1){
            break;
        }
        test[usW_C_i].eval = evaluate(test[usW_C_i].ssW_D_mid, test[usW_C_i].ssW_D_fin, test[usW_C_i].ssW_D_re);
        usW_C_count++;
    }

    for(usW_C_i = 0;usW_C_i < usW_C_count;usW_C_i++){
        printf("%c\n", test[usW_C_i].eval);
    }

    return 0;
}

unsigned char evaluate(signed short mid, signed short fin, signed short re){
    signed short ssW_D_sum;
    unsigned char ubW_D_result;

    ssW_D_sum = mid + fin;

    if(mid == -1 || fin == -1){
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= 80){
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= 65){
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= 50){
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= 30){
        if(re >= 50){
            ubW_D_result = 'C';
        }
        else{
            ubW_D_result = 'D';
        }
    }
    else{
        ubW_D_result = 'F';
    }

    return ubW_D_result;
}


Measured memory_bytes: 2040
#include <iostream>

int main() {
  long long H, W;
  std::cin >> H >> W;

  long long ans;
  if (H == 1 || W == 1) {
    ans = 1;
  } else if (H % 2 == 0) {
    ans = W * H/2;
  } else {
    ans = W * (H-1)/2;
    ans += (W+1)/2;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int MAX_V = 410; // 頂点数
vector<vector<int>> d(MAX_V, vector<int>(MAX_V, INF));
void warshall_floyd() {
  for(int k = 0; k < MAX_V; ++k)
    for(int i = 0; i < MAX_V; ++i)
      for(int j = 0; j < MAX_V; ++j)  d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) {
    cin >> s[i];
  }
  rep(i, h * w) d[i][i] = 0;
  rep(i,h)rep(j,w) {
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    if(s[i][j] == '#') continue;
    rep(k, 4) {
      int nx = dx[k] + i;
      int ny = dy[k] + j;
      if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '.') {
        d[nx*w + ny][i*w + j] = 1;
        d[i*w + j][nx*w + ny] = 1;
      }
    }
  }
  warshall_floyd();
  int ans = 0;
  rep(i, h * w)rep(j, h * w) {
    if(d[i][j] != INF) chmax(ans, d[i][j]);
  }
  cout << ans << endl;

}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
 	char a[7][5] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
  	int i;
  string b;
  cin >> b;
  if(b == a[0])
  {
    cout << 7;
  }
  else if(b == a[1])
  {
    cout << 6;
  }
  else if(b == a[2])
  {
    cout << 5;
  }
  else if(b == a[3])
  {
    cout << 4;
  }
  else if(b == a[4])
  {
    cout << 3;
  }
  else if(b == a[5])
  {
    cout << 2;
  }
  else if(b == a[6])
  {
    cout << 1;
  }
  return 0;
}

Measured memory_bytes: 256