akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N, A, B;
    cin >> N >> A >> B;

    int m;
    if(N <= A + B) m = abs(N - (A + B) );
    else m =  0;
    cout << min(A, B) << " " << m << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.System.out;

class CircleInARectangle {
    private boolean isContain; // ?????¢????????????????????¨???????????????????????????????????????

    CircleInARectangle(int w, int h, int cx, int cy, int cr) {
        this.isContain = isCircleInRect(w, h, cx, cy, cr);
    }

    @Override
    public String toString() {
        return isContain ? "Yes" : "No";
    }

    // ??????a?????????b????????¨????????????????????????
    private boolean isLineInLine(int al, int ar, int bl, int br) {
        return al >= bl && ar <= br;
    }

    private boolean isCircleInRect(int rw, int rh, int cx, int cy, int cr) {
        return isLineInLine(cx - cr, cx + cr, 0, rw) &&
                isLineInLine(cy - cr, cy + cr, 0, rh);
    }

    public static boolean isOutCircleFromRect( int w, int h, int cx, int cy, int cr ) {
        return !(((cx - cr) >= 0) && ((cx + cr) <= w) &&
            ((cy - cr) >= 0) && ((cy + cr) <= h));
    }
}

public class Main {
    public static void main(String... args ) {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();

        out.println(new CircleInARectangle(w, h, x, y, r));
    }
}

Measured memory_bytes: 26260
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$A = $in->nextInt();
$B = $in->nextInt();
$C = $in->nextInt();
$D = $in->nextInt();

$out->println(max(0,min($B,$D)-max($A,$C)));

?>


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) { cin >> a[i]; }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int Alice =0;
    int Bob = 0;
    rep(i,N) {
        if (i%2==0) { Alice += a[i]; }
        else { Bob += a[i]; }
    }
    cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "4", "0224" ].parse.expand.solve == 3 );
	assert( [ "6", "123123" ].parse.expand.solve == 17 );
	assert( [ "19", "3141592653589793238" ].parse.expand.solve == 329 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.map!( ( a ) => cast( long )( a - '0' ) ).array;
	return tuple( n, s );
}

auto solve( long n, long[] s )
{
	bool[ string ] ks;
	auto as = new bool[ 10 ];
	foreach( i, a; s )
	{
		if( as[ a ] ) continue;
		as[ a ] = true;
		
		auto bs = new bool[ 10 ];
		foreach( j, b; s[ i + 1 .. $ ] )
		{
			if( bs[ b ] ) continue;
			bs[ b ] = true;
			
			auto cs = new bool[ 10 ];
			foreach( c; s[ i + 1 + j + 1 .. $ ] )
			{
				if( cs[ c ] ) continue;
				cs[ c ] = true;
				
				ks[ [ a, b, c ].to!( string ) ] = true;
			}
		}
	}
	return ks.length;
}


Measured memory_bytes: 2812
def main():
    qhsd=list(map(int,input().split(" ")))
    n=int(input())
    for i in range(3):
        if qhsd[i+1]>qhsd[i]*2: qhsd[i+1]=qhsd[i]*2
    res=(n%2)*qhsd[2]+(n//2)*qhsd[3]
    print(int(res))

main()    

Measured memory_bytes: 3060
#include <iostream>

int a[100];

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

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

	int ans = 100000000;
	for (int i = -100; i <= 100; ++i) {
		int cost = 0;
		for (int j = 0; j < n; ++j)
			cost += (a[j] - i)*(a[j] - i);

		if (cost < ans)
			ans = cost;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h=nxt(),w=nxt(),n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    bool right=1;
    int i=0,j=0;
    vector <vector <int>  > test;
    vector <int> r1(w);
    test.resize(h,r1);
    for(int x=0;x<n;x++)
    {
        int val=v[x];
        while(val--)
        {//cout<<x+1<<" "<<i<<" "<<j<<endl;
            test[i][j]=x+1;
            if(right)
            {
                if(j==w-1)
                {
                    i++;
                    right=0;
                }
                else
                    j++;
            }
            else
            {
                if(j==0)
                {
                    i++;
                    right=1;
                }
                else
                    j--;
            }

        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            cout<<test[i][j]<<" ";
        cout<<endl;
    }
    
    
    return 0;   
}




 
 


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int n , q ;
    cin >> n >> q;
    vector < ll > a(n);
    for( int i = 0 ; i < n ; i++) cin >> a[i] ;
    sort(st(a));
    vector < pair < ll , int > > query(q) ;
    for( int i = 0 ; i < q ; i++) cin >> query[i].ss >> query[i].ff ;
    sort(st(query));
    int low = 0 ;
    for( int i = q-1 ; i>=0 ; i--){
        int b = query[i].ss;
        ll c = query[i].ff;
        while(low<n && a[low]<c && b > 0 ){
            a[low] = c ;
            low++;
            b--;
        }
    }
    ll ans = 0 ;
    for( int i = 0 ; i < n ;i++) ans += a[i] ;
    cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
 
int main(void){
  int a,b,c,d,e,k;
  int da = 0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  da=e-a;

  if(da>k){
	printf(":(");
	//printf(“No”);
  }else if(da<=k){
	//printf(“Yes”);
	printf("Yay!");
  }
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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


int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a.at(i);
    int max_diff = 0;
    rep(i,n){
        rep(j,n){
            max_diff = max(max_diff,abs(a[i] - a[j]));
        }
    }
    cout << max_diff << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
using namespace std;

int h;
int nodes[250];

void store() {
    for (int i = 0; i < h; i++) {
        cin >> nodes[i];
    }
}

void printKey(int i) {
    cout << ": key = " << nodes[i] << ", ";
}

void printParent(int i) {
    if (i == 0) {
        return;
    }
    cout << "parent key = " << nodes[(i - 1) / 2] << ", ";
}

void printLeft(int i) {
    if (2 * i + 1 < h) {
        cout << "left key = " << nodes[2 * i + 1] << ", ";
    }    
}

void printRight(int i) {
    if (2 * i + 2 < h) {
        cout << "right key = " << nodes[2 * i + 2] << ", ";
    }    
}

void printNode() {
    for (int i = 0; i < h; i++) {
        cout << "node " << i + 1;
        printKey(i);
        printParent(i);
        printLeft(i);
        printRight(i);
        cout << endl;
    }
}

int main() {
    cin >> h;
    store();
    printNode();

    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,u,v,dp[100005][2];
vl adj[100005];
void dfs(ll i,ll par)
{
	dp[i][0]=1;
	dp[i][1]=1;
	for(auto j:adj[i])
	{
		if(j!=par)
		{
			dfs(j,i);
			dp[i][0]=(dp[i][0]*(dp[j][0]+dp[j][1]))%M;
			dp[i][1]=(dp[i][1]*dp[j][0])%M;
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    rep(i,0,n-1)
    {
    	cin>>u>>v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    dfs(1,0);
    cout<<(dp[1][0]+dp[1][1])%M;
}


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

int main() {
  int w,a,b;
  int kekka;
  cin >> w >> a >> b;
  
  if(a <= b){
    cout << max(0,b - (a+w));
  }else{
    cout << max(0,a - (b+w));
  }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = []
for i in range(h):
  t = input()
  s.append(t)
yokol = [[0 for i in range(w)] for j in range(h)]
yokor = [[0 for i in range(w)] for j in range(h)]
tateu = [[0 for i in range(w)] for j in range(h)]
tated = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
  cnt = 0
  for j in range(w):
    if s[i][j] == '#':
      cnt =0
    else:
      cnt += 1
      yokol[i][j] = cnt
  cnt = 0
  for j in reversed(range(w)):
    if s[i][j] == '#':
      cnt=0
    else:
      cnt += 1
      yokor[i][j] = cnt

for j in range(w):
  cnt = 0
  for i in range(h):
    if s[i][j] == '#':
      cnt =0
    else:
      cnt += 1
      tateu[i][j] = cnt
  cnt = 0
  for i in reversed(range(h)):
    if s[i][j] == '#':
      cnt =0
    else:
      cnt += 1
      tated[i][j] = cnt

ans = 0
for i in range(h):
  for j in range(w):
    x = yokol[i][j] + yokor[i][j] + tateu[i][j] + tated[i][j] - 3
    ans = max(ans,x)
print (ans)

Measured memory_bytes: 183684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, h; cin >> a >> b >> h;

	int res = (a + b) * h / 2;

	cout << res << endl;

	return 0;
}

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

int main(){
  vector<int> v(5);
  for(int i=0;i<5;i++)cin >> v[i];
  sort(v.begin(),v.end(),[](const int &a,const int &b){return a%10 < b%10;});
  int ret = 0,t=0;
  for(int i=0;i<5;i++){
    if(t==0&&v[i]%10!=0){
      t=1;
      ret+=v[i];
    }
    else if(t==1)ret+=v[i]/10*10+10;
    else ret+=v[i];
  }
  cout << ret << endl;
  return 0;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
ll A[100010];
ll acc[100010], num[100010];

signed main(){
    cin >> N;
    REP(i, N + 1) cin >> A[i];
    REP(i, N + 1){
        acc[i] += A[i];
        acc[i + 1] += acc[i];
    }
    if(A[0] > 1){
        PRINT("-1");
        return 0;
    }
    num[0] = 1;
    ll ans = 1;
    FOR(i, 1, N + 1){
        num[i] = min((num[i - 1] - A[i - 1]) * 2, acc[N] - acc[i - 1]);
        if(num[i] <= 0){
            PRINT("-1");
            return 0;
        }
        ans += num[i];
    }
    if(num[N] != A[N]){
        PRINT("-1");
        return 0;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 5892
#include<bits/stdc++.h>
#include<set>
#include<iterator>
#include<algorithm>
using namespace std;
#define forr(a,n) for(int i=a;i<=n;i++)
#define MAX 1000000007LL
#define mod 998244353
#define forn(n,a) for(int i=n;i>=a;i--)
#define all(x) x.begin() , x.end()
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pii pair<int,int>
#define ll long long
const int N = (int)1e5 + 9;
ll power(ll x,ll y)
{
    ll ans = 1;
    while(y>0)
    {
        if(y%2 == 1)
            ans = ans*x;
        x=x*x;
        y=y>>1;
    }
    return ans;
}
int t;
string s;
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("in.txt" , "r" , stdin);
    // // freopen("out.txt" , "w" , stdout);
    // #endif
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin>>t>>s;
    if(t%2 == 0)
    {
        string s1="",s2="";
        for(int i=0;i<t/2;i++)
            s1+=s[i];
        for(int i=t/2;i<t;i++)
            s2+=s[i];
        if(s1 == s2)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n,r;

    while (cin>>n>>r && n>0 && r>0){
        int list[50];

        for (int j = 0; j < n; ++j) {
            list[j]=n-j;
        }
        for (int i = 0; i < r; ++i) {
            int p,c;
            int tmp[50];

            cin>>p>>c;
            for (int j = 0; j < c; ++j) {
                tmp[j]=list[p+j-1];
            }
            for (int k = 0; k < p-1; ++k) {
                list[p+c-k-2]=list[p-k-2];
            }
            for (int l = 0; l < c; ++l) {
                list[l]=tmp[l];
            }
        }
        cout<<list[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int MOD = 2019;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        string s; cin >> s;
        int ans = 0;
        int n = s.size();
        map<int,int> ma;
        int rem = 0;
        int mul = 1;
        ma[0]++;
        REV(i,n-1,0){
            int x = s[i] - '0';
            rem = x*mul + rem;
            rem %= MOD;
            ans += ma[rem];
            ma[rem]++;
            mul *= 10;
            mul %= MOD;
        }
        cout << ans;
    }   
}

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


int main()
{
	int L, N;
	cin >> N >> L;
	vector<string> s;
	string str, j;
	for (int i = 0; i < N; ++i) {
		cin >> str;
		s.push_back(str);
	}
	sort(s.begin(), s.end());

	for (int i = 0; i < N; ++i) {
		j += s.at(i);
	}

	cout << j << endl;	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]//val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans *= a[i]//val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

f_ans = 0
for i in range(N):
  f_ans += (ans-1)%a[i]
print(int(f_ans))
  
      
  

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

int main()
{
	int S;
	int h,m,s;
	cin >>S;
	h = S / (60*60);
	S = S - h * (60*60);
	m = S / 60;
	S = S - m * 60;
	s = S;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

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

using namespace std;

int abs(int a,int b){
  if( a >= b){ return a - b;
             }
  else{return b - a;}}

int main(){ 
  string S; cin >> S; int s = (int) S.size();
  vector<int> T(s);
  for(int i = 0; i < s;  i++){
    T[i] = S[i] - '0';}
  
  int min_diff = 1e4;
  
  for(int i = 0;i <= s - 3; i++){
    int x = 100*T[i] + 10*T[i+1] + T[i+2];
    min_diff = min(min_diff, abs(753,x));}
  
  cout << min_diff << endl;
  
  return 0;}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, check = 0;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n%10 == 7) {
      check = 1;
      break;
    }
    n /= 10;
  }
  if (check == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n-1){
        a[i+1]+=a[i];
    }
    vi b(n);
    REP(i,n){
        cin>>b[i];
    }
    REPR(i,n-2){
        b[i]+=b[i+1];
    }
    int ans=0;
    REP(i,n){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, t: (i64, i64), mut a: (i64, i64), mut b: (i64, i64));
    let inf = "infinity";
    if a.0 > b.0 && a.1 > b.1 {
        println!("{}", 0);
        return;
    }
    if a.0 < b.0 {
        if a.1 < b.1 {
            println!("{}", 0);
            return;
        }
        std::mem::swap(&mut a, &mut b);
    }
    let d0 = t.0 * (a.0 - b.0);
    let d1 = t.1 * (a.1 - b.1) + d0;
    if d1 == 0 {
        println!("{}", inf);
        return;
    }
    if d1 > 0 {
        println!("{}", 0);
        return;
    }
    debug!("{:?}", (d0, d1, d0 % d1)); // DEBUG
    println!(
        "{}",
        2 * (d0 / -d1) + 1 - if d0 % (-d1) == 0 { 1 } else { 0 }
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2164
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	long long n;
	cin>>n;
	string ans="";
	while(n>0){
		int r=n%26;
		r=r+25;
		r%=26;
		debug(n,r);
		ans+=char('a'+r);
		n--;
		n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    REP(i, N) cin >> v[i] >> w[i];
    int dp[N+1][W+1] = {};
    int res = 0;
    REP(i, N){
        REP(j, W+1){
            if(j<w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<double> A(N);
  double sum = 0;
  rep(i,N)
  {
    cin >> A[i];
  }
  rep(i,N)
  {
    sum += 1/A[i];
  }
  cout << 1/sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 3005
#define lo long long
using namespace std;
int n;
double A[li],dp[li][li];
double dfs(int node,int hd){
	double cev=0;
	if(node==n+1){
		if(hd>n/2) return 1;
		return 0;
	}
	if(dp[node][hd]!=-1.0) return dp[node][hd];
	cev+=dfs(node+1,hd+1)*A[node];
	cev+=dfs(node+1,hd)*(1.0-A[node]);
	return dp[node][hd]=cev;
}
int main(){
	for(int i=1;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			dp[i][j]=-1.0;
		}
	}
	//~ cout<<dp[1][2];
	//~ return 0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lf",&A[i]);
	double ty=dfs(1,0);
	printf("%.10lf",ty);
	return 0;
}




Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll k,a,b,v=0;
cin>>k>>a>>b;
FORA(i,a,b)
{
	if(i%k==0)
	{
		cout<<"OK\n";
		v++;
		break;
	}
	
}
if(v==0)
{
	cout<<"NG\n";
}

return  0;
}




Measured memory_bytes: 3656
MOD = 10 ** 9 + 7
n, m, k = map(int, input().split())
def f(i, j):
    return i*(i-1)*(i+1)//6 * j ** 2
def c(a, b):
    r = 1
    for i in range(a, a - b, -1):
        r = r * i % MOD
    t = 1
    for i in range(1, b + 1):
        t = t * i % MOD
    return r * pow(t, MOD - 2, MOD)
print((f(n, m) + f(m, n)) * c(n*m - 2, k - 2) % MOD)


Measured memory_bytes: 3064
//2008dC
I;int parse(char *p){
  switch(*p){
    case 'F': return 0;
    case 'T': return 1;
    case '-': return !parse(p+1);
    case '(': {
                int x=0;
                p++;
                char *q=p;
                for(;;p++){
                  if(*p=='(')x++;
                  if(*p==')')x--;
                  if(x==0&&*p!='-')break;
                }
                p++;
                switch(*p){
                  case '*': return parse(q)&parse(p+1);
                  case '+': return parse(q)|parse(p+1);
                  case '-': return !parse(q)|parse(p+2);
                }
              }
  }
  return (I>>(*p-97))&1;
}

char p[1001],*q;main(){for(;scanf("%s",p),*p-'#';puts(I==2048?"YES":"NO")){
	q=strchr(p,'=')+1;
	for(I=0;I<2048;I++)if(parse(p)!=parse(q))break;
}exit(0);}

Measured memory_bytes: 552
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
template<typename T> void setmin(T& a, T& b) { a = min(a, b); }
template<typename T> void setmax(T& a, T& b) { a = max(a, b); }

const int INF = 1 << 25;

int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
char b[1000][1000];
int open[1000][1000];
int d[1000][1000];
int H, W, N, tx, ty;
typedef pair<int, int> Pii;
typedef pair<int, Pii> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef _WIN32
	istream &cin = ifstream("case.txt");
#endif

	while(cin >> W >> H) {
		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				cin >> b[y][x];
				if(b[y][x] == 't') {
					tx = x, ty = y;
				}
				d[y][x] = INF;
				open[y][x] = b[y][x] == '#' ? INF : 0;
			}
		}

		cin >> N;
		for(int i = 0; i < N; i++) {
			int x, y;
			cin >> x >> y;
			if(b[y][x] == '#') open[y][x] = i + 1;
		}

		d[0][0] = 0;
		priority_queue<P, vector<P>, greater<P> > q;
		q.push(P(0, Pii(0, 0)));
		while(!q.empty()) {
			int cost = q.top().first;
			int x = q.top().second.first, y = q.top().second.second;
			q.pop();
			if(d[y][x] != cost) continue;
			if(x == tx && y == ty) break;
			for(int k = 0; k < 4; k++) {
				int nx = x + dx[k], ny = y + dy[k];
				if(0 <= nx && nx < W && 0 <= ny && ny < H) {
					if(b[ny][nx] == '#') {
						if(d[ny][nx] > max(d[y][x], open[ny][nx])) {
							d[ny][nx] = max(d[y][x], open[ny][nx]);
							q.push(P(d[ny][nx], Pii(nx, ny)));
						}
					}
					else if(d[ny][nx] > d[y][x]) {
						d[ny][nx] = d[y][x];
						q.push(P(d[ny][nx], Pii(nx, ny)));
					}
				}
			}
		}

		if(d[ty][tx] == INF) {
			cout << -1 << endl;
		}
		else {
			cout << d[ty][tx] << endl;
		}
	}
}

Measured memory_bytes: 10044
#include<stdio.h>
int main(void){
    int b,f,r,v,n,i,j,k,h[5][4][11];
    for(i=1;i<5;i++){
    for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                    h[i][j][k]=0;
        }
    }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
            scanf("%d%d%d%d",&b,&f,&r,&v);
            h[b][f][r]=h[b][f][r]+v;
    }
    for(i=1;i<4;i++){
        for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                if(h[i][j][k]==0){
                printf(" %d",0 );
                }else printf(" %d",h[i][j][k]);
        }printf("\n");
    }printf("####################\n");
    }
    for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                if(h[4][j][k]==0){
                printf(" %d",0 );
                }else {printf(" %d",h[i][j][k]);
                }
            }printf("\n");
        }
return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#define PI 3.141592653589
#define N_MAX 1000
#define NUM 26
#define min(x,y) x < y ? x : y
#define max(x,y) x > y ? x : y

int main()
{
  int n, len, i, j, a_point = 0, b_point = 0;
  char a[N_MAX],b[N_MAX];
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      scanf("%s %s",a,b);
      if(strcmp(a,b) == 0) 
	{	     
	  a_point++;
	  b_point++;
	}
      else if(strncmp(a,b,min(strlen(a),strlen(b))) == 0)
	{
	  if(strlen(a) > strlen(b)) a_point += 3;
	  else b_point += 3;
	}
      else
	{
	  len = min(strlen(a),strlen(b));
	  j = 0;
	  while(j < len)
	    {
	      if(a[j] - 'a' > b[j] - 'a')
		{
		  a_point += 3;
                  break;
		}
	      else if(a[j] - 'a' < b[j] - 'a')
		{
		  b_point += 3;
		  break;
		}
	      else
		{
		  j++;
		}
	    }
	}
    }
  printf("%d %d\n",a_point,b_point);
  return 0; 
}

Measured memory_bytes: 612
#include<iostream>
#include<algorithm>
#include<string>
#define MAX 1001
using namespace std;

string x, y;

int c[MAX][MAX];
int lcs(int m, int n);

int main() {
	int i, q, n, m;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> x >> y;
		cout << lcs(x.length(), y.length()) << endl;
	}
	return 0;
}

int lcs(int m, int n) {
	int i, j, maxl = 0;
	c[0][0] = 0;
	for (i = 1; i <= m; i++)c[i][0] = 0;
	for (j = 1; j <= n; j++)c[0][j] = 0;
	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++) {
			if (x[i - 1] == y[j - 1])c[i][j] = c[i - 1][j - 1] + 1;
			else c[i][j] = max(c[i][j - 1], c[i - 1][j]);
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}

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

using ll = long long;
const ll inf = 1e18;
const int  N = 1e5 + 10;

ll n, W;
ll dp[102][N];

std::vector<pair<ll, ll>> v;
ll go(ll idx, ll pick){
	if(idx == v.size()) return 0;
	if(dp[idx][pick] != -1)return dp[idx][pick];
	ll xx = -inf, yy = -inf;
	if(pick + v[idx].first <= W)
	xx = v[idx].second + go(idx + 1, pick + v[idx].first);
	yy = go(idx + 1, pick);
	return dp[idx][pick] = max(xx, yy);
}
int main(int argc, char const *argv[]){
	
	cin >> n >> W;
	for (int i = 0; i < n; ++i){
		ll x, y;
		cin >> x >> y;
		v.push_back({x, y});
	}
	sort(v.begin(), v.end());
	memset(dp, -1, sizeof dp);
	cout << go(0, 0);
	return 0;
}

Measured memory_bytes: 80000
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,K = LI()
    H = sorted(LI(),reverse=True)
    H_removed = H[K:]
    print(sum(H_removed))


main()



Measured memory_bytes: 49604
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    int N;
    cin >> N;
    
    vector<tuple<string, int, int>> res;
    REP(i, N) {
        string s;
        int p;
        cin >> s >> p;
        res.emplace_back(s, p*(-1), i+1);
    }

    sort(res.begin(), res.end());

    for (auto e : res) {
        cout << get<2>(e) << "\n";
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, int> pp;

int main()
{
    int n, c, m[4], s[4], sum[4];

    while(cin >> n && n)
    {
        vector<pp> res;
        REP(n)
        {
            cin >> c;
            rep(j,4)cin>> m[j] >> s[j]; 
            res.push_back(pp((m[0]+m[1]+m[2]+m[3])*60 + s[0]+s[1]+s[2]+s[3], c));
        }
        sort(all(res));
        cout << res[0].second << endl;
        cout << res[1].second << endl;
        cout << res[n-2].second << endl;
    }

    return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  if(n%2){
    cout<<0<<endl;
    return 0;
  }
  n/=2;
  long long ans=0;
  long long frac=1;
  //log5 10^18 < 26
  for(long long i=0;i<26;i++){
    frac*=5;
    ans+=(n/frac);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, s[1000][12] = {}, i, j, k, f, c, count;
  while(scanf("%d", &n) && n){
    for(i = 0;i < n;i++) scanf("%d", &s[0][i]);
    c = f = 0;
    while(!f){
      f = 1;
      for(i = 0;i < n;i++){
	count = 0;
	for(j = 0;j < n;j++)
	  if(s[c][i] == s[c][j]) count++;
	s[c + 1][i] = count;
      }
      for(i = 0;i < n;i++) if(s[c][i] != s[c + 1][i]) f = 0;
      c++;
    }

    printf("%d\n", c - 1);
    for(i = 0;i < n;i++) printf(i != 0 ? " %d" : "%d", s[c - 1][i]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 664
#include<stdio.h>

int main(){

  int n,m;
  int i,j,cnt=0;
  
  scanf("%d",&n);

  int S[n];

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&m);

  int T[m];

  for(i=0;i<m;i++){
    scanf("%d",&T[i]);
  }


  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      
      if(T[i]==S[j]){
	cnt++;
	break;
      }
    }
  }

  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2140
program atcoder_abc115c_sort
    implicit none
    integer(8) :: n,k,i,ans=10000000000_8
    integer(8),allocatable,dimension(:) :: a,ind
    read*,n,k
    allocate( a(n) )
    allocate( ind(n) )
    read(*,*)(a(i),i=1,n)
    do i=1,n
        ind(i) = i;
    end do
    call sort(a,ind)
    do i=1,n-k+1
        ans = min(ans,a(i+k-1)-a(i))
    enddo
    write(*,'(I0)')ans


  !----------------------functions--------------------------
  contains
  recursive subroutine mergesort(a, p, r, b,ia,ib)
  integer(8) a(:), b(:),ia(:),ib(:)
  integer(8) p, r
  integer(8) q
  if (p < r) then
    q = (p+r)/2
    call mergesort(a, p, q, b,ia,ib)
    call mergesort(a, q+1, r, b,ia,ib)
    call merge(a, p, q, r, b, ia,ib)
  end if
  end subroutine mergesort
  subroutine merge(a, p, q, r, b, ia,ib)
    integer(8) a(:), b(:),ia(:),ib(:)
    integer(8) p, r, q, i, j, k
    integer(8) t,ti
    k = p;   i = p;   j = q+1
    do
      if (.not. (k <= r)) exit
      if (j > r) then
        t = a(i); ti = ia(i); i = i+1
      else if (i > q) then
        t = a(j); ti = ia(j); j = j+1
        
      else if (a(i) <= a(j)) then
        t = a(i); ti = ia(i); i = i+1
      else
        t = a(j); ti = ia(j); j = j+1
      end if
      b(k) = t; ib(k) = ti; k = k+1

    end do
    do i = p, r
      a(i) = b(i)
      ia(i) = ib(i)
    end do
  end subroutine merge
  subroutine sort(a,ia)
    integer(8) a(:), b(size(a)),n,ia(:),ib(size(a))
    n = size(a)
    call mergesort(a,1_8,n,b,ia,ib)
  end subroutine sort
  end program atcoder_abc115c_sort

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
typedef long long int ll;
vector<ll>tree[100001];
ll n;
ll dp[100001][2];
ll const mod = 1e9+7;
void dfs(ll,ll);
int main()
{
    scanf("%lld",&n);
    memset(dp,-1,sizeof(dp));
    for(int i = 0 ; i < n-1; i++)
    {
        ll a, b;
        scanf("%lld%lld",&a,&b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    //start dp
    dfs(1,1);
    printf("%lld\n",(dp[1][0]+dp[1][1])%mod);
}
void dfs(ll e,ll p)
{
    //calculate value
    if(dp[e][0]!=-1&&dp[e][1]!=-1)return;
    //calculate two sums
    dp[e][0] = dp[e][1] = 1;
    for(int i = 0 ; i < tree[e].size(); i++)
    {
        if(tree[e][i]==p)continue;
        dfs(tree[e][i],e);
        dp[e][0] = (dp[e][0]*dp[tree[e][i]][1])%mod;
        dp[e][1] = (dp[e][1]*((dp[tree[e][i]][1]+dp[tree[e][i]][0])%mod))%mod;
    }
    return;

}


Measured memory_bytes: 17604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

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

ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
    ll n;
    cin >> n;
    vector<ll> T(n);
    for(int i=0;i<n;i++){
        cin >> T[i];
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        ans = lcm(ans,T[i]);
    }
    cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    double res = 0;
    for(int i = 0; i < n; i++){
        double t;cin>>t;
        res+=(1/t);
    }
    cout<<setprecision(9)<<(1.00/res);
}


Measured memory_bytes: 256
n = int(input())
a = list(input().split())

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

sum = 0
for k, v in a_dict.items():
    sum += v*(v-1)//2
    a_dict[k] = (v*(v-1)//2)-((v-1)*(v-2)//2)

for i in a:
    print(int(sum-a_dict[i]))


Measured memory_bytes: 86092
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,h,ans=0,sum=0,cnt=0;
  cin >> n >> h;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    sum+=b[i];
    cnt++;
  }
  sort(a,a+n);
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(b[i]<a[n-1]){
      sum-=b[i];
      cnt--;
    }
  }
  if(h<=sum){
    reverse(b,b+n);
    for(int i=0;i<n;i++){
      h-=b[i];
      ans++;
      if(h<=0){
        cout << ans << endl;
        return 0;
      }
    }
  }else{
    h-=sum;
    ans+=cnt;
    ans+=h/a[n-1];
    if(h%a[n-1]!=0){
      ans++;
    }
    cout << ans << endl;    
  }
  return 0;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main(){
	int n;
	si(n);
	vector<pair<ll, int> > v1(n), v2(n), vv1(n), vv2(n);
	for(int i = 0; i < n; i++){
		int a, b;
		sii(a, b);
		v1[i] = {(ll)2*1000000000 - a - b, i};
		v2[i] = {a + b, i};
		vv1[i] = {(ll)1000000000 - b + a, i};
		vv2[i] = {(ll)1000000000 - a + b, i};
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	sort(vv1.begin(), vv1.end());
	sort(vv2.begin(), vv2.end());
	ll ans = 0;
	if(v1[0].scn != v2[0].scn)
		ans = (ll)2*1000000000 - v1[0].fst - v2[0].fst;
	else
		ans = max((ll)2*1000000000 - v1[0].fst - v2[1].fst, (ll)2*1000000000 - v1[1].fst - v2[0].fst);

	if(vv1[0].scn != vv2[0].scn)
		ans = max(ans, (ll)2*1000000000 - vv1[0].fst - vv2[0].fst);
	else
		ans = max(ans, max((ll)2*1000000000 - vv1[0].fst - vv2[1].fst, (ll)2*1000000000 - vv1[1].fst - vv2[0].fst));
	printf("%lld\n", ans);
	return 0;
}


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


int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){

  
  int C[26];
  int S[26][365];
  int T[365];
  int res_do[26];
  int score;
  
  int min_num=100;
  int min_c =0;
  
  
  for(int i=0;i<26;i++){
    cin >> C[i];
    if(min_num>C[i]){
      min_c=i+1;
      min_num=C[i+1];
    }
  }
  
  
  
  int max_num;
  int max_s;
  
  
  for(int j=0;j<26;j++){
    res_do[j]=0;
  }
  
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      res_do[j]++;
    }
    max_num = 0;
    max_s = 26;
    for(int j=0;j<26;j++){
      cin >> S[j][i];
      if(max_num<S[j][i]+C[j]*res_do[j]){
        max_num=S[j][i]+C[j]*res_do[j];
        max_s=j;
      }
    }
    //cout << max_s <<":"<<max_num<<endl;
    T[i]=max_s;
    res_do[max_s]=0;
  }
  
  int P[365];
  for(int i=0;i<365;i++){
    P[i]=T[i];
  }
  int pre_score=0;
  
  int ed=0;
  for(int k=0;k<1000;k++){
    ed++;
    score=0;
    for(int j=0;j<26;j++){
      res_do[j]=0;
    }
    for(int i=0;i<365;i++){
      score= score+S[P[i]][i];
      for(int j=0;j<26;j++){
        score =score+(res_do[j]-i)*C[j];
      }
      res_do[P[i]]=i;
    }
    if(score>pre_score){
      pre_score=score;
      ed=1;
      for(int i=0;i<365;i++){
        T[i]=P[i];
      }
    }
    for(int i=0;i<365;i++){
      int d = (ed+i)%26;
      P[i]=T[d];
    }
    if(ed>26){
      for(int i=0;i<365;i++){
        int d = (ed+rand())%26;
        P[i]=T[d];
      }
    }
  }
    
    
  
  for(int i=0;i<365;i++){
    cout << T[i]+1 <<endl;
  }
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n,ll x){
    if(n<0) return 0;
    else return n/x+1;
}

int main(void)
{
    ll a,b,x; cin>>a>>b>>x;
    if(a==0) cout<<b/x+1<<endl;
    else cout<<b/x-(a-1)/x<<endl;
    return 0;
}

Measured memory_bytes: 3636