akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define inf 1000000007
#define pb push_back

char v1[1005][1005]; ll dp[1005][1005];

ll fun(ll h,ll w)
{
    ll h1=-1; ll w1=-1;
    rep(i,0,h-1) if(v1[i][0]=='#') { h1=i; break; }
    if(h1==-1) h1=h;
    rep(i,0,w-1) if(v1[0][i]=='#') { w1=i; break; }
    if(w1==-1) w1=w;
    rep(i,0,h1-1) dp[i][0]=1; rep(i,h1,h-1) dp[i][0]=0;
    rep(i,0,w1-1) dp[0][i]=1; rep(i,w1,w-1) dp[0][i]=0;
    
    rep(i,1,h-1)
    {
        rep(j,1,w-1)
        {
            if(v1[i][j]=='#') dp[i][j]=0;
            else dp[i][j]=(dp[i-1][j]%inf+dp[i][j-1]%inf)%inf;
        }
    }
    
    return dp[h-1][w-1];
}

int main()
{
    ll h,w; cin>>h>>w;
    rep(i,0,h-1) 
    { rep(j,0,w-1) cin>>v1[i][j]; }
    ll ans=fun(h,w); cout<<ans%inf;
}


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

using namespace std;

int main() {
  int N, Q;
  long long K;
  
  cin >> N >> K >> Q;
  
  vector<int> queue(N, -Q);
  
  for (int i = 0; i < Q; i++) {
    int in;
    
    cin >> in;
    
    queue[in - 1]++;
  }
  
  for (int i = 0; i < N; i++) {
    if (K + queue[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>

int main(){
	long long int N;
	scanf("%lld", &N);
	int k, digit[64];
	for(k = 0; N != 0; k++){
		digit[k] = N & 0x1;
		N >>= 1;
	}
	int i, left[2 * k - 1];
	for(i = 1; i <= k; i++){
		left[2 * i] = i;
	}
	int j = k;
	for(i = 0; i < k - 1; i++){
		if(digit[k - i - 2] == 1){
			left[2 * k - 3 - 2 * i] = j;
			j++;
		}
		else{
			left[2 * k - 3 - 2 * i] = 0;
		}
	}
	left[0] = j;
	printf("%d\n", 2 * j);
	for(i = 0; i < 2 * k - 1; i++){
		if(left[i] != 0){
			printf("%d ", left[i]);
		}
	}
	for(i = 1; i <= j; i++){
		printf("%d ", i);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

int main() {
    for (int i = 1; i <= 5; i++) {
        int a;
        cin >> a;
        if (!a) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var answer = 0L;
            foreach (var i in Enumerable.Range(1, N))
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    answer += i;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28276
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
ll ans[55555];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,x,y; cin>>n>>x>>y;
	x--; y--;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int dist=abs(i-j);
			dist=min(dist,abs(i-x)+1+abs(y-j));
			//dist=min(dist,abs(i-y)+1+abs(x-j));
			ans[dist]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		cout<<ans[i]<<'\n';
	}
}

   


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

using namespace std;

int main(){

	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if( i % 2 == 0){
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

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

#define ll                   long long
#define MOD                  1000000007
#define fast()               ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define fd(i,a,b)          for(ll i=(ll)a;i<(ll)b;i++)
#define bk(i,a,b)          for(ll i=(ll)a;i>=(ll)b;i--)
#define pb                   push_back
#define vi                   vector<ll>
#define test()               ll t; cin>>t; while(t--)
#define endl                 "\n"
#define param                greater<ll>()
#define ff                   first
#define ss                   second
#define all(v)               v.begin(),v.end()
#define mk                   make_pair
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define MAX 1000000000000000000

using namespace std;

const ll N = 1e5+10;


// vector<ll> adj[N];

ll count=0;

ll n,m;

char sqr[1010][1010];
ll vis[1010][1010];
ll dp[1010][1010];

ll xax[2]={0,1};
ll yax[2]={1,0};

ll dfs(ll i , ll j)
{
    if(i==n && j==m)
    {
        return 1;
    }
    
    if(vis[i][j])
    return dp[i][j]%MOD;
    
   vis[i][j]=1;

  for(ll k=0;k<2;k++)
  {
  
        ll x=i+xax[k];
        ll y=j+yax[k];
        
        if(x>0 && x<=n && y>0 && y<=m && sqr[x][y]=='.')
        {
            dp[i][j]= (dfs(x,y)%MOD + dp[i][j]%MOD )%MOD;
        }
       
       
   }
   
   
   return dp[i][j]%MOD;


}


int main()
{

    fast()

    ll t;
    // cin>>t;
    t=1;

    while(t--)
    {
       ll i,j,a,b,d=0;

        cin>>n>>m;
        
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                cin>>sqr[i][j];
                
                if(sqr[i][j]=='#')
                vis[i][j]=1;
                
            }
        }
        
       ll res= dfs(1,1);



        // vector < ll > vec(n+1),sum(n+1,0),vec2(n+1);


        

    //   ll ans=0;

        
    //     for(i=1;i<=n;i++)
    //     {
    //         ans=max(ans,dp[i]);
            
    //         // cout<<dp[i]<<" ";
          
    //     }
        
        
        // for(i=1;i<=n;i++)
        // {
        //     for(j=1;j<=m;j++)
        //     {
        //         cout<<dp[i][j];
                
        //     }
        //     cout<<endl;
        // }
        

        cout<<dp[1][1]%MOD<<endl;


    }

}



Measured memory_bytes: 17280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,X,cnt;
    cnt = 0;
    cin >> N >> X;
    X = N;
    while(N){
        cnt = cnt + N%10;
        N /=10;
    }
        
    
    if (X%cnt == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
long long m;
int n;
long long num[1001];
long long sum[1000005];
int main(){
	while(1){
	scanf("%d %lld",&n,&m);
	if(!n) break;
	for(int i=0;i<n;i++){
		scanf("%lld",&num[i]);
	}
	num[n]=0;
	int ro=0;
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[ro]=num[i]+num[j];
			ro++;
		}
	}
	long long ans=0;
	sort(sum,sum+ro);
	for(int i=0;i<ro;i++){
		if(sum[i]>m){ break;}
		int rp=lower_bound(sum,sum+ro,m-sum[i])-sum;
			rp--;
			ans=max(ans,sum[i]+sum[rp]);
	}
	printf("%d\n",ans);
}
	return 0;
}

Measured memory_bytes: 5144
import bisect
n = int(input())
L = list(map(int, input().split()))
#%%
L.sort()

ans = 0
for i in range(n-2): # aを固定
    for j in range(i+1, n-1): # bを固定
        ab = L[i] + L[j]
        idx = bisect.bisect_left(L, ab, lo=j)
        ans += max(idx - (j+1), 0)

print(ans)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N;
  cin >> N;
  
  long long count = 10000000000;
  for(long i = 1LL; i*i < N+1; i++){
    long long c = 10000000000;
    if(N%i != 0) continue;
    	string j = to_string(i);
    	string k = to_string(N/i);
    	
    	int l = j.size();
    	int m = k.size();
      
      	if(l < m){
        	c = m;
      	}
      	else{
        	c = l;
      	}
    
    
    if(count > c){
      count = c;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    ($t:ty) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty ;) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ; $n:expr) => {
        (0..$n).map(|_|
            input!($t)
        ).collect::<Vec<_>>()
    };
}

fn main(){
    let (_a,b,_c) = input!(String,String,String);
    println!("A{}C", b.chars().collect::<Vec<char>>()[0]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;	cin >> s;
  vector<string>	day={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i=0;i<7;i++){
    if(day[i]==s)	cout << 7-i;
  }
}

Measured memory_bytes: 3600
import sys

def LI(): return list(map(int, sys.stdin.readline().split()))
N, K = LI()
p = LI()
ps = []
for i in range(N):
    ps.append((p[i] + 1) / 2)
 
anss = []
tmp = 0
for i in range(N):
    tmp += ps[i]
    if i > K - 1:
        tmp -= ps[i - K]
    anss.append(tmp)
 
print(max(anss))

Measured memory_bytes: 24404
# include <iostream>
# include <cstdio>
# include <cmath>
using namespace std;

long long A[1000000];
long long N,K;
int main(void)
{
    // freopen("aaa.in","r",stdin);
    scanf("%lld%lld",&K,&N);
    for (int i=1;i<=N;i++) {
        scanf("%lld",&A[i]);
    }
    long long ans = A[1]+K-A[N];
    long long maxx = ans;
    for (int i=2;i<=N;i++)
    {
        ans+=A[i]-A[i-1];
        maxx = max(maxx,A[i]-A[i-1]);
    }
    printf("%lld\n",ans-maxx);
    return 0;
}

Measured memory_bytes: 4764
n = int(input())

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

Alist = [x for x in A if x%2==0]

ans = []
for x in Alist:
    if x%3==0 or x%5==0:
        ans.append(True)
    else:
        ans.append(False)
        break
if all(ans)==True:    
    print("APPROVED") 
else:
    print("DENIED")


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 305;
int dp[N][N][N];

int main(){
  fastIO;
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  for(int i = 0 ; i < n; i ++ ){
    dp[i][i][0] = 1;
    if(i + 1 < n){
      if(s[i] == s[i + 1]){
        dp[i][i + 1][0] = 2;
      }
      else{
        dp[i][i + 1][0] = 1;
        dp[i][i + 1][1] = 2;
      }
    }
  }
  int r;
  int cost;
  for(int len = 3; len <= n; len ++ ){
    for(int l = 0 ; l + len - 1 < n; l ++ ){
      r = l + len - 1;
      for(int t = 0 ; t <= k ; t ++ ){
        dp[l][r][t] = max(dp[l][r-1][t], dp[l+1][r][t]);
        cost = (s[l] != s[r]);
        if(t - cost >= 0){
          dp[l][r][t] = max(dp[l][r][t], dp[l+1][r-1][t - cost] + 2);
        }
      }
    }
  }
  int ans = 0;
  for(int t = 0 ;t <= k ; t ++ ) ans = max(ans, dp[0][n-1][t]);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 110848
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if(a >= k) {
		cout << k << '\n';
		return 0;
	}
	if(a + b >= k) {
		cout << a << '\n';
		return 0; 
	}
	k -= a + b;
	cout << a - k << '\n';
}


Measured memory_bytes: 3648
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-06(Fri)
   note
**********************************************************************/

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
		sc.close();
		if(n < x) {
			prtln(t);
		} else {
			prtln((int)(((double)n / (double)x) + 0.5) * t);
		}
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}


Measured memory_bytes: 27076
#include <iostream>


int main(){
	int W, H, x, y, r;

	std::cin >> W >> H >> x >> y >> r;


	if(W >= (x+r) && 0 <= (x-r)){
		if(H >= (y+r) && 0 <= (y-r)){
			std::cout << "Yes" << std::endl;
		}
		else{ 
			std::cout << "No" << std::endl;
		}
	}
	else{
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	bool a[26]={};
	rep(i,0,s.size()){
		int t = s[i]-'a';
		a[t]++;
	}

	if(a[0] && a[1] && a[2])
		Yes;
	else
		No;
	ret 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long ans = 2 * (x / 11);
    long r = (x % 11);
    if(r == 0) {
    } else if(r <= 6) {
      ans++;
    } else {
      ans += 2;
    }  
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>

int main(void){
    int N;
    long long a, b=1, c=2, ans;
    std::cin >> N;

    if (N == 1) ans = 1;
    else {
        for (int i=2; i<=N; ++i){
            a = b + c;
            c = b;
            b = a;
        }
        ans = a;
    }

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

    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long ans = 0;
		for( int i=0; i<N; i++ ){
			ans += sc.nextLong()-1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25680
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;

int main()
{
    int H, A;
    cin >> H >> A;

    int count = 0;
    while (true) {
        count++;
        H -= A;
        if (H <= 0) {
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, cnt = 0;
    while(cin >> n, n){
        if(cnt) puts("");
        cnt++;
        vector<pair<int, string>> v(n);
        for (int i = 0; i < n; ++i) {
            string s; int a, b, c;
            cin >> s >> a >> b >> c;
            v[i] = {a*300+c*100+n-i, s};
        }
        sort(v.begin(),v.end(), greater<>());
        for (int i = 0; i < n; ++i) {
            cout << v[i].second << "," << v[i].first/100 << "\n";
        }
    }
    return 0;
}


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

int func(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /=10;
  }
  return sum;
}
int total = 0;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  for(int i= 0; i<=n; i++){
    if(func(i)>=a and func(i)<= b) total+=i;

  }
  cout<<total<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A < B) {
			if(A + X < B) {
				System.out.println("dangerous");
			} else {
				System.out.println("safe");
			}
		} else {
			System.out.println("delicious");
		}
		
		
		
	}
}

Measured memory_bytes: 24020
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int n[11][331];
int f[10],g;

void num(int d,int s) {
 int i;
 if (d==10) return;
 for (i=0;i<10;i++) {
	 if (f[i]==0) {
		 n[d][s+(d+1)*i]++;
	     f[i]=1;
	     num(d+1,s+(d+1)*i);
	     f[i]=0;
	 }
 }
}

int main() {
 int a,b; 
 num(0,0);
 while(cin >> a >> b) if (b>330) cout << 0 << endl; else cout << n[a-1][b] << endl; 
 return 0;
}

Measured memory_bytes: 1172
<?php
list($a, $b) = ints();
for ($i = 0; $i < 100; ++$i) {
    if ($i < 50) $s[] = str_repeat('#', 100);
    else $s[] = str_repeat('.', 100);
}
--$a;
--$b;
for ($i = 0; $i < 50; $i += 2) {
    for ($j = 0; $j < 100; $j += 2) {
        if ($a === 0) break 2;
        $s[$i][$j] = '.';
        --$a;
    }
}
for ($i = 51; $i < 100; $i += 2) {
    for ($j = 0; $j < 100; $j += 2) {
        if ($b === 0) break 2;
        $s[$i][$j] = '#';
        --$b;
    }
}
echo '100 100', PHP_EOL;
for ($i = 0; $i < 100; ++$i) echo $s[$i], PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16288
d,g = map(int, input().split())
ps = []
cs = []
for i in range(d):
    p,c = map(int, input().split())
    ps.append(p)
    cs.append(c)
INF = 1 << 50
dp = [INF]*110000
dp[0] = 0
for k,(p,c) in enumerate(zip(ps,cs)):
    tmp = dp[:]
    for i in range(p+1):
        for j in range(g//100+1):
            if dp[j] == INF:continue
            if i < p:
                tmp[j+(k+1)*i] = min(dp[j+(k+1)*i], dp[j]+i)
            else:
                tmp[j+(k+1)*i+c//100] = min(dp[j+(k+1)*i+c//100], dp[j]+i)
    dp = tmp[:]
print(min(dp[g//100:]))

Measured memory_bytes: 86256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    while (true) {
        string S;
        cin >> S;
        if (S == "-") break;
        int m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int h;
            cin >> h;
            S = S.substr(h, S.length()) + S.substr(0, h);
        }
        cout << S << endl;
    }
}



Measured memory_bytes: 3160
import itertools


n = input()
l = list(map(int, input().split())) 
l.sort()
cnt = 0
c_list = list(itertools.combinations(l, 3))
# print(c_list)


for lis in c_list:
    # print(lis[0])
    if (lis[-3]+ lis[-2] > lis[-1])and (lis[-1]!=lis[-2])and (lis[-1]!=lis[-3])and(lis[-2]!=lis[-3]):
        cnt += 1

print(cnt)

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

int main() {
    int x; cin >> x;
    int happy = 0;

    happy += (x/500)*1000;
    x -= (x/500)*500;
    happy += (x/5)*5;

    cout << happy << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb emplace_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 5000005, mod = 998244353;
int n, m;
ll f[MX], in[MX];

ll comb (int n, int k) {
	return f[n] * in[k] % mod * in[n - k] % mod; 
}

ll fun (int n, int k) {
	return comb(n + k - 1, k);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	f[0] = in[0] = in[1] = 1;
	for (int i = 1; i < MX; i++)
		f[i] = f[i-1] * i % mod;
	for (int i = 2; i < MX; i++)
		in[i] = in[mod % i] * (mod - mod / i) % mod;
	for (int i = 1; i < MX; i++)
		(in[i] *= in[i-1]) %= mod;

	cin >> n >> m;

	ll res = 0;
	for (int i = 0; i <= min(m, n); i++) {
		if ((3 * m - i) % 2) continue;
		(res += comb(n, i) * fun(n, (3 * m - i) / 2)) %= mod;
		(res -= comb(n, i) * fun(n, (m - i) / 2) % mod * n) %= mod;
		(res += comb(n, i) * fun(n - 1, (m - i) / 2) % mod * (n - i)) %= mod;
	}

	cout << MOD(res, mod) << endl;

	return 0;
}


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

void solve(int N, int X, int T)
{
    cout << (N + X - 1) / X * T << endl;
}

int main()
{
    int N;
    cin >> N;
    int X;
    cin >> X;
    int T;
    cin >> T;
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    auto A = make_vec<int>(N, 2);
    REP(i, N) cin >> A[i][0];
    REP(i, N) cin >> A[i][1];

    vector<int> left(N + 1), right(N + 1);
    REP(i, N) left[i + 1] = left[i] + A[i][0];
    for (int i = N - 1; i >= 0; i--) right[i] = right[i + 1] + A[i][1];

    int ans = 0;
    REP(i, N) { chmax(ans, left[i + 1] + right[i]); }

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


Measured memory_bytes: 256
H, W = map(int, input().split())

grid = []

for h in range(H):
    inputs = input()
    _w = []
    for w in range(W):
        _w.append(inputs[w])
    grid.append(_w)

dy = [-1, -1, -1, 0, 0, +1, +1, +1]
dx = [-1, 0, +1, -1, +1, -1, 0, +1]

for i in range(H):
    for j in range(W):

        if grid[i][j] == '#': continue

        num = 0
        for k in range(8):
            ci = i + dy[k]
            cj = j + dx[k]

            if ci < 0 or H <= ci: continue
            if cj < 0 or W <= cj: continue
            if grid[ci][cj] == "#": num += 1
        
        grid[i][j] = "{}".format(num)

for g in range(len(grid)):
    print(''.join(grid[g]))


Measured memory_bytes: 3064
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {

		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();

		Map<Integer, Integer> relationMap = new TreeMap<>();
		//初期セット
		IntStream.rangeClosed(1, n).forEach(i -> relationMap.put(i, 0));

		for (int j = 2; j <= n; j++) {
			int managerNumber = stdIn.nextInt();
			relationMap.replace(managerNumber, relationMap.get(managerNumber)+1);

		}

		stdIn.close();

		for (Entry<Integer, Integer> e : relationMap.entrySet()) {
			System.out.println(e.getValue());
		}

	}

}

Measured memory_bytes: 72360
#Shift only
x = int(input())
y = input()
z = y.split(" ")
black = [int(s) for s in z]
cnt = 0
count = 0
while True:
    for i in range(x):
        if(black[i] % 2 == 0):
            cnt += 1
    if(cnt == x):
        cnt = 0
        count += 1
        for i in range(x):
            black[i] = black[i] / 2
    else:
        print(count)
        break

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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    int A, B;
    cin >> A >> B;
    int A_8 = ceil(A * 100 / 8);
    int B_10 = B * 10;
    int big = max(A_8, B_10);
    while (1) {
        int a = floor(big * 0.08);
        int b = floor(big * 0.1);
        if (a > A || b > B) {
            cout << -1 << endl;
            return;
        }
        else if (a == A && b == B) {
            cout << big << endl;
            return;
        }
        big++;
    }
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);
  int sub1 = x - a;
  int sub2 = b - sub1;
  if(sub1 >= 0 && sub2 >= 0) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
using namespace std;
int main(){
int a;
char x;
int b;
cin>>a>>x>>b;
if(x=='+')
cout<<a+b<<endl;
else
cout<<a-b<<endl;
}

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

int main(){
    string str;
    cin >> str;
    int ok = 0;
    for(int i = 0; i < str.size()-1; i++){
        if(str[i] == 'A' && str[i+1] == 'C') ok = 1;
    }
    if(ok == 1) cout << "Yes" << endl;
    if(ok == 0) cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int d,s,t;
        cin>>d>>t>>s;
        if(t>=(double)d/s){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    cin >> s;
    if((s.size()%2+(s.front()!=s.back()))%2) cout << "Second" << endl;
    else cout << "First" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll = long long ;
using namespace std;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
int main(){
   int n;cin >> n;
   vector<ll> vec(n);
   for(int i=0;i<n;i++){
       cin >> vec[i];
   }
   if(n==1){
       cout<<vec[0]<<endl;
   }else{
 //  ll Gcd = gcd(vec[1],vec[0]);
   ll Lcm = lcm(vec[1],vec[0]);
   for(int i=2;i<n;i++){
       Lcm = lcm(Lcm,vec[i]);
       
   }
   cout<<Lcm<<endl;
   
   
   }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //int K = sc.nextInt();
        //long N = sc.nextLong();

        int[] A = new int[N];
        int[] B = new int[N];
        int count=0;
        for(int i=0; i<N; i++){
            A[i]=sc.nextInt();
            B[i]=sc.nextInt();
            if(A[i]==B[i]){
                count++;
            }else{
                count=0;
            }
            if(count==3){
                System.out.println("Yes");
                return;
            }
        }
        

        
        System.out.println("No");
        }
    }

Measured memory_bytes: 36012
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <vector>
using namespace std;

int main() {
    int N,A,B;
    cin>>N>>A>>B;
    int x;
    x=A*N;
    if(x>B){
        x=B;
    }
    cout<<x<<endl;
    return 0;

 }


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, wmax) = (v[0], v[1]);

    let mut w = vec![0u64; n];
    let mut v = vec![0usize; n];
    for i in 0..n {
        let temp = read_vec::<u64>();
        w[i] = temp[0];
        v[i] = temp[1] as usize;
    }
    let vmax: usize = 100 * 1000;
    // let vmax: usize = 100;

    let mut dp = vec![vec![1000_000_000_0000; vmax + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..vmax + 1 {
            if j < v[i] {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = std::cmp::min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    let mut ans = 0;
    for i in 0..vmax + 1 {
        if dp[n][i] <= wmax as u64 {
            ans = i;
        }
    }
    // println!("{:?}", &dp[n][0..20]);
    println!("{:?}", ans);
}


Measured memory_bytes: 106748
use proconio::input;

fn main() {
    input! {
        s: String,
        t: String
    }

    solve(s, t);
}

fn solve(s: String, t: String) {
    let mut cnt = 0;
    let s_ch: Vec<char> = s.chars().collect();
    let t_ch: Vec<char> = t.chars().collect();

    for i in 0..s.len() {
        if !(s_ch[i] == t_ch[i]) {
            cnt += 1;
        }
    }

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


Measured memory_bytes: 4400
X = int(input())
# dp[i]:= ちょうどi円となる買い物が存在するorしない
dp = [0] * (X+1)
dp[0] = 1
for i in range(X):
    if dp[i] == 1:
        for next in [100,101,102,103,104,105]:
            if i+next<=X:
                dp[i+next] = 1
print(dp[X])

Measured memory_bytes: 68372
#include <stdio.h>

int main(){
  int n;
  long long d;
  scanf("%d%lld",&n,&d);
  int ans = 0,i=0;
  for(i;i<n;++i){
    long long x,y;
    scanf("%lld%lld",&x,&y);
    if(x*x+y*y<=d*d)ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1736
#クラスカル法
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x): #親を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y): #和集合の生成
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x): #所属する集合の大きさ
        return -self.parents[self.find(x)]

    def same(self, x, y): #同じ集合に属しているか判定
        return self.find(x) == self.find(y)

    def members(self, x): #同じ集合に属する要素全列挙
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self): #集合のリーダー全列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self): #集合の数
        return len(self.roots())

    def all_group_members(self): #辞書型,{(リーダーの番号):(その集合の要素全列挙)}
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.unite(a-1,b-1)
print(-min(uf.parents))

Measured memory_bytes: 14412
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int a[] = new int[n];
    int min = -1;
    int max = -1;
    for (int i=0; i<n;i++){
      int b = scan.nextInt();
      a[i] = b;
      if (b<min){
        min = b;
      }
      if (b>max){
        max = b;
      }
    }

    int dis = max-min+1;

    int[] c = new int[dis];
    for (int i = min; i<=max; i++){
      int sum = 0;
      for (int j=0;j<n;j++){
        sum += (a[j] - i)*(a[j] - i);
      }
      c[i-min] = sum;
    }

    int minn = c[0];
    for (int gg=0; gg <max-min+1; gg++){
      if (c[gg] < minn){
        minn = c[gg];
      }
    }

    System.out.println(minn);

  }
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int n;
auto a = make_vec<int>(0, 0);
vector<int> dp;

mint rec(int men, int women) {
    if (men == n) return 1;
    if (dp[women] != -1) return dp[women];
    mint res = 0;
    rep(j, n) {
        if (a[men][j] && !(women >> j & 1)) {
            int nmen = men + 1;
            int nwomen = women | (1 << j);
            res += rec(nmen, nwomen);
        }
    }
    return dp[women] = res.x;
}

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

    cin >> n;
    a = make_vec<int>(n, n);
    rep(i, n) rep(j, n) cin >> a[i][j];
    dp.resize(1<<n, -1);
    cout << rec(0, 0) << endl;
}


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e9 + 7;
int main(){
	ll a,b;
	cin>>a>>b;
	ll mid=abs(a-b);
	if(mid%2==0){
		printf("%lld\n",min(a,b)+mid/2);
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}                                


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  private static String s;

  public static long rec(int i, String c) {
    if (i == s.length()) {
      long ans = 0;
      String[] nums = c.split(",", 0);
      for (String num : nums) {
        ans += Long.parseLong(num);
      }
      return ans;
    }
    return rec(i + 1, c + s.charAt(i)) + rec(i + 1, c + "," + s.charAt(i));
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    s = sc.next();
    String c = String.valueOf(s.charAt(0));
    System.out.println(rec(1, c));
  }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> board(h, vector<char>(w, ' '));
    rep(y, h) rep(x, w) cin >> board[y][x];
    vector<vector<int>> distances(h, vector<int>(w, INT_MAX / 10));

    P start = [&] {
        rep(y, h) {
            rep(x, w) {
                if (board[y][x] == 'S') return P(y, x);
            }
        }
        __throw_runtime_error("konaide");
    }();

    distances[start.first][start.second] = 0;
    struct Point {
        ll y, x, cost;
    };

    queue<Point> q;
    q.push({start.first, start.second, 0});

    auto to_id = [&](int y, int x) {
        return y * w + x;
    };

    struct Direction {
        int y, x;
    };
    vector<Direction> directions = {
            {0,  1},
            {1,  0},
            {0,  -1},
            {-1, 0},
    };


    auto reachable = [&](int y, int x, int distance) {
        if (x == -1 || x == w || y == -1 || y == h) return false;
        if (board[y][x] == '#') {
            return false;
        }
        if (distances[y][x] <= distance) {
            return false;
        }
        return true;
    };

    while (!q.empty()) {
        Point p = q.front();
        q.pop();
        for (Direction d : directions) {
            int nx = p.x + d.x;
            int ny = p.y + d.y;
            int nd = p.cost + 1;
            if (reachable(ny, nx, nd)) {
                distances[ny][nx] = nd;
                q.push({ny, nx, nd});
            }
        }
    }

    auto calc = [&](int y, int x) -> int {
        auto p = [&](int a) -> int {
            return (a + k - 1) / k;
        };
        int l = p(x);
        int r = p(w - x - 1);
        int u = p(y);
        int d = p(h - y - 1);


        return min({l, r, u, d});
    };

    int ans = INT_MAX;
    rep(y, h) {
        rep(x, w) {
            if (distances[y][x] > k) continue;
            int now = calc(y, x);
            cmin(ans, now);
        }
    }
    cout << ans + 1 << endl;
}


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

int h[100001];
vector<int> adj[100001];

int main(void) {
    int n,m;
    scanf("%d %d\n",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%d ",&h[i]);
    }
    for(int i=0;i<m;i++) {
        int u,v;
        scanf("%d %d\n",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ret=0;
    for(int i=1;i<=n;i++) {
        bool flag=true;
        for(int j=0;j<adj[i].size();j++) {
            int next=adj[i][j];
            if (h[next]>=h[i]) {
                flag=false;
            }
        }
        ret+=flag;
    }
    printf("%d",ret);
}

Measured memory_bytes: 9260
'use strict'
function main(inp) {
  inp = inp.trim().split('\n');
  let N = inp[0].split(' ')[0];
  let As = inp[1].split(' ').map(x => x*1);
  let sum = As.reduce((a,c) => {return c+a});
  let ans = N - sum >= 0 ? N - sum: -1;
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 30688
from sys import stdin
from queue import Queue

n, q = [int(x) for x in stdin.readline().rstrip().split()]
proc = Queue()
for _ in range(n):
    pin = stdin.readline().rstrip().split()
    proc.put((pin[0], int(pin[1])))

time = 0
while not proc.empty():
    p = proc.get()
    if p[1] > q:
        proc.put((p[0], p[1]-q))
        time += q
    else:
        time += p[1]
        print(p[0], time)


Measured memory_bytes: 13636
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = 1
while a[0] % 2 == 0:
  a[0] //= 2
  b *= 2
if b == 0:
  print(0)
else:
  for i in range(1,n):
    a[i] //= b
    if a[i] % 2 == 0:
      print(0)
      break
  else:
    m //= b//2
    lcm = a[0]
    for i in range(1,n):
      big,sml = lcm,a[i]
      while sml != 0:
        big,sml = sml,big%sml
      lcm *= a[i] // big
      if lcm > m:
        print(0)
        break
    else:
      m -= lcm
      ans = 1
      lcm *= 2
      ans += m // lcm
      print(ans)

Measured memory_bytes: 14400
#include<bits/stdc++.h>
#define ChenChuLing main
using namespace std;
int n,m;
int f[100004],a[100004];
int Find(int x){return f[x]==x?x:f[x]=Find(f[x]);}
vector<int>G[100004];
set<int>tr[100004];
int ChenChuLing (){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=m;i++){
        int u,v,p,q;
        scanf("%d%d",&u,&v);
        p=Find(u);q=Find(v);
        if(p!=q)f[p]=q;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        tr[Find(i)].insert(i);
    }
    for(int i=1;i<=n;i++){
        int tg=Find(i);
        if(tr[tg].find(a[i])!=tr[tg].end())++ans;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main()
{
  int a, b;
  cin >> a;
  cin >> b;
  if (a > 9 || a <= 0 || b > 9 || b <= 0) {
    cout << -1 << endl;
  }
  else
    cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  long long A, B, K;
  cin >> A >> B >> K;

  long long a = A;

  if (A <= K) {
    a = 0;
    K = K - A;
  } else {
    a = A - K;
    K = 0;
  }

  long long b = B;

  if (B <= K) {
    b = 0;
  } else {
    b = B - K;
  }

  cout << a << " " << b << endl;
 
}

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


int main() {
  int n, k, tmp, answer = 0;
  cin >> n >> k;
  int m[n+1];
  for (int i = 0; i < n+1; i++) m[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    m[tmp]++;
  }
  sort(m, m+n+1, greater<int>());
  for (int i = k; i < n+1; i++) {
    if (m[i] == 0) break;
    answer += m[i];
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;
using LL = long long;

LL molt(int l, int n) {
    if (l == 0) return 0;
    if (l == 1) return 1;
    int a = (l - 1) * 2 - 1;
    LL ret = l;
    for (int i = 0; i < n; i++) {
        ret = ret * 2 + a;
    }
    return ret;
}

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

    string snake;
    cin >> snake;

    vector<int> O{0};
    int X = 0;

    if (snake[0] == 'x') {
        X++;
    } else {
        O[0] = 1;
    }

    for (int i = 1; i < snake.length(); i++) {
        if (snake[i] == 'x') {
            X++;
        } else {
            if (snake[i - 1] == 'x') {
                O.push_back(1);
            } else {
                O[O.size() - 1]++;
            }
        }
    }

    LL ans = X;
    for (auto o : O) {
        ans += molt(o, N);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // KEYENCE-A - Painting

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();

        int x = h > w ? h : w;
        
        int cnt = n / x;
        
        if (n % x > 0) cnt++;
        
        
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main ()
{
   int a,b,c,A,B;
   scanf("%d %d",&A,&B);
   a=A+B;
   b=A-B;
   c=A*B;
   if(a>b && b>c){
    printf("%d",a);
   }
   else if(b>a&&b>c){
    printf("%d",b);
   }
    else if (c>a&&c>b){
    printf("%d",c);
   } 
   else if(a==b||a>b){
    printf("%d",a);

   }



    return 0;
}

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

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<ll>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int main()
{
    FASTIO;
    int n; cin >> n;
    vl a(n);
    rep(i, 0, n-1) cin >> a[i];
    sort(all(a));

    ll ans = a.back();
    a.pop_back();

    deque<ll> q;
    q.pb(a.back());
    a.pop_back();

    while(a.size() > 1) {
        ll x = a.back(); a.pop_back();
        ll y = a.back(); a.pop_back();
        ans += 2ll*q.front();
        q.pop_front();

        q.push_back(x);
        q.push_back(y);
    }

    if(a.size() == 1) ans += q.front();
    cout << ans << nl;
    return 0;
}


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

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

  vector<int> num(N+10);
  for( int x = 1; x <= 100; x++ ){
    for( int y = 1; y <= 100; y++ ){
      for( int z = 1; z <= 100; z++ ){
        if( x*x+y*y+z*z+x*y+y*z+z*x <= N ) num[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for( int i = 1; i <= N; i++ ) cout << num[i] << endl;
 }


Measured memory_bytes: 3568