akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    ll a;
    ld b;
    cin>>a>>b;
    ld ans = a*b;
    ll res = ans;
    cout<<res;

}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	for (int i = 0; i < 105; ++i) {
		if (i >= a && i <= b && i >= c && i <= d) ++ans;
	}
	if (c >= b || a >= d) {
		cout << 0;
		return 0;
	}
	cout << ans - 1;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    answer();
   }
   static void answer()
     {
       Scanner sc = new Scanner(System.in);
       
       while(true)
       {
         int h = sc.nextInt();
         
         int w = sc.nextInt();
         
         if(h == 0 && w == 0)break;
         
         for(int i = 0; i < h; i ++)
         {
           for(int j = 0; j < w; j ++)
           {
             if((i + j) % 2 == 0)
             {
               System.out.printf("#");
             }
             else System.out.printf(".");
           }
           System.out.println();
         }
         System.out.println();
       }
     }
 }
    


Measured memory_bytes: 60412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

vector<int> g[100005];
vector<ll> d(100005);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	rep(i, n) cin >> d[i];
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	int ans = 0;
	rep(i, n) {
		bool ok = true;
		ll tmp = d[i];
		for (auto& c : g[i]) {
			if (d[i] <= d[c]) ok = false;
		}
		if (ok) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9260
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    a,b = map(int, input().split())
    if b%a==0:
        print(a+b)
    else:
        print(b-a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
loop do
    h,w = gets.split(" ").map do |i| i.to_i end
    if h + w == 0 then
        break
    else
        (1..h).each do |high|
            (1..w).each do |wide|
                if high.odd? == true && wide.odd? == true then
                    print "#"
                elsif high.even? == true && wide.even? == true then
                    print "#"
                else
                    print "."
                end
            end
            puts ""
        end
        puts ""
    end
end

Measured memory_bytes: 8764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,f=0,ans=0;
  cin>>n>>m;
  if(n==1&&m==0){
    cout <<0;
    return 0;
  }
  else if(n==2&&m==0){
    cout <<10;
    return 0;
  }
  else if(n==3&&m==0){
    cout <<100;
    return 0;
  }
  vector<int>a(m);
  vector<int>b(m);
  vector<int>c(44);
  for(int i=0;i<m;i++){
    cin>>a.at(i)>>b.at(i);
  }
  for(int i=0;i<m;i++){
    if(a.at(i)==1 && b.at(i)==0){
      if(n==1){
        cout <<0;
        return 0;
      }
      cout <<-1;
      return 0;
    }
    for(int j=0;j<m;j++){
      if(a.at(i)==a.at(j) &&b.at(i)!=b.at(j)){
        cout <<-1;
        return 0;
      };
    }
    if(c.at(a.at(i))==0){
      ans=ans+b.at(i)*pow(10,n-a.at(i));
    }
    c.at(a.at(i))++;
  }
  if(n==2 && c.at(1)==0)ans=ans+10;
  else if(n==3 && c.at(1)==0)ans=ans+100;
  cout <<ans;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        Set<Integer> amari = new HashSet<>();
        int f = a % b;
        while (!amari.contains(f)) {
            amari.add(f);
            f = (f + a) % b;
        }

        if (amari.contains(c)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	
	int n;
	cin>>n;
	vector<double>dp(n+1);
	dp[0]=1;
	for(int coin=0;coin<n;coin++){
		double head_p;
		cin>>head_p;
		for(int i=coin+1;i>=0;i--){
			dp[i] = (i == 0 ? 0 : dp[i-1] * head_p) + dp[i] * (1 - head_p);
		}
		
	}
	double answer = 0;
    for(int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if(heads > tails) {
            answer += dp[heads];
        }
    }
    printf("%.10lf\n", answer);
}

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

typedef long long ll;

int main() {
#ifdef TooLazy
    freopen("in.txt", "r", stdin);
#endif /// TooLazy

    int x, a, b;
    while( cin >> x >> a >> b ) {
        int m = abs(x - a);
        int n = abs(x - b);

        if( m < n ) {
            puts("A");
        } else puts("B");
    }


    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<stack>
#include<queue>
#include<deque>
#include<list>

using namespace std;

int A1; 
int A2;
int A3;
int main()
{
	cin >> A1 >> A2 >> A3;
	int total = A1 + A2 + A3;
	if(total > 21)
	{
		printf("bust\n");
	}
	else
	{
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 0, b = 0, c = 0, rate[100] = {}, last = 0, k = 0, ansa = 0, ansb = 0, x = 0, y = 0;
	
	int onex = 0, tenx = 0, hunx = 0, thoux = 0,manx=0;
		int one = 0, ten = 0, hun = 0, thou = 0,man=0;
	std::cin >>a;
	
	bool okada = true;
	for (int i = 1; i <= a - 1; i++) {
	}
	if (a < 1000) {
		std::cout << "ABC" << std::endl;
	}
	else {
		std::cout << "ABD" << std::endl;
	}
}







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

namespace Free
{
    class Program
    {
        static bool Check(int[] a, int n, int m)
        {
            int b = 1;
            for (int i = 0; i < n; i++) b *= 2;
            for (int k = 0; k < b; k++)
            {
                int sum = 0;
                for (int i = 0; i < n; i++)
                {
                    if (((k >> i) & 1) == 1)
                    {
                        sum += a[i];
                        if (sum == m) return true;
                        if (sum > m) break;
                    }
                }
            }
            return false;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int q = int.Parse(Console.ReadLine());
            int[] M = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            foreach(var m in M)
            {
                Console.WriteLine(Check(A, n, m) ? "yes" : "no");
            }
        }
    }
}



Measured memory_bytes: 18292
N = float(input())
y = N/1.08 #すべて
x = int(y) #整数の箇所のみ(int)
z = float(x) #整数の箇所のみ(float)
flag=y-z
p=1/1.08
if flag==0:
 print(x)
elif flag+p > 1:
 print(x+1)
else:
 print(':(')


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 20:53:54 2019

@author: ctiuser
"""

N = int(input())
A = [int(input()) for i in range(N)]

ans = [A[0]]

for i in range(1,N):
    l,r = 0, len(ans)-1
    p = (r-l)//2 + 1
    if A[i] <= ans[r]:
        ans.append(A[i])
    elif A[i] > ans[l]:
        ans[l] = A[i]
    else:
        tmp = r
        while r - l > 1:
            if A[i] > ans[p]:
                tmp = p
                r = p
                p = (r-l)//2 + l
            else:
                l = p
                p = (r-l)//2 + l
        ans[tmp] = A[i]
#    print(i,ans)
print(len(ans))



Measured memory_bytes: 56152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a,b,c,d;
string s;
int main(){
	cin>>a>>b>>c>>d;
	if(d<=a || b<=c) puts("0");
	else printf("%d\n",min(b,d)-max(a,c));
}

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

int main() {
	string N;
	long long K;
	cin >> N >> K;
	long long S = N.size();
	if (K == 1) {
		cout << (N[0] - '0') + (S - 1) * 9 << endl;
	}
	if (K == 2) {
		long long ANS = 0;
		string T;
		for (int i = 0; i < S; i++) {
			for (int j = i + 1; j < S; j++) {
				for (int k = 1; k <= 9; k++) {
					for (int l = 1; l <= 9; l++) {
						T = "";
						for (int m = 0; m < S; m++) {
							if (m == i) T += '0' + k;
							else if (m == j) T += '0' + l;
							else T += '0';
						}
						if (T <= N) ANS++;
					}
				}
			}
		}
		cout << ANS << endl;
	}
	if (K == 3) {
		long long ANS = 0;
		string T;
		for (int i = 1; i < S; i++) {
			for (int j = i + 1; j < S; j++) {
				for (int k = 1; k <= 9; k++) {
					for (int l = 1; l <= 9; l++) {
						T = N[0];
						for (int m = 1; m < S; m++) {
							if (m == i) T += '0' + k;
							else if (m == j) T += '0' + l;
							else T += '0';
						}
						if (T <= N) ANS++;
					}
				}
			}
		}
		cout << ANS + (N[0] - '0' - 1) * 81 * (S - 1) * (S - 2) / 2 + 729 * (S - 1) * (S - 2) * (S - 3) / 6 << endl;
	}
}

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

long long  gcd(long long a, long long b)
{
	long long c;
	while (a != 0)
	{
		c = a;
		a = b%a;
		b = c;
	}
	return b;
}

int main()
{
	long long lnIn1, lnIn2;
	cin >> lnIn1 >> lnIn2;

	//Function 
	cout << gcd(lnIn1, lnIn2) << endl;
	//End of Function
	//system("pause");
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll prvi = abs(a - b);
    ll drugi = (v - w) * t;
    if(drugi >= prvi)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a&&b&&c>=1&&a&&b&&c<=100)
    {
        if(a!=b&&b!=c&&a!=c)
        {
            printf("3");
        }
        else if(a!=b|b!=c)
        {
            printf("2");
        }
        else
            printf("1");

    }
    return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	    int n,m;
        int a[100100];
	    scanf("%d%d",&n,&m);
	    int minx=0;
	    memset(a,0,sizeof(a));
	    for(int i=1;i<=m;i++){        
		    int x,y;        
		    scanf("%d%d",&x,&y);
		        if(minx==0){
			        minx=x;        
		        }
		        if(minx>x){
			        minx=x;
		        }
		    int min=a[x];
		    if(min==0){            
		    	a[x]=y;
		    }else if(min>y){
		    	a[x]=y;
		    }
	    }
	    int flag=1;
	    int k=a[minx];
	    for(int i=1;i<=n;i++){
		    if(a[i]==0){
			    continue;
		    }
		    if(i>=k){        
			    flag++;
			    k=a[i];
		    }else if(k>a[i]){    
			    k=a[i];
		    }
	    }
	    printf("%d\n",flag);
        return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def fullsearch(x, k):
    for l, r in zip(x, x[k-1:]):
        distance = abs(r - l)
        yield distance + abs(r)
        yield distance + abs(l)

def main():
    _, K = map(int, input().split())
    X = list(map(int, input().split()))



    print(min(fullsearch(X, K)))

main()

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


int main(void){
    // Your code here!
    int H, W;
    cin >> H >> W;
    int field[(H+2) * (W+2)];
    for(int i=0; i<(H+2)*(W+2); i++) field[i] = 0;
    
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        for(int j=0; j<W; j++){
            char ch = s.at(j);
            if(ch=='#'){
                field[(i+1)*(W+2)+j+1] = 1;
            }
        }
    }
    
    // //拡張した盤上表示
    // for(int i=0;i<(H+2);i++){
    //     for(int j=0;j<(W+2); j++){
    //         cout << field[(W+2)*i+j];
    //     }
    //     cout << endl;
    // }
    
    //数え上げて出力
    for(int i=0;i<(H+2);i++){
        for(int j=0;j<(W+2); j++){
            if ((i==0)or(i==H+1)or(j==0)or(j==W+1))continue;
            int index = i*(W+2) + j;
            int index_box[8] = {-W-3, -W-2, -W-1, -1, 1, W+1, W+2, W+3};
            if(field[index]== 1){
                cout << '#';
                continue;
            }
            int num = 0;
            for(int j = 0; j<8; j++){
                if (field[index + index_box[j]] == 1){
                    num++;
                }
            }
            cout << num;
        }
        if((i==0)or(i==H+1)){
            
        }else{
            cout << endl;
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  int X = N;
  int fX = 0;
  while(N>0){
   fX += N % 10;
    N /=10;
  }
  if( X % fX == 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 per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;

ll s;
bool check[1000000000];

ll f(ll x){
  return (x%2!=0? 3*x+1:x/2);
}
int main(int argc, char const *argv[]) {
  std::cin >> s;
  ll cnt = 1;
  rep(i,0,1000000000)check[i] = false;
  check[s] = true;
  while(true){
    ll tmp = f(s);
    cnt++;
    if(check[tmp])break;
    check[tmp]=true;
    s = tmp;
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 976768
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;
using VP = pair<int, pair<int, int> > ;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

const int maxE = 300010;
int parent[maxE];
int parent_rank[maxE];


int main() {
	string s, t;
	cin >> s >> t;
	int max_same = 0;

	for (int i = 0; i < s.size() - t.size() + 1; i++) {
		int count = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] == t[j]) {
				count++;
			}
		}
		max_same = max(count, max_same);
	}

	cout << t.size() - max_same << endl;

	return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int X = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
//		String S = sc.next();

		if(X < A) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}

	}
}


Measured memory_bytes: 21972
/*
  AtCoder Beginner Contest 097
  C - K-th Substring
*/

#include<iostream>
#include<string>
#include<vector>
using namespace std;

int comp(string& a, string& b) {
  if (a == b) return 0;

  int la = a.length(), lb = b.length();
  for(int i = 0; i < la && i < lb; ++i) {
    if (a[i] != b[i]) {
      return (a[i] > b[i]) ? 1 : -1; 
    }
  }
  
  return (la > lb) ? 1 : -1;
}

string s;
int K;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> s >> K;
  vector<string> v;

  int L = s.length();
  for (int l = 1; l <= K; ++l) {
    for (int i = 0; i <= L - l; ++i) {
      string ss = s.substr(i,l);

      if (v.empty()) v.push_back(ss);
      else {
        int idx;
        for(idx = v.size() - 1; idx >= 0; --idx) {
          int res = comp(ss, v[idx]);
          if (res == 0) break; // ss == v[idx]
          else if (res == 1) { // ss > v[idx]
            v.insert(v.begin()+idx+1, ss);
            break;
          }
        }        
        if (idx == -1) v.insert(v.begin(), ss);

        if (v.size() > K) v.pop_back();
      }
    }
  }

  cout << v[K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b>> c;
    cout << "A" << char(toupper(char(b[0]))) << "C" << endl;
    return 0;
}



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

int main(void){
    char str1[100], str2[100], str3[100];
    
    cin >> str1 >> str3;
    strcpy(str2, str1);
    
    strcat(str1, str2);
    if(strstr(str1, str3) == NULL) cout << "No" << endl;
    else cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

char s[1111111] = {};

int main(){
    scanf("%s", s);
    int l = strlen(s), sum = 0;
    for(int i=l-1;i;i--){
        if(s[i]<'5') sum += s[i] - '0';
        else if(s[i]>'5'){
            sum += '0' + 10 - s[i];
            s[i-1]++;
        }else {
            if(s[i-1]<'5'){
                sum += 5;
            }else {
                sum += 5;
                s[i-1]++;
            }
        }
    }
    sum += min(s[0] - '0', '0' + 11 - s[0]);
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1, y1, x2, y2;
	double ans;

	//座標を入力
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	//距離 = sqrt((y2 - y1)^2 + (x2 - x1)^2)
	ans = sqrt(pow(y2 - y1, 2.0) + pow(x2 - x1, 2.0));

	//結果を出力
	printf("%lf\n", ans);

	return 0;
}


Measured memory_bytes: 2112
def erase(line)
  (1..9).each do |i|
    5.downto(3).each do |j|
      line.gsub!(/#{i.to_s}{#{j}}/, '0'*j)
    end
  end
  line
end

def sum(board)
  board.flat_map{ |l| l.split('') }.map(&:to_i).reduce(:+)
end

def fall(board)
  5.times do |i|
    s = ""
    @h.times do |j|
      s += board[j][i]
    end
    s.gsub(/0/, '').rjust(@h, '0').split('').each_with_index do |n, j|
      board[j][i] = n
    end
  end
end

def solve(board)
  loop do
    score = sum(board)
    board.map!{ |l| erase(l) }
    fall(board)
    break if score == sum(board)
  end
  sum(board)
end

while (@h = gets.to_i) != 0
  board = @h.times.map{ gets.chomp.delete(' ') }
  score = sum(board)
  puts score - solve(board)
end

Measured memory_bytes: 10568
//#include<bits/stdc++.h>
//using namespace std;
//#define mem(a) memset(a,0,sizeof(a))
//#define dbg(x) cout<<#x<<" = "<<x<<endl
//#define ll long long
////不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
//multiset<double>s;
//void prt()
//{
//	for(multiset<double>::iterator it=s.begin();it!=s.end();it++)
//	{
//		prllf("%lf ",*it);
//	}
//	cout<<endl;
//}
//ll main()
//{
//	ll n,k;
//	cin>>n>>k;
//	for(ll i=0;i<n;i++)
//	{
//		double t;
//		scanf("%lf",&t);
//		s.insert(t);
//		prt();//************
//	}
//	for(ll i=0;i<k;i++)
//	{
//		multiset<double>::iterator it=--s.end();
//		double t=*it;
//		s.erase(it);
//		t/=2;
//		s.insert(t),s.insert(t);
//		prt();//************
//	}
//	double t=*(--s.end());
//	ll a=t;
//	if(t-a>=0.5)a++;
//	prllf("%d\n",a);
//	return 0;
//}

#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
ll len[200010];
ll M=0,n,k;
ll erfen()
{
	ll m=0,mid;
	if(!k)return M; 
	while(M>m)
	{
		mid=(M+m)>>1;
		ll s=0;
		for(ll i=0;i<n;i++)
		{
			if(len[i]<=mid)continue;
//			//ll t=1.*len[i]/(1.*mid+0.5)-1;
//			if(t<=0)t=1;
//			long double l=1.*len[i]/(t+1);
//			if(l-0.5>=mid)t++;
//			s+=t;
			if(mid==0){s=k+1;continue;}
			ll t=len[i]/(mid);
			if(t*(mid)==len[i])t--;
			s+=t;
		}
		//printf("m=%d M=%d mid=%d s=%d\n",m,M,mid,s);
		if(s>k)m=mid+1;
		else M=mid;
	}
	return (M+m)/2;
}
int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&len[i]);
		M=(len[i]>M?len[i]:M);
	}
	printf("%lld\n",erfen());
	return 0;
}

Measured memory_bytes: 5348
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n: usize = get_line().parse().unwrap();
    let aas: u64 = get_line().split_whitespace()
        .map(|e| e.parse::<u64>().unwrap())
        .fold(1, |sum, x| sum.saturating_mul(x));

    if aas <= 10u64.pow(18) {
        println!("{}", aas);
    } else {
        println!("-1");
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 6) {
    cout << 0 << endl;
  }
  else if (a < 13) {
    cout << b / 2 << endl;
  }
  else {
  	cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
INF=10**18
V,E=map(int,input().split())
G=[[INF]*V for i in range(V)]
for i in range(E):
    s,t,d=map(int,input().split())
    G[s][t]=d
ans=INF
dp=[[INF]*V for i in range(1<<V)]
dp[0][0]=0
    
for S in range(1<<V):
    for v in range(V):
        if S&(1<<v):
            for j in range(V):
                dp[S][v]=min(dp[S][v],dp[S-(1<<v)][j]+G[j][v])
print(dp[(1<<V)-1][0] if dp[(1<<V)-1][0]!=INF else -1)


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

int main(){
    int N,M;
    scanf("%d%d",&N,&M);
    N--;
    int X[M];
    for(int i = 0;i<M;i++){
        scanf("%d",&X[i]);
    }
    if(N>=M){
        printf("0");
        return 0;
    }

    sort(X,X+M,greater<int>());
    int Y[M-1];
    for(int i = 0;i<M-1;i++){
        Y[i] = X[i]-X[i+1];
    }
    nth_element(Y,Y+M-N-1,Y+M-1);
    int sum = 0;
    for (int i = 0;i < M-1-N;i++){
        sum += Y[i];
    }
    printf("%d\n",sum);

    return 0;
}

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

using lint = long long int;

int main(){
    lint A,B;
    set <lint> st;
    int K;

    cin >> A >> B >> K;
    for(lint i = A;i < min(A+K,B+1);i++){
        st.insert(i);
    }
    for(lint i = max(A,B-K+1);i<=B;i++){
        st.insert(i);
    }

    for(auto itr=st.begin();itr!=st.end();itr++){
        cout << *itr << "\n";
    }

    return 0;
}

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(){
  string s,t;
  cin >> s >> t;
  int n=s.size();
  string y=t.erase(n);
  if(s==y)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
#define int long long
#define M 1000000007
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int t1,t2,a1,a2,b1,b2,a,b,lst,nxt,ans;
inline int gcd(re int x,re int y){
	return x%y?gcd(y,x%y):y;
}
signed main(){
t1=read();
t2=read();
a1=read();b1=read();
a2=read();

b2=read();

if((a1>a2&&b1>b2)||(a1<a2&&b1<b2)){
	puts("0");
	return 0;
}

if(a1<a2)swap(a1,a2),swap(b1,b2);
a=(a1-a2)*t1;
b=(b2-b1)*t2;
if(a>b){
	puts("0");
	return 0;
}
if(a==b){
	puts("infinity");
	return 0;
}
int tmp=b-a;
ans=(a/tmp)*2;
if(a%tmp)++ans;
printf("%lld",ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	int p[4]={};
	p[a-1]++;
	p[b-1]++;
	p[c-1]++;
	p[d-1]++;
	p[e-1]++;
	p[f-1]++;
	std::sort(p, p+4);
	if(p[0]==1 && p[1]==1 && p[2]==2)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct StronglyConnectedComponents{
    vector<int> used,cmp,vs;
    vector<vector<int>> v,rv,g;
    StronglyConnectedComponents(int n):used(n),cmp(n,-1),v(n),rv(n){}

    void add_edge(int x,int y){
        v[x].push_back(y);
        rv[y].push_back(x);
    }
    void dfs(int x){
        used[x]=true;
        for(auto to:v[x])if(!used[to])dfs(to);
        vs.push_back(x);
    }

    void rdfs(int x,int k){
        cmp[x]=k;
        for(auto to:rv[x])if(cmp[to]==-1)rdfs(to,k);
    }

    int scc(){
        rep(i,used.size())if(!used[i])dfs(i);
        reverse(vs.begin(),vs.end());
        int k=0;
        for(auto x:vs)if(cmp[x]==-1)rdfs(x,k++);
        return k;
    }
    void build(){
        int k=scc();
        g.resize(k);
        rep(i,v.size()){
            for(auto& to:v[i]){
                int x=cmp[i],y=cmp[to];
                if(x!=y)g[x].push_back(y);
            }
        }
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    StronglyConnectedComponents scc(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        scc.add_edge(x, y);
    }
    scc.scc();
    int q;cin>>q;
    rep(i,q){
        int x,y;
        cin>>x>>y;
        cout<<(scc.cmp[x]==scc.cmp[y])<<endl;
    }
    return 0;
}



Measured memory_bytes: 4376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;

struct edge
{
	int from;
	int to;
	int cost;
};

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

	int sum = 0;
	if (L >= 0){
		for(int ni = 1; ni < N; ni++){
			sum += ni + L;
		}
	}
	else if (L <= - N) {
		for (int ni = 0; ni < N-1; ni++) {
			sum += ni + L;
		}
	}
	else {
		for (int ni = 0; ni < N; ni++) {
			sum += ni + L;
		}
	}

	printf("%d", sum);

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;
const int maxn=2e5+5;
string s;
int n,vis[maxn],ans;
int dp[maxn][2];
string a[maxn][2];
int main(){
	cin>>s;
	n=s.size();
	s=" "+s;
	string last="";
	for (int i=1;i<=n;i++){
		if (i>=2){
			a[i][1]="  ";
			a[i][1][0]=s[i-1],a[i][1][1]=s[i];
		}
		a[i][0]=" ";
		a[i][0][0]=s[i];
	}
	memset(dp,0xf3,sizeof(dp));
	dp[0][0]=dp[0][1]=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=1;j++){
			for (int k=0;k<=1;k++){
				//cout<<"print i "<<i-1-j<<endl;
				if (j!=k) {
					if (i-1-j>=0) dp[i][j]=max(dp[i][j],dp[i-1-j][k]+1);
				}
				else if (i-1-k>=0&&a[i][j]!=a[i-1-j][k]) dp[i][j]=max(dp[i][j],dp[i-1-j][k]+1);
			}
		}
	}
	cout<<max(dp[n][0],dp[n][1])<<endl;
}

Measured memory_bytes: 11448
#include <iostream>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

ll fact(int n) {
  ll ret{1};
  for (int i = 1; i <= n; ++i) {
    ret = (ret * i) % MOD;
  }
  return ret;
}

int main() {
  ll N, M, ans{};
  cin >> N >> M;
  if (N>M) swap(N,M);
  if (M==N) {
    ans = (((2 * fact(M)) % MOD) * fact(N) %MOD);
  } else if (N+1==M) {
    ans = ((fact(M) % MOD) * fact(N) % MOD);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;

	if (N < 105)
		cout << 0 << endl;

	else {
		int ans = 0;
		for (int i = 105; i <= N; i = i + 2) {
			int sum = 0;
			for (int j = 1; j <= i; j = j + 2) {
				if (i%j == 0)
					sum++;
			}
			if (sum == 8)
				ans++;
		}
		cout << ans << endl;	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
 
int main() {
  long long int n,k;
  cin>>n>>k;
  vector<long long int> h(n);
  rep(i,n) cin>>h[i];
  sort(h.rbegin(),h.rend());
  long long int ans=0;
  for(long long int i=k;i<n;i++){
  ans+=h[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef struct {
  int id;
  int parent;
  int depth;
  int child_num;
  int* children;
} node;

node* tree;

void update_depth(int node_id, int depth) {
  node nod = tree[node_id];
  tree[node_id].depth = depth;
  int child_num = nod.child_num;
  for (int i = 0; i < child_num; i++) {
    update_depth(nod.children[i], depth+1);
  }
}

int main() {
  int n, id, k, i,j;
  int* children;
  node nod,child;

  cin >> n;

  tree = new node[n];

  for (i = 0; i < n; i++) {
    tree[i].parent = -1;
  }

  for (i = 0; i < n; i++) {
    cin >> id >> k;

    nod = tree[id];
    nod.id = id;
    nod.child_num = k;

    children = new int[k];
    for (j = 0; j < k; j++) {
      cin >> children[j];

      tree[children[j]].parent = id;
    }

    nod.children = children;

    tree[id] = nod;
  }

  // depth
  for (i = 0; i < n; i++) {
    nod = tree[i];
    if (nod.parent == -1) {
      update_depth(i,0);
    }
  }

  // output
  for (i = 0; i < n; i++) {
    nod = tree[i];
    cout << "node " << nod.id << ": parent = " << nod.parent <<  ", depth = " << nod.depth << ", ";
    if (nod.parent == -1) {
      cout << "root";
    } else if (nod.child_num == 0) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << ", [";
    if (nod.child_num != 0) {
      cout << nod.children[0];
      for (j = 1; j < nod.child_num; j++) {
        cout << ", " << nod.children[j];
      }
    }
    cout << "]" << endl;
  }
  
  return 0;
}

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

using namespace std;

int main() {
  int a, b, c, res;
  scanf("%d %d %d", &a, &b, &c);
  res = a + b + c;
  res -= max(a, max(b, c));
  cout << res;
  return 0;
}

Measured memory_bytes: 256
n=0
s=0

while 1:
    n,s=map(int,input().split())
    if not n and not s:
        break
    ans=0
    for t in range(1024):
        tt=t
        su=0
        cnt=0
        for i in range(10):
            if tt%2:
                su+=i
                cnt+=1
            tt//=2
        if cnt==n and su==s:
            ans+=1
    print(ans)



Measured memory_bytes: 5588
#include<bits/stdc++.h>
#define FOR(i, n, m) for(int i = n; i < (int)m; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = std::int_fast64_t;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 1000000007;
constexpr long double eps = 1e-15;
template<typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
    os << to_string(p.first) << " " << to_string(p.second);
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, v.size()) {
        if(i) os << " ";
        os << to_string(v[i]);
    }
    return os;
}

vector<vector<int>> t;
vector<int> dp;

bool is_path(int v, int p) {
    bool ret = true;
    if((int)t[v].size() >= 3) return false;
    for(auto c: t[v]) {
        if(c == p) continue;
        ret = ret & is_path(c, v);
    }
    return ret;
}

int dfs(int v, int p) {
    int ret = 0;
    bool b = false;
    for(auto c: t[v]) {
        if(c == p) continue;
        if(is_path(c, v)) {
            if(!b) b = true;
            else ret++;
        } else {
            ret += dfs(c, v);
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    t.resize(n);
    dp.resize(n);
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        t[a].pb(b);
        t[b].pb(a);
    }
    int root = -1;
    REP(i, n) if((int)t[i].size() >= 3) root = i;
    if(root == -1) cout << 1 << endl;
    else cout << dfs(root, -1) << endl;
    return 0;
}


Measured memory_bytes: 9344
n = int(input())
a = list(map(int, input().split()))
a.sort()
MAX = 10 ** 6 + 1
flg_lst = [False] * MAX
res = 0
for i in range(n):
    if flg_lst[a[i]]:
        continue
    if i + 1 == n or a[i+1] != a[i]:
        res += 1
    for j in range(a[i], MAX, a[i]):
        flg_lst[j] = True
print(res)


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> ab(M);
    rep(i, M) {
        cin >> ab[i].first >> ab[i].second;
    }
    ab.emplace_back(200000, 200000);
    sort(ab.begin(), ab.end());

    int ans = 0, L = -1, R = -1;
    rep(i, M) {
        if (ab[i].first < R) {
            L = ab[i].first;
            R = min(R, ab[i].second);
        }
        else {
            L = ab[i].first;
            R = ab[i].second;
            //cout << i << ": " << L << ", " << R << endl;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

bool check(ll i, ll m, vector<ll>& S, vector<ll>& x)
{
  return S.at(m) - S.at(i) == (x.at(m) ^ x.at(i));
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> A.at(i);
  }
  vector<ll> S(N + 1, 0);
  for (ll i = 0; i < N; ++i)
  {
    S.at(i + 1) += S.at(i) + A.at(i);
  }
  vector<ll> x(N + 1, 0);
  for (ll i = 0; i < N; ++i)
  {
    x.at(i + 1) = x.at(i) ^ A.at(i);
  }
  vector<bool> ok(N, true);
  ll diff = 0;
  for (ll i = 1; i < N + 1; ++i)
  {
    if (x.at(i) + diff != S.at(i))
    {
      ok.at(i - 1) = false;
      diff = S.at(i) - x.at(i);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i)
  {
    ll l = i, r = N + 1;
    while (l + 1 != r)
    {
      ll m = (l + r) / 2;
      if (check(i, m, S, x))
      {
        l = m;
      }
      else
      {
        r = m;
      }
    }
    ans += l - i;

    // for (ll j = i + 1; j < N + 1; ++j)
    // {
    //   if (S.at(j) - S.at(i) == (x.at(j) ^ x.at(i)))
    //   {
    //     // cout << i << j << endl;
    //     ans += 1;
    //   }
    //   else
    //   {
    //     break;
    //   }
    // }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
while i=gets
 n=i.chomp.to_i
 s=0
 10.times do |a|
  10.times do |b|
   10.times do |c|
    10.times do |d|
     if a+b+c+d==n
      s+=1
     end
    end
   end
  end
 end
 puts s.to_i
end 

Measured memory_bytes: 6084
#include <iostream>
using namespace std;
int main(void){
    long long n, a, s=0, t=0, ans1 = 0, ans2 = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        s += a;
        t += a;
        if(i%2 == 0){
            if(s >= 0){
                ans1 += s+1;
                s = -1;
            }
            if(t <= 0){
                ans2 += 1-t;
                t = 1;
            }
        }else{
            if(s <= 0){
                ans1 += 1-s;
                s = 1;
            }
            if(t >= 0){
                ans2 += t+1;
                t = -1;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int use[8];
  int l[8];
  rep(i, n) cin >> l[i];
  int ans = INF;
  for(int i = 0; i < (1<<20); i++){
    int tmp = i;
    int cnt = -30;
    int lena = 0, lenb = 0, lenc = 0;
    rep(j, n){
      use[j] = tmp%4;
      if(use[j]) cnt+=10;
      if(use[j]==1){
        lena += l[j];
      }
      if(use[j]==2){
        lenb += l[j];
      }
      if(use[j]==3){
        lenc += l[j];
      }
      tmp = tmp/4;
    }
    if(lena==0 || lenb==0 || lenc==0) continue;
    ans = min(cnt+abs(a-lena)+abs(b-lenb)+abs(c-lenc), ans);
  }
  cout << ans <<endl;
}
    
    

Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 2000000

int size, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if ( size < 1 ) return;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int temp;
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i/2] < A[i] ){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
  }
}

void insert(int key){
  size++;
  A[size] = -1000000001;
  increaseKey(size, key);
}

main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }
  
  return 0;
}


Measured memory_bytes: 5616
#include <cstdio>
#include <algorithm>
#include <cstring>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

int a[100010];

int main()
{
	int n, cnt = 0;
	scanf("%d", &n);
	Rep(i, n) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	bool flag = true;
	int ty = 0;
	Rep(i, n - 1) {
		if (a[i] != a[i + 1]) {
			if (ty && ((a[i + 1] - a[i]) & 1)) {
				if (n - i == a[i]) flag = true;
				else if (n - i < a[i]) cnt ++;
			}
			else if (!ty && !((a[i + 1] - a[i]) & 1)) {
				if (n - (i + 1) == a[i]) flag = true;
				else if (n - (i + 1) < a[i]) cnt ++;
			}
			ty = 0;
		}
		else ty ^= 1;
	}
	if (!((a[n] + ty - cnt) & 1)) flag = false;
	
	if (!flag) printf("First\n");
	else printf("Second\n");
	
	return 0;
}


Measured memory_bytes: 512
MOD = (10**9) + 7
str = gets.chomp
dp_a = 0
dp_ab = 0
dp_abc = 0

dp_none = 1

a = 'A'
b = 'B'
c = 'C'
str.chars do |s|
  case s
  when a
    dp_a = (dp_a + dp_none)%MOD
  when b
    dp_ab = (dp_ab + dp_a)%MOD
  when c
    dp_abc = (dp_abc + dp_ab)%MOD
  else
    dp_abc = (dp_abc * 3 + dp_ab)%MOD
    dp_ab = (dp_ab * 3 + dp_a)%MOD
    dp_a = (dp_a * 3 + dp_none)%MOD
    dp_none = (dp_none * 3)%MOD
  end
end

p dp_abc

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

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

	int sum = 0, tmp = n;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}

	if (n%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> a(n+1, 0);
    rep(i, n-1){
        int x; cin >> x;
        a[x]++;
    }
    rep(i, n) {
        cout << a[i+1] << endl;
    }

}


Measured memory_bytes: 4052
H,W=map(int,input().split())
s=["#"*W]
m=0
for i in range(H):
    s.append(input())
    m+=s[-1].count(".")
s.append("#"*W)
for i in range(H+2):
    s[i]="#"+s[i]+"#"
l=[[-1]*(W+2) for i in range(H+2)]
l[1][1]=1
b=[(1,1)]
c=2
while b:
    a=[]
    for i in b:
        if s[i[0]][i[1]+1]=="." and l[i[0]][i[1]+1]==-1:
            l[i[0]][i[1]+1]=c
            a.append((i[0],i[1]+1))
        if s[i[0]-1][i[1]]=="." and l[i[0]-1][i[1]]==-1:
            l[i[0]-1][i[1]]=c
            a.append((i[0]-1,i[1]))
        if s[i[0]+1][i[1]]=="." and l[i[0]+1][i[1]]==-1:
            l[i[0]+1][i[1]]=c
            a.append((i[0]+1,i[1]))
        if s[i[0]][i[1]-1]=="." and l[i[0]][i[1]-1]==-1:
            l[i[0]][i[1]-1]=c
            a.append((i[0],i[1]-1))
    c+=1
    b=a
if l[-2][-2]==-1:
    print(-1)
else:
    print(m-l[-2][-2])

Measured memory_bytes: 3192
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
  
	public static void main(String[] args) {
	   
	    long a = sc.nextLong();
	    long b = sc.nextLong();
	    long c = sc.nextLong();
	    long k = sc.nextLong();
	    long ans = 0;
	    ans+=Math.min(a,k);
	    k-=Math.min(a, k);
	    k-=Math.min(b, k);
	    if(k > 0) {
	    	ans-=Math.min(k, c);
	    }
	    out.print(ans);
		out.close();
   }
	
	
}



Measured memory_bytes: 32928
#include <iostream>
#include <algorithm>

using namespace std;

int gcd(int,int);

int main (void) {
    int n;
    int a[100002];
    int left[100002], right[100002];

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

    left[0] = a[0];
    for (int i=1; i<n; i++) {
        left[i] = gcd(left[i-1], a[i]);
    } 

    right[n-1] = a[n-1];
    for (int i=n-2; i>=0; i--) {
        right[i] = gcd(right[i+1], a[i]);
    }

    int ans = max(left[n-2], right[1]);
    for (int i=1; i<n-1; i++) {
        ans = max(ans, gcd(left[i-1],right[i+1]));
    }

    cout << ans << endl;

}

int gcd(int a, int b) { 
    if (b>a) {
        int t = b;
        b = a;
        b = t;
    }
    int m = a%b;

    if (m == 0) {
        return b; 
    }
    return gcd(b, m); 
} 

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------
//union-find

const int MAX_V = limit;

int par[MAX_V];
int rank_[MAX_V];

void init(int n) {

    rep(i, n) {
        par[i] = i;
        rank_[i] = 0;
    }
}

int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]); //経路圧縮
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}

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

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;

    set<string> used;

    rep(n, k) {

        string Min = "zzzzzzzzzzzzzzzzzzzzzzzzzzz";

        rep(i, s.length()) {

            rep2(j, 5) {
                if (i + j > s.length()) continue;
                string sub = s.substr(i, j);
                if (used.count(sub)) continue;
                if (Min > sub) Min = sub;
            }
        }
        if (n == k - 1) cout << Min << endl;
        else used.insert(Min);
    }

    return 0;
}


Measured memory_bytes: 256