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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int a[3][3];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    REP(i,3) REP(j,3){
        cin>>a[i][j];
    }
    int n;
    cin>>n;
    //vi b(n);
    bool c[3][3]={};
    REP(i,n) {
        int b;
        cin>>b;
        REP(i,3) REP(j,3){
            if(a[i][j]==b) c[i][j]=true;
        }
    };

    string ans="No";

    REP(i,3){
        if(c[i][0] & c[i][1] & c[i][2]) ans="Yes";
    }
    REP(i,3){
        if(c[0][i] & c[1][i] & c[2][i]) ans="Yes";
    }
    if(c[0][0] & c[1][1] & c[2][2]) ans="Yes";
    if(c[0][2] & c[1][1] & c[2][0]) ans="Yes";
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    n--;
    while(n--){
        ll l, r;
        cin >> l >> r;
        ll j = max((a-1)/l, (b-1)/r) + 1;
        a = j * l;
        b = j * r;
    }
    cout << a + b;
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    //int n = 1;
    //cin >> n;
    //w//hile(n--){
        solve();
       // cout << endl;
    //}
    //fclose(stdout);
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long 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 repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
int main()
{
    string s;
    cin>>s;
    ll curr=1;ll ans=0;
    repA(i,1,s.size()-1){
        if(s[i]==s[i-1])
            curr++;
        else{
            if(curr%3==0){
                ans+=(curr*2)/3;
            }
            else if(curr%3==1)
                ans+=(curr/3)*2+1;
            else{
                if(i==s.size()-1){
                    ans+=(curr/3)*2+1;
                }
                else
                    ans+=(curr/3)*2+2;
                i++;
            }
            curr=1;
        }
    }
    if(curr%3==0)
        ans+=(curr*2)/3;
    else
        ans+=(curr/3)*2+1;
    cout<<ans;
    return 0;
}


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

using namespace std;

#define ll unsigned long long

void solve(){

    int n; cin >> n;
    vector<int> arr (n+1, 1);
    for(int i = 2; i <= n; ++i)
        for(int j = i; j <= n; j += i)
            ++arr[j];

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += (ll)i * (ll)arr[i];
    cout << ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}



Measured memory_bytes: 42252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
int a[maxx];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	double ans = (a[1] + a[2]) / 2.0;
	for(int i = 3; i <= n; i++) ans = (ans + a[i]) / 2.0;
	printf("%lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  X = list(map(int, input().split()))

  min_ = float('inf')
  for p in range(1, 101):
    sum_ = 0
    for i in range(N):
      sum_ += (X[i] - p)**2
    min_ = min(min_, sum_)

  print(min_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 63544
KS = list(map(int,input().split()))
sum =0
K = KS[0]
S = KS[1]
N=K+1
for i in range(N):
	if(S-i) > 2*K:
		continue
	for m in range(N):
		if(i+m) > S:
			break
		if (S -m-i) <= K:
			sum+=1
print(sum)

Measured memory_bytes: 41068
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	s=input()
	k=int(input())
	for c in list(s)[:k]:
		if c != '1':
			print(c)
			return 
	print('1')
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X;
    cin >> X;
    int ans = 1;
    for(int i=2; i<=1000; ++i)
    {
        int st = i*i;
        for(;st<=X;st*=i)
        ans = max(ans, st);
    }
    cout<<ans<<endl;
}

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

typedef long long ll ;
#define pb push_back
#define mod 1000000007
string s[2000] ;
ll dp[2000][2000] , vis[2000][2000] ;
ll n , m ;

ll ans ( ll i , ll j ) {

    if (i>=n or j>=m) return 0 ;
    if (i==n-1 and j==m-1) return 1 ;
    if (vis[i][j]) return dp[i][j] ;
    if (s[i][j]=='#') return 0 ;

    ll x = ans(i+1,j) ;
    ll y = ans(i,j+1) ;
    vis[i][j] = 1 ;

    return dp[i][j] = (x+y)%mod ;



}

int main() {
    ll i ;
    cin >> n >> m ;

    for(i=0;i<n;i++) cin >> s[i] ;

    cout << ans(0,0) ;

    return 0 ;


}


Measured memory_bytes: 33664
#include<stdio.h>

int min(int *a, int length){
    int min = a[0];
    for(int i = 0; i < length; i++){
        if(min > a[i]) min = a[i];
    }
    return min;
}

int main(void){
    int N = 0, T = 0;
    scanf("%d %d", &N, &T);
    int c[N], t[N];
    int TLE = 0; // 0 -> できない 1 -> できる
    for(int i = 0; i < N; i++){
        scanf("%d %d", &c[i], &t[i]);
    }

    int c_1[N];
    int j = 0;
    for(int i = 0; i < N; i++){
        if(t[i] <= T){
            TLE = 1;
            c_1[j] = c[i]; j++;
        }
    }
    if(TLE == 0){
        printf("TLE\n");
    }else{
        printf("%d\n", min(c_1, j));
    }

    return 0;
}

Measured memory_bytes: 128
N = gets.to_i
T, A = gets.chomp.split.map(&:to_f)
H = gets.chomp.split.map(&:to_f)

sub = 0xffffffff
ans = -1

H.each.with_index(1) do |hi, i|
  s = (A - (T - hi * 0.006)).abs
  if s < sub
    sub = s
    ans = i
  end
end

puts ans

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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n > 0) {
    ans++;
    n /= k;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
h,w = gets.chomp.split.map(&:to_i)
def solve h,w
	res = 10**18
	(1..h-1).each do |i|
		s = h*w
		# 縦割り
		s1 = i * w
		s2 = w/2 * (h-i)
		s3 = s - s1 - s2
		t = [s1,s2,s3].minmax

		# 横割り
		s2 = (h-i)/2 * w
		s3 = s - s1 - s2
		u = [s1,s2,s3].minmax
		
		res = [res,t[1] - t[0],u[1] - u[0]].min
	end
	res
end

puts [solve(h,w),solve(w,h)].min

Measured memory_bytes: 3836
// problem: "https://atcoder.jp/contests/abc155/tasks/abc155_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;


ll minNotes(string &s,vector<vector<ll>>&V,ll i,ll n,ll p)
{
    if(i == n)
        return 0;

    if(V[i][p] == -1)
    {
        if(!p)
            V[i][p] = min((ll)(s[i]-'0') + minNotes(s,V,i+1,n,p), 10 - (ll)(s[i]-'0') + (i == n-1) + minNotes(s,V,i+1,n,!p));

        else
            V[i][p] = min(9 - (ll)(s[i]-'0') + (i == n-1) + minNotes(s,V,i+1,n,p), 1 + (ll)(s[i]-'0') + minNotes(s,V,i+1,n,!p));
    }

    return V[i][p];
}

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

    vector<vector<ll>>V(s.size(),vector<ll>(2,-1));
    cout<<minNotes(s,V,0,s.size(),0);     // define

    return 0;
}


Measured memory_bytes: 149636
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int ans[10011];

void MAIN() {
    scanf("%d", &N);

    for (LL x=1;; x++) {
	if (x*x > N) break;
	for (LL y=1;; y++) {
	    if (x*x + y*y + x*y > N) break;

	    for (LL z=1;; z++) {
		LL g = x*x + y*y + z*z + x*y + y*z + z*x;
		if (g <= N) ans[g]++;
		if (g > N) break;
	    }
	}
    }

    for (int i=1; i<=N; i++) printf("%d\n", ans[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> r(N); vector<int> l(N);
  for (int i=0; i<N; i++) {
    cin >> r[i] >> l[i];
  }
  int cnt = 0;
  for (int i=0; i<N; i++) {
    cnt += l[i]-r[i]+1;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ALL(a) a.begin(), a.end()
#define REP(i,a) for(ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i,a,b) for(ll i(a), _##i(b); i <= _##i; ++i)
using namespace std;
using ll = long long;

void solve(){
    ll x;
    cin >> x;
    ll ans = 0;
    ans = 1000 * (x / 500);
    ans += 5 * (x % 500 / 5);
    cout << ans << "\n";
}

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

    int T = 1;
    //cin >> T;
    FOR(i,1,T){
        solve();
    }
}


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

using namespace std;

int N, M, Q;
vector<int> a, b, c, d;

long long f(int rem, int last, vector<int> curr){
	if(rem == 0){
		long long sum = 0;
		for(int i=0;i<Q;i++){
			if(curr[b[i]-1] - curr[a[i]-1] == c[i])
				sum += d[i];
		}
		/*for(int i=0;i<curr.size();i++){
			cout<<curr[i]<<" ";
		}
		cout<<": "<<sum<<"\n";*/
		return sum;
	}
	else{
		long long maxi = 0;
		for(int i=last;i<=M;i++){
			curr.push_back(i);
			maxi = max(maxi, f(rem-1, i, curr));
			curr.pop_back();
		}
		return maxi;
	}
}

int main(){
	cin>>N>>M>>Q;
	a.assign(Q+1, 0);
	b.assign(Q+1, 0);
	c.assign(Q+1, 0);
	d.assign(Q+1, 0);
	vector<int> curr;
	for(int i=0;i<Q;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	cout<<f(N, 1, curr)<<"\n";
	return 0;
}

Measured memory_bytes: 3600
L = []
for i in range(1, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            L.append(i * 10000 + j * 1000 + k * 100 + j * 10 + i)
a, b = map(int, input().split())
print(sum(i in L for i in range(a, b + 1)))
# print(sum(a <= e <= b for e in L))


Measured memory_bytes: 3060
local n = io.read("*n")
local arr
do
  local _accum_0 = { }
  local _len_0 = 1
  for i = 1, n do
    _accum_0[_len_0] = io.read("*n")
    _len_0 = _len_0 + 1
  end
  arr = _accum_0
end
table.sort(arr)
local r = 1
for i = 2, n do
  if arr[i - 1] ~= arr[i] then
    r = r + 1
  end
end
return print(r)

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize "03"
#pragma GCC target("sse4")

#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,n) for(ll i=a;a<n?i<n:i>=n;a<n?i+=1:i-=1)
#define loop(i,a, n) for(ll i = a; i <= n; i++)
#define loopb(i,a, n) for(ll i = a; i >= n; i--)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define setmem(x, k) memset(x, k, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
// const ll N = 1e6+5;	
// ll a[N], b[N], dp[N], in[N], out[N], level[N], vis[N];
// vl g[N];
ll n, m, W;


void solve() {
	ll x, y, z, p, q, r;
	cin >> n >> W;
	ll weight[n], value[n];
	f(i,n) cin >> weight[i] >> value[i];
	ll dp[n+1][W+1];
	for (ll i = 0; i < n+1; i++) { 
       	for (ll w = 0; w < W+1; w++) { 
           	if (i==0 || w==0)
               	dp[i][w] = 0; 
           	else if (weight[i-1] <= w) 
                dp[i][w] = max(value[i-1] + dp[i-1][w-weight[i-1]],  dp[i-1][w]); 
           	else
                dp[i][w] = dp[i-1][w]; 
       } 
   } 
   cout << dp[n][W];
}

int32_t main() {
	IOS
	ll T;
	// cin >> T;
	// while(T--)
		solve();
	cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
	return 0;
}

Measured memory_bytes: 79232
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int maxtime(int x) { return (x + 9) / 10 * 10; }

int remtime(int x) { return maxtime(x) - x; }

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int ans = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
  ans -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s;
  int countA=0;
  int countB=0;
  bool irap=true;
  int ans;
  
  cin >> s;
  
  for (int i=0;i < s.size();i++){
    if(irap==true){
      if (s.at(i)=='0'){
        countA++;
      }else{
        countB++;
      }
      irap=false;
    }else{
      if (s.at(i)=='1'){
        countA++;
      }else{
        countB++;
      }
      irap=true;
    }
  }
  if (countA < countB){
    ans=countA;
  }else{
    ans=countB;
  }
  cout << ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,d[31][5001];
ll k,c[5001],sum[31][5001],best[31][5001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,n){
		cin>>d[0][i];
		d[0][i]--;
	}
	rep(i,n){
		cin>>c[i];
	}
	rep(i,n){
		sum[0][i]=c[d[0][i]];
		best[0][i]=c[d[0][i]];
	}
	rep(i,30){
		rep(j,n){
			d[i+1][j]=d[i][d[i][j]];
			sum[i+1][j]=sum[i][j]+sum[i][d[i][j]];
			best[i+1][j]=max(best[i][j],sum[i][j]+best[i][d[i][j]]);
		}
	}
	ll ans=-1e18;
	rep(i,n){
		ll kk=k,b=0,sm=0;
		int now=i;
		while(kk){
			if(kk%2){
				ans=max(ans,sm+best[b][now]);
				sm+=sum[b][now];
				now=d[b][now];
			}
			b++;
			kk/=2;
		}
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 6716
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<int> in_num(N, 0);
    vector<vector<int> > e(N, vector<int>());
    vector<int> ans(N, 0);
    for(int i=0; i<N-1+M; i++) {
        int s, t;
        cin >> s >> t;
        e[s-1].push_back(t-1);
        in_num[t-1]++;
    }
    
    queue<int> que;
    for(int i=0; i<N; i++) {
        if(in_num[i]) {
            ;
        } else {
            que.push(i);
        }
    }
    
    while(!que.empty()) {
        int cur=que.front();
        que.pop();
        
        for(int i=0; i<e[cur].size(); i++) {
            in_num[e[cur][i]]--;
            if(in_num[e[cur][i]]) {
                ;
            } else {
                que.push(e[cur][i]);
                ans[e[cur][i]] = cur+1;
            }
        }
    }
    
    for(int i=0; i<N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if (n < 6) {
			int[] a = {2, 3, 25, 30, 60};
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.append(a[i]).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		} else {
			int[][] a = {{3, 9, 2, 10, 4, 8, 6, 12}, {6, 3, 9, 2, 10, 4, 8, 12}};
			StringBuilder sb = new StringBuilder();
			int k = n % 2;
			int x = n / 8;
			int y = n % 8;
			for (int i = 0; i < x; i++) {
				int b = 12 * i;
				for (int j = 0; j < 8; j++) {
					sb.append(a[k][j] + b).append(' ');
				}
			}
			int b = 12 * x;
			for (int j = 0; j < y; j++) {
				sb.append(a[k][j] + b).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] ss = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = ss[0];
            int b = ss[1];
            if (a>b)
            {
                WriteLine(a+a-1);
            }
            else if(a<b)
            {
                WriteLine(b + b - 1);
            }
            else
            {
                WriteLine(a + b);
            }
        }
    }
}


Measured memory_bytes: 13396
N = int(input())

num_list = [int(i) for i in input().split()]

cnt = 0
flag = True

while flag:
    for i in range(N):
        if num_list[i] % 2 == 1:
            flag = False
            break
        else:
            num_list[i] = num_list[i] / 2
            if i == N - 1:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<string>

int main(){
  int N;
  std::cin>>N;
  std::string W[N];

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

  bool rule=true;
  for(int i=0;i<N;i++)
    for(int j=i+1;j<N;j++)
      if(W[i]==W[j]) rule=false;

  for(int i=0;i<N;i++){
    if(i!=N-1&&W[i][W[i].length()-1]!=W[i+1][0])
      rule=false;
    }


  if(rule) std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int A,B,x,y,z;
    scanf("%d %d",&A,&B);
    x=A+B;
    y=A-B;
    z=A*B;
    if(x>y && x>z){
        printf("%d\n",x);
    }
    else if(y>z){
        printf("%d\n",y);
    }
    else{
        printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
  	int temp = (s[5]-'0') * 10 + (s[6]-'0');
  	if(temp<=4) puts("Heisei"); 
    else puts("TBD");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    char a[4002],b[4002];
    while(scanf("%s\n%s\n",a,b)!=-1){
        int asize=strlen(a),bsize=strlen(b);
        int ma=0;
        for(int i=0;i<asize;i++){
            int miat=min(bsize,asize-i);
            bool is=false;
            int now=0;
            for(int j=0;j<miat;j++){
                if(!is&&a[i+j]==b[j]){
                    now++;
                    is=true;
                }else if(is&&a[i+j]==b[j])now++;
                else if(is&&a[i+j]!=b[j]){
                    ma=max(ma,now);
                    now=0;
                    is=false;
                }
            }
            ma=max(now,ma);
        }
        for(int i=0;i<bsize;i++){
            int miat=min(asize,bsize-i);
            bool is=false;
            int now=0;
            for(int j=0;j<miat;j++){
                if(!is&&a[j]==b[i+j]){
                    now++;
                    is=true;
                }else if(is&&a[j]==b[i+j])now++;
                else if(is&&a[j]!=b[i+j]){
                    ma=max(ma,now);
                    now=0;
                    is=false;
                }
            }
            ma=max(now,ma);
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 100;
    REP(i, n){
        int a;
        cin >> a;
        int cnt = 0;
        while(a % 2 == 0){
            cnt++;
            a /= 2;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	long double x,y;
	cin>>x>>y;
	cout<<floor(log2(y)-log2(x))+1<<endl;
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
	char buf[10];
	int num1;
	int num2;
	int sum;
	
		fgets(buf,10,stdin);
		sscanf(buf,"%d %d",&num1,&num2);
	
		sum = num1 + num2;
	
	if(sum < 10)
		printf("%d \n",sum);
	else
		printf("error\n");
		
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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; }


int main(){ 
  int n, k; cin >> n >> k;
  vector<int> A(n); rep(i, n) cin >> A[i];
  if(k >= 5000){
    rep(i, n) cout << n << " ";
    cout << ln;
  }else{
    rep(i, k){
      vector<int> plus(n), minus(n);
      rep(j, n){
        int s = max(0, j-A[j]), t = min(n-1, j+A[j]);
        plus[s]++; minus[t]++;
      }
      int cnt = 0;
      rep(j, n){
        cnt += plus[j];
        A[j] = cnt;
        cnt -= minus[j];
      }
    }
    rep(i, n){
      cout << A[i] << " ";
    }cout << ln;
  }
}


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

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

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll A, B, Q;
vector<ll> s, t;

int main(int argc, char **argv)
{
	cin >> A >> B >> Q;
	
	s.resize(A+2);
	REP(i, A) cin >> s[i+1];
	s[0] = -INF;
	s[A+1] = INF;
	
	t.resize(B+2);
	REP(i, B) cin >> t[i+1];
	t[0] = -INF;
	t[B+1] = INF;

	REP(_, Q)
	{
		ll x; cin >> x;
		ll res{INF};
		auto jin_r_it = lower_bound(ALL(s), x);
		auto jin_l_it = prev(upper_bound(ALL(s), x));
		auto tera_r_it = lower_bound(ALL(t), x);
		auto tera_l_it = prev(upper_bound(ALL(t), x));

		ll jinld = abs(*jin_l_it - x);
		ll jinrd = abs(*jin_r_it - x);
		ll terald = abs(*tera_l_it - x);
		ll terard = abs(*tera_r_it - x);

		// right
		res = min(res, max(jinrd, terard));
		// left , right
		res = min(res, jinrd+terard);
		res = min(res, max(jinrd, terald)+min(jinrd, terald)*2);
		res = min(res, max(terard, jinld)+min(terard, jinld)*2);
		res = min(res, max(jinld, terald));

		std::cout << res << std::endl;
	}
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int n; cin >> n;
  rep(i,100)rep(j,100)
    if(i*4+j*7 == n){
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
 
using namespace std;

signed main() {
	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	rep(i, N) cin >> A[i];

	map<int, int> m;
	rep(i, N) m[A[i]]++;

	vector<int> nums;
	itrep(it, m) {
		nums.push_back((*it).second);
	}

	sort(all(nums));

	int ret = 0;
	int left = m.size() - K;
	int pt = 0;
	while (left > 0) {
		int num = nums[pt];
		ret += nums[pt];
		left--;
		pt++;
	}

	cout << ret << endl;

	return 0;
}


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

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

int main() {
  // 2^31 以上の値を扱うときは long long
  long long X, now = 100; cin >> X;
  int year;
  for (year = 0; now < X; ++year) {
    // 小数 から 整数 に変換するときは、切り捨てられる
    now *= 1.01;
  }
  cout << year << endl;
}


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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

I64		X, Y;

int		main()	{
		cin >> X >> Y;
		
		int ans= 0;
		for (; X <= Y; ans++, X<<= 1);
		
		cout << ans;
}




Measured memory_bytes: 256
import heapq

N,K = map(int, input().split())
P = [int(p) for p in input().split()]

h = []
H = []
for i in range(K):
    heapq.heappush(h, (P[i], i))
    heapq.heappush(H, (-P[i], i))
    
ans = 1
for i in range(N-K):
    while h[0][1] < i:
        heapq.heappop(h)
    while H[0][1] < i:
        heapq.heappop(H)
    heapq.heappush(h, (P[i+K], i+K))
    heapq.heappush(H, (-P[i+K], i+K))
    if h[0][0] == P[i] and -H[0][0] == P[i+K]:
        continue
    ans += 1
    
f = 0
cnt = 1
for i in range(N-1):
    if P[i] < P[i+1]:
        cnt += 1
    else:
        if cnt >= K and f == 1:
            ans -= 1
        elif cnt >= K and f == 0:
            f = 1
        cnt = 1
        
if cnt >= K and f == 1:
    ans -= 1
    
print(ans)

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

int main() {
    int req[10]={0,2,5,5,4,5,6,3,7,6};
    int n,m;cin>>n>>m;
    int a[m];
    for (int i=0;i<m;i++)
        cin>>a[i];
    sort(a,a+m,greater<int>());
    int dp[n+1];
    fill(dp,dp+n+1,-1);
    dp[0]=0;
    for (int i=0;i<m;i++)
        for (int j=req[a[i]];j<=n;j++)
            if (dp[j-req[a[i]]]!=-1)
                dp[j]=max(dp[j],dp[j-req[a[i]]]+1);
    string ans;
    for (int i=n,j=0;j<m;j++)
        if (i-req[a[j]]>=0&&dp[i]-1==dp[i-req[a[j]]]) {
            ans+=to_string(a[j]);
            i-=req[a[j]];
            j=-1;
        }
    cout<<ans<<endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input1 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var H = input1[0];
        var A = input1[1];

        var n = Math.Ceiling((float) H / (float) A);
        Console.WriteLine(n);
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int main( int argc, char *argv[] )
{
	int A = 0;
	int B = 0;
	int C = 0;

	scanf( "%d %d %d", &A, &B, &C );

	if( (A + B) >= C )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
def sum_ari_seq(a):
    return a * (a + 1) // 2


def mean(a):
    return sum_ari_seq(a) / a


n, k = map(int, input().split())
p = list(map(int, input().split()))

max_value = 0
for i in range(k):
    max_value += mean(p[i])

cur = max_value
for i in range(k, n):
    cur += (mean(p[i]) - mean(p[i-k]))
    max_value = max(max_value, cur)

print(max_value)


Measured memory_bytes: 24804
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int i;
    int ans=1;
    for(i=0;i<n-1;i++){
        if(s[i] != s[i+1])
        ans++;
    }
    printf("%d\n",ans);
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}
int main(void)
{
  ll x, k, d, count, ans;
  cin >> x >> k >> d;
  if(abs(x)>d){
    count = abs(x)/d;
    if(count>=k){
      ans = abs(x)-d*k;
    }else{
      x = abs(x)%d;
      k = k-count;
      if(k%2==0){
        ans = abs(x);
      }else{
        ans = abs(d-x);
      }
    }
  }else{
    if(k%2==0){
      ans = abs(x);
    }else{
      ans = abs(d-abs(x));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3544
n, m, q = [int(e) for e in input().split()]

import itertools as it
abcd=list()
for i in range(q):
    abcd.append([int(e) for e in input().split()])


all = it.combinations_with_replacement(range(1,m+1),n)

count=list()
num=0
for i in all:
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1] == j[2]:
            num += j[3]
        else:
            pass
    count.append(num)
    num=0

print(max(count))

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

using namespace std;
typedef long long ll;

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

bool isBalancedS(const string &s) {
    int cnt = 0;
    rep(i, s.size()) {
        if(s[i] == '[') cnt++;
        if(s[i] == ']') cnt--;
        if(cnt < 0) return false;
    }
    if(cnt > 0) return false;
    return true;
}
bool isBalancedR(const string &s) {
    int cnt = 0;
    rep(i, s.size()) {
        if(s[i] == '(') cnt++;
        if(s[i] == ')') cnt--;
        if(cnt < 0) return false;
    }
    if(cnt > 0) return false;
    return true;
}

bool isBalanced(const string &s) {
    if(!isBalancedS(s)) return false;
    if(!isBalancedR(s)) return false;
    // check substring
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == '(') {
            int len = 0;
            int cnt = 1;
            for(int j=i+1; j<s.size(); ++j, ++len) {
                if(s[j] == '(') cnt++;
                if(s[j] == ')') cnt--;
                if(cnt==0) break;
            }
            if(!isBalancedS(s.substr(i+1, len))) return false;
        } else if(s[i] == '[') {
            int len = 0;
            int cnt = 1;
            for(int j=i+1; j<s.size(); ++j, len++) {
                if(s[j] == '[') cnt++;
                if(s[j] == ']') cnt--;
                if(cnt==0) break;
            }
            if(!isBalancedR(s.substr(i+1, len))) return false;
        }
    }
    return true;
}

int main(void){
    string s;
    while(getline(cin, s) && s!=".") {
        if(isBalanced(s)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3188
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  string a;
  cin>>a;
  int count0=0;
  int count1=0;
  rep(i,a.size()){
     if(a.at(i)=='0'){
        count0++;
     }
     else{
        count1++;
     }
  }
  cout<<2*min(count1,count0)<<endl;
}



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

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> lii;

ll h, w, ans = 0;

int main() {

    cin >> h >> w;
    if(h == 1 || w == 1) ans = 1;
    else if(h % 2 == 1 && w % 2 == 1) {
        ans = ((h - 1) * w) / 2;
        ans += (w / 2) + 1;
    }
    else {
        ans = (h * w) / 2;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
  
  int n,m,in[10000],out[10000],s=0,max;
  
  cin >>n;
  cin >>m;
  
  for(int i=0 ; i < n ; i++){
    cin >>in[i]>>out[i];
  }
  
  max=m;
  s+=m;
  
  for(int i=0 ; i < n ; i++){
    
    s+=in[i];
    s-=out[i];
    
    if( s < 0 ){
      max=0;
      break;
    }
    
    if( s > max){
      max=s;
    }
    
  }
  
  cout <<max<<endl;
  
  return 0;

}

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

int main(){
    string n;
    cin>>n;
    for(int i=0; i<3; i++){
        if(n[i]=='9')n[i]='1';
        else if(n[i]=='1')n[i]='9';
    }
    cout<<n<<endl;
    return 0;
}

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

using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
    int n,ans;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        m[x]++;
    }
    for(int i=0;i<v.size();i++) 
      if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; 
      else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

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

void print(int numbers[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << numbers[i];
  }
  cout << endl;
}

int selection_sort(int numbers[], int n) {
  int count = 0;

  for (int i = 0; i < n; i++) {
    int minj = i;

    for (int j = i; j < n; j++)
      if (numbers[j] < numbers[minj])
        minj = j;

    if (i != minj) {
      count++;
      swap(numbers[i], numbers[minj]);
    }
  }

  print(numbers, n);

  return count;
}

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

  int numbers[n] = {0};

  for (int i = 0; i < n; i++)
    cin >> numbers[i];

  int count = selection_sort(numbers, n);
  cout << count << endl;

  return 0;
}



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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  vector<string>vs;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    bool flag=true;
    for(int j=0;j<m;j++){
      if(s[j]=='#')flag=false;
    }
    if(flag==false)vs.pb(s);
  }
  vector<string>ans;
  for(int i=0;i<m;i++){
    bool flag=true;
    string s="";
    for(int j=0;j<vs.size();j++){
      if(vs[j][i]=='#')flag=false;
      s+=vs[j][i];
    }
    if(flag==false)ans.pb(s);
  }
  for(int i=0;i<ans[0].size();i++){
    for(int j=0;j<ans.size();j++){
      cout<<ans[j][i];
    }
    cout<<endl;
  }
  return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int C[N], S[N], F[N];
    REP(i, N - 1)
    {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < N - 1; ++i)
    {
        int x = S[i] + C[i];
        for (int j = i + 1; j < N - 1; ++j)
        {
            if (x > S[j])
            {
                if (x % F[j] != 0)
                {
                    x += F[j] - x % F[j];
                }
            }
            else
            {
                x = S[j];
            }
            x += C[j];
        }
        cout << x << endl;
    }

    cout << "0" << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
a = map(int, input().split())
alist = list(a)

tmp = []

for i in range(n-1):

    if i == 0:
        tmp.append(alist[i])
        tmp.append(alist[i])
    else:
        tmp.append(alist[i])
        if alist[i] < max(tmp[i], tmp[i+1]):
            tmp[i] = alist[i]


sum = 0
for i in tmp:
    sum += int(i)

print(sum)

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

int main(){
    int N,W;
    cin>>N>>W;
    int dp[2][W+1];
    fill(dp[0],dp[2],0);
    for(int i=0;i<N;i++){
        int v,w;
        cin>>v>>w;
        for(int j=0;j<w;j++)dp[i%2][j]=dp[(i+1)%2][j];
        for(int j=0;j<=W;j++){
            if(j+w<=W){
                dp[i%2][j+w]=max(dp[(i+1)%2][j+w],dp[(i+1)%2][j]+v);
            }
        }
    }
    int max=0;
    for(int i=0;i<=W;i++){
        if(max<dp[(N+1)%2][i])max=dp[(N+1)%2][i];
    }
    cout<<max<<endl;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> a(110);
    for(int i=0;i<n;i++)cin>>a.at(i);
    for(int i=n-1;i>=0;i--){
        if(i==0){
            cout<<a.at(i);
            break;
        }
        cout<<a.at(i)<<" ";
    }
    cout<<endl;
}



Measured memory_bytes: 3096
import math
MOD = 1000000007
N = int(input())

d_p = dict()
d_m = dict()
ans = 1
zz = 0

for n in range(N):
    a,b = map(int,input().split())

    if a==0 and b==0:
        zz += 1
        continue
    if a==0:
        n_sign = 0
        b = 0
    elif b==0:
        n_sign = 1
        a = 0

    else:    
        n_sign = ((a<0) + (b<0))%2
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a,b)
        a//=gcd
        b//=gcd

    if n_sign==1:
        s =str(b)+'/'+str(a)
        d_m[s] = d_m.get(s,0) + 1
    elif n_sign==0:
        s =str(a)+'/'+str(b)
        d_p[s] = d_p.get(s,0) + 1      

for k,v in d_m.items():
    if k in d_p:
        ans *= (2**v + 2**d_p[k] - 1)
        d_p.pop(k)
    else:
        ans *= 2**v
    ans %= MOD

for k,v in d_p.items():
    ans *= 2**v
    ans %= MOD

ans -= 1
ans += zz
ans %= MOD
print (ans)


Measured memory_bytes: 38220
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M),b(M),v(N-1);
  rep(i,M){
    cin >> a.at(i) >> b.at(i);
  }
  rep(i,N-1){
    v.push_back(i+2); //2,...,N
  }
  
  bool flg;
  int left, right, cnt=0;
  while(1){
    for(int i=0; i<N-1; i++){
      flg = false;
      if(i==0) left = 1;
      else left = v.at(i-1);
      right = v.at(i);
      
      for(int j=0; j<M; j++){
        if((left == a.at(j) && right == b.at(j))
           || (left == b.at(j) && right == a.at(j))){
          //cout << "left, right: " << left << right << "   a, b: " << a.at(j) << b.at(j) << endl;
          flg = true;
          break;
        }
      }
      if(!flg) break;
    }
    if(flg) cnt++;
    if(!next_permutation(v.begin(), v.end())) break;
  }
    
  cout << cnt << endl; // 標準出力
}

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

bool isPrime(int x) {
    if (x == 2)
        return true;
    if (x < 2 || x % 2 == 0)
        return false;
    for (int i = 3; i <= sqrt(x); i += 2) {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main(int argc, char *argv[])
{
    int n, cnt;
    while (cin >> n, n) {
        cnt = 0;
        for (int i = n + 1; i <= n * 2; ++i) {
            if (isPrime(i))
                cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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



int main() {

	int k,tmp;
	int calc=0;
	std::vector<int>num;
	std::cin >> k;
	
	rep(i, 0, k) {
		std::cin >> tmp;
		num.push_back(tmp-1);
	}
	
	rep(i, 0, num.size()) {
		if(i < num[i]) {
			if(i == num[num[i]])calc++;
		}
	}
	
	std::cout << calc << std::endl;

	
	return 0;
}

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

int main() {
  int N, max, ans = 1;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  max = H.at(0);
  for (int i = 1; i < N; i++) {
    if (max > H.at(i)) continue;
    max = H.at(i);
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, K;
	cin >> N >> K;

	vector<int> a(N);
	rep(i, N) cin >> a[i];

	vector<int> v;
	rep(i, N) {
		int sum = 0;
		REP(j, i, N - 1) {
			sum += a[j];
			v.push_back(sum);
		}
	}

	int ret = 0;
	bool start = false;
	for (int bit = 50; bit >= 0; bit--) {
		vector<int> pool;
		int base = 1LL << bit;

		for (int &num : v) {
			if ((num & base)) {
				pool.push_back(num);
			}
		}

		if (start) {
			if (pool.size() >= K) {
				v = pool;
				ret |= base;
			}
		} else if (pool.size() >= K) {
			start = true;
			v = pool;
			ret |= base;
		}
		//cerr << "bit:" << bit << " ret:" << ret << endl;
		//cerr << " v:";
		//for (int num : v) cerr << num << " ";
		//cerr << endl;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 6260
from sys import stdin
n = int(stdin.readline().rstrip())
a = [0]*n
for i in range(n):
    a[i] = stdin.readline().rstrip()
a = sorted(a)
answer = 1
for i in range(n-1):
    if a[i] != a[i+1]:
        answer += 1
print(answer)

Measured memory_bytes: 25492