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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int n;
bool visited[8];
bool p[8][8];

int dfs(int v) {
    bool all = true;
    rep (i, n) {
        if (visited[i] == false) all = false;;
    }
    if (all) return 1;
    int res = 0;
    rep (i, n) {
        if (p[v][i] == false) continue;
        if (visited[i]) continue;
        visited[i] = true;
        res += dfs(i);
        visited[i] = false;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    rep (i, n) {
        rep (j, n) {
            p[i][j] = false;
        }
        visited[i] = false;
    }
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        p[a][b] = true, p[b][a] = true;
    }
    visited[0] = true;
    cout << dfs(0) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

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

ll PowMod_RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = PowMod_RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * PowMod_RepeatSquaring(N, P-1, M);
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll ans = PowMod_RepeatSquaring(2, n, MOD);
    ans -= 1;
    ans %= MOD;
    // nCaとnCbを求める
    ll a_fact = 1;
    ll b_fact = 1;
    ll a_x = 1;
    ll b_x = 1;
    for(int i=1; i<=a; i++){
        a_fact *= i;
        a_fact %= MOD;
    }
    REP(i, a){
        a_x *= n-i;
        a_x %= MOD;
    }
    for(int i=1; i<=b; i++){
        b_fact *= i;
        b_fact %= MOD;
    }
    REP(i, b){
        b_x *= n-i;
        b_x %= MOD;
    }
    ll a_com = a_x * modinv(a_fact, MOD) % MOD;
    ll b_com = b_x * modinv(b_fact, MOD) % MOD;
    ans -= a_com;
    ans -= b_com;
    if(ans < 0){
        bool minus = true;
        while(minus){
            ans += MOD;
            if(ans >= 0){
                minus = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e5 + 5;
const int oo = 1e9 + 5;
const int MOD = 998244353;

int v[N];
void solve() {
    LL n;
    cin >> n;
    n--;
    LL have = 1;
    int len;
    for (len=1;;++len) {
        have *= 26;
        if (n >= have) {
            n -= have;
        } else {
            break;
        }
    }
    for (int j=0;j<len;++j) {
        have /= 26;
        LL now = n / have;
        n %= have;
        cout << (char)('a' + now); 
    }
    cout << '\n';
} 

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long, int>>
#define deb(x) cout <<"deb "<<#x<<" "<< x << endl;
#define all(x) x.begin(), x.end()
ll MOD = 1e9 + 7;
const int INF = 2e9 + 10;
void solve()
{
    string s[2];
    cin>>s[0]>>s[1];
    int c1,c2;
    cin>>c1>>c2;
    string t;
    cin>>t;
    if(t==s[0]) c1--;
    else c2--;
    cout<<c1<<" "<<c2;
}

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

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    int64_t x,i=0,a=100;
    cin>>x;
    while(a<x)
    {
        a*=1.01;
        i++;
    }
    cout<<i<<endl;

    return 0;
}


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

int main() {
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    long long X = min({A, B, C, D, E});
    cout << (N + X - 1) / X + 4 << endl;
}

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

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

int main() {
	int H, W, N; cin >> H >> W >> N;
	map<int, map<int, int>>mp; long long cnt[10] = {};
	cnt[0] = (long long)(H - 2) * (W - 2);
	for (int i = 0,a,b; i < N; i++) {
		cin >> a >> b;
		for (int j = 0; j < 9; j++)mp[a + dy[j]][b + dx[j]]++;
	}
	for (auto&& row : mp) {
		int y = row.first;
		if (y < 2 || H - 1 < y)continue;
		for (auto&& col : row.second) {
			int x = col.first;
			if (x < 2 || W - 1 < x)continue;
			cnt[col.second]++; cnt[0]--;
		}
	}
	for (int i = 0; i < 10; i++)cout << cnt[i] << endl;

	return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis , int k , int p , int &ans)
{
    vis[x] = 1;
    // out1(p);
    if ( p == -1 )
    {
        int s = k-1;
        rep(i,0,v[x].size())
        {
            ans *= s;
            // out1(s);
            s--;
            ans %= mod;
        }
    }
    else
    {
        int s = k-2;
        rep(i,0,v[x].size()-1)
        {
            ans *= s;
            // out1(s);
            s--;
            ans %= mod;
        }
    }
    
    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis,k,x,ans);
        }
    }
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,k;
    cin>>n>>k;

    vector< vector<int> > v(n+1);
    rep(i,0,n-1)
    {
        int a,b;
        cin>>a>>b;

        v[a].pb(b);
        v[b].pb(a);
    }

    int ans = k;
    int p = -1;
    vector<int> vis(n+1,0);
    dfs(v,1,vis,k,-1,ans);
    cout<<ans%mod<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 12416
#include <bits/stdc++.h>
#include <set>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n; cin>>n;
    int v=stoi(n);
    int c=n.size();
    int ans=0;
    if(c>5) ans=90909;
    else if(c==5)
    {
        ans=909+v-10000+1;
    }
    else if (c==4)
    {
        ans=909;
    } else if(c==3)

    {
        ans=9+v-100+1;

    } else if(c==2)
    {
        ans=9;
    } else if(c==1)

    {
        ans=v;
    }
    cout<<ans<<endl;
    return  0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll k,nr,poz,p;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>k;
    poz=0;
    p=1;
    for(int i=1;i<=k;i++)
    {
        nr=(nr+(7*p)%k)%k;
        if(nr==0)
        {
            cout<<i;
            return 0;
        }
        p=(p*10)%k;
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a<=0 && b>=0){
        cout << "Zero" << endl;
    }
    else if(a<0 && b<0){
        if((b-a)%2==0){
            cout << "Negative" << endl;
        }
        else{
            cout << "Positive" << endl;
        }
    }
    else if(a>0 && b>0){
        cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
  ll N, K, t;
  ll x[100005];

  cin >> N >> K;

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

  ll ans = 1e18;

  for (int i = 0; i < N-K+1; i++) {
    ll l = x[i], r = x[i+K-1];
    if (r * l < 0) {
      r = abs(r); l = abs(l);
      t = min(r, l) * 2 + max(r, l);
    } else {
      r = abs(r); l = abs(l);
      t = max(r, l);
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    double prob[n+1];
    for(int i = 1; i <= n; i++) cin >> prob[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    //dp[i][j] = prob of having exactly j heads in first i coins
    dp[1][0] = 1.0 - prob[1];
    dp[1][1] = prob[1];
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(j > i) dp[i][j] = 0;
            else{
                if(i > 1){
                    dp[i][j] += dp[i-1][j]*(1.0 - prob[i]);
                    if(j > 0) dp[i][j] +=dp[i-1][j-1]*prob[i];
                }
            }
        }
    } 
    double ans = 0;
    for(int i = n/2 + 1; i <=n; i++){
        ans += dp[n][i];
    }
    cout << fixed;
    cout << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
vector<ll> adj[100005];
ll pai[100005];
ll mod, down[100005], up[100005];
 
ll solve(ll u, ll p = 0){
    if(down[u] > 0) return down[u];
    pai[u] = p;
    ll res = 1;
    for(ll v : adj[u])
        if(v != p)
            res = (res*(1 + solve(v, u)))%mod;
    return down[u] = res;
}
 
void go(ll u, ll p = 0){
    vector<ll> vec, nodes;
    for(ll v : adj[u])
        if(v != p){
            nodes.push_back(v);
            vec.push_back(1 + down[v]);
        }
 
    vector<ll> pref(vec), suff(vec);
    for(ll i = 1; i < pref.size(); i++)
        pref[i] = (pref[i]*pref[i-1])%mod;
    for(ll i = ll(suff.size()) - 2; i >= 0; i--)
        suff[i] = (suff[i]*suff[i+1])%mod;
 
    for(ll i = 0; i < nodes.size(); i++){
        ll v = nodes[i];
        ll esq = (i-1 >= 0 ? pref[i-1] : 1);
        ll dir = (i+1 < vec.size() ? suff[i+1] : 1);
        esq = (esq*dir)%mod;
        //cout << u << " setando up de " << v << endl;
        up[v] = (1 + ((esq*up[u])%mod) )%mod;
    }
    
    for(ll v : nodes)
        go(v, u);
}
 
int main(){
    ll n; cin >> n >> mod;
    for(ll i = 0; i < n-1; i++){
        ll u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ll root = 1;
    for(ll i = 1; i <= n; i++)
        if(!pai[i]){
            solve(i);
            root = i;
        }
    for(ll i = 1; i <= n; i++)
        up[i] = 1;
 
    go(root);
    // for(ll i = 1; i <= n; i++)
    //     cout << "down[" << i << "] = " << down[i] << endl;
    // for(ll i = 1; i <= n; i++)
    //     cout << "up[" << i << "] = " << up[i] << endl;
    for(ll i = 1; i <= n; i++){
        ll res = (down[i] * up[i])%mod;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 28416
s = int(input())
MOD = int(1e9 + 7)

def c(k, r):
    n = 1
    for i in range(r):
        n = n * (k - i) * pow(i + 1, MOD - 2, MOD) % MOD
    return n

ans = sum([c(s - 3 * i + i - 1, i - 1) for i in range(1, s // 3 + 1)]) % MOD
print(ans)

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

typedef long long int ll;


int main(){
  ll k;
  cin>>k;
  ll a,b;
  cin>>a>>b;
  ll i;
  ll flag=0;
  for(i=a;i<=b;i++){
    if(i%k==0){
      flag=1;
      break;
    }
  }
  if(flag){
    cout<<"OK"<<endl;
  }
  else
  {
    cout<<"NG"<<endl;
  }
return 0;
}


Measured memory_bytes: 3620
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a%3==0){
    cout<<"Possible"<<'\n';
  }
  else if(b%3==0){
    cout<<"Possible"<<'\n';
  }
  else if((a+b)%3==0){
    cout<<"Possible"<<'\n';
  }
  else{
    cout<<"Impossible"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define mod 1000000007
using namespace std;

const int NMAX = 200010;

int lastpoz[NMAX];
int dp[NMAX];

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

    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1];
        int v;
        cin >> v;
        if (lastpoz[v] && lastpoz[v] != i - 1)
            dp[i] = (dp[i] + dp[lastpoz[v]]) % mod;
        lastpoz[v] = i;
    }

    cout << dp[n] << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, X);
  rep(i, 0, LINF) {
    if (i * (i + 1) >= X * 2) {
      print(i);
      return;
    }
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;


const int nax = 3007;

LL dp[nax][nax];

int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	dp[1][1] = 1;
	FOR(len,2,n+1)
	{
		VI pref(len);
		FOR(j,1,len)
		{
			pref[j] = pref[j-1];
			pref[j] = (pref[j] + dp[len-1][j])%mod;
		}
		FOR(a,1,len+1)
		{
			int l,r;
			if(s[len-2]=='<')
			{
				l = 1;
				r = a - 1;
			}
			else
			{
				l = a;
				r = len-1;
			}
			if(r>=l)
				dp[len][a] = (dp[len][a]+pref[r]+mod-pref[l-1])%mod;
		}
	}








	LL Ans = 0;
	FOR(i,1,n+1)
		Ans = (Ans + dp[n][i])%mod;
	cout << Ans;
	return 0;
}


Measured memory_bytes: 69120
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
  cout << setprecision(20) << fixed;
  int n; cin >> n;

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = (v[0] + v[1])/2.0;
  for (int i = 2; i < n; i++) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char S[11], T[100];
	int a, b,c;
	scanf("%s",S);
	scanf("%s", T);
	a = strlen(S);
	b = strlen(T);
	
	if (b == a + 1 )
	{
		T[b-1] = '\0';
		c = strcmp(S, T);
		
		if (c == 0)
		{
			printf("Yes");

		}
		else
		{
			printf("No");
		}
		
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1716
/* competitive programming */
#include "bits/stdc++.h"
using namespace std;

/* using */
// long
using ll = long long;
using ld = long double;
// vector
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vld = vector<ld>;
using vs = vector<string>;
using vi2 = vector<vector<int>>;
using vll2 = vector<vector<ll>>;

/* define */
// array
#define ari(x) array<int, x>
#define ard(x) array<double, x>
#define arll(x) array<ll, x>
#define arld(x) array<ld, x>
#define ars(x) array<string, x>
#define ari2(x, y) array<array<int, y>, x>
#define arll2(x, y) array<array<ll, y>, x>
// int -> ll
#define int ll // int -> ll
// push_back系
#define pb(x) push_back(x)    // push_back
#define eb(x) emplace_back(x) // emplace_back
// all range
#define all(x) x.begin(), x.end() // all_range
// gcd, lcm
#define gcd(x, y) __gcd(x, y)         // gcd
#define lcm(x, y) (x / gcd(x, y) * y) // lcm
// PI
#define PI M_PI // PI

// 大文字・小文字変換
struct ToUpper
{
    char operator()(char c) { return toupper(c); }
};
struct ToLower
{
    char operator()(char c) { return tolower(c); }
};

/* A・B問題用外部変数 */
ll n, k;  // 範囲・長さ・整数用
string s; // 文字列用

/* main */
void Main(void)
{
    cin >> n >> k >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s << endl;
}

signed main(int argc, char *argv[])
{
    ll now_time = clock();
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    if (argc == 2 && *argv[1] == 't')
    {
        // 時間計測
        cout << endl;
        cout << "Execution Time : " << 1.0 * (clock() - now_time) / CLOCKS_PER_SEC << "[sec]" << endl;
    }
    else
    {
        // 通常処理
    }

    return 0LL;
}


Measured memory_bytes: 3612
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



def paint(i, j, copied):

    for I in range(h):
        if((i>>I)&1):
            for J in range(w):
                copied[I][J] = "$"

    for J in range(w):
        if((j>>J)&1):
            for I in range(h):
                copied[I][J] = "$"

def check(grid1):
    toret = 0
    for i in range(h):
        for j in range(w):
            if(grid1[i][j]=='#'):
                toret+=1
    return (toret==k)

h,w,k = MAP()

grid = []

for _ in range(h):
    grid.append(list(input()))


ans = 0

for row in range(1<<h):
    for col in range(1<<w):
        copied = [x[:] for x in grid]
        paint(row, col, copied)

        ans+=check(copied)
        # print(copied, grid, ans, row, col)
print(ans)

Measured memory_bytes: 75860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N; 
  string kind = "Three";
  
  for (int i = 0; i < N; i++){
    char s;
    cin >> s;
    if (s == 'Y'){
      kind = "Four";
      break;
    }
    else {
      continue;
    }
  }
  cout << kind << endl;
}

Measured memory_bytes: 256
n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
mod = 1_000_000_007
ans = 0
tmp = 0
for i in range(n-1,0,-1):
    tmp = (tmp+a[i])%mod
    ans += (tmp*a[i-1])%mod
print(ans%mod)

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

void solv() {
    int A, B;
    char op;
    cin >> A >> op >> B;
    switch (op)
    {
    case '+':
        cout << A + B << endl;
        return;
    case '-':
        cout << A - B << endl;
        return;
    default:
        break;
    }
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

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

	int N, W; cin >> N >> W;
	vl w(N), v(N);
	rep(i, N)cin >> w[i] >> v[i];
	vvl dp(N + 1, vl(W + 1, 0));
	rep(i, N)rep(j, W + 1)
	{
		if (j < w[i])
		{
			dp[i + 1][j] = dp[i][j];
		}
		else
		{
			dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}
	ll ans = dp[N][W];
	co(ans);
	return 0;
}


Measured memory_bytes: 80256
Scanf.scanf "%d" (fun k ->
    let mat = Array.make_matrix 201 201 (-1) in
    let rec gcd a b = if b = 0 then a else
        if mat.(a).(b) >= 0 then mat.(a).(b) else
            let r = gcd b (a mod b) in
            let () = mat.(a).(b) <- r in
            r
    in

    let rec loop_a a acc =
        let rec loop_b b acc =
            let rec loop_c ab c acc =
                if c > k then acc else loop_c ab (c + 1) (acc + gcd ab c)
            in
            if b > k then acc else loop_b (b + 1) (loop_c (gcd a b) 1 acc)
        in
        if a > k then acc else loop_a (a + 1) (loop_b 1 acc)
    in
    loop_a 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 6172
#include<bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 310000;
string S;
int se[MAXN], sw[MAXN];
int fe[MAXN], fw[MAXN];
int e, w;

int main() {
    cin >> n >> S;
    for (int i = 0; i < n; ++i) {
    	se[i] = se[i - 1];
    	sw[i] = sw[i - 1];
    	if (S[i] == 'E') {
    		++se[i];
    	}
    	else ++sw[i];
    }
    e = se[n - 1];
    w = sw[n - 1];
    for (int i = n - 1; i >= 0; --i) {
    	fe[i] = e - se[i];
    	fw[i] = w - sw[i];
    }
    int ans = fe[1];
    for (int i = 1; i <= n; ++i) {
    	ans = min(ans, sw[i - 1] + fe[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=505;
int h,w,k;
string G[N];
int ans[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> k;
    REP(i,h) cin >> G[i];
    VI xs;
    REP(i,h) REP(j,w) {
        if ( G[i][j]=='#' ) xs.PB(i);
    }
    sort_uniq(xs);
    for ( int i=0; i<xs.size(); i++ ) {
        VI ys;
        REP(j,w) if ( G[xs[i]][j]=='#' ) ys.PB(j);
        ys.PB(w);
        int px=( i==0 ? 0 : xs[i-1]+1 );
        if ( i+1==xs.size() ) xs[i]=h-1;
        // paint 0 -> ys[0]
        for ( int j=0; j<ys[0]; j++ ) {
            for ( int x=px; x<=xs[i]; x++ ) {
                ans[x][j]=k;
            }
        }
        REP(j,(int)ys.size()-1) {
            for ( int y=ys[j]; y<ys[j+1]; y++ ) {
                for ( int x=px; x<=xs[i]; x++ ) {
                    ans[x][y]=k;
                }
            }
            k--;
        }
    }

    REP(i,h)REP(j,w) {
        cout << ans[i][j] << ' ';
        if ( j+1==w ) cout << '\n';
    }

    return 0;
}



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

int main(){
  int n; cin >> n;
  int a[200010];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int max = 0, max_ind, max2 = 0;
  for (int i = 0; i < n; i++){
    if (a[i] > max){
      max = a[i];
      max_ind = i;
    }else if (a[i] > max2){
      max2 = a[i];
    }
  }
  for (int i = 0; i < n; i++){
    if (i == max_ind) cout << max2 << endl;
    else cout << max << endl;
  }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin >> a;
	int l = a.size();
	int c = 0, f = 0;
	for(int i = 0; i <= l; i++){
		if(a[i] == 'C')	c++;
		if(c >= 1)
			if(a[i] == 'F') f++;
	}
	if(c >= 1 && f >= 1) cout << "Yes" << endl;
	if(c < 1 || f < 1) cout << "No" << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    int t, a; cin >> t >> a;
    
    int64_t tsum = t, asum = a;
//    cout << tsum << " " << asum << endl;
    
    for(int i = 1; i < n; i++){
        cin >> t >> a;
       
        long long c1 = (tsum + t - 1) / t; // ceil func
        long long c2 = (asum + a - 1) / a; // ceil func
//        cout << c1 << " " << c2 << endl;
        
        long long ratio = max(c1, c2);
        tsum = t * ratio;
        asum = a * ratio;
//        cout << ratio << " " << tsum << " " << asum << endl;
    }
    
    cout << tsum + asum << endl;
}




Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int c[3][3] = {0};
    int a[3] = {0};
    int b[3] = {0};
    a[0] = 50;

    for (int i = 0; i < 3; i++){
        for (int k = 0; k < 3; k++){
            cin >> c[i][k];
        }
    }

    for (int i = 0; i < 3; i++){
        b[i] = c[0][i] - a[0];
    }

    for (int i = 1; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }


    bool flag = true;
    for (int i = 0; i < 3; i++){
        for (int k = 0; k < 3; k++){
            if (c[i][k] != a[i] + b[k]){
                flag = false;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {

        var NHW = Console.ReadLine().SplittedStringToInt32List();
        var N = NHW[0];
        var H = NHW[1];
        var W = NHW[2];
        var ls = new List<KeyValuePair<int,int>>();
        var count = 0;
        for (int i = 0; i < N; i++)
        {
            var ab = Console.ReadLine().SplittedStringToInt32List();
            var a = ab[0];
            var b = ab[1];
            if (a >= H && b >= W)
                count++;
        }
        Console.WriteLine(count);
        Console.ReadLine();
    }


    
    
    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A; cin >>A;
cout << A*A;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int length,data[100],i,j,k,v;
  
  
  //input
  scanf("%d",&length);
  
  for(i=0;i<length;i++){
    scanf("%d",&data[i]);
  }

  //output
  for(k=0;k<length;k++){
    if(k+1==length){
      printf("%d",data[k]);
    }
    else{
      printf("%d ",data[k]);
    }
  }
  printf("\n");

  
  for(i=1;i<length;i++){
    
    v = data[i];
    j = i-1;
    
    while(j>=0 && data[j]>v){
      data[j+1] = data[j];
      j--;
    }
    data[j+1] = v;
    
    
    //output
    for(k=0;k<length;k++){
      if(k+1==length){
	printf("%d",data[k]);
      }
      else{
	printf("%d ",data[k]);
      }
    }
    printf("\n");
     
  }
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

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

int s2n(string s)
{
	int n = 0;
	int d = 1;
	rep(i, s.size()) {
		int ch = s[i];
		if (isdigit(ch))
			d = ch-'0';
		else {
			switch(ch) {
			case 'm': n += d*1000; break;
			case 'c': n += d*100; break;
			case 'x': n += d*10; break;
			case 'i': n += d*1; break;
			}
			d = 1;
		}
	}
	return n;
}

string n2s(int n)
{
	string s = "";
	char cs[] = "mcxi";
	for (int i = 1000, j = 0; i >= 1; i /= 10, j++) {
		if (n >= i) {
			int k = n/i;
			n %= i;
			if (k != 1)
				s += k+'0';
			s += cs[j];
		}
	}
	return s;
}

int main(void)
{
	int n;
	cin >> n;
	rep(i, n) {
		char ss1[256], ss2[256];
		string s1, s2;
		scanf("%s %s", ss1, ss2);
		s1 = ss1, s2 = ss2;
		cout << n2s(s2n(s1)+s2n(s2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
/* Problem Description:

*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#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 FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define TRvi(it, c) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define inf 0x3f3f3f3f
#define EPS 1e-10
#define PI acos(-1.0)
#define scan(x) scanf("%d",x)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define LSOne(x) x&(-x)
#define debug(x) cout << #x << " " << x << endl;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int N = 1e5;
vector< pair<int, long> > grp[N];

bool col[N];
void dfs(int cur, int p){
  for (vector< pair<int, long> >::iterator adj = grp[cur].begin(); adj != grp[cur].end(); adj++){
    if (adj->first != p){
        if (adj->second % 2 == 1)
          col[adj->first] = !(col[cur]);
        else col[adj->first] = col[cur];
        dfs(adj->first, cur);
    }
  }
  return;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
   //  freopen("in" , "r" , stdin);
   //  freopen("out" , "w" , stdout);
    #endif
    int n;
    cin >> n;
    REP(i,0,n-1){
      int u,v; long w;
      cin >> u >> v >> w;
      u--, v--;
      grp[u].pb(mp(v,w));
      grp[v].pb(mp(u,w));
    }
    int cur = 0;
    col[0] = true;
    dfs(0,-1);
    REP(i,0,n){
      if (col[i]) cout << "0"<<endl;
      else cout << "1" << endl;
    }
    return 0;
 }


Measured memory_bytes: 9600
package main

import (
	"fmt"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)
	r := 0
	nx := 10
	p := 1
	for i := 1; i <= n; i++ {
		if i == nx {
			nx *= 10
			p = 1 - p
		}
		r += p
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int D[11][1024];
int T[11][1024];
int main() {
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  string S[11];
  for (int i=0; i<H; i++) {
    cin >> S[i];
  }
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      D[i][j] = S[i][j] - '0';
    }
  }
  int ret = 10000000;
  for (int b=0; b<(1<<H); b++) {
    int cnt = 0;
    int r = 0;
    int mx = 0;
    for (int j=0; j<W; j++) {
      T[cnt][j] = D[cnt][j];
    }
    for (int i=0; i<H-1; i++) {
      if ((b & (1<<i)) > 0) {
        r++;
        cnt++;
        for (int j=0; j<W; j++) {
          T[cnt][j] = D[i+1][j];
        }
      } else {
        for (int j=0; j<W; j++) {
          T[cnt][j] += D[i+1][j];
          mx = max(mx, T[cnt][j]);
        }
      }
    }
    cnt++;
    if (mx > K) continue;
    int U[11];
    for (int i=0; i<cnt; i++) U[i] = 0;
    for (int i=0; i<W; i++) {
      bool f = false;
      for (int j=0; j<cnt; j++) {
        U[j] += T[j][i];
        if (U[j] > K) {
          f = true;
        }
      }
      if (f) {
        r++;
        for (int j=0; j<cnt; j++) {
          U[j] = T[j][i];
        }
      }
    }
    ret = min(ret, r);
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>> n;
    vector<long long> a(n);
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }

    long long dp[n][n];
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<n;j++)
        dp[i][j]=0;
    }
    for(long long i=0;i<n;i++)
    dp[i][i]=a[i];

    for(long long i=n-2;i>=0;i--)
    {
        for(long j=i+1;j<n;j++)
        {
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
            // cout<<dp[i][j]<<" ";
        }
    }


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

}

Measured memory_bytes: 70528
n = int(input())
l = []
for i in range(n):
    d = {}
    d["index"] = i+1
    d["city"], d["score"] = input().split()
    d["score"] = int(d["score"])
    l.append(d)
results = []
citys = list(set([l[i]["city"] for i in range(n)]))
citys.sort()
for city in citys:
    sorted_scores = sorted([l[i]["score"] for i in range(n) if l[i]["city"] == city], reverse=True)
    for score in sorted_scores:
        candidate = [l[i]["index"] for i in range(n) if (l[i]["city"] == city)&(l[i]["score"] == score)][0]
        results.append(candidate)
print(*results, sep="\n")

Measured memory_bytes: 3064
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[N-1])

Measured memory_bytes: 20600
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    if(n % 2)
    {
        puts("No");
        return 0;
    }
    string a,b;
    for(int i = 0;i < n / 2;i++)
    {
        a+=s[i];
        b+=s[i + n / 2];
    }
    if(a == b)
        puts("Yes");
    else
        puts("No");

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
	int key;
	Node* right, * left, * parent;
};
Node* root, *NIL;
Node* treeMinimum(Node* x) {
	while (x->left != NIL)x = x->left;
	return x;
}
Node* find(Node* u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
Node* treeSuccessor(Node* x) {
	if (x->right != NIL)return treeMinimum(x->right);
	Node* y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node* z) {
	Node* y;
	Node* x;
	
	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);
	if (y->left != NIL) x = y->left;
	else x = y->right;
	if (x != NIL) x->parent = y->parent;

	if (y->parent == NIL) root = x;
	else {
		if (y == y->parent->left) y->parent->left = x;
		else y->parent->right = x;
	}
	if (y != z)z->key = y->key;
	free(y);
}

void insert(int k) {
	Node* y = NIL;
	Node* x = root;
	Node* z;
	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL) root = z;
	else {
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node* u) {
	if (u == NULL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node* u) {
	if (u == NULL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node* t = find(root, x);
			if (t != NIL)printf("yes\n");
			else printf("no\n");
		}
		else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com == "delete") {
			scanf("%d", &x);
			treeDelete(find(root, x));
		}
	}
	return 0;
}


Measured memory_bytes: 22060
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	cin>>m;
	int p[m],x[m];
	rep(i,m){
		cin>>p[i]>>x[i];
		p[i]--;
		int sum=0;
		rep(j,n){
			if(j==p[i])sum+=x[i];
			else sum+=a[j];
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

int a[105];

int main(void)
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL);
//    cout.tie(NULL);
    int n;
    double num=1.0,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
        cnt+=(double)1/a[i];
    num/=cnt;
//    cout << num;
    printf("%.9lf", num);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

sm=idx=0
ans=set()
for i in range(1, N+1):
    sm+=i
    ans.add(i)
    if sm>=N:
        idx=i
        break

if sm>N:
    ans.remove(sm-N)
for a in ans:
    print(a)


Measured memory_bytes: 3700
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,
    vs: [isize;n]
  }
  
  let mut l_map: Vec<(isize, Vec<isize>)> = vec![];
  let mut sum = 0;
  let mut stack = vec![];
  l_map.push((0, vec![]));
  for i in 0..n {
    let v = vs[i];
    if v < 0 {
      stack.push(v);
      stack.sort();
    }
    sum += v;
    l_map.push((sum, stack.clone()));
  }

  let mut r_map: Vec<(isize, Vec<isize>)> = vec![];
  let mut sum = 0;
  let mut i = n - 1;
  let mut stack = vec![];
  r_map.push((0, vec![]));
  loop {
    let v = vs[i];
    if v < 0 {
      stack.push(v);
      stack.sort();
    }
    sum += v;
    r_map.push((sum, stack.clone()));
    
    if i == 0 { break }
    i -= 1;
  }
  
  let mut max = 0;
  for l in 0..=k {
    let r_max = k - l;
    for r in 0..=r_max {
      let mut remove_point = k - l - r;
      let (mut v, ms) = if n <= r + l {
        l_map[n].clone()
      } else {
        let left = l_map[l].clone();
        let right = r_map[r].clone();
        (left.0 + right.0, [left.1, right.1].concat())
      };
      
      for i in 0..remove_point {
        if ms.len() <= i { break }
        v -= ms[i];
      }
      max = std::cmp::max(max, v);    
    }
  }
  println!("{}", max);
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std ;
int main() {
 long long n  , i ,t,k,ans=0 ,j;
 cin >> n ;
long long a[n+10] ;
 for(i=0;i<n;i++)
    cin >> a[i] ;

 for(i=0;i<n;i++){
    for(j=i+1;j<n;j++)
        ans+= (a[i]*a[j]) ;
 }
 cout << ans << endl ;



}


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

using namespace std;

string s;
int N, fcv[100];
long long sol;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;

    for (int i = 1; i <= N; ++i) {
        cin >> s;
        
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            ++fcv[s[0] - 'A'];
        }
    }
    
    // for (int i = 0; i < 26; ++i) {
    //     if (fcv[i]) {
    //         cout << (char)(i + 'A') << ' ' << fcv[i] << '\n';
    //     }
    // }
    
    for (int i = 0; i < 26; ++i) {
        for (int j = i + 1; j < 26; ++j) {
            for (int k = j + 1; k < 26; ++k) {
                if (i != j && i != k && j != k && fcv[i] && fcv[j] && fcv[k]) {
                    sol += 1LL * fcv[i] * fcv[j] * fcv[k];
                }
            }
        }
    }
    
    cout << sol << '\n';
    return 0;
}


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

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

  int a[n][m] = {};
  int b[m] = {};
  int ans[n] = {};

  for( int i=0; i<n; i++ ){
    for( int j=0; j<m; j++ ){
      int input;
      cin >> input;
      a[i][j] = input;
    }
  }

  for( int i=0; i<m; i++ ){
    int input;
    cin >> input;
    b[i] = input;
  }

  for( int i=0; i<n; i++ ){
    for( int j=0; j<m; j++ ){
      ans[i] += a[i][j]*b[j];
    }
  }

  for( int i=0; i<n; i++ ){
    cout << ans[i] << endl;
  }
}


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

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

const long long int inf = 1 << 29 ;

int main(void) {
	int n,m;
	cin >> n >> m;

	vector<long long int> x(n), y(n), z(n);
	rep(i, n) {
		cin >> x[i] >> y[i] >> z[i];
	}

	vector<long long int> vec(n);
	long long int ans = 0;
	for (int signx = -1; signx < 2; signx += 2) for (int signy = -1; signy < 2; signy += 2) for (int signz = -1; signz < 2; signz += 2) {
	  rep(i,n) vec[i] = signx*x[i] + signy * y[i] + signz * z[i];
		sort(vec.begin(), vec.end());
		long long int sum = 0;
		rep(i,m) sum += vec[n-m+i];
		ans = max(ans, sum);
	}

	cout << ans << endl;
}

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

int main() {
    int n;
    ll z, w;
    cin >> n >> z >> w;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    if (n == 1) {
        cout << abs(a[0] - w) << endl;
    } else {
        cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
    }
}

Measured memory_bytes: 256