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

int main() {
  long n;
  long now = 1;
  long des = 0;
  bool disc = false;

  cin >> n;
  vector<long> a(n);
  for (long i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (long i = 0; i < n; i++) {
    if (a[i] == now) {
      disc = true;
      now++;
    } else {
      des++;
    }
  }

  if (disc == false) {
    cout << -1 << endl;
  } else {
    cout << des << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define pow(x) (x)*(x)
#define mid(min, max) ((min + max) / 2)

int main() {
	string s;
	cin >> s;
	int c = 0, n = s.length();

	rep(i, n / 2) {
		if (s[i] != s[n-i-1])
			++c;
	}

	out(c);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string imp="Impossible\n";

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
// const int N=4;
const int N=5e5+5;
ll MOD=998244353;
ll n,m,k,i,j;
bool f0,f1,f2;
const int MAXN=2e3;

int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
	cout<<fixed<<setprecision(11);
    int tests=1;    
    cin>>tests;
    while(tests--){
        int n;  cin>>n;
        ll k[n],l[n],r[n];
        for(int i=0;i<n;i++)    cin>>k[i]>>l[i]>>r[i];
        ll ans=0;
        int dif[n];
        for(int i=0;i<n;i++)    dif[i]=l[i]-r[i];
        vector<pair<pii,int>>ord;
        for(int i=0;i<n;i++){
            if(dif[i]>0){
                ord.pb({{k[i],dif[i]},i});
            }
        }
        sort(all(ord));
        priority_queue<int,vector<int>,greater<int>>pq;
        for(auto i:ord){
            int np=pq.size();
            if(np<i.fi.fi){
                pq.push(i.fi.se);
                ans+=l[i.se];
            }
            else{
                if(i.fi.se>pq.top()){
                    ans-=pq.top();
                    pq.pop();
                    pq.push(i.fi.se);
                    ans+=l[i.se];
                }
                else{
                    ans+=r[i.se];
                }
            }
        }
        ord.clear();
        for(int i=0;i<n;i++){
            if(dif[i]<0&&k[i]!=n){
                ord.pb({{n-k[i],-dif[i]},i});
            }
            else if(dif[i]<0&&k[i]==n)  ans+=l[i];
        }
        sort(all(ord));
        while(!pq.empty())  pq.pop();
        for(auto i:ord){
            int np=pq.size();
            if(np<i.fi.fi){
                pq.push(i.fi.se);
                ans+=r[i.se];
            }
            else{
                if(i.fi.se>pq.top()){
                    ans-=pq.top();
                    pq.pop();
                    pq.push(i.fi.se);
                    ans+=r[i.se];
                }
                else{
                    ans+=l[i.se];
                }
            }
        }
        for(int i=0;i<n;i++)    if(dif[i]==0)   ans+=l[i];
        cout<<ans<<"\n";
    }
    return 0;
}


 



Measured memory_bytes: 10788
#演習2－5　
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*40
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range(3,31):
            A[i]=A[i-1]+A[i-2]+A[i-3]
    print((A[n]//3650)+1)



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

int main(){
    int a, b, c, t = 0;
    cin >> a >> b >> c;
    
    if (a > b){
        t = a;
        a = b;
        b = t;
    } if (b > c){
        t = b;
        b = c;
        c = t;
    } if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};




ll gcd(ll x, ll y)
{
  if(x<y)
  {
    swap(x,y);
  }
  while(y>0)
  {
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}

ll func(VL d){
  ll tmp=0;
  tmp=gcd(d[0],d[1]);
  tmp=gcd(tmp,d[2]);
  return tmp;
}

int main(){
  int K;cin>>K;
  VL a(3);
  ll ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int r=1;r<=K;r++){
        a[0]=i;
        a[1]=j;
        a[2]=r;
        ans+=func(a);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]
K = int(sys.stdin.buffer.readline())
VP = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(K)]

graph = [[] for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

mins = [-INF] * N
maxes = [INF] * N
for v, p in VP:
    v -= 1
    mins[v] = p
    maxes[v] = p

root = VP[0][0] - 1


def dfs(v, p=None, p_max=INF, p_min=-INF):
    p_max = min(p_max + 1, maxes[v])
    p_min = max(p_min - 1, mins[v])
    c_max = maxes[v]
    c_min = mins[v]
    for u in graph[v]:
        if u == p:
            continue
        ma, mi = dfs(u, v, p_max, p_min)
        c_max = min(c_max, ma + 1)
        c_min = max(c_min, mi - 1)
    maxes[v] = min(p_max, c_max)
    mins[v] = max(p_min, c_min)
    return c_max, c_min


dfs(root)

ok = True
for ma, mi in zip(maxes, mins):
    ok &= ma >= mi
if not ok:
    print('No')
    exit()

ans = [None] * N
ans[root] = maxes[root]
stack = [(root, None)]

while stack:
    v, p = stack.pop()
    a = ans[v]
    for u in graph[v]:
        if u == p:
            continue
        if mins[u] <= a - 1 <= maxes[u]:
            ans[u] = a - 1
        elif mins[u] <= a + 1 <= maxes[u]:
            ans[u] = a + 1
        else:
            print('No')
            exit()
        stack.append((u, v))
print('Yes')
print(*ans, sep='\n')


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

int main() {

    int n, k;
    cin >> n >> k;

    int res = 0;
    int row = 1;
    int w = 0;
    while ( n >= row ) {

	//	cout << w << " " << row << endl;
	
	if ( row*k >= w ) {
	    ++res;
	    w += row;
	    n -= row;
	}
	else if ( n >= row+1 ) ++row;
	else break;
    }
    
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main(void){
    string s,t;
    std::cin >> s>>t;
    bool flag=false;
    for (int i = 0; i < s.size(); i++){
        char tmp=s[s.size()-1];
        for(int j=s.size()-2;j>=0;j--){
            s[j+1]=s[j];
        }
        s[0]=tmp;
        if(s.compare(t)==0){
            flag=true;
            break;
        }
    }
    if(flag)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for i in range(N):
    s = input().strip()
    d[s] += 1

L = sorted(d.items(), key=lambda x: -x[1])
MX = L[0][1]

L2 = [l[0] for l in L if l[1] == MX]
L2.sort()

for l in L2:
    print(l)

Measured memory_bytes: 46108
def main():
    n, m = map(int, input().split())
    ab_list = [list(map(int, input().split())) for _ in range(n)]
    cd_list = [list(map(int, input().split())) for _ in range(m)]

    for ab in ab_list:
        a = ab[0]
        b = ab[1]
        min_diff = 10 ** 9
        ans = 0
        for i in range(m):
            c = cd_list[i][0]
            d = cd_list[i][1]
            diff = abs(a - c) + abs(b - d)
            if diff < min_diff:
                min_diff = diff
                ans = i + 1
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67736
#include<cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void join(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb])swap(ra,rb);
        v[rb]=ra;
        sz[ra]+=sz[rb];
        
    }
    bool same(int a,int b){
        //same set
        return (root(a)==root(b));
    }
    int size(int a){
        return sz[root(a)];
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	
		int n,x,y;
        cin>>n>>x>>y;
        cout<<((n+x-1)/x)*y<<"\n";
	
}

Measured memory_bytes: 5960
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> fi(H);
    REP(i,H) cin >> fi[i];
    string ans = "NO";
    vector<int> dice(4);
    dice[0] = 2, dice[1] = 3, dice[2] = 5, dice[3] = 4;
    vector<vector<bool>> used(H, vector<bool>(W));

    auto dfs = [&](auto && self, int h, int w, vector<int> D) -> void{
        if(used[h][w]) return;
        used[h][w] = true;
        if(h == H-1 && w == W-1){
            ans = "YES";
            return;
        }
        REP(i,4){
            int nh = h + dx[i], nw = w + dy[i];
            if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if(fi[nh][nw] == '#') continue;
            int next = fi[nh][nw] - '0';
            int d = D[i];
            // cout << nh << " " << nw << " " << next << " " << d << endl;
            // cout << "DICE : ";
            vector<int> dd = D;
            // REP(i,4) cout << D[i] << " ";
            // cout << endl;
            if(next != d) continue;
            int cur = fi[h][w] - '0';
            if(i == 0) dd[0] = 7 - cur, dd[2] = cur;
            else if(i == 1) dd[1] = 7 - cur,  dd[3] = cur;
            else if(i == 2) dd[0] = cur, dd[2] = 7 - cur;
            else dd[1] = cur, dd[3] = 7 - cur;
            self(self, nh, nw,dd);
        }
    };
    dfs(dfs, 0, 0, dice);
    cout << ans << endl;
}



Measured memory_bytes: 4348
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//constants
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1<<28;


int main(int argc, char **argv) {
    long long x, y;
    cin >> x >> y;
    long long ans = 0;
    if (x==y)
        ans = 0;
    else if (x<0 && y<0){
        if (x<=y)
            ans = abs(abs(x) - abs(y));
        else
            ans = 2 + abs(abs(x) - abs(y));
    }
    else if (x>=0 && y>=0){
        if (x<=y)
            ans = abs(abs(x) - abs(y));
        else
            ans = 2 + abs(abs(x) - abs(y));
        if (y==0) ans--;
    }
    else if (x<0 && y>=0){
        ans = 1 + abs(abs(x) - abs(y));
        if (y==0) ans--;
    }
    else if (x>=0 && y<0)
        ans = 1 + abs(abs(x) - abs(y));

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

  int num[26] = {0};
  rep(i, S.size()) {
    int idx = S[i] - 'a';
    num[idx]++;
  }
  string res = "None";
  rep(i, 26) {
    if (!num[i]) {
      res = 'a' + i;
      break;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	vector<int64_t> H(N);
	rep(i, N) cin >> H.at(i);
	reverse(H.begin(), H.end());
	rep2(i, N, 1, 1){
		if (H.at(i - 1) == H.at(i) - 1) H.at(i)--;
		else if (H.at(i - 1) < H.at(i)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;

int div6(int n){
    int rtn = 0;
    int b = n;
    for(int i=6;i>=0;--i){
        int a = pow(6,i);
        rtn += b/a;
        b = b % a;
    }
    return rtn;
}
int div9(int n){
    int rtn = 0;
    int b = n;
    for(int i=5;i>=0;--i){
        int a = pow(9,i);
        rtn += b/a;
        b = b % a;
    }
    return rtn;
}
int main() {
    int n;
    cin >> n;
    int res = n;
    REP(i,n+1){
        res = min(res,div6(i)+div9(n-i));
    }
    cout << res << endl;
    /*vector<pair<int,int>> pair1(n);
     vector<pair<int,int>> pair2(n);
     REP(i,n){
     int a,b;
     cin >> a >> b;
     pair1[i] = make_pair(a,b);
     }
     REP(i,n){
     int c,d;
     cin >> c >> d;
     pair2[i] = make_pair(c,d);
     }
     
     sort(pair1.begin(),pair1.end());
     sort(pair2.begin(),pair2.end());
     REP(i, n){
     cout << pair1[i].first << pair1[i].second <<endl;
     }
     int maxn = -1;
     int cand = -1;
     REP(i,n){
     REP(j,n){
     if(pair1[i].first<pair2[j].first){
     if(pair1[i].second>maxn){
     cand = i;
     }
     }
     }
     }
     /*REP(i, n){
     cout << pairs[i].first << pairs[i].second <<endl;
     }
     /*int n;
     int res = 100000;
     cin >> n;
     //vector<int> x(n);
     REP2(i,1,n/2+1){
     res = min(res,psum(i)+psum(n-i));
     if(psum(i)+psum(n-i)==1){
     cout << "i:" << i <<endl;
     }
     }
     cout << res << endl;*/
    return 0;
}



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

int  main(void)
{
  int n;
  char s[100010][5];
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%s",s[i]);
  }

  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  for(int i=0;i<n;i++){
    if(strcmp(s[i],"AC")==0){
      ac++;
    }
    if(strcmp(s[i],"WA")==0){
      wa++;
    }
    if(strcmp(s[i],"TLE")==0){
      tle++;
    }
    if(strcmp(s[i],"RE")==0){
      re++;
    }
  }


  printf("AC x %d\n",ac);
  printf("WA x %d\n",wa);
  printf("TLE x %d\n",tle);
  printf("RE x %d\n",re);


  return 0;
}


Measured memory_bytes: 2212
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;


int main(void) {
    int n,k;
    string str;
    cin>>n>>k;
    cin>>str;
    k--;

    if(str[k] == 'A') {
        str[k] = 'a';
    } else if(str[k] == 'B') {
        str[k] = 'b';
    } else {
        str[k] = 'c';
    }

    cout<<str<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int d = 0;
    int ans = 1;
    rep(i, N) {
        int l;
        cin >> l;
        d += l;
        if (d <= X) {
            ++ans;
        } else {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    string S; cin >> S;
    vector<int> suml(N+1),sumr(N+1);
    vector<bool> usedr(10,false),usedl(10,false);
    rep(i,N){
        int d = S[i]-'0';
        if(!usedl[d]){
            suml[i+1] = suml[i]+1;
            usedl[d] = true;
        }
        else suml[i+1] = suml[i];
    }
    for(int i = N-1; i >= 1; i--){
        int d = S[i]-'0';
        if(!usedr[d]){
            sumr[i] = sumr[i+1]+1;
            usedr[d] = true;
        }
        else sumr[i] = sumr[i+1];
    }
    vector<int> ans(10);
    vector<int> before(10);
    rep(i,N){
        int d = S[i]-'0';
        ans[d] += (suml[i]-suml[before[d]])*sumr[i+1];
        before[d] = i;
    }
    int ans2 = 0;
    rep(i,10) ans2 += ans[i];
    cout << ans2 << endl;
}



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

int main()
{
    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll t1 = H1 * 60 + M1;
    ll t2 = H2 * 60 + M2;

    cout << (t2 - t1) - K << endl;
}


Measured memory_bytes: 3612
s = input()

if len(s) == 2:
  if s[0]==s[1]:
    print(1,2)
    exit()
  else:
    print(-1,-1)
    exit()

for i in range(len(s)-2):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit()
  if s[i]==s[i+2]:
    print(i+1,i+3)
    exit()
print(-1,-1)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll n,ans=0;
void check(ll a)
{
	ll x=n;
	while(x%a==0) x/=a;
	if(x%a==1) ans++;
}
int main()
{
	cin>>n;
	for(ll i=1;i*i<=n-1;i++)
	{
		if((n-1)%i==0)
		{
			if(i>1) ans++;
			if((n-1)/i!=i) ans++;
		}
	}
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i>1) check(i);
			if(i!=n/i) check(n/i);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
longest=0
l=['A','T','G','C']
s=input()
for i in range(len(s)):
  if s[i] in l:
    start=i
    nowlen=0
    while(s[start] in l):
      if start==len(s)-1:
        nowlen+=1
        break
      else:
        start+=1
        nowlen+=1
    if nowlen>longest:
      longest=nowlen
print(longest)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 1010000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void Main() {
    ll X, Y;
    cin >> X >> Y;
    ll n = 2 * X - Y;
    ll m = 2 * Y - X;
    if (n >= 0 && m >= 0 && n % 3 == 0 && m % 3 == 0) {
        COMinit();
        n /= 3;
        m /= 3;
        cout << COM(n + m, n) << '\n';
    } else {
        cout << 0 << '\n';
    }

}

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


Measured memory_bytes: 23936
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int N=0,W=0,S=0,E=0;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='N')N=1;
		if(s[i]=='S')S=-1;
		if(s[i]=='W')W=1;
		if(s[i]=='E')E=-1;
	}
	cout << ((N+S==0&&W+E==0)?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int ans = 9999;
  for(int i = 0; i < s.size()-2; i++){
    string a;
    for(int j = i; j < 3 + i; j++)
      a.push_back(s.at(j));
    //cout << a << endl;
    ans = min(ans,abs(stoi(a)-753));
    a.erase(a.begin(),a.end());

  }
  cout << ans;
}

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

int main()
{
    int a, b, c, d = 0;
    cin >> a >> b >> c;
    if (a == b)
    {
        d++;
    }
    if (b == c)
    {
        d++;
    }
    if (a == c)
    {
        d++;
    }
    cout << (d == 1 ? "Yes" : "No") << endl;
    // system("pause");
}

Measured memory_bytes: 888
#f
from functools import reduce
p = 1000000007  #ここを変える
cmod_max = 200000  #ここを変える
ccache = []
inv_ccache = [None] * (cmod_max + 1)
def powmod(a, n):
    global p
    res = 1
    tmp=a
    while n>0:
        if n & 1 == 1:
            res = (res * tmp) % p
        n=n//2
        tmp = tmp * tmp % p
    return res
def invmod(n):
    return powmod(n, p - 2)
def cmod(n, r):
    global p
    global ccache
    global inv_ccache
    if len(ccache) == 0:
        ccache.append(1)
        for i in range(cmod_max):
            ccache.append(ccache[i]*(i+1)%p)
        inv_ccache[cmod_max] = invmod(ccache[cmod_max])
        for i in range(cmod_max, 0, -1):
            inv_ccache[i - 1] = inv_ccache[i] * i % p
    if r > n or r < 0:
        return 0
    if r > n // 2:
        return cmod(n, n - r)
    return ccache[n]*inv_ccache[r]%p*inv_ccache[n-r]%p

n = int(input())
adj_of = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    adj_of[a - 1].append(b - 1)
    adj_of[b - 1].append(a - 1)
stack = [(0, -1)] # root, excludee
course = []
while len(stack) > 0:
    popped = stack.pop()
    course.append(popped)
    for adj in adj_of[popped[0]]:
        if adj != popped[1]:
            stack.append((adj, popped[0]))
sizes = [{} for _ in range(n)] #size, pattern_num
pattern_nums = [{} for _ in range(n)]
for step in reversed(course):
    size = 1
    pattern_num = 1
    for adj in adj_of[step[0]]:
        if adj != step[1]:
            size += sizes[adj][step[0]]
            pattern_num *= pattern_nums[adj][step[0]] * cmod(size - 1, sizes[adj][step[0]])
            pattern_num %= p
    sizes[step[0]][step[1]] = size
    pattern_nums[step[0]][step[1]] = pattern_num

#print(course)
#print(sizes)
#print(pattern_nums)

ans = [None] * n
for step in course:
    if step[0] == 0:
        ans[0] = pattern_nums[0][-1]
        continue
    #ans[step[0]] = pattern_nums[step[0]][step[1]] * pattern_nums[step[1]][step[0]]\
    #             * cmod(sizes[step[0]][step[1]] + sizes[step[1]][step[0]], sizes[step[0]][step[1]]) % p
    pattern_nums_step1_step0 = ans[step[1]] * invmod(cmod(n - 1, sizes[step[0]][step[1]]) * pattern_nums[step[0]][step[1]]) % p
    ans[step[0]] = pattern_nums[step[0]][step[1]] * pattern_nums_step1_step0\
                 * cmod(n - 1, sizes[step[0]][step[1]] - 1) % p

for a in ans:
    print(a)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((C+B-1)/B > (A+D-1)/D){
    cout << "No" << endl;
  }
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }


int main(){
    string S=is();
    if(S[S.length()-1]=='s'){
        os(S);
        ose("es");
    }else{
        os(S);
        ose("s");
    }

    return 0;
}


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

if N > 2 and M > 2:
    print ((N-2)*(M-2))
elif N==2 or M ==2:
    print (0)
elif N==1 and M ==1:
    print (1)
elif N+M < 3:
    print (0)
else:
    print (N+M-3)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,x;
	cin >> a >> b >> x;
	if(x==a*a*b/2)printf("45.0000000000\n");
	else if(x<a*a*b/2){
		double a1=x/a*2/b;
		double xie=sqrt(a1*a1+b*b);
		double h=a1*b/xie;
		double ans=asin(h/a1)/3.14159265359*180;
		printf("%.10lf\n",ans);
	}
	else{
		x=a*a*b-x;
		double b1=x/a*2/a;
		double xie=sqrt(a*a+b1*b1);
		double h=a*b1/xie;
		double ans=asin(h/a)/3.14159265359*180;
		printf("%.10lf\n",ans);
	}
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
int main()
{
    ll n, m;
    cin >> n >> m;
    vll h(n);
    vvll path(n);
    rep(i,n)cin >> h[i];
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    ll cnt = 0;
    rep(i,n){
        bool ok = true;
        rep(j, path[i].size())if(h[i] <= h[path[i][j]])ok = false;
        if(ok)cnt++;
    }
    cout << cnt << endl;

    /*rep(i,n){
        //cout << path[i].size();
        cout << h[i] << "    ";
        rep(j,path[i].size())cout << path[i][j] << " ";
        cout << endl;
    }*/

    return 0;
}

Measured memory_bytes: 9860
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    vi dp(3);

    rep(day, 0, n) {
        vi new_dp(3);
        vi c(3);

        rep(i, 0, 3)
        scn(c[i]);

        rep(i, 0, 3) {
            rep(j, 0, 3) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }

        dp = new_dp;
    }

    int mx = 0;

    rep(i, 0, 3)
    mx = max(mx, dp[i]);

    prin(mx);
}

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

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define forr(i,k,n) for(int i=k; i<n; i++)
#define iforr(i,k,n) for(int i=n-1; i>=k; i--)
#define rep(i,n) forr(i,0,n)
#define irep(i,n) iforr(i,0,n)
#define aut(i,arr) for(auto& i:arr)
#define all(arr) arr.begin(), arr.end()
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>
#define f first
#define db double
#define s second
#define ll long long 
#define ull unsigned long long
#define E '\n'
#define lmax 9223372036854775807;
#define MOD 1000000007
using namespace std;
vi v;
vvi ed;
void dfs(int i)
{
	v[i]=1;
	aut(j,ed[i])
		if(!v[j])
			dfs(j);
}
void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("code.in","r",stdin);
    freopen("code.out","w",stdout);
    #endif
}

int main()
{
	//Fast_IO();
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		vi arr(n);
		vi dp(n,0);
		rep(i,n)
			cin>>arr[i];
		dp[1]=abs(arr[1]-arr[0]);
		forr(i,2,n)
			dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
		cout<<dp[n-1];
		cout<<E;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

  int h, w;
  cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }

  // cost[i] := 数字iを1に変えるのに必要な魔力
  const int inf = 1e9;
  vector<int> cost(10, inf);
  auto chmin = [](auto &a, auto b) { a = min(a, b); };
  for (int i = 0; i < 10; i++) {
    vector<bool> visit(10);
    function<void(int, int)> dfs = [&](int cur, int d) {
      if (cur == 1) {
        chmin(cost[i], d);
        return;
      }
      for (int j = 0; j < 10; j++) {
        if (visit[j])
          continue;
        visit[j] = true;
        dfs(j, d + c[cur][j]);
        visit[j] = false;
      }
    };
    visit[i] = true;
    dfs(i, 0);
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int a;
      cin >> a;
      if (a == -1)
        continue;
      ans += cost[a];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
a = []
x = 0;
ans = 0

n = gets.to_i
n.times do |i|
  a << gets.to_i
  a[i] -= 1
end

for i in 0..100010
  if x == 1
    ans = i
    break
  end
  x = a[x]
end

if ans != 0
  p ans
else
  puts "-1"
end


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    char x, y;
    cin >> x >> y;
    int p = x;
    int q = y;
    if(p < q) cout << '<' << endl;
    else if(p == q) cout << '=' << endl;
    else cout << '>' << endl;
    return 0;
}

Measured memory_bytes: 3688
N , L = map(int, input().split())
ajisum = 0
aji = L
for x in range(N):
    ajisum += aji
    aji += 1
if L >= 0:
    ans = ajisum - L
elif aji - 1 <= 0:
    ans = ajisum - (aji - 1)
else:
    ans = ajisum
print(ans)

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

int N;
vector<int> A(1e5+5);
vector<int> order(1e5+5);

int main(){

    cin >> N;
    for (int i=1; i<=N; i++){
        cin >> A.at(i);
    }

    for (int i=1; i<=N; i++){
        order.at(A.at(i)) = i;
    }

    for (int i=1; i<=N; i++){
        cout << order.at(i) << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	static int n, m;
	static boolean graph[][];
	static boolean vis[];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		graph = new boolean[n][n];
		vis = new boolean[n];
		for(int i = 0 ; i < m ; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			graph[a][b] = graph[b][a] = true;
		}
		for(int i = 0 ; i < n ; i++) vis[i] = false;
		vis[0] = true;
		System.out.println(dfs(0));
	}

	public static int dfs(int x) {
		boolean all_vis = true;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i] == false) all_vis = false;
		}
		if(all_vis == true) return 1;
		int ret = 0;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i] == true) continue;
			if(graph[x][i] == false) continue;
			vis[i] = true;
			ret += dfs(i);
			vis[i] = false;
		}
		return ret;
	}

}


Measured memory_bytes: 22100
a = gets.to_i + 1
b = gets.to_i + 1
c = gets.to_i + 1
x = gets.to_i

count = 0
a.times do |i|
  b.times do |j|
    c.times do |k|
      total = 500 * i + 100 * j + 50 * k
      count += 1 if total == x
    end
  end
end

puts count


Measured memory_bytes: 1788
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll D, N;
  cin>>D>>N;
  ll ans = 1;
  for(int i=0;i<D;++i) ans *= 100;
  if(N<100) cout<<ans*N<<endl;
  else cout<<ans*(N+1)<<endl;
}



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

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define MOD 998244353

using namespace std;

using pii = pair<int, int>;

unsigned long long clp(unsigned long long x) {
    x -= 1;
    x = x | (x >>  1);
    x = x | (x >>  2);
    x = x | (x >>  4);
    x = x | (x >>  8);
    x = x | (x >> 16);
    x = x | (x >> 32);
    return x + 1;
}

template <class T>
class segment_tree {
private:
    const size_t n;
    const T UNIT;
    const std::function<T(const T&, const T&)> f;
    std::vector<T> a;
public:
    segment_tree(size_t size, std::function<T(const T&, const T&)> f, T UNIT) : n(clp(size)), UNIT(UNIT), f(f) {
        a.resize(2 * n - 1, UNIT);
    }

    void update(size_t i, const T &x) {
        i += n - 1;
        a[i] = x;
        while (i) {
            i = (i - 1) / 2;
            a[i] = f(a[2 * i + 1], a[2 * i + 2]);
        }
    }

    T query(size_t query_first, size_t query_last, size_t k = 0, size_t node_first = 0, size_t node_last = 0) const {
        if (k == 0) {
            node_last = n;
        }
        if (node_last <= query_first || query_last <= node_first) {
            return UNIT;
        }
        if (query_first <= node_first && node_last <= query_last) {
            return a[k];
        } else {
            size_t node_mid = (node_first + node_last) / 2;
            T vl = query(query_first, query_last, k * 2 + 1, node_first, node_mid);
            T vr = query(query_first, query_last, k * 2 + 2, node_mid, node_last);
            return f(vl, vr);
        }
    }
};

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

    int N;
    cin >> N;
    vector<pii> XD(N);
    REP(i, N) {
        int X, D;
        cin >> X >> D;
        XD[i] = pii(X, D);
    }
    sort(all(XD));
    vector<int> X(N), D(N);
    REP(i, N) {
        tie(X[i], D[i]) = XD[i];
    }

    // i 番目のロボットを起動したとき
    // 何番目のロボットまで連鎖するか
    segment_tree<int> rmq(N, [](int x, int y) { return max(x, y); }, INT_MIN);
    
    // dp[i] = (ロボット i 以降のみの組み合わせ)
    vector<int> dp(N + 1);
    dp[N] = 1;

    RREP(i, N) {
        // ロボット i を起動したとき, 直接的に起動するロボット (自身も含める) のうち最も右にあるもの,
        // つまり, X[k] < X[i] + D[i] を満たす k のうち最大のもの,
        // つまり, X[k + 1] >= X[i] + D[i] を満たす k のうち最小のものを求める.
        int k = lower_bound(X.begin() + i, X.end(), X[i] + D[i]) - X.begin() - 1;
        // ロボット i を起動したとき, 間接的に起動するロボットのうち最も右にあるもの.
        int l = rmq.query(i + 1, k + 1);
        // ロボット i を起動したとき, 起動するロボット (自身も含める) のうち最も右にあるもの.
        int m = max(k, l);
        rmq.update(i, m);
        // (ロボット i を起動しない場合) + (ロボット i を起動しない場合)
        dp[i] = (dp[i + 1] + dp[m + 1]) % MOD;
    }

    cout << dp[0] << endl;

    return 0;
}


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

int main(){
    ll r, c;
    cin >> r >> c;
    vector<ll> csum(c, 0);
    REP(i, r){
        ll tmp = 0;
        REP(j, c){
            ll x;
            cin >> x;
            tmp += x;
            csum.at(j) += x;
            cout << x << ' ';
        }
        cout << tmp << endl;
    }
    REP(j, c){
        cout << csum.at(j) << ' ';
    }
    cout << accumulate(csum.begin(), csum.end(), 0LL) << endl;
    return 0;
}



Measured memory_bytes: 3080
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
from collections import Counter
cs=Counter(d)
ct=Counter(t)
j=True
for x in t:
    if cs[x]<ct[x]:
        j=False
print("YES" if j else "NO")

Measured memory_bytes: 127696
using System;
using System.Collections.Generic;
using System.Linq;

namespace id_0339cs
{
    class Triangle:IEquatable<Triangle>
    {
        int _a, _b, _c;
        public Triangle(int[] vs)
        {
            _a = vs[0];
            _b = vs[1];
            _c = vs[2];
        }
        bool IEquatable<Triangle>.Equals(Triangle other)
        {
            if(other == null)
            {
                return false;
            }
            return (this._a == other._a && this._b == other._b && this._c == other._c);
        }
        public override int GetHashCode()
        {
            return (_a.ToString() +" "+ _b.ToString() +" "+ _c.ToString()).GetHashCode();
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            List<Triangle> triangles = new List<Triangle>();
            foreach(var i in Enumerable.Range(0, n))
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x=>x).ToArray();
                triangles.Add(new Triangle(vs));
            }
            int a = triangles.Distinct().Count();
            Console.WriteLine(n - a);

        }
    }
}



Measured memory_bytes: 10568
#include <stdio.h>
int main(){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
      printf("%d\n",a+b);
    }
    else if(op=='-'){
      printf("%d\n",a-b);
    }
    else if(op=='*'){
      printf("%d\n",a*b);
    }
    else if(op=='/'){
      printf("%d\n",a/b);
    }
    else if(op=='?'){
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int a = Integer.parseInt(arr[0]), b = Integer.parseInt(arr[1]);
            if (a > b){
                System.out.println("a > b");
            } else if (a < b){
                System.out.println("a < b");
            } else {
                System.out.println("a == b");
            }
        } catch(IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24508
#include<bits/stdc++.h>
#define LL long long
using namespace std;
string a,b;
int main(){
    getline(cin,a);getline(cin,b);
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(b>a)
        cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
import collections

n = int(input())

s = []

for i in range(n):
    s.append(input())

c = collections.Counter(s)
cc = c.most_common()
mx = cc[0][1]
cc.sort(key = lambda x:x[0])

for i in range(len(cc)):
    if cc[i][1] == mx:
        print(cc[i][0])


Measured memory_bytes: 48408
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
list<ll> graph[100005];
ll n,m;
ll vis[100005]={0};
void dfs(ll p){
	if(vis[p])return;
	vis[p]=1;
	for(auto i=graph[p].begin();i!=graph[p].end();i++){
		dfs(*i);
	}
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			if(i!=1)ans++;
			dfs(i);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 13824
S = input()

ans = ''

if len(S) != 26:
    a_z = [chr(i) for i in range(97, 123)]
    for s in S:
        a_z.remove(s)
    ans = S + a_z[0]
    print(ans)
else:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        ans = -1
        print(ans)
    else:
        a_z = [int(i) for i in range(97, 123)]
        inputs = list(map(ord, list(S)))
        buf = [inputs[-1]]
        for i in range(1, len(S)):
            if inputs[25-i] > inputs[25-(i-1)]:
                buf.append(inputs[25-i])
            else:
                buf.sort()
                for item in buf:
                    if inputs[25-i] < item:
                        last = item
                        break
                print(''.join(list(map(chr, inputs[:25-i]+[last]))))
                break


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


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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<string> t=deduplicate(s);
    cout << t.size() << endl;

    return 0;
}

Measured memory_bytes: 15612