akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, K;
    vector<int> numbers1;    // 正の値
    vector<int> numbers2;    // 負の値
    
    cin >> N >> K;
    
    int n;
    for ( int i = 0; i < N; i++ ) {
        cin >> n;
        if (0<n) {
            numbers1.push_back(n);
        } else if (n<0) {
            numbers2.insert(numbers2.begin(),-n);
        } else {
            numbers1.push_back(n);
            numbers2.insert(numbers2.begin(),-n);
        }
    }
    
    int mincnt = 1e9;
    
    if ( numbers1.size() >= K ) mincnt = min( mincnt, numbers1[K-1]);
    if ( numbers2.size() >= K ) mincnt = min( mincnt, numbers2[K-1]);
    if ( numbers2.size() > 0 && numbers2[0]==0 ) {
        numbers2.erase( numbers2.begin() );
        numbers1.erase( numbers1.begin() );
        K--;
    }
    
    
    
    if ( numbers1.size() > 0 && numbers2.size() > 0) {
        
        int r = min( (int)numbers1.size()-1, K-2 );
        int l = (K-2) - r;
        
        while( l<numbers2.size() && r >= 0 ) {
            //cout << l << " " << r << endl;
            mincnt = min( mincnt, numbers1[r]*2 + numbers2[l] );
            mincnt = min( mincnt, numbers1[r] + numbers2[l]*2 );
            l++; r--;
        }
        
    }
    
    cout << mincnt << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
 
signed main()
{
  string s; cin >> s;
  int ans = 0;
  if(s == "RRR") ans = 3;
  if(s == "RRS") ans = 2;
  if(s == "RSS") ans = 1;
  if(s == "RSR") ans = 1;
  if(s == "SRR") ans = 2;
  if(s == "SSR") ans = 1;
  if(s == "SSS") ans = 0;
  if(s == "SRS") ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i++)

using namespace std;

int main(void)
{
  unsigned int count = 0;
  int h, w;
  cin >> h >> w;
  vector<vector<int>> indp(h);
  for(auto& x : indp) x.resize(w);

  int mv = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> indp[i][j];
      indp[i][j] = !indp[i][j];
      mv |= indp[i][j];
    }
  }

  for(int i = 1; i < h; i++){
    for(int j = 1; j < w; j++){
      indp[i][j] *= min({indp[i-1][j-1], indp[i-1][j], indp[i][j-1]}) + 1;
      mv = max(mv, indp[i][j]);
    }
  }
  cout << mv*mv << endl;


  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int res = 999;
    string s;
    int n;
    for (int i=0; i<S.size()-2; i++) {
        s = S.substr(i,3);
        n = stoi(s);
        res = min(res, abs(n-753));
    }
    cout << res;
}

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

using namespace std;

template <typename T>
class  PriorityQueue {
private:
	vector <T> d;
public:
	void push(T s) {
		int k = d.size();
		d.push_back(s);
		while (k&&d[(k - 1) / 2] < d[k]) {
			swap(d[(k - 1) / 2], d[k]);
			k = (k - 1) / 2;
		}
	}
	T top() {
		return d[0];
	}
	void pop() {
		d[0] = d.back();
		d.pop_back();
		maxHeapify(0);
	}
	void maxHeapify(int k) {
		int l = 2 * k + 1, r = 2 * k + 2;
		T leargest;
		if (l < d.size() && d[k] < d[l]) {
			leargest = l;
		}
		else {
			leargest = k;
		}
		if (r < d.size() && d[leargest] < d[r]) {
			leargest = r;
		}
		if (leargest != k) {
			swap(d[k], d[leargest]);
			maxHeapify(leargest);
		}
	}
};
int main() {
	PriorityQueue<int> pq;
	string a;
	int b;
	while (1) {
		cin >> a;
		if (a == "insert") {
			cin >> b;
			pq.push(b);
		}
		else if (a == "end")break;
		else {
			cout << pq.top() << endl;
			pq.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 6932
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e10;
ll w[105], v[105];
ll dp[300005] = {};
ll a[200005];
ll b[200005];
int main() {
	ll n, m;
	cin >> n >> m;
	ll l, r;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		dp[l-1] += 1;
		dp[r] -= 1;
	}
	for (int i = 0; i <= n; i++) {
		dp[i + 1] = dp[i + 1] + dp[i];
	}
	
	
	ll count = 0;
	for (int i = 0; i <= n; i++) {
		if (dp[i] == m) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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 dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};


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

cout<<(n+k-3)/(k-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s;
int main(){
  cin >> s;
  int can=0;
  for (size_t i = 2; i<s.length(); i+=2) {
    can = 0;
    for (size_t ck = 0; ck < (s.length()-i)/2; ck++) {
      if (s[ck] != s[ck+(s.length()-i)/2]) {
        can = -1;
        break;
      }
      can += 2;
    }
    if(can != -1) break;
  }
  cout << can << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;


ll llmin(ll x_ll, ll y_ll){
	if (x_ll < y_ll) return x_ll;
	return y_ll;
}

ll llmax(ll x_ll, ll y_ll){
	if (x_ll > y_ll) return x_ll;
	return y_ll;
}

bool dpx[4000][16000];
bool dpy[4000][16000];

int main(){
	string s;
	int x, y;
	cin >> s >> x >> y;
	int coun = 0, num = 0;
	vector<int> vecx, vecy;
	int now = 0;
	if (s[now] == 'F'){
		while (s[now] == 'F'){
			now++;
		}
	}
	vecx.push_back(0);
	vecy.push_back(0);
	for (int i = now; i < s.length(); i++){
		if (s[i] == 'F'){
			coun++;
			if (i == s.length()-1){
				if (coun != 0){
					if (num % 2 == 0){
						vecx.push_back(coun);
					}else{
						vecy.push_back(coun);
					}
				}
			}
		}else{
			if (coun != 0){
				if (num % 2 == 0){
					vecx.push_back(coun);
				}else{
					vecy.push_back(coun);
				}
				coun = 0;
			}
			num++;
		}
	}

	dpx[0][8000+now] = true;
	for (int i = 1; i < vecx.size(); i++){
		for (int j = 0; j < 16000; j++){
			if (dpx[i-1][j] == true){
				if (j+vecx[i] < 16000) dpx[i][j+vecx[i]] = true;
				if (j-vecx[i] >= 0) dpx[i][j-vecx[i]] = true;
			}
		}
	}

	dpy[0][8000] = true;
	for (int i = 1; i < vecy.size(); i++){
		for (int j = 0; j < 16000; j++){
			if (dpy[i-1][j] == true){
				if (j+vecy[i] < 16000) dpy[i][j+vecy[i]] = true;
				if (j-vecy[i] >= 0) dpy[i][j-vecy[i]] = true;
			}
		}
	}
	if (dpx[vecx.size()-1][8000+x] && dpy[vecy.size()-1][8000+y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 27444
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    string s,t;
    cin >> s >> t;
    if(s.length()<t.length()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int ans = 0;
    int sum = 0;
    bool ok = false;
    rep(i,s.length()-t.length()+1){
        string x = s.substr(i,t.length());
        rep(j,t.length()){
            if(x[j] == '?'){
                sum++;
                continue;
            }
            else if(x[j] == t[j]){
                sum++;
                continue;
            }
            else break;
        }
        if(sum == t.length()) {
            ans = i;
            ok = true;
        }
        sum = 0;
    }
    if(!ok) cout << "UNRESTORABLE" << endl;
    else{
        rep(i,s.length()){
            if(s[i] == '?'&&i != ans){
                s[i] = 'a';
            }else if(i == ans){
                rep(j,t.length()){
                    s[i+j] = t[j];
                }
                i += t.length()-1;
            }
        }
        cout << s << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void comp(int a, int b)
{
    if(a < b){
        cout << "a < b" << endl;
    }else
    if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }

}
int main(void){
    int x, y;
    cin >> x >> y;
    comp(x, y);
    return 0;
}

Measured memory_bytes: 3092
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
for i in range(26):
    last.append(0)
for i in range(365):
    keys=list(map(int,input().split()))
    s.append(keys)
for i in range(365):
    print(s[i].index(max(s[i]))+1)

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=s[0]-'0';
  int b=s[1]-'0';
  int c=s[2]-'0';
  int d=s[3]-'0';

  if(a+b+c+d==7)cout<<s[0]<<'+'<<s[1]<<'+'<<s[2]<<'+'<<s[3];
  else if(a+b+c-d==7)cout<<s[0]<<'+'<<s[1]<<'+'<<s[2]<<'-'<<s[3];
  else if(a+b-c+d==7)cout<<s[0]<<'+'<<s[1]<<'-'<<s[2]<<'+'<<s[3];
  else if(a+b-c-d==7)cout<<s[0]<<'+'<<s[1]<<'-'<<s[2]<<'-'<<s[3];
  else if(a-b+c+d==7)cout<<s[0]<<'-'<<s[1]<<'+'<<s[2]<<'+'<<s[3];
  else if(a-b+c-d==7)cout<<s[0]<<'-'<<s[1]<<'+'<<s[2]<<'-'<<s[3];
  else if(a-b-c+d==7)cout<<s[0]<<'-'<<s[1]<<'-'<<s[2]<<'+'<<s[3];
  else if(a-b-c-d==7)cout<<s[0]<<'-'<<s[1]<<'-'<<s[2]<<'-'<<s[3];

  cout<<"=7"<<endl;
  return(0);
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $H, $W);
for ($i = 0; $i < $H; $i++) {
    $a[$i] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
$direction = 1;
$x = -1;
$y = 0;
$ans = [];
$tmp = [];
$mode = false;
while(true) {
    $prev_x = $x;
    $prev_y = $y;
    
    $x += $direction;
    if ($x < 0) {
        $x = 0;
        $y++;
        $direction *= -1;
    } else if ($x >= $W) {
        $x = $W - 1;
        $y++;
        $direction *= -1;
    }
    if ($y >= $H) break;
    if ($mode) {
        $tmp[] = [$prev_y, $prev_x, $y, $x];
    }
    if ($a[$y][$x] % 2 === 1) {
        $mode = ! $mode;
        if ($mode === false) {
            while($tmp) {
                $array = array_pop($tmp);
                array_push($ans, $array);
            }
        }
    }
}
$output = "";
$output .= sprintf("%d\n", count($ans));
foreach ($ans as $v) {
    $output .= sprintf("%d %d %d %d\n", $v[0] + 1, $v[1] + 1, $v[2] + 1, $v[3] + 1);
}
echo $output;

Measured memory_bytes: 68212
/*
ABHIJEET BISWAS
CSE (2017-2021)
MNNIT ALLAHBAD
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e15
#define ll long long
#define ld long double
#define int ll
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define F first
#define S second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define grp vector<int> graph[MAX];
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//////////////////////TEMPLATE ENDS///////////////////////////////////////////////////////////////////////
ll power(ll,ll);
ll mpower(ll,ll);
//////////////////////////////////////////////////////////////////////////////////////////////////////////

double dp[303][303][303];
int n;
int a,b,c,t;

int32_t main() {
	fastIO
	

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		a += (t==1);
		b += (t==2);
		c += (t==3);
	}
	double t;
	for(int k = 0;k<=n;k++)
	{
		for(int j = 0;j+k<=n;j++)
		{
			for(int i=0;i+j+k<=n;i++)
			{
				if(i==0 and j==0 and k==0) continue;
				double &ans = dp[i][j][k];
				t = (n*1.0/(i+j+k));
				if(i>0)
					ans += (dp[i-1][j][k]*i)/n;
				if(j>0)
					ans += (dp[i+1][j-1][k]*j)/n;
				if(k>0)
					ans += (dp[i][j+1][k-1]*k)/n;
				ans += 1;
				ans *= t;
			}
		}
	}
	
	cout << std::fixed << setprecision(15) << dp[a][b][c] << endl;
	
	return 0;
}







/*_________________________________________________Utility Functions HERE_______________________________*/

ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		res=res*a;
		a=a*a;
		b=b/2;
	}
	return res;
}
ll mpower(ll a ,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return res;
}

Measured memory_bytes: 217344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

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

P a[maxn];

bool cmp(P a, P b)
{
    return a.second < b.second;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, i, j, k, x, y;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;
    sort(a, a + n);
    x = a[n / 2].first;
    if (n % 2 == 0)
        x += a[n / 2 - 1].first;
    sort(a, a + n, cmp);
    y = a[n / 2].second;
    if (n % 2 == 0)
        y += a[n / 2 - 1].second;
    cout << y - x + 1 << "\n";
    return 0;
}


Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int f(char in) {
    return in - 'a';
}
string s, t;
map<char, int> mp;
int dp[205000][30];

int main() {
    //cout.precision(10);
    cin >> s >> t;
    int N = s.size();
    string S = s + s;
    for(int i = S.size() - 1; i >= 0; i--) {
        for(char a = 'a'; a <= 'z'; a++) {
            dp[i][f(a)] = mp[a];
            if(mp[a] == 0) dp[i][f(a)] = -1;
        }
        mp[S[i]] = i;
    }
    int index = 0;
    if(S[0] != t[0]) {
        index = dp[0][f(t[0])];
        if(index == -1) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = index + 1;
    for(int i = 1; i < t.size(); i++) {
        ll newindex = dp[index][f(t[i])];
        if(newindex == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans += newindex - index;
        index = newindex % N;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

class UnionFind {
public:
	vector<int>par, rank, node;
	UnionFind(int n) :par(n), rank(n, 0),node(n,1) {
		for (int i = 0;i < n;i++)par[i] = i;
	}
	void init(int n) {
		for (int i = 0;i < n;i++) {
			par[i] = i;
			rank[i] = 0;
			node[i] = 1;
		}
	}

	int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}

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

	void unite_tree(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	int root_size(int x){
		return rank[find(x)];
	}

	int size(int x) {
		return node[find(x)];
	}

	void unite_node(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (size(x) < size(y))swap(x, y);
		node[x] += node[y];
		par[y] = par[x];
	}
};


int main(void){
    int n,m;
    cin>>n>>m;
    UnionFind uf = UnionFind(n+1);
    for(int i=0;i<m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        uf.unite_tree(x,y);
    }
    map<int,int>p;
    for(int i=1;i<=n;i++){
        p[uf.find(i)]++;
    }
    cout<<p.size()<<endl;
    return 0;
}

Measured memory_bytes: 6144
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 27284
#include<iostream>
#include<map>
#include<string>
using namespace std;
int n,m,ans=0;
int main(){
	cin >> n;
	map<string,int> a;
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		a[s]++;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> s;
		a[s]--;
	}
	map<string,int>::iterator it;
	for(it=a.begin();it!=a.end();it++)
		ans=max(ans,(*it).second);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  l.sort()
  sm=sum(l)

  l3=[]
  for i in range(m):
    a,b=LI()
    l3.append([b,a])
  l3=sorted(l3,key=lambda x:x[0],reverse=True)

  n2=0
  for x in l3:
    n2+=x[1]

  # if n>n2:
  i=0
  i2=0
  while True:
    if i>n-1:
      break
    if i2>m-1:
      break

    a,b=l3[i2]
    while True:
      if i>n-1:
        break
      if i2>m-1:
        break

      if b==0:
        i2+=1
        break

      x=l[i]
      if x<a:
        sm+=a-x
        b-=1
        i+=1
      else:
        i2+=1
        break

  print(sm)

main()


Measured memory_bytes: 29096
#include <iostream>

#define rep(i, n) for (i = 1; i <= n; i++)

using namespace std;

//inline int gcd(int x, int y) {
//	int i, j;
//	if (x == 0) return y;
//	if (y == 0) return x;
//	for (int i = 0; 0 == (x & 1); ++i) x >>= 1;
//	for (int j = 0; 0 == (y & 1); ++j) y >>= 1;
//	if (j < i) i = j;
//	while (1) {
//		if (x < y) x ^= y, y ^= x, x ^= y;
//		if (0 == (x -= y)) return y << i;
//		while (0 == (x & 1)) x >>= 1;
//	}
//}

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}

int main() {
	int k;
	cin >> k;
	
	int i, j, m, res = 0;
	rep (i, k) {
		rep(j, k) {
			rep(m, k) {
				res += gcd(gcd(i, j), m);
			}
		}
	}
	
	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long c=a+b,d,e;
    if(n<=c){
        if(n>=a){
        cout<<a<<endl;
        return 0;
        }
        if(n<a){
            cout<<n<<endl;
            return 0;
        }
    }
    else if(n>c){
        d=n/c;
        e=n%c;
        if(e<a){
            cout<<a*d+e<<endl;
            return 0;
        }
        else{
            cout<<a*d+a<<endl;
            return 0;
        }
    }
}

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

int main(){

    int N;
    cin >> N;
    double yen[N], ans=0.0;
    string type;
    for(int i=0; i<N; i++){
      cin >> yen[i] >> type;
      if(type == "JPY"){
        ans += yen[i];
      }else{
        ans += yen[i]*380000.0;
      }
    }

    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    cout << fixed << setprecision(10);
    double c;
    c=abs( (m*pi/30) - (h/6 + m/360)*pi);
    double d2;
    d2 = a*a + b*b - 2*a*b*cos(c);
    cout<<sqrt(d2)<<endl;
}

Measured memory_bytes: 4248
#include <cstdio>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
	
	char s[3];
	map<string, int> m;

	while(scanf("%*d, %s", &s)!=EOF)
		m[string(s)]++;
	cout << m["A"] << endl << m["B"] << endl << m["AB"] << endl << m["O"] << endl;

	return 0;

}

Measured memory_bytes: 0
"""
Code of Ayush Tiwari
Codeforces: servermonk
Codechef: ayush572000

"""
import sys
input = sys.stdin.buffer.readline

def solution():
    n=int(input())
    l=list(map(int,input().split()))
    dp=[0]*n
    dp[1]=abs(l[1]-l[0])
    for i in range(2,n):
        a=dp[i-1]+abs(l[i]-l[i-1])
        b=dp[i-2]+abs(l[i]-l[i-2])
        dp[i]=min(a,b)
    print(dp[n-1])

solution()

Measured memory_bytes: 84000
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}




void solve()
{
 
 int dp[2][2];
 cin >> dp[0][0] >> dp[0][1] >>dp[1][0] >> dp[1][1];
 
 int cur=0;
 while(true)
 {
  if(cur==0)
  {
   dp[1][0]-=dp[0][1];
   if(dp[1][0]<=0)
   {
    cout<<"Yes\n";
    return ;
   }
   cur=1;
  }else
  {
    dp[0][0]-=dp[1][1];
    if(dp[0][0]<=0)
    {
      cout<<"No\n";
      return ;
    }

   cur=0;
  }
  
  
 }

}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
LL n, m;
int main()
{
    n = in();
    m = in();
    cout << (n - 1) * (m - 1);
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()

    println(rec(0L, N, 0))
}

fun rec(v: Long, n: Long, b: Int): Long {
    if (v > n) {
        return 0L
    }

    return rec(v * 10 + 7, n, b or 4) +
            rec(v * 10 + 5, n, b or 2) +
            rec(v * 10 + 3, n, b or 1) +
            (if (b == 7) 1 else 0)
}


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

int main() {
  int N;
  cin >> N;
  if (N / 1000 == N % 1000 / 100 && N / 1000 == N % 100 / 10)
    cout << "Yes" << endl;
  else if (N % 1000 / 100 == N % 10 && N % 100 / 10 == N % 10)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (a[i] == a[j] || a[j] == a[k]) continue;
                if (a[i] + a[j] > a[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;

#define pb push_back

// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());

// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());



// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);


bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string str;
    cin >> str;
    for(ll i = 0; i<str.size();i++)
    {
        if(str[i] == '?')
        {
            str[i]='D';
        }
    }
    cout << str << endl;
    return 0;
}   

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
long long pos=0,n,ans=0,tot=0,cnt=0;
long long a[200005],b[200005];
long long fa[200005];
map<long long,long long> mp;
map<long long,long long> mmp;
long long find(long long k) {
	if(fa[k]==k)return k;
	return fa[k]=find(fa[k]);
	}
void merge(long long x,long long y) {
	fa[find(x)]=find(y);
	}
int main() {
//	freopen("duliu.in","r",stdin);
//	freopen("duliu.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1; i<=n; i++) {
		scanf("%lld",&a[i]);
		pos^=a[i];
		}
	a[n+1]=pos;
	pos=0;
	for(int i=1; i<=n; i++) {
		scanf("%lld",&b[i]);
		mp[b[i]]--;
		pos^=b[i];
		}
	for(int i=1; i<=n+1; i++) {
		mp[a[i]]++;
		}
	bool flag1=true;
	for(int i=1; i<=n; i++) {
		if(mp[b[i]]<0) {
			flag1=false;
			break;
			}
		}
	if(!flag1) {
		cout<<-1;
		return 0;
		}
	b[n+1]=pos;
	for(int i=1; i<=n+1; i++)
		if(a[i]!=b[i]) {
			ans++;
			if(!mmp.count(a[i])) {
				mmp[a[i]]=++cnt;
				fa[cnt]=cnt;
				}
			}
	//cout<<ans<<endl;
	for(int i=1; i<=n; i++)
		if(a[i]!=b[i])
			merge(mmp[a[i]],mmp[b[i]]);
	for(int i=1; i<=n; i++)
		if(fa[i]==i)ans++;
	//cout<<ans<<endl;
	if(a[n+1]!=b[n+1])ans-=2;
	else if(mmp.count(a[n+1]))ans-=1;
	cout<<ans<<endl;
	}
// 0 1 2 3(0)
// 3 2 1 0

// 1 2 3 4 9(13)
// 13 1 2 3 4


Measured memory_bytes: 17664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_040
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int[] left = new int[s.Length + 1];
            int[] right = new int[s.Length + 1];
            int tmp = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == '<') tmp++;
                else tmp = 0;
                left[i + 1] = tmp;
            }
            for(int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == '>') tmp++;
                else tmp = 0;
                right[i] = tmp;
            }
            long res = 0;
            for(int i = 0; i < s.Length + 1; i++)
            {
                res += Max(left[i], right[i]);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 16864
q,h,s,d = gets.split.map(&:to_i)
n = gets.to_i
ans = []

ans << n*4 * q
ans << n*2 * h
ans << n * s
x = n.divmod(2)
ans << x[0] * d + [x[1]*s, x[1]*2*h, x[1]*4*q].min
puts ans.min

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

int main (){
	long long n,a,b;
	
	cin>>n>>a>>b;
	
	if ( ( b - a ) % 2 == 0){
		cout<< ( ( b - a ) / 2 )<<endl;
	}
	else{
    	if(( a - 1 ) < (n - b)){
        	cout<< (b - a - 1) / 2 + a; 
        }
		else{
        	cout<< (b - a - 1) / 2 + n - b + 1; 
        }
	}
}

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

li = []
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n+10):
    if i == 0 or i == 1:
        li.append(1)
    else:
        li.append((li[i-1] + li[i-2]) % mod)

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        ans = 0
    ans %= mod

print(ans%mod)


Measured memory_bytes: 11056
N, M = map(int, input().split())
l=[list(map(int,input().split()))+[i] for i in range(M)]
l=sorted(l,key=lambda x:x[0]*1000000000+x[1])
cnt=0
for i,x in enumerate(l):
    if x[0]!=l[i-1][0]:cnt=0
    cnt+=1
    l[i][1]=cnt
for x in sorted(l,key=lambda x:x[2]):
    print("{:06}{:06}".format(x[0],x[1]))

Measured memory_bytes: 29724
<?php
/*
    Problem URL : http://arc074.contest.atcoder.jp/tasks/agc016_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */


fscanf(STDIN, "%s", $s);
$a = str_split($s);
$cnt = count($a);
$arr = array();

for ($i = 0; $i < $cnt; $i++) {
    $arr[$a[$i]] = 1;
}

$k = array_keys($arr);

if (count($k) == 1) {
    echo  "0" . PHP_EOL;
    exit;
}

$ans = PHP_INT_MAX;

foreach ($k as $moji) {
    $res = solve($s, $moji);
    $ans = min($res, $ans);
}

echo $ans . "\n";

function solve($s, $moji) {
    $cnt = 0;
    while(true) {
        $cnt++;
        $newS = "";
        for ($i = 0; $i < strlen($s) - 1; $i++) {
            if (substr($s, $i, 1) == $moji) {
                $newS .= substr($s, $i, 1);
            } elseif (substr($s, $i+1, 1) == $moji ) {
                $newS .= substr($s, $i+1, 1);
            } else {
                $newS .= substr($s, $i, 1);
            }
        }
        $flg = true;
        for ($i = 1; $i < strlen($newS); $i++) {
            if (substr($newS, 0, 1) != substr($newS, $i, 1)) {
                $flg = false;
            }
        }

        if ($flg === true) {
            return $cnt;
        } else {
            $s = $newS;
        }
    }
}


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

using ll = long long;

ll N, M;

bool C(ll x) {
    ll to_s = max(0LL, x - N) * 2;
    return (M - to_s) >= 2 * x;
}

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

    ll ok = 0,
       ng = (N + M);
    while (ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if (C(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
lists = deque([])
 
for i in range(n):
    query = list(map(int, input().split()))
    if(query[0] == 0 and query[1] == 1):
        lists.append(query[2])
    elif(query[0] == 0 and query[1] == 0):
        lists.appendleft(query[2])
    elif(query[0] == 1):
        print(lists[query[1]])
    elif(query[0] == 2 and query[1] == 0):
        lists.popleft()
    elif(query[0] == 2 and query[1] == 1):
        lists.pop()


Measured memory_bytes: 21892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Node
    {
        internal int parent;
        internal int depth;
        internal string type;
        internal List<int> children;

        public Node()
        {
            parent = -1;
            depth = 0;
            type = "";
            children = new List<int>();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int i, j;
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n];
            for (i = 0; i < n; i++) nodes[i] = new Node();

            for (i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if (input[1] > 0)
                {
                    for (j = 0; j < input[1]; j++)
                    {
                        nodes[input[0]].children.Add(input[j + 2]);
                        nodes[input[j + 2]].parent = input[0];
                    }
                }
            }

            int rootIndex = 0;

            for (i = 0; i < n; i++)
            {
                if (nodes[i].parent != -1)
                {
                    nodes[i].type = nodes[i].children.Count > 0 ?
                        "internal node" : "leaf";
                }
                else
                {
                    rootIndex = i;
                    nodes[i].type = "root";
                }
            }

            Stack<Node> stk = new Stack<Node>();
            stk.Push(nodes[rootIndex]);

            while (stk.Count > 0)
            {
                Node temp = stk.Pop();

                foreach (var child in temp.children)
                {
                    nodes[child].depth = temp.depth + 1;

                    if (nodes[child].children.Count > 0)
                        stk.Push(nodes[child]);
                }
            }

            StringBuilder sb = new StringBuilder();
            for (i = 0; i < n; i++)
            {
                sb.AppendLine("node " + i + ": parent = " + nodes[i].parent +
                    ", depth = " + nodes[i].depth + ", " + nodes[i].type +
                    ", [" + string.Join(", ", Array.ConvertAll(nodes[i].children.ToArray(), a => a.ToString())) + "]");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 64592
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
  }
  int ans=1;
  n-=k;
  while(n>0)n-=(k-1),ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let (n, m, l) = input_size();
    let A = input(n, m);
    let B = input(m, l);

    for i in 0..n {
        for j in 0..l{
            let c: i64 = A[i].iter().enumerate().map(|(k, &v)| v * B[k][j]).sum();
            if j < l-1{
                print!("{} ", c);
            }
            else {
                println!("{}", c);
            }
        }
    }
}

fn input_size() -> (usize, usize, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let l: usize = iter.next().unwrap().parse().unwrap();

    (n, m, l)
}

fn input(n: usize, m: usize) -> Vec<Vec<i64>> {
    let mut mat: Vec<Vec<i64>> = vec![];
    for _ in 0..n {
        let mut s = String::new();
        io::stdin().read_line(&mut s).expect("");
        let mut iter = s.trim().split_whitespace();

        let mut v = vec![];
        for _ in 0..m {
            v.push(iter.next().unwrap().parse().unwrap());
        }
        mat.push(v);
    }
    mat
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << (A + B >= C ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append([i+1,A])
c=0
k=1
for i in range(n+1):
    k=a[k-1][1]
    c+=1
    if k==2:
        print(c)
        break
if c==n+1:print(-1)

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

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n), s = vector<int>(n);
	for(auto i = 0; i < n; ++i){
		cin >> a[i];
		s[i] = a[i];
	}
	sort(s.begin(), s.end());
	int lm = s[n / 2 - 1], rm = s[n / 2];
	for(auto i = 0; i < n; ++i){
		cout << (a[i] <= lm ? rm : lm) << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    vector<int> A(5);
    cin >> A;
    for (int i = 0; i < 5; i++) {
        if (A[i] == 0)  {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
import math

n = int(input())
sta = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    sta += [dict(c = c, s = s, f = f)]

for i in range(n):
    time = 0
    while i < n - 1:
        x = math.ceil((time - sta[i]['s']) / sta[i]['f']) if time > sta[i]['s'] else 0
        time = sta[i]['s'] + sta[i]['f'] * x + sta[i]['c']
        i += 1
    print(str(time))


Measured memory_bytes: 3316
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

K = get_int

# X = 1.step(1000000).map do |n|
#   [n, (n.to_f/ n.to_s.split('').map(&:to_i).sum)]
# end
#
# X.sort! { |a, b| a[1] <=> b[1] }
# xx = []
# max = 0
# X.each do |x|
#   if x[0] > max
#     xx << x
#     max = x[0]
#   end
# end

require 'bigdecimal'

x = 1
def next_x(x)
  if x.to_s.length < 5
    x+1
  else
    a = x.to_s.split('')[0..3].join.to_i
    ((a+1).to_s + ('9' * (x.to_s.length - 4))).to_i
  end
end

x = 1
ans = [1]
while x <= 10 ** 18
  x = next_x(x)
  ans << x
end

ans.map! { |n| [n,(BigDecimal(n)/ n.to_s.split('').map(&:to_i).sum)] }
ans.sort! do |a, b|
  if (a[1] <=> b[1]) == 0
    a[0] <=> b[0]
  else
    a[1] <=> b[1]
  end
end

xx = []
max = 0
ans.each do |x|
  if x[0] > max
    xx << x
    max = x[0]
  end
end

K.times do |i|
  puts xx[i][0]
end



Measured memory_bytes: 46132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  ll n;
  cin>>n;
  VI a(n);
  for(i=0;i<n;i++) cin>>a[i];
  VVI dp(n+1,VI(8,-INF));
  dp[0][7]=a[0];
  dp[0][1]=0;
  for(i=1;i<n;i++){
    for(j=5;j<8;j++) chmax(dp[i][j],dp[i-1][j-5]+a[i]);
    for(j=0;j<3;j++) chmax(dp[i][j],dp[i-1][j+5]);
    for(j=0;j<3;j++) chmax(dp[i][j],dp[i-1][j+1]);
  }
  if(n%2==0) cout<<max(dp[n-1][2],dp[n-1][6])<<endl;
  else cout<<max(dp[n-1][1],dp[n-1][5])<<endl;

  

}

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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const int maxn = 1e5 + 5;

int n, m;
vector<int> ne[maxn];
int ans[maxn];
bool found[maxn];

int dp(int pos){
	if(found[pos]) return ans[pos];
	found[pos] = true;
	ans[pos] = 0;
	for(auto i : ne[pos]){
		ans[pos] = max(ans[pos], dp(i)+1);
	}
	return ans[pos];
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		ne[u].push_back(v);
	}
	int finalAns = 0;
	for(int i = 1; i <= n; i++){
		finalAns = max(finalAns, dp(i));
	}
	printf("%d\n", finalAns);
}

Measured memory_bytes: 7552
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int R,W,C,P,x;
	for(;scanf("%d%d%d%d",&P,&W,&C,&R),R;)
	{
		for(x=0;x<=INT_MAX;x++)
		{
			if((P+x*R-(C*W))>=0.0)
			{
				printf("%d\n",x);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3184
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)

N = int(input())
D = [int(x) for x in input().split()]
# L = [[int(x) for x in input().split()] for _ in range(N)]
# N, M = map(int, input().split())
# S = input()

D.sort()

print(D[N // 2] - D[N // 2 - 1])


Measured memory_bytes: 52780