akhauriyash/Code-Regression huggingface dataset:
H, W = gets.split.map &:to_i
A = ([*$<].join.chars - ["\n"]).group_by(&:itself).values.map(&:size).sort.reverse

n = (H / 2) * (W / 2)
if A.map{|a|a/4}.inject(:+) < n
  puts:No
  exit
end
i = 0
n.times{
  i += 1 while A[i] < 4
  A[i] -= 4
}
puts (if H.even? && W.even?
  A.all?{|a|a == 0}
else
  m = (H * W - n * 4) / 2
  if A.map{|a|a/2}.inject(:+) < m
    puts:No
    exit
  end
  i = 0
  m.times{
    i += 1 while A[i] < 2
    A[i] -= 2
  }
  if H.even? || W.even?
    A.all?{|a|a == 0}
  else
    *_0, _1 = A.sort
    _0.all?{|a|a == 0} && _1 == 1
  end
end)?:Yes: :No


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

int main(){
  int K,X;
  cin >> K >> X;
  
  bool ans = false;

  if(500 * K >= X) ans = true;


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

  return 0;
}


Measured memory_bytes: 764
/****************************>>>>HEADFILES<<<<****************************/
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
using namespace std;
/****************************>>>>>DEFINE<<<<<*****************************/
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define FIN             freopen("input.txt","r",stdin)
#define rep(i,a,b)      for(int i = a;i <= b;i++)
#define MP(a,b)         make_pair(a,b)
#define PB(a)           push_back(a)
#define fst             first
#define snd             second
/****************************>>>>>>DEBUG<<<<<<****************************/
#define out(x)          cout<<x<<"  ";
/****************************>>>>SEPARATOR<<<<****************************/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,l,r;
    cin>>n>>l>>r;
    cout<<max(0ll,(n-1)*(r-l)+l-r+1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int x,y;
  cin>>x>>y;
  if(x==y||x%y==0){
    cout<<-1<<endl;
  }else{
    cout<<x*y-x<<endl;
  }
  return 0;
}


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

    for(int i=9; i>0; i--){
        if( N/i < 10 && N%i == 0){
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<pair<int,int>> t(n);
	vector<int> akt(n);
	for(int i=0;i<n;++i) {
		cin>>t[i].first;
		akt[i]=t[i].first;
		t[i].second=i;
	}
	sort(t.begin(), t.end());
	int ans=0;
	for(int i=0;i<n;++i) {
		int ez=akt[t[i].second];
		for(int j=t[i].second;j>=0 && akt[j];j--) akt[j]-=ez;
		for(int j=t[i].second+1;j<n && akt[j];j++) akt[j]-=ez;
		ans+=ez;
	}
	cout<<ans<<"\n";
	return 0;
}


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

using namespace std;

using ll = long long;

int main(void){
    ll h,w,k;
    ll label = 0;
    ll first_find = -1;

    cin >> h >> w >> k;

    vector<vector<ll>> field(h, vector<ll>(w,0));
    vector<vector<ll>> ans(h, vector<ll>(w,0));
    
    for(ll i=0; i<h; i++){
        ll find_berry = 0;
        for(ll j=0; j<w; j++){
            char ch;
            cin >> ch;

            if(ch=='#'){
                field[i][j] = 1;
                find_berry++;
                if(first_find==-1)
                    first_find = i;
            }else if(ch=='.'){
                field[i][j] = 0;
            }
        }
        if(find_berry>0){
            ll label_cnt = 0;
            for(ll j=0;j<w;j++){
                if(find_berry>label_cnt)
                    ans[i][j] = label+1;
                else
                    ans[i][j] = label;
                if(field[i][j]==1){
                    label_cnt++;
                    label++;
                }
            }
        }else if(i>0){
            for(ll j=0;j<w;j++){
                ans[i][j] = ans[i-1][j];
            }
        }
    }

    for(ll i=first_find-1; i>=0; i--){
        for(ll j=0;j<w;j++){
            ans[i][j] = ans[i+1][j];
        }
    }

    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int s;
    cin >> s;
    int a=s/100,b=s%100;
    if(a<=12 && a!=0){
      if(b<=12 && b!=0){
        cout << "AMBIGUOUS";
      }else cout << "MMYY";
    }else{
      if(b<=12 && b!=0){
        cout << "YYMM";
      }else cout << "NA";
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * 
 */


/**
 * @author Jnaneswar Reddy
 *
 */
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int n;
		Scanner scan =new Scanner(System.in);
		n=scan.nextInt();
		scan.nextLine();
		HashMap<String,Integer> m = new HashMap<>();
//		for(int i=0;i<4;i++)
//		{  String s1= scan.nextLine();
//			if(!m.containsKey(s1))
//			{
//				m.put(s1, 0);
//			}
//		}
		m.put("AC", 0);
		m.put("WA", 0);
		m.put("TLE", 0);
		m.put("RE", 0);
		
		
		for(int i=0;i<n;i++)
		{  String s1= new String(scan.nextLine());
			
		if(!m.containsKey(s1))
			{
				m.put(s1, 0);
			}
		else {
				m.put(s1,(m.get(s1)+1));
			
			
		}}
		
	          System.out.println("AC" +
	                             " x " + m.get("AC"));
	          System.out.println("WA" +
                      " x " + m.get("WA"));
	          
	          System.out.println("TLE" +
                      " x " + m.get("TLE"));
	          System.out.println("RE" +
                      " x " + m.get("RE"));
		
	}

}


Measured memory_bytes: 59680
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    System.out.println(((a==b)&&(b!=c))||((b==c)&&(c!=a))||((c==a)&&(a!=b))
                       ?"Yes":"No");
  }
}

Measured memory_bytes: 21332
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, k, q := nextInt(), nextInt(), nextInt()
	wins := map[int]int{}

	for i := 0; i < q; i++ {
		wins[nextInt()-1]++
	}

	for i := 0; i < n; i++ {
		if wins[i] > q-k {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 7296
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

ll calc(ll H){
    if(H==1) return 1;
    return 2*(ll)calc(H/2.0);
}

int main(int argc, const char * argv[]) {
    
//    // input from txt （提出時にこの箇所は削除すること）
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
//
    ll H;
    cin >> H;
    
    ll leaf_number = calc(H);
    ll depth = floor(log(H)/log(2));
    ll atack_depth = 0;
    
    for(ll i=0;i<depth;i++){
        atack_depth += pow(2,i);
    }
    
//    cout << "depth : " << depth << endl;
//    cout<< "atack_depth : " << atack_depth << endl;
//    cout<< "leaf_number : " <<leaf_number << endl;
    cout<< leaf_number+atack_depth << endl;
 
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans = "No";
  if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]

sumS = sum(S)
if sumS % 10 != 0:
  print(sumS)
else:
  arr = list(filter(lambda x:x % 10, S))
  if arr:
    print(sumS - min(arr))
  else:
    print(0)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }

xy_t P[110];
int main() {
	int N=0;
	double x, y;
	while (scanf("%lf,%lf", &x, &y) != EOF) { //入力ループは"\n"で抜ける
		P[N++] = xy_t(x, y);
	}

	double sum = 0.0;
	for (int i = 0; i + 2 < N; i++) {
		xy_t a = P[0], b = P[i + 1], c = P[i + 2];
		sum += cross_product(b - a, c - a) / 2;
	}
	printf("%.6f\n", abs(sum));
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) (v).begin(), (v).end()
#define P pair<int,int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll 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 {
        mint res(*this);
        return res/=a;
    }
};

mint table[200200];
void fact(){
    table[0] = table[1] = 1;
    for(ll i = 2; i < 200200; i++){
        table[i] = table[i - 1] * i;
    }
}

mint comb(ll n, ll r){
    return table[n] / table[r] / table[n - r];
}

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

     ll m = 0; // maximum people in a room
     if(k + 1 >= n) m = n;
     else m = k + 1;

     fact();
     mint ans(0);
     // i: number of zero
     for(int i = 0; i < m; i++){
         ans += comb(n,i) * comb(n - 1, i);
     }
     cout << ans.x << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
 
h,w = list(map(int,input().split()))
s1,s2 = list(map(int,input().split()))
f1,f2 = list(map(int,input().split()))
 
s1,s2 = s1-1,s2-1
f1,f2 = f1-1,f2-1
 
Q = [(s1,s2)]
V = [[0]*w for _ in range(h)]
G = []
ALL = [(s1,s2)]
V[s1][s2] = 1
 
for _ in range(h):
  tmp = list(input().rstrip())
  G.append(tmp)
 
count = 0
best = 0
 
while True:
  while Q:
    new_Q = []
    for node in Q:
      i,j = node[0], node[1]
      if V[i][j]==0:
        ALL.append((i,j))
        V[i][j] = 1

      if i-1>0:
        if V[i-1][j]==0 and G[i-1][j]=='.':
          V[i-1][j]=1
          new_Q.append((i-1,j))
          ALL.append((i-1,j))
 
      if j-1>0:
        if V[i][j-1]==0 and G[i][j-1]=='.':
          V[i][j-1]=1
          new_Q.append((i,j-1))
          ALL.append((i,j-1))
 
      if i+1<h:
        if V[i+1][j]==0 and G[i+1][j]=='.':
          V[i+1][j]=1
          new_Q.append((i+1,j))
          ALL.append((i+1,j))
 
      if j+1<w:
        if V[i][j+1]==0 and G[i][j+1]=='.':
          V[i][j+1]=1
          new_Q.append((i,j+1))
          ALL.append((i,j+1))
 
    Q = new_Q
 
  if V[f1][f2]==1:
    print(count)
    break
  else:
    count += 1
    part= []
    
    ALL = list(set(ALL))
 
    for node in ALL:
      i,j = node[0], node[1]
      
      for x in range(i-2,i+3):
        for y in range(j-2,j+3):
          if x>-1 and y>-1 and x<h and y<w and G[x][y] == '.' and V[x][y]==0:
            part.append((x,y))         	
       
    ALL = list(set(part))
    #print(ALL)
    Q = list(ALL)
    
    if (f1,f2) in ALL:
      print(count)
      break
 
    if len(ALL)==0:
      print(-1)
      break
      
    ALL = []
        


Measured memory_bytes: 136928
#include<iostream>
using namespace std;
int main()
{
	long long int n,a,b;
	cin>>n>>a>>b;
	long long int m;
	if(a==0)
	cout<<0;
	else
	{
		m=n/(a+b);
		if(n-m*(a+b)<=a)
		m=m*a+n-m*(a+b);
		else m=(m+1)*a;
		cout<<m;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define int64_t long long


int main() {
    string s;
    cin>>s;
    for(int i=0;i<3;++i){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    printf("Good\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void main()
{
	int x = 0;
	int y = 0;
	int i;
	
	for(i=0;;i++)
	{
		scanf("%d",&x);
		scanf("%d",&y);
		
		if((x==0)&&(y==0))
		{
			break;
		}
		
		if(((0<=x)&&(x<=10000))&&((0<=y)&&(y<=10000)))
		{
			if(x<=y)
			{
				printf("%d %d\n",x,y);
			}
			else
			{
				printf("%d %d\n",y,x);
			}
		}
	}
}



Measured memory_bytes: 2028
def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    houses = []
    for a in A:
        if not a in houses:
            houses.append(a)
        else:
            pass

    houses.sort()
    ans = 0
    for i in range(len(houses) - 1):
        ans += houses[i + 1] - houses[i]

    print(ans)


solve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,j,m,p,k,q;
	char c,w;
  while(cin>>n,n){
  	int a[26]={0},i,f=1,q=0;
    for(i=1;i<=n;i++){
	  cin>>c;
	  for(a[c-'A']++,m=j=0;j<26;j++)if(max(m,a[j])==a[j]){k=j;m=a[j];}
	  for(p=j=0;j<26;j++)if(j!=k)p=max(p,a[j]);
	  if(m>n-i+p&&f){
	  	q=i;
	  	w=k+'A';
	  	f=0;
	  }
	}
	if(q>0)cout<<w<<' '<<q<<endl;
	else cout<<"TIE"<<endl;
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int d,t,s;
	cin>>d>>t>>s;
	cout<<(t*s>=d?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 55
#define sigma 26

int n, i, dim, j;
char s[maxN];
int cnt[33], aux[33];

int main()
{
   // freopen("test.in","r",stdin);

    for (i = 0; i < sigma; i++) cnt[i] = 55;

    scanf("%d\n", &n);
    for (i = 1; i <= n; i++) {
        memset(s, 0, sizeof(s));
        memset(aux, 0, sizeof(aux));

        scanf("%s\n", s + 1);
        dim = strlen(s + 1);
        for (j = 1; j <= dim; j++) aux[ s[j] - 'a' ]++;

        for (j = 0; j < sigma; j++)
            cnt[j] = min(cnt[j], aux[j]);
    }

    for (i = 0; i < sigma; i++) {
        for (j = 1; j <= cnt[i]; j++)
            printf("%c", 'a' + i);
    }



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long n, a, b;
	cin>>n>>a>>b;
	if((b-a)%2==0) cout<<(b-a)/2;
	else{
		long long ans=a+(b-a-1)/2;
		ans=min(ans, n-b+1+(b-a-1)/2);
		cout<<ans;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> s;
  for (int i = a; i < a + k && i <= b; i++)
    s.insert(i);
  for (int i = b; i > b - k && i >= a; i--)
    s.insert(i);
  for (auto itr = s.begin(); itr != s.end(); itr++)
    cout << *itr << endl;
}


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


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=50;

ll d[nmax][nmax],a[nmax][nmax];
P edge[nmax];
ll n;
bool visited[nmax],allvisited;

void dfs(ll c){
    visited[c]=true;
    for(ll i=0;i<n;i++){
        if(d[c][i]==1&&!(visited[i])){
            dfs(i);
            }
        }
    }


int main(){
    ll m,a,b,ans;
    cin>>n>>m;
    ans=0;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        edge[i]=P(a-1,b-1);
    }
    for(ll ct=0;ct<n;ct++){
        for(ll ct2=0;ct2<n;ct2++){
            if(ct==ct2)d[ct][ct2]=0;
            else d[ct][ct2]=inf;
        }
    }
    for(ll ct=0;ct<m;ct++){
        d[edge[ct].first][edge[ct].second]=1;
        d[edge[ct].second][edge[ct].first]=1;
    }

    for(ll i=0;i<m;i++){
        d[edge[i].first][edge[i].second]=inf;
        d[edge[i].second][edge[i].first]=inf;

        for(ll j=0;j<n;j++)visited[j]=false;
        dfs(0);

        allvisited=true;
        for(ll i=0;i<n;i++){
            if(!(visited[i])){
                allvisited=false;
                break;
            }
        }
        if(!(allvisited)) ans++;


        d[edge[i].first][edge[i].second]=1;
        d[edge[i].second][edge[i].first]=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    s, t = read()
    result = think(s, t)
    write(result)


def read():
    return read_line(), read_line()


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s, t):
    # create dp table
    local_s = ' ' + s  # for convenience
    local_t = ' ' + t
    dp = [[0 for x in range(len(local_s))] for y in range(len(local_t))]

    for y, ct in enumerate(local_t):
        for x, cs in enumerate(local_s):
            if x == 0 or y == 0:
                dp[y][x] = 0
            else:
                if local_s[x] == local_t[y]:
                    dp[y][x] = dp[y - 1][x - 1] + 1
                else:
                    dp[y][x] = max(dp[y - 1][x], dp[y][x - 1], dp[y - 1][x - 1])

    # scan dp table backward
    x = len(dp[0]) - 1
    y = len(dp) - 1
    buf = ''

    while x > 0 and y > 0:
        if local_s[x] == local_t[y]:
            buf += local_s[x]
            x -= 1
            y -= 1
        else:
            if dp[y][x] == dp[y - 1][x]:
                y -= 1
            else:
                x -= 1

    buf = list(buf)
    buf.reverse()
    return ''.join(buf)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 121308
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)
#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)
#define mize(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)
#define shl(k) ((k) << 1)
using namespace std;

const int N = 5005;
int n, a[N], g[N][N], e[N], G[N];
int64_t f[N][N], F[N], INF = 1e15;
vector<int> ke[N];

void dfs(int u, int p)
{
    for(int v: ke[u]) if (v != p) {
        dfs(v, u);
        e[u] += e[v] + 1;
    }

    int m = 0;
    f[u][0] = a[u];
    g[u][0] = (a[u] > 0);

    for(int v: ke[u]) if (v != p) {
        FOR(i, 0, m+e[v]+1) F[i] = INF, G[i] = 0;

        FOR(i, 0, m) FOR(j, 0, e[v]) {
            mize(F[i+j], f[u][i] + f[v][j]);
            if (f[v][j] < 0 || g[v][j]) mize(F[i+j+1], f[u][i]);
            if (g[u][i]) {
                if (g[v][j]) G[i+j] = 1;
                if (f[v][j] < 0) G[i+j+1] = 1;
            }
        }

        m = m + e[v] + 1;
        FOR(i, 0, m) f[u][i] = F[i], g[u][i] = G[i];
    }
}
int main()
{
    ios::sync_with_stdio(); cin.tie(0);

    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n-1) {
        int u, v; cin >> u >> v;
        ke[u].pb(v); ke[v].pb(u);
    }

    dfs(1, 0);
    FOR(i, 0, n-1) if (f[1][i] < 0 || g[1][i]) {
        cout << i; return 0;
    }
}


Measured memory_bytes: 293504
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

long long GCD(long long m,long long n){
    if(n == 0) return m;
    else return GCD(n,m % n);
}

long long LCM(long long m,long long n){
    long long g = GCD(m,n);
    return m / g * n;
}

signed main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int tmp = LCM(a[0], a[1]);
    for(int i = 2; i < n; i++){
        tmp = LCM(tmp, a[i]);
    }
    int mother = 0;
    REP(i,n){
        mother += tmp / a[i];
    }
    cout << setprecision(12) << (double)tmp / (double)mother << endl;
}

Measured memory_bytes: 256
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
 
def solve():
  n = inp()
  c = 0
  for i in range(n):
      if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:
          c = c + i + 1
  print(c)
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()


Measured memory_bytes: 67484
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),a=in(),b=in();
    cout<<min(b,a*n);
}


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

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define debug(x) cout << #x << "=" << (x) << endl;

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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int q;
  cin >> q;
  while(q--){
    int num,ct=0;
    cin >> num;
    while(num>=10){
      int ma=0,digit=0,n=num;ct++;
      while(n!=0)
      {digit++;n/=10;}
      int p10=1;
      for(int i=1;i<digit;i++)
      {
        p10*=10;
        ma=max(ma,num%p10*(num/p10));
      }
      if(ma==num){cout << -1 << endl;break;}
      num=ma;
    }
    cout << ct << endl;
  }
}

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



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

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

  if (N % 1111 == 0) { /* AAAA */
    cout << "Yes" << endl;
  }
  else if ((N - N % 10) % 111 == 0) { /* AAAa */
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int a,b,c,k;cin>>a>>b>>c>>k;
 	while(b<=a){
 		b*=2;
 		k--;
 	}
 	while(c<=b){
 		c*=2;
 		k--;
 	}
 	if(k>=0){
 		cout<<"Yes"<<endl;
 	}
 	else{
 		cout<<"No"<<endl;
 	}
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n,t ;cin>>n>>t;
    vector<pair<int,int>> p;
    FOR(n){
        int c,tt;
        cin >>c>>tt;
        if(tt<=t){
            p.push_back(make_pair(c,tt));
        }
    }
    sort(p.begin(),p.end());
    if (p.size()==0) COUT("TLE");
    else  COUT(p[0].first);
    
    //FOR(p.size()){
    //   cout << p[i].first << " " << p[i].second<<endl;
    //}

    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}

int main(){
	ll h,w;cin>>h>>w;
	ll ans=INF;

	for(ll i=1;i<h;i++){
		ll MAX=0,MIN=INF;
		MAX=MIN=i*w;

		MAX=max(MAX,(h-i)*((w+(w%2))/2));
		MIN=min(MIN,(h-i)*((w)/2));

		ans=min(ans,MAX-MIN);
	}
	
	for(ll i=1;i<w;i++){
		ll MAX=0,MIN=INF;
		MAX=MIN=i*h;

		MAX=max(MAX,(w-i)*((h+(h%2))/2));
		MIN=min(MIN,(w-i)*((h)/2));

		ans=min(ans,MAX-MIN);
	}


	for(ll i=1;i<h;i++){
		ll MAX=i*w,MIN=i*w;

		MAX=max(MAX,w*((h-i+(h-i)%2)/2));
		MIN=min(MIN,w*((h-i)/2));

		ans=min(ans,MAX-MIN);
	}

	for(ll i=1;i<w;i++){
		ll MAX=i*h,MIN=i*h;

		MAX=max(MAX,h*((w-i+(w-i)%2)/2));
		MIN=min(MIN,h*((w-i)/2));

		ans=min(ans,MAX-MIN);
	}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  double x;
  string u;

  cin >> N ;
  double sum = 0;
  for (int i = 0; i < N; i++){
    cin >> x >> u ;
    if (u == "JPY"){
      sum += x;
    } else {
      sum += x * 380000.0;  
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


int edit_distance(string s,string t){
  int n=s.size(),m=t.size();
  vector< vector<int> > dp(n+2,vector<int>(m+2,n+m));
  dp[0][0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      chmin(dp[i+1][j],dp[i][j]+1);
      chmin(dp[i][j+1],dp[i][j]+1);
      chmin(dp[i+1][j+1],dp[i][j]+(s[i]!=t[j]));
    }
  }
  return dp[n][m];
}

const int LOCAL = 0;
string ANS = "Atcod3rIsGreat";
int ask(string T){
  cout<<"? "<<T<<endl;
  if(LOCAL) return edit_distance(ANS,T);
  int ans;
  cin>>ans;
  return ans;
}

void answer(string S){
  cout<<"! "<<S<<endl;
  if(LOCAL) assert(S==ANS);
  exit(0);
}


//INSERT ABOVE HERE
signed main(){
  string B;
  for(int i=0;i<26;i++) B+=char('a'+i);
  for(int i=0;i<26;i++) B+=char('A'+i);
  for(int i=0;i<10;i++) B+=char('0'+i);

  const int L = 128;
  int len=0;
  vector<string> ss(B.size());
  for(int i=0;i<(int)B.size();i++){
    ss[i]=string(L-ask(string(L,B[i])),B[i]);
    len+=ss[i].size();
  }

  using P = pair<int, string>;
  priority_queue<P, vector<P>, greater<P> > pq;
  for(int i=0;i<(int)B.size();i++)
    if(!ss[i].empty()) pq.emplace(ss[i].size(),ss[i]);

  while(pq.size()>1){
    string X=pq.top().second;pq.pop();
    string Y=pq.top().second;pq.pop();
    string Z;
    while(!X.empty() and !Y.empty()){
      string P=Z+Y[0]+X;
      if(ask(P)==len-(int)P.size()){
        Z+=Y[0];
        Y.erase(Y.begin());
      }else{
        Z+=X[0];
        X.erase(X.begin());
      }
    }
    Z+=X+Y;
    pq.emplace(Z.size(),Z);
  }

  answer(pq.top().second);
  return 0;
}


Measured memory_bytes: 3808
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let mut l: Vec<i64> = (0..n).map(|_| read()).collect();

    l.sort();
    let mut ans = 0;

    for i in 0..l.len() {
        for t in i+1..l.len() {
            for k in t+1..l.len() {
                if l[i] == l[t] || l[k] == l[t] || l[i] == l[k]{
                    continue;
                }
                if l[i] + l[t] > l[k] {
                    ans += 1;
                }
            }
        }
    }

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


Measured memory_bytes: 2148
n,t=map(int,input().split())

c=[]
for i in range(n):
  c_=list(map(int,input().split()))
  c.append(c_)
  
c.sort()

for i in range(n):
  if c[i][1]<=t:
    print(c[i][0])
    exit()
    
  else:
    continue
    
print('TLE')


Measured memory_bytes: 9100
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
p = int(readline())
if p % 2 == 1:
    print(0)
else:
    p //= 2
    ans = 0
    while p:
        p //= 5
        ans += p
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int a[100],d[100],f[100];
int inf=100000,t=0,n;
int v[100][100];
void bfs(int s){
    d[s]=0;
    a[s]=inf;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<n;i++){
            if(v[u][i]==1&&a[i]!=inf){
                a[i]=inf;
                q.push(i);
                d[i]=d[u]+1;
                //cout<<d[i]<<" "<<d[u]<<endl;
            }
        }
    }
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int tmp;
      cin>>tmp;
      v[u-1][tmp-1]=1;
    }
  }
  bfs(0);
  for(int i=0;i<n;i++)
      if(!a[i])d[i]=-1;
  for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<endl;
  }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,m,s,ans=1LL;
    cin>>n>>m;
    s=ll(sqrt(m))+1LL;
    ll p[s];
    memset(p,0,sizeof(p));
    for(ll i=2LL;i<s;i++){
        while(m%i==0){
            m/=i;
            p[i]++;
        }
    }
    if(m!=1)p[1]++;
    for(int i=1;i<s;i++){
        if(p[i])ans*=com(n-1+p[i],p[i]);
        ans%=mod;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    cout << (n - i + 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int i;
    int sum=0;
    for(i=1; i<n; i++) {
        sum+=i;
        if(sum>=n) {
            break;
        }
    }
    int lim=i;

    for(i=lim; i>=1; i--) {
        if(n>=i) {
            printf("%d\n", i);
            n-=i;
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int w,h,n;
	int x[100],y[100],a[100];
	int ans=0;
	int l,r,u,d; //黒く塗られた部分と白く塗られた部分の境目
	
	cin>>w>>h>>n;
	l=0;
	d=0;
	r=w;
	u=h;
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i]>>a[i];
	
	for(int i=0;i<n;i++)
	{
		switch(a[i])
		{
			case 1:
				l=max(l,x[i]);
				break;
			case 2:
				r=min(r,x[i]);
				break;
			case 3:
				d=max(d,y[i]);
				break;
			case 4:
				u=min(u,y[i]);
				break;
		}
	}
	if(r-l<0 || u-d<0)
		ans=0;
	else
		ans=(r-l)*(u-d);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


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

string s="";
while(N>0){
   N--;
        s+=(char)(N%26+'a');
    
    N/=26;
}
reverse(all(s));
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        string s = to_string(i);
        if(s.size() % 2 == 1) cnt++;
    }
    cout << cnt;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main ()
{
__

int a,b,c;

cin >> a >> b >>c;

if(a-b > c ) cout << 0;

else cout << c-(a-b);

return 0;
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict

sys.setrecursionlimit(10**7)
A, B, K = map(int, input().split())


if K <= A:
    print(A-K, B)
else:
    print(0, max(0, B-(K-A)))


Measured memory_bytes: 3444
import Control.Monad
import Control.Applicative
import Data.List

main :: IO()
main = getLine >>= main' . read
    where
        main' 0 = return ()
        main' _ = do
            as <- map read . words <$> getLine :: IO [Int]
            print $ solve as 
            main

solve :: [Int] -> Int
solve as = head $ sort $ f $ sort as

f :: [Int] -> [Int]
f (_:[])= []
f (a:as) = ((head as) - a) : (f as)
 

Measured memory_bytes: 5480
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  // dorm[i][x]
  // i: the index of the dormitory building.
  // 0 <= x <= 9: the 10 rooms in the first floor
  // 10 <= x <= 19: the 10 rooms in the second floor
  // 20 <= x <= 29: the 10 rooms in the third floor
  int dorms[4][30] = {0};

  int n;
  cin >> n;
  int b, f, r, v;
  for (int i = 0; i < n; ++i) {
    cin >> b >> f >> r >> v;
    const int x = (f - 1) * 10 + r - 1;
    dorms[b-1][x] += v;
  }

  for (int i = 0; i < 4; ++i) {
    if (i > 0)
      printf("####################\n");
    for (int j = 0; j < 30; ++j) {
      if (j == 10 || j == 20)
        printf("\n");
      printf(" %d", dorms[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

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



int main() {
    int n;
    std::string s;
    cin >> n >> s;
    int ans = 0;
    for(int i=0; i<n-2; i++) {
        if ((s[i] == 'A')&&(s[i+1] == 'B')&&(s[i+2] == 'C')) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void)
{
    int n = 0, k = 0;
    cin >> n >> k;
    int num[100000] = {0};
    double p[100000];
    for (int i = 0; i < n; i++)
    {
        num[i] = i + 1;
        p[i] = 1.0 / n;
    }

    int loop = n;
    while (num[0] < k)
    {
        for (int i = loop - 1; i >= 0; i--)
        {
            if(num[i] >= k) {
                loop = i;
                continue;
            }
            num[i] *= 2;
            p[i] *= 0.5;
        }
    }

    double ans = 0.0;
    for(int i = 0; i < n; i++) {
        ans += p[i];
    }


    cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

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

int main()
{
	int N,K,T,U,V,L;
	cout.setf(ios::fixed);
	cout.precision(8);

	cin >> N >> K >> T >> U >> V >> L;
	int a[N+1], c=0, udist=0, vdist=0, vend;
	for (int i=0; i<N; i++)
		cin >> a[i];
	a[N] = L;

	udist = a[0];
	vend = a[0]+V*T;
	for (int i=0; i<N; i++)
	{
		while (c>0 && vend<a[i+1])
		{
			c--; vend += V*T;
		}

		if (c == 0 && vend<a[i+1])
		{
			vdist += vend - a[i];
			udist += a[i+1] - vend;
			vend = a[i+1] + V*T;
		}
		else
		{
			vdist += a[i+1] - a[i];
			if (c == K)
				vend = a[i+1] + V*T;
			else
				c++;
		}
	}
	cout << double(udist)/double(U) + double(vdist)/double(V) << endl;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Math.Pow(int.Parse(Console.ReadLine()), 3));
        }
    }
}


Measured memory_bytes: 13140
S = gets.chomp
T = gets.chomp
answer = "z" * (S.size + 1) 	# あえて+1

if S.size < T.size
 puts "UNRESTORABLE"
 exit
end

(S.size - T.size + 1).times do |i|
	flag = true

	(T.size).times do |j|
		if S[i+j] == "?" || S[i+j] == T[j]
			next
		else
			flag = false
			break
		end
	end
	
	if flag == true
		s = S.clone
		s[i, T.size] = T
		s.tr!('?', 'a')
		answer = s if s < answer
	end
end

if answer == "z" * (S.size + 1)
	puts "UNRESTORABLE"
else
	puts answer
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string s[10010];
    cin >> N;
    rep(i,0,N) cin >> s[i];
    ll tonari = 0, n_a = 0, n_b = 0, n_ab = 0;
    rep(i,0,N){
        rep(j,0,s[i].size()-1){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') tonari++;
        }
        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') n_ab++;
        else if(s[i][0] == 'B') n_b++;
        else if(s[i][s[i].size()-1] == 'A') n_a++;
    }
    ll ans = tonari;
    if(n_ab > 0){
        if(n_a > 0){
            ans++;
            n_a--;
        }
        if(n_b > 0){
            ans++;
            n_b--;
        }
    }
    ll tt = min(n_a, n_b);
    ans += tt;
    if(n_ab > 0) ans += n_ab - 1;
    print(ans);

    // ll tt = min(n_a, n_b);
    // ans += tt;
    // // print(ans);
    // ll vv = max(n_a, n_b) - tt;
    // if(n_ab > 0){
    //     ans += n_ab - 1;
    //     if(vv > 0) ans++;
    // }
    // print(ans);

    
}

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

int main() {
  int N,a,b,c,d,e,f,g,h,n;
  cin>>N;
  a=N/10000000;
  b=(N-a*10000000)/1000000;
  c=(N-a*10000000-b*1000000)/100000;
  d=(N-a*10000000-b*1000000-c*100000)/10000;
  e=(N-a*10000000-b*1000000-c*100000-d*10000)/1000;
  f=(N-a*10000000-b*1000000-c*100000-d*10000-e*1000)/100;
  g=(N-a*10000000-b*1000000-c*100000-d*10000-e*1000-f*100)/10;
  h=N-a*10000000-b*1000000-c*100000-d*10000-e*1000-f*100-g*10;
  n=N%(a+b+c+d+e+f+g+h);
  if(n==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;





signed main() {
    ll n;
    cin >> n;
    
    ll sgn = 0;
    ll m = 1e10;
    ll sum = 0;
    
    ll a = 0;
    rep(i, n) {
        cin >> a;
        if (a < 0) sgn ++;
        m = min(m, abs(a));
        sum += abs(a);
    }
    
    if (sgn % 2 == 1) sum -= m*2;
    
    mes(sum);
    
    
    
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << min({a*b, b*c, c*a}) << endl;
    }
    return 0;
}


Measured memory_bytes: 3600