akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
	ll k; cin >> k;
	ll ls = 0, ans = -1;
	for(int i = 0; i <= 1e6; i++) {
		ls = (ls*10+7)%k;
		if(!ls) {
			cout << i + 1 << endl;
			return;
		}
	}
	cout << -1 << endl;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  map<string,int> mp;
  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  mp[s]=a,mp[t]=b;
  string u; cin >> u;
  mp[u]--;
  cout << mp[s] << " " << mp[t] << endl;
  
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> data(m * 2);
  for(int i = 0; i < m * 2; i++){
    cin >> data.at(i);
  }
  for(int i = 1; i <= n; i++)
  {
    int x = count(begin(data), end(data), i);
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<cstring>
using namespace std;
 int dp[100001];
int n;
vector<int>v;
int frogjump(int n)
{    if(n<=1)
     return 0;
     if(n==2)
     { 
	    return abs(v[n-1]-v[n-2]);
	 }
    if(dp[n]!=-1)
      return dp[n];
      int  ans1=abs(v[n-1]-v[n-2])+frogjump(n-1);
       int ans2=abs(v[n-1]-v[n-3])+frogjump(n-2);
      return dp[n]=min(ans1,ans2);
}

/*
long long  frogjump2(vector<int>v,int n)
{ dp[1]=0;
dp[0]=0;
v[0]=10000000;
  for(int i=2;i<=n;i++)
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  return dp[n];
	
	
}*/
int main()
{ memset(dp,-1,sizeof(dp));
  cin>>n;
  
  for(int i=1;i<=n;i++)
    { int x;
   	  cin>>x;
   	  v.push_back(x);
     }
  
    cout<<frogjump(n);
  
}

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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(b<=a){
        b*=2;
        k--;
    }
    if(k<0){
        cout << "No";
        return 0;
    }
    while(c<=b){
        c*=2;
        k--;
    }
    if(k<0){
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3648
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input:Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();

    if input[0] % input[1] == 0 {
        println!("0");
    }else {
        println!("1");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int h, w, n; cin >> h >> w >> n;
    int larger = max(h, w);
    int colored = 0;
    for(int i=0; i<larger; i++){
        colored += larger;
        if(colored >= n){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

M = [0] * N
total_rain = sum(A)
# まずM1を求める
# countは１つおきのダムの水量の総和
count = 0
for i in range(0, N, 2):
    count += A[i]
M[0] = 2 * count - total_rain
for i in range(N-1):
    M[i+1] = 2 * A[i] - M[i]
print(*M)


Measured memory_bytes: 64484
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader r = new InputReader(System.in);
		int n = r.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = r.nextInt() - 1;
		}
		int res = 0;
		for (int i = 0; i < arr.length; i++) {
			if (arr[arr[i]] == i)
				res++;
		}
		System.out.println(res / 2);
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


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

int main(){
  int a,b,c;
  cin >> a >> b;
  int ta=a+b;
  int sa=a-b;
  int sk=a*b;
  int max=sk;
  if(max<sa) max=sa;
  if(max<ta) max=ta;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int h, a; cin >> h >> a;
    cout << (h+a-1) / a << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a, b, x, i;
  scanf("%d %d", &a, &b);
  for(i=1; i<999; i++){
    x = i*(i+1)/2 - a;
    if(x == (i+1)*(i+2)/2 - b){
      printf("%d\n", x);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }


vector<int> v[100001];
int c[100000];
int y[100000];

int main(){
  int n,T;
  cin >> n >> T;
  int ans = inf;
  bool f = true;
  rep(i,n){
    int c,t;
    cin >> c >> t;
    if(t <= T){
      ans = min(ans,c);
      f = false;
    }
  }
  if(f){
    cout << "TLE" << endl;
  }
  else cout << ans << endl;
}



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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = n;
	vector <bool> used(n+1);
	for (int i=1; i<=k; i++) {
		int d; cin >> d;
		for (int j=1; j<=d; j++) {
			int x; cin >> x;
			if (!used[x]) ans --;
			used[x] = 1;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  cin >>n;
  int cnt =n;
  for(i=0;i<=n;i++) {
    int tmp=0;
    int t=i;
    while(t>0){
      tmp += t%6;
      t/=6;
    }
    t=n-i;
    while(t>0){
      tmp += t%9;
      t/=9;
    }
    if(cnt>tmp) cnt=tmp;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int A, B, C, D;
    int sum_A, sum_C;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    sum_A = A;
    sum_C = C;
    while(1) {
        sum_C = sum_C - B;
        if(sum_C <= 0) {
            printf("Yes\n");
            break;
        }
        
        sum_A = sum_A - D;
        if(sum_A <= 0){
            printf("No\n");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2088
import java.util.*;
class Main
{
  static public void main(String args[])
  {
    Scanner in = new Scanner(System.in);
    String s = in.nextLine();
    boolean b = false;
    for(int i=0; i<s.length()-1; i++)
    {
      if(s.charAt(i) == s.charAt(i+1))
      {
        b = true;
      }
    }
    if(!b)
    {
      System.out.println("Good");
    }
    else
    {
      System.out.println("Bad");
    }
  }
}

Measured memory_bytes: 21204
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil

using namespace std;

int main() {

	int N;
	cin >> N;

	if (N % 1000 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1000 - (N % 1000) << endl;
	}

	return 0;

}

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

int main() {
  string s;
  cin>>s;
  int a=0;
  int b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C')a=1;
    if(a==1&&s[i]=='F')b=1;
  }
  if(b==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
  
int main() {
    int a,b;
    cin >> a >> b;
  
    char c[3] = { ('=' - (a<b) + (a>b)) };
    c[1] = (c[0] == '=')*'=';
    cout << "a " << c << " b" << endl;
}

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


int main(){
    long A;
    string B;
    cin >> A >> B;
    long C = (100 * (B[0] - '0') + 10 * (B[2] - '0') + (B[3] - '0'));
    cout << (A * C) / 100 << endl;
    return 0;
}

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

int main() {
    long long int A,B,C,D, K;
    long long int new_A, new_B, new_C, new_K;
    long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, s, w;

    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    while(1) {
        C = C-B;
        if (C <= 0) {break;} 
        A = A - D;    
        if (A <= 0) {break;} 
    }
    if (A <= 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    // long long int tmp, cnt = 0;
    // tmp = b;
    // for (;;) {
    //     tmp = tmp/10;
    //     cnt ++;
    //     if (tmp > 0) {
    //     }
    //     else {
    //         break;
    //     }
    // } 
    // long long int time = 1;
    // for (int i = 0; i < cnt; i++) {
    //     time *= 10;
    // }
    // b += a*time;
    // // cout << b<< endl;
    // bool flag = false;
    // for (long long int i = 0; i < sqrt(b)+1; i++) {
    //     if (i*i == b) {
    //         flag = true;
    //     }
    // }
    // if (flag) {
    //     cout << "Yes" << endl;
    // }
    // else {
    //     cout << "No" << endl;
    // }

    return 0;
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;

int dp[100005];
int heights[100005];


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

    cin >> n;

    memset(dp, 0x3f, sizeof(dp));
    dp[0]=0;

    poiu(n) cin >> heights[i];

    for(int i=0; i<n; ++i) {
        for( int j=i+1; j<i+3 && j<n; j++) {
            min_self(dp[j], dp[i]+abs(heights[i]-heights[j]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;

}



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

int main() {
  int N, X, mmin, msum;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i<N; i++) cin >> m[i];
  mmin = m[0];
  msum = m[0];
  for(int i = 1; i<N; i++) {
    mmin = min(mmin, m[i]);
    msum += m[i];
  }
  
  X -= msum;
  int q = X / mmin;
  
  cout << N + q << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M,K = MI()

for i in range(N+1):
    for j in range(M+1):
        if K == i*(M-j)+j*(N-i):
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 64576
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
int fact(int x){ return x==1?x:x*fact(x-1); }
const int MAXN = 10;
typedef pair<int,int> pii;
int n;
pii A[MAXN];
double caldist(pii a, pii b){
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i].first >> A[i].second;
    double ans = 0;
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) ans += caldist(A[i],A[j]);
    //printf("%f\n",ans/n);
    cout << setiosflags(ios::fixed) << setprecision(10) << ans/n << endl;
        return 0;
}

Measured memory_bytes: 256
def comb(n,k,mod):
  a = 1
  b = 1
  for i in range(k):
    a = a * (n-i) % mod
    b = b * (i+1) % mod
  return a * pow(b, mod-2, mod) % mod
s = int(input())
mod = 10**9+7
mx = s//3
# s_r = s-3*mx
# for i in range(1,mx+1):
#     tmp_r = s-i*3
#     for j in range(i*3,s+1):
ans = 0
for i in range(1,mx+1):
    tmp_r = s-i*3
    ans += comb(i+tmp_r-1,tmp_r,mod)
    ans %= mod

print(ans)


Measured memory_bytes: 64572
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<long long,int>m;
  long long n,ans=0,a[200000],x;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    a[i]=i?a[i-1]+x:x;
    if(!m[a[i]])m[a[i]]=i+1;
  }
  for(int i=0;i<n;i++){
    if(m[a[i]])if(i-m[a[i]]+1>ans)ans=i-m[a[i]]+1;
    if(!a[i])ans=i+1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 17012
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> N >> L;
    ans = 1 << 30;
    int sm = 0;
    int tmp;
    for (int i = 1; i <= N; i++) {
        if (abs(L + i - 1) < ans) {
            ans = abs(L + i - 1);
            tmp = L + i - 1;
        }
        sm += L + i - 1;
    }
    cout << sm - tmp << endl;
}

Measured memory_bytes: 256
s = int(input())
arr = [s]

for i in range(1, 1000001):
    if arr[i-1] % 2 == 0:
        fi = arr[i-1]//2
    else:
        fi = 3 * arr[i-1] + 1
    if fi in arr:
        print(i+1)
        exit()
    else:
        arr.append(fi)

Measured memory_bytes: 3060
"""
    参加: N 人
    

    input:
        - S: S[i] == 'a' -> 国内, b -> 海外, c -> Neither
    output: 予選通過/No Yes/No
"""

N, A, B = map(int, input().split())
S = input()

passed_cnt = 0
overseas_cnt = 0
for c in S:
    if c == 'a': # 国内学生
        if passed_cnt < A + B:
            print('Yes')
            passed_cnt += 1
        else:
            print('No')
    elif c == 'b': # 海外学生
        if passed_cnt < A + B and overseas_cnt < B:
            print('Yes')
            passed_cnt += 1
        else:
            print('No')
        overseas_cnt += 1
    else: # 学生でない
        print('No')



Measured memory_bytes: 52952
#include<stdio.h>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a, b, x, y;
	cin>>a>>b>>x>>y;
	printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}


Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    int x = 100, c = 0, val;
    cin >> val;
    while(x < val){
        x += x/100;
        c++;
    }
    cout << c << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3652
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int maxn = 2e3 + 10;

int Gcd(int a, int b) { return b ? Gcd(b, a % b) : a; }

int a[maxn];
vector<int> adj[maxn], g[maxn];
int deg[maxn];
bool vis[maxn], insta[maxn];
priority_queue<int> Q;

void Dfs(int u)
{
	vis[u] = insta[u] = true;
	int d = adj[u].size();
	for (int i = 0; i < d; ++ i)
	{
		int v = adj[u][i];
		if (!vis[v]) Dfs(v);
		if (!insta[v])
		{
			g[u].push_back(v);
			++ deg[v];
		}
	}
	insta[u] = false;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j)
		{
			if (i == j) continue;
			if (Gcd(a[i], a[j]) != 1) adj[i].push_back(j);
		}
	for (int i = 1; i <= n; ++ i)
		if (!vis[i]) Dfs(i);
	for (int i = 1; i <= n; ++ i)
		if (!deg[i]) Q.push(i);
	while (!Q.empty())
	{
		int u = Q.top();
		printf("%d ", a[u]);
		Q.pop();
		int d = g[u].size();
		for (int i = 0; i < d; ++ i)
		{
			int v = g[u][i];
			if (!-- deg[v]) Q.push(v);
		}
	}
	return 0;
}


Measured memory_bytes: 23168
#include<stdio.h>

int main(){
  int n, u, k, v, i, j;
  int G[101][101] = {};
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }
for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d", G[i][j]);
if(j != n) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
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;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<long long> H;

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    H.push_back(tmp);
  }

  vector<int> res;
  for (int i = 0; i < M; i++) {
    int A, B;

    cin >> A >> B;

    if (H.at(A - 1) == H.at(B - 1)) {
      res.push_back(A);
      res.push_back(B);
    } else if (H.at(A - 1) > H.at(B - 1)) {
      res.push_back(B);
    } else {
      res.push_back(A);
    }
  }

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

  cout << N - res.size() << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int a = 0, b = 0, c = 0;
  rep(i, s.size()) {
    if (s[i] == 'a') ++a;
    if (s[i] == 'b') ++b;
    if (s[i] == 'c') ++c;
  }
  if (abs(a - b) <= 1 && abs(b - c) <= 1 && abs(c - a) <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3716
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const ll INF = 1e15 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n;
    cin >> n;
    vi v(n + 1, 0);
    ll s = 0;
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
        s += v[i];
    }
    ll mn = INF;
    ll k = v[1];
    for(int i = 2; i <= n; ++i){
        ll x = abs(s - k - k);
        mn = min(mn, x);
        k += v[i];
    }
    cout << mn;
}

Measured memory_bytes: 3972
#ARC077C - pushpush (ABC066C)
from collections import deque

n = int(input())
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
    if i % 2 == parity:
        b.appendleft(j)
    else:
        b.append(j)
print(*b)

Measured memory_bytes: 25412
import collections

ans=[]
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            if tmp<=10000:
                ans.append(tmp)
                
c = collections.Counter(ans)

n=int(input())
for i in range(1,n+1):
    if i in c:
        print(c[i])
    else:
        print(0)

Measured memory_bytes: 19640
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;string a,b,c;
  cin>>N>>a>>b>>c;
  int ans=0;
  for(int i=0;i<N;i++){
    if(a[i]==b[i]&&b[i]==c[i])continue;
    if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i])ans++;
    else ans+=2;
  }
  cout<<ans<<endl;
}


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

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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;

    int ans = 0;
    rep(i, N) {
        if (A[i] != B[i] && A[i] != C[i] && B[i] != C[i]) {
            ans += 2;
        } else if (A[i] != B[i] || A[i] != C[i] || B[i] != C[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $a);

$ary = str_split($a);

for ($i = count($ary)-1; $i >= 1; $i--) {
    if (isset($ary[$i-1]) && $ary[$i] != 9) {
        $ary[$i] = 9;
        $ary[$i-1]--;
    }
}

$total = 0;
foreach ($ary as $v) {
    $total += $v;
}

echo $total;


Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)

int main(){
    int n,i=0,u=0,r=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a), greater<int>());
  
    while((i+1<n) && ( i < a[i+1] && a[i] > i+1) && a[i+1] != i+1) i++;
    while(((i+r+1) < n) &&  i < a[i+r+1] ) r++;
    while(i+u+1 < a[i]) u++;
   
    if(r%2==0 && u%2==0) cout << "Second" << endl;
  	else  cout << "First" << endl;
    return 0;
}

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

#define INF 1e9
#define LINF 1e18
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
 
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
#define MAX 501

int N;
VI H;
int min_cost = LINF;
VI cost;

void dp(int n,int sum_cost){
    if(n == N-1){
        if(min_cost > sum_cost){
            min_cost = sum_cost;
        }
    }
    if(n >= N){
        return;
    }
    dp(n+1,sum_cost + abs(H[n]-H[n+1]));
    dp(n+2,sum_cost + abs(H[n]-H[n+2]));
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);

    cin >> N;
    H.assign(N,-1);
    cost.assign(N,LINF);
    R(i,N) cin >> H[i];
    //dp(0,0);
    //
    cost[0] = 0;
    cost[1] = abs(H[0]-H[1]); 
    FOR(i,2,N){
        cost[i] = min(cost[i-1]+abs(H[i]-H[i-1]),cost[i-2]+abs(H[i]-H[i-2]));
    }
    min_cost = cost[N-1];
    //cout << to_string(N) << endl;
    //R(i,N) cout << to_string(H[i]) << endl;
    cout << to_string(min_cost) << endl;
}


Measured memory_bytes: 4780
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    H = LIST()
    maxv = 0
    count = 0
    for nn in range(N-1):
        if H[nn] - H[nn+1] >= 0:
            count += 1
        else:
            maxv = max(maxv, count)
            count = 0
    maxv = max(maxv, count)
    print(maxv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sci(fd) scanf("%d",&fd)
#define scll(fd) scanf("%lld",&fd)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.1415926535897932
#define pii pair < int,int > 
#define pll pair < ll,ll >
#define fi first
#define se second
#define LOGN 20
const ll infi=1000000000000000009;
int main()
{
    ll n,m,i;
    scll(n);
    scll(m);
    ll a1=0,b1=0,a,b,c;
    scll(a);
    for(i=1;i<n;i++)
    {
        scll(c);
        a1=(a1+(i*(n-i))%MOD*(c-a))%MOD;
        a=c;
    }

    scll(a);
    for(i=1;i<m;i++)
    {
        scll(c);
        b1=(b1+(i*(m-i))%MOD*(c-a))%MOD;
        a=c;
    }
    //printf("%lld %lld\n",a1,b1);
    a1=(a1*b1)%MOD;
    printf("%lld\n",a1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define INF 2147483647

int matrixChainOrder(int* p,int n){
    int i,j,l,k,q;
    int m[n+1][n+1];
    for(i = 1 ; i <= n ; i++){
        m[i][i] = 0;
    }
    for(l = 2 ; l <= n ; l++){
        for(i = 1 ; i <= n-l+1 ; i++){
            j = i+l-1;
            m[i][j] = INF;
            for(k = i ; k <= j-1 ; k++){
                q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                if(q < m[i][j]){
                    m[i][j] = q;
                }
            }
        }
    }
    return m[i-1][j];
}


int main(){
    int i,n,z;
    scanf("%d",&n);
    int M[2][n],P[n+1];
    for(i = 0 ; i < n ; i++){
        scanf("%d %d",&M[0][i],&M[1][i]);
    }
    P[0] = M[0][0];
    for(i = 1 ; i <= n ;i++){
        P[i] = M[1][i-1];
    }
    if(n <= 1) z = 0;
    else z = matrixChainOrder(P,n);
    printf("%d\n",z);
}



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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> count(M);
    for(int i = 0;i < N;++i){
        int a;
        cin >> a;
        for(int j = 0;j < a;++j){
            int A;
            cin >> A;
            --A;
            ++count[A];
        }
    }
    int ans = 0;
    for(int i = 0; i < M;++i){
        if(count[i] == N){
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
K,N= map(int,input().split())
a_list = list(map(int,input().split()))
diff = []
for i in range(N-1):
    diff.append(a_list[i+1] - a_list[i])
diff.append(a_list[0] + (K-a_list[N-1]))
# print(max(diff))
print(K-max(diff))

Measured memory_bytes: 25580
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <numeric>
#include <functional>

using namespace std;

#define INF 1e18

struct RMQ {
	static const int MAX_N = 200000;
	int n;
	vector<long long> dat;
	RMQ() {}
	RMQ(int n_) { init(n_); }
	void init(int n_) {
		dat.resize(2 * MAX_N - 1);
		n = 1;
		while (n < n_) n *= 2;
		for (int i = 0; i < 2 * n - 1; i++) dat[i] = INF;
	}
	void update(int k, long long a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	long long query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return INF;
		if (a <= l && r <= b) return dat[k];
		else {
			long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
	long long query(int a, int b) {
		return query(a, b, 0, 0, n);
	}

	long long a(int k) {
		return dat[k + n - 1];
	}
};

struct LRC {
	int l, r, c;
	bool operator<(const LRC a) {
		return l < a.l;
	}
};

int main() {
	int n, m; cin >> n >> m;
	RMQ segtree(n);
	vector<LRC> dat(m);
	for (LRC& a : dat) {
		cin >> a.l >> a.r >> a.c;
		--a.l, --a.r;
	}
	sort(dat.begin(), dat.end());
	segtree.update(0, 0);
	for (LRC a : dat) {
		long long mini = segtree.query(a.l, a.r);
		if (mini == INF) continue;
		if (segtree.a(a.r) > mini + a.c) segtree.update(a.r, mini + a.c);
	}
	long long ans = segtree.a(n - 1);
	cout << (ans == INF ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 4480
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")

N=input()
k=N[-1]
k=int(k)
if k in [2,4,5,7,9]:
    print("hon")
elif k in [0,1,6,8]:
    print("pon")
else:
    print("bon")

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

#define db(x) cerr << #x ": " << (x) << '\n';

using namespace std;

typedef long long ll;

const ll oo = 1e18;

bool f(ll n, ll k)
{
    if(k == 1)return false;
    while(n%k==0)
    {
        n/=k;
    }
    n = n%k;
    if(n == 1)return true;
    else return false;
}

vector<pair<ll,int>> FACTORIZATION(ll N)
{
    vector<pair<ll,int>> fact;
    for(ll i = 2 ; i*i <= N ; i++)
    {
        if(N%i == 0)
        {
            int cont = 0;
            while(N%i == 0)N /= i, cont++;
            fact.push_back({i,cont});
        }
    }
    if(N > 1)fact.push_back({N,1});
    return fact;
}

vector<ll> GENERATE_DIVISORS(vector<pair<ll,int>> fact)
{
    vector<ll> div = {1};
    for(int i = 0 ; i < fact.size() ; i++)
    {
        vector<ll> temp;
        ll p = 1;
        for(int j = 0 ; j <= fact[i].second ; j++)
        {
            vector<ll> nw, tp;
            for(int k = 0 ; k < div.size() ; k++)tp.push_back(div[k]*p);
            merge(temp.begin(),temp.end(),tp.begin(),tp.end(),back_inserter(nw));
            swap(temp,nw);
            p *= fact[i].first;
        }
        swap(div,temp);
    }
    return div;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll N;
    cin >> N;

    vector<ll> t1 = GENERATE_DIVISORS(FACTORIZATION(N));
    vector<ll> t2 = GENERATE_DIVISORS(FACTORIZATION(N-1));

//    for(auto x : t1)cout << x<< " ";
//    for(auto x : t2)cout << x<< " ";

    set<ll> st;
//
    for(int i = 0 ; i < t1.size() ; i++)if(f(N,t1[i]))st.insert(t1[i]);
    for(int i = 0 ; i < t2.size() ; i++)if(f(N,t2[i]))st.insert(t2[i]);

    cout << st.size() << '\n';

    return 0;
}


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

const int maxN = 1e5 + 10, oo = 2e9;

int n, k, h[maxN], f[maxN];

int abs(int x)
{
    return max(x, -x);
}

int main()
{
  //  freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &k);
    for (int i = 1 ; i <= n; ++i)
        scanf("%d", &h[i]);
    f[1] = 0;
    for (int i = 2; i <= n; ++i)
    {
        f[i] = oo;
        for (int j = 1; j <= k; ++j)
            if (i - j > 0)
                f[i] = min(f[i], f[i - j] + abs(h[i] - h[i - j]));
    }
    printf("%d", f[n]);
}

Measured memory_bytes: 1024
import bisect
import numpy as np
N = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
b_bisect = [bisect.bisect_left(a,one) for one in b]
b_cumsum = np.cumsum(b_bisect)
c_bisect = [bisect.bisect_left(b,one) for one in c]

ans = 0
for one in c_bisect:
    if one == 0:
        continue
    else:
        ans += b_cumsum[one-1]
print(ans)


Measured memory_bytes: 37644
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
struct asd
{
	long long int num;
	long long int wz;
	long long int cs;
}b[110000];
long long int a[110000], c[110000];
bool cmp(asd a, asd b)
{
	return a.num < b.num;
}
int main()
{
	long long int n, m;
	cin >> n >> m;
	for (long long int i = 1; i <= m; i++)
	{
		scanf("%lld %lld", &b[i].cs, &b[i].num);
		b[i].wz = i;
	}
	sort(b + 1, b + m + 1, cmp);
	memset(c, 0, sizeof(c));
	for (long long int i = 1; i <= m; i++)
	{
		c[b[i].cs]++;
		a[b[i].wz] = b[i].cs * 1000000 + c[b[i].cs];
	}
	for (int i = 1; i <= m; i++)
	{
		printf("%012lld\n", a[i]);
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void start()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
    //   freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
int32_t main()
{
	//start();
    int n; cin >> n;
    if(n >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <deque>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n, q;
    string s;

    cin >> n >> q;
    cin.ignore();
    getline(cin,s);
    vector<string> v(q);


    REP(i,q){
        getline(cin, v[i]);
    }

    int l = 0, r = n - 1;


    DEFOR(i,q,0){
        
        if(v[i][2]=='L'){
            if(s[l]==v[i][0]){

                l++;
            }  
            if(r+1 < n && v[i][0] == s[r+1]){
                r++;
            }
        }else{
        
            if(s[r]==v[i][0]){

                r--;
            }       
            if(l-1 >= 0 && v[i][0] == s[l-1]){
                l--;
            }
        }
    }

    cout<<max(r-l+1,0)<<endl;
    

    return 0;
}


Measured memory_bytes: 5312
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int N;
        cin >> N;
        if(N==0) break;
        int W,H;
        cin >> W >> H;
        vector<vector<char> > F(H,vector<char>(W,'.'));
        rep(i,N){
            int x,y;
            cin >> x >> y;
            x--;y--;
            F[y][x] = '*';
        }
        int S,T;
        cin >> S >> T;
        int ret = 0;

        for(int i=0;i<H-T+1;i++){
            for(int j=0;j<W-S+1;j++){
                int c = 0;
                for(int k=i;k<i+T;k++){
                    for(int l=j;l<j+S;l++){
                        if(F[k][l] == '*'){
                            c++;
                        }
                    }
                }
                ret = max(ret,c);
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  string s; cin >> s;
  string t = "CF";
  ll pos = 0;
  REP(i,SZ(s)){
    if(s[i] == t[pos]) pos++;
    if(pos==SZ(t)) yes();
  }
  no();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define DEKAI 1000000007
#define INF (1<<28)
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */


signed main(){

	int n, m;
	double  ans;
	cin>>n>>m;

n = max(n,m);

ans = (double)4/3*3.14159265*pow(n,3);
	printf("%.8f\n", ans);
  	return 0;
}


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

using namespace std;
typedef long long ll;

ll N;
ll A[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    ll memo = 0;
    for(int i=0;i<N;i++){
        if(A[i] != memo+1) continue;
        memo++;
    }
    if(memo == 0) cout << -1 << endl;
    else cout << N - memo << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AKenkenRace
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inputs[0], a = inputs[1], b = inputs[2], c = inputs[3], d = inputs[4];
            var s = Console.ReadLine().ToCharArray();

            // a ~ Math.Max(c, d) で岩が連続していなければそれぞれがゴールすることは可能
            // d < c の場合、２人が入れ替わる必要があるため
            // b - 1 ~ d + 1 の間で３マス連続で何もないマスが続く必要がある
            bool reachable = true, swappable = false;

            var nearGoal = c < d ? c : d;
            var farGoal = c < d ? d : c;
            var currentState = true;
            var stateCount = 0;
            for (var i = a - 1; i < farGoal; i++)
            {
                var state = s[i] == '.';
                if (state == currentState)
                {
                    stateCount++;
                    if (!currentState) reachable = false;
                    if (currentState && 3 <= stateCount && b <= i && i <= nearGoal) swappable = true;
                }
                else
                {
                    currentState = state;
                    stateCount = 1;
                }
            }

            var reachableToGoal = c < d ? reachable : reachable && swappable;
            var answer = reachableToGoal ? "Yes" : "No";

            // 解答の出力
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 12256
from collections import Counter

input()
arr = Counter(list(map(int,input().split())))
ans = [0,0]
for a in arr:  
  if arr[a] > 1:
    ans.append(a)
  if arr[a] > 3:
    ans.append(a)
ans.sort()
print(ans[-1] * ans[-2])

Measured memory_bytes: 18600
#include <iostream>

using namespace std;

int n, m, o, ans = 0, A[1010101];
int main() {
	cin >> n >> m >> o;
	if (n + m >= o) o > n ? cout << o - n << endl : cout << 0 << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 3072
a, b, c, x, y = map(int, input().split())
same = 0
diff = 0
if x>y:
    diff=min(a*(x-y), 2*c*(x-y))
    same = y
elif y>x:
    diff=min(b*(y-x), 2*c*(y-x))
    same = x
else:
    same = x
print(min((a+b)*same, 2*c*same) + diff)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());

int main() {
int n;
cin >> n;
int b[n-1];
REP(i,n-1) {
  cin >> b[i];
}
int a[n];
a[0]=b[0];
a[n-1]=b[n-2];
REP(i,n-2) {
  a[i+1]=min(b[i],b[i+1]);
}
ll ans=0;
REP(i,n) ans+=a[i];
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256