akhauriyash/Code-Regression huggingface dataset:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
N=int(input())
A=list(map(int,input().split()))
A=[[A[i],i] for i in range(N)]
A.sort(reverse=True)
dp=[[0 for i in range(N+1)] for _ in range(N+1)]
for n in range(N):
    a,p=A[n]
    for x in range(1,n+2):
        y=n+1-x
        dp[x][y]=max(dp[x][y],dp[x-1][y]+round(abs(x-1 - p))*a)
    for y in range(1,n+2):
        x=n+1-y
        dp[x][y]=max(dp[x][y],dp[x][y-1]+round(abs(N-y - p))*a)
    #print(dp)
print(max([dp[x][y] for x in range(N+1) for y in range(N+1) if x+y==N]))


Measured memory_bytes: 112116
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

//上下左右
int dx[] = { 0,0,-1,1 };
int dy[] = { 1,-1,0,0 };

int main() {
    int H, W, cnt = 0;
    cin >> H >> W;
    vector<vector<char>>s(H + 2, vector<char>(W + 2, '.'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (s[i][j] == '#') {
                bool ok = false;
                for (int k = 0; k < 4; k++) {
                    if (s[i + dx[k]][j + dy[k]] == '#') {
                        ok = true;
                        break;
                    }
                }
                if (!ok) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main(void)
{
	int s_length, q_length, i, z = 0, x, j;
	int *s, *q;
	scanf("%d", &s_length);
	s = (int *)malloc(sizeof(int) * s_length);
	
	for(i = 0;i < s_length;i++){
		scanf("%d", &s[i]);
	}
	
	scanf("%d", &q_length);
	
	q = (int *)malloc(sizeof(int) * q_length);
	
	for(x = 0;x < q_length;x++){
		scanf("%d", &q[x]);
	}
		
	for(i = 0;i < q_length;i++){
		for(j = 0;j < s_length;j++){
			if(q[i] == s[j]){
				z++;
				break;
			}
		}
		
	}
	
	printf("%d\n", z);
			
	return 0;
	
	
}

Measured memory_bytes: 636
n=int(input())
a_num=0
b_num=0
set_num=0
ans=0
for i in range(n):
    s=list(input())
    for j in range(len(s)-1):
        if s[j]+s[j+1]=="AB":
            ans+=1
    if s[0]=="B" and s[-1]=="A":
        set_num+=1
    elif s[0]=="B":
        b_num+=1
    elif s[-1]=="A":
        a_num+=1
if set_num==0:
    print(ans+min(a_num,b_num))
else:
    ans+=set_num-1
    if not(a_num==0 and b_num==0):
        a_num+=1
        b_num+=1
    print(ans+min(a_num,b_num))

Measured memory_bytes: 50408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        scanner.close();
        int c = a*b;
        if (c%2 == 1){
            System.out.println("Odd");
        }
        else if(c%2 == 0){
            System.out.println("Even");
        }
        
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;


int main(void)
{
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];

	sort(a, a + 4);
	if (a[0] == a[1] && a[2] == a[3])cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	int n,m;
	cin>>n>>m;
	if(n%2==1){
		for(int i=1;i<=m;i++){
			cout<<i<<" "<<2*m+2-i<<endl;
		}
	}
	else{
		for(int i=1;i<=(m+1)/2;i++){
			cout<<i<<" "<<m+2-i<<endl;
		}
		for(int i=1;i<=m/2;i++){
			cout<<m+1+i<<" "<<2*m+2-i<<endl;
		}
	}


return 0;
}



Measured memory_bytes: 3636
MOD = 10 ** 9 + 7


def ex_euclid(a,b,c,d):
    if (b == 1) : return d
    x = a // b
    y = a % b
    return ex_euclid(b,y,d,(c[0]-x*d[0],c[1]-x*d[1]))
    

def mod_inv(a,p):
    x = ex_euclid(p,a,(1,0),(0,1))
    return x[1] % p

n = int(input())
visited = [-1 for i in range(n+1)]

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

for i in range(n+1):
    if(visited[a[i]] == -1):visited[a[i]] = i
    else : 
        x = visited[a[i]]
        y = i
        break

m = x + (n-y)

#n+1Ck - mC(k-1)

nc = n+1
mc = 1

print(nc-mc)

for i in range(2,n+2):
    nc = (nc * (n+2-i)) % MOD
    nc = (nc * mod_inv(i,MOD)) % MOD
    if (i-1 <= m):
        mc = (mc * (m+2-i)) % MOD
        mc = (mc * mod_inv(i-1,MOD)) % MOD
        print((nc - mc) % MOD)
    else:
        print(nc)

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

int main()
{
  string s; cin >> s;
  int n = s.size();
  bool f = false;
  for (int i=1; i<n; i++) {
    if (s[i] !='9') f = true;
  }
  ll ans = (s[0]-'0') + (n-1)*9;
  if (f) ans--;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int n;
  cin>>n;
  vector<int>a(n-1);
  for(int i=0;i<n-1;i++){
    cin>>a[i];
  }
  map<int,int>mp;
  for(int i=1;i<=n;i++)mp[i]=0;
  set<int>st;
  for(int i=0;i<n-1;i++){
    if(st.count(a[i])){
      mp[a[i]]++;
    }else {
      st.insert(a[i]);
      mp[a[i]]=1;
    }
  }
  for(int i=1;i<=n;i++){
    cout<<mp[i]<<endl;
  }
}

Measured memory_bytes: 22796
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(H, W, grid):
    res_x = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#':
                x += 1
                continue
            rx = x
            while rx < W and grid[y][rx] != '#':
                rx += 1
            for xx in range(x, rx):
                res_x[y][xx] = rx-x
            x = rx
        x = 0
        y += 1

    res_y = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#' or res_y[y][x] != 0:
                x += 1
                continue
            dy = y
            while dy < H and grid[dy][x] != '#':
                dy += 1
            for yy in range(y, dy):
                if res_y[yy][x] == 0:
                    res_y[yy][x] = dy-y
            x += 1
        x = 0
        y += 1

    ans = 0
    for y in range(H):
        for x in range(W):
            t = res_x[y][x] + res_y[y][x] - 1
            if t > ans:
                ans = t
    return ans


def main(args):
    H, W = map(int, input().split())
    grid = [input() for _ in range(H)]
    ans = solve(H, W, grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 126936
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define inf         1000000007
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
using namespace std;
//using namespace chrono;
int main()
{
	FastIO;
	string s,u;
	ll a, i,t, j, k,b, n;
	vector<ll>v;
	cin >> n;
	f(i, n)
	{
		cin >> a;
		v.push_back(a);
	}
	sort(all(v));
	cout << v[(n / 2)] - v[(n/2)-1] << endl;
	return 0;
}

Measured memory_bytes: 1400
P = 2019
S=input()
N = len(S)
ans=0

rem = [0]*P
mod = 0
ten = 1
rem[mod]=1
for i in range(N):
    mod=(mod+int(S[N-i-1])*ten)%P
    ten=ten*10%P
    rem[mod]+=1
for j in rem:
    ans+=(j*(j-1))//2
print(ans)


Measured memory_bytes: 9220
#include <cstdio>

int read() {
    int x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') ch = getchar();
    while (ch >= '0' && ch <= '9') {
        x = x + ch - '0';
        x %= 9;
        ch = getchar();
    }
    return x;
}

int main() {
    int tmp = read();
    if (!tmp) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1532
#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-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    for (int i = K; i < N; ++i) {
        if (A[i-K] < A[i]) puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 4040
N,M=map(int,input().split())
a=[[i]+list(map(int,input().split())) for i in range(M)]
a.sort(key=lambda x:(x[1],x[2]))

j=0
for i in range(M):
    if j!=a[i][1]:
        j=a[i][1]
        k=1
    s=format(a[i][1],'0>6') + format(k,'0>6')
    a[i].append(s)
    k+=1

a.sort()
for i in range(M):
    print(a[i][3])

Measured memory_bytes: 34864
import kotlin.math.*  
fun main(args : Array<String>){
    var k: Long = readLine()!!.toLong()
    
    var zandaka:Long = 100
    for (i in 1..k){
        zandaka = zandaka + (floor(zandaka.toDouble() * 0.01)).toLong()
        if (zandaka >= k){
            print(i.toString())
            break
        }
    }
}

Measured memory_bytes: 34408
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m,q;
  cin >> n >> m >> q;
  vector<int> l(q), r(q), diff(q), v(q);
  rep(i,q){
    cin >> l[i]; --l[i];
    cin >> r[i]; --r[i];
    cin >> diff[i];
    cin >> v[i];
  }

  int ans = 0;
  vector<int> a(n,1);
  while(true){
    int res = 0;
    rep(qi,q){
      if(a[r[qi]]-a[l[qi]]==diff[qi]) res += v[qi];
    }
    ans = max(ans,res);

    bool ok = true;
    vector<int> is;
    for(int i = n-1; i>=0; --i){
      if(a[i]<m){
        a[i]++;
        for(int ii:is) a[ii] = a[i];
        break;
      }else if(i==0){
        ok = false;
        break;
      }else{
        is.push_back(i);
      }
    }
    if(!ok) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <set>
#define BU_MAX 51
#define BO_MAX 51
using namespace std;

struct Bunny{
  int boat;
  int bads[ BU_MAX ];
  int badsCounter;
};

int main () {
  int n, k;
  int bb[ BO_MAX ][ BU_MAX ];
  int m[ BO_MAX ];
  int counter;
  set<int> owata;
  Bunny bunny[ BU_MAX ];

  cin >> n >> k;
  for( int i = 0; i < n; i++ ) {
    bunny[ i ].badsCounter = 0;
  }
  for( int i = 0; i < k; i++ ) {
    cin >> m[ i ];
    for( int j = 0; j < m[ i ]; j++ ) {
      cin >> bb[ i ][ j ];
      bunny[ bb[ i ][ j ] ].boat = i;
    }
  }

  int r;
  cin >> r;
  for( int i = 0; i < r; i++ ) {
    int p, q;
    cin >> p >> q;
    bunny[ p ].bads[ bunny[ p ].badsCounter++ ] = q;
    bunny[ q ].bads[ bunny[ q ].badsCounter++ ] = p;

    if( bunny[ p ].boat == bunny[ q ].boat ) {
      if( owata.find( p ) == owata.end() ){
        counter++;
        owata.insert( p );
      }
      if( owata.find( q ) == owata.end() ){
        counter++;
        owata.insert( q );
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(int T)
{
    int n;
    cin >> n;
    int cnt=0,ans=0;
    for(int i=1;i<=n;i++)
    {
        int u,v;
        cin >> u >> v;
        if(u==v)
        {
            cnt++;
            ans = max(ans,cnt);
        }
        else
        {
            ans = max(ans,cnt);
            cnt=0;
        }
        
    }
    if(ans>=3)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}



signed main()
{
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3620
SIZE=5*10**5+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCr mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(n,r): # nHr mod MOD の計算
    return choose(n+r-1,r)

def narabekae(n,r): #nPr mod MOD の計算
    return fac[n]*finv[n-r]%MOD


N,M=map(int,input().split())
ans=0
for k in range(N+1):
    ans+=choose(N,k)*narabekae(M-k,N-k)*(-1 if k%2==1 else 1)
    ans%=MOD
ans*=narabekae(M,N)
print(ans%MOD)


Measured memory_bytes: 68192
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

long long n,m;
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
#endif
	cin>>n>>m;	
	if(n==1||m==1){
		if(n==1&&m==1)cout<<1<<endl;
		else if(n==1)cout<<m-2<<endl;
		else if(m==1)cout<<n-2<<endl;
	}else cout<<(n-2)*(m-2)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI a(n, -1);
    REP(i,n){
        int x = in() - 1, y = in() - 1;
        if (a[x] != -1){
            cout << -1 << endl;
            return 0;
        }
        a[x] = y;
    }
    VI f(n);
    int ans = 0;
    REP(i,n){
        if (f[i]) continue;
        int x = i, c = 0;
        while (!f[x]){
            f[x] = 1;
            c++;
            x = a[x];
        }
        ans += c - 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
#define fixed(n) fixed<<setprecision((n))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> p;
vector<int> s;
vector<bool> in;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	in.resize(n+1);
	reps(i,n){
		int a;
		cin >> a;
		if(a == i) in[i] = true;
	}
	int cnt = 0;
	int cntb = 0;
	bool flg = false;
	reps(i,n){
		if(in[i]){
			cntb++;
		}
		else{
			cnt += (cntb + 2 -1) / 2;
			cntb = 0;
		}
	}
	cnt += (cntb + 2 -1) / 2;
	cout << cnt << '\n';

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll x = 1000;
    rep(i, n-1) {
        int s = a[i];
        int t = a[i+1];
        if (s < t) {       // もし翌日、株価が上がっていら、
            ll k = x / s;  // 前日に買えるだけ株価を購入
            x %= s;        // 前日の残金
            x += k*t;      //　すぐに現金に戻す
        }
    }
    
    cout << x << endl;
    return 0; 
}

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

typedef long long int ll ;

int p[100010] ;
ll size[100010] ;

int Find(int x){
	if(p[x] == x)return x ;
	return p[x] = Find(p[x]) ;
}

ll Union(int a , int b){
	int u , v ;
	u = Find(b) ;
	v = Find(a) ;
	p[u] = v ;
	ll ret ;
	if(u != v){
		ret = size[u]*size[v] ;
		size[v] += size[u] ;
	}
	else ret = 0 ;

	return ret ;
}

int main(int argc, char const *argv[])
{
	//freopen("input.txt" , "r" , stdin) ;

	ll n , c ;
	int a[100010] , b[100010] ; 
	int m ;

	cin >> n >> m ;

	c = (n*(n-1))/2 ;


	for(int i = 0 ; i <= n ; i++){
		p[i] = i ;
		size[i] = 1 ;
	}

	for(int i = 1 ; i <= m ; i++)scanf("%d %d" , &a[i] , &b[i]) ;

	std::vector<ll> ans ;
	ans.push_back(c) ;

	int x , y ;

	for(int i = m ; i > 1 ; i--){
		x = a[i] ;
		y = b[i] ;

		ll red = Union(x , y) ;

		c -= red ;

		ans.push_back(c) ;
	}

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

	for(int i = 0 ; i < ans.size() ; i++)printf("%lld\n", ans[i]);

	return 0;
}

Measured memory_bytes: 4212
import java.util.*;
import java.math.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 入力
	int a = sc.nextInt();
	BigDecimal res = new BigDecimal("0");
    
    for(int i=1;i<=a;i++) {
        if(i%5 == 0 || i%3 == 0) {
            continue;
        } else {
            res = res.add(BigDecimal.valueOf(i));
        }
    }
	// 出力
    System.out.print(res.toPlainString());
	}
}

Measured memory_bytes: 52584
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    bool f=1;
    for(int j=0;j<s.size();j++)
      if(s.at((i+j)%s.size())!=t.at(j))
        f=0;
    if(f){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3568
fun main(args:Array<String>) {
  val (m,n) = readLine()!!.split(" ").map(String::toLong)
  when {
    m == 1L && n == 1L -> 1L
    m == 1L && n != 1L -> n - 2
    m != 1L && n == 1L -> m - 2
    else -> (m-2L)*(n-2L)
  }.let (::println)
}

Measured memory_bytes: 37792
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,q;
int l[200005],r[200005],dat[200005],qry[200005];
map<int,int>mp;
struct SegTree{
	#define SIZE 1048576
	int f[SIZE<<1];
	int l,r,v;
	void init(){
		for(int i=0;i<SIZE*2;i++)f[i]=inf;
	}
	void _set(int k=1,int ll=0,int rr=SIZE-1){
		if(ll>r||rr<l)return;
		if(l<=ll&&rr<=r){
			f[k]=min(f[k],v);
			return;
		}
		int mid=ll+rr>>1;
		_set(k<<1,ll,mid);
		_set(k<<1|1,mid+1,rr);
	}
	void set(int _l,int _r,int _v){
		l=_l;r=_r;v=_v;_set();
	}
	int _query(int ll=0,int rr=SIZE-1,int k=1){
		if(ll==rr)return f[k];
		int mid=ll+rr>>1;
		int tmp=(l<=mid?_query(ll,mid,k<<1):_query(mid+1,rr,k<<1|1));
//		cerr<<ll<<" "<<rr<<" "<<f[k]<<endl;
		return min(f[k],tmp);
	}
	int query(int _l){
		l=_l;return _query();
	}
}data;
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		int x,a,b;
		scanf("%d%d%d",&a,&b,&x);
		dat[i]=x;
		l[i]=max(0,a-x);r[i]=max(-1,b-x-1);
		mp[l[i]];if(~r[i])mp[r[i]];
	}
	for(int i=1;i<=q;i++){
		scanf("%d",&qry[i]);
		mp[qry[i]];
	}
	int cnt=0;
	for(auto &p:mp)p.second=++cnt;
	data.init();
	for(int i=1;i<=n;i++){
		l[i]=mp[l[i]];if(~r[i])r[i]=mp[r[i]];
		if(~r[i])data.set(l[i],r[i],dat[i]);
	}
	for(int i=1;i<=q;i++){
		qry[i]=mp[qry[i]];
		int ans=data.query(qry[i]);
		printf("%d\n",ans==inf?-1:ans);
	}
	return 0;
}

Measured memory_bytes: 40704
#include <cstdio>
#include <math.h>

using namespace std;

int main(){
  int a, b;
  char op;
  while(true) {
    scanf("%d %c %d", &a, &op, &b);
    switch(op) {
      case '+':
        printf("%d\n", a + b);
        break;
      case '-':
        printf("%d\n", a - b);
        break;
      case '*':
        printf("%d\n", a * b);
        break;
      case '/':
        printf("%d\n", a / b);
        break;
      default:
        return 0;
    }
  }
}



Measured memory_bytes: 2668
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  int X;
  cin >> X;
  
  int now = 100;
  int nen = 0;
  while( now < X ){
    now += now*0.01;
    nen++;
  }
  cout << nen << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    char a[100000];
    int c;
    while(cin >> a ){
    for(int i=0;i<strlen(a);i+=2){
        printf("%c",a[i]);

    }
    printf("\n");
    }
    return 0;
}



Measured memory_bytes: 384
/*ex5_3
  kt125 */

#include<stdio.h>
#define SIZE 100

int main(void){
    int height, width, //縦、横
        count, //'.'をカウントする変数
        k=0, //カウンタ変数
        row_del_num, //消去する行の数
        col_del_num, //消去する列の数
        height_ans, //答えとなる配列の縦の長さ
        width_ans, //答えをなる配列の横の長さ
    	col_del[SIZE], //消去する列の番号を記憶する配列
        row_del[SIZE];  //消去する行の番号を記憶する配列
  
    char board[SIZE][SIZE], //与えられたマス目の配列
         ans_row[SIZE * SIZE], //答えとなるマス目の文字を一列に並べた配列
    	 ans[SIZE][SIZE];  //答えとなる配列
  
    scanf("%d %d", &height, &width);

    for(int i=0; i < height;i++){
        for (int j=0; j < width; j++){
            scanf(" %c", &board[i][j]);
        }  
    }

    for(int i=0; i < height; i++){
        for(int j=0; j < width; j++){
            if(board[i][j]== '.'){
                count++;
            }
        }
        if (count == width){ //i行が全て'.'だった場合
            row_del[k] = i; //配列の最初から順に用いるためにkを使う
            k++;
        }
        count = 0; //各行ごとにリセット
    }  
    row_del_num = k; //消去する行の数

    k = 0; //リセット

    for(int i=0; i < width; i++){
        for(int j=0; j < height; j++){
            if(board[j][i]== '.'){
                count++;
            }
        }
        if (count == height){ //i列が全て'.'だった場合
            col_del[k] = i;
            k++;
        }
      	count = 0; //各列ごとにリセット
    } 

  	col_del_num = k; //消去する列の数
    
    for(int i=0; i < row_del_num; i++){
        for (int j=0; j < width; j++){
            board[row_del[i]][j] = 'o'; //消去する行の文字を'o'に置き換える
        }
    }
    for(int i=0; i < col_del_num; i++){
        for (int j=0; j < height; j++){
            board[j][col_del[i]] = 'o'; //消去する列の文字を'o'に置き換える
        }
    }
  	k = 0; // リセット
  	
    for(int i=0; i < height; i++){
        for(int j=0; j < width; j++){
            if (board[i][j] != 'o'){ //'o'を飛ばす
                ans_row[k] = board[i][j];
              	k++;
            }
        }
    }

  	height_ans = height - row_del_num; //答えとなる配列の縦の長さ
  	width_ans = width - col_del_num; //答えとなる配列の横の長さ

    for(int i=0; i < height_ans; i++){
        for(int j=0; j < width_ans;j++){
            ans[i][j] = ans_row[j + i * (width_ans)]; //一次元の配列をマス目に合うように二次元に直す
        }
    }
  
	for(int i=0; i < height_ans;i++){
        for (int j=0; j < width_ans; j++){
            printf("%c", ans[i][j]); //マス目をprint
        }
        printf("\n");
    }
    return 0;
}



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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int N;
    cin>>N;
    V<LL> A(N);
    REP(i,N) cin>>A[i];

    sort(ALL(A));

    LL ans = 0;
    REP(i,N-1){
        ans += A[N-((i+1)/2)-1];
    }

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

Measured memory_bytes: 4828
#include <iostream>
#define SIZE 10000
using namespace std;


int a[SIZE];
int b[SIZE];

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

    int t;
    cin>>t;
    for(int i = 0;i < t;i++)
    {
        cin>>b[i];
    }

    int n = 0;

    for(int i = 0;i < t;i++)
    {
        for(int j = 0;j < q;j++)
        {
            if(b[i] == a[j])
            {
                n++;
                break;
            }
        }
    }

    cout<<n<<endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

vector<int>a;
map<ll,bool>m;

int main()
{
    weewoo;
    int n;
    cin >> n;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x;cin >> x;
        a.push_back(x);
    }
    int cnt=1;
    for(int i=0;i<n;i++){
        if(a[i]!=cnt||m[a[i]])
            ans++;
        else{
            m[a[i]]=1;
            cnt++;
        }
    }
    if(ans<n)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 13556
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int rec1(string s){
    vector<int>a;
    vector<bool>b;
    REP(i,s.size()){
        if(i%2==0)a.push_back(s[i]-'0');
        else b.push_back(s[i]=='*'?true:false);
    }
    REP(i,b.size()){
        if(b[i]){
            a[i+1]=a[i]*a[i+1];
            a[i]=0;
        }
    }
    int sum=0;
    REP(i,a.size()){
        sum+=a[i];
    }
    return sum;
}
int rec2(string s){
    int res=s[0]-'0';
    for(int i=2;i<s.size();i+=2){
        if(s[i-1]=='*'){
            res*=(s[i]-'0');
        }else{
            res+=(s[i]-'0');
        }
    }
    return res;
}
int main(){
    string s;
    cin>>s;
    int bob;
    cin>>bob;
    int a=rec1(s);
    int b=rec2(s);
    if(a==bob){
        if(b==bob){
            cout<<"U"<<endl;
        }else{
            cout<<"M"<<endl;
        }
    }else{
        if(b==bob){
            cout<<"L"<<endl;
        }else{
            cout<<"I"<<endl;
        }
    }
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9;
constexpr int64_t mx=1e18;
int main()
{
  int64_t s;
  cin>>s;
  if(s<=mod){
    cout<<0<<" "<<0<<" "<<1<<" "<<0<<" "<<0<<" "<<s;
    return 0;
  }
  else if(s==mx){
    cout<<0<<" "<<0<<" "<<mod<<" "<<0<<" "<<0<<" "<<mod;
    return 0;
  }
  s+=mod;
  int64_t y=s%mod;
  int64_t x=(s-y)/mod;
  cout<<0<<" "<<0<<" "<<1<<" "<<mod<<" "<<x<<" "<<mod-y;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int n;
  cin>>n;
  int r=n%1000;
  cout<<(1000-r)%1000<<endl;
return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N;
    cin >> N;
    string ans = "";
    while(N>0) {
        if(N %26 == 0) {
            ans += 'z';
            N /= 26;
            N--;
        }
        else {
            ans += (char)('a'+N%26-1);
            //cout << N%26 << endl;
            N /= 26;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3616
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ll summa = 0;
    vector<ll> s(n);
    vector<ll> pref(2 * n + 1, 0);
    for (int i = 0; i < n; i++){
    	cin >> s[i];
    	summa += s[i];
    	pref[i + 1] = s[i];
    	if (i >= 2)
    		pref[i + 1] += pref[i - 1];
    }
    for (int i = n; i < 2 * n; i++)
    	pref[i + 1] = pref[i - 1] + s[i - n];
    // print(pref);
    for (int i = 0; i < n; i++){
    	ll val = summa - 2 * pref[i + n - 1];
    	// cout << pref[i + n - 1] << " " << val << endl;
    	if (i > 0)
    		val += 2 * pref[i];
    	cout << val << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3712
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @s = gets.chomp.split("T").map(&:size)
    @x,@y = gets.split.map(&:to_i)
    @h = s.select.with_index{ |v,i| i.even? }
    @v = s.select.with_index{ |v,i| i.odd? }
  end

  def solve
    valid?(h.shift,h,x) && valid?(0,v,y)
  end

  def valid?(init, arr, pos)
    return pos.zero? if init.nil?

    stack = [init]
    while arr.size > 0
      work = []
      d = arr.shift
      stack.each do |e|
        work << e + d
        work << e - d
      end
      work.uniq!
      stack = work
    end
    stack.include?(pos)
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
  # pp self
end

Measured memory_bytes: 54812
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict


import sys
# sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline
# readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    g = defaultdict(list)
    rg = defaultdict(set)

    V = set()

    def ij2v(i, j):
        if i > j:
            i, j = j, i
        return i * 10**6 + j
    for i, a in enumerate(A, start=1):
        for j in range(len(a)-1):
            u = ij2v(i, a[j])
            v = ij2v(i, a[j+1])
            g[u].append(v)
            rg[v].add(u)
            V.add(u)
            V.add(v)

    s = []
    for v in V:
        if not rg[v]:
            s.append(v)

    done = len(s)
    ans = 0
    while s:
        ans += 1
        ns = []
        for u in s:
            for v in g[u]:
                # if v in done:
                #     continue
                rg[v].remove(u)
                if len(rg[v]) == 0:
                    ns.append(v)
                    done += 1
        s = ns

    if done != N * (N-1) // 2:
        return -1

    return ans



def main():
    N = read_int()
    A = [read_int_n() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 386444
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
int a[100];
int n;
int main()
{
    cin>>n;
    for(int i = 0; i < n; ++i){
        cin>>a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j) ans += a[i]*a[j];
    }cout<<ans<<endl;
}


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

int N, W;
int dp[210][10010][2];
vector<int> v;
int M = 1e9+7;

int main() {
	cin >> N >> W;
	for(int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp; v.push_back(tmp);
	}
	dp[0][0][0] = 1;
	sort(v.rbegin(), v.rend());

	for(int i = 0; i < v.size(); i++) {
		for(int j = 0; j < 10010; j++) {
			dp[i+1][j][0] = ((j-v[i] < 0) ? 0 : (dp[i][j-v[i]][0] + dp[i][j-v[i]][1])) % M;
			dp[i+1][j][1] = (dp[i][j][0] + dp[i][j][1]) % M;
		}
	}

	int ans = 0;
	int sum = 0;
	bool flg = true;

	for(int i = v.size(); i > 0; i--) {
		for(int j = 0; j < (i > 0 ? v[i-1] : 1) && W-sum-j >= 0; j++) {
			ans = (ans + dp[i][W-sum-j][1]) % M;
		}
		sum += i > 0 ? v[i-1] : 0;
		if(ans)
			flg = false;
	}
	if(flg)
		cout << 1 << endl;
	else
		cout << ans << endl;
}

Measured memory_bytes: 17528
n, c = map(int, input().split())
X = [0 for _ in range(n)]
V = [0 for _ in range(n)]
right = [0 for _ in range(n)]
left = [0 for _ in range(n)]
rl = [0 for _ in range(n)]
lr = [0 for _ in range(n)]

calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X[i] = x
    V[i] = v
    calsum += v
    right[i] = calsum-x
    rl[i] = calsum-2*x

calsum = 0
for i in range(n):
    calsum += V[n-i-1]
    left[i] = calsum - (c-X[n-i-1])
    lr[i] = calsum - 2*(c-X[n-i-1])

M = max(0, max(right), max(left))
m = 0
for i in range(0, n-1):
    m = max(m, left[i])
    M = max(M, m + rl[n-i-2])

m = 0
for i in range(0, n-1):
    m = max(m, right[i])
    M = max(M, m + lr[n-i-2])

print(M)


Measured memory_bytes: 26948
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    res = LINF;
    int D,G; cin >> D >> G;
    vector<ll> p(D),c(D);
    for(int i = 0; i < D;i++) cin >> p[i] >> c[i];
    
    G/= 100;
    for(auto& v:c) v/=100;
    
    for(int i = 0; i < (1<<D);i++){
        ll L = G;
        ll cnt = 0;
        for(int j = 0; j < D;j++){
            if((i>>j)&1){
                L -= (j+1)*p[j]+c[j];
                cnt += p[j];
            }
        }
        if(L <= 0){
            res = min(res,cnt);
            continue;
        }
        for(int j = D-1;j>=0;j--){
            if((i>>j)&1) continue;
            ll num = min(p[j],(L+j)/(j+1));
            L -= num*(j+1);
            cnt += num;
            if(L <= 0) break;
        }
        if(L <= 0) res = min(res,cnt);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,v,p,ans=-1;
const ll MOD = 1000000007;
bool decide(ll i,vector<ll> a){
    if(a[n-p]>a[i]+m) return false;
    ll cnt=m*v;
    For(j,0,n){
        if(a[j]<=a[i]){
            cnt-=m;
        }
        else if(j>n-p){
            cnt-=m;
        }
        else if(a[j]<=a[i]+m){
            cnt-=a[i]+m-a[j];
        }
    }
    if(cnt>0) return false;
    else return true;
}
void Main(){    
    cin>>n>>m>>v>>p;
    vector<ll> a(n);
    For(i,0,n) cin>>a[i];
    sort(ALL(a));
    if(decide(0,a)){
        cout<<n<<endl;
        return;
    }
    ll ok=n-p,ng=0;
    while(ok>ng+1){
        ll c=(ok+ng)/2;
        if(decide(c,a)){
            ok=c;
        }
        else{
            ng=c;
        }
    }
    cout<<n-ok<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;

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

        if (A > 8 || B > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

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

map<ll, ll> memo;

ll attack(ll h) {
  if (memo.count(h) != 0) return memo[h];

  ll attack_count = (2 * attack(h / 2)) + 1;
  memo[h] = attack_count;

  return attack_count;
}

int main() {
  ll h;
  cin >> h;

  memo[1] = 1;

  cout << attack(h) << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  for (int i=0; i < N; i++){
    cin >> a[i];
  }
  int flash,count;
  flash = 1;
  count = 0;
  while (flash != 2 and count < N){
      flash = a[flash-1];
      count += 1;
  }
  if (count >= N){
    cout << -1 << endl;
  }else{
    cout << count << endl;
  }
}



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Calculate(long a, long b, long c)
        {
            var s = new[] { a, b, c };
            long min = s.Min();
            long max = s.Max();
            return (min > 0) ? max - min : long.MaxValue;
        }
        static long Solve(long H, long W)
        {
            long min = long.MaxValue;
            long h1 = (H + 0) / 3;
            long h2 = (H + 1) / 3;
            long h3 = (H + 2) / 3;
            long ha = (H + 0) / 2;
            long hb = (H + 1) / 2;
            long w1 = (W + 0) / 3;
            long w2 = (W + 1) / 3;
            long w3 = (W + 2) / 3;
            long wa = (W + 0) / 2;
            long wb = (W + 1) / 2;
            min = Math.Min(Calculate(h1 * W, h2 * W, h3 * W), min);
            min = Math.Min(Calculate(w1 * H, w2 * H, w3 * H), min);
            min = Math.Min(Calculate(h1 * W, (H - h1) * wa, (H - h1) * wb), min);
            min = Math.Min(Calculate(h3 * W, (H - h3) * wa, (H - h3) * wb), min);
            min = Math.Min(Calculate(w1 * H, (W - w1) * ha, (W - w1) * hb), min);
            min = Math.Min(Calculate(w3 * H, (W - w3) * ha, (W - w3) * hb), min);
            return min;
        }
        static void Main(string[] args)
        {
            long[] values = ReadLongs();
            Console.WriteLine(Solve(values[0], values[1]));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string N; cin >> N;

    if(N[0]=='7' or N[1]=='7' or N[2]=='7') cout << "Yes"<< endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3664