akhauriyash/Code-Regression huggingface dataset:
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline ll read() {
    ll X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

inline ll calc(ll n,ll x) {
    if (n%x==0) return n*2-x;
    return n/x*x*2+calc(x,n%x);
}

int main() {
    ll n=read(),x=read();
    printf("%lld\n",calc(n-x,x)+n);
    return 0;
}


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

int main(){
  string t;
  cin >> t;
  
  if(t.size() == 1){
    if(t.at(0) == 'P')
      t.at(0) = 'P';
    else
      t.at(0) = 'D';
  }
  
  if(t.at(0) == '?' && t.size() > 1){
    if(t.at(1) == 'P')
      t.at(0) = 'D';
    else
      t.at(0) = 'P';
  }
  
  for(int i = 1; i<t.size()-1; i++){
    if(t.at(i) == '?'){
      if(t.at(i+1) == 'D' && t.at(i-1) == 'D')
        t.at(i) = 'P';
      else
        t.at(i) = 'D';
    }
  }
  if(t.at(t.size()-1) == '?')
    t.at(t.size()-1) = 'D';
  cout << t << endl;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string a, b, c;
    cin >> a >> b >> c;

    // int a = 'a';
    // int b = 'A';
    // cout << a << " " << b << endl;
    char d = a[0]-('a'-'A');
    char e = b[0]-('a'-'A');
    char f = c[0]-('a'-'A');

    cout << d << e << f << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d, g, s, t, u;
  in2(a, b);
  in2(c, d);
  s = c;
  t = d;
  while(s > 0 && t > 0){
    if(s > t)
      s = s % t;
    else
      t = t % s;
    if(s == 0)
      g = t;
    if(t == 0)
      g = s;
  }
  g = (d * c) / g;
  s = (a - 1) / c;
  s += (a - 1) / d;
  s -= (a - 1) / g;
  t = b / c;
  t += b / d;
  t -= b / g;
  u = t - s;
  out(b - a + 1 - u);
  memi;
}

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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int arr[200001];

int main()
{
    fast_in_out;
    int n, cnt = 1;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if(i > 0)
        {
            if(arr[i] < arr[i - 1])
            {
                cnt++;
            }
            else
            {
                arr[i] = arr[i - 1];
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 4392
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
#define N 101010
LL n , a[ N ];
void init(){
  n = getint();
  for( int i = 1 ; i <= n ; i ++ )
    a[ i ] = getint();
}
void no(){
  puts( "-1" );
  Bye;
}
void solve(){
  LL candl = 2 , candr = 2;
  for( int i = n ; i >= 1 ; i -- ){
    LL tmpl = candl / a[ i ] * a[ i ];
    if( tmpl < candl ) tmpl += a[ i ];
    LL tmpr = candr / a[ i ] * a[ i ];
    if( tmpl > tmpr ) no();
    candl = tmpl;
    candr = tmpr + a[ i ] - 1;
  }
  cout << candl << " " << candr << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int AB, BC, AC;
  if(a>b){
    AB = a - b;
  }
  else if(a<b){
    AB = b - a;
  }
  if(b>c){
    BC = b - c;
  }
  else if(b<c){
    BC = c - b;
  }
  if(a>c){
    AC = a - c;
  }
  else if(a<c){
    AC = c - a;
  }
  if(AC <= d) {
    cout << "Yes" << endl;
  }
  else if(AB <= d && BC <= d) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
vector<int> gather(vector<int> vec,int w){
  int cnt = 0;
  int n_w = w;
  int vec_cnt = 0;
  int tmp = 0;
  vector<int> ans;
  int flag = 0;
  while(cnt < vec.size()){
    if(cnt == n_w){
      flag = 0;
      ans.push_back(tmp);
      tmp = 0;
      n_w = n_w+w;
      vec_cnt++;
    }
    tmp = tmp + vec[cnt];
    flag = 1;
    cnt++;
  }
  if(flag == 1)ans.push_back(tmp);
  return ans;
}
int max_vec(vector<int> vec){
  int ans = -1;
  for(int i = 0;i < vec.size();i++){
    ans = max(ans,vec[i]);
  }
  return ans;
}
int main(){
  int n,w;
  while(cin >> n >> w, n && w){
    vector<int> hist(101,0);
    int max_hist = 0;
    for(int i = 0;i < n;i++){
      int v;
      cin >> v;
      max_hist = max(max_hist,v);
      hist[v]++;
    }
    vector<int>::iterator tmp = hist.begin();
    //    vector<int> iterator::tmp2 = hist.end();
    hist.erase(tmp+max_hist+1,hist.end());
    vector<int> ans = gather(hist,w);
    //////////
    //    cout << "aaaaaaaaa" << endl;
    //for(int i = 0;i < ans.size();i++){
    // cout << ans[i]  << endl;
    //}
    //cout << "ddddddddd" << endl;
    //////////////////
    double cost = 0.01;
    for(int i = 0;i < ans.size();i++){
      double ink = (double)(ans.size() - 1 - i)/(double)(ans.size() - 1);
      double hei =  (double)ans[i] / (double)max_vec(ans);
      //      cout << ink << "       f  " << hei << endl;
      cost += ink*hei;
    }
    //    cout << "deb" << ans.size() << " " << ans[0] <<  endl;
    cout <<  fixed << setprecision(10) << cost << endl;
    
  }
  
}

Measured memory_bytes: 1284
n,m=map(int,input().split())
wa=[0]*(n+1)
ac=[0]*(n+1)
for _ in range(m):
  p,s=input().split()
  p=int(p)
  if s=='AC':
    ac[p]=1
  if s=='WA' and ac[p]==0:
    wa[p]+=1
wa=[wa[i]*ac[i] for i in range(n+1)]
print(sum(ac),sum(wa))

Measured memory_bytes: 5528
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


main(){
    //制約的に半分全列挙が間に合う
    int n;
    cin>>n;
    string s;
    cin>>s;
    string s1="",s2="";
    for(int i=0;i<n;i++){
        s1+=s[i];
        s2+=s[i+n];
    }
    reverse(ALL(s2));
    map<pair<string,string>,ll> m1,m2;
    for(int i=0;i<(1<<n);i++){
        string t11="",t12="",t21="",t22="";
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                t11+=s1[j];
                t21+=s2[j];
            }
            else{
                t12+=s1[j];
                t22+=s2[j];
            }
        }
        //1の方が長くすりゃいいか
        m1[make_pair(t11,t12)]++;
        m2[make_pair(t21,t22)]++;
    }
    ll ans=0;
    for(auto x:m1){
        ans+=m2[x.first]*x.second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 108288
N = int(input())
As = list(map(int, input().split()))
Bs = []
for i in range(N):
  b = As[i]-i-1
  Bs.append(b)
Bs.sort()
m = Bs[N//2]
r = sum(map(lambda B: abs(B-m), Bs))
print(r)


Measured memory_bytes: 26708
// https://atcoder.jp/contests/dp/tasks/dp_d

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N, W;
  cin >> N >> W;

  V<pair<ll, ll>> items(N);
  rep(i, 0, N) {
    cin >> items[i].first;
    cin >> items[i].second;
  }

  V<V<ll>> dp(N + 1, V<ll>(W + 1, 0));

  rep(i, 1, N + 1) {
    auto item = items[i - 1];
    auto w = item.first;
    auto v = item.second;

    rep(j, 1, W + 1) {
      chmax(dp[i][j], dp[i - 1][j]);

      if (j - w >= 0) {
        chmax(dp[i][j], dp[i - 1][j - w] + v);
      }
    }
  }

  cout << dp[N][W] << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 80256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n,m;
    cin>>n>>m;
    int a[N]={};
    rep(i,m){
        int aa,b;
        cin>>aa>>b;
        a[aa]++;
        a[b]++;
    }
    rep(i,n){
        if(a[i]%2){
            cout<<"NO"; return 0;
        }
    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
 ll n;
 cin>>n;
 ll arr[n];
 for(ll i=0;i<n;i++){
  cin>>arr[i];
 }
 ll sum=0;
 sort(arr,arr+n,greater<int>());
 sum += arr[0];
 ll x=2,k=1,m=1;
while(x < n){
  sum += arr[k];
  bool flag = false;
  if(m==2){
    m=1;
    k++;
    flag=true;
  }
  if(!flag) m++;
  x++;
}
 // if(n%2!=0){
 //  ll k=1;
 //      while(x < n){
 //           sum += (arr[k]*2);
 //           k++;
 //           x+=2;
 //      }
 // }else{
 //  n--;
 //   ll k=1;
 //      while(x < n){
 //           sum += (arr[k]*2);
 //           k++;
 //           x+=2;
 //      }
 //     // sum += arr[k];
 // }
 cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	ll N,A,B;
	ll X,pre;
	ll ans=0;
	cin>>N>>A>>B;
	cin>>pre;
	for(int i=1;i<N;i++){
		cin>>X;
		if((X-pre)*A>B)
			ans+=B;
		else
			ans+=(X-pre)*A;
		pre=X;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
n, d = map(int, input().split())
xs = [list(map(int, input().split()))for _ in range(n)]
c = 0
check = []
for i in range(n):
  check.append(i)
  for j in range(n):
    if i == j or j in check:
      continue
    else:
      a = xs[i][:]
      b = xs[j][:]
      length = math.sqrt(sum([(n-m)**2 for n,m in zip(a,b)]))
      if length%1 == 0:
        c += 1
print(c)

Measured memory_bytes: 3064
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i+1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i: int):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i: int, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

N, Q = map(int, input().split())
bit = Bit(N+1)
for i in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        bit.add(x, y)
    else:
        print(bit.sum(y+1) - bit.sum(x))



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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int h,w;cin>>h>>w&&h|w;){
		vvi d(10,vi(10));
		rep(i,10) rep(j,10) cin>>d[i][j];
		vvi g(h,vi(w));
		rep(i,h) rep(j,w) cin>>g[i][j];

		rep(k,10) rep(i,10) rep(j,10) chmin(d[i][j],d[i][k]+d[k][j]);
		ll res=0;
		rep(i,h) rep(j,w) if(g[i][j]!=-1) res+=d[g[i][j]][1];
		cout<<res<<endl;
	}
}


Measured memory_bytes: 384
#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)

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << "\n";
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll dp[1001][1001];

int main()
{
    int h, w;
    cin >> h >> w;

    char a[1001][1001];
    rep(i, h) rep(j, w) cin >> a[i][j];
    dp[0][0] = 1;

    ll mod = 1e9 + 7;

    rep(i, h)
    {
        rep(j, w)
        {
            if (a[i][j] == '#')
                dp[i][j] = 0;
            else if (i == 0 && j == 0)
                continue;
            else if (j == 0)
                dp[i][j] = dp[i - 1][j] % mod;
            else if (i == 0)
                dp[i][j] = dp[i][j - 1] % mod;
            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

    OP(dp[h - 1][w - 1]);

    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    if (sum >= 22) puts("bust");
    else puts("win");
    return 0;
}

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

using namespace std;

int main()
{
	int k,a,b;
  cin>>k>>a>>b;
  
  if(a%k==0 || b%k==0)
    cout<<"OK"<<"\n";
    
    else
    {
      if((a/k)==(b/k))
        cout<<"NG"<<"\n";
      
      else
         cout<<"OK"<<"\n";
    }
  
  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[111];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += max(a[i]-a[i-1],0);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "strings"
  "bufio"
  "os"
  "strconv"
  "sort"
)
func StrStdin() (stringInput string) {
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    stringInput = scanner.Text()

    stringInput = strings.TrimSpace(stringInput)
    return
}
// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
    // 文字列で1行取得
    stringInput := StrStdin()

    // 空白で分割
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

func SplitIntStdin(delim string) (intSlices []int, err error) {
    // 文字列スライスを取得
    stringSplited := SplitStrStdin(" ")

    // 整数スライスに保存
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main() {
  var n int
  fmt.Scanf("%d",&n)
    sli, err := SplitIntStdin(" ")
    if err != nil {
        fmt.Println(err)
    } else {
      sort.Ints(sli)
      sum1 := 0
      sum2 := 0
      for i,v  := range sli{
        if (n+1)%2 == i%2 { 
          sum1 += v 
        }else{
          sum2 += v
        }
      }
      fmt.Println(sum1-sum2)
    }
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (;;) {
		C = C - B;
		if (C < 1) {
			cout << "Yes" << endl;
			return 0;
		}
		A = A - D;
		if (A < 1) {
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  long long n;
  cin>>n;
  string s;
  cin>>s;
  vector<long long> sr(n, 0);
  vector<long long> sg(n, 0);
  vector<long long> sb(n, 0);
  REP(i, n){
    if(i == 0){
      if(s[i] == 'R') sr[i]++;
      if(s[i] == 'G') sg[i]++;
      if(s[i] == 'B') sb[i]++;
    }else{
      sr[i] = sr[i-1];
      sg[i] = sg[i-1];
      sb[i] = sb[i-1];
      if(s[i] == 'R') sr[i]++;
      if(s[i] == 'G') sg[i]++;
      if(s[i] == 'B') sb[i]++;
    }
  }
  map<char, int> mp;
  mp['R'] = 0; mp['G'] = 1; mp['B'] = 2;
  map<int, char> col;
  col[0] = 'R'; col[1] = 'G'; col[2] = 'B';
  long long ans = 0;
  for(int j = 1; j < n; j++){
    for(int k = j + 1; k < n; k++){
      bool rgb[3] = {};
      if(s[j] == s[k]) continue;
      rgb[mp[s[j]]] = true;
      rgb[mp[s[k]]] = true;
      char c;
      REP(x, 3) if(!rgb[x]) c = col[x];
      long long temp;
      if(c == 'R') temp = sr[j-1];
      if(c == 'G') temp = sg[j-1];
      if(c == 'B') temp = sb[j-1];
      int bi = 2 * j - k;
      if(bi < 0){
        ans += temp;
        continue;
      }
      if(s[bi] == c){
        ans += temp - 1;
      }else{
        ans += temp;
      }
    }
  }
  cout<<ans<<endl; 
  return 0;
}



Measured memory_bytes: 3732
N = int(input())
li = list(map(int,input().split()))
x = 0
sum = 0
for i in range(N):
    sum += li[i]
for i in range(N-1):
    x += li[i]
    li[i] = abs(x-(sum-x))
del li[N-1]
print(min(li))
        
        

Measured memory_bytes: 24812
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int r, c;
	int count;
	int a;
	int sumc[100] = {0};
	int	sumr;
	int sum = 0;;
	
	cin >> r >> c;

	for (int i = 0; i <= r; i++) {
		sumr = 0;
		for (int j = 0; j <= c; j++) {
			if (i == r) {
				if (j == c) {
					cout << sum;
					break;
				}
				cout << sumc[j] << " ";
				sum += sumc[j]; 
				continue;
			}

			if (j == c) {
				cout << sumr;
				break;
			}
			cin >> a;
			sumr += a;
			sumc[j] += a;
			cout << a << " ";
		}
		cout << endl;
	}
		
	return (0);
}

Measured memory_bytes: 1160
//How Many Divisors?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String[] abc = in.readLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);

		int count=0;
		
		for (int i = 1; i <= c; i++) {

			if (a <= i && i <= b) {
				if (c % i == 0) {
				count++;
				}
			}
		}

		System.out.println(count);

		
	}
}

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

typedef unsigned long long ll;
#define mod 1000000007

ll pow(ll m, ll n){
	  if(n==0) return 1;
	  if(n%2==1)	return pow(m*m%mod,n/2) % mod * m % mod;
	  return pow(m*m%mod,n/2) % mod;
}

int main(){

	  ll m,n; cin >> m >> n;
	  cout << pow(m,n)%mod << endl;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(long long i=I;i<A;i+=B)
#define rep(I,A,B) for(long long j=I;j<=A;j+=B)
#define repp(I,A,B) for(long long j=I;j>=A;j-=B)
#define str(A) for(long long k=0;A[k]!='\0';k++)
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define all(v) v.begin(),v.end()
vector <int> adj[100001];
bool visit[100001];
const int mod = 1000000007;
ll mod_mult(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll mult(ll x,ll y) { ll prod = 1; while(y>0){ if(y&1) prod = mod_mult(prod,x); x=mod_mult(x,x); y/=2;} return prod;}
long double dp[3001][3001];
long double arr[3002];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,i;
	cin>>n;
	FOR(0,n,1)
		cin>>arr[i];
	int k = n/2;
	if(n%2)
		k++;
	long double ans = 0.0;
	dp[0][1] = arr[0], dp[0][0] = 1-arr[0];
	for(int i = 1; i<n; i++)
		dp[i][0] = dp[i-1][0]*(1-arr[i]);
	for(int i = 1; i<n; i++)
	{
		for(int j = 1; j<=n; j++)
		{
			dp[i][j] = dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
		}
	}
	for(int i = k; i<=n; i++)
		ans += dp[n-1][i];
	printf("%.10Lf",ans);
	return 0;
}

Measured memory_bytes: 143488
N, M = map(int, input().split())

divisor = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divisor.append(i)
        if i != M // i:
            divisor.append(M // i)

print(max(v for v in divisor if v <= M // N))



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

using namespace std;

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

    long long a, b, c;
    cin >> a >> b >> c;
    if (c - a - b <= 0) {
        cout << "No\n";
        return 0;
    }

    if (4*a*b < (c-a-b)*(c-a-b)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d,x;
  cin >> n >> d >> x;
  int ans = x;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A.at(i) ;
  }
  for(int i=0;i<n;i++){
    int j=0;
    while(j*A.at(i)+1 <= d){
      ans ++;
      j++;
    }
  }
  cout << ans <<endl;
}
      
      

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

int main() {
  int A, B, i=0;
  cin >> A >> B;
  
  for(int n=A;n<=B;n++) {
    int a, b, c, d, e;
     a=n/10000%10;
     b=n/1000%10;
     c=n/100%10;
     d=n/10%10;
     e=n%10;
    if (a==e && b==d) {
      i++;
    }
  }
  cout << i << endl;
}

Measured memory_bytes: 256
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, m, x = 3, 3, 10
    C = [60, 70, 50]
    A = [[2, 2, 4], [8, 7, 9], [2, 3, 9]] 

  else:
    ##INPUT 
    #n = input()
    n, m, x = map(int, input().split())
    C = []
    A = []
    for _ in range(n):
      tmp = list(map(int, input().split()))
      C.append(tmp[0])
      A.append(tmp[1:])

  ## SUBMITION CODES HERE
  ans = f_inf
  for s in range(1<<n): # 1<<n: 2^n 
    cost = 0
    D = [0] * m
    for i in range(n):
        if s>>i & 1: # Shift s by i times to the right and check if the least significant digit is 1
            cost += C[i]
            for j in range(m):
                D[j] += A[i][j]
    
    flg = True
    for d in D:
        if d < x: flg = False
    if flg: ans = min(ans, cost)

  if ans == f_inf: 
    print(-1)
  else: 
    print(ans)

main()

Measured memory_bytes: 9280
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = N.to_string().chars().filter(|&c| c == '2').count();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = abs(abs(n) - abs(m));
  if (n + ans == m) {
    cout << ans << endl;
  } else if (-n + ans == m || -(n + ans) == m) {
    cout << ans + 1 << endl;
  } else {
    cout << ans + 2 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


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

	if (N % 2) {
		rep(i, N / 2) {
			cosp(A[N - 1 - 2 * i]);
		}
		cosp(A[0]);
		rep(i, N / 2) {
			cosp(A[1 + 2 * i]);
		}
	}
	else {
		rep(i, N / 2) {
			cosp(A[N - 1 - 2 * i]);
		}
		rep(i, N / 2) {
			cosp(A[2 * i]);
		}
	}
	cout << endl;

	Would you please return 0;
}

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

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

    string subf, subb;
    bool state = false;

    auto rev = [&]() {
        state = !state;
    };
    auto front = [&](char c) {
        if (state) subb += c;
        else subf += c;
    };
    auto back = [&](char c) {
        if (state) subf += c;
        else subb += c;
    };

    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            rev();
            continue;
        }
        int f; char c;
        cin >> f >> c;
        if (f == 1) front(c);
        else back(c);
    }

    reverse(subf.begin(), subf.end());
    s = subf + s + subb;
    if (state) {
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
}



Measured memory_bytes: 4260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

vll enumdiv(ll a, ll b) {
  vll ret;
  for(ll i = 1; i * i <= min(a, b); ++i) {
    if(a%i == 0 && b%i == 0){
      ret.push_back(i);
    }
  } 
  return ret;
}

//素因数分解する
//https://drken1215.hatenablog.com/entry/2019/10/03/175800
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for(ll p = 2; p * p <= n; ++p) {
    if(n % p != 0) continue;  //約数判定
    int num = 0;
    //その素因数がいくつ含まれるか調べる
    while(n % p == 0) {
      ++num;
      n /= p; //破壊的にnを変更していることに注意
    }
    res.push_back(make_pair(p, num));
  }
  //ここでは，(n , 1)も含めることに注意
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

ll gcd(ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(ll, a); invar(ll, b);
  
  ll gcdi = gcd(a, b);
  auto ps = prime_factorize(gcdi);
  
  //Nも含めるので+1
  fin(ps.size() + 1);
}

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

int main(){
    int x;
    vector<int> xs;
    for(int i=0; i<3; i++) {
        cin >> x;
        xs.push_back(x);
    }

    sort(xs.begin(), xs.end());

    if(xs[0]+xs[1] == xs[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int x; cin >> x;
	x -= 400;
	x = (x/200);
	cout << 8-x << '\n';
}

Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#include <numeric>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
  
       int m = n / 1000 ;
       if (n % 1000 != 0) {
           m++;
       }
    
    
    cout << m * 1000 - n << endl;
}

    


    


    





















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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    int k; cin >> k >> s;
    if(s.size()<=k) cout << s << endl;
    else{
        rep(i,0,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

class Restaurant {
public:
    string s;
    int p;
    int id;

    Restaurant(string _s, int _p, int _id) {
        s = _s;
        p = _p;
        id = _id;
    }
};

bool cmp(const Restaurant &a, const Restaurant &b) {
    if (a.s == b.s) {
        return a.p > b.p;
    } else {
        return a.s < b.s;
    }
}

void solve() {
    int n;
    cin >> n;
    vector<Restaurant> r;
    for (int i = 0; i < n; ++i) {
        string s;
        int p;
        cin >> s >> p;
        r.push_back(Restaurant(s, p, i + 1));
    }

    sort(r.begin(), r.end(), cmp);

    for (int i = 0; i < n; ++i) {
        cout << r[i].id << "\n";
    }
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int all[5][2],ans=-1;
    string tran="000";
    for(int i = 0;i<m;i++)
    {
        cin>>all[i][0]>>all[i][1]; //s and c
    }
    for(int i = 0;i<m;i++)
    {
       if(tran[all[i][0]-1]=='0'||(all[i][1]+48)==tran[all[i][0]-1] )
       {
           if(all[i][1]==0&&all[i][0]==1&&n!=1)
           {
               cout<<-1<<endl;
               return 0;
           }
           //cout<<"left is"<<all[i][0]<<endl;
           tran[all[i][0]-1]=all[i][1]+48; //s and c
           //cout<<"tran is "<<tran<<endl;
       }
        else
        {
            cout<<ans<<endl;
            return 0;
        }
    }
    
    ans=(tran[0]-48)*100+(tran[1]-48)*10+(tran[2]-48);
    if(n==1)
        ans/=100;
    if(n==2)
    {
        ans/=10;
        if(ans<10)
            ans+=10;
    }
    if(n==3)
    {
        if(ans<100)
            ans+=100;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define NMAX 200000

int main(){

	int N;
	int R[NMAX];
	int max[NMAX];
	int ans;

	cin>>N;

	for(int i=0;i<N;i++){
		cin>>R[i];
	}

	max[N-1]=-1;
	max[N-2]=R[N-1];
	for(int i=N-3;i>=0;i--){
		if(max[i+1]<R[i+1]) max[i]=R[i+1];
		else max[i]=max[i+1];
	}

	ans=max[0]-R[0];
	for(int i=1;i<N-1;i++){
		if(ans<max[i]-R[i]) ans=max[i]-R[i];
	}

	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        String target = sc.next();

        if (len >= target.length()) {
            System.out.println(target);
        } else {
            System.out.println(target.substring(0, len) + "...");
        }

    }
}


Measured memory_bytes: 38676
import itertools

N = int(input())
p_list = tuple((map(int, input().split())))
q_list = tuple((map(int, input().split())))

tmp = []
for i in range(N):
    tmp.append(i+1)

cnt = 1
for i in itertools.permutations(tmp, N):
    if i == p_list:
        a = cnt

    if i == q_list:
        b = cnt
    cnt += 1

print(abs(a-b))


Measured memory_bytes: 3060
def main():
    N = input()
    K = int(input())

    N_list = [int(s) for s in N]
    N_len = len(N)

    # dp[i][j][k]
    # i: 桁数
    # j: 未満フラグ
    # k: 上からiまでの0でない数字の個数
    dp = [[[0 for _ in range(K + 2)] for _ in range(2)]
          for _ in range(N_len + 1)]
    dp[0][0][0] = 1

    for i in range(N_len):
        for j in range(2):
            for k in range(K + 1):
                x_max = 9 if j == 1 else N_list[i]
                for x in range(x_max + 1):
                    # print("i={},j={},k={},x={}".format(i, j, k, x))
                    if k <= K:
                        if x == 0:
                            dp[i + 1][j | (x < N_list[i])][k] += dp[i][j][k]
                        else:
                            dp[i + 1][j | (x < N_list[i])][k +
                                                           1] += dp[i][j][k]

    ans = dp[N_len][0][K] + dp[N_len][1][K]
    print(ans)

    # for i, a in enumerate(dp):
    #     for j, b in enumerate(a):
    #         for k, c in enumerate(b):
    #             print("dp[{}][{}][{}]={}".format(i, j, k, c))


main()


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

int main(){
    int N;
    int diff = 0;

    cin >> N;

    int p[N];
    int sortedP[N];

    for(int i = 0; i < N; i++){
        int P;
        cin >> P;
        p[i] = P;
        sortedP[i] = P;
    }
    sort(sortedP, sortedP + N);

    for(int i = 0; i < N; i++){
        if(p[i] != sortedP[i]){
            diff++;
        }
    }

    if(diff == 0 || diff == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < (int)(n); i++)
using namespace std;

int h, w;
int a[500][500];
int n;
int p[250000], q[250000], r[250000], s[250000];

signed main() {
	int i, j;
	
	cin >> h >> w;
	rep(i, h) rep(j, w) cin >> a[i][j];
	
	rep(i, h) {
		if (i % 2 == 0) {
			for (j = 0; j + 1 < w; j++) {
				if (a[i][j] % 2) {
					p[n] = i; q[n] = j;
					r[n] = i; s[n] = j + 1;
					n++;
					a[i][j]--;
					a[i][j + 1]++;
				}
			}
			if (a[i][w - 1] % 2 && i + 1 < h) {
				p[n] = i; q[n] = w - 1;
				r[n] = i + 1; s[n] = w - 1;
				n++;
				a[i][w - 1]--;
				a[i + 1][w - 1]++;
			}
		}
		else {
			for (j = w - 1; j > 0; j--) {
				if (a[i][j] % 2) {
					p[n] = i; q[n] = j;
					r[n] = i; s[n] = j - 1;
					n++;
					a[i][j]--;
					a[i][j - 1]++;
				}
			}
			if (a[i][0] % 2 && i + 1 < h) {
				p[n] = i; q[n] = 0;
				r[n] = i + 1; s[n] = 0;
				n++;
				a[i][0]--;
				a[i + 1][0]++;
			}
		}
	}
	
	cout << n << endl;
	rep(i, n) { cout << p[i] + 1 << " " << q[i] + 1 << " " << r[i] + 1 << " " << s[i] + 1 << endl; }
	
	/*rep(i, h) {
		rep(j, w) {
			cout << a[i][j];
		}
		cout << endl;
	}*/
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

ll nCr[51][51];

int main() {
  nCr[0][0] = 1;
  rep (i, 50) rep (j, i + 1) {
    nCr[i + 1][j] += nCr[i][j];
    if (j + 1 <= 50) nCr[i + 1][j + 1] += nCr[i][j];
  }

  int N, A, B;
  cin >> N >> A >> B;

  vector<ll> v(N);
  map<ll, int> cnt;
  rep (i, N) {
    cin >> v[i];
    cnt[v[i]]++;
  }

  sort(rall(v));
  uniq(v);

  double sum = 0;
  int d = 0;
  ll c = 0;

  rep (i, v.size()) {
    if (d + cnt[v[i]] < A) {
      sum += v[i] * cnt[v[i]];
      d += cnt[v[i]];
    } else {
      if (d == 0) {
        sum = v[i];
        d = 1;
        REP (j, A, B + 1) {
          c += nCr[cnt[v[0]]][j];
        }
      } else {
        c = nCr[cnt[v[i]]][A - d];
        sum += v[i] * (A - d);
        d = A;
      }
      break;
    }
  }

  printf("%.10f\n", sum / d);
  cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int a;
	cin >> a;
	cout << a + a * a + a * a * a;
 	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    lint x;
    cin >> x;
    lint s = 100;
    lint y = 0;
    while(s < x){
        s = s * 1.01;
        y++;
    } 
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3644