akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long H;
    std::cin >> H;
    long long W;
    std::cin >> W;
    std::vector<std::string> S(H);
    for (int i = 0; i < H; i++) {
        std::cin >> S[i];
    }

    VV<int> r(H, (V<int>(W, INF)));
    queue<pii> q;
    rep(i, H) rep(j, W) {
        if (S[i][j] == '#') {
            r[i][j] = 0;
            q.emplace(i, j);
        }
    }
    int ans = 0;
    while (!q.empty()) {
        pii p = q.front();
        int x = p.second, y = p.first;
        q.pop();
        auto update = [&](int x, int y, int d) {
            if (r[y][x] != INF) return;
            r[y][x] = d;
            ans = max(ans, d);
            q.push(make_pair(y, x));
        };
        rep(i, 4) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx < 0 || yy < 0 || xx >= W || yy >= H) continue;
            if (S[yy][xx] == '#') continue;
            update(xx, yy, r[y][x] + 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    n=5;
    int count=0;
    int data;
    for(int i=1;i<=5;i++)
    {
        cin>>data;
        if(data==0)
        {
            count=i;
            
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    int n;
    cin >> n;
    multiset<int> ms;
    for(int i = 0; i < 3*n; i++)
    {
        int a;
        cin >> a;
        ms.insert(a);
    }
    ll ans = 0;
    while(n--)
    {
        int h = *ms.rbegin();
        ms.erase(ms.find(h));
        int m = *ms.rbegin();
        ans += m;
        ms.erase(ms.find(m));
        ms.erase(ms.begin());
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include <stdio.h>

int main() {

	int r,g,b;
	
	scanf( "%d %d %d", &r, &g, &b );
	
	if((( r*100+g*10+b) % 4 ) == 0 ){
		printf( "YES" );
	}else{
		printf( "NO" );
	}
	return( 0 );
}


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

using namespace std;

int m, n;
vector<int> w;

bool IsStorable( int width ) {

    int row = 0, c = 0, i = 0;

    while ( i < n ) {
	if ( c + w[i] <= width ) {
	    c += w[i];
	    ++i;
	}
	else if ( ++row < m ) c = 0;
	else return false;
    }

    return true;
}

int main() {

    while ( cin >> m >> n && m && n ) {

	w.resize( n );
	for ( int i=0; i<n; ++i ) cin >> w[i];

	int minw = 1;
	int maxw = 1500000;
	if ( !IsStorable( maxw ) ) cout << "NA" << endl;

	while ( maxw > minw ) {
	    int mid = (maxw + minw)/2;
	    if ( IsStorable(mid) ) maxw = mid;
	    else                   minw = mid + 1;
	}

	cout << minw << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3032
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    auto f = [&](ll K) {
        if (K == 1)
        {
            return false;
        }
        ll n = N;
        while (n % K == 0)
        {
            n /= K;
        }
        return n % K == 1;
    };
    ll ans = 0;
    for (ll i = 1; i * i <= N; ++i)
    {
        ans += f(i);
        if (N % i == 0 and i < N / i)
        {
            ans += f(N / i);
        }
        if ((N - 1) % i == 0 and i < (N - 1) / i)
        {
            ans += f((N - 1) / i);
        }
    }
    OUT(ans);
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CY cout<<"Yes\n"
#define CN cout<<"No\n"
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<ll> dp(100005,-1);
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// ll rec(vector<ll>v,int k,int l,ll ans,int i,int f1,int f2)
// {

//     if(l==k)
//         return ans;
//     if(f1==1)
//     {
//         if(i>=v.size())
//         return INT_MAX;
//     }

//     return min(rec(v,k,l+1,max(ans,v[i]),i+2),rec(v,k,l,ans,i+1));
// }
ll bs(vector<ll>v,ll n)
{
    ll c=0;
    bool s=1;
    while(s)
    {
        s=0;
        c++;
        for(int i=0;i<n-1;i++)
        {
            if(v[i]>v[i+1])
                {swap(v[i],v[i+1]);s=1;}
        }
    }
    return c;
}
void solve()
{
    ll n; cin>>n;
    ll k=0;
    ll od=0;
    while(od<n)
    {
        k++;
        od+=(ll)(pow(26,k)+0.5);
      //  cout<<od<<" ";
    }
    k--;
    //cout<<k<<"\n";
    ll z=(ll)(pow(26,k)+0.5)-1;
    //cout<<z<<"\n";
    ll sg=(26*z)/25;
    n-=sg;
    ll d=k+1;
    ll i=0;
    //cout<<d<<" "<<n<<" "<<sg;
    while(d>0)
    {
        ll t=ceil((n*1.0)/(ll)(pow(26,d-1)+0.5));
        cout<<(char)('a'+t-1);
        d--;
        n=n-((t-1)*(ll)(pow(26,d)+0.5));
    }
cout<<"\n";
}
int main() {
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    ll t;t=1;
// cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int X=0;
  int a=0;
  cin >> N;
  string S;
  cin >> S;
  
  for(int i=0;i<N;i++){
    if(S.at(i)=='I')
      X++;
    else
      X--;
    a=max(a,X);
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
/*input
4
1 2 3 4
3
1 2
3 4
2 4
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll MX = 100005;

ll n, q, a[MX], f[MX];

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	cin >> n;
	ll sum = 0;
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
		f[a[i]]++;
		sum += a[i];
	}
	cin >> q;
	for(ll i = 0; i < q; i++) {
		ll b, c; cin >> b >> c;
		sum += ((c - b) * f[b]);
		f[c] += f[b];
		f[b] = 0;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 5188
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[100+5],x,y,h;
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++){scanf("%d",&a[i]);h+=a[i];}
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    printf("%d\n",h-a[x]+y);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,i,n) lower_bound(v.begin()+i,v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
vector<l> fact(l n)
{
	vector<l> v;
	for(l i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.pb(i);
			if(i!=n/i)
			{
				v.pb(n/i);
			}
		}
	}
	return v;
}//prefixsums
void frooty()
{
	l a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3664
using System;
using System.Collections.Generic;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int H = 0, W = 0;

            string[] inputStr = Console.ReadLine().Split(' ');
            H = int.Parse(inputStr[0]);
            W = int.Parse(inputStr[1]);

            char[,] HW = new char[H, W];

            for(int i = 0;i < H; ++i)
            {
                string str = Console.ReadLine();
                for(int j = 0;j < W; ++j)
                {
                    HW[i, j] = str[j];
                }
            }
            for(int i = 0; i < H; ++i)
            {
                for(int j = 0; j < W; ++j)
                {
                    int counter = 0;

                    if(HW[i,j] != '#')
                    {
                        if (i - 1 >= 0 & j - 1 >= 0 && HW[i - 1, j - 1] == '#')
                        {
                            counter++;
                        }
                        if (i - 1 >= 0 && HW[i - 1, j] == '#')
                        {
                            counter++;
                        }
                        if (i - 1 >= 0 & j + 1 < W && HW[i - 1, j + 1] == '#')
                        {
                            counter++;
                        }
                        if (j - 1 >= 0 && HW[i, j - 1] == '#')
                        {
                            counter++;
                        }
                        if (j + 1 < W && HW[i, j + 1] == '#')
                        {
                            counter++;
                        }
                        if (i + 1 < H & j - 1 >= 0 && HW[i + 1, j - 1] == '#')
                        {
                            counter++;
                        }
                        if (i + 1 < H && HW[i + 1, j] == '#')
                        {
                            counter++;
                        }
                        if (i + 1 < H & j + 1 < W && HW[i + 1, j + 1] == '#')
                        {
                            counter++;
                        }
                        HW[i, j] = char.Parse(counter.ToString());
                    }
                }
            }

            for(int i = 0;i < H; ++i)
            {
                for(int j = 0;j < W; ++j)
                {
                    Console.Write($"{HW[i,j]}");
                }
                Console.Write("\n");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
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>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9+7;

typedef tuple<int,int,int> State; // operator< defined
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef double ld;


int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  
	int n,k,i,j,l;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;++i)
		cin>>a[i];

	ll dp[n+2][k+1];
	// memset(dp,0,sizeof(dp));
	
	for(i=0;i<=k;++i){
		dp[1][i] = (i > a[0]) ? 0 : 1;
	}

    for(i=2;i<=n;++i){
    	for(j=0;j<=k;++j){
    		if(j == 0)
    			dp[i][j] = dp[i-1][j];
    		else
	    		dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - ((j-a[i-1]-1>=0) ? dp[i-1][j-a[i-1]-1]:0))%mod;
    	}
    }
    cout<<dp[n][k];

#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}


Measured memory_bytes: 78464
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int H, W; cin >> H >> W;
	vector<char> cs(H * W);
	REP(i, H) REP(j, W) cin >> cs[i * W + j];
	const int INF = 1e9;
	vector<int> dists(H * W, INF);
	vector<int> parents(H * W, -1);
	dists[0] = 0;
	deque<int> Q{ 0 };
	while (!Q.empty())
	{
		int v = Q.front(); Q.pop_front();
		int r = v / W, c = v % W;
		vector<int> neighbors;
		if (r > 0 && cs[v - W] == '.') neighbors.push_back(v - W);
		if (r < H - 1 && cs[v + W] == '.') neighbors.push_back(v + W);
		if (c > 0 && cs[v - 1] == '.') neighbors.push_back(v - 1);
		if (c < W - 1 && cs[v + 1] == '.') neighbors.push_back(v + 1);
		for (const int n : neighbors)
		{
			if (dists[n] > dists[v] + 1)
			{
				dists[n] = dists[v] + 1;
				parents[n] = v;
				Q.push_back(n);
			}
		}
	}
	if (dists[H * W - 1] == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		vector<int> path;
		for (int v = H * W - 1; v != -1; v = parents[v])
		{
			path.push_back(v);
		}
		int ans = H * W;
		for (const char ch : cs)
		{
			if (ch == '#') --ans;
		}
		cout << ans - path.size() << endl;
	}
}

Measured memory_bytes: 3612
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
a = m.times.map { gets.to_i }

MOD = 10**9 + 7

dp = [1, 1]

a.each do |i|
  dp[i] = 0
end

2.upto(n) do |i|
  next if dp[i] && dp[i].zero?

  dp[i] = dp[i - 1] + dp[i - 2]
end

puts dp[n] % MOD


Measured memory_bytes: 433020
using System;

class MainClass
{
	public static void Main (string[] args)
	{
		int a = int.Parse (Console.ReadLine ());

		for (int i = 3; i <= a; i++) {
			string s = i.ToString ("D");

			if (i % 3 == 0)
			{
				
				Console.Write (" " + i);
			} 
			else if (s.IndexOf ("3") >= 0) 
			{
				Console.Write (" " + i);
			}
		}
		Console.WriteLine ("");
	}
}

Measured memory_bytes: 9816
#include<iostream>

using namespace std;

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

	long long sum = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 && i % 5 == 0) {
		}
		else if (i % 3 == 0) {
		}
		else if (i % 5 == 0) {
		}
		else {
			sum = sum + i;
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  string s,s1[20];
  cin >> s;

  int j = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')     
      s1[j] += s[i];
    else {
      if(s1[j] == "") continue;
      else j++;
    }
  }
  int max = 0;
  for(int i = 0; i < 20; i++) {
    if(max < s1[i].size())
      max = s1[i].size();
  }
  cout << max << endl; 
}

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

int main()
{
    long long L, R;
    cin >> L >> R;
    long long ans = 2018 * 2017;
    for (long long i = L; i < min(R, L + 2019 + 1); i++)
    {
        for (long long j = i + 1; j <= min(R, L + 2019 + 1); j++)
        {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 22 2020 22:03:12 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

bool ok(int n){
    string s = to_string(n);
    string t = s;
    reverse(all(t));
    return (s==t);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int a,b;
    cin >> a >> b;
    int ans = 0;
    rep(i,a,b){
        ans += ok(i);
    }
    cout << ans << endl;

    time_taken();
    return 0;
}

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

using namespace std;
int input[100005][11];
int ma[100005],an[100005];
int bfs[100005];
vector<int>edge[100005];
void go(int in[]){
	int x=in[0]-1;
	int d=in[1];
	int v=in[2];
	if(d<=ma[x])return;
	ma[x]=d;
	bfs[0]=x;
	int rr=1;
	for(int i=0;i<rr;i++){
		int x=bfs[i];
		if(!an[x])an[x]=v;
		if(!ma[x])continue;
		for(int j=0;j<edge[x].size();j++){
			int y=edge[x][j];
			int nd=ma[x]-1;
			if(nd>ma[y]){
				ma[y]=nd;
				bfs[rr++]=y;
			}
		}
	}
} 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		edge[x].push_back(y);
		edge[y].push_back(x); 
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++)for(int j=0;j<3;j++)cin>>input[i][j];
	memset(ma,-1,sizeof(ma));
	for(int i=q-1;i>=0;i--){
		go(input[i]);
	}
	for(int i=0;i<n;i++)cout<<an[i]<<endl;
	return 0;
}

Measured memory_bytes: 12024
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] -= 1
d = {}
n = 0
s = 0
d[0] = 0
while True:
    s = A[s]
    n += 1
    if s not in d:
        d[s] = n
    else:
        n1 = d[s]
        n2 = n
        break

if K<n1:
    s = 0
    while K>0:
        s = A[s]
        K -= 1
    ans = s+1
elif K>=n1:
    K -= n1
    K %= n2-n1
    while K>0:
        s = A[s]
        K -= 1
    ans = s+1
print(ans)

Measured memory_bytes: 111656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M, Q;
    cin >> N >> M;
    vector<int> es[N];
    rep(i, M){
        int a, b; cin >> a >> b; a--, b--;
        es[a].pb(b), es[b].pb(a);
    }
    cin >> Q;
    int v[Q], d[Q], c[Q];
    rep(i, Q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    int col[N][11];
    rep(i, N) rep(j, 11) col[i][j] = 0;
    rep3(i, Q-1, 0){
        queue<pii> que;
        que.push(pii(v[i], d[i]));
        while(!que.empty()){
            pii p = que.front();
            que.pop();
            int j = p.first, k = p.second;
            if(col[j][k] != 0) continue;
            for(int l = k; l >= 0 && col[j][l] == 0; l--) col[j][l] = c[i];
            for(auto &e: es[j]){
                if(k > 0) que.push(pii(e, k-1));
            }
        }
    }
    rep(i, N) cout << col[i][0] << endl;
}

Measured memory_bytes: 12480
#https://atcoder.jp/contests/abc138/submissions/7003989
import sys

input = sys.stdin.readline

# 遅延評価で加えてあげるだけ

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N - 1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

#print(AB)
#print(PX)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
#print("graph:", graph)

value = [0] * (N + 1)
for p, x in PX:
    value[p] += x
#print("value:", value)
q = [(1, 0)]
#print("***loop***")
while q:
    x, parent = q.pop()
#    print("x:", x, "parent:", parent)
    value[x] += value[parent]
#    print("value:",value)
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y, x))
#    print("q:",q)

print(*value[1:])


Measured memory_bytes: 116452
S=list(input())
odd = 1
for i in range(len(S)):
    if odd == 1:
        if S[i] != 'h':
            print ("No")
            exit(0)
    if odd == 0:
        if S[i] != 'i':
            print ("No")
            exit(0)

    odd = 1 - odd

if odd == 1:
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^'0');
		ch=getchar();
	}
	return x*f;
}
int a[MAXN];
int main(){
	int n=read();
	for (register int i=1;i<=n;++i){
		a[i]=read();
	}
	sort(a+1,a+1+n,greater<int>());
	int p=1;
	for (;p<=n;++p){
		if (a[p]<p) break;
	}
	p--;
	int cnt1=0,cnt2=0;
	for (register int i=p+1;i<=n;++i){
		//printf("i:%d a[i]:%d p:%d\n",i,a[i],p); 
		if (a[i]<p) break;
		cnt1++;
	}
//	printf("%d %d\n",a[p],p);
	cnt2=a[p]-p;
	//printf("%d %d %d\n",p,cnt1,cnt2);
	if ((cnt1&1)||(cnt2&1)) puts("First");
	else puts("Second");
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

   
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

   
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; 
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size(); 
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, g;
    cin >> r >> g;
    cout << 2*g - r << endl;


    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	fmt.Println(N - K + 1)
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 1776
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  while(cin>>n){
    int sm=0;
    for(i=0;i<n/2;i++)
      sm+=(int)pow(3,i)*2;
    if(n%2)
      sm+=(int)pow(3,i);
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(L[n-1])


Measured memory_bytes: 2940
N = int(input())
a = list(map(int, input().split()))

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    if i > N / 2:
        if a[i-1] == 1:
            hako[i] = a[i-1]
    else:
        count = 0
        for j in range(i,N+1,i):
            if j%i == 0:
                count += hako[j]

        if count % 2 == a[i-1]:
            hako[i] = 0
        else:
            hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

Measured memory_bytes: 14516
// * It's time to PLAY !

#include <bits/stdc++.h>

using namespace std;

#ifdef EXILE
#include "prettyprint.hpp"
#define debug(args) cerr << #args << " = " << args << endl;
#else
#define debug(args) 20040119
#endif

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long

void OPEN(string str)
{
    freopen((str + ".inp").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}

void PLAY()
{
    int a, b;
    cin >> a >> b;
    vector<int> d;
    set<int> cm;
    for (int i = 1; i * i <= __gcd(a, b); ++i)
    {
        if (a % i == 0 && b % i == 0)
        {
            cm.insert(i);
            cm.insert(__gcd(a, b) / i);
        }
    }
    for (auto v : cm)
    {
        bool ok = true;
        for (auto x : d)
        {
            ok &= (__gcd(x, v) == 1);
        }
        if (ok)
            d.push_back(v);
    }
    cout << d.size();
}

signed main()
{
    fastio;
    PLAY();
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            sum = a * 500 + b * 100 + c * 50
            if sum == X:
                ans = ans + 1
            
print(ans)




Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;


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

  vector <int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  
  bool flag = true;

  for (int i = N - 1; i >= 1; i--){
    if (H[i - 1] == H[i] + 1){
      H[i - 1]--;
    }else if(H[i - 1] > H[i]){
      flag = false;
    }
  }
  
  if (flag == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
  

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
using namespace std;


int main(void)
{
	int N, W; cin >> N >> W;
	vector<int> w(N), v(N); rep(i, 0, N)cin >> w[i] >> v[i];
	vector<vector<lli>> dp(N + 1, vector<lli>(W + 1, 0));
	rep(i, 1, N + 1) {
		rep(j, 0, W + 1) {
			dp[i][j] = dp[i - 1][j];
			if (j >= w[i - 1])dp[i][j] = more(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}
	}
	cout << dp[N][W] << endl;

	return 0;
}


Measured memory_bytes: 80256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}


const int N=100000;
int prime[N+1];
int like[N+1]; // ruisekiwa


int main(){
	int q;
	cin >> q;
	vector<int> l(q),r(q);
	REP(i,q) cin >> l[i] >> r[i];
	
	for(int i=2; i<=N; i++){
		if(prime[i]==1) continue;
		for(int j=i*2; j<=N; j+=i){
			prime[j] = 1;
		}
	}
	
	like[1] = 0;
	for(int i=3; i<=N; i+=2){
		if(prime[i]==0 && prime[(i+1)/2]==0){
			like[i+2] = like[i] + 1;
		}else{
			like[i+2] = like[i];
		}
	}
	
	REP(i,q){
		cout << like[r[i]+2] - like[l[i]] << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
struct Graph{
  int node;
  vector<vector<pair<int,X>>> edge;
  vector<vector<int>> rev;  
  vector<X> d;//distance from start 
  const X inf = 1e+13;//initial value
  vector<bool> visit;//visited flag
  vector<bool> f;//Can node 's' visit 'g' ?
  
  Graph(int _n){
    node = _n;
    edge.resize(node);
    rev.resize(node);
  }
  
  void add_edge(int from,int to,X cost){
    edge[from].push_back(make_pair(to,cost));
  }
  
  void add_rev(int from,int to){
    rev[from].push_back(to);
  }

  void dfs(int v){
    visit[v] = true;
    f[v] = true;
    for(auto w:rev[v]){
      if(visit[w]){
	continue;
      }
      dfs(w);
    }
  }

  void run_dfs(int g){//check each node can reach goal
    visit.assign(node,false);
    f.assign(node,false);
    f[g] = true;
    dfs(g);
  }

  void check_f(){
    rep(i,node){
      cout << i << ":" << f[i] << "\n";
    }
  }
  
  bool bellmanford(int s){//if graph have negative-loop, return false
    d.assign(node,inf);
    d[s] = 0;
    bool flag = true;
    rep(i,node){
      rep(v,node){
	if(d[v]==inf) continue;
	for(auto w:edge[v]){
	  if(d[w.first]>d[v] + w.second){
	    d[w.first] = d[v] + w.second;
	    if(i==node-1){
	      //**********need in abc061d and abc137e**************	    
	      if(f[w.first]){
		flag = false;
	      }
	      //	      flag = false;
	    }
	  }
	}
      }
    }
    return flag;
  }

  X get_d(int v){
    return d[v];
  }
  
};


int main()
{
  int n,m,p;
  cin >> n >> m >> p;
  vector<int> a(m),b(m);
  vector<ll> c(m);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i] -= p;
  }

  Graph<ll> bf(n);

  rep(i,m) bf.add_edge(a[i],b[i],-c[i]);

  rep(i,m){
    bf.add_rev(b[i],a[i]);
  }

  bf.run_dfs(n-1);
  //  bf.check_f();

  if(bf.bellmanford(0)){
    cout << max(0LL,-bf.get_d(n-1)) << "\n";
  }
  else{
    cout << -1 << "\n";
  }
  
  return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int A, B;

signed main() {
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
	} else if (A >= 6 and A <= 12) {
		cout << B/2 << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int,input().split())

a, b = x2 - x1, y2 - y1
x3, y3 = x2 - b, y2 + a
x4, y4 = x3 - a, y3 - b

print(x3, y3, x4, y4)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    ll ans;
    ans=1900*m+100*(n-m);
    ans*=pow(2,m);
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c,d;
int sum,ans;
str s1,s2,s;

int32_t main() {
    fast();
    cin >>a >> b ;

    cout<<ceils(a,b);
    return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e6+3;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[1500001], invf[1500001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    fac(MOD-1);
    int q; cin>>q;
    for(int i=0; i<q; i++){
        ll x, d, n; cin>>x>>d>>n;
        if(d==0){
            cout<<powmod(x, n)<<endl;
            continue;
        }
        if(n>=MOD || x==0){
            cout<<0<<endl;
            continue;
        }
        ll p=powmod(d, n);
        ll y=x*inv(d)%MOD;
        if(y+n-1>=MOD){
            cout<<0<<endl;
            continue;
        }
        cout<<p*f[y+n-1]%MOD*invf[y-1]%MOD<<endl;
    }
    return 0;
}

Measured memory_bytes: 19328
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	for(int i=0;i<5;i++){
		if(a[i]==0)
			cout<<i+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int main(){
  unsigned int H, W;
  while(cin>>H>>W && H !=0 && W!=0) {
    for(int i=1; i<=H; i++) {
      for(int j=1; j<=W; j++){
         if((i+j)%2 == 0) cout << '#';
         else cout << '.';
       }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNext()) {
                int n = sc.nextInt();
                long c = sc.nextLong();
                long[] xs = new long[n];
                long[] vs = new long[n];
                for(int i = 0; i < n; i++){
                    xs[i] = sc.nextLong();
                    vs[i] = sc.nextLong();
                }
                
                // ---0===|
                long[] max_l = new long[n+1];//leftにi番目まで見たときのmax
                long[] max_l2 = new long[n+1];//行って戻ってくる
                long sum_l = 0;
                max_l[0] = 0;
                max_l2[0] = 0;
                for(int i = 0; i < n; i++){
                    sum_l += vs[i];
                    max_l[i+1] = (max_l[i] > sum_l - xs[i])? max_l[i]: sum_l - xs[i];
                    max_l2[i+1] = (max_l2[i] > sum_l - xs[i]*2)? max_l2[i]: sum_l - xs[i]*2;
                }
                // |===0---
                long[] max_r = new long[n+1];
                long[] max_r2 = new long[n+1];
                long sum_r = 0;
                max_r[0] = 0;
                max_r2[0] = 0;
                for(int i = 0; i < n; i++){
                    sum_r += vs[n-1-i];
                    max_r[i+1] = (max_r[i] > sum_r - c + xs[n-1-i])? max_r[i]: sum_r - c + xs[n-1-i];
                    max_r2[i+1] = (max_r2[i] > sum_r - (c-xs[n-1-i])*2)? max_r2[i]: sum_r - (c-xs[n-1-i])*2;
                }
                long max = Math.max(max_l[n],max_r[n]);
                for(int i=0; i<n+1; i++){
                    max = (max > max_l[i]+max_r2[n-i])? max: max_l[i]+max_r2[n-i];
                    max = (max > max_r[i]+max_l2[n-i])? max: max_r[i]+max_l2[n-i];
                }
                System.out.println(max);
            }
        }
    }
}

Measured memory_bytes: 89816
// Problem : B - Golden Coins
// Contest : AtCoder - AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli n,t=0,a;
	cin>>n;
	a=n%500;
	t+=(n/500)*1000;
	t+=(a/5)*5;
	cout<<t;
	return 0;
}

Measured memory_bytes: 3604
s = input()
t = input()

cost = 10**9+7

for i in range(len(s) - len(t)+1):
    c = 0
    sub_s = s[i:i+len(t)]
    for j in range(len(t)):
        if sub_s[j] != t[j]:
            c += 1
    cost = min(c, cost)
print(cost)

Measured memory_bytes: 67620
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from fractions import gcd


def lcm(a, b):
    # 最小公約数
    g = gcd(a, b)
    return a * b // g


H, W = read_ints()

if H == 1 or W == 1:
    print(1)
    exit()
# 市松模様を分解してカンガル
# Hはそのまま詰める
print((H * (W // 2)) + (W % 2) * ((H + 1) // 2))


Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    int arr[5],ans;
    for(int i=0;i<5;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
            ans = i+1;
    }
    cout<<ans<<"\n";
    return 0;
}



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

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

    unsigned long long power = 1;
    for(int i = 0; i < n; i++) {
        power *= (i + 1);
        power %= 1000000007;
    }
    cout << power << endl;
}

Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int M = in.nextInt();
        int ans = (N*(N-1))/2 + (M*(M-1))/2; 
        println(ans);        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

int main(void){
  int gr[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
  int x,y;
  
  cin >> x >> y;
  puts(gr[x]-gr[y]?"No":"Yes");
  return 0;
}

Measured memory_bytes: 256