akhauriyash/Code-Regression huggingface dataset:
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 12:08:45 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	a, b, x;
	cin >> a >> b >> x;
	int l, r;
	r = b / x;
	l = max(0LL, (a - 1)) / x;
	if (a == 0)
		r++;
	cout << r - l << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

struct A
{
    int num1=0;
    int num2=0;
}number;
int main(){
  int N;
  cin >> N;
  struct A number[N];
  for(int i=0;i<N;i++){
    cin >> number[i].num1;
    number[number[i].num1-1].num2=i;
  }

  for(int i=0;i<N;i++){
    cout << number[i].num2+1 << " ";
  }
  cout << endl;

  return 0;
} 


Measured memory_bytes: 1536
use proconio::input;
use proconio::marker::Chars;
use std::collections::HashSet;
use std::iter::Iterator;

fn main() {
    input! {
    n: i32,
    m: i32,
    h:[i32; n],
    mut road:[(i32, i32);m],
    }

    let mut ans = n;

    let mut v: HashSet<i32> = HashSet::new();

    for r in &road {
        if  h[(r.0 - 1) as usize] == h[(r.1 - 1) as usize]  {
            if !v.contains(&r.0) {
                v.insert(r.0);
                ans = ans -1;
            }
            if !v.contains(&r.1) {
                v.insert(r.1);
                ans = ans - 1;
            }
            continue;
        }

        if h[(r.0 - 1) as usize] < h[(r.1 - 1) as usize]  {
            if !v.contains(&r.0) {
                v.insert(r.0);
                ans = ans - 1;
            }
        } else {
            if !v.contains(&r.1) {
                v.insert(r.1);
                ans = ans - 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl

signed main(){
    char a; cin >> a;
    if(a>='a'&&a<='z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3588
#ABC156:B_Digits

N,R = input().split()
N = int(N)
R = int(R)

i = 1

while N//(R**(i)) > 1:
    if N//(R**(i+1)) == 0:
        break
    i += 1

if N//(R**i) == 0:
    print(i)
else:
    print(i + 1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = r*2*pi;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a*100+b*10+c)%4)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)


bool isPrime(int n){
	if(n<=1)return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	int a,d,n;
	while(cin>>a>>d>>n,a|d|n){
		while(1){
			if(isPrime(a) && --n==0)break;
			a+=d;
		}
		cout<<a<<endl;
	}
	return 0;
}

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

int main() {
  char c;

  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)(a).size())

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

int n, m;
int b[1000];
int h[1000];
int f[1000];
int a[1000];


bool ok(double hei, int x, int t){
  //cout << hei << endl;
  double tsum = 0;
  double from = 0;
  
  vector<int> st1, st2;
  for(int i = 0;; ++i){
    if(x < b[i]) break;
    if(h[i] < hei) continue;
    while(!st1.empty() && h[st1.back()] < h[i]) st1.pop_back();
    st1.push_back(i);
  }


  for(int i = n-1;; --i){
    if(x > b[i]) break;
    if(h[i] < hei) continue;
    while(!st2.empty() && h[st2.back()] < h[i]) st2.pop_back();
    st2.push_back(i);
  }

  // for(int i = 0; i < SZ(st1); ++i){
  //   cout << st1[i] << " " << b[st1[i]] << " " << h[st1[i]] << endl;
  // }

  // for(int i = 0; i < SZ(st2); ++i){
  //   cout << st2[i] << " " << b[st2[i]] << " " << h[st2[i]] << endl;
  // }
  
  
  from = 0;
  int idx = 0;
  for(int i = 0; i + 1 < SZ(st1); ++i){
    while(idx < m && f[idx] < b[st1[i + 1]]){
      from += t * a[idx];
      ++idx;
    }
    from -= abs(b[st1[i + 1]] - b[st1[i]]) * h[st1[i+1]] * 30;
    from = max(0.0, from);
  }
  
  tsum += from;
  idx = m - 1;
  from = 0;
  for(int i = 0; i + 1 < SZ(st2); ++i){
    while(idx >= 0 && f[idx] > b[st2[i + 1]]){
      from += t * a[idx];
      --idx;
    }
    from -= abs(b[st2[i + 1]] - b[st2[i]]) * h[st2[i+1]] * 30;
    from = max(0.0, from);
  }

  tsum += from;
  rep(i, m){
    if(b[st1.back()] < f[i] && f[i] < b[st2.back()])
      tsum += t * a[i];
  }
  
  return tsum >= 30 * hei * abs(b[st2.back()] - b[st1.back()]);
}

void solve(){
  cin >> n;
  b[0] = 0;
  h[0] = 50;
  rep(i, n) cin >> b[i + 1] >> h[i + 1];
  b[n + 1] = 100;
  h[n + 1] = 50;
  n += 2;
  
  cin >> m;
  rep(i, m) cin >> f[i] >> a[i];
  int asum = 0;
  rep(i, m) asum += a[i];
  
  int l;
  cin >> l;
  rep(i, l){
    ll p, t;
    cin >> p >> t;
    
    if(t * asum >= 50 * 100 * 30){
      cout << 50 << endl;
      continue;
    }
    
    double low = 0;
    double up = 50;
    rep(jj, 100){
      double mid = (low + up) / 2;
      if(ok(mid, p, t)) low = mid;
      else up = mid;
    }
    printf("%.8f\n", low);
    //exit(0);
  }
}

int main(int argc, char *argv[])
{
  int d;
  cin >> d;
  rep(i, d) solve();
}

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

int main(void){
    int r,g,b;

    cin >> r >> g >> b;

    int N = r*100+g*10+b;

    if(N%4 == 0)
        cout << "YES" << endl;

    else
        cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

    if(N.length() == 2){
        cout<<N<<endl;
    }else{
        reverse( N.begin(), N.end()) ;
        cout << N <<endl;
    }

    return 0;
}

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

typedef long long ll;

using namespace std;

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

    ll count (0);
    for (ll i=1; i<=n; i++)
    {
        string s = to_string(i);
        if (s.size() % 2 != 0)
            count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int C;
  int D;
  
  cin >> A >> B >> C >> D;
  
  int ans = 0;
  if(D>A){
    ans += A;
    D -= A+B;
    if(D>0){
      ans -= D;
    }
  }else{
    ans += D;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;
 
int N,K;
int a[5005];
int dp[5005][5005];
vector<int> A;
vector<int> B;
 
bool solve(int i){
    A.erase(A.begin()+i);
    int n=A.size();
    for(int j=0;j<=N;++j)for(int k=0;k<=K;++k)dp[j][k]=0;
    if(A[0]<=K)dp[0][A[0]]=1;
    dp[0][0] = 1;
    int res=0;
    for(int j=1;j<n;++j){
        for(int k=0;k<K;++k){
            if(k-A[j]<0)dp[j][k] = dp[j-1][k];
            else dp[j][k] = (dp[j-1][k]||dp[j-1][k-A[j]]);
        }
    }
    for(int k=max(0ll,K-a[i]);k<=K;++k){
        if(dp[n-1][k])res=1;
    }
    A.insert(A.begin()+i,a[i]);
    if(res)return true;
    else return false;
}
 
signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>a[i];
        A.PB(a[i]);
        B.PB(a[i]);
    }
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    sort(a,a+N);
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int ans = 0;
    int l = 0, r = N-1;
    int mid;
    if(!solve(r)){
        cout<<N<<endl;
        return 0;
    }
    for(int i=0;i<20;++i){
        mid=(l+r)/2;
        if(!solve(mid))l=mid;
        else r=mid;
    }
    if(r==l){
        if(solve(l))cout<<l<<endl;
        else cout<<l+1<<endl;
    }
    else cout<<l+1<<endl;
}

Measured memory_bytes: 195968
program main
  implicit none
  integer i,N,K,ans
  integer,allocatable :: H(:)
  read(*, *)N,K
  allocate(H(N))
  read(*, *) (H(i), i = 1,N)
  ans = 0
  do i = 1,N
    if (H(i) >= K) then
      ans = ans + 1
    end if
  end do
  write(*, *) ans
end program main


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

int main() {
  long N, D;
  cin >> N >> D;  
  D = abs(D);
  
  long count = 0;
  for (long i=0; i<N; i++) {
    long X, Y;
    cin >> X >> Y;
    X = abs(X);
    Y = abs(Y);
    if (X*X+Y*Y <= D*D) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())

# それぞれの要素のつながりを1で表現
A = [ [0 for _ in range(N)] for _ in range(N) ]

visited = [False]*N

for i in range(M):
    a, b = map(int, input().split())
    # インデックスのため -1する
    a -= 1
    b -= 1
    A[a][b] = 1
    A[b][a] = 1

def dfs(node, count):
    # 全てのノードが訪れられていたら ans+=1
    if all(visited):
        return count+1
    
    # 全てのノード間の繋がりでfor文
    for i in range(N):
        # nodeの繋がりがあるか判定。
        if A[node][i] == 0:
            continue
        # 見ているノードが訪れられているか判定。
        if visited[i]:
            continue
        
        # 見ているノード間の繋がりがあり、そのノードが訪れられていないとき。
        visited[i] = True
        count = dfs(i, count)
        # 探索前の状態に戻す
        visited[i] = False

    return count

# 開始地点
visited[0] = True

# 開始地点とcountを引数に
count = dfs(0, 0)

print(count)

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    long mod = 1_000_000_007;
    long[] fac = new long[n+1];
    long[] finv = new long[n+1];
    long[] inv = new long[n+1];
    fac[0] = 1, fac[1] = 1;
    finv[0] = 1, finv[1] = 1;
    inv[1] = 1;
    foreach (i; 2 .. n+1) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
    long comb(int x, int y) {
        if (x < y) return 0;
        if (x < 0 || y < 0) return 0;
        return fac[x] * (finv[y] * finv[x-y] % mod) % mod;
    }
    foreach (i; 0 .. k) {
        writeln((comb(n-k+1, i+1) * comb(k-1, i)) % mod);
    }
}

Measured memory_bytes: 2300
h,w=map(int,input().split())

word={}
A=[list(input()) for _ in range(h)]
for i in A:
    for j in i:
        if j not in word:word[j]=1
        else:word[j] +=1

D=[0]*5
if h%2==0 and w%2==0:
    D[4]=(h*w)//4
elif (h%2==0 and w%2==1) or (h%2==1 and w%2==0):
    if h%2==1:
        D[2]=w//2
        D[4]=w*(h-1)//4
    else:
        D[2]=h//2
        D[4]=h*(w-1)//4
else:
    D[2]=(h+w-2)//2
    D[4]=(h-1)*(w-1)//4
    D[1]=1

P=[0]*5
for i in word.values():
    P[4] +=i//4;i %=4
    P[2] +=i//2;i %=2
    P[1] +=i

for i in (4,2,1):
    if D[i]==P[i]:continue
    elif D[i]<P[i]:
        P[i//2] +=(P[i]-D[i])*2
    else:print("No");exit()
print("Yes" if P[0]==0 else "No")

Measured memory_bytes: 38964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=174417441744;
ll pw(ll k){
  for(int i=0;i<40;i++){
    if((((ll)1)<<i)>k) return (((ll)1)<<i);
  }
}
int main(){
  multiset<ll> ms,ms_;
  ll n;
  cin>>n;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    ms.insert(a);
    ms_.insert(-a);
  }
  ll ans=0;
  while(!ms.empty()){
    ll max_v=*(ms_.upper_bound(-inf));
    max_v*=-1;
    ll pr=pw(max_v)-max_v;
    ms.erase(ms.find(max_v));
    ms_.erase(ms_.find(-max_v));
    if(ms.empty()) break;
    ll ai=*(ms.lower_bound(pr));
    if(ai==pr){
      ans++;
      ms.erase(ms.find(ai));
      ms_.erase(ms_.find(-ai));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 18944
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    # a, b = get_inputs(int)
    # A = str(a)*b
    # B = str(b) * a
    # if A < B:
    #     print(A)
    # else:
    #     print(B)
    N = get_input(int)
    P = get_inputs(int)

    P_min = None
    ans = 0
    for i in range(N):
        if P_min is None:
            ans += 1
            P_min = P[i]
            continue

        if P[i] <= P_min:
            ans += 1

        P_min = min(P_min, P[i])
    # print(' '.join(map(str, ans)))
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 34168
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

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

    if(n == 1 || m == 1) {
        if(n == m) {
            cout << 1 << endl;
            return 0;
        }
        cout << max(n, m) - 2 << endl;
        return 0;
    }

    ll out = n * m - (2 * n + 2 * (m - 2));
    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
flg = True
while True:
	a, b = map(int, raw_input().split())
	if a == b == 0: break
	if flg:
		flg = False
	else:
		print ""
	pflg = False
	for i in xrange(a, b + 1):
		if i % 400 == 0 or (i % 4 == 0 and i % 100 != 0):
			print i
			pflg = True
	if not pflg:
		print "NA"

Measured memory_bytes: 5484
#include <bits/stdc++.h>
#include <queue>
using namespace std;
typedef pair<long long, int> P; 
int main(){
	int N, M; cin >> N >> M; 
	long long INF = 1e18; 
	vector<P> E[100010] = {};  
	for(int i = 1; i < N; i++){
		E[i].push_back(make_pair(0LL, i-1)); 
	}
	for(int i = 0; i < M; i++){
		int L, R; long long C; cin >> L >> R >> C; 
		L--; R--; 
		E[L].push_back(make_pair(C, R)); 
	}
	long long dist[100010] = {}; 
	fill(dist+1, dist+N, INF); 
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(make_pair(0LL, 0)); 
	while(que.size()){
		P p = que.top();
		que.pop(); 
		int now = p.second; 
		for(int i = 0; i < E[now].size(); i++){
			if(dist[now] + E[now].at(i).first < dist[E[now].at(i).second]){
				dist[E[now].at(i).second] = dist[now] + E[now].at(i).first;
				que.push(make_pair(dist[now] + E[now].at(i).first, E[now].at(i).second)); 
			}
		}
	}
	if(dist[N-1] == INF) cout << -1 << endl; 
	else cout << dist[N-1] << endl; 
}

Measured memory_bytes: 10232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

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

int d[110][110];
int edge[110][110];
const int INF = 114514810;
int n, m;

int main(void) {
    rep(i, 110) rep(j, 110) {
        d[i][j] = edge[i][j] = INF;
    }

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        //scanf("%d%d%d", &a, &b, &c);
        cin >> a >> b >> c;
        --a; --b;
        d[a][b] = d[b][a] = c;
        edge[a][b] = edge[b][a] = c;
    }

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (!edge[i][j]) continue;
            if (d[i][j] == edge[i][j]) ++cnt;
        }
    }

    int ans = m - cnt;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
A, B, C = map(int, input().split())
q = int(input())

k = 0

for i in range(q+1):
    for j in range(0, q-i+1):
        B_ = B * (2 ** i)
        C_ = C * (2 ** j)
        if A < B_ and B_ < C_ and A < C_:
            k = 1
if k != 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans=0;

    ll n;

    cin >> n;

    vector<ll> l(n);
    for(auto&& x: l) cin >> x;

    if(n<3) n=0;

    vector<ll> tl(3);
    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            for(ll k=j+1; k<n; k++){
                tl[0] = l[i];
                tl[1] = l[j];
                tl[2] = l[k];
                sort(tl.begin(), tl.end());
                if(tl[0]==tl[1]||tl[1]==tl[2])
                    continue;
                if(tl[2]<(tl[0]+tl[1])){
                    ans++;
                    //print(i+1,j+1,k+1)
                    print(tl[2], tl[1],tl[0])
                }
            }
        }
    }

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



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,m;
	cin>>n>>m;
	int d[222222]={};
	int u[222222]={};
	vector<P> v;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		v.push_back(P(x,y));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<m;i++){
		int t=v[i].second;
		d[t+1]=d[t]+1;
		u[t]=u[t+1]+1;
	}
	for(int i=1;i<=n;i++){
		if(i-1)cout<<" ";
		cout<<d[i]+u[i]+1;
		//cout<<d[i]<<" "<<u[i]<<endl;
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 5608
#ABC077C 解説を見て自作
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
#あるBの下にいくつCが入るか数える
C_under_B=[0]*N     #i番目のBの下に入るCの数
for i in range(N):
    C_under_B[i]=N-bisect.bisect_right(C,B[i])
#あるBの上にいくつAが乗るか数える
A_on_B=[0]*N     #i番目のBの上に乗るAの数
for i in range(N):
    A_on_B[i]=bisect.bisect_left(A,B[i])
#あるBの上下におけるものを数えて出力
ans=0
for i in range(N):
    ans+=C_under_B[i]*A_on_B[i]
print(ans)

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

using namespace std;

int main(){

  //int i,m,M;
  //string S,T,U;
  double N;
  const double PI=3.14159265358979323846;
  //cin>>S>>T;
  
  cin>>N;
  //cin>>U;

  
  //  cout<<S<<endl;
  cout<<N*PI*2.0<<endl;
    return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>

int main(void){
    int N[4],n;
    scanf("%d %d %d %d ",&N[0],&N[1],&N[2],&N[3]);
    if(N[0]==1||N[1]==1||N[2]==1||N[3]==1) n++;
    if(N[0]==9||N[1]==9||N[2]==9||N[3]==9) n++;
    if(N[0]==7||N[1]==7||N[2]==7||N[3]==7) n++;
    if(N[0]==4||N[1]==4||N[2]==4||N[3]==4) n++;

    if(n==4) printf("YES");
    else printf("NO");
    
    


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int X,ans = 1,j,i;
  cin >> X;
  if(X != 1){
    for(i = 2; i < X;i++){
      j = i * i * i;
      while(j <= X){
        j *= i;
      }
      if(j / i >= ans && j / i <= X) ans = j / i;
    }
    cout << ans;
  }
  else cout << "1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second

using namespace std;

vector<string> maze;
vector<vector<bool> > tomados;

int h,w;
int a[2][4] = {
				{1,-1,0,0},
				{0,0,1,-1}
				};
int blanco,negro;
void ff(int i,int j,char c){
	if(i < 0 || i >= h || j < 0 || j >= w || tomados[i][j]) return;
	if(maze[i][j] == c) return;
	tomados[i][j] = true;
	if(maze[i][j] == '#') negro++;
	else{
		blanco++;
	}
	for (int x = 0; x < 4; ++x){
		ff(i+a[0][x],j + a[1][x],maze[i][j]);
	}
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> h >> w;
	vector<bool> em(w,false);
	tomados.assign(h,em);
	for (int i = 0; i < h; ++i){
		cin >> s;
		maze.push_back(s);
	}
	ll ans = 0;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			if(maze[i][j] == '#'){
				negro = blanco = 0;
				ff(i,j,'.');
				if(blanco){
					ans += (ll)blanco*negro;
				} 
			}
		}
	}
	cout << ans << '\n' ;

	return 0;
}

Measured memory_bytes: 15488
# Input
s = str(input())
N = len(s)

while s != "":
    if s[N-5:N] == "dream" or s[N-5:N] == "erase":
        s = s[:N-5]
        N = len(s)
    elif s[N-6:N] == "eraser":
        s = s[:N-6]
        N = len(s)
    elif s[N-7:N] == "dreamer":
        s = s[:N-7]
        N = len(s)
    else:
        break

if s == "":
    print("YES")
else:
    print("NO")

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

ll pro(string &s) {
    auto iter = find(s.begin(), s.end(), '.');
    int cnt = iter == s.end() ? 9 : 10 - (s.end() - iter);
    if (iter != s.end()) s.erase(iter);
    for (int i=0; i<cnt; ++i) s.push_back('0');
    return stoll(s);
}

void solve() {
    int N;
    cin >> N;
    vector<ll> num(N);
    for (int i=0; i<N; ++i) {
        string s;
        cin >> s;
        num[i] = pro(s);
    }

    vector<int> cnt2(N), cnt5(N);
    for (int i=0; i<N; ++i) {
        while (num[i]%2 == 0) {
            num[i] /= 2;
            ++cnt2[i];
        }
        while (num[i]%5 == 0) {
            num[i] /= 5;
            ++cnt5[i];
        }
    }

    ll res = 0;
    vector<vector<int>> cnt(19, vector<int>(19));
    for (int i=0; i<N; ++i) {
        res += cnt[max(0, 18-cnt2[i])][max(0, 18-cnt5[i])];
        for (int j=0; j<=min(18, cnt2[i]); ++j) {
            for (int k=0; k<=min(18, cnt5[i]); ++k) {
                ++cnt[j][k];
            }
        }
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 6372
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        long[] a = new long[1+n];
        for(int i = 1; i<= n; i++)a[i] = nl()+a[i-1];
        long[][] ans = new long[1+n][1+n];
        for(int i = 1; i<= n; i++)for(int j = i+1; j<= n; j++)ans[i][j] = ans[j][i] = IINF;
        for(int l = 1; l< n; l++)
            for(int i = 1; i+l<= n; i++)
                for(int k = i; k< i+l; k++)
                    ans[i][i+l] = Math.min(ans[i][i+l], ans[i][k]+ans[k+1][i+l]+a[i+l]-a[i-1]);
        pn(ans[1][n]);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int x = ceil(n*1.0/1000);
	x *= 1000;
	cout<<x-n<<endl;
	return 0;
}

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


int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << (n-a)%b << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
typedef vector<LL> VL;
typedef vector<VL> ML;
ML operator * (const ML &a, const ML &b) {
    int n = a.size(), m = b[0].size();
    int k = a[0].size();
    ML ret(n, VL(m, 0));
    for (int i = 0 ; i < n ; i++)
        for (int j = 0 ; j < m ; j++)
            for (int x = 0 ; x < k ; x++)
                (ret[i][j] += a[i][x] * b[x][j]) %= MOD;
    return ret;
}
ML fpow(auto &A, LL n) {
    if (n == 1) return A;
    auto k = fpow(A, n >> 1);
    if (n & 1)
        return k * k * A;
    else
        return k * k;
}
void marmot0814() {
    int n; LL k; cin >> n >> k;
    ML A(n, VL(n));
    for (auto &vv : A)
        for (auto &v : vv)
            cin >> v;
    ML res = fpow(A, k);
    LL ans = 0;
    for (auto &vv : res)
        for (auto &v : vv)
            (ans += v) %= MOD;
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3656
#7
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
bingo = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1:
        bingo = 1
        
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        bingo = 1

if a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0]:
    bingo = 1

if bingo == 1:
    print('Yes')

else:
    print('No')
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long l;
int main()
{
    l n , k;
    cin>>n>>k;
    l arr[n];
    for( l i = 0 ;i< n ; i++)
    cin>>arr[i];
    
    l dp[k+1];
    memset(dp , 0 , sizeof(dp));
    dp[0]=0;
    for( l i = 1 ; i<=k ;i++)
    {
        for(l t = 0 ; t<n ;t++)
        {
            l temp = i-arr[t];
            if(temp>=0)
            {
                if(dp[temp]==0)
                {
                    dp[i]=1;
                    break;
                }
            }
        }
    }
   /* for(l i = 0 ;i<= k ;i++)
    cout<<dp[i]<<"  "; */
    if(dp[k]==1)
    cout<<"First";
    else 
    cout<<"Second";
    
    
    
    
    return 0;
}

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

int main()
{
    int ary[] = {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};
    int k;

    cin >> k;

    cout << ary[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r
l = list(map(int, input().split()))
X = l[0]
Y = l[1]
Algo.greatest_common_divisor(X, Y)

Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n;
	cin >> n;
	int a[n],b[n];
	forn(i,0,n){
		cin >> a[i] >> b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	int l;
	int r;
	ll ans = 0;
	if(n%2==1){
		l = a[n/2];
		r = b[n/2];
	}
	else{
		l = a[n/2] + a[n/2-1];
		r = b[n/2] + b[n/2-1];
	}
	ans = (r-l+1);
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

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


Measured memory_bytes: 5196
import numpy as np

H, W = (list(map(int, input().split())))
S = [[_ for _ in input()] for i in range(H)]
for i in range(H):
  for j in range(W):
    if(S[i][j] == "."):
      count = 0
      if(i - 1 in range(H)):
        if(j - 1 in range(W)):
          if(S[i-1][j-1] == "#"):
            count += 1
        if(j in range(W)):
          if(S[i- 1][j] == "#"):
            count += 1
        if(j + 1 in range(W)):
          if(S[i-1][j + 1] == "#"):
            count += 1
      if(i in range(H)):
        if(j - 1 in range(W)):
          if(S[i][j-1] == "#"):
            count += 1
        if(j in range(W)):
          if(S[i][j] == "#"):
            count += 1
        if(j + 1 in range(W)):
          if(S[i][j + 1] == "#"):
            count += 1
      if(i + 1 in range(H)):
        if(j - 1 in range(W)):
          if(S[i+1][j-1] == "#"):
            count += 1
        if(j in range(W)):
          if(S[i+1][j] == "#"):
            count += 1
        if(j + 1 in range(W)):
          if(S[i+1][j + 1] == "#"):
            count += 1
      S[i][j] = count
for i in range(H):
  out = ""
  for char in S[i]:
    out += str(char)
  print(out)

Measured memory_bytes: 13000
def main():
    N=int(input())
    dp=[[0]*3 for _ in range(N+1)]
    abc=[list(map(int,input().split())) for _ in range(N)]
    for i in range(N):
        for j in range(3): #移動元
            for k in range(3): #移動先
                if j==k: continue
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])
    print(max(dp[N]))
    
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9;
const ll lINF = 1e18;
const int MOD = 1e9+7;
const int SIZE = 100005;


int main() {
	ll n;
	ll ans;
	ll c[SIZE];
	for (ll i = 0; i < SIZE; i++) {
		c[i] = 0;
	}
	scanf("%lld", &n);
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		c[a[i]]++;
	}

	ans = 0;
	for (ll i = 1; i < SIZE-1; i++) {
		ll buf = c[i-1] + c[i] + c[i+1];
		ans = max(ans, buf);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long Q, H, S, D, N;
		Q = sc.nextLong();
		H = min(sc.nextLong(), 2*Q);
		S = min(sc.nextLong(), 2*H);
		D = sc.nextLong();
		N = sc.nextLong();
		sc.close();
		long ans;
		if(D>=2*S) {
			ans = N*S;
		} else {
			if(N%2==1) {
				ans = D*(N/2) + S;
			} else {
				ans = D*(N/2);
			}
		}
		System.out.println(ans);
		
	}
	
	private static long min(long a, long b) {
		if(a>b) {
			return b;
		} else {
			return a;
		}
	}

}


Measured memory_bytes: 22612
N, L = map(int, input().split())
As = list(map(int, input().split()))

i = 0

for j in range(1,N):
  if As[j-1] + As[j] >= L:
    i = j
    break
    
if i == 0:
  print('Impossible')
else:
  print('Possible')
  for j in range(1,i):
    print(j)
  for j in range(N-1,i,-1):
    print(j)
  print(i)

Measured memory_bytes: 85988
def main():
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()
    if (u == s):
        print("{} {}".format(a-1, b))
    else:
        print("{} {}".format(a, b-1))

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define inf 2000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif
			
			ll n,k;
			cin>>n>>k;
			ll arr[n];
			for(ll i=0;i<n;i++)
			cin>>arr[i];

			for(ll i=k;i<n;i++)
			{
				if(arr[i]>arr[i-k])
				cout<<"Yes"<<endl;
				else
				cout<<"No"<<endl;
			}
		
			
			return 0;
		 }	




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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n, k;
vector<ll> v;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      // i回取り k - i回戻し
      // j回右から i - j回左から
      int li = -1, ri = n - 1;
      vector<ll> minus, plus;
      for (int k = 0; k < min(j, n); k++) {
        if (v[k] >= 0) plus.push_back(v[k]);
        else minus.push_back(v[k]);
        li = k;
      }
      for (int k = 0; k < i - j; k++) {
        int k2 = n - 1 - k;
        if (k2 <= li) continue;
        if (k2 < 0) continue;
        if (v[k2] >= 0) plus.push_back(v[k2]);
        else minus.push_back(v[k2]);
      }
      sort(minus.begin(), minus.end());
      ll sum = 0;
      for (auto &v : plus) sum += v;
      for (auto &v : minus) sum += v;
      for (int l = 0; l < min(k - i, (int) minus.size()); l++) sum -= minus[l];
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	int alpha[26]={0};
	int ret = 1;

	cin >> S;

	for(int i=0;i<S.length();i++){
		alpha[S[i]-'A']++;
	}

	for(int i=0;i<26;i++){
		if (!((alpha[i] == 2) || (alpha[i] == 0))) {
			ret=0;
		}
	}

	if(ret){
		cout << "Yes" << endl;
	}else{
        cout << "No" << endl;
    }

	return 0;

}


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

using namespace std;
int main() {
    int N, active = 0, ans;
    cin >> N;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    for (int i = 0; i < N; i++) {
        if (active < x[i]) {
            ans += x[i] - active;
        }
      	active = x[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

import math

def insertion_sort(num_list, length, interval):
    cnt = 0
    for i in range(interval, length):
        v = num_list[i]
        j = i - interval
        while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
        num_list[j+interval] = v
    return cnt

def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    print(*reversed(intervals))
    print(cnt)

input_num = int(input())
input_list = list()
for i in range(input_num):
    input_list.append(int(input()))
shell_sort(input_list, input_num)
for num in input_list:
    print(num)

Measured memory_bytes: 47616
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int N;
cin >> N;

int X;
for( int i = 1; i <= sqrt(N); i++ ){
if( N % i == 0 ) X = i;
}

cout << (X-1LL) + (N/X - 1LL) << endl;



}


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

#define NIL -1

int n;
queue<int> pre;
vector<int> in;
queue<int> post;

int findin(int u) {
	for (int i = 0; i < n; i++)
		if (in[i] == u)
			return i;
	return NIL;
}

void rec(int l, int r) {
	if (l >= r)
		return;
	int c = pre.front();
	pre.pop();
	int m = findin(c);
	rec(l, m);
	rec(m + 1, r);
	post.push(c);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		pre.push(a);
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		in.push_back(a);
	}
	rec(0, n);
	for (int i = 0; i < n - 1; i++) {
		cout << post.front() << " ";
		post.pop();
	}
	cout << post.front() << endl;
	return 0;
}



Measured memory_bytes: 3164
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */

#ifndef H_make_vector
#define H_make_vector

#include <cstddef>
#include <type_traits>
#include <vector>

namespace detail {
  template <typename Tp, size_t N>
  std::vector<Tp> make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N == 1), Tp const&>::type x
  ) {
    return std::vector<Tp>(sizes[0], x);
  }
  template <typename Tp, size_t N>
  auto make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N > 1), Tp const&>::type x
  ) {
    size_t size = sizes[N-1];
    sizes.pop_back();
    return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
        size, make_vector<Tp, N-1>(sizes, x)
    );
  }
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x = Tp()) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

#endif  /* !defined(H_make_vector) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <array>

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  size_t k;
  scanf("%zu", &k);
  size_t n = s.length();

  size_t const loose = 0;
  size_t const tight = 1;
  std::array<size_t, 2> const tightness{{loose, tight}};

  auto dp = make_vector({n+1, k+1, 2_zu}, 0_jd);
  dp[0][0][tight] = 1;
  for (size_t i = 0; i < n; ++i) {
    for (size_t t: tightness) {
      for (size_t j = 0; j <= k; ++j) {
        for (int c = '0'; c <= '9'; ++c) {
          if (t == tight && s[i] < c) break;
          size_t nt = (t == tight && s[i] == c)? tight: loose;
          size_t nj = ((c == '0')? j: j+1);
          if (nj > k) continue;
          dp[i+1][nj][nt] += dp[i][j][t];
        }
      }
    }
  }

  printf("%jd\n", (dp[n][k][loose] + dp[n][k][tight]));
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
using namespace std;


int W,H;
int sx,sy,gx,gy;
vector< pair<int,int> > e[5];

int memo[1000][1000][5] = {};

int dfs(int x,int y,int c,int r){
	if( memo[x][y][c] != -1 ) return memo[x][y][c];
	if( r == 0 ) return abs(gx-x)+abs(gy-y);
	int g = (c+1)%5;
	int ans = 1e8;
	for(int i = 0 ; i < e[g].size() ; i++){
		ans = min( ans , dfs(e[g][i].first,e[g][i].second,g,r-1) + abs(e[g][i].first-x)+abs(e[g][i].second-y) );
	}
	return memo[x][y][c] = ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	while(cin >> W >> H && W){
		rep(i,5)e[i].clear();
		sx = sy = gx = gy = 1e7;
		
		vector< pair<int,int> > list;
		rep(i,H){
			rep(j,W){
				char c;
				cin >> c;
				if( c == 'S' ) sx = j , sy = i;
				else if( c == 'G' ) gx = j , gy = i;
				else if( c != '.' ) e[c-'1'].push_back(make_pair(j,i)), list.push_back(make_pair(j,i));
			}
		}
		list.push_back(make_pair(sx,sy));
		list.push_back(make_pair(gx,gy));
		int F = !e[0].size() + !e[1].size() + !e[2].size() + !e[3].size() + !e[4].size();
		if( F >= 2){
			cout << "NA" << endl;
			continue;
		}
		pair<int,int> ans = make_pair(1e8,1e8);
		rep(i,5){
			rep(j,list.size()) rep(k,5) memo[list[j].first][list[j].second][k] = -1;
			ans = min(ans,make_pair(dfs(sx,sy,i,4),i));
		}
		if( 1e6 > ans.first ){
			cout << ans.second+1 << " " << ans.first << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 18000
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    int L;
    cin >> L;
    L--;
    int cnt = 0;
    int M = 0;
    vector<pair<pair<int, int>,int>> ANS(0);
    for(int i = 0; i < 20; i++){//  2^cnt <= L < 2^(cnt+1)
        if(pow(2, i) - 1 <= L){
            cnt = i;
        }
    }
    
    for(int i = 0; i < cnt; i++){
        ANS.push_back({{i+1, i+2}, 0});
        ANS.push_back({{i+1, i+2}, pow(2, i)});
    }
    int V = cnt + 1;//頂点数
    M += pow(2, cnt) -1;
    while(L != M){
        cnt--;
        if(L - M >= pow(2, cnt)){
            ANS.push_back({{cnt+1, V},M+1});
            M += pow(2, cnt);
        }
    }
    
    cout << V << " " << ANS.size() << endl;
    for(int i = 0; i < ANS.size(); i++){
        cout << ANS.at(i).first.first << " " << ANS.at(i).first.second << " " << ANS.at(i).second << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = 1;
        int i = 0;
        while (x > 0) {
            x = Integer.parseInt(sc.next());
            i++; 
            if (x > 0)
                System.out.println("Case " + i + ": " + x); 
        }
    }
}


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

int main(){
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    
    int largest = (B / K) * K;  //B以下のKの倍数のうち、最大となる数

    if(largest >= A){
        cout << "OK";
    }
    else{
        cout << "NG";
    }
}

Measured memory_bytes: 3600