akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;
ll gcd(ll a, ll b){
	if(b != 0) return gcd(b, a % b);
	else return a;
}

int main(){
	int t;
	cin >> t;
	ll ans = 1;
	REP(i, t){
		ll x;
		cin >> x;
		ans = (ans / gcd(ans, x)) * x;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    string n;
    cin >> n;
    for(int i=0; i<n.size(); i++){
        if(n[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin >> n;
	vi a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    int result = 0;

    for(int i = 0; i < 30 ;i++){
        vi tempb(n);
        rep(j,n) tempb[j] = b[j] % (1<<(i+1));
        sort(tempb.begin(), tempb.end());
        ll total = 0;
        rep(j,n){
            int tempa = a[j] % (1<<(i+1));
            total += lower_bound(tempb.begin(), tempb.end(), 2*(1<<i) - tempa) - lower_bound(tempb.begin(), tempb.end(), (1<<i) - tempa);
            total += lower_bound(tempb.begin(), tempb.end(), 4*(1<<i) - tempa) - lower_bound(tempb.begin(), tempb.end(), 3*(1<<i) - tempa);
        }
        if(total%2 == 1) result += (1<<i);
    }
	
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	int a[3],sum=0;
	FOR(i,0,3)cin >> a[i];
	FOR(i,0,3)sum+=a[i];
	if(sum>=22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
}


Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    ll n,x,y,cnt=0,d,p;
    sfl(n),sfl(d);
    d = d*d;
    for(ll i=1;i<=n;i++){
        sfl(x),sfl(y);
        p = x*x+y*y;
        if(p<=d) cnt++;
    }
    pfl(cnt);
    return 0;
}

Measured memory_bytes: 3784
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const ll MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int n, m;
        cin >> n >> m;
        vector <int> graph[n + 1];
        for (int i = 0; i < m; ++i) {
            int u, v;
            cin >> u >> v;
            graph[u].push_back(v);
        }
        vector <int> dp(n + 1, -1);
        vector <bool> visited(n + 1, false);
        function <int(int)> dfs = [&] (int u) {
            visited[u] = 1;
            if (dp[u] != -1) return dp[u];
            int path_length = 0;
            for (int i = 0; i < (int)graph[u].size(); ++i) {
                path_length = max(path_length, dfs(graph[u][i]));
            }
            dp[u] = 1 + max(dp[u], path_length);
            return dp[u];
        };
        for (int i = 1; i <= n; ++i) {
            if (!visited[i]) {
                dfs(i);
            }
        }
        int mx = -1;
        for (int i = 1; i <= n; ++i) {
            mx = max(mx, dp[i]);
        }
        cout << mx - 1 << endl;
    };
    Solve();
    
    return 0;
}



Measured memory_bytes: 9600
using System;
using System.Diagnostics;

/// <summary>
/// 余弦定理で各針の端点の距離を求める
/// 角度は時間に対する変化割合から計算する
/// 角度はラジアンで計算する
/// </summary>
namespace C_Colon
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, H, M;
            var input = Console.ReadLine().Split(' ');
            A = int.Parse(input[0]);
            B = int.Parse(input[1]);
            H = int.Parse(input[2]);
            M = int.Parse(input[3]);

            // 割合で計算
            var h = (H * 60.0 + M) / 720.0;
            var m = M / 60.0;

            // 角度割合の差分を絶対値で取得
            var p = Math.Abs(h - m);

            // 角度が小さいほうを求める(小さいほうが内角となる)
            p = Math.Min(p, 1-p);

            // 割合を角度に変換
            var ang = p * 360;

            // 角度をラジアンに変換
            var rad = ang * Math.PI / 180;

            var result = A * A + B * B - 2 * A * B * Math.Cos(rad);
            result = Math.Sqrt(result);
            Console.WriteLine(result);
        }
    }
}


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

int main(void){
    int m,n,k;
    int sum = 0;
    cin >> n >> m >> k;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            sum = i*m+j*n - i*j*2;
            if(sum == k)break;
        }
        if(sum == k)break;
    }
    if(sum == k)cout << "Yes";
    else cout << "No";
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  
  int sqfloorN;
  sqfloorN = floor(sqrt(N));

  cout << sqfloorN * sqfloorN << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

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

}



const ll limit=28;
ll a[limit];
ll b[limit];

bool G[limit][limit];
ll N,M;

ll dfs(ll v,bool visited[limit]){
  bool ALL=true;
  
  rep(i,N){
    if(visited[i]==false){
      ALL=false;
    }
  }

  if(ALL){
return 1;//本体に1を足す
  }

  
  ll ret=0;
  
  rep(i,N){
    if(G[v][i]==true&&visited[i]==false){
      
      visited[i]=true;
      ret+=dfs(i,visited);
      visited[i]=false;
    }
  }

  return ret;
}

      
int main(){
    cin>>N>>M;
 
  
  rep(i,M){
    cin>>a[i]>>b[i];
    G[a[i]-1][b[i]-1]=G[b[i]-1][a[i]-1]=true;
  }
  bool visited[limit];
rep(i,N){
  visited[i]=false;
  
}
 
  visited[0]=true;
  
  cout<<dfs(0,visited)<<endl;
}


Measured memory_bytes: 256
s = input()
N = len(s)
num = float('inf')
for i in range(2):
    tmp = 0
    for j in range(N):
        if j % 2 == i:
            if s[j] == '1':
                tmp += 1
        else:
            if s[j] == '0':
                tmp += 1
    num = min(tmp, num)
print(num)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long int b[200001],a[200000];
int main()
{
    int n;
    cin>>n;
    b[n]=0;
    long long int sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=0;
    }
    for(int i=0; i<n; i++)
    {
       b[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]<=1)
        {
           continue;
        }
        else
        {
            sum+=b[i]*(b[i]-1)/2;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(b[a[i]]<=1)
        cout<<sum<<endl;
        else
        cout<<sum-b[a[i]]+1<<endl;
    }
    return 0;
}



Measured memory_bytes: 5760
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int t = sc.nextInt();
		int x = sc.nextInt();

		pr.println((double)t / x);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
"""
A - Signboard
https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_a

"""
import sys


def solve(s):
    ans = 0
    for ch1, ch2 in zip(s, 'CODEFESTIVAL2016'):
        if ch1 != ch2:
            ans += 1
    return ans


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
long long pre[111000],suf[111000],ans;
int a[110000],rr[111000],m,n,l,k,j;
char sg[1110000];
long long cmp(int l,int r)
{
	if(l>r)
	{
		return 0;
	}
	else
	{
		return suf[r]-suf[l-1];
	}
}
int main()
{
	cin>>m;
	cin>>a[1];
	pre[1]=a[1];
	suf[1]=a[1];
	for(int x=1;x<m;x++)
	{
	scanf(" %c %d",&sg[x],&a[x+1]);
		if(sg[x]=='+')
		{
			pre[x+1]=pre[x]+a[x+1];
		}
		else
		{
			pre[x+1]=pre[x]-a[x+1];
		}
			suf[x+1]=suf[x]+a[x+1];
	}
	rr[m]=m;
	ans=pre[m];
	for(int x=m-1;x>=0;x--)
	{
		if(sg[x]=='+')
		{
			rr[x]=rr[x+1];
		}
		else
		{
			rr[x]=x;
		}
	}
	for(int x=1;x<m;x++)
	{
		if(sg[x]=='-')
		ans=max(ans,pre[x]-cmp(x+1,rr[x+1])+suf[m]-suf[rr[x+1]]);
	}
	printf("%lld\n",ans);
}

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

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

int main() {
  int N, A, B;
  scanf("%d%d%d",&N,&A,&B);
  int t = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = fSOD(i);
    if (sum >= A && sum <= B) {
      t += i;
    }
  }
  printf("%d\n",t);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





string str;

void solve() {
  for (int bit = 0; bit < 8; ++bit) {
	int tmp = (int)(str[0] - '0');
	for (int i = 0; i < 3; ++i) {
	  if (bit & (1<<i)) tmp += (int)(str[i+1] - '0');
	  else tmp -= (int)(str[i+1] - '0');
	}
	if (tmp == 7) {
	  cout << str[0];
	  for (int i = 0; i < 3; ++i) {
		if (bit & (1<<i)) cout << '+';
		else cout << '-';
		cout << str[i+1];
	  }
	  cout << "=7" << endl;
	  return;
	}
  }
}


int main() {
  while (cin >> str) {
	solve();
  }
}


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

using namespace std;

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

	unsigned long long counter = 0;
	unsigned long long Acnt = 0, Bcnt = 0, ABcnt = 0;
	vector<string> v( N );
	for ( int i = 0; i < N; i++ )
	{
		cin >> v[i];

		bool Afind = false;
		string::size_type index, beforeIndex = 0;
		while ( ( index = v[i].find( "AB", beforeIndex ) ) != string::npos )
		{
			counter++;
			beforeIndex = index + 1;
		}

		if ( v[i].back() == 'A' )
		{
			Afind = true;
			++Acnt;
		}
		if ( v[i][0] == 'B' )
		{
			++Bcnt;
			if ( Afind )
			{
				ABcnt++;
			}
		}
	}

	// 出現頻度が少ない方に合わせる
	if ( Acnt > Bcnt )
	{
		counter += Bcnt;
	}
	else if ( Bcnt > Acnt )
	{
		counter += Acnt;
	}
	else
	{
		if ( Acnt == ABcnt )
		{
			if ( Acnt == 0 )
			{
				// 候補なし
			}
			else
			{
				counter += ( ABcnt - 1 );
			}
		}
		else
		{
			counter += Acnt;
		}
	}


	cout << counter << endl;

	return ( 0 );
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];
ll n,m;


int main()
{
    fast_cin;
    ll t;

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s,s1;
    ll lock=0,sum=0,co=0;

    cin>>n>>m;
    if(n>=10 || m>=10)
    cout<<"-1"<<endl;
    else
        cout<<n*m<<endl;

    s1.clear();
    vec.clear();

}



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

string calPlus( string a, string b )
{
    for( int i = a.size() - 1; i >= 1; i-- )
        a[i] += b[i] - '0';
    for( int i = a.size() - 1; i >= 1; i-- )
        if( a[i] - '0' > 9 )
        {
            a[i] -= 10;
            a[i-1]++;
        }
    int t = 0;
    while( a[t] == '0' )
        t++;
    return a.substr( t, a.size() );
}

int compareString( string a, string b )
{
    if( a.size() > b.size() )
        return 0;
    else if( a.size() < b.size() )
        return 1;
    else
    {
        for( int i = 0; i < a.size(); i++ )
        {
            if( a[i] > b[i] )
                return 0;
            else if( a[i] < b[i] )
                return 1;
            else;
        }
    }
    return 3;
}

int main()
{
    int cnt = 0;
    string s, t = "1";

    cin >> s;

    while( compareString( t, s ) != 0 )
    {
        t = calPlus( "0" + t, "0" + t );
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int k, a, b; cin >> k >> a >> b;
	bool res = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			res = true;
			break;
		}
	}
	if (res) puts("OK");
	else puts("NG");
	return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main(){
    int n;
    int h[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int answer=0;
    while(1){
        bool b=true;
        int i=0;
        for(;i<n;i++){
            if(h[i]>0){
                b=false;
                break;
            }
        }
        if(b) break;
        for(;i<n;i++){
            if(h[i]>0) h[i]--;
            else break;
        }
        answer++;
    }
    printf("%d\n",answer);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define endl "\n"
#define goat() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
typedef long long ll;
string lower(string s) {
	for (int i = 0; i < s.length(); i++) {
		if (s[i] >= 65 && s[i] <= 92) {
			s[i] += 32;
		}
	}
	return s;
}
ll arr[100][100];
int main() {
	goat();
	int n, i, c = 0;
	string s, t;
	cin >> s >> t;
	n = s.length();
	for (i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			c++;
		}
	}
	cout << c;
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

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

//２分探索　単調的に範囲が取れることに着目して思いつくべき。

int check(const string &s, const vector<pchar> &td, int pos) {
  //範囲for文という表現　配列やコンテナを簡潔に扱うためのfor文の別表現である。　
  // 範囲for文は配列または、begin()およびend()で表される範囲内の全ての要素に対して、処理を実行する。
  for (auto c : td) {
    if (c.first == s[pos]) {  //クエリに該当するものだった場合
      if (c.second == 'R')
        pos++;
      else if (c.second == 'L')
        pos--;

      if (pos < 0)
        return -1;
      else if (s.length() <= pos)
        return 1;
    }
  }

  return 0;
}

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

  string s;
  cin >> s;

  vector<pchar> td(Q);
  FOR(i, 0, Q) cin >> td[i].first >> td[i].second;

  int fall_left, fall_right;

  //[low,high) //[ok,ng)
  int low, mid, high;
  low = 0;
  high = N;

  while (high - low > 1) {  //右側に落ちる下限
    mid = (high + low) / 2;
    if (check(s, td, mid) == 1)
      high = mid;  //落ちた
    else
      low = mid;
  }

  fall_right = (N - 1) - low;

  low = 0;
  high = N;
  //(low,high]

  while (high - low > 1) {  //左側に落ちる上限
    mid = (high + low) / 2;
    if (check(s, td, mid) == -1)
      low = mid;  //落ちた場合
    else
      high = mid;
  }

  fall_left = high;

  cout << N - (fall_left + fall_right) << endl;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int32> x(n),y(n);
  vector<char> c(n);
  REP(i,n)cin >> x[i] >> y[i] >> c[i];
  vector<vector<vector<int32>>> cnt(2*k,vector<vector<int32>>(k,vector<int32>(2,0)));
  REP(i,n){
    x[i] %= 2 * k;
    y[i] %= 2 * k;
    if(y[i] >= k){
      y[i] -= k;
      x[i] = (x[i] + k) % (2*k);
    }
    cnt[x[i]][y[i]][c[i]%2]++;
  }
  REP(i,2*k)REP(j,k)REP(ci,2){
    if(i-1 >= 0)
      cnt[i][j][ci] += cnt[i-1][j][ci];
    if(j-1 >= 0)
      cnt[i][j][ci] += cnt[i][j-1][ci];
    if(i-1 >= 0 && j-1 >= 0)
      cnt[i][j][ci] -= cnt[i-1][j-1][ci];
  }
  int32 ans = 0;
  auto sum = [&](int32 l, int32 b, int32 r, int32 t, int32 ci){
    int32 res = 0;
    res += cnt[r][t][ci];
    if(b >= 0)
      res -= cnt[r][b][ci];
    if(l >= 0)
      res -= cnt[l][t][ci];
    if(b >= 0 && l >= 0)
      res += cnt[l][b][ci];
    return res;
  };
  REP(i,k)REP(j,k)REP(ci,2){
    int32 cand = 0;
    cand += sum(i-k,j-k,i,j,ci);
    cand += sum(i,j-k,i+k,j,1-ci);
    cand += sum(i+k,j-k,2*k-1,j,ci);
    cand += sum(i-k,j,i,k-1,1-ci);
    cand += sum(i,j,i+k,k-1,ci);
    cand += sum(i+k,j,2*k-1,k-1,1-ci);
    
    // cout << i << " " << j << " " << cand << endl;
    ans = max(ans,cand);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 114272
#include<bits/stdc++.h>
#define LL long long 
#define inf 1e10
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	LL h,w;
	cin>>h>>w;
	LL Max=-inf,Min=inf;
	LL ans=inf;
	for(LL i=1;i<h-1;i++){
		LL left=h-i;
		LL h1=floor(left/2.0);
		LL h2=ceil(left/2.0);
		Max=max(max(h1,h2),i);
		Min=min(min(h1,h2),i);
		ans=min(ans,(Max-Min)*w);
	}
	for(LL i=1;i<h;i++){
		LL x1=w*i;
		LL x2=(h-i)*floor(w/2.0);
		LL x3=(h-i)*ceil(w/2.0);
		Max=max(max(x1,x2),x3);
		Min=min(min(x1,x2),x3);
		ans=min(ans,Max-Min);
	}
	for(LL i=1;i<w-1;i++){
		LL left=w-i;
		LL l1=floor(left/2.0);
		LL l2=ceil(left/2.0);
		Max=max(max(l1,l2),i);
		Min=min(min(l1,l2),i);
		ans=min(ans,(Max-Min)*h);
	}
	for(LL i=1;i<w;i++){
		LL x1=h*i;
		LL x2=(w-i)*floor(h/2.0);
		LL x3=(w-i)*ceil(h/2.0);
		Max=max(max(x1,x2),x3);
		Min=min(min(x1,x2),x3);
		ans=min(ans,Max-Min);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	ll a, b, k;
	cin >> a >> b >> k;
	ll cont = 0;
	for (ll i = min(a, b); i > 0; --i)
	{
		if (a % i == 0 && b % i == 0) cont++;
		if (cont == k) {
			cout << i << "\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
def solve():
    _ = input()
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    d = [x-y for x, y in zip(a, b)]

    # print(d)

    if sum(d) < 0:
        return -1

    neg = [d for d in d if d < 0]
    pos = sorted([x for x in d if x > 0], reverse=True)

    ans = len(neg)

    i = 0
    n = sum(neg)
    while n< 0:
        n+= pos[i]
        i+=1
    ans += i
    return ans


print(solve())





Measured memory_bytes: 19068
#                         author:  kagemeka 
#                         created: 2019-11-09 15:46:24(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())

    count = 0
    for i in range(len(s)):
        if s[i] == '1':
            count += 1
        else:
            last_1 = i - 1
            break
    else:
        last_1 = len(s) - 1
    
    if k <= count:
        ans = '1'
    else:
        ans = s[last_1 + 1]
    
    print(ans)
    



if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	cnt := 0
	for a := 1; a < n; a++ {
		for b := 1; a*b < n; b++ {
			c := sort.Search(n-a*b, func(c int) bool { return a*b+c >= n })
			if a*b+c == n {
				cnt++
			}
		}
	}
	io.Println(cnt)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1864
H, W =list(map(int, input().split()))
grid = [ list(input()) for _ in range(H)]

deleted_w = []
for i in range(H):
  if(all(j == "." for j in grid[i])):
    deleted_w.append(i)

deleted_h = []
for i in range(W):
  line = [ grid[k][i] for k in range(H)]
  if(all(j == "." for j in line)):
    deleted_h.append(i)

for i in range(H):
  if(i in deleted_w):
    continue
  for j in range(W):
    if(j in deleted_h):
      continue
    else:
      print(grid[i][j], end="")
  print("")

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

int main(){
	ll n;
  	cin >> n;
  	string ans;
  	
  	while(n){
    	n--;
      	ans += 'a' + n % 26;
      	n /= 26;
    }
  
  	reverse(ans.begin(), ans.end());
	  
  	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

bool compare(const pair<int,int> &A,const pair<int,int> &B){
	if(A.first!=B.first) return A.first<B.first;
	else return A.second<B.second;
}

int main(void){
  int n;
  while(cin>>n,n){
    vector<pair<int,int> > timetable;
    for(int i=0;i<n;++i){
      int sh,sm,ss,eh,em,es;
      scanf("%d:%d:%d",&sh,&sm,&ss);
      scanf("%d:%d:%d",&eh,&em,&es);
      timetable.push_back(make_pair(sh*3600+sm*60+ss,1));
      timetable.push_back(make_pair(eh*3600+em*60+es,-1));
    }
    sort(timetable.begin(),timetable.end(),compare);
    int ans=0;
    int now=0;
    for(int i=0;i<2*n;++i){
    	now+=timetable[i].second;
    	ans=max(now,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1496
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
    string S;
    cin>>S;
    int ans=0;
    for(int i=1;i<S.size();i++){
        if(S[i-1]!=S[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	for(int i = 0; i < 5; i++) {
		int t;
		cin >> t;
		if(t == 0) {cout << i + 1 << endl;break;}
	}
	
}





Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>
int ketasuu(int n){
    for(int i=6;i>=0;i--){
        if((int)n/pow(10,i)>=1) return i+1;
    }
    return -1;
}
int divide(int n,int m){
    return (int)(n/pow(10,m+1))*(int)(n%(int)pow(10,m+1));
}
int main(){
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int count=0,newn,n;
        scanf("%d",&n);
        while(ketasuu(n)>=2){
            newn=0;
            int l=ketasuu(n);
            for(int j=0;j<l-1;j++){
                if(newn<divide(n,j)) newn=divide(n,j);
            }
            n=newn;
            count++;
        }
        printf("%d\n",count);
    }
}

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

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int d_s(int n) {
    int res = 0;
    while (n > 0) {
        res += (n % 10);
        n /= 10;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    if (n % d_s(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    int maxs=a[0];
    int sum=1;
    for(int i=1; i<n; i++)
        if(a[i]>=maxs)
        {
            sum++;
            maxs=a[i];
        }
        cout<<sum<<endl;
    return 0;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n;
  cin >> n;
  vector<pair<string,int> > pa(n);
  map <int,int> m;
  rep(i,n){
    string s;
    int p;
    cin >> s >> p;
    pa[i] = make_pair(s,100-p);
    m[100-p] = i+1;
  }
  sort(all(pa));
  rep(i,n){
    cout << m[pa[i].second] << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a[10010];
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)scanf("%d",&a[i]);
  int s=0;
  for(int i=0;i<m;i++)s+=a[i];
  if(s>n)printf("-1");
  else printf("%d",n-s);
  return(0);
}


Measured memory_bytes: 1744
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
int n=read(),k=read(),a[5555];
for (int i=1;i<=n;++i) a[i]=read();
sort(a+1,a+n+1);
int ans=n,sum=0;
for (int i=n;i;--i){
  if (sum+a[i]<k) sum+=a[i];
  else ans=i-1;
  }
write(ans);
}

Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n,x;cin >> n >> x;
    vector<int>m(n);
    int cost=0;
    rep(i,n){
        cin >> m[i];
        cost+=m[i];
    }
    cost=x-cost;
    int min=*min_element(m.begin(),m.end());
    int s=cost/min;
    cout << n+s << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input!{
        k: usize,
    }

    let mut sev = 7;

    for i in 0..k {
        sev %= k;
        if sev == 0 {
            println!("{}", i+1);
            return;
        }
        sev = sev * 10 + 7;
    }

    println!("{}", -1);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,m;cin>>n>>m;
    vll x(n),y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll xsum=(ll)0;ll ysum=(ll)0;
    rep(i,n-1){
        xsum+=((ll)i+(ll)1)*(n-(ll)i-(ll)1)*(x[i+1]-x[i]);
        xsum%=inf;
    }
    rep(i,m-1){
        ysum+=((ll)i+(ll)1)*(m-(ll)i-(ll)1)*(y[i+1]-y[i]);
        ysum%=inf;
    }
    cout<<(xsum*ysum)%inf<<endl;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

ll S(ll n) {
	ll r = 0;
	while (n) {
		r += n % 10;
		n /= 10;
	}
	return r;
}

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	
	vector<pair<ll, double>> v;
	rep (i, 1, 1000) {
		rep (j, 0, 15) {
			ll n = i;
			rep (z, 0, j) {
				n *= 10;
				n += 9;
			}
			v.pb({n, (double)n / S(n)});
		}
	}
	sort(all(v));
	/*for (auto pp: v) {
		cerr << pp.ft << " " << pp.sd << "\n";
	}*/
	set<ll> wyn;
	double minn = INF;
	for (int i = SZ(v) - 1; i >= 0; i--) {
		if (v[i].sd <= minn) {
			minn = v[i].sd;
			wyn.insert(v[i].ft);
		}
	}
	int k;
	cin >> k;
	for (auto x: wyn) {
		cout << x << "\n";
		k--;
		if (k == 0) {
			return 0;
		}
	}
	/*
	
	
	rep (i, 1, 1001) {
		int n = i * 10 + 9;
		cout << n << " " << S(n) << " " << (double)n / S(n) << "\n";
	}
	vector<double> v, sv;
	v.pb(-1);
	rep (i, 1, (1e6 + 1)) {
		v.pb((double)i / S(i));
	}
	sv = v;
	vector<int> wyn;
	double minn = INF;
	for (int i = SZ(sv) - 1; i >= 0; i--) {
		if (sv[i] < minn) {
			minn = sv[i];
			wyn.pb(i);
		}
	}
	reverse(all(wyn));
	for (auto x: wyn) {
		cout << x << "\n";
	}*/
	
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  string S;
  cin >> S;
  int ans=0;
  rep(i,6) if(S[i]=='1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 512
n = gets.to_i
as = gets.split
  .each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }
  .select { |_, v| v >= 2 }

ans = 0
prev = 0

as.keys.sort.each do |k|
  v = as[k]
  s = v >= 4 ? [prev * k, k ** 2].max : prev * k

  ans = s if s >= ans
  prev = k
end

puts ans


Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long i, tong = 0;
    for (i = 1; i <= n; i++)
    {
        if (i % 15 != 0 && (i % 5) != 0 && (i % 3) != 0)
            tong += i;
    }
    cout << tong;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+7,M=5e3+7; bool qc,fl[N][M],qt[N][M];
int n,w[N],s[N],fa[N],len[N]; vector<int>v[N];
inline void find(int u){
	
	fl[u][0]=1; int sum=0,h=-1;
	for(int i=0;i<len[u];i++){
		find(v[u][i]),memset(qt[u],0,sizeof(qt[u])); sum=sum+w[v[u][i]]+s[v[u][i]];
		for(int x=w[v[u][i]];x<=5e3;x++) qt[u][x]|=fl[u][x-w[v[u][i]]];
		for(int x=s[v[u][i]];x<=5e3;x++) qt[u][x]|=fl[u][x-s[v[u][i]]];
		for(int x=0;x<=5e3;x++) fl[u][x]=qt[u][x];
	}
	for(int i=w[u];i>=0;i--) if(fl[u][i]){h=i; break;}
	if(h==-1) qc=1; s[u]=sum-h;
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d",&fa[i]),v[fa[i]].push_back(i),len[fa[i]]++;
	for(int i=1;i<=n;i++) scanf("%d",&w[i]); find(1);
	if(!qc) puts("POSSIBLE"); else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/
int dp[101][101];
char m[101][101];

signed		main()
{
	int h, w; cin >> h >> w;
	rep(i, h)
	{
		cin >> m[i];
	}
	dp[0][0] = (m[0][0] == '#');
	rep(i, h)rep(j, w)
	{
		if (i + j == 0) continue;
		dp[i][j] = 1000000;
		if (i > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (m[i][j] == '#' && m[i - 1][j] == '.'));
		if (j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (m[i][j] == '#' && m[i][j - 1] == '.'));
	}
	cout << dp[h - 1][w - 1] << endl;
}



Measured memory_bytes: 256
def MaxNum(n1, n2):
    if int(n1) > int(n2):
        return int(n1 + n2)
    else:
        return int(n2 + n1)

if __name__ == '__main__':
    data = input().split()
    sum = list()

    sum.append(int(data[0]) + MaxNum(data[1], data[2]))
    sum.append(int(data[1]) + MaxNum(data[0], data[2]))
    sum.append(int(data[2]) + MaxNum(data[0], data[1]))

    print(max(sum))


Measured memory_bytes: 3064
import Control.Applicative

square :: Int -> Int
square a = a*a

isRightTriangle :: [Int] -> Bool
isRightTriangle array = do
    if (foldl (\x y->x+(square y)) 0 array) - (square $ maximum array) * 2 == 0 then True else False

loop c = do
    if c /= 0 then do
        ss <- words <$> getLine
        if (isRightTriangle $ map (\x->read x :: Int) ss)  == True then putStrLn "YES" else putStrLn "NO"
        loop (c-1)
    else putStr ""

main = do
    count <- read <$> getLine
    loop count

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

using namespace std;

int main() {

	int n, m;
	cin >> n >> m;
	vector<long int>h(n);
	int a;
	int b;
	vector<int>ko(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> h[i];
		ko[i] = 1;
	}
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		if (h[a - 1] < h[b - 1]) {
			ko[a - 1] = 0;
		}
		else if(h[a - 1] > h[b - 1]){
			ko[b - 1] = 0;
		}
		else if (h[a - 1] == h[b - 1]) {
			ko[a - 1] = 0;
			ko[b - 1] = 0;
		}
	}

	int x = 0;
	for (i = 0; i < n; i++) {
		x += ko[i];
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 4576
#include<stdio.h>

//nonZeroを昇順にソート マージソート
long int tmp[200000];
void mergeSort(long int x[], int left, int right) {
  long int mid, i, j, k;
  if (left >= right) return;
  
  mid = (left+right)/2;
  mergeSort(x, left, mid);
  mergeSort(x, mid+1, right);
  
  for (i = left; i <= mid; i++) tmp[i] = x[i];
  for (i = mid + 1, j = right; i <= right; i++, j--) tmp[i] = x[j];
  
  i = left;
  j = right;
  
  for (k = left; k <= right; k++) {
    if (tmp[i] <= tmp[j]) x[k] = tmp[i++];
    else x[k] = tmp[j--];
  }
}

int main(void) {
  long int N, K;
  scanf("%ld %ld", &N, &K);
  long int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%ld", &A[i]);
  }
  
  //各数字の回数を数える
  long int cnt[200000] = {0};
  for (int i = 0; i < N; i++) {
    cnt[A[i]-1]++;
  }
  
//  printf("\n");
//  for (int i = 0; i < N; i++) {
//    printf("%ld ", cnt[i]);
//  }
  
  //0でないものを集めた配列を作る
  long int nonZero[200000] = {0};
  int j = 0;
  for (int i = 0; i < N; i++) {
    if (cnt[i] != 0) {
      nonZero[j] = cnt[i];
      j++;
    }
  }
  
//  printf("\nbefore : ");
//  for (int i = 0; i < j; i++) {
//    printf("%ld ", nonZero[i]);
//  }
  
  //nonZeroを昇順にソート クイックソート
//  for (int i = 0; i < j-1; i++) {
//    for (int k = 0; k < j-1-i; k++) {
//      if (nonZero[k] > nonZero[k+1]) {
//        int tmp = nonZero[k];
//        nonZero[k] = nonZero[k+1];
//        nonZero[k+1] = tmp;
//      }
//    }
//  }

  
  //クイックソートでは動かないマージソートにせねば
  mergeSort(nonZero, 0, j-1);
  
  
//  printf("\nafter : ");
//  for (int i = 0; i < j; i++) {
//    printf("%ld ", nonZero[i]);
//  }
  
  //数の少ないものから整数を書き換える
  long int ball = 0;
  int k = 0;
  while (j > K) {
    ball += nonZero[k];
    k++;
    j--;
  }
  
//  printf("\n");
  printf("%ld", ball);
  
  return 0;
}


Measured memory_bytes: 6400
def main():
    N,K = map(int,input().split())
    modzero = 0
    modhalf = 0
    for i in range(1,N+1):
        if i%K == 0:
            modzero += 1
        elif (i%K == (K/2)) and (K/2 == K//2):
            modhalf += 1
    ans = modzero**3 + modhalf**3
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060