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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int solve(int k, int sz, string s, string target, int cnt) {
  if(k == sz) {
    return s == target ? cnt : INF;
  } else {
    int diff = (target[k] + 10 - s[k]) % 10;
    if(diff) cnt++;
    else return solve(k+1, sz, s, target, cnt);
    int mi = INF;
    for(int i=k;i<sz;++i) {
      s[i] = ((s[i] - '0') + diff) % 10 + '0';
      mi = min(mi, solve(k+1, sz, s, target, cnt));
    }
    return mi;
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int k; cin >> k;
    if(k == 0) break;
    string s1, s2; cin >> s1 >> s2;
    string s = "";
    string zeros = "";
    for(int i=0;i<k;++i) {
      s.push_back((s2[i] + 10 - s1[i]) % 10 + '0');
      zeros.push_back('0');
    }
    int sz = s.size();
    cout << solve(0, sz, s, zeros, 0) << endl;
  }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define INF (1 << 30)

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<string> s(n),t(m);
  bool ok = false;
  REP(i,n)cin >> s[i];
  REP(i,m)cin >> t[i];
  REP(i,n){
    REP(j,n){
      bool flag = true;
      REP(k,m){
        REP(l,m){
          if(i+k >= n || j+l >= n)flag = false;
          if(!flag)break;
          if(s[i+k][j+l] != t[k][l])flag = false;
        }
      }
      if(flag)ok = true;
    }
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

class Combi {
private:
	vector<lint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; 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;
		}
	}

public:
	Combi(int N = 100000) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	lint Cmod(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;
	}

	lint Pmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n - k] % MOD;
	}
};

int N ,K;
lint ans;
Combi C;
vector<vector<Edge<int>>> edges;

lint dfs(int k, vector<Edge<int>> edge,int now, int from) {


	for (const auto &e : edge) {
		if (e.to != from) {
			ans *= dfs(max(k - 1, K - 2), edges[e.to], e.to ,now);
			ans %= MOD;
		}
	}
	
	if (now == 0) ans *= C.Pmod(k, (int)edge.size());
	return C.Pmod(k, (int)edge.size()-1);

}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	edges.resize(N);
	int u, v;
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v;
		edges[u - 1].emplace_back(v - 1, 1);
		edges[v - 1].emplace_back(u - 1, 1);
	}

	ans = K;
	dfs(K - 1, edges[0], 0 ,0);

	cout << ans % MOD << "\n";

	return 0;
}

Measured memory_bytes: 19840
import sys
import collections
input = sys.stdin.readline
N, K, C = map(int, input().split())
S = input().strip()

L, R = [-1]*N, [-1]*N
i = 0
for k in range(K):
  while i < N and S[i] == 'x':
    i += 1
  if i >= N: break
  L[i] = k
  i += C+1
i = N-1
for k in range(K-1, -1, -1):
  while i >= 0 and S[i] == 'x':
    i -= 1
  if i < 0: break
  R[i] = k
  i -= C+1
for i in range(N):
  if L[i] != -1 and L[i] == R[i]:
    print(i+1)

Measured memory_bytes: 20928
n,m=map(int,input().split())
ab=[]
for _ in range(n):
    ab.append(list(map(int,input().split())))
cd=[]
for _ in range(m):
    cd.append(list(map(int,input().split())))
for i in range(n):
    tmp=float('inf')
    ans=0
    for j in range(m):
        if tmp>abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
            tmp=abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            ans=j+1
    print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, K, A[200005];
map<int, int> m;
set<int> st;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>K;
    REP(i,0,N){
        cin>>A[i];
        m[A[i]]++;
        st.insert(A[i]);
    }

    vector<pair<int, int>> v;
    auto itr = m.begin();
    while(itr != m.end()){
        v.push_back(make_pair((*itr).S, (*itr).F));
        itr++;
    }

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

    int ans = 0;
    REP(i,0,v.size()){
        if(st.size() <= K) break;
        ans += v[i].F;
        st.erase(v[i].S);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 22008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



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

   int count=0,ans=0;
   for(int i=0; i<s.size(); i++){
       if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
           count ++;
           ans = max(ans,count);
       }
       else count =0;
   }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);

  int amax, asec, a[N + 3];
  int amaxi, aseci;
  amax = asec = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > amax) {
      amax = a[i];
      amaxi = i;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i == amaxi) continue;
    if (a[i] > asec) {
      asec = a[i];
      aseci = i;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i == amaxi) {
      printf("%d\n", asec);
    } else {
      printf("%d\n", amax);
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#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 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

int main()
{
  int N;
  cin>>N;
  vector<int> A(N,0);
  REP(i,N) cin>>A[i];
  int cnt=0;
  bool Even=true;
  while(Even)
  {
      for (int i = 0; i < N; ++i)
      {
          if (A[i] % 2 != 0)
          {
              Even = false;
              
          }
          A[i] /= 2;
      }
      ++cnt;
  }
  cout<<cnt-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans=INF;
  for(int i=0;i<=200000;i++){
    ll res=0;
    res+=i*c;
    res+=max(0,(x-i/2))*a+max((y-i/2),0)*b;
    chmin(ans,res);
  }
  cout << ans << endl;
    
}


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

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

  int ans = 0; int v = 0;
  for(int i =0 ; i<N-1; i++){
    if(H[i]>=H[i+1]){
      v++;}

    else{
      v = 0;
    }
    ans = max(ans,v);
    }
    cout << ans << endl;
  }


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int h,w; cin>>h>>w;
    int sy,sx,gy,gx; cin>>sy>>sx>>gy>>gx;
    --sy; --sx; --gy; --gx;
    vector<string> g(h);
    rep(i,h) cin>>g[i];

    deque<P> q;
    vector<vector<ll>> dp(h+1, vector<ll>(w+1, LINF));
    q.emplace_back(sy,sx);
    dp[sy][sx] = 0;
    while (!q.empty()) {
        P cur = q.front(); q.pop_front();
        int cy = cur.first; int cx = cur.second;
        for (int dy = -2; dy <= 2; ++dy) {
            for (int dx = -2; dx <= 2; ++dx) {
                if (dy == 0 && dx == 0) continue;
                int ny = dy+cy; int nx = dx+cx;
                int cost = 1;
                if ((dy==0 && dx==1) || (dy==0 && dx==-1) || (dy==1 && dx==0) || (dy==-1 && dx==0)) {
                    cost = 0;
                }
                if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if (g[ny][nx] == '#') continue;
                if (chmin(dp[ny][nx], dp[cy][cx]+cost)) {
                    if (cost) q.emplace_back(ny,nx);
                    else q.emplace_front(ny,nx);
                }
            }
        }
    }

    if (dp[gy][gx] == LINF) cout << -1 << '\n';
    else cout << dp[gy][gx] << '\n';
    return 0;
}

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

int main(){
    char s[101000];
    cin >> s;
    bool a[26]={false};
    for(int i=0;s[i]!='\0';i++)a[s[i]-'a']=true;
    for(int i=0;i<26;i++){
        if(!a[i]){
            cout << (char)(i+'a') <<endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int n, r;
    cin >> n >> r;

    if(n < 10) cout << r + 100*(10-n) << endl;
    else cout << r << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;


int main()
{
    int s, w;

    cin >> s >> w;

    if (w >= s) cout << "unsafe\n";
    else cout << "safe\n";

    return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;
int n;
ll seg[5*N];
void update(int i,ll val,int p=1,int L=1,int R=n){
    if(L>i || R<i)return;
    if(i==L && i==R){
        seg[p] = val;
        return ;
    }
    int mid = L+R >> 1;
    update(i,val,2*p,L,mid);
    update(i,val,2*p+1,mid+1,R);
    seg[p] = max(seg[2*p],seg[2*p+1]);
}

ll query(int i,int j,int p=1,int L=1,int R=n){
    if(L>j || R<i)return 0;
    if(L>=i && R<=j)return seg[p];
    int mid = L+R >> 1;
    ll c1 = query(i,j,2*p,L,mid);
    ll c2 = query(i,j,2*p+1,mid+1,R);
    return max(c1,c2);
}


int main()
{
    FASTIO
    cin >> n;
    vector<pair<int,pair<int,int> > > a;
    a.resize(n);
    for(int i=0;i<n;i++){
        cin >> a[i].F;
    }
    for(int i=0;i<n;i++){
        cin >> a[i].S.F;
        a[i].S.S = i+1;
    }
    sort(all(a),greater<pair<int,pair<int,int> > >());
    for(int i=0;i<n;i++){
        int ind=a[i].S.S;
        int b=a[i].S.F;
        ll x = b + query(ind,n);
        update(ind,x);
    }
    cout << query(1,n) << endl;
    return 0;
}
/**

*/


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

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

    int count = 0;
    int D = 0;
    int L;
    

    while (D <= X) {
        count++;
        if (count == N+1) {
            cout << count << endl;
            return 0;
        }
        cin >> L;
        D = D + L;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const R = parseInt(input)
    if(R < 1200){
        console.log('ABC')
    } else if (R < 2800){
        console.log('ARC')
    } else {
        console.log('AGC')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};


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

    UnionFind uf(N);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        --a; --b;

        uf.unite(a, b);
    }

    int ans = 0;
    REP(i, N){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if (n % 2 == 1) {
            System.out.println(0);
            return;
        }
        long base = 10;
        long count = 0;
        while (base <= n) {
            count += n / base;
            base *= 5;
        }
        System.out.println(count);
    }
}

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

/*int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << sqrt(pow((x1-x2),2)+pow((y1-y2),2)) << endl;
    return 0;
}*/

int main(){
    double a,b,c,S,L,h;
    double PI = acos(-1);
    cin >>a>>b>>c;
    S=a*b*sin(c*PI/180.0)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180.0));
    h=2*S/a;
    cout << fixed << setprecision(8) << S << endl << L << endl << h <<endl;
}


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

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> E(N), R(N);
  REP(i, 0, M) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    E[x].push_back(y);
    R[y].push_back(x);
  }

  vector<ll> cnt(N);
  REP(i, 0, N) {
    cnt[i] = R[i].size();
  }

  stack<ll> stk;
  REP(i, 0, N) {
    if (cnt[i] == 0) {
      stk.push(i);
    }
  }

  vector<ll> dp(N);

  while (!stk.empty()) {
    ll v = stk.top();
    stk.pop();

    for (ll u : E[v]) {
      dp[u] = max(dp[u], dp[v] + 1);
      if (cnt[u]-- == 1) {
        stk.push(u);
      }
    }
  }

  ll ans = 0;
  REP(i, 0, N) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
  {
   long long int n,cnt=0;
  string s;
   cin>>n;
  cin>>s;
   for(int i=0;i<n;i++){
  if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
    cnt++;
  }
  cout<<cnt;
  return 0;
  }


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N, q; cin >> N >> q;
    vector<tuple<ll, ll, ll>> cst(0);
    rep(i, 0, N){
        ll a, b, c; cin >> a >> b >> c;
        cst.emplace_back(c, a-c, b-c);
    }
    sort(cst.begin(),cst.end());
    set<ll> t;
    t.insert(INF);
    vll lis;
    rep(i, 0, q){
        ll v; cin >> v;
        t.insert(v);
        lis.emplace_back(v);
    }
    Map o;
    for(auto x: cst){
        ll X = get<0>(x), s = get<1>(x), e = get<2>(x);
        
        auto r = t.lower_bound(s); auto u = t.lower_bound(e);
        auto f = r;
        vll p(0);
        rep(i, 0, N){
            if(f == u){
                break;
            }
            ll g = *f;
            p.emplace_back(g);
            o[g] = X;
            f = next(f, 1);
        }
        for(auto y: p){
            t.erase(y);
        }
        //prt(endl);
    }
    ll m = 0;
    for(auto x: lis){
        if(o.find(x) == o.end()){
            prtl(-1);
        }else{
            prtl(o[x]);
        }
    }
}





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

using namespace std;

int main() {
	string S;
	int nedan = 700;

	cin >> S;

	if (S[0] == 'o')nedan += 100;
	if (S[1] == 'o')nedan += 100;
	if (S[2] == 'o')nedan += 100;

	cout << nedan << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int max = 0;
        for (int i = 2; i < s.length(); i += 2) {
            String left = s.substring(0, (s.length() - i) / 2);
            String right = s.substring((s.length() - i) / 2, (s.length() - i));
            //System.out.println(left + " " + right);
            if (left.equals(right)) {
                System.out.println(s.length() - i);
                return ;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H,vector<char>(W));
  rep(y,H) rep(x,W) cin >> S[y][x];
  rep(y,H) rep(x,W){
    if(S[y][x]=='.') continue;
    int count = 0;
    if(x!=0){
      if(S[y][x-1]=='#') count++;
    }
    if(x!=W-1){
      if(S[y][x+1]=='#') count++;
    }
    if(y!=0){
      if(S[y-1][x]=='#') count++;
    }
    if(y!=H-1){
      if(S[y+1][x]=='#') count++;
    }
    if(count==0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
// by : 信冯哥
#include<bits/stdc++.h>
using namespace std;
const int maxn = (int)1e3+5;
const int mod = (int)1e9+7;

typedef long long ll;
//#define int ll

#define orz cout<<endl
#define debug cout<<"-------------------"<<endl
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)
#define sync ios::sync_with_stdio(false)

int n,m,k,l,s,t,r;
double a[maxn],T,op,x,ans;

int main()
{
	
	ans=double(mod);
	cin>>n;
	cin>>T>>op;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(ans>fabs(T-0.006*x-op))
			{
				t=i;
				ans=fabs(T-0.006*x-op);
				
			}
	}
	cout<<t;
	return 0;
}


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

int main(){
    ll n; cin >> n;
    n %= 1000;
    if(n == 0) put(0);
    else put(1000-n);
}

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

int main(){
  int N;
  int ans = 0;
  int count = 0;
  vector<int> anss;
  cin >> N;
  while(N){
    int i = 1;
    while( i <= N/2 ){
      int j = i;
      while(ans < N){
        ans += j;
        if(ans == N) count++;
        j++;
      }
      i++;
      ans = 0;
    }
    anss.push_back(count);
    count = 0;
    cin >>  N;
  }
  for(int j = 0; j < anss.size(); j++){
    cout << anss[j] << endl;
  }
}



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

const int MOD = 1000000007;
using Data = pair<long long, vector<ll> >;

int main() {
  ll n;
  cin >> n;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  sort(vec.begin(),vec.end());
  rep(i,n-1){
    if(vec[i]==vec[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1792
from collections import deque
n = int(input())
a = list(map(int,input().split()))
q = deque()
for i in range(n):
    if i % 2 == 0:
        q.appendleft(a[i])
    else:
        q.append(a[i])
if n % 2 == 0:
    q.reverse()
print(*q)


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

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

    int n, d, x;
    cin >> n >> d >> x;
    VVI p(d, vector<int>(n, 0));
    for (int i = 0; i < d; i++)
        for (int j = 0; j < n; j++)
            cin >> p[i][j];
    std::vector<int> dp(100001);
    for (int i = 0; i < d - 1; i++)
    {
        for (int j = 0; j <= x; j++)
            dp[j] = j;
        for (int j = 0; j < n; j++)
            for (int k = 0; k <= x; k++)
            {
                if (k - p[i][j] >= 0)
                {
                    dp[k] = max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
                }
            }
        for (int j = 0; j <= x; j++)
            x = max(x, dp[j]);
    }
    cout << x << endl;
}


Measured memory_bytes: 3392
/*https://atcoder.jp/contests/abc068/tasks/abc068_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, max_count = 0, val = 1;
	cin >> n;
	// cout << 2 / 2;
	for (int i = 1; i <= n; i++)
	{
		int count = 0, a = i;
		while (a % 2 == 0)
			a /= 2, count++;
		if (count > max_count)
			max_count = count, val = i;
	}
	cout << val;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main() {
  int num;
  cin >> num;
  vector<int> nums(4);
  for(int i = 0; i < 4; i++) {
    nums.at(i) = num % 10;
    num /= 10;
  }
  
  for(int tum = 0; tum < (1 << 3); tum++) {
    int sum = nums.at(3);
    string S = to_string(nums.at(3));
    bitset<3> bits(tum);
    if(bits.test(0)) {
      sum += nums.at(2);
      S += "+";
    } else {
      sum -= nums.at(2);
      S += "-";
    }
    S += to_string(nums.at(2));
    if(bits.test(1)) {
      sum += nums.at(1);
      S += "+";
    } else {
      sum -= nums.at(1);
      S += "-";
    }
    S += to_string(nums.at(1));
    if(bits.test(2)) {
      S += "+";
      sum += nums.at(0);
    } else {
      sum -= nums.at(0);
      S += "-";
    }
    S += to_string(nums.at(0));
    if(sum == 7) {
      
      S += "=7";
      cout << S << endl;
      return 0;
    }
  }
}

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

int N;
vector<double> v;

int main () {
  cin >> N;
  v.resize(N);
  rep(i,N) cin >> v[i];

  sort(all(v));

  double x = 0;
  ll k = 1;
  for(int i = N - 1; i >= 1; i--) {
    k *= 2;
    x += v[i] / k;
  }
  x += v[0] / k;

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll N,M;
	cin>>N>>M;
	vector<ll>v;
	for(ll i=1;i*i<=M; i++){
		if(M%i==0){
			v.push_back(i);
          	v.push_back(M/i);
		}
	}
  	ll n=v.size();
  	sort(v.rbegin(),v.rend());
	for(ll i=0; i<n; i++){
      		if(v[i]*N<=M){
			cout<<v[i]<<endl;
			return 0;
		}
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
int main()
{
	int n;
	string a,b;
	map<string,int> t;
	cin>>n;
	while(n--)
	{
		cin>>a>>b;
		if(a[0]=='i') t[b]=1;
		else
		{
			if(t[b]) cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 52448
use proconio::input;

// ordtools {{{
#[allow(dead_code)]
mod ordtools {
    pub trait Ordtools: PartialOrd + Sized {
        fn change_min(&mut self, mut rhs: Self) {
            if self > &mut rhs {
                *self = rhs;
            }
        }

        fn change_max(&mut self, mut rhs: Self) {
            if self < &mut rhs {
                *self = rhs;
            }
        }
    }

    impl<T: PartialOrd + Sized> Ordtools for T {}
}
// }}}
use ordtools::Ordtools;

fn main() {
    input!(n: usize, a: [i64; n]);
    let sum = a.iter().copied().sum::<i64>();
    let mut now = 0;
    let mut ans = std::i64::MAX;
    for (i, x) in a.iter().copied().enumerate() {
        now += x;
        if i != n - 1 {
            ans.change_min((sum - 2 * now).abs());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4728
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

//#[proconio::fastout]
fn main() {
    input!(
        n: usize,
        ss: [Chars; n],
    );
    let mut ans = String::new();
    let mut counts = BTreeMap::new();
    for s in ss {
        let mut count = HashMap::new();
        for c in s { *count.entry(c).or_insert(0) += 1; }
        for (c, k) in count.into_iter() { counts.entry(c).or_insert(Vec::new()).push(k); }
    }
    for (k, v) in counts.into_iter() {
        if v.len() == n {
            for _ in 0..(v.into_iter().min().unwrap()) { ans.push(k); }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, d, x;
  cin >> n >> d >> x;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x += (d-1)/a + 1;
  }
  cout << x << endl;
  return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    vector<P> task( N );
    REP( i, N ) cin >> task[i].second >> task[i].first;
    sort( ALL( task ) );

    int time = 0;
    REP( i, N ){
        time += task[i].second;
        if( time > task[i].first ){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


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

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

using namespace std;

int main() {

    int k;
    cin >> k;

    vector<long int> L{1,2,3,4,5,6,7,8,9}, tmp{1,2,3,4,5,6,7,8,9}, tmp2;

    rep(j,9) {  

        rep(i,tmp.size()) {
            if (tmp[i]%10!=0) tmp2.push_back(10*tmp[i]+(tmp[i]%10-1));
            tmp2.push_back(10*tmp[i]+(tmp[i]%10));
            if (tmp[i]%10!=9) tmp2.push_back(10*tmp[i]+(tmp[i]%10+1));
        }

        copy(tmp2.begin(), tmp2.end(), back_inserter(L));
        tmp.erase(tmp.begin(), tmp.end());
        copy(tmp2.begin(), tmp2.end(), back_inserter(tmp));
        tmp2.erase(tmp2.begin(), tmp2.end());
    }

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

    cout << L[k-1] << endl;
    
    return 0;
}

Measured memory_bytes: 5332
require 'set'
def check(arr)
  a =[0,9,12,15,18,21,30]
  a.each_cons(2){|s,t| return false if (s...t).any?{ |i| arr[i] != arr[s] } }
  true
end

MV = [[0,1,2,14,18,27,28,29,15,20],
      [6,7,8,12,9,21,22,23,17,11],
      [0,3,6,9,15,23,26,29,20,17],
      [2,5,8,11,12,21,24,27,18,14]]
  
gets.to_i.times do
  cube = gets.split(" ").map(&:to_i)
  s = Set.new(cube)
  q = []
  q << [cube, 0]
  until q.empty?
    tmp, cnt = q.shift
    if check tmp
      p cnt
      break
    end
    MV.each do |arr|
      tmp2 = tmp.dup
      arr[0,5].zip(arr[5,5]).each do |a, b|
        tmp2[a], tmp2[b] = tmp2[b], tmp2[a]
      end
      unless s.include? tmp2
        q << [tmp2, cnt+1] 
        s.add tmp2
      end
    end
  end
end

Measured memory_bytes: 9180
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (n, mut k): (usize, usize);
    input!(n, k);
    let mut v = Vec::new();
    for _ in 0..n {
        let (a, b): (usize, usize);
        input!(a, b);
        v.push((a, b));
    }
    v.sort();
    for (a, b) in v {
        if k > b {
            k -= b;
        } else {
            p(a);
            break;
        }
    }
}

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

#define x first
#define y second

int main() {
  int n;
  cin >> n;
  set < pair < int, int > > gay, shit;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    pair < int, int > gang;
    cin >> gang.first >> gang.second;
    gay.insert(gang);
  }
  for (int i = 0; i < n; ++i) {
    pair < int, int > gang;
    cin >> gang.first >> gang.second;
    shit.insert(gang);
  }
  while (!shit.empty()) {
    auto pr = *shit.begin();
    shit.erase(shit.begin());
    pair < int, int > res = make_pair(-1, -1);
    for (auto gang: gay) {
      if (pr.x > gang.x && pr.y > gang.y)
        res = max(res, make_pair(gang.y, gang.x));
    }
    gay.erase(make_pair(res.y, res.x));
    if (res.first > -1)
      ++ans;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
fun main(args: Array<String>): Unit {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()

    var L = 0
    var r = Int.MAX_VALUE
    for (i in 0 until m) {
        L = Math.max(L, sc.nextInt())
        r = Math.min(r, sc.nextInt())
    }
    println(Math.max(r - L + 1, 0))
}


Measured memory_bytes: 68724
INF = 2000000000


def warshallFloyd():
    global V
    for k in range(V):
        for i in range(V):
            if A[i][k] == INF:
                continue
            for j in range(V):
                if A[k][j] == INF:
                    continue
                A[i][j] = min(A[i][k] + A[k][j], A[i][j])
    


nums=list(map(int,input().split()))
V = nums[0]
E = nums[1]

A = [[INF for i in range(V)] for j in range(V)]
for i in range(V):
    A[i][i] = 0

for i in range(E):
    nums=list(map(int,input().split()))
    A[nums[0]][nums[1]] = nums[2]

warshallFloyd()

negative = False

for i in range(V):
    if A[i][i] < 0:
        negative = True

if negative:
    print("NEGATIVE CYCLE")
else:
    for i in range(V):
        for j in range(V):
            if A[i][j] == INF:
                A[i][j] = "INF"
        
    for i in range(V):
        for j in range(V-1):
            if A[i][j] == INF:
                A[i][j] = "INF"
            print(A[i][j], end = " ")
        print(A[i][V-1])















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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("pieaters.in","r",stdin)
#define OUT freopen("pieaters.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

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

#define INF 2000000000
#define alpha 26

#define maxn 3010
#define LOG 18

vector <int> g[maxn] ;
int w[maxn] , a[maxn] ;

int dfs(int u, int par)
{
    int res = 0 ;
    for(int v: g[u])
    {
        if( v==par ) continue ;
        if( a[v] < a[u] ) res |= ( dfs(v,u)^1 ) ;
    }
    return res ;
}

int main()
{
    int n ;

    scanf("%d",&n) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;

    for(int i=1 ; i<n ; i++)
    {
        int u , v ;
        scanf("%d %d",&u,&v) ;
        g[u].pb(v) ; g[v].pb(u) ;
    }

    vector <int> ans ;

    for(int i=1 ; i<=n ; i++)
    {
        w[i] = dfs(i,0) ;
        if(w[i]==1) ans.pb(i) ;
    }

    for(int v:ans) printf("%d ",v) ;
    printf("\n") ;

    return 0 ;
}


Measured memory_bytes: 512
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>

#define dprintf(s,...) printf("%s:%d" s,__func__,__LINE__,__VA_ARGS__)
using namespace std;

typedef pair<int,int> P;
typedef long long int ll;
int n,r;
int c[51];

void solve(vector<int> &deck, vector<int> &deckC,int c){

  queue<int> deckA,deckB;
  int b=floor(n/2);
  
  for(int i=0;i<n;i++){
    if(i<b) deckB.push(deck[i]);
    else deckA.push(deck[i]);
  }
  int id=0;
  while(id<n){
    for(int i=0;i<c;i++){
      if(deckA.empty()) break;
      deckC[id] = deckA.front();
      deckA.pop();
      id++;
      
    }
    for(int i=0;i<c;i++){
      if(deckB.empty()) break;
      deckC[id] = deckB.front();
      deckB.pop();
      id++;
    }

  }
  

}

int main(){

  
  while(1){
    cin>>n>>r;
    if(cin.eof()) break;
    for(int i=0;i<r;i++){
      cin>>c[i];
    }
    vector<int> deck(n),deckC(n);
    for(int i=0;i<n;i++) deck[i]=i;
    for(int i=0;i<r;i++){
      solve(deck,deckC,c[i]);
      swap(deck,deckC);
    }
    //for(int i=0;i<n;i++)
      //cout<<deck[i]<<" ";
    //cout<<endl;
    cout<<deck[n-1]<<endl;
  }
  
  return 0;
}

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

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> X(M);

    for (int i = 0; i < M; i++) {
        std::cin >> X[i];
    }

    if (N >= M) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::sort(X.begin(), X.end(), [](const auto &lhs, const auto &rhs) { return lhs < rhs; });

    std::vector<int> reg(M - 1);
    for (int i = 0; i < M - 1; i++) {
        reg[i] = X[i + 1] - X[i];
    }

    std::sort(reg.begin(), reg.end(), [](const auto &lhs, const auto &rhs) { return lhs > rhs; });

    int move_cnt = X[M - 1] - X[0];
    for (int i = 0; i < N - 1; i++) {
        move_cnt -= reg[i];
    }

    std::cout << move_cnt << std::endl;

    return 0;
}


Measured memory_bytes: 1024
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                thanks                         return
#define                pii                            pair<int,int>
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}

void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    thank_you;
}


void solve()
{
    int n,l;
    cin>>n>>l;
    vector<string> v(n);
    iter_(i,n)
        cin>>v[i];
    sort(v.begin(),v.end());
    iter_(i,n)
        cout<<v[i];
    cout<<endl;

}


Measured memory_bytes: 3556
function main(input) {
  let args = input.split("\n");
  let n = args.length;

  for (let i = 0; i < n; i++) {
    if (args[i] === "0") {
      break;
    }
    let ret = 0;
    for (let j = 0; j < args[i].length; j++) {
      ret += Number(args[i][j]);
    }
    console.log(ret);
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 16172
# 問題：https://atcoder.jp/contests/abc142/tasks/abc142_d

import math

def gcd(a, b):
    while b > 0:
        tmp = b
        b = a % b
        a = tmp
    return a


def count_prime_factorize(n):
    res = 1
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            res += 1
            while n % i == 0:
                n //= i
        i += 1
    if n != 1:
        res += 1
    return res


a, b = map(int, input().strip().split())
x = gcd(a, b)
res = count_prime_factorize(x)
print(res)



Measured memory_bytes: 9120
/*
***AUTHOR***
*ADVAITVD99*
*/
#include<bits/stdc++.h>

using namespace std;

int main(){
	//clock_t tim;
    //tim = clock();
	const long long MOD=998244353;
    {
		int n,k;
		cin>>n>>k;
		vector<pair<int,int>> coins;
		for(int i=0;i<k;i++){
			int L,R;
			cin>>L>>R;
			R++;
			coins.push_back({L,R});
		}	
		//sort(coins.begin(),coins.end());
		long long dp[n];
		fill(dp,dp+n,0);
		dp[0]=1;
		dp[1]=-1;
		for(int i=0;i<n;i++){
			if(i>0){
				dp[i]=(dp[i]+dp[i-1])%MOD;
			}
			for(int j=0;j<k;j++){
				int l,r;
				l=coins[j].first;
				r=coins[j].second;
				if(i+l<n){
					dp[i+l]=(dp[i+l]+dp[i])%MOD;
				}
				if(i+r<n){
					dp[i+r]=(dp[i+r]-dp[i]);
				}
			}
		}
		dp[n-1]=dp[n-1]%MOD;
		if(dp[n-1]<0){
			dp[n-1]+=MOD;
		}
		cout<<dp[n-1]<<endl;
	}

    //tim = clock() - tim;
    //double time_taken = ((double)tim)/CLOCKS_PER_SEC;
    //cout<< fixed << setprecision(3) << time_taken << "seconds" <<endl;

	return 0;
}


Measured memory_bytes: 5184
#include <stdio.h>
#include <stdlib.h>

#define H 500001

void maxHeapify(int [], int, int);
void buildMaxHeap(int [], int);

int main(){
  int i;
  int h;
  int a[H];

  scanf("%d",&h);
  if(h<1 || h>H) exit(1);

  for(i=1; i<h+1; i++) scanf("%d", &a[i]);  

  buildMaxHeap(a, h);

  for(i=1; i<h+1; i++){
    printf(" %d", a[i]);
    if(i==h) printf("\n");
  }

  return 0;
  
}

void buildMaxHeap(int a[], int h){
  int i;
  for(i=h/2; i>0; i--) maxHeapify(a, i, h);
  return;
}

void maxHeapify(int a[], int i, int h){
  int left, right, big, tmp;

  left = i*2;
  right = left+1;

  if(left <= h && a[left]>a[i]) big = left;
  else big = i;

  if(right <= h && a[right] > a[big]) big = right;

  if(big != i){
    tmp = a[big];
    a[big] = a[i];
    a[i] = tmp;
    maxHeapify(a, big, h);
  }
  return;
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    int count=0;
    rep(i,n-1) if(a[i]==a[i+1]) count++;
    if(count%2==1) count++;

    cout << n-count << endl;

    return 0;
}

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

#define MAX_N 1000
#define MAX_M 1000

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

}



Measured memory_bytes: 3624
import collections
def e(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res
MOD = 10**9 + 7
n = int(input())
chk = [0 for i in range(n+1)]
for i in range(2, n+1):
    tmp = collections.Counter(e(i))
    for j in tmp:
        chk[j] += tmp[j]
ans = 1
for i in chk:
    if i:
        ans = ans*(i + 1)%MOD
print(ans)

Measured memory_bytes: 3316
n = int(input())
C = []
S = []
F = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    time = 0
    while i != n-1:
        if i == 0:
            time += S[i]
        elif S[i] <= time and time%F[i] == 0:
            time += 0
        else:
            if time > S[i]:
                r = (time-S[i])//F[i]
                time = S[i] + F[i]*(r + 1)
            else:
                time = S[i]
        time += C[i]
        i += 1        
    print(time)

print(0)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
ll g1(ll n, int p) {
	if (n == 0)return 0;
	return n/p+g1(n/p,p);
}
int main() {
	ll a,ans=0;
	cin >> a;
	if(a%2==0) ans = g1(a/2, 5);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        Reader.init();
        long A=Reader.nextLong();
      	long B=Reader.nextLong();
      	println(lcm(A, B));
    }

    static int mod=1000000007;
    public static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextInt(); } }
    public static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextLong(); } }
    public static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.next(); } }
    public static void print(Object O){ System.out.print(O); }
    public static void println(Object O){ System.out.println(O); }
    public static void display(int arr[]){ System.out.println(Arrays.toString(arr)); }
    public static void display(int arr[][], int N){ for(int i=0;i<N;i++){ System.out.println(Arrays.toString(arr[i])); } }
  	static long gcd(long x, long y) { return y==0 ? x : gcd(y, x % y); }
    static long lcm(long x, long y) { return x*y / gcd(x, y); }
}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init() {
        reader=new BufferedReader(new InputStreamReader(System.in));
        tokenizer=new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) {
            tokenizer=new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException { return Integer.parseInt(next()); }
    static double nextDouble() throws IOException { return Double.parseDouble(next()); }
    static long nextLong() throws IOException { return Long.parseLong(next()); }
    static String nextLine() throws IOException { return reader.readLine(); }
}

Measured memory_bytes: 23124