akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SUP ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
    SUP
    int n;
    cin >> n;
    long double x;
    map<pair<int, int>, int> cnt;
    for(int i=0; i<n; i++){
        cin >> x;
        long long tmp = llround(x*1e9);
        int two=0, five=0;
        while(tmp%2==0){
            two++;
            tmp/=2;
        }
        // tmp=x;
        while(tmp%5==0){
            five++;
            tmp/=5;
        }
        cnt[{two, five}]++;
    }
    long long ans=0;
    for(auto p1:cnt){
        for(auto p2:cnt){
            if(p1.first.first+p2.first.first>=18 and p1.first.second+p2.first.second>=18){
                if(p1<p2){
                    ans += (long long)p1.second*p2.second;
                } else if(p1==p2){
                    ans += (long long)p1.second * (p1.second-1)/2;
                }
            } 
        }
    }
    cout << ans;
} 



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

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

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(200002)


def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True


n, m = map(int, input().split())
x = [None] * n
G = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    G[l-1].append([r-1, d])
    G[r-1].append([l-1, -d])
res = True
for i in range(n):
    if x[i] is None:
        x[i] = 0
        res &= dfs(i)
print('Yes' if res==True else 'No')

Measured memory_bytes: 135196
/*
   Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define pii pair < ll, ll >
#define vi vector < ll >
#define vb vector < bool >
#define vvi vector < vector < ll > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define min_pq(t) priority_queue < t, vector < t >, greater < t > >
#define max_pq(t) priority_queue < t >
#define pb push_back
#define ff first
#define ss second

ll mod_sum() { return 0ll; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1ll; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }

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

vvb all;

void generate(vb till_now, ll dep){
    if(dep == 0){
        all.pb(till_now);
        return;
    }
    till_now.pb(true);
    generate(till_now, dep-1);
    till_now.pop_back();
    till_now.pb(false);
    generate(till_now, dep-1);
}

ll solve(){
    ll n, m, x;
    cin >> n >> m >> x;
    vb boolvec;
    generate(boolvec, n);
    vi cost(n);
    vvi books(n, vi(m));
    for(ll i=0; i<n; i++){
        cin >> cost[i];
        for(ll j=0; j<m; j++)
            cin >> books[i][j];
    }
        
    ll mn = LINF;

    for(auto vec : all){
        vi know(m);
        ll cost_pat = 0;
        for(ll i=0; i<n; i++){
            if(vec[i]){
                for(ll j=0; j<m; j++)
                    know[j] += books[i][j];       
                cost_pat += cost[i];
            }
        }
        
        ll mnn = LINF;
        for(auto kn : know)
            mnn = min(mnn, kn);
        if(mnn >= x)
            mn = min(mn, cost_pat);
    }

    cout << (mn == LINF ? -1 : mn) << endl;

    return 0;
}

int main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}



Measured memory_bytes: 3804
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

class Problem {
    private int N;
    private ArrayList<Integer> b;

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        b = new ArrayList<>(N);
        for (int i = 0; i < N; i++) {
            b.add(sc.nextInt());
        }
    }

    void solve() {
        ArrayList<Integer> a = new ArrayList<>(N);

        for(int i = 0; i < N; i++) {
            if (b.get(i) > (i+1)) {
                System.out.println(-1);
                return;
            }
        }

        while (!b.isEmpty()) {
            int maxIndex = -1;
            for (int i = 0; i < b.size(); i++) {
                if (b.get(i) == (i+1) && i > maxIndex) {
                    maxIndex = i;
                }
            }
            if (maxIndex < 0) {
                System.out.println(-1);
                return;
            }
            a.add(0, b.remove(maxIndex));
        }
        for (Integer n: a) {
            System.out.println(n);
        }
    }
}

public class Main {
    public static void main(String[] args) {
        new Problem().solve();
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;
int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double time=60*h+m;
  long double pi = 3.141592653589793;
  long double ah=(time*360)/720;
  long double bh=(m*360)/60;
  long double x=abs(ah-bh);
  if(x>=180){
    x=360-x;
  }
  long double y=180;
  long double t=a*a+b*b-2*a*b*cos(pi/(y/x));
  cout<<fixed<<setprecision(13);
  cout<<sqrt(t)<<endl;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	void solve(){


		long double a;
		long double b;
		in(a,b);
		long double tmp = a*b;
		int tmpp = floor(tmp);
		out(tmpp);

			







	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int X;
    cin>>X;

    if(X>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No"<<endl;
    }

    



}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    double ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int pi=i;
        double pans=1.0/n;
        while(pi<k)pans/=2,pi*=2;
        ans+=pans;
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

/*入居者情報から、アパートの入居状況を表示する*/
/*棟数(b)：4、階数(f)：3、部屋数(r)：10*/
int main(){
	
	char c;
	int i,j,k,l;
	int youso_m,youso_n;
	int sum=0;
	int rowco[100][100]={0};
	int vector[100]={0};
	
	scanf("%d %d",&youso_n,&youso_m);
	
	for(i=0; i<youso_n; i++){
		for(j=0; j<youso_m; j++){
			scanf("%d%c",&rowco[i][j],&c);
			if(c == '\n'){
				break;
			}
		}
	}
	
	for(i=0; i<youso_m; i++){
		scanf("%d",&vector[i]);
	}

	
	for(i=0; i<youso_n; i++){
		for(j=0; j<youso_m; j++){
			sum += rowco[i][j] * vector[j];
		}
		printf("%d\n",sum);
		sum = 0;
	}
	
	return 0;
}




Measured memory_bytes: 2080
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    int n;
    int a[999]={};
    int b[999]={};
    int ans=0;
    int tmp=0;
    
    scanf("%d", &n);
    
    for(int i=1; i<n; i++){
        
        scanf("%d", &b[i]);
        
    }
    
    for(int i=1; i<=n; i++){
        
        a[i] = 999999;
        
    }
    
    for(int i=1; i<n; i++){
        
        if(a[i]>b[i]){
            
            a[i] = b[i];
            
        }
        
        if(a[i+1]>b[i]){
            
            a[i+1] = b[i];
            
        }
        
    }
    
    for(int i=1; i<=n; i++){
        
        ans += a[i];
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main()
{
  int n, cnt = 0;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    int p;
    cin >> p;
    if(p != i + 1)
      cnt++;
  }
  cout << (cnt == 2 || cnt == 0 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 3608
#! ruby -Ks

#配列の生成
height = []

10.times{
    #標準入力を整数に変換して配列に格納
    height.push(STDIN.gets.to_i)
}

#配列の並び替え
height.sort!

#height[height.size()-1]の省略と考えると分かり易い
p height[-1]
p height[-2]
p height[-3]

Measured memory_bytes: 5648
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    l = list(range(N+M-1))
    max_score = 0
    for comb in itertools.combinations(l, M-1):
        A = []
        n = 1
        for i in range(N+M-1):
            if i in comb:
                n+=1
            else:
                A.append(n)
        #print(A)
        score = sum([di if A[bi-1] - A[ai-1] == ci else 0 for ai, bi, ci, di in zip(a, b, c, d)])
        max_score = max(score, max_score)

    print(max_score)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()



Measured memory_bytes: 9296
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()

{
	string message;
	cin >> message;

	message.replace(2, 2, "18");

	cout << message << endl;

	return 0;
}


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

int main()
{
  int a, b; std::cin >> a >> b;
  std::string s; std::cin >> s;
  
  for (int i = 0; i <= a + b; i++)
  {
  	if ((i == a && s[i] != '-') || (i != a && (s[i] - '0' < 0 || s[i] - '0' > 9)))
    {
      std::cout << "No\n";
      return 0;
    }
  }
  
  std::cout << "Yes\n";
  
  return 0;
}

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

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

    int ans = 0;
    for(int i = 1; i < n + 1; i++){
        int count = 0;
        if(i % 2 == 0){
            continue;
        }
        for(int j = 1; j < i+1; j++){
            if(j % 2 == 0){
                continue;
            } 
            if(i % j == 0){
                count++;
            }
        }   
        if(count == 8){
            ans++;
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int A,B; cin>>A>>B;
	cout<<(ll)A*B/gcd(A,B)<<endl;
}


Measured memory_bytes: 256
Num = int(input())
Count = 0
Count_result = 0
result = 0
a = 0

for i in range(1,Num+1):
    a = i
    while a % 2 == 0  and  a / 2 > 0:
        a /= 2
        Count += 1
    if Count_result < Count:
        Count_result = Count
        result = i
    Count = 0
if Num == 1 :
    result = 1
print (result)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int N, M, a[100010], b[100010];

int main() {
  cin>>N>>M;
  REP(i,0,M){
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
  }

  int d[100010];
  REP(i,0,N) d[i] = 0;
  REP(i,0,M){
    if(a[i]!=0) d[a[i]]++;
    if(b[i]!=0) d[b[i]]++;
  }

  REP(i,1,N){
    if(d[i]%2 == 1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
int par[10001];
int root(int x){
  if(par[x]!=x){return root(par[x]);}
  else return x;
}
int same(int x,int y){
  if(root(x)==root(y)) return 1;
  else return 0;
}
void unite(int x,int y){
  if(root(x)==root(y)) return;
  else par[root(x)]=root(y);
}

signed main() {
rep(i,10001){par[i]=i;}
int n,q;cin>>n>>q;
int com,x,y;
rep(i,q){
  cin>>com>>x>>y;
  if(com==1){
    cout<<same(x,y)<<endl;
  }
  else{
    unite(x,y);
  }
}
}



Measured memory_bytes: 3180
N = int(input())
l = list(map(int, input().split()))
min_h = l[0]
is_possible = "Yes"
for i in range(N):
    if l[i] < min_h - 1:
        is_possible = "No"
        break
    min_h = max(min_h, l[i])

print(is_possible)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
    
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  int flag=0;
  
  while(c>=0 || a>=0)
  {
      c = c-b;
      
      if(c<=0 && a>0)
      {
          flag=1;
          break;
      }
      else
      a = a-d;
      
  }
  
  if(flag==1)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

bool issafe(int x,int y,int n,int m){
  return (x>=0 && y>=0 && x<n && y<m);
}

void dfs(string t,vector<string>& temp,int ind){
    
    if(ind==t.length())
    {
        temp.pb(t);
        return;
    }
    
    if(t[ind]=='?')
    {
        t[ind]='A';
        dfs(t,temp,ind+1);
        t[ind]='?';
    }
    dfs(t,temp,ind+1);
}

void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
        string s;
        cin>>s;
        
        string t="?KIH?B?R?";
        
        vector<string> temp;
        dfs(t,temp,0);
        int n=temp.size();
        
        forn(i,0,n){
            t=temp[i];
            string cur="";
            for(int j=0;j<t.length();j++){
                if(t[j]!='?')
                cur.pb(t[j]);
            }
            if(cur==s){
                cout<<"YES";
                return;
            }
        }     
        cout<<"NO";
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


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

int main()
{
    string s;
    cin >> s;
    long long ans = 1e9+7;

    for (int i = 0; i <= s.size() - 3; i++)
    {
        int x = stoi(s.substr(i, 3));
        ans = min(ans, llabs(x - 753));

        //cout << x << endl;
    }
    cout << ans << endl;
}

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

using namespace std;

bool lt(const tuple<string, int, int> &x1, const tuple<string, int, int> &x2)
{
  if (get<0>(x1) == get<0>(x2)) {
    return get<1>(x1) > get<1>(x2);
  } else {
    return get<0>(x1) < get<0>(x2);
  }
}

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

  vector<tuple<string, int, int> > v;

  for (int i = 0; i < n; i++) {
    string s;
    int p;
    cin >> s >> p;
    v.push_back(make_tuple(s, p, i+1));
  }
  sort(v.begin(), v.end(), lt);

  for (int i = 0; i < n; i++) {
    cout << get<2>(v[i]) << endl;
  } 

  return 0;
}


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

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  char    lpstr[ 1536 ];
  int     c = 0;
  char  * t;

  fgets ( lpstr, sizeof ( lpstr ), stdin );

  for ( t = strtok ( lpstr, " .,\n" ); t != NULL;
        t = strtok ( NULL,  " .,\n" ) )
  {
    const int len = strlen ( t );

    if ( 3 <= len && len <= 6 )
    {
      if ( c++ )  putchar ( ' ' );
      fputs ( t, stdout );
    }
  }
  puts ( "" );

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,m,mx1=0,mx2=0,ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i>0;i--)mx2=max(mx2,a[i]=((mx1=max(mx1,a[i]))-a[i]));
	for(int i=1;i<=n;i++)if(mx2==a[i])ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int x, a;

int main() {
	cin >> x >> a;
	
	cout << (x < a ? 0 : 10) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef double db;
typedef string str;
// head

int main(){
    int n,w;
    int V,W;
    cin  >>n>>w;
    int dp[101][10010];
    range(i,n){
        cin>>V>>W;
        range(j,w+1){
            if ((j-W)>=0){
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-W]+V);
            }
            else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout << dp[n][w]<<endl;

    

}


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

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

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	ll cntd = b / d - a / d;
	ll cntc = b / c - a / c;
	ll g = lcm(c, d);
	ll cntcd = b / g - a / g;
	ll sum = cntd + cntc - cntcd;
	
	
	cout << b - a  - sum;
	return 0;
	

}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i = 0; i < 3*n; i++)  cin >> a[i];

    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = n; i < 3*n-1; i+=2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
    int n, x;
    int count = 0;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(int i = 1; i <= n-2; i++){
            for(int j = i+1; j <= n-1; j++){
                for(int k = j+1; k <= n; k++){
                    if(i + j + k == x){
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
        count = 0;
    }
    return 0;
}


Measured memory_bytes: 3088
//Name: Stellar Performance of the Debunkey Family
//Level: 2
//Category: グラフ,Graph,最小全域木,Minimum Spanning Tree,MST
//Note:

/*
 * 最小全域木を求めればよい。
 *
 * このコードではKruskal法を用いている。
 * オーダーは O(M log M)。
 */
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Edge {
    int a, b, c;

    bool operator <(const Edge &e) const {
        return c < e.c;
    }
};

struct DisjointSet/*{{{*/
{
  vector<int> parent;

  int root(int x)
  {
    if (parent[x] < 0) {
      return x;
    } else {
      parent[x] = root(parent[x]);
      return parent[x];
    }
  }

  explicit DisjointSet(int n) : parent(n, -1) {}

  bool unite(int x, int y)
  {
    const int a = root(x);
    const int b = root(y);
    if (a != b) {
      if (parent[a] < parent[b]) {
        parent[a] += parent[b];
        parent[b] = a;
      } else {
        parent[b] += parent[a];
        parent[a] = b;
      }
      return true;
    } else {
      return false;
    }
  }

  bool find(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -parent[root(x)]; }
};/*}}}*/

bool solve() {
    int N, M;
    if(!(cin >> N >> M)) return false;
    if(!N && !M) return false;

    vector<Edge> edges(M);
    for(int i = 0; i < M; ++i) {
        Edge &e = edges[i];
        cin >> e.a >> e.b >> e.c;
    }
    sort(begin(edges), end(edges));

    DisjointSet ds(N);
    int ans = 0;
    for(const auto &e : edges) {
        if(ds.unite(e.a, e.b)) {
            ans += e.c;
        }
    }
    cout << ans << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1212
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B))
E=nlargest(k,(d+c for d in D for c in C))
print('\n'.join(map(str,E)))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    string s = "Christmas";
    while(n != 25){
        s += " Eve";
        n++;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

import math
sq=int(math.sqrt(m))//1

#計算量減らすために、予め約数のリスト用意。
yaku=[]
for i in range(1,sq+1):
  if m%i==0:
    yaku.append(i)
    yaku.append(m//i)
yaku.sort(reverse=True)

for i in yaku:
  if n*i<=m:
    print(i)
    exit()

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int k,a,b,mul,count=0;
    scanf("%d %d %d",&k,&a,&b);
    for(int i=1;i<=b;i++)
    {
        mul=k*i;
        if(mul>=a && mul<=b)
        {
            printf("OK\n");
            count++;break;
        }
    }
    if(count==0)
        printf("NG\n");
}


Measured memory_bytes: 1644
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  
  
  trace(A, n);
  /*

    your code

   */
  for(j = 2;j <= n;j ++)
    {
      key = A[j];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
      i = j - 1;
      
	while(i >= 0 && A[i] > key)
	  {
	    A[i+1] = A[i];
	    i = i - 1;
	  }
	    A[i + 1] = key;
	    trace(A,n);
    }
  

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

struct RmQ{
  //Ranged minimum Query

  int n;
  vector<int> node;
  //1-indexed

  RmQ(int size){
    int t=1;
    while(t<size){
      t*=2;
    }

    node.clear();
    node.resize(t*2,INT_MAX);
    n=t;
  }

  void update(int i,int val){
    i=i+n;
    node[i]=val;
    i/=2;

    while(i>0){
      node[i]=min(node[i*2],node[i*2+1]);
      i/=2;
    }
  }

  int find(int s,int t,int k=1,int left=0,int right=-1){
    if(right<0)right=n;

    if(right<=s||left>=t){
      return INT_MAX;
    }

    if(left>=s&&right<=t){
      return node[k];
    }

    return min(find(s,t,k*2,left,(left+right)/2),find(s,t,k*2+1,(left+right)/2,right));
  }
};

int main(void){
  int n,q,c,x,y,i;
  cin>>n>>q;

  RmQ tree(n);

  for(i=0;i<q;i++){
    scanf("%d %d %d",&c,&x,&y);
    //cin>>c>>x>>y;
    if(c==0){
      tree.update(x,y);
    }
    else{
      y++;
      printf("%d\n",tree.find(x,y));
    }
  }

  return 0;
}



Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> T;

int main() {
  ll L; cin >> L;
  ll r = 0;
  for (ll i = 0; i < 30; i++) {
    if (L >= 1 << i) {r = i;}
  }
  vector<T> es;
  for (ll i = 0; i < r; i++) {
    es.push_back(T(i+1,i+2,0));
    es.push_back(T(i+1,i+2,1 << i));
  }
  ll leng = 1 << r;
  for (ll i = r-1; i >= 0; i--) {
    if (L >> i & 1) {
      es.push_back(T(i+1,r+1,leng));
      leng += (1 << i);
    }
  }
  cout << r+1 << " " << es.size() << endl;
  for (ll i = 0; i < es.size(); i++) {
    cout << get<0>(es[i]) << " " << get<1>(es[i]) << " " << get<2>(es[i]) << endl;
  }
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int32_t(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}ll ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
constexpr int maxn = 1e6+10; // remember to calculate. if tle, check maxn first.
int vis[maxn];
int main()
{
    int n;
    cin >> n;
    int tp = 7, cnt = 1;
    vis[tp] = 1;
    while(1){
        if(tp % n == 0) {
            break;
        }
        cnt++;
        tp *= 10;
        tp += 7;
        tp %= n;
        if(vis[tp]) {
            cout << -1 << endl;return 0;
        }
        vis[tp] = 1;

    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 7544
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextInt()

    val numStudents = mutableListOf<St>()
    for (i in (1..N)) {
        numStudents.add(St(i, scanner.nextInt()))
    }

    val result = numStudents.sortedBy { it.numStudents }
        .map { it.shussekiBangou }
        .joinToString(" ")

    println(result)
}

private data class St(val shussekiBangou: Int, val numStudents: Int)

Measured memory_bytes: 78532
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char S[3005];
lli dp[3005][3005];
#define MOD (1000000007LL)

int main(void){
	int n;
	scanf("%d%s",&n,S);
	rep(i,n)dp[0][i] = 1;
	rep(i,n-1){
		lli s = 0;
		rep(j,n-i)s = (s + dp[i][j])%MOD;
		lli ns = 0;
		rep(j,n-i-1){
			ns = (ns + dp[i][j]) % MOD;
			if(S[i]=='>')dp[i+1][j] = (s - ns + MOD) % MOD;
			if(S[i]=='<')dp[i+1][j] = ns;
		}
	}
	printf("%lld\n",dp[n-1][0]);
	return 0;
}

Measured memory_bytes: 70016
# シカのAtCoDeerくんは二つの正整数a,bを見つけました。
# aとbの積が偶数か奇数か判定してください。
# メモ：発見したこと（Ctrl + /〔#をつけるショートカット〕)は、クリップボードにコピーしている状態では無効か!??

# aとbの定義
a,b=map(int,input().split())

# 積が奇数か偶数か
if ( a * b ) % 2 :
    print('Odd')
else:
    print('Even')

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0 && D == 0 && L == 0){
      break;
    }
    vector<int> x(T);
    for (int i = 0; i < T; i++){
      cin >> x[i];
    }
    vector<int> d(T + 1, 0);
    for (int i = 0; i < T; i++){
      if (x[i] >= L){
        d[i]++;
        d[min(i + D, T)]--;
      }
    }
    for (int i = 0; i < T; i++){
      d[i + 1] += d[i];
    }
    int ans = 0;
    for (int i = 0; i < T - 1; i++){
      if (d[i] > 0){
        ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3752
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	//S
	cout << fixed << a*(b*sin((c*M_PI)/180)) /2.0<< endl;
	//L
	cout << fixed << a+b+sqrt(a*a+b*b-2*a*b*cos((c*M_PI) / 180)) << endl;
	//h
	cout << fixed << b*sin((c*M_PI) / 180) << endl;

	return 0;
}

Measured memory_bytes: 3396
module MultiSet = struct
  module type S = sig
    type elt
    type t
    val empty : t
    val is_empty : t -> bool
    val mem : elt -> t -> bool
    val count : elt -> t -> int
    val add : elt -> t -> t
    val remove : elt -> t -> t
    val clear : elt -> t -> t
    val cardinal : t -> int
    val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
    val max_elt : t -> elt
  end

  module Make (EltMap : Map.S) : S with type elt = EltMap.key = struct
    type elt = EltMap.key
    type t = int EltMap.t

    let empty = EltMap.empty
    let is_empty = EltMap.is_empty
    let mem = EltMap.mem
    let count x m = try EltMap.find x m with Not_found -> 0
    let add x m = EltMap.add x (count x m + 1) m
    let remove x m =
      match EltMap.find x m with
      | 1 -> EltMap.remove x m
      | n -> EltMap.add x (n - 1) m
      | exception Not_found -> m
    let clear = EltMap.remove
    let cardinal m = EltMap.fold (fun _ -> ( + )) m 0
    let fold f = EltMap.fold (fun x n -> Array.fold_right f (Array.make n x))
    let max_elt m = fst (EltMap.max_binding m)
  end
end

module IntMultiSet = MultiSet.Make (Map.Make (struct
  type t = int
  let compare = compare
end))

let rec solve acc n xs =
  let x = IntMultiSet.max_elt xs in
  if x + acc <= n - 1 then acc
  else
    let cost = (x + acc + 2) / (n + 1) in
    solve (acc + cost) n (IntMultiSet.add (x - cost * (n + 1)) (IntMultiSet.remove x xs))

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun s a -> IntMultiSet.add a s) IntMultiSet.empty as_
  |> solve 0 n
  |> Printf.printf "%d\n"

Measured memory_bytes: 2688
import sys
N = str(input())
H = list(map(str, input().split()))
for i in range(len(H)-1):
  if int(H[i]) > int(H[i+1])+1:
    print('No')
    sys.exit()
  if int(H[i]) == int(H[i+1])+1:
    H[i+1] = int(H[i+1])+1
print('Yes')

Measured memory_bytes: 66380
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
using Graph=vector<vector<int>>;
int main(){
    int n,m;cin>>n>>m;
    int ans[n-1]={0};
 Graph G(n);
 for(int i=0;i<m;i++){
     int a,b;
     cin>>a>>b;
     a--;b--;
     G[a].push_back(b);
     G[b].push_back(a);
 }
 vector<int> dist(n,-1);
 queue<int> que;
 dist[0]=0;
 que.push(0);
 while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv:G[v]){
      if(dist[nv]!=-1)continue;
      ans[nv-1]=v+1;
      dist[nv]=dist[v]+1;
      que.push(nv);
    }
 }
 bool ok=true;
 rep(i,n-1)if(ans[i]==0)ok=false;
 if(ok){
 cout<<"Yes"<<endl;
for(int v=0;v<n-1;v++){
    cout<<ans[v]<<endl;
 }
 }
 else cout<<"No"<<endl;
}

Measured memory_bytes: 10484
char S[2001*2002];
m[4][2001*2002],H,W,z,d[4]={1,-1},k,i;

f(i){
	return m[k][i]=S[i]=='.'?m[k][i]?:1+f(i+d[k]):0;
}

main(t){
	scanf("%d%d ",&H,&W);
	for(d[2]-=d[3]=~W;i+~W*H;++i)
		S[i-~W]=getchar();
	for(;i--;z=fmax(z,t))
		for(t=k=0;k<4;++k)
			t+=f(i-~W,k);
	printf("%d",z-3);
}


Measured memory_bytes: 66688
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
N_orig = N
As = list(map(int,input().split()))
As.sort()

Bs = []
if N % 2 == 1:
    Bs.append(0)
    N -= 1
    b = 2
else:
    b = 1

while N > 0:
    Bs.append(b)
    Bs.append(b)
    N -= 2
    b += 2

if As != Bs:
    print(0)
else:
    print(pow(2, N_orig // 2, 1000000007))




Measured memory_bytes: 14008
# import itertools
# import math
import sys

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, K = map(int, input().split())
H = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()


if K >= len(H):
    print(0)
    sys.exit()

H.sort(reverse = True)

print(sum(H[K:]))

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

int main() {
	string s;
	while ( cin >> s ) {
		int ss = s.size();
		int cnt = 0;
		stack<char> stk;
		
		for (int i = 0; i < ss; ++i) {
			if ( !stk.empty() and stk.top() != s[ i ] ) {
				stk.pop();
				cnt++ ;
			}
			else {
				stk.push( s[ i ] );
			}
		}
		
		cout << cnt*2 << '\n';
	}
	return 0;
}

Measured memory_bytes: 512
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    ps = [list(map(str, readline().rstrip().decode('utf-8').split())) for _ in range(m)]
    ac = collections.defaultdict(int)
    wa = collections.defaultdict(int)
    for p, s in ps:
        if s == "WA":
            if p not in ac:
                wa[p] += 1
        if s == "AC":
            ac[p] += 1
    wac = 0
    for k, v in wa.items():
        if k in ac:
            wac += v
    print(len(ac), wac)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 72668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        long answer = 0;
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        long h = stdin.nextLong();
        long w = stdin.nextLong();
        for (long i = 0; i < n; i++) {
            long a = stdin.nextLong();
            long b = stdin.nextLong();
            if (h <= a && w <= b) answer++;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 24404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

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

int main(int argc, char *argv[]) {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    printf("%lld\n", llabs(n - 2)*llabs(m-2));
}


Measured memory_bytes: 256
x,n = map(int, input().split())
a = list(map(int,input().split()))
c = -1
b = 0
d = 101
e = 0
for w in range(103):
  if c not in a:
    b = abs(x - c)
    if b < d:
      d = b
      e = c
      c += 1
    else:
      c += 1
  else:
    c += 1
print(e)

Measured memory_bytes: 9128
from collections import deque

H, W = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

C = [list(input()) for i in range(H)]
inf = float("inf")
for i in range(H):
    for j in range(W):
        if C[i][j] == ".":
            C[i][j] = 0
        else:
            C[i][j] = 1
d0 = [[1, 0], [0, 1], [-1, 0], [0, -1]]
d1 = [[-2, -2], [-2, -1], [-2, 0], [-2, 2], [-1, 2], [0, 2], [-2, 1], [-1, -2], [-1, -1], [-1, 1], [0, -2], [1, -2], [1, -1], [1, 1], [1, 2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]
# d1 = [[i, j] for i in range(-2, 3) for j in range(-2, 2)]
dist = [[inf] * W for i in range(H)]
dist[sx][sy] = 0
que = deque([[0, sx, sy]])
while que:
    L, x, y = que.popleft()
    # if x == gx and y == gy:
    #     break
    for dx, dy in d0:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and L + C[nx][ny] < dist[nx][ny] and C[nx][ny] == 0:
            dist[nx][ny] = L + C[nx][ny]
            que.appendleft([L, nx, ny])
    for dx, dy in d1:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and L + C[nx][ny] + 1 < dist[nx][ny] and C[nx][ny] == 0:
            dist[nx][ny] = L + C[nx][ny] + 1
            que.append([L + 1, nx, ny])


ans = dist[gx][gy]
if ans == inf:
    print(-1)
else:
    print(ans)


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

int main() {
	int N[3];
	cin >> N[0] >> N[1] >> N[2];
	int change = 0;
	int maxNum = 0, sum = 0;
	for (int i = 0;i < 3;i ++) {
		maxNum = max(maxNum, N[i]);
		sum += N[i];
	}
	if ((3 * maxNum - sum) % 2 == 0) cout << ((3 * maxNum - sum) >> 1);
	else cout << ((3 * maxNum + 3 - sum) >> 1);
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

明らかに、全ての数字をmax(A,B,C)にするべき
ただし、一度の操作でsum(A,B,C)は2増えるので、3max(A,B,C)-sum(A,B,C)が奇数なら全ての数字をmax(A,B,C)+1にする
*/

Measured memory_bytes: 256