akhauriyash/Code-Regression huggingface dataset:
<?php
list($n, $weight) = explode(" ", trim(fgets(STDIN)));
for ($i = 0; $i < $n; $i++) {
    $item[] = explode(" ", trim(fgets(STDIN)));
}
echo depth_dp(count($item)-1, $weight).PHP_EOL;



function depth_dp($no, $weight)
{
    global $item;
    static $dp = [];
    if (isset($dp[$no][$weight])) {
        return $dp[$no][$weight];
    }
    if ($no < 0) {
        return 0;
    }
    $value = depth_dp($no - 1, $weight);    // 入れない場合
    if ($weight >= $item[$no][0]) {         // まだ入るので入れる場合
        $value = max(
            $value,
            depth_dp($no - 1, $weight - $item[$no][0]) + $item[$no][1]
        );
    }
    $dp[$no][$weight] = $value;
    return $value;
}


Measured memory_bytes: 16244
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;


ll sq(ll x) {return x*x;}

void solve() {
    ll a, b, c; cin >> a >> b >> c;
    bool yes;
    ll lhs = c-a-b;
    if (lhs <= 0) yes = false;
    else {
        ll k = lhs/2;
        if (lhs % 2) yes = k*k + k >= a*b;
        else yes = k*k > a*b;
    }
    if (yes) cout << "Yes";
    else cout << "No";
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

int main(){
  int n,m;
  long int student[100][100],check[100][100];
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++) cin>>student[i][j];
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<2;j++) cin>>check[i][j];
  }

  long int ans;
  for(int i=0;i<n;i++){
    long int t=10000000000;
    for(int j=0;j<m;j++){
      long int d=abs(student[i][0]-check[j][0])+abs(student[i][1]-check[j][1]);
      if(t>d){
        t=d;
        ans=j+1;
      }
    }
    cout<<ans<<endl;
  }


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	vector<long long> v(n);
	long long sum=0;
	for(long long& x:v) {cin >> x;sum+=x;}
	long long half=0;

	for(long long i=0;i<n;i++){
		half+=v[i];
		if(half>=sum/2) {
			long long temp=half-v[i];
			cout << min(abs(half-(sum-half)),abs(temp-(sum-temp)));
			break;
		}
	}
	
			
	
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c&&a==c) {
    cout<<"No"<<endl;
  }
    else if(a!=b&&b!=c&&a!=c) cout<<"No"<<endl;
    else{
    cout<<"Yes"<<endl;
  }





  
}


Measured memory_bytes: 256
from math import ceil
s=input()
gu=s.count('g')
pa=s.count('p')

p=len(s)//2
g=int(ceil(len(s)/2))

gu,g=gu-min(gu,g),g-min(gu,g)
pa,p=pa-min(pa,p),p-min(pa,p)

if g==0 and gu==0 and p==0 and pa==0:
  print(0)
  exit()
  
if p==0 and gu==0:
  print(-g)
  exit()
  
if pa==0 and g==0:
  print(gu)
  exit()

Measured memory_bytes: 9160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():

  # a〜z
  l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

  l2=[list() for i in range(26)]
  l3=[list() for i in range(26)]

  s=S()
  t=S()

  for i in range(len(s)):
    if len(l2[l.index(s[i])])>0:
      if l2[l.index(s[i])][0]!=t[i]:
        return 'No'
    else:
      l2[l.index(s[i])].append(t[i])
    if len(l3[l.index(t[i])])>0:
      if l3[l.index(t[i])][0]!=s[i]:
        return 'No'
    else:
      l3[l.index(t[i])].append(s[i])

  return 'Yes'

print(main())


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

using namespace std;

int main(void) {
    int N = 0;
    cin >> N;

    vector<pair<int, int>> nihon;
    vector<bool> isShima(N + 2);
    int count = 0;
    int maxCount = 0;

    for (int i = 1; i <= N; ++i) {
        int num = 0;
        cin >> num;
        nihon.push_back(make_pair(-num, i));
    }

    stable_sort(nihon.begin(), nihon.end());

    if (nihon[0].first != 0) {
        for (int i = 0; i < N; ++i) {
            isShima[nihon[i].second] = true;
            if (!isShima[nihon[i].second - 1] && !isShima[nihon[i].second + 1]) {
                count++;
            }
            else if (isShima[nihon[i].second - 1] && isShima[nihon[i].second + 1]) {
                count--;
            }
            if (nihon[i].first != nihon[i + 1].first) maxCount = max(maxCount, count);
        }
    }

    cout << maxCount << endl;
}


Measured memory_bytes: 4404
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/2
Solved on 2019/3/
@author: shinjisu
"""


# Educational Dynamic Programming
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_A():  # Frog 1
    N = getInt()
    H = getIntList()
    dmp((N, H), 'N, H')
    c = zeros(N)
    c[1] = abs(H[1]-H[0])
    for i in range(2, N):
        c[i] = min(c[i-1] + abs(H[i]-H[i-1]),
         c[i-2] + abs(H[i]-H[i-2]))
    dmp(c, 'c')
    return c[N-1]


debug = False  # True False
ans = prob_A()
print(ans)
#for row in ans:
#    print(row)


Measured memory_bytes: 13908
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s;
    cin>>s;
    int n=sz(s);

    if(s=="keyence"){
        puts("YES");
        return 0;
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            string t = s;
            if(j+i-1>=n)break;
            t.erase(j, i);
            if(t=="keyence"){
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 100010;

int n, m, i, j, k, v[N], d[N];

inline int abs(int x) {
    return (x >= 0 ? x : (-x));
}

inline int minim(int x, int y) {
    return (x < y ? x : y);
}

int main(){
    cin >> n >> k;
    for (i = 1; i <= n; ++i) {
        cin >> v[i];
    }
    m = minim(k, n);
    for (i = 2; i <= m; ++i) {
        d[i] = d[i - 1] + abs(v[i] - v[i - 1]);
        for(j = i - 2; j > 0; --j) {
            d[i] = minim(d[i], d[j] + abs(v[i] - v[j]));
        }
    }
    for (i = k + 1; i <= n; ++i) {
        d[i] = d[i - 1] + abs(v[i] - v[i - 1]);
        for(j = 2; j <= k; ++j) {
            d[i] = minim(d[i], d[i - j] + abs(v[i] - v[i - j]));
        }
    }
    cout << d[n] << "\n";
	return 0;
}


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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

bool visited[100010];

bool func(string &str, int pos)
{
    if(visited[pos]) return false;
    if(pos >= str.size()) return true;
    visited[pos] = true;
    if(str.substr(pos,5)=="dream") if(func(str,pos+5)){
        return true;
    }
    if(str.substr(pos,7)=="dreamer") if(func(str,pos+7)){
        return true;
    }
    if(str.substr(pos,5)=="erase") if(func(str,pos+5)){
        return true;
    }
    if(str.substr(pos,6)=="eraser") if(func(str,pos+6)){
        return true;
    }
    return false;
}

int main()
{
    string str;
    cin >> str;

    memset(visited,0,false);

    if(func(str,0)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 1920
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string b = Console.ReadLine();
        if (b == "A") Console.WriteLine("T");
        else if (b == "T") Console.WriteLine("A");
        else if (b == "G") Console.WriteLine("C");
        else if (b == "C") Console.WriteLine("G");
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=50005;
int a[100005];
int n,m;
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2==1)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
// Example program
#include <iostream>
#include <string>

using namespace std;

int a, b, c, x;

int main()
{
  cin >> a >> b >> c >> x;
  
  x /= 50;
  
  int counter = 0;
  for (int aa = 0; aa <= a; ++aa) {
  for (int bb = 0; bb <= b; ++bb) {
  for (int cc = 0; cc <= c; ++cc) {
    if (aa * 10 + bb * 2 + cc == x) counter += 1;    
  }}}
  
  cout << counter << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,sx,sy,total;
};
int main(){

	int n;
	ll a,b;
	cin>>n>>a>>b;
	int total=0;
	rep(i,n){
		ll t;
		cin>>t;
		if(t<a||t>=b)total++;
	}
	cout<<total<<endl;
	return 0;

}




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

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

    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    if (b > c) {
        t = b;
        b = c;
        c = t;
    }
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }

    printf("%d %d %d", a, b, c);
    printf("\n");

    return 0;
}

Measured memory_bytes: 1028
import Control.Monad
import Data.List

main = do
  [n, k] <- map read . words <$> getLine
  hs <- replicateM n $ readLn
  print $ minimum $ func k $ sort hs
  
func :: Int -> [Int] -> [Int]
func k xs = zipWith (-) (drop (k - 1) xs) xs

Measured memory_bytes: 65916
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  long current = 0;
  rep (i, N) {
    if (i == 0 and S[i] == 'L') continue;
    if (i == N-1 and S[i] == 'R') continue;
    if (S[i] == 'L' and S[i-1] == 'L') current++;
    if (S[i] == 'R' and S[i+1] == 'R') current++;
  }
  long ans = current;
  ans += K * 2;
  ans = min(ans, N-1);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	vs := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}
	sort.Float64s(vs)

	ans := vs[0]
	for i := 1; i < n; i++ {
		ans += vs[i]
		ans /= 2.0
	}
	fmt.Printf("%0.10f\n", ans)
}


Measured memory_bytes: 1836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> w;
int main() {
  cin >> n;
  read_n(w, n);

  vector<i64> s(n + 1);
  for (i64 i = 1; i <= n; ++i) s[i] = s[i - 1] + w[i - 1];

  i64 ans = 1 << 30;
  for (i64 i = 1; i < n; ++i) {
    ans = min(ans, abs(s[n] - s[i] - s[i]));
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int fun(int n){
        int ans=100000;
        for(int i=0;i<n;i++){
            int x=(int)(ans*0.05),y=0;
            if (x%1000>0)y=1000;
            ans=ans+x+y-x%1000;
        }
        return ans;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println(fun(sc.nextInt()));
    }
}


Measured memory_bytes: 26160
N,M = map(int,input().split())
S = [input() for _ in range(N)]
T = [input() for _ in range(M)]
ans = False
cnt = N - M
for i in range(cnt+1):
    for j in range(cnt + 1):
        tmp = T[0]
        check = S[i][j:M+j]
        key = 0
        if(check == tmp):
            key += 1
            for k in range(1,M):
                tmp = T[k]
                check =  S[i+k][j:M+j]
                if(check == tmp):
                    key += 1
        if(key == M):
            ans =True
            break

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int R;
    cin >> R;

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

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

using namespace std;

int A;
int B;

int main() {
  cin >> A;
  cin >> B;

  if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;


// mod付きpower
// x^n
ll modpow(ll x, int n) {
	if (n == 0) return 1LL;
	else if (n % 2 == 0) return modpow((x * x) % MOD, n / 2) % MOD;
	else return (modpow((x * x) % MOD, n / 2) * x) % MOD;
}

// a/bを返す
ll divMod(ll a, ll b) {
	ll res = a * modpow(b, MOD - 2);
	return res % MOD;
}

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

	ll X, Y; cin >> X >> Y;
	if ((X + Y) % 3 == 0) {
		ll N = (X + Y) / 3;
		X -= N;
		Y -= N;
		if (X >= 0 && Y >= 0) {
			ll ans = 1;
			for (ll i = 1; i <= X + Y; i++) {
				ans *= i;
				ans %= MOD;
			}
			for (ll i = 1; i <= X; i++) ans = divMod(ans, i);
			for (ll i = 1; i <= Y; i++) ans = divMod(ans, i);
			cout << ans << endl;
		}
		else cout << 0 << endl;
	}
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

int main()
{
    string s;
    cin >> s;
    if(((s[0] == s[1]) && (s[0] == s[2])) || ((s[1] == s[2]) && (s[1] == s[3]))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,H;
  cin >> N;
  int HM = 0;
  int ans = 0;
  for (int i = 0; i < N; i++){
    cin >> H;
    if (H >= HM){
      ans++;
      HM = H;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
mod = 998244353
A,B,C,D = map(int,input().split())

dp = [[0]*(D+1) for _ in range(C+1)]
dp[A][B] = 1
for a in range(A+1,C+1):
    dp[a][B] = dp[a-1][B]*B%mod
for b in range(B+1,D+1):
    dp[A][b] = dp[A][b-1]*A%mod
for a in range(A,C):
    for b in range(B,D):
        dp[a+1][b+1] = (dp[a+1][b]+dp[a][b+1]+a*dp[a+1][b]+b*dp[a][b+1]-a*b*dp[a][b])%mod
print(dp[C][D])

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

using namespace std;

typedef long long ll;

const int maxn=1e6+5,mod=1e9+7;
const double pi=acos(-1);

int main()
{
    char c;
    cin>>c;
    if(c-'A'>=0&&c-'A'<=26)
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;
    /*int n,k;
    cin>>n>>k;
    int a[1005];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;*/
    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>

int Eratos[1000000];

int main()
{
	Eratos[0] = Eratos[1] = 0;
	for (int i = 2; i < 1000000; i++){
		Eratos[i] = 1;
	}
	for (int i = 2; i < 1000; i++) {
		if (Eratos[i]) {
			for (int j = 2 * i; j < 1000000; j += i) {
				Eratos[j] = 0;
			}
		}
	}
	int n,res;
	res = 1;
	for (int i = 2; i < 1000000; i++) {
		if (Eratos[i]) {
			Eratos[i] = res;
			res++;
		}
	}
	while (scanf("%d", &n) != EOF) {
		res = 0;
		while (!Eratos[n]) {
			n--;
			if (n == 0)
				break;
		}
		if (n)
			printf("%d\n", Eratos[n]);
		else
			printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 4940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Array.Sort(a);
        int ans = 0;
        for (int i = 1; i < 3; i++) {
            ans += Math.Abs(a[i] - a[i - 1]);
        }
        Console.WriteLine(ans);
    }
}


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

int N, M, V, P;
int A[100100];

int main(){
	scanf("%d%d%d%d", &N, &M, &V, &P);
	rep(i, N){
		scanf("%d", &A[i]);
	}
	int ans = P;
	sort(A, A+N);
	reverse(A, A+N);
	V = N-V;
	long long sum = A[P-1];
	int cnt = P;
	for(int i = P; i < N; i++){
		if(V >= i-P+1){
			if(A[i] >= A[P-1] - M) cnt++;
		} else if((sum - 1LL * (i-P+1) * A[i]) <= (1LL * M * V) && A[i] >= A[P-1] - M) cnt++;
		sum += A[i];
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
	int n,ye;
	cin >> n >>ye;
  	bool xk=true;
	for (int x=0;x<=n;x++){
		for (int y=0;y<=n-x;y++){
        	if (x*10000+y*5000+(n-x-y)*1000==ye) {
            	cout << x << " " << y << " " << n-x-y << endl;	
              	xk =false;
              	break;
            }
              
        }
      	if (xk==false) break;
    }
  	if (xk==true) cout << "-1 -1 -1"<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll H,W;
  cin >> H >> W;
  ll ans=1000000000000;
  for(int i=1;i<W;i++){
    ll a=H*i; ll b,c;
    if(H%2==0){b=(W-i)*H/2;  c=(W-i)*H/2;}
    else{b=(W-i)*(H+1)/2;  c=(W-i)*(H-1)/2;}
    ll s=max({a,b,c})-min({a,b,c});
    ans=min(ans,s);
    
    if((W-i)%2==0){b=(W-i)*H/2;  c=(W-i)*H/2;}
    else{b=(W-i+1)*H/2;  c=(W-i-1)*H/2;}
    s=max({a,b,c})-min({a,b,c});
    ans=min(ans,s);
  }
  for(int i=1;i<H;i++){
    ll a=W*i; ll b,c;
    if(W%2==0){b=(H-i)*W/2;  c=(H-i)*W/2;}
    else{b=(H-i)*(W+1)/2;  c=(H-i)*(W-1)/2;}
    ll s=max({a,b,c})-min({a,b,c});
    ans=min(ans,s);
    
    if((H-i)%2==0){b=(H-i)*W/2;  c=(H-i)*W/2;}
    else{b=(H-i+1)*W/2;  c=(H-i-1)*W/2;}
    s=max({a,b,c})-min({a,b,c});
    ans=min(ans,s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void StartProgram()
{
    long double circleRadius, circumReference;
    scanf("%Lf", &circleRadius);
    
    circumReference = 2 * M_PI * circleRadius;
    printf("%Lf", circumReference);
    
    return ;
}

int main(int argc, const char * argv[])
{
    StartProgram();
    
    return 0;
}


Measured memory_bytes: 1736
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int H = stdIn.nextInt();
		int N = stdIn.nextInt();
		int sum = 0;
		for(int i=0 ;i<N;i++) {
			sum += stdIn.nextInt();
		}
		if(sum>=H) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 46012
#include <iostream>
#include <vector>
#include <algorithm>
#include "math.h"
using namespace std;
int main(){
int N, a;
cin>>N;
vector<int> vec;
for(int i = 0; i < N; ++i){
    cin>>a;
    vec.push_back(a);
}
long long ans = vec[0] - 1;
int k = 2;
for(int i = 1; i < N; ++i){
    if(vec[i] > k){
        long long t = ceil(vec[i] / (double)k) - 1;
        ans += t;
    }
    else if(vec[i] == k){
        k++;
    }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()


long a,b,c,d;
long cost[4];
long dic[3] = {2,3,5};

long dfs(long now, map<long,long> &mp){
  if(mp.count(now)) return mp.at(now);
  long ans;
  if(now > 2*1e9) ans = 2*1e18;
  else ans = now*d;
  rep(i,3){
    if(now % dic[i] == 0) ans = min(ans, dfs(now/dic[i], mp) + cost[i]);
    else{
      ans = min(ans, dfs(now/dic[i], mp) + cost[i] + cost[3]*(now % dic[i]));
      ans = min(ans, dfs(now/dic[i] + 1, mp) + cost[i] + cost[3]*(dic[i] - now % dic[i]));
    }
  }
  mp[now] = ans;
  return ans;
}

void Main(){
  long n;
  cin >> n;
  rep(i,4) cin >> cost[i];
  a = cost[0];
  b = cost[1];
  c = cost[2];
  d = cost[3];
  map<long,long> mp;
  mp[0] = 0;
  mp[1] = d;
  cout << dfs(n, mp) << endl;
}

int main(){
  int t;
  cin >> t;
  rep(i,t) Main();
}

Measured memory_bytes: 4260
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[2000];
int main() {
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    int cnt = 0;
    sort(a, a + n);
    for(int a = 0; a < n; ++a) {
        int b = a + 1, c = a + 2;
        while(b < n) {
            while(c < n && ::a[c] < ::a[a] + ::a[b])
                ++c;
            cnt += c - b - 1;
            ++b;
        }
    }
    cout << cnt << endl;
    return 0;
}
// 1 2 3 4
// 

Measured memory_bytes: 256
p, g = 998244353, 3
invg = pow(g, p-2, p)
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(invg, (p - 1) >> i, p) for i in range(24)]
def convolve(a, b):
    def fft(f):
        for l in range(k)[::-1]:
            d = 1 << l
            v = W[l+1]
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p

    def ifft(f):
        for l in range(k):
            d = 1 << l
            v = iW[l+1]
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p

    n0, n1 = len(a), len(b)
    k = (max(n0, n1) - 1).bit_length() + 1
    n = 1 << k
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 203344
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	var tmpS string
	fmt.Scan(&tmpS)
	s := strings.Split(tmpS, "")

	now := s[0]
	ans := make([]string, 1)
	ans[0] = now
	i := 0

	for i < n - 1 {
		for s[i] == now && i < n - 1{
			i++
		}
		if i != n - 1 {
			now = s[i]
			ans = append(ans, now)
		} else {
			if ans[len(ans) - 1] != s[i] {
				ans = append(ans, s[i])
			}
			break
		}
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 9472
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int N = sc.nextInt();
        
		//System.out.println(N+" "+M);
      String result ="No";
      for(int i = 1 ; i < 10;++i){
        if(N % i == 0){
          int remainder = N / i; 
          if(remainder > 0 && remainder < 10){
          	result = "Yes";
          } 
        }
      }
		System.out.println( result);
    }


}


Measured memory_bytes: 22740
import itertools, collections
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
cum = [0] + [c % M for c in itertools.accumulate(A)]
cnt = collections.Counter(cum)
ans = sum(v * (v - 1) // 2 for v in cnt.values())
print(ans)


Measured memory_bytes: 21336
#include <bits/stdc++.h>
#define NMAX 300005

using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
const ll MOD=1e9+7;
ll primes[250],sz=0;
bool sieve[1100],counted[1000009];
void getprimes(){
    ll size=1100;
    for(ll i=4;i*i<size;i+=2)
        sieve[i]=1;
    for(ll i=3;i*i<size;i+=2){
        if(!sieve[i])
            for(ll j=i*i;j<size;j+=i)
                sieve[j]=1;
    }
    for(ll i=2;i<size;i++){
        if(!sieve[i])
            primes[sz++]=i;
    }
}
bool wrongDivs(ll x){
    for(ll i=0;primes[i]*primes[i]<=x;i++){
        if(x%primes[i]==0){

            if(counted[primes[i]])
                return true;
            counted[primes[i]]=1;

            while(x%primes[i]==0)
                x/=primes[i];
        }
    }
    if(x>1){
        if(counted[x])
            return true;
        counted[x]=1;
    }
    return false;
}
int main()
{
    getprimes();
    ll n,x,arrgcd;
    bool pairwise_coprime=1,setwise_coprime=0;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        if(!setwise_coprime){
            if(i==0) arrgcd=x;
            else arrgcd=__gcd(arrgcd,x);
            if(arrgcd==1) setwise_coprime=1;
        }
        if(pairwise_coprime){
            if(wrongDivs(x))
                pairwise_coprime=0;
        }
    }
    if(pairwise_coprime)
        cout<<"pairwise coprime";
    else if(setwise_coprime)
        cout<<"setwise coprime";
    else cout<<"not coprime";
    return 0;
}


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

int main() {
  ll n,m; cin>>n>>m;
  ll ans;
  if(n*2>=m){ans=m/2;}
  else{ans=n+(m-2*n)/4;}
  cout<<ans;
}

Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define FORALL(i,x) for(auto i=x.begin();i!=x.end();i++)
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second


class UnionFind {
public:
    vector<ll> parent; //parent[i]はiの親
    vector<ll> siz; //素集合のサイズを表す配列(1で初期化)

    //コンストラクタの:の後ろはメンバ変数を初期化している
    UnionFind(ll n):parent(n),siz(n,1){ //最初は全てが根であるとして初期化する
        for(ll i=0;i<n;i++){parent[i]=i;}
    }

    ll root(ll x){ //データxの属する木の根を再帰で得る
        if(parent[x]==x) return x;
        //代入式の値は代入した変数の値になる！
        //経路圧縮(根に直接要素を繋ぐことで計算を効率化する)
        return parent[x]=root(parent[x]);
        //再帰で得る際に親の更新を行っておく
    }

    void unite(ll x,ll y){ //xとyの木を併合する
        ll rx=root(x);//xの根をrx
        ll ry=root(y);//yの根をry
        if(rx==ry) return; //同じ木にある時
        //小さい集合を大きい集合へと併合させる(ry→rxへ併合)
        if(siz[rx]<siz[ry]) swap(rx,ry);
        siz[rx]+=siz[ry];
        parent[ry]=rx; //xとyが同じ木にない時はyの根ryをxの根rxにつける
    }

    bool same(ll x,ll y){//xとyが属する木が同じかを返す
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }

    ll size(ll x){ //素集合のサイズ
        return siz[root(x)];
    }
};

signed main(){
    ll n,k,l;cin >> n >> k >> l;

    UnionFind uf1(n);
    vector< pair<ll,ll> > pq(k);
    REP(i,k){cin >> pq[i].F >> pq[i].S;pq[i].F-=1;pq[i].S-=1;}
    REP(i,k){uf1.unite(pq[i].F,pq[i].S);}

    UnionFind uf2(n);
    vector< pair<ll,ll> > rs(l);
    REP(i,l){cin >> rs[i].F >> rs[i].S;rs[i].F-=1;rs[i].S-=1;}
    REP(i,l){uf2.unite(rs[i].F,rs[i].S);}

    vector< pair<ll,ll> > num(n);
    REP(i,n){num[i].F=uf1.root(i);num[i].S=uf2.root(i);}
    map< pair<ll,ll>, ll> group;
    REP(i,n){
        if(group.find(num[i])==group.end()){
            group[num[i]]=1;
        }else{
            group[num[i]]+=1;
        }
    }
    REP(i,n){
        if(i!=n-1){
            cout << group[num[i]] << " ";
        }else{
            cout << group[num[i]] << endl;
        }
    }
}

Measured memory_bytes: 24064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
int main(){
	string str;
	int i,countjoi=0,countioi=0;
	while(cin>>str){
	for(i=0;i<str.size()-2;i++){
		if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I'){
				countjoi++;
		}
		if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I'){
				countioi++;
		}
	}
	cout<<countjoi<<endl;
	cout<<countioi<<endl;
	countjoi=0;
	countioi=0;
	}
return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
int main(void)
{
	int n,a[201],i,z,mini=1000000000;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&a[i]);
	}
	for(i=0; i<n; i++){
		z=0;
		while(a[i]%2==0){
			a[i]=a[i]/2;
			z=z+1;
		}
		if(mini>z){
			mini=z;
		}
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
	int k;
	while(cin>>k,k)
	{
		int sum=0,t;
		rep(i,k*(k-1)/2)cin>>t,sum+=t;
		cout<<sum/(k-1)<<endl;
	}
	
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	string s, t; cin >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
}



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

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class DStringFormation {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;in>>s;
        ll n;in>>n;
        string f,b;
        ll cnt=0;
        ll front=1;
        rep(i,n){
            ll t;in>>t;
            if(t==1) {
                front*=-1;
                ++cnt;
            } else if (t==2){
                ll F;in>>F;
                char C;in>>C;
                if(F==1){
                    if(front==1) f.push_back(C);
                    else if(front==-1) b.push_back(C);
                } else {
                    if(front==1) b.push_back(C);
                    else if(front==-1) f.push_back(C);
                }
            }
        }

        reverse(all(f));
        string res = f+s+b;
        if(cnt%2==0){
            out<<res<<endl;
        } else {
            reverse(all(res));
            out<<res<<endl;
        }
	}
};


int main() {
	DStringFormation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 2e5 + 5;
long long fac[N] = {};
long long INV(long long x) {
    if (x == 1) return 1;
    return (mod - mod / x) * INV(mod % x) % mod;
}
void init() {
    fac[0] = 1;
    for (int i = 1; i < N; i++)
        fac[i] = fac[i - 1] * i % mod;
}
long long ksm(long long a, long long b) {
    if (b == 0) return 1;
    if (b == 1) return a % mod;
    else if (b & 1) return ksm(a * a % mod, b >> 1) * a % mod;
    else return ksm(a * a % mod, b >> 1);
}
int main() {
    init();
    long long n, m, k;
    cin >> n >> m >> k;
    long long ans = 0, t;
    for (int i = 0; i <= k; i++) {
        t = fac[n - 1] * INV(fac[i] * fac[n - 1 - i] % mod) % mod;
        t = t * ksm(m - 1, n - 1 - i) % mod;
        ans = (ans + t * m) % mod;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 5176
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;forn(i,t)
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    int n,c=0;
    cin>>n;
    int a[n];
    forn(i,n)cin>>a[i];
    forn(i,n){
        if(i%2==1 and (a[i]*a[i])%2==1)c++;
    }
    cout<<c;

End;
}


Measured memory_bytes: 3608
n = int(input())
b = list(map(int, input().split()))
a = []
for i in range(n):
    if i == 0:
        a.append(b[0])
    elif i == n-1:
        a.append(b[n-2])
    else:
        a.append(min(b[i-1],b[i]))
print(sum(a))


Measured memory_bytes: 3060
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

A=0
b=0
c=0
z=[]
for i in range(n):
    A+=abs(x[i]-y[i])
    b+=(x[i]-y[i])*(x[i]-y[i])
    c+=(abs(x[i]-y[i]))**3
    z.append(abs(x[i]-y[i]))
D=max(z)

    
B=b**(1/2)
C=c**(1/3)

print(A)
print(B)
print(C)
print(D)


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

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

int a[1010][1010];
int dp[1010][1010];

int main()
{
    int h,w,n;
    
    while (cin>>h>>w>>n, h) {
        memset(dp, 0, sizeof(dp));
        rep(i, h) rep(j, w) cin >> a[i][j];

        dp[0][0] = n-1;

        rep(i, h) {
            rep(j, w) {
                if (a[i][j] == 0) {
                    dp[i+1][j] += dp[i][j] / 2 + (dp[i][j] % 2);
                    dp[i][j+1] += dp[i][j] / 2;
                } else {
                    dp[i][j+1] += dp[i][j] / 2 + (dp[i][j] % 2);
                    dp[i+1][j] += dp[i][j] / 2;
                }
            }
        }

        rep(i, h) rep(j, w) {
            a[i][j] = (a[i][j] + dp[i][j]) % 2;
        }

        int y = 0, x = 0;

        while (y < h && x < w) {
            if (a[y][x] == 1) x++;
            else y++;
        }

        cout << y+1 << ' ' << x+1 << endl;
    }
}

Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x[n],y[n],a[n];
    REP(i,n){
        cin >> x[i] >> y[i] >> a[i];
    }
    bool black[w][h] = {};
    REP(i,n){
        if(a[i] == 1){
            REP(j,x[i]){
                REP(k,h){
                    black[j][k] = true;
                }
            }
        }else if(a[i] == 2){
            for(int j = x[i]; j < w; j++){
                REP(k,h){
                    black[j][k] = true;
                }
            }
        }else if(a[i] == 3){
            REP(j,y[i]){
                REP(k,w){
                    black[k][j] = true;
                }
            }
        }else if(a[i] == 4){
            for(int j = y[i]; j < h; j++){
                REP(k,w){
                    black[k][j] = true;
                }
            }
        }
    }
    int ans = 0;
    REP(i,w){
        REP(j,h){
            if(black[i][j] == false) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int A[15][25];
int n,m,cnt=0;
int Get_dis(int x,int y){
	int res=0;
	for(int i=1;i<=m;i++){
		res+=abs(A[x][i]-A[y][i])*abs(A[x][i]-A[y][i]);
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&A[i][j]);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		int res=Get_dis(i,j);
		int flag=sqrt(res);
		if(flag*flag==res)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
# - coding : utf-8 -*-
import numpy as np

def mean_temp(t, x):
    temp = t - x * 0.006
    return temp

def getNearestIdx(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

if __name__ == '__main__':
    n = int(raw_input())
    t, a = map(int, raw_input().split())
    hs = map(int, raw_input().split())

    result = []
    for h in hs:
        result.append(mean_temp(t, h))
    output = getNearestIdx(result, a) + 1
    print output

Measured memory_bytes: 16264
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    bool p = false;
    bool w = false;
    bool g = false;
    bool y = false;

    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;

        if (c == 'P') {
            p = true;
        }
        if (c == 'W') {
            w = true;
        }
        if (c == 'G') {
            g = true;
        }
        if (c == 'Y') {
            y = true;
        }
    }

    if (p && w && g && y) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }

    return 0;
}


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

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

    long long H, W; cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << "\n";
    }
    else {
        cout << (H * W + 1) / 2 << "\n";
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  int sum=1,summ=1;
  for(int i=0;i<n;++i){
    cin>>vec[i];
  }
  for(int i=0;i<n-k;++i){
    if(vec[i]<vec[i+k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}
    /*if(i<k){
      sum*=vec[i];
      summ=sum;
    }
  }
  for(int i=0;i<n-k;++i){
    summ=(summ*vec[i+k])/vec[i];
    if(sum<summ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    sum=summ;
  }*/

Measured memory_bytes: 4840
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    };
    let &max = a.iter().max().unwrap();
    let mut r = max;
    let mut d = 1_000_000_001;
    for &a_i in a.iter() {
        if a_i == max {
            continue;
        }
        let d_i = (a_i - max / 2).abs();
        if d_i < d {
            r = a_i;
            d = d_i;
        }
    }
    println!("{} {}", max, r);
}


Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void){
    char s[21];
    cin >> s;
    
    int i;
    for(i = 0; i < 19; i++){
        if(i == 5 || i == 13){
            cout << " ";
        }else{
            cout << s[i];
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int d[101][101];

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

    const int INF = 1e9;
    rep(i, 101){
        rep(j, 101) if(i != j) d[i][j] = INF;
    }

    vector<int> a(m), b(m), c(m);

    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    rep(k, n){
        rep(i, n){
            rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }

    int ans = m;
    rep(i, m){
        bool used = false;
        rep(j, n){
            if(d[a[i]][j] + c[i] == d[j][b[i]]) used = true;
        }
        if(used) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256