akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        Arrays.sort(A);

        if (N % 2 == 1) {
            int start = N / 2;
            int before = start;
            long sum1 = 0;
            long sum2 = 0;

            for (int i = 0; i < N/2; i++) {
                sum1 += A[N - 1 - i] - A[before];
                sum1 += A[N - 1 - i] - A[i];
                before = i;
            }

            before = start;
            for (int i = 0; i < N/2; i++) {
                sum2 += A[before] - A[i];
                sum2 += A[N - 1 - i] - A[i];
                before = N - 1 - i;
            }

            System.out.println(Math.max(sum1, sum2));
        } else {
            int start = N / 2 - 1;
            int before = start;
            long sum1 = 0;
            long sum2 = 0;

            for (int i = 0; i <= N/2 - 1; i++) {
                if (i == N/2 - 1) {
                    sum1 = A[N - 1 - i] - A[before];
                } else {
                    sum1 += A[N - 1 - i] - A[before];
                    sum1 += A[N - 1 - i] - A[i];
                    before = i;
                }
            }

            start = N / 2;
            before = start;
            for (int i = 0; i <= N/2 - 1; i++) {
                if (i == N/2 - 1) {
                    sum2 += A[before] - A[i];
                } else {
                    sum2 += A[before] - A[i];
                    sum2 += A[N - 1 - i] - A[i];
                    before = N - 1 - i;
                }
            }

            System.out.println(Math.max(sum1, sum2));
        }
    }
}

Measured memory_bytes: 51104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		ans += __builtin_ctz(a);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    ll n,m,v,p;
    cin>>n>>m>>v>>p;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.rbegin(),a.rend());
    ll sum=0;
    ll c=n-p+1;
    for(int i=p;i<n;i++){
        sum+=a[i];
    }
    ll vp = v-(p-1);
    sum+=(m)*vp;
    ll up=a[p]+m+1;
    ll d=a[p]-1;

    while(up>d){
        ll mid=(up+d)/2;
       // cout<<up<<" "<<mid<<" "<<d<<endl;
        int j=p-1;
        ll csum = 0;
        bool f =false;
        while(true){
            if(j==n)break;
            if(mid<a[j])break;
            if(abs(mid-a[j])>m){
                csum+=m;
            }else{
                csum+=abs(mid-a[j]);
            }
            // cout<<a[j]<<" "<<csum<<endl;

            if(csum>=m*vp){
                // cout<<csum<<endl;
                f=true;
                break;
            }
            j++;
        }
        if(f){
            up=mid;
        }else{
            d=mid+1;
        }
       // cout<<up<<" "<<mid<<" "<<d<<endl;
        // if(mid==d)break;
    }
   // cout<<up<<d<<endl;
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]+m>=up){
            ans++;
        }
    }
    cout<<ans<<endl;










    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << '+' << endl;
    else if (a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

h,m,hh,mm,k = map(int, input().split())

ss = h*60+m

ff = hh*60+mm

if ff-ss < 0:
    tmp = ff-ss + 24*60
else:
    tmp = ff-ss

ans = tmp - k

print(max(0,ans))


Measured memory_bytes: 9116
#include <stdio.h>
#include <string.h>
using namespace std;
int a[100001];

int main(){
	int n,k,i,j,l,o,p=100001,q,r=1000000,w,f;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
	scanf("%d",&a[i]);
	if(a[i]<p){p=a[i];q=i;}
}
j=q-k+1;
if(j<1)j=1;
for(i=j;i<=q;i++){
	if((i-1)%(k-1))w=(i-1)/(k-1)+1;
	else w=(i-1)/(k-1);
	if(i+k-1>=n)f=1;
	else {f=(n-(i+k-1));
	if(f%(k-1))f=f/(k-1)+2;
	else f=f/(k-1)+1;
}
if(f+w<r)r=f+w;

}
printf("%d",r);
	
	return 0;
}

Measured memory_bytes: 512
s = input()
n = len(s)
ans = 'Yes'
if s != s[::-1]:
    ans = 'No'
seq1 = int((n - 1) / 2)
if s[:seq1] != s[seq1-1::-1]:
    ans = 'No'
seq2 = int((n + 3) / 2)
if s[seq2-1:] != s[n:seq2-2:-1]:
    ans = 'No'
print(ans)

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

void input();
void solve();
ld f(ld,ld,ld);

ld a,b,x;
const ld PI=acos(-1);

int main(){
  solve();
  return 0;
}
void input(){
  cin>>a>>b>>x;
}
ld f(ld a,ld b,ld x){
  if(a*a*b/2<=x){
    return atan(2*(a*a*b-x)/(a*a*a));
  }else{
    return PI/2-atan(2*x/(a*b*b));
  }
}
void solve(){
  input();
  cout<<fixed<<setprecision(10)<<f(a,b,x)*180/PI<<endl;
}

Measured memory_bytes: 256
import copy

def find(h):
    bits_active = {}
    for i in range(pow(2,h)):
        x = bin(i)[2:]
        if len(x) < h:
            x = '0'*(h-len(x))+x

        ones = x.count('1')
        if ones not in bits_active.keys():
            bits_active[ones] = []

        bits_active[ones].append(x)

    return bits_active

def good(grid,h,w,row_perm,col_perm,k):
    temp = copy.deepcopy(grid)
    for i in range(h):
        if row_perm[i] == '1':
            for j in range(w):
                temp[i][j] = 'r'

    for j in range(w):
        if col_perm[j] == '1':
            for i in range(h):
                temp[i][j] = 'r'

    count = 0
    for i in range(h):
        for j in range(w):
            if temp[i][j] == '#':
                count += 1

    if count == k:
        return True

    return False

def main():
    h,w,k = map(int,input().split())
    grid = []
    for i in range(h):
        grid.append(list(input()))

    bits_active_rows = find(h)
    bits_active_cols = find(w)
    total = 0
        
    for rows_chosen in range(h+1):
        for cols_chosen in range(w+1):
            for row_perm in bits_active_rows[rows_chosen]:
                for col_perm in bits_active_cols[cols_chosen]:
                    if good(grid,h,w,row_perm,col_perm,k):
                        total += 1

    print(total)

main()


Measured memory_bytes: 72064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

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

	long long int a[5], m = 0;
	for (int i = 0; i < 5; i++){
		cin >> a[i];
		m = max(m, (n - 1) / a[i]);
	}

	cout << m + 5 << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split(' '))
P=list(map(int,input().split(' ')))

p1 = sum([x <= A for x in P])
p2 = sum([A+1 <= x <= B for x in P])
p3 = sum([B+1 <= x for x in P])

print(min(p1,p2,p3))


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    int n = s.size() + 1;
    vector<int> v(n, 0);

    int cnt1 = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == '<') {
            v[i] = cnt1;
            cnt1++;
        } else {
            v[i] = cnt1;
            cnt1 = 0;
        }
    }

    int cnt2 = 0;
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == '>') {
            cnt2++;
            v[i] = max(v[i], cnt2);
        } else {
            cnt2 = 0;
            v[i] = max(v[i], cnt2);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += v[i];
    }
    
    cout << ans << endl;;
    return 0;
}



Measured memory_bytes: 4740
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m,v[200005],c[200005];
	long long dp[200005] = {}, memo[200005] = {},res=0,cou=0;
	string str, str2;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> v[i];
		res += abs(v[i]);
		if (v[i] < 0) {
			cou++;
		}
		else {
			v[i] = -v[i];
		}
	}
	sort(v, v + n);
	if (cou % 2 == 1) {
		res += 2 * v[n - 1];
	}

	cout << res;
}


Measured memory_bytes: 1024
//
#include<iostream>
using namespace std;
int m,d;
int main()
{
	cin>>m>>d;
	int shi,ge;
	ge=d%10;
	d/=10;
	shi=d%10;
	int tot=0;
	for(int k=1;k<=m;k++)
	for(int j=2;j<shi;j++)
	for(int i=2;i<=9;i++)
	{
		if(i*j==k) tot++;
	}
	for(int k=1;k<=m;k++)
	{
		for(int i=2;i<=ge;i++)
		{
			if(i*shi==k) tot++;
			
		}
	}
	cout<<tot;
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v(i) (n - i + 1)
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 300010;

struct P{
    LL x, y;
}st[N];
P m(P a, P b) { return (P){a.x - b.x, a.y - b.y};}
LL cro(P a, P b) { return a.x * b.y - a.y * b.x;}

LL f0[N], s0[N], sf0[N], f1[N], s1[N], sf1[N], t[N], tmp[N];

int n, x[N], top;

void solve(int l, int r)
{
	if (l == r) return;
	int mid = (l + r) >> 1;
	
//	printf("%d %d : \n", l, r);
	
	top = 0;
	for (LL i = l; i <= mid; i ++) {
		P a = (P){2 * i, sf0[i] + 1ll * i * i - i + s0[i]};
		while (top >= 2 && cro(m(a, st[top]), m(st[top], st[top - 1])) <= 0) top --;
		st[++ top] = a;
	}
	for (LL i = mid + 1; i <= min(r, n); i ++) {
		while (top >= 2 && st[top].y - st[top].x * i <= st[top - 1].y - st[top - 1].x * i) top --;
		tmp[i] = st[top].y - st[top].x * i - s0[i] + i + i * i + sf1[i + 1];
	}
	for (LL i = min(r, n); i >= mid + 1; i --) {
		if (i != min(r, n)) tmp[i] = max(tmp[i], tmp[i + 1]);
		t[i] = max(t[i], tmp[i]);
	}
	
	top = 0;
	for (LL i = r; i >= mid + 1; i --) {
		P a = (P){2 * v(i), sf1[i] + v(i) * v(i) - v(i) + s1[i]};
		while (top >= 2 && cro(m(a, st[top]), m(st[top], st[top - 1])) <= 0) top --;
		st[++ top] = a;
	}
	for (LL i = mid; i >= max(l, 1); i --) {
		while (top >= 2 && st[top].y - st[top].x * v(i) <= st[top - 1].y - st[top - 1].x * v(i)) top --;
		tmp[i] = st[top].y - st[top].x * v(i) - s1[i] + v(i) + v(i) * v(i) + sf0[i - 1];
	}
	for (LL i = max(l, 1); i <= mid; i ++) {
		if (i != max(l, 1)) tmp[i] = max(tmp[i], tmp[i - 1]);
		t[i] = max(t[i], tmp[i]);
	}
	
	solve(l, mid); solve(mid + 1, r); 
}

void dp(LL *s, LL *f, LL *sf)
{
	Rep(i, n) s[i] = s[i - 1] + x[i] * 2;
	top = 0, st[++ top] = (P){0, 0};
	for (LL i = 1; i <= n; i ++) {
		while (top >= 2 && st[top].y - st[top].x * i <= st[top - 1].y - st[top - 1].x * i) top --;
		f[i] = st[top].y - st[top].x * i - s[i] + i + i * i, sf[i] = max(sf[i - 1], f[i]);
		P a = (P){2 * i, sf[i] + i * i - i + s[i]};
		while (top >= 2 && cro(m(a, st[top]), m(st[top], st[top - 1])) <= 0) top --;
		st[++ top] = a;
	}
}

int main()
{
   // freopen("f.in", "r", stdin);
//	freopen("f.out", "w", stdout);
	scanf("%d", &n);
	Rep(i, n) scanf("%d", &x[i]);
	
	dp(s0, f0, sf0);
	reverse(x + 1, x + 1 + n);
	dp(s1, f1, sf1);
	reverse(s1 + 1, s1 + 1 + n);
	reverse(f1 + 1, f1 + 1 + n);
	reverse(sf1 + 1, sf1 + 1 + n);
	reverse(x + 1, x + 1 + n);
	Rep(i, n) t[i] = -1e18;
	
	solve(0, n + 1);
	
	int m;
	scanf("%d", &m);
	Rep(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%lld\n", max(sf0[a - 1] + sf1[a + 1], t[a] + x[a] * 2 - b * 2) / 2);
	}
	
	return 0;
}
/*
5
1 1 4 1 1
2
3 2
3 10
*/

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> v(h + 2, vector<char>(w + 2, '#'));
  for (int i = 1; i < h + 1; i ++) {
    for (int j = 1; j < w + 1; j ++) {
      cin >> v[i][j];
    }
  }
  for (int i = 0; i < h + 2; i ++) {
    for (int j = 0; j < w + 2; j ++) {
      cout << v[i][j];
    }
    cout << endl;
  }
}

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

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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;

  if(K >= A && K <= A + B) {
    cout << 0 << ' ' << B - (K - A) <<endl;
  } else if(K >= A && K > A + B) {
    cout << 0 << ' ' << 0 <<endl;
  } else {
    cout << A - K << ' ' << B << endl;
  }
  
  return 0;
}


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if(n<1200) cout<<"ABC";
    else if(n<2800) cout<<"ARC";
    else cout<<"AGC";
    return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<P> E;
    if (N % 2) {
        for (int i = 1; i <= N; ++i) {
            for (int j = i + 1; j <= N; ++j) {
                if (i + j == N) continue;
                E.push_back( P(i, j) );
            }
        }
    } else {
        for (int i = 1; i <= N; ++i) {
            for (int j = i + 1; j <= N; ++j) {
                if (i + j == N + 1) continue;
                E.push_back( P(i, j) );
            }
        }
    }

    cout << E.size() << endl;
    for (auto p : E) {
        printf("%d %d\n", p.first, p.second);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    int d = n%10;
    if(d==3) puts("bon");
    else if(d==0 || d==1 || d==6 || d==8) puts("pon");
    else puts("hon");
}

Measured memory_bytes: 3684
package main

import (
	"bufio"
	"fmt"
	"os"
		"strconv"
	)

type TupleInt struct {
	first  int
	second int
}

func main() {
	numList := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&numList[i])
	}

	modList := make([]int, 5)
	for i := 0; i < 5; i++ {
		modList[i] = numList[i] % 10
	}
	min := modList[0]
	for _, i := range modList {
		if i < min && 0 < i {
			min = i
		}
	}

	total := 0
	c := 1
	for k:=0; k<5; k++ {
		if modList[k] == 0 {
			total = total + numList[k]
		} else if modList[k] == min && c > 0{
			total = total + numList[k]
			c--
		} else {
			total = total + numList[k] - modList[k] + 10
		}
	}
	fmt.Println(total)


}



func listIntMin(a []int) int {
	min := a[0]
	for _, i := range a {
		if i < min && 0 < i {
			min = i
		}
	}
	return min
}

func Max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type SortInterFace []TupleInt

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].first < s[j].first
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let x: usize = sc.read();
    let y = x / 100;
    let m = x % 100;
    let yymm = 1 <= m && m <= 12;
    let mmyy = 1 <= y && y <= 12;
    if yymm && mmyy {
        println!("AMBIGUOUS");
    } else if yymm {
        println!("YYMM");
    } else if mmyy {
        println!("MMYY");
    } else {
        println!("NA");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
int n;
inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    quickread();
    cin >> n;
    int re = n % 1000;
    int ret = (re == 0) ? 0 : (1000 - re);
    cout << ret << endl;
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

ll C[100005], A[100005];

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

	ll n, i, j, k, x, y, z;
	cin >> n >> k;
	for (i = 1; i <= n; ++i) cin >> A[i];
	A[0] = -MOD;
	for (i = 2; i <= n; ++i) {
		C[i] = 1e18;
		for (j = 1; j <= k; ++j) {
			if (i-j <= 0) continue;
			C[i] = min(C[i], C[i-j] + abs(A[i] - A[i-j]));
		}
	}
	cout << C[n] << endl;

	return 0;
}


Measured memory_bytes: 1792
n = gets.to_i
x = gets.split.map{|i|[i.to_i,0]}
a = []
b = []
n.times do |i|
    x[i][1] = i+1
end
x.sort!
n.times do |i|
    (x[i][1]-1).times do
        a << x[i][1]
    end
end
ans = []
j = 0
(n*n).times do |i|
    if j < n && x[j][0] == i+1
        if (a.include?(x[j][1]))
            puts "No"
            exit
        end
        ans << x[j][1]
        (n-x[j][1]).times do
            b << x[j][1]
        end
        j += 1
    else
        if !a.empty?
            ans << a.shift
        elsif !b.empty?
            ans << b.pop
        else
            puts "No"
            exit
        end
    end
end
puts "Yes",ans.join(" ")

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll T0, T1;
    cin >> T0 >> T1;
    pll A, B;
    cin >> A.first >> A.second;
    cin >> B.first >> B.second;

    ll fa = A.first * T0, fb = B.first * T0;
    ll sa = fa + A.second * T1, sb = fb + B.second * T1;

    if (sa == sb) {
        cout << "infinity" << endl;
        return 0;
    }

    if ((fa < fb && sa < sb) || (fa > fb && sa > sb)) {
        cout << 0 << endl;
        return 0;
    }

    ll d = abs(sa - sb);
    ll ans = (abs(fa - fb) / d) * 2LL;
    if (abs(fa - fb) % d > 0)
        ans++;
    cout << ans << endl;
    return 0;
}

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

typedef long double     ld;
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;

const int inf = 0x3f3f3f3f;
const ll  INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e)    for(int i=b; i<=e; i++)
#define FORD(i, b, e)   for(int i=b; i>=e; i--)
#define SIZE(x)         ((int)(x).size())
#define pb              push_back
#define st              first
#define nd              second
#define all(a)          begin(a), end(a)
#define watch(x)        cerr << (#x) << " is " << (x) << '\n';

int n,q,a,b;

vi G[200010];

ll res[200010];
bool vis[200010];

void dfs(int u){
    vis[u]=1;

    for(int v : G[u]){
        if(!vis[v]){
            res[v]+=res[u];
            dfs(v);
        }
    }
}


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

    cin>>n>>q;

    FOR(i,1,n-1){
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }

    FOR(i,1,q){
        cin>>a>>b;
        res[a]+=b;
    }

    dfs(1);
    FOR(i,1,n) cout<<res[i]<<" ";

    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int Max=0x3f3f3f3f;
ll dfs(ll n)
{
    if(n==1)return 1;
    return 2*dfs(n/2)+1;
}
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll cnt=dfs(n);
        printf("%lld\n",cnt);
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
L = []
for h in range(H):
  L.append(input())
  
X = [0]*W
Y = [0]*H

for h in range(H):
  for w in range(W):
    if L[h][w]=="#":
      X[w]=1
      Y[h]=1
      
for h in range(H):
  if Y[h]==1:
    for w in range(W):
      if X[w]==1:
        print(L[h][w] , end="")
    print()
        

Measured memory_bytes: 9152
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int x[] = new int[n];
        int buf[] = new int[n];
        for (int ct = 0; ct < x.length; ct++) {
            x[ct] = sc.nextInt();
            buf[ct] = x[ct];
        }
        
        Arrays.sort(buf);
 
        if (buf[n / 2-1] < buf[n / 2]) {
            for (int oki : x) {
                if (oki <= buf[n / 2-1]) {
                    System.out.println(buf[n / 2 ]);
                } else {
                    System.out.println(buf[n / 2-1]);
                }
            }
        } else {
            for (int ct = 0; ct < x.length; ct++) {
                System.out.println(buf[n / 2-1]);
            }
        }
    }
}

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

int main(){
    
    uint N, M; cin >> N >> M;
    vector<uint> vType(M, 0);
    
    for(uint ni=0; ni<N; ++ni){
        uint K; cin >> K;
        for(uint ki=0; ki<K; ++ki){
            int A; cin >> A; --A;
            ++vType[ A ];
        }
    }
    
    int numT=0;
    for(uint i=0; i<vType.size(); ++i){
        if(vType[i]==N){ ++numT; }
    }
    
    cout << numT << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define inf 1000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    int windowLength, curtainLength;
    cin >> windowLength >> curtainLength ;
    if(windowLength > curtainLength * 2)
        cout << windowLength - curtainLength * 2 << endl;
    else
        cout << 0 << endl;
}




Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
        int i;
		
      	if(n.length() >= 3){
          StringBuilder b;
          b = new StringBuilder(n);
          n = b.reverse().toString();
          
        }
      	
		
        System.out.println(n);

      	
 
    }
}

Measured memory_bytes: 35708
# include <iostream>
# include <iomanip>

int main() {
	int H, W;
   	while(true){
   		std::cin >> H >> W;
   		if(H == 0 && W == 0)
   			break;
   		for(int y = 0; y < H; y++){
   			for(int x = 0; x < W; x++){
   				std::cout << "#" ;
   			}
   			std::cout << std::endl;
   		}
   		std::cout << std::endl;
   	}
   	return 0;
}

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

using namespace std;

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

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  int ret = 114514;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    int sum = 0;
    while(x % 2 == 0) {
      x /= 2;
      ++sum;
    }
    ret = min(ret, sum);
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
vector<vector<int>> a(n,vector<int>(2,0));
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < 2; j++)
    {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
  ans += a[i][1] - a[i][0] + 1;
  }
  cout << ans << endl;
}


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

int main(void){
    int a,b;
    int result;
    vector<int> vresult;
    string op;

    while(1){
        cin >> a;
        cin >> op;
        cin >> b;

        if(op == "+")
          result = a+b;
        else if(op == "-")
          result = a-b;
        else if(op == "*")
          result = a*b;
        else if(op == "/")
          result = a/b;
        else if(op == "?")
            break;
        vresult.push_back(result);
    }
    for(auto x : vresult)
        cout << x << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n,p,s=1,ans;
    cin>>x>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    for(int i=0;i<1000;i++){
    	for(int j=0;j<n;j++){
        	if(x-i==a[j]) s=0;
        }
        if(s==1){
        	cout<<x-i;
            return 0;
        }
        s=1;
        for(int j=0;j<n;j++){
        	if(x+i==a[j]) s=0;
        }
        if(s==1){
        	cout<<x+i;
            return 0;
        }
        s=1;
    }
}
 


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

using namespace std;

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

    int a =1;

    if(s[2]!=s[3]){a=0;}
    if(s[4]!=s[5]){a=0;}

    if(a==0){cout << "No"<< endl;}
    if(a==1){cout << "Yes"<< endl;}

}

Measured memory_bytes: 888
def ll():
    return list(map(int,input().split()))
def l():
    return int(input())
n = l()
w = ll()
x=0
l=[]
for i in range(n):
    x += w[i]
    y = sum(w)-x
    l.append(abs(x-y))
l = sorted(l)
print(l[0])


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

int main() {
    char b;
    cin >> b;
    char out;
    if (b == 'A') {
        out = 'T';
    }
    else if (b == 'C') {
        out = 'G';
    }
    else if (b == 'G') {
        out = 'C';
    }
    else {
        out = 'A';
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


di = []

for i in range(5):
    di.append(int(input()))

su = []
for i in range(5):
    su.append(di[i]%10)

m = 100000
for i in range(5):
    if m > su[i] and su[i] != 0:
        m = su[i]

last = 0
for i in range(5):
    if su[i] == m :
        last = i

time = 0
for i in range(5):
    if i != last:
        time += ((di[i]//10))*10
        if di[i] % 10 != 0:
            time += 10
    else:
        time += di[i]

print(time)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    vector<int> a(N);
    vector<int> b(N);
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];

    ll ans = 0;

    REPR(digit,29){//逆順にすることでa,bの配列を再利用できる！！
        int beki = 1<<digit;
        REP(i,N){
            a[i] %= (beki<<1);
            b[i] %= (beki<<1);
        }
        sort(ALL(b));
        ll num = 0;
        REP(i,N){
            num += lower_bound(ALL(b), 2*beki - a[i])
                - lower_bound(ALL(b), beki - a[i]);

            num += lower_bound(ALL(b), 4*beki - a[i])
                - lower_bound(ALL(b), 3*beki - a[i]);
        }

        if(num%2==1) ans += beki;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> countCoins = new ArrayList<>();

            for (String s : input) {
                countCoins.add(Integer.parseInt(s));
            }

            sortNatualOrder(countCoins);

            int countOfCoinA = countCoins.get(0);
            int countOfCoinB = countCoins.get(1);

            int result = countOfCoinA + countOfCoinB;
            if (result < countOfCoinB * 2 - 1) {
                result = countOfCoinB * 2 - 1;
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void sortNatualOrder(List<Integer> intList) {
        int tmp = intList.get(1);
        if (intList.get(0) > intList.get(1)) {
            intList.set(1, intList.get(0));
            intList.set(0, tmp);
        }
    }
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	int min = 100000000;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (min > a[i]) cnt++;
		min = std::min(min, a[i]);
	}
	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    string s;
    int ac=0,tle=0,wa=0,re=0;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="TLE")tle++;
        else if(s=="WA")wa++;
        else if(s=="RE")re++;
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
    return 0;
}


Measured memory_bytes: 3724
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int H,W,h,w;
cin>>H>>W>>h>>w;
cout<<(H-h)*(W-w)<<endl;

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Node {
	int id, key;
	Node parent, left, right;



	public Node(int id, int key) {
		super();
		this.id = id;
		this.key = key;
	}



	@Override
	public String toString() {
		String parentKey = parent == null ? "" :
			"parent key = " + Integer.toString(parent.key) + ", ";
		String leftKey = left == null ? "" :
			"left key = " + Integer.toString(left.key) + ", ";
		String rightKey = right == null ? "" :
			"right key = " + Integer.toString(right.key) + ", ";

		return "node " + id + ": key = " + key + ", " + parentKey + leftKey + rightKey;
	}
}

public class Main {
	public static Node binaryTree(Node[] btree, int p_id, int c_id) {
		if (p_id != -1) {
			btree[c_id - 1].parent = btree[p_id - 1];
		}

		if (c_id * 2 <= btree.length) {
			btree[c_id - 1].left = binaryTree(btree, c_id, c_id * 2);
		}
		if (c_id * 2 + 1 <= btree.length) {
			btree[c_id - 1].right = binaryTree(btree, c_id, c_id * 2 + 1);
		}

		return btree[c_id - 1];
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		Node[] btree = new Node[h];
		for (int i = 0; i < h; i++) {
			btree[i] = new Node(i + 1, sc.nextInt());
		}
		binaryTree(btree, -1, 1);
		for (int i = 0; i < h; i++) {
			System.out.println(btree[i]);
		}
	}
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool a[31]={1};
    for(int i=1;i<30;i++){
        a[i]=0;
    }
    int q;
    for(int i=0;i<28;i++){
        cin >> q;
        a[q]=1;
    }
    for(int i=0;i<31;i++){
        if(a[i]==0){
            cout << i << endl;
        }
    }

    return 0;
}


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

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

using namespace std;

const int MAX_N = 1000100;
const int IINF = INT_MAX;

int H,W,N;
char opr[MAX_N];
char field[1010][1010];
int dx[] = {+0,+1,+0,-1}; // 上 右 下 左
int dy[] = {-1,+0,+1,+0};
int G[MAX_N][4];

void init(){
  deque<int> deq[4]; 
  G[0][0] = 0;
  REP(i,1,4) deq[i].push_back(0);
  int dir = 0;

  REP(i,1,N+1){
    if( opr[i] == 'L' ) ( dir += 3 ) %= 4;
    else                ( dir += 1 ) %= 4;
    G[i][dir] = i;
    rep(j,4) if( j != dir ) deq[j].push_back(i);
    while( !deq[dir].empty() ) {
      G[deq[dir].front()][dir] = min(G[deq[dir].front()][dir],i);
      deq[dir].pop_front();
    }
  }
}

struct Data {
  int cur,dir;
};

int mindist[1010][1010][4],sp,ep;
inline bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

void compute(){
  rep(i,H) rep(j,W) rep(k,4) mindist[i][j][k] = IINF;
  mindist[sp/W][sp%W][0] = 0;
  deque<Data> deq;
  deq.push_back((Data){sp,0});
  while( !deq.empty() ){
    Data data = deq.front(); deq.pop_front();
    if( data.cur == ep ) { puts("Yes"); return; }
    rep(ndir,4){
      if( ndir == data.dir ) {
        int nx = data.cur % W + dx[ndir], ny = data.cur / W + dy[ndir];
        if( !isValid(nx,ny) ) continue;
        if( field[ny][nx] == '#' ) continue;
        if( mindist[ny][nx][ndir] > mindist[data.cur/W][data.cur%W][data.dir] ) {
          mindist[ny][nx][ndir] = mindist[data.cur/W][data.cur%W][data.dir];
          deq.push_back((Data){nx+ny*W,ndir});
        }
      } else {
        if( mindist[data.cur/W][data.cur%W][ndir] > G[mindist[data.cur/W][data.cur%W][data.dir]][ndir] ) {
          mindist[data.cur/W][data.cur%W][ndir] = G[mindist[data.cur/W][data.cur%W][data.dir]][ndir];
          deq.push_back((Data){data.cur,ndir});
        }
      }
    }
  }
  puts("No");
}

char debug[4] = {'U','R','D','L'};

int main(){
  while( cin >> H >> W >> N, H|W|N ){
    opr[0] = '*';
    REP(i,1,N+1) cin >> opr[i];
    rep(i,H) rep(j,W) {
      cin >> field[i][j];
      if( field[i][j] == 'S' ) { field[i][j] = '.'; sp = j + i * W; }
      if( field[i][j] == 'G' ) { field[i][j] = '.'; ep = j + i * W; }
    }
    rep(i,N+1) rep(j,4) G[i][j] = IINF;
    init();
    /*
    puts("---");
    rep(i,N+1) {
      cout << i << "-th" << endl;
      rep(j,4) {
        cout << debug[j] << " : " << ((G[i][j]==IINF)?-1:G[i][j]) << ", ";
      } cout << endl;
    }
    */
    compute();
  }
  return 0;
}

Measured memory_bytes: 19904
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




vector<ll>lst;
map<ll,ll>cnt;

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

  rep(i,N){
    ll inp; cin >> inp;
    lst.pb(inp);
    cnt[inp] = !cnt[inp];
  }

  rmsame(lst);

  ll ans = 0;
  rep(i,lst.size())
    if(cnt[lst[i]]) ans ++;
  cout << ans << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 7284
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





/* Segment Tree */
class SegmentTree
{
private:
    long long n;    // 配列の要素数
    long long s;    // 配列を初期化するときの値
    vector<long long> data;     // セグメントツリーを持つ配列
public:
    SegmentTree(long long m, long long t);   // mは配列の要素数、tは配列を初期化するときの値
    long long operation(long long t1, long long t2); // 二項演算
    void update(long long k, long long a);  // k番目(0-indexed)の値をaに変更
    long long query(long long a, long long b);   // [a, b) の値を求める。外から呼ぶときはこっち
    long long ans(long long a, long long b, long long k, long long l, long long r);   // [a, b) の値を求める。
};

SegmentTree::SegmentTree(long long m, long long t){
    n = 1;
    
    while(n < m) n *= 2;
    
    for(long long i = 0; i < 2 * n - 1; i++){
        data.push_back(t);
    }
    
    s = t;
}

long long SegmentTree::operation(long long t1, long long t2){
    if(t1 == t2) return t1;
    return max(t1, t2) - min(t1, t2);
}

void SegmentTree::update(long long k, long long a){
    k += n - 1;
    data[k] = a;
    
    while(k > 0){
        k = (k - 1) / 2;
        data[k] = operation(data[k * 2 + 1], data[k * 2 + 2]);
    }
}

long long SegmentTree::query(long long a, long long b){
    return ans(a, b, 0, 0, n);
}

long long SegmentTree::ans(long long a, long long b, long long k, long long l, long long r){
    if(r <= a || b <= l) return s;
    if(a <= l && r <= b){
        return data[k];
    }
    else{
        long long vl = ans(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = ans(a, b, k * 2 + 2, (l + r) / 2, r);
        
        return operation(vl, vr);
    }
}


int main() {
    ll n;
    cin >> n;
    SegmentTree tree(1 << n, 0);
    REP(i, 1 << n){
        ll a;
        cin >> a;
        tree.update(i, a);
    }
    cout << tree.query(0, 1 << n) << endl;
}


Measured memory_bytes: 6512
package main

import (
	"fmt"
	"math"
)

func main() {
	var h int
	fmt.Scanf("%d", &h)

	var a int = 1
	for 1 < h {
		a++
		h = h / 2
	}

	var result int
	for i := 0; i < a; i++ {
		result += int(math.Pow(2, float64(i)))
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    vector<double> p(n);
    FOR(i, 0, n)cin >> p[i];

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1;
    FOR(i, 0, n)eFOR(j, 0, i + 1) {
        if (j)dp[i + 1][j] += dp[i][j - 1] * p[i];
        dp[i + 1][j] += dp[i][j] * (1 - p[i]);
    }

    double ans = 0;
    eFOR(i, n / 2 + 1, n)ans += dp[n][i];
    cout << ans << "\n";
}


Measured memory_bytes: 70784
def travel(arr):

    current_loc = (0, 0)
    current_time = 0

    for dest in arr:

        next_loc = (dest[1], dest[2])

        distance = abs(next_loc[0] - current_loc[0]) + abs(next_loc[1] - current_loc[1])

        if distance > dest[0] - current_time:
            return 'No'

        elif (dest[0] - current_time - distance)%2 != 0:
            return 'No'

    return 'Yes'


n = int(input())
arr = []
for _ in range(n):
    arr.append(list(map(int, input().split())))

print(travel(arr))

Measured memory_bytes: 27380
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> t(n);
  long long int all=0;
  for(int i=0; i<n; i++){
    cin>>t.at(i);
    all+=t.at(i);
  }
  int m;
  cin>>m;
  vector<int> p(m);
  vector<int> x(m);
  for(int i=0; i<m; i++){
    cin>>p.at(i);
    cin>>x.at(i);
  }


  for(int i=0; i<m; i++){
    long long int ans=all;
    ans-=t.at(p.at(i)-1);
    ans+=x.at(i);
    cout<<ans<<endl;
  }
}

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


void solve(long long K){
    int a[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
#include <cstdint>
#include<tuple>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;

int main(void){
  int n,k;
  cin>>n>>k;
  int ans=0;
  rep0(i,n){
    int h;
    cin>>h;
    if(h>=k) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256