akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#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');
}

LL N, X, M;
int T[100011];

void MAIN() {
    scanf("%lld%lld%lld", &N, &X, &M);

    memset(T, -1, sizeof T);
    int cnt = 0;
    LL A = X;
    while (T[A] == -1) {
	T[A] = cnt;
	cnt++;
	A = A * A % M;
    }

    int tail = T[A];
    int cycle = cnt - tail;
    LL joint = A;
    A = X;

    LL ans = 0;

    for (int i=0; i<tail; i++) {
	if (i < N) ans += A;
	A = A * A % M;
    }

    LL sum = 0;
    REP (i, cycle) {
	sum += A;
	A = A * A % M;
    }

    if (N >= tail) {
	ans += (N - tail) / cycle * sum;

	int rest = (N - tail) % cycle;
	REP (i, rest) {
	    ans += A;
	    A = A * A % M;
	}
    }


    printf("%lld\n", ans);
}

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



Measured memory_bytes: 4256
import collections
import bisect

def main():
    s=input()
    t=input()
    s = s*2
    n = len(s)
    cs = collections.Counter(s)
    ct = collections.Counter(t)
    for sct in ct.keys():
        if cs[sct] == 0:
            return -1
    dc = collections.defaultdict(list)
    for i in range(n):
        dc[s[i]].append(i+1)
    res = 0
    ptl = 0
    for i in range(len(t)):
        tl = dc[t[i]][bisect.bisect_left(dc[t[i]],ptl+1)]
        res += tl - ptl
        ptl = tl - n//2 if tl > n//2 else tl
    return res

print(main())

Measured memory_bytes: 54892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define PI 3.1415926535897932384626
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	char a;
	cin>>a;
	if(a>='a' && a<='z') cout<<'a';
	else cout<<'A';
	return 0;
}


Measured memory_bytes: 3636
// AOJ ALDS1_2_B Selection Sort
// 2018.4.27 bal4u

#include <stdio.h>

int selection_sort(int n, int *a)
{
	int i, j, minj, x;
int ans = 0;

	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j] < a[minj]) minj = j;
		}
		if (i != minj) {
			x = a[i], a[i] = a[minj], a[minj] = x;
ans++;
		}
	}
return ans;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int a[102];

int main()
{
	int N, i, k;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	k = selection_sort(N, a);
	printf("%d", a[0]);
	for (i = 1; i < N; i++) printf(" %d", a[i]);
	putchar('\n');
	printf("%d\n", k);
	return 0;
}



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

int main()
{
    long long i,j,k,m,n;
    cin>>n;
    vector<long long>v;
    cin>>k;
    v.push_back(k);
    m=k;
    for(i=0;i<n-1;i++)
    {
        cin>>k;
        v.push_back(k);
        m^=k;
    }
    for(i=0;i<n;i++)
    {
        j=m^v[i];
        cout<<j<<" ";
    }
    cout<<endl;

}


Measured memory_bytes: 5272
// luogu-judger-enable-o2
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='a'){
	cout<<"vowel"<<endl;
	return 0;
	}
	if(s[0]=='e'){
	cout<<"vowel"<<endl;
	return 0;
	}
	if(s[0]=='i'){
	cout<<"vowel"<<endl;
	return 0;
	}
	if(s[0]=='o'){
	cout<<"vowel"<<endl;
	return 0;
	}
	if(s[0]=='u'){
	cout<<"vowel"<<endl;
	return 0;
	}
	else cout<<"consonant"<<endl;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int l,r,d;
  cin >> l >> r >> d;

  int ans = 0;
  for(int i = l; i <= r; i++){
    if(i%d == 0) ans ++;
  }

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int x,y,a,b,c;
	ll p[100001],q[100001],r[100001];

	cin>>x>>y>>a>>b>>c;
	rep(i,a)cin>>p[i];
	rep(j,b)cin>>q[j];
	rep(k,c)cin>>r[k];
	sort(p,p+a,greater<ll>());
	sort(q,q+b,greater<ll>());
	sort(r,r+c,greater<ll>());

	ll d[200002]={};
	rep(i,x)d[i]=p[i];
	rep(i,y)d[i+x]=q[i];
	sort(d,d+x+y);

	ll t=0;
	rep(i,x+y){
		if(d[i]<r[i])t+=r[i];
		else t+=d[i];
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    print(-(-N//2))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#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 >> K;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
        cin >> d[i];
    vector<int> sd(N + 1, 0);
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        sd[i] = sd[i - 1] + d[i - 1];
        sum += d[i - 1];
    }
    for (int i = 1; i <= min(N, K); i++) {
        for (int j = N - i, k = 0; j <= N; j++, k++) {
            vector<int> n;
            for (int l = 0; l < k; l++) {
                if (d[l] < 0)
                    n.push_back(d[l]);
            }
            for (int l = j; l < N; l++) {
                if (d[l] < 0)
                    n.push_back(d[l]);
            }
            sort(n.begin(), n.end());
            int x = 0;
            for (int l = 0; l < min((ll)n.size(), K - i); l++) {
                x -= n[l];
            }
            ll tmp = 0;
            tmp = sd[j] - sd[k];
            tmp = sum - tmp + x;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long n,m;
  cin >> n >> m;
  long a[100],b[100],c[100],d[100];
  for(int i=1; i<=n; i++) cin >>a[i]>>b[i];
  for(int i=1; i<=m; i++) cin >>c[i]>>d[i];
  
  vector<vector<long>> e(100,vector<long>(100));
  vector<long> f(100,1000000000);
  int g[100];
 
  for(int i=1; i<=n; i++){
   for(int j=1; j<=m; j++){
    e[i][j] = abs(a[i]-c[j])+abs(b[i]-d[j]);
     if(f[i] > e[i][j]) {
       f[i] = e[i][j];
       g[i] = j;
     }
   }
  }
 for(int i=1; i<=n; i++) cout << g[i] << endl;
  
  
  
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
using namespace std;
 
int main(){
  int n,total = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i){
    total += i;
  }
  cout << total << endl;
}

Measured memory_bytes: 256
# Candy Disribution Again

N, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
num = 0
for i in range(len(a)):
    if x >= a[i] :
        num += 1
        x -= a[i]
    else :
        break
if x > 0 and num == N :
    num -= 1
print(num)


Measured memory_bytes: 3060
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    a, b, c = MI()
    if a <= c and c <= b:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    int n;
    cin>>n;
    map<string, int> m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<m.size();
    
    
    
} 

Measured memory_bytes: 19288
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

typedef tree<
        pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{*
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/


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

    ll n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    ll sum = 0;
    for (auto it: a) sum+=it;
    if (sum%((n*(n+1)/2))) {cout<<"NO"; return 0;}
    ll K = sum/(n*(n+1)/2);

    //cout<<K<<endl;

    vector<ll> diff(n);
    for (int i = 0; i<n; i++) diff[i] = a[(i+1)%n] - a[i] - K;

    for (int i = 0; i<n; i++)
    {
        if (diff[i]>0) {cout<<"NO"; return 0;}
        if ((-diff[i])%n) {cout<<"NO"; return 0;}
    }
    cout<<"YES";


}



Measured memory_bytes: 4744
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func findPrime(x int) int {
	for {
		divided := true
		mx := int(math.Sqrt(float64(x)))
		for i := 2; i < mx; i++ {
			if x%i == 0 {
				divided = false
				break
			}
		}
		if divided {
			return x
		}
		x++
	}
}

func main() {
	x := nextInt()
	prime := findPrime(x)
	fmt.Println(prime)
}


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

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

  int ans = 0;
  for(int i=1; i<=N; i+=2){
    int cnt = 0;
    for(int j=1; j<=i; j++){
      if(i%j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
l=sorted(l,key=lambda x:-x[0]-x[1])
a=0
b=0
for i in range(n):
    if i%2==0:
        a+=l[i][0]
    else:
        b+=l[i][1]
print(a-b)

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

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var a = RInts();
        Array.Sort(a);
        WriteLine(a.Max()-a.Min());
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


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

using namespace std;

void dfs(const vector<vector<int> > &G, vector<vector<int> > &visitTime, int& count, int node)
{
  if(visitTime[node][0] != 0){
    return;
  }else{
    visitTime[node][0] = ++count;
  }
  for (int i = 0; i < G.size();i++){
    if(G[node][i] == 1){
      dfs(G, visitTime, count, i);
    }
  }
  visitTime[node][1] = ++count;
}

int main()
{
  int N, U, K, V;
  int count = 0;
  cin >> N;
  vector<vector<int> > G(N, vector<int>(N, 0));
  vector<vector<int> > visitTime(N, vector<int>(2, 0));
  for (int i = 0; i < N; i++)
  {
    cin >> U >> K;
    for (int j = 0; j < K;j++){
      cin >> V;
      G[U - 1][V - 1] = 1;
    }
  }
  for (int i = 0; i < N;i++){
    dfs(G, visitTime, count, i);
  }
  for (int i = 0; i < N;i++){
    cout << i + 1 << " " << visitTime[i][0] << " " << visitTime[i][1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B,C; cin>>A>>B>>C;
	ote(A+B+C>=22?"bust":"win");
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    char S[N + 10];
    scanf("%s", S);

    int cnt = 0;

    for (int i = 0; i < N - 2; i+= 1){
        if(S[i] == 'A' && S[i+1] == 'B'&& S[i+2] == 'C'){
            cnt += 1;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {

    int n,m;
    cin >> n >> m;
    char c;
    for(int x = 0;x<=n+1;x++){
        for(int i = 0;i<=m+1;i++){
            if(i == 0 || i == m + 1 || x == 0 || x == n + 1){
                cout << "#";
            }
            else{
                cin >> c;
                cout << c;
            }
        }
        cout << "\n";
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[100010];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i];
	sort(a,a+n);
	
	int c=0,d=0;
	REP(i,0,n){
		if(a[i]==a[i+1] and a[i+1]==a[i+2]) c++,i++;
		else if(a[i]==a[i+1]) d++;
	}
	
	cout << n-2*c-(d-d%2+2*(d%2)) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！



//Eと名のつくのはデバッグ用！
int EintN(int array[],const int num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const int num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}


int AllElementChange0(int array[],const int num){
    for(int i=0;i<num;i++){array[i]=0;}
    return 0;
}


int test(){
    return 0;
}

int Ap(){
    int ans;ans=0;
    int a;
    cin>>a;
    
    OutputAndReturn0(a*a*3);
    return 0;
}

int Bp(){
    int ans;ans=0;
    int N,D;
    cin>>N>>D;
    OutputAndReturn0((N+2*D)/(2*D+1));
    return 0;
}

int Cp(){
    int ans;ans=0;
    int N;cin>>N;
    int A[N+1];
    AllElementChange0(A, N+1);
    int max1=0,max2=0;
    FOR(i, 1, N+1){
        cin>>A[i];
        
        if(max1<=A[i]){max2=max1;max1=A[i];}
        else if(max2<=A[i]){max2=A[i];}
        
    }
    
    FOR(i, 1, N+1){
        cout<< ((A[i]==max1)?max2:max1) <<endl;
    }
   
    //OutputAndReturn0(ans);
    return 0;
}

int Dp(){
    int ans;ans=0;
    OutputAndReturn0(ans);
    return 0;
}

signed main(){
    //test();
    //Ap();
    //Bp();
    Cp();
    //Dp();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    bool can = false;
    for(int i = 1;i <= 9;i++){
        for(int j  = 1;j <= 9;j++){
            if(i*j == n) can = true;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int P, Q, R;

int main(int argc, char **argv) {
    std::cin >> P >> Q >> R;

    int ret = P + Q;
    ret = std::min(ret, Q + R);
    ret = std::min(ret, R + P);

    std::cout << ret << std::endl;

    return 0;
}


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

int F[200000], szF[200000], FC[200000], g[200000];
int a,b,n,k,m;

int findFriend(int x)
{
	return F[x] = x == F[x] ? x : findFriend(F[x]);
}

void friendship(int x, int y){
	x = findFriend(x);
	y = findFriend(y);
	
	if(x == y) return;
	
	if(szF[x] > szF[y]) swap(x,y);
	
	F[x] = y;
	szF[y] += szF[x];
}

int32_t main()
{
	cin >> n >> m >> k;
	
	for(int i=1; i<=n; i++)
		F[i] = i, szF[i] = 1;
	
	for(int i=0; i<m; i++)
	{
		cin >> a >> b;
		friendship(a,b);
		g[a]++;
		g[b]++;
	}
	
	for(int i=1; i<=n; i++)
		FC[i] = szF[findFriend(i)] - g[i] - 1;
	
	for(int i=0; i<k; i++)
	{
		cin >> a >> b;
		if(findFriend(a) == findFriend(b))
			FC[a]--, FC[b]--;
	}
	
	for(int i=1; i<=n; i++)
		cout << FC[i] << ' ';
		
	cout << '\n';
}

Measured memory_bytes: 6144
#include<stdio.h>
int main()
{
	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	if(a % k == 0 || b % k == 0)	printf("OK");
	else{
		if(a / k == b / k)	printf("NG");
		else	printf("OK");
	}
	return 0;
 } 

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

using namespace std;

long long x, y;

bool get(long long x, long long y) {
//    for (int i = 2; i <= x; i += 2) {
//        if (!get(x - i, y + i / 2)) {
//            return true;
//        }
//    }
//
//    for (int i = 2; i <= y; i += 2) {
//        if (!get(x + i / 2, y - i)) {
//            return true;
//        }
//    }
//
//    return false;

    return max(x, y) - min(x, y) >= 2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> x >> y;

    if (get(x, y)) {
        cout << "Alice" << endl;
    } else {
        cout << "Brown" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e3+10;


int main(int argc,const char** argv){

	fastio;

	int n;

	cin >> n;

	vi v(n);

	rep(i,0,n) cin >> v[i];

	sort(v.rbegin(),v.rend());

	int alice = 0,bob = 0;

	rep(i,0,n){
		if(i%2 == 0) alice+=v[i];
		else bob+=v[i];
	}

	cout << alice - bob << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    vector<ll> x(4,0);
    x[0] = a*c;
    x[1] = a*d;
    x[2] = b*c;
    x[3] = b*d;
    sort(x.rbegin(),x.rend());
    cout << x[0] << endl;
}

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

void solve(void) {
  string s1;
  string s2;
  cin >> s1 >> s2;

  if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}
int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans1=0,s1=0;    
    rep(i,n) {
        s1+=a[i];
        if (i%2==0) {
            if (s1<=0) {
                ans1+=-s1+1;
                s1=1;
            }
        } else {
            if (s1>=0) {
                ans1+=s1+1;
                s1=-1;
            }
        }
    }
    ll ans2=0,s2=0;    
    rep(i,n) {
        s2+=a[i];
        if (i%2==1) {
            if (s2<=0) {
                ans2+=-s2+1;
                s2=1;
            }
        } else {
            if (s2>=0) {
                ans2+=s2+1;
                s2=-1;
            }
        }
    }
    ll ans=(ans1<ans2)?ans1:ans2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


ll dp[100][1200];
ll dp2[4][22010];
ll n, a;

int main() {
	cin >> n >> a;
	dp[0][0] = 1;
	for (int i = 1; i <= 40; ++i) {
		for (int j = 0; j <= 1000; ++j) {
			for (int k = 0; k <= j; ++k)
				dp[i][j] = max(dp[i][j], min(n, dp[i - 1][j - k] * k));
		}
	}
	ll ans = n;

	for (int i = 1; i <= 1200000; ++i)
		ans = min(ans, a + i + (n + i - 1) / i);

	for (int i = 1; i <= 40; ++i)
		for (int j = 0; j <= 1000; ++j) {
			if (dp[i][j] != 0)
				ans = min(ans, a * i + j + (n + dp[i][j] - 1) / dp[i][j]);
		}
	dp2[0][0] = 1;
	for (int i = 1; i <= 3; ++i) {
		for (int j = 0; j <= 21000; ++j) {
			if (i == 1) {
				dp2[i][j] = j;
				continue;
			}
			if (i == 3 && j > 5000)
				continue;
			for (int k = 0; k <= j; ++k)
				dp2[i][j] = max(dp2[i][j], min(n, dp2[i - 1][j - k] * k));
		}
	}
	for (int i = 1; i <= 3; ++i)
		for (int j = 0; j <= 21000; ++j) {
			if (dp2[i][j] != 0)
				ans = min(ans, a * i + j + (n + dp2[i][j] - 1) / dp2[i][j]);
		}

	cout << ans << "\n";
	return 0;
}




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

#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  ll K, X;
  cin >> K >> X;
  if (K * 500 >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));

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


ll func(ll a){
    ll ans = 0;
    for(ll i = 2;i*i <= a;++i){
        if(a%i == 0){
            while(a % i == 0){
                a /= i;
            }
            ans++;
        }
    }
    if(a != 1) ans++;
    return ans;
}

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

    ll a,b;
    cin >> a >> b;
    ll t = gcd(a,b);
    t = func(t);
    cout << t+1 << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// 分割数テーブル
// NをK個の非負整数の和で表す通り数 O(NK)
struct PartitionNumber {
    vector<vector<ll>> P;
    PartitionNumber (ll N) : P(N + 1, vector<ll>(N + 1)){
        for (ll k = 0; k <= N; k++) P[0][k] = 1;
        for (ll n = 1; n <= N; n++) {
            for (ll k = 1; k <= N; k++) {
                P[n][k] = P[n][k - 1] + (n - k >= 0 ? P[n - k][k] : 0);
                if (P[n][k] >= MOD) P[n][k] -= MOD;
            }
        }
    }

    ll get(ll n, ll k){
        return P[n][k];
    }
};

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    if(N<K){
        cout << 0 << endl;
        return 0;
    }

    PartitionNumber P(max(N-K, K));

    cout << P.get(N-K, K) << endl;
}


Measured memory_bytes: 10784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string n;int k;cin>>n>>k;
    int ns=n.size();
    set<int> notuse;
    rep(i,k){
        int d;cin>>d;
        notuse.insert(d);
    }
    int ans=0;
    vin use;
    rep(i,10)if(!notuse.count(i))use.push_back(i);
    int us=use.size();
    vbo judge(ns);//n[i]が存在→true,存在しない→false
    int tmp=1;//n[i]より大きな数字が存在する場所より前にn[i]未満しか存在しない場所が来たらアウト
    rep(i,ns){
        if(use[us-1]<(n[i]-'0')&&tmp==1)tmp=0;
        else if(!notuse.count((n[i]-'0')))judge[i]=true;
        else{
            judge[i]=false;
            if(tmp==1)tmp=2;
        }
    }
    if(tmp==0){//nより一桁大きい
        ans=(use[0]>0?use[0]:use[1]);
        rep2(i,1,ns+1)ans=10*ans+use[0];
    }
    else{
        rep(i,ns){
            if(!judge[i]){
                ans=ans*10+(*upper_bound(all(use),n[i]-'0'));
                rep(j,ns-i-1)ans=ans*10+use[0];
                break;
            }
            else ans=ans*10+(n[i]-'0');
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, limit;
	cin >> n >> limit;

	vector<int> c(n);
	vector<int> t(n);
	rep (i, 0, n)
		cin >> c[i] >> t[i];

	int res = INF;
	rep (i, 0, n) {
		if (t[i] > limit)
			continue;
		res = min(res, c[i]);
	}

	if (res == INF)
		cout << "TLE" << endl;
	else
		cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    max_n = 2*(10**5)
    fac, inv = [1]*(max_n+1), [0]*(max_n+1)
    for i in range(2, max_n+1):
        fac[i] = fac[i-1] * i % mod
    inv[-1] = pow(fac[-1], mod-2, mod)
    for i in range(max_n, 0, -1):
        inv[i-1] = inv[i] * i % mod

    # nCrを求める
    def ncr(n, r):
        return fac[n]*inv[r]*inv[n-r]%mod

    n, k = map(int, input().split())
    res = 0
    # i:空き部屋の数
    for i in range(n):
        if i > k:
            continue
        res += ncr(n, i) * ncr(n-1, i)
        res %= mod
    print(res)

if __name__ == '__main__':
    main()


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

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        q.push(a);
    }

    while(m>0){
        int t=q.top();
        q.pop();
        q.push(t/2);
        m--;
    }
    long long ans=0;
    while(!q.empty()){
        int t=q.top();
        q.pop();
        ans+=t;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
#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() {
    ll n;
    cin >> n;
    pair<ll, ll> ans = make_pair(0,0);
    for (ll i = 1; i*i <= n; i++) {
        if (n%i == 0) {
            ans.first = i;
            ans.second = n / i;
        }
    }

    cout << ans.first + ans.second -2 << endl;
    
    return 0;
}

Measured memory_bytes: 3616
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3636
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        aa: [u32;n]
    }



    let mut t = 1;
    let mut cnt = 0;
    for a in aa {
        if a == t {
            t += 1;
        } else {
            cnt += 1;
        }
    }
    if t == 1 { cnt = -1 }
    println!("{}", cnt);
}
/* vim:set foldmethod=marker: */


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

int j,y;

void solve(int jnow,int ynow,string s){
	if(jnow==j && ynow==y){
		cout<<s<<endl;
		return;
	}
	if(j<jnow || y<ynow) return;
	if(jnow==5 && ynow<4) return;
	if(ynow==5 && jnow<4) return;
	if(jnow==5 && ynow==5) return;
	if(jnow==6 || ynow==6) return;
	solve(jnow+1,ynow,s+'A');
	solve(jnow,ynow+1,s+'B');
}

int main(){
	cin>>j>>y;
	solve(0,0,"");
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
    int n; cin >> n;
    // city, -val, i
    set<pair<string,pair<int,int>>> s;
    FOR(i,1,n+1){
        string city; int val; cin >> city >> val;
        s.insert({city,{-val,i}});
    }
    for(auto xx : s) cout << xx.second.second << '\n';
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3636
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        for (int i = 0; i < k; ++i)
            cout << s[i];
        cout << "...";
    } else
        cout << s;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long T, long long A, std::vector<long long> H){
    double min_diff = INF;
    int ans = -1;

    REP(i, N) {
        double now_diff = abs(A - (T - (H[i] * 0.006)));
        if(now_diff < min_diff) {
            min_diff = now_diff;
            ans = i + 1;
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, T, A, std::move(H));
    return 0;
}


Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

x = int(input())
ans = 0
if(x == 7 or x== 5 or x==3):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 39020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int l[n];
    int maxv = -1;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        maxv = max(maxv, l[i]);
        sum += l[i];
    }
    sum -= maxv;
    if (sum > maxv) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int na[10010];
	int count = 0;
	int fn=0;
	int i,j,k;
	
	scanf("%d",&n);
	
	for(i=0;i<=n;i++){
		na[i] = 0;
	}
	
	for(i=1;i<=100;i++){
		for(j=1;j<=100;j++){
			for(k=1;k<=100;k++){
				fn = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
				if(fn <= n){
					na[fn]=na[fn] + 1;
				}
			}
		}
	}
	
	for(i=1;i<=n;i++){
		printf("%d\n",na[i]);
	}
	
	return 0;
}


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

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

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

ll f(ll n){
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(n%i==0) sum++;
    }
    return sum;
}

int main(void)
{
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(f(i)==8 && i%2==1) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,M;
vector<LL> a,b;
vector<int> c;//どの宝箱が開錠可能かを表す
 
LL ans = 0;

void solve(){
	//dp[i][j]:i番目の鍵まで見たとき、
	//bit列jで表されるような宝箱を開けるときの
	//最小費用
	const int opened_all = (1<<N)-1;//全部開けた時を表すビット列
	vector<vector<LL>> dp(M+1,vector<LL>(opened_all+1,INF));
	dp[0][0] = 0;
	for(int i=0;i<M;i++){
		for(int j=0;j<=opened_all;j++){
			//i番目の鍵を購入する場合
			dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]],dp[i][j]+a[i]);
			//しない場合
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		}
	}
	ans = dp[M][opened_all];
	if(ans==INF) ans = -1;
}
 
int main(){
    cin >> N >> M;
    a = vector<LL>(M);
    b = vector<LL>(M);
    c = vector<int>(M,0);
    for(int i=0;i<M;i++){
    	cin >> a[i] >> b[i];
    	for(int j=0;j<b[i];j++){
    		LL c_input;
	    	cin >> c_input;
	    	c[i] |= (1<<(c_input-1)); 
    	}
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

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

const int N = 1e5 + 5;

int n,k,ans,dp[N][3],profit[3];
map<char,char> winner = {{'s','r'},{'p','s'},{'r','p'}};
map<int, char> indexToChar = {{0, 'r'}, {1, 's'}, {2, 'p'}};
string t;

int solve(int idx, int col) {

    if(idx>=n) return 0;

    int &ret = dp[idx][col];

    if(ret!=-1) return ret;

    ret = 0;

    for(int i=0;i<3;++i)
        if(col!=i) ret = max(ret,solve(idx+k,i));

    return ret += winner[t[idx]]==indexToChar[col] ? profit[col] : 0;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k >> profit[0] >> profit[1] >> profit[2] >> t;

    memset(dp,-1,sizeof(dp));

    for(int i=0;i<k;++i) ans += max({solve(i,0),solve(i,1),solve(i,2)});

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 9424
input_data = list(map(int, input().split()))
n = input_data[0]
a = input_data[1]
b = input_data[2]

X = []
for i in range(a, n + 1):
    c = 0
    for j in str(i):
        c = c + int(j)
    
    if a <= c and c <= b:
        X.append(i)

print(sum(X))

Measured memory_bytes: 3296