akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    unordered_map<string, ll> counter;

    int N;

    std::cin >> N;
    string s;

    for (int i = 0; i < N; ++i)
    {
        std::cin >> s;

        std::sort(s.begin(), s.end());

        counter[s]++;
    }

    ll combinations = 0;

    for (auto& it : counter)
    {
        ll curr = (it.second * (it.second - 1)) / 2;
        combinations += curr;
    }

    cout << combinations << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 10660
from collections import deque

while True:
    x, y = map(int, input().split())
    if x == 0:break
    mp = [list("#" * (x + 2))] + [list("#" + input() + "#") for _ in range(y)] + [list("#" * (x + 2))]
    ice_cnt = 0
    ice_dic = []
    vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
    
    
    def ice_search(x, y, ice_cnt):
        for dx, dy in vec:
            if mp[y + dy][x + dx] == "X":
                mp[y + dy][x + dx] = ice_cnt
                ice_dic[ice_cnt] += 1
                ice_search(x + dx, y + dy, ice_cnt)


    for i in range(1, y + 1):
        for j in range(1, x + 1):
            if mp[i][j] == "S":
                sx, sy = j, i
                mp[i][j] = "."
            if mp[i][j] == "G":
                gx, gy = j, i
                mp[i][j] = "."
            if mp[i][j] == "X":
                mp[i][j] = ice_cnt
                ice_dic.append(1)
                ice_search(j, i, ice_cnt)
                ice_cnt += 1

    que = deque()
    que.append((0, sx, sy, [v // 2 for v in ice_dic], 0))
    dic = {}
    dic[(sx, sy, 0)] = 0
    hash_lst = [150 ** i for i in range(len(ice_dic))]
    while que:
        score, px, py, counters, hs = que.popleft()
        if (px, py) == (gx, gy):
            print(score)
            break
        for dx, dy in vec:
            nx, ny = px + dx, py + dy
            if mp[ny][nx] == "#":continue
            elif mp[ny][nx] == ".":
                if (nx, ny, hs) in dic:continue
                dic[(nx, ny, hs)] = True
                que.append((score + 1, nx, ny, counters[:], hs))
            else:
                num = mp[ny][nx]
                if counters[num] <= 0:continue
                new_counters = counters[:]
                new_counters[num] -= 1
                new_hs = hs + hash_lst[num]
                if (nx, ny, new_hs) in dic:continue
                dic[(nx, ny, new_hs)] = True
                que.append((score + 1, nx, ny, new_counters, new_hs))



Measured memory_bytes: 267256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,i,j,k;
  string s;
  cin>>n>>a>>b>>s;
  int x=0,y=0;
  for(i=0;i<n;i++){
    if(s[i]=='a') {
      if(x<a+b){
	x++;
	cout << "Yes" << endl;
      }else cout << "No" << endl;
    }
    if(s[i]=='b') {
      if(x<a+b&&y<b){
	x++;
	y++;
	cout << "Yes" << endl;
      }else cout << "No" << endl;
    }
    if(s[i]=='c') {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;
queue<P>Q;

int main(){

    ll N, K;
    cin >> N >> K;
    ll tmp[111] = {};
    ll sum = 0;
    for(ll i = 2; i <= N; i++){
        tmp[i] = i;
        sum += (N - i);
        Q.push(P(1, i));
    }  
    if(sum < K){
        cout << -1 << endl;
        return 0;
    }

    for(ll idx = N; sum > K; sum--){
        if(tmp[idx] == N)idx--;
        Q.push(P(idx, tmp[idx] + 1));
        tmp[idx]++;
    }
    cout << Q.size() << endl;
    while(!Q.empty()){
        cout << Q.front().first << " " << Q.front().second << endl;
        Q.pop();
    }



    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin>>s>>t;
	int m = s.size();
	int n = t.size();
	int dp[m][n];pp par[m][n];
	rep(i,0,m)
	{
		rep(j,0,n)
		{
			dp[i][j] = 0;
			if(s[i]==t[j])
			{
				if(i>0 and j>0) dp[i][j] = 1+dp[i-1][j-1];
				else dp[i][j] = 1;
			}
			else
			{
				if(i>0) dp[i][j] = max(dp[i][j],dp[i-1][j]);
				if(j>0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
			}
		}
	}

	rep(i,0,m)
	{
		rep(j,0,n)
		{
			par[i][j] = {-1,-1};
			if(s[i]==t[j])
			{
				if(i>0 and j>0 and dp[i][j] == 1+dp[i-1][j-1]) par[i][j] ={i-1,j-1} ;
				else par[i][j] = {-1,-1};
			}
			else
			{
				if(i>0 and dp[i][j]==dp[i-1][j]) par[i][j] = {i-1,j};
				if(j>0 and dp[i][j] == dp[i][j-1]) par[i][j] = {i,j-1};
			}


		}
	}
	int i = m-1;
	int j = n-1;
	string ans;
	while(pp(i,j)!=pp(-1,-1))
	{
		if(s[i]==t[j]) ans.pb(s[i]);
		int t = par[i][j].first;
		j = par[i][j].second;
		i = t;

	}
	reverse(all(ans));
	cout<<ans<<endl;


}

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

int main(){
	int n;
	cin >> n;
	int counts = 0;
	int countsA = 0;
	for(int i = 1; i <=n; i++){
		counts = 0;
		if(i%2 == 0) continue;
		else{
	    for(int j = 1; j<=n;j++){
			if(i%j == 0) counts++;
		}
		if(counts == 8) countsA++;
	}
	}
	cout << countsA << endl;
}

Measured memory_bytes: 3612
from collections import defaultdict
S = list(input())[::-1]
n = len(S)
d = defaultdict(int)
d[0] += 1
res = 0
for i, s in enumerate(S):
    res += int(s)*pow(10, i, 2019)
    res %= 2019
    d[res] += 1

ans = 0
for k in d.keys():
    dk = d[k]
    ans += dk*(dk-1)//2
print(ans)

Measured memory_bytes: 12188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int N = pow(10, 5);
vector<bool> isp(N + 1, true);
//素数ならtrueを返すライブラリ
void sieve()
{
    isp[0] = false;
    isp[1] = false;
    for (int i = 2; pow(i, 2) <= N; i++)
    {
        if (isp[i])
            for (int j = 2; i * j <= N; j++)
                isp[i * j] = false;
    }
}

int main()
{
    sieve();
    int n;
    cin >> n;

    int cnt = 0, i = 0;
    while (cnt < n)
    {
        i++;
        if (isp[i] && i % 5 == 1)
        {
            cout << i << " ";
            cnt++;
        }
    }

    cout << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  ll h,w;cin>>h>>w;
  ll mi=1e18;

  if(w%3==0||h%3==0){out(0);return 0;}

  for(int i=1;i<=((h%2)?h/2:h/2+1);i++){
      ll s0=w*i;
      ll s1=w/2*(h-i);
      ll s2=(w+1)/2*(h-i);
      mi=min(mi,max({s0,s1,s2})-min({s0,s1,s2}));
      
  }
  int q=w/3,r=w%3;
  ll s[5];
  rep(i,0,3){
    int l=q;
    if(r!=0){l++;r--;}
    s[i]=l*h;
  }
  mi=min(mi,max({s[0],s[1],s[2]})-min({s[0],s[1],s[2]}));

  swap(h,w);
  for(int i=1;i<=((h%2)?h/2:h/2+1);i++){
      ll s0=w*i;
      ll s1=w/2*(h-i);
      ll s2=(w+1)/2*(h-i);
      mi=min(mi,max({s0,s1,s2})-min({s0,s1,s2}));
   
  }
  q=w/3,r=w%3;
  rep(i,0,3){
    int l=q;
    if(r!=0){l++;r--;}
    s[i]=l*h;
  }
  mi=min(mi,max({s[0],s[1],s[2]})-min({s[0],s[1],s[2]}));

  out(mi);

  return 0;
}


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

int main()
{
int D;
cin >> D;
if(D==25) cout  << "Christmas" <<endl;
else if(D==24) cout << "Christmas Eve" << endl;
else if(D==23) cout << "Christmas Eve Eve" << endl;
else if(D==22) cout << "Christmas Eve Eve Eve" << endl;

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();
	for(int i = 0; i < n; ++i){
	    BigInteger bi1 = new BigInteger(sc.next());
	    BigInteger bi2 = new BigInteger(sc.next());

	    String result = (bi1.add(bi2)).toString();

	    if(result.length() > 80){
		result = "overflow";
	    }

	    System.out.println(result);
	}
    }
}

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

int main() {
  vector<char> vec(3);
  int ans = 0;
  for (int i=0; i<3; i++){
    cin >> vec.at(i);
  }
  char T;
  for (int i=0; i<3; i++){
    cin >> T;
    if (T == vec.at(i)){
      ans++;
    }
    else continue;
  }
  cout << ans << endl;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

ll a[maxn];
int n;
ll k;

bool ok(ll mid){
  ll cnt = 0;
  for (int i = 1; i < n; ++i){
    if (a[i] == 0){
      if (mid >= 0) cnt += n - i;
      continue;
    }
    ll d = mid / a[i];
    if (a[i] > 0){
      if (abs(mid) % a[i] != 0){
        if ( (d == 0 && mid < 0) || d < 0) --d;
      }
      int pos = upper_bound(a + i + 1, a + n + 1, d) - a;
      --pos;
      cnt += pos - i;
    } else {
      if (abs(mid) % abs(a[i]) != 0){
        if ((d == 0 && mid < 0) || d > 0) d++;
      }
      int pos = lower_bound(a + i + 1, a + n + 1, d) - a;
      cnt += n - pos + 1;
    }
  }
  return cnt >= k;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  ll inf = 1e18;
  ll l = -inf, r = inf;
  while (l <= r){
    ll mid = (l + r) / 2;
    if (ok(mid)) r = mid - 1;
    else l = mid + 1;
  }
  cout << r + 1;
return 0;
}




Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a;cin>>a;
    double b;cin>>b;
    ll bb=b*100+0.5;
    cout<<(a*bb)/100<<endl;
    
    return 0;
}





Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] A = new int[N];
		for ( int n = 0 ; n < N ; n++ ) {
			A[n] = sc.nextInt();
		}

		int first = 0;
		int second = 0;
		for ( int i = 0 ; i < N ; i++ ) {
			if ( first <= A[i] ) {
				second = first;
				first = A[i];
			} else if ( second <= A[i]) {
				second = A[i];
			}
		}

		StringBuffer ans = new StringBuffer();
		for ( int i = 0 ; i < N ; i++ ) {
			if ( A[i] == first ) {
				ans.append(second);
			} else {
				ans.append(first);
			}
			ans.append("\n");
		}
		System.out.println(ans.toString());
	}
}


Measured memory_bytes: 67784
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            if (sc.nextInt() % 2 == 1) {
                System.out.println("first");
                return;
            }
        }
        System.out.println("second");
    }
}

Measured memory_bytes: 48564
from collections import deque

S = deque(list(input()))
Q = int(input())
reverse = True
for i in range(Q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:
        right = query[1] == '1'
        if right == reverse:
            S.appendleft(query[2])
        else:
            S.append(query[2])
if not reverse:
    print(''.join(list(reversed(S))))
else:
    print(''.join(list(S)))


Measured memory_bytes: 72552
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    vi cnt(n,0);
    vii g(n,vi());
    FOR(i,0,n-1){
        g[i].PB(i+1);
        g[i+1].PB(i);
    }
    g[x].PB(y);
    g[y].PB(x);
    cerr<<"test"<<endl;
    FOR(st,0,n){
        vi d(n,mod);
        d[st]=0;
        queue<int> q;
        q.push(st);
        while (q.size())
        {
            int nw=q.front();
            q.pop();
            for(const auto nx:g[nw]){
                if(d[nx]==mod){
                    d[nx]=d[nw]+1;
                    q.push(nx);
                }
            }
        }
        FOR(i,0,n){
            cnt[d[i]]++;
        }
    }
    FOR(i,1,n){
        cout<<cnt[i]/2<<endl;
    }

}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict

class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)
    
    def groups(self):
        if isinstance(self.parent,list):
            return list(map(lambda x: x<0, self.parent)).count(True)
        else: # self.parent: defaultdict
            return list(map(lambda x: x<0, self.parent.values())).count(True) 

N = int(input())
uf = UnionFind()
for _ in range(N):
    x, y = inpl()
    uf.merge(2*x,2*y+1)

nxny = defaultdict(lambda: [0, 0])
for k in uf.parent.keys():
    nxny[uf.root(k)][k % 2] += 1

ans = sum([ nx * ny for nx, ny in nxny.values() ]) - N
print(ans)

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,W;
    Scd2(N,W);
    int w,v;
    ll ans = 1;
    ll dp[100002] = {};
    dp[0] = 1;
    Rep(i,N){
        Scd2(w,v);
        for( int wi = W; wi >= w ; wi--){
            if( dp[wi-w] ){
                dp[wi] = max( dp[wi] , dp[wi-w] + v );
            }
        }
    }

    Rep(wi,W+1){
        ans = max( dp[wi] , ans );
    }
    printf ("%llu\n", ans-1);


    return 0;
}



Measured memory_bytes: 1024
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

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

fn main() {
    input! {
        l: f64
    }

    let t = l / 3.;
    println!("{}", t.powf(3.));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long x,y;
    cin >> x >> y;
    if ((y % 2 == 0 ) && (2 * x <= y) && (y <= 4*x))
      cout << "Yes" << endl;
	else
      cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=(1<<18)+100,
          L=1e5+100,
          S=sqrt(N)+100;

int n,s;
int v[N],w[N];
int dp[S][L];

int solve(int i,int j)
{
    if(i<=s)
        return dp[i][j];
    return max(solve(i/2,j),
               j>=w[i]?solve(i/2,j-w[i])+v[i]:0);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i]>>w[i];

    s=sqrt(n);
    for(int i=1;i<=s;i++)
        for(int j=1;j<L;j++)
            dp[i][j]=max({dp[i][j-1],
                          dp[i/2][j],
                          j>=w[i]?dp[i/2][j-w[i]]+v[i]:0});

    int q;
    cin>>q;
    while(q--)
    {
        int i,j;
        cin>>i>>j;
        cout<<solve(i,j)<<"\n";
    }
}


Measured memory_bytes: 407332
#include <iostream>
#include <map>
#include <cstdio>

const int MAXN = (int)2e5 + 1;
const int64_t INF = (int64_t)1e17;
int a[MAXN];
std::map<int, int64_t> f[MAXN];

int get_min(int i, int n) {
  if (n % 2 == 1) return (i - 1) / 2;
  return i / 2;
}

int get_max(int i) {
  return (i + 1) / 2;
}

int64_t solve(int n) {
  for (int i = 1; i <= n; ++i) {
    int min = get_min(i, n);
    int max = get_max(i);
    for (int j = min; j <= max; ++j) {
      f[i][j] = -INF;
    }
  }
  f[1][0] = 0;
  f[1][1] = a[1];
  f[2][0] = 0;
  f[2][1] = std::max(a[1], a[2]);
  for (int i = 3; i <= n; ++i) {
    int i_min = get_min(i, n);
    int i_max = get_max(i);
    for (int j = i_min; j <= i_max; ++j) {
      if (get_min(i - 1, n) <= j && j <= get_max(i - 1)) 
        f[i][j] = f[i - 1][j];
      if (i > 2 && get_min(i - 2, n) <= j - 1 && j - 1 <= get_max(i - 2)) {
        int64_t cur = f[i - 2][j - 1] + a[i];
        if (cur > f[i][j]) f[i][j] = cur;
      }
      // printf("i = %d j = %d f = %lld\n", i, j, (long long)f[i][j]);
    }
  }
  return f[n][n / 2];
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 38788
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	
	int x;
	int min = 9999999;
	int max = -9999999;
	long sum = 0;
	for (int i = 0; i < n; i++) {
		std::cin >> x;
		if (x < min) min = x;
		if (x > max) max = x;
		sum += x;
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int x,y; cin>>x>>y;
    for(int i=0;i<=x;i++){
        if(2*i+4*(x-i)==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}



Measured memory_bytes: 3616
n = int(input())

ac = [[0 for i in range(1,10)] for j in range(1, 10)]

for i in range(n+1):
    s = str(i)[0]
    e = str(i)[-1]
    if s == "0" or e == "0":
        continue
    ac[int(s) - 1][int(e) - 1] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += ac[i-1][j-1] * ac[j-1][i-1]
    
print(ans)

Measured memory_bytes: 41964
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;


int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    string T;
    cin>>T;
    
    int ans = -1;
    for(int l=0;l<=N;l++) {
        bool ok = true;
        for(int j=0;j<l;j++) {
            if (T[j]!=S[j+N-l])
                ok=false;
        }
        if (ok) {
            ans = l;
        }
    }
    
    cout << S.size() + N-ans << endl;
    
    
}

Measured memory_bytes: 256
<?php
  # 文字列の入力
fscanf(STDIN, "%s", $s);
$z = 0;
if(substr($s,0,1)==1){
  $z = $z+1;}
if(substr($s,1,1)==1){
  $z = $z+1;}
if(substr($s,2,1)==1){
  $z = $z+1;}
echo $z;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
  int n;
  cin >> n;
  vector<vector<P>> g(n);
  rep(i,n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].emplace_back(make_pair(b, c));
    g[b].emplace_back(make_pair(a, c));
  }

  vector<int> dp(n, 0);
  
  auto dfs1 = [&](auto&& f, int p = -1, int u = 0)->void{
    for (auto v : g[u]) {
      if (v.first == p) continue;
      f(f, u, v.first);
      dp[u] = max(dp[v.first] + v.second, dp[u]);
    }
  };
  int res = 0;
  auto dfs2 = [&](auto&& f, int pdp, int p = -1, int u = 0)->void{
    int deg = g[u].size();
    for (int i = 0; i < deg; i++) if (g[u][i].first == p) dp[g[u][i].first] = pdp;

    vector<int> left(deg+1, 0);
    for (int i = 0; i < deg; i++) left[i + 1] = max(left[i], dp[g[u][i].first] + g[u][i].second);
    vector<int> right(deg+1, 0);
    for (int i = deg - 1; i >= 0; i--) right[i] = max(right[i + 1], dp[g[u][i].first] + g[u][i].second);
    res = max(res, left[deg]);
    for (int i = 0; i < deg; i++) {
      int v = g[u][i].first;
      if (v == p) continue;
      int d = max(left[i], right[i + 1]);
      f(f, d, u, v);
    }
  };

  dfs1(dfs1);
  dfs2(dfs2, dp[0]);
  cout << res << endl;
  return 0; 
} 


Measured memory_bytes: 22516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef long double ld;
/* abc 072 - c */
int  main()
{
	int n; cin >> n;
	vector <int> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	int cnt = 0;
	int at = 0;
	rep(i, n)
	{
		if ((a[i] - a[at]) <= 2)
			cnt = i - at + 1;
		else
		{
			ans = max(cnt, ans);
			cnt = 1;
			while (a[i]-a[at] > 2)
				at++;
		}
	}
	ans = max(cnt, ans);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main () {
  while (1) {
    int x,y;
    char op;
    scanf ("%d %c %d",&x,&op,&y);
    if (op == '?') break;
    if (op == '+') {
      printf ("%d\n",x+y);
    }else if (op == '-') {
      printf ("%d\n",x-y);
    }else if (op == '*') {
      printf ("%d\n",x*y);
    }else if (op = '/') {
      printf ("%d\n",x/y);
    }
  }
 return 0;
}

Measured memory_bytes: 600
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if a+b+c+d==7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
elif a+b+c-d==7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
elif a+b-c+d==7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
elif a-b+c+d==7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
elif a+b-c-d==7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
elif a-b-c+d==7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
elif a-b+c-d==7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
elif a-b-c-d==7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b) printf("%d\n", c);
	else if (b == c) printf("%d\n", a);
	else printf("%d\n", b);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;
ll gcd(ll a, ll b){
    if(a * b == 0) return a + b;
    return gcd(b, a % b);
}
void solve(){
    ll a, b;
    cin >> a >> b;
    cout << (a * b) / gcd(a, b);
}

 
int main(){
    barsik;
    int q = 1;
//    freopen("file.txt", "w", stdout);
    //cin >> q;
 
    for(double i = 1; i <= q; i++){
        //cout << "Case " << i << ": ";
        solve();
    }
}


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

using namespace std;

int main()
{
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (op != '?')
	{
		int c;
		if (op == '+') c = a + b;
		if (op == '-') c = a - b;
		if (op == '*') c = a * b;
		if (op == '/') c = a / b;
		cout << c << endl;
		cin >> a >> op >> b;
	}
}



Measured memory_bytes: 3088
#include <stdio.h>
int main(){
	int score_a,score_b;
	int i,n;
	int a,b;
	scanf("%d",&n);
	while(n != 0){
		score_a=0;
		score_b=0;
		for(i=1;i<=n;i++){
			scanf("%d %d",&a,&b);
			if(a==b){
				score_a+=a;
				score_b+=a;
			}
			else{
				if(a>b){
					score_a+=a+b;
				}
				else{
					score_b+=a+b;
				}
			}
		}
		printf("%d %d\n",score_a,score_b);
		scanf("%d",&n);
	}
	return NULL;
}

Measured memory_bytes: 600
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;

const int M = 100000 + 5;

void mymain(){
    int n,w;
    cin >> n >> w;
    vector<pair<int,int>> arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i].F >> arr[i].S;
    }
    vector<vector<int>> dp(n,vector<int>(w+1,0));
    for(int i=1 ; i<=w ; i++){
        if(arr[0].F <= i)
            dp[0][i] = arr[0].S;
    }
    for(int i=1 ; i<n ; i++ ){
        for(int j = 1; j<=w ; j++ ){
            dp[i][j] = dp[i-1][j];
            if(j - arr[i].F >= 0 ){
                dp[i][j] = max(dp[i][j], dp[i-1][j - arr[i].F] + arr[i].S);
            }
        }
    }

    cout << dp[n-1][w] <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


Measured memory_bytes: 79488
import collections
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
c=collections.Counter(a)
d=list(c.keys())
d.sort()
d=d[::-1]
z=0
ans=1
for i in d:
    if c[i]>=4:
        if z==0:
            print(i**2)
            break
        elif z==2:
            ans*=i
            print(ans)
            break
    elif 2<=c[i]<=3:
        if z==0:
            z+=2
            ans*=i
            continue
        elif z==2:
            ans*=i
            print(ans)
            break
else:
    print(0)

Measured memory_bytes: 71064
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] h = new long[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextLong();
    }
    sc.close();

    long[] dp = new long[N];
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    for (int i = 0; i < N; i++)
      for (int k = i + 1; k < N && k <= i + 2; k++)
        dp[k] = Math.min(dp[k],
            dp[i] + Math.abs(h[k] - h[i]));
    long ans = dp[N - 1];
    System.out.println(ans);
  }
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		int t;
		cin>>t;
		int s=t,mi=t,ma=t;
		for (int i = 1; i < n; ++i)
		{
			cin>>t;
			s+=t;
			mi=min(mi,t);
			ma=max(ma,t);
		}
		cout<<(s-ma-mi)/(n-2)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int n,m,sum;
int t[1000000];
struct pin
{
	int xv,sh;
}p[1000000];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t[i]);
		sum=sum+t[i];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&p[i].xv,&p[i].sh);
		printf("%d\n",sum+(p[i].sh-t[p[i].xv]));
	}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x;
		cin >> x;
		n -= x;
	}
	cout << max(-1, n) << "\n";
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int o_o = 1;
  if (!o_o)
    cin >> o_o;
  for (; o_o; --o_o)
    solve();
  return 0;
}

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n) cout << s[i] << t[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll jc[maxn], bjc[maxn];
int n, a[maxn], b[maxn];
ll lw[405][405], nw[405][405];
int main() {
	jc[0] = bjc[0] = 1;
	for (int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod, 
		bjc[i] = ksm(jc[i], mod - 2);
	lw[0][0] = 1;
	int la = 0, lb = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		int na = la + a, nb = lb + b - 1;
		for (int j = 0; j <= na; j++)
			for (int k = 0; k <= nb; k++)	
				nw[j][k] = 0;
		for (int j = 0; j <= la; j++)
			for (int k = 0; k <= lb; k++) {
				nw[j + a][k] += lw[j][k];
				nw[j + a][k] %= mod;
				ll pw = 1;
				for (int s = 0; s <= b - 1; s++)
					nw[j][k + s] = (nw[j][k + s] + lw[j][k] * -bjc[s] % mod * pw) % mod, 
					pw = pw * a % mod;
			}
		la = na, lb = nb;
		for (int j = 0; j <= la; j++)
			for (int k = 0; k <= lb; k++)
				lw[j][k] = nw[j][k], 
				lw[j][k] %= mod;
	}
//	cout << la << ' ' << lb << endl;
	ll tans = 0;
	ll s = la;
//	cout << s << endl;
	for (int j = 0; j <= la; j++)
		for (int k = 0; k <= lb; k++) {
			if (j == la && k == 0) continue;
			ll np = s * jc[k] % mod;
			np = np * lw[j][k] % mod;
			np = np * ksm(ksm(s - j, k + 1), mod - 2) % mod;
		//	if (lw[j][k]) cout << j << ' ' << k << ' ' << lw[j][k] << ' ' << np << endl;
			tans -= np;
			tans %= mod;
		}
	if (tans < 0) tans += mod;
	cout << tans << endl;
	return 0;
}


Measured memory_bytes: 5120
N = int( input() )
As = list( map( int, input().split() ) )

rate = []
anycol = 0
for i in As : 
  if i >= 3200 : 
    anycol += 1 
  else : 
     rate.append( i // 400 )
 
count = len( set(rate) )
 
print( max(count, 1), count+anycol )

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<VV> VVV;



int main() {
	ll sum=0,a,n, count1 = 0, min = 1000000005;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a < 0)count1++;
		if (abs(a) < min)min = abs(a);
		sum += abs(a);
	}
	if (count1 % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * min << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string a;
	int x=0,y=0,i;
	cin>>a;
	for(i=0;i<a.length() ;i++){
		x+=a[i]-48;
		y+=a[i]-48;
		if(i!=a.length()-1){
			y*=10;
		}
	}
	if(y%x==0){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

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

using namespace std;

int Judge(int n, vector<int> &d) {
	do {
		if (d[n % 10])
			return false;
		n /= 10;
	}while (n > 0);
	return true;
}

int main(void) {
	int ans, k, i, a;
	vector<int> d(10, false);
	cin >> ans >> k;
	for (i = 0; i < k; i++) {
		scanf("%d", &a);
		d[a] = true;
	}
	while (!Judge(ans, d)) {
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long[] cs = new long[n - 1];
        long[] ss = new long[n - 1];
        long[] fs = new long[n - 1];

        for (int i = 0; i < n - 1; i++)
        {
            cs[i] = sc.NextLong();
            ss[i] = sc.NextLong();
            fs[i] = sc.NextLong();
        }

        long[,] times = new long[n, n]; // i番目の駅にjが到着している時刻

        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < i; j++)
            {
                var before = times[i - 1, j];
                var start = ss[i - 1];
                var span = fs[i - 1];
                long wait;
                if (before > start)
                {
                    long mod = (before - start) % span;
                    if (mod == 0)
                    {
                        wait = 0;
                    }
                    else
                    {
                        wait = span - mod;
                    }
                }
                else
                {
                    wait = start - before;
                }
                var cost = cs[i - 1];
                times[i, j] = before + wait + cost;
            }
        }

        for (int i = 0; i < n; i++)
        {
            var answer = times[n - 1, i];
            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 29576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,L;
    cin >> N >> L;
    vec<string> S(N);
    for(int i=0;i<N;i++) cin >> S[i];
    sort(S.begin(),S.end());
    for(auto& s:S) cout << s;
    cout << "\n";
}

Measured memory_bytes: 256
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A = rl()

if sum(A) >= 22:
	print('bust')
else:
	print('win')


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  long long T = 1, A = 1;
  while (N--)
  {
    long long t, a;
    cin >> t >> a;
    long long n = max((T + t - 1) / t, (A + a - 1) / a);
    T = t * n;
    A = a * n;
  }
  cout << T + A << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]
    
    is_all_seen = [False]*n
    cnt = 0
    seen = [None]*n
    rks = [None] *n
    sys.setrecursionlimit(10**9)
    def dfs(graph,s,r):
        seen[s] = s+1
        if rks[s] is None:
            rks[s] = r

        for i in range(len(graph[s])):
            if seen[graph[s][i]-1]:
                continue
            dfs(graph, graph[s][i]-1,r)

    for i in range(m):
        a,b = map(int, input().split())

        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    # print(fgraph)
    #print(bgraph)
    # 連結成分に対してid的なindexをつける
    c = -1
    for i in range(n):

        if rks[i] is None:
            c += 1
            dfs(fgraph, i, c)
    
    for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)

    counter = Counter(rks)
    for i in range(n):
        # counter[rks[i]] 連結成分のサイズ
        # len(fgraph[i]) 友達の数
        # len(bgraph[i]) 連結成分内のブロックの数
        # 1 自分
        print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 381772
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
//---------------------------

//ll a[MX];
ll a[MX];
vector <ll> acum;

int main(){
    fastio;
    ll n;
    cin>>n;
    f(i,1,n+1) cin>>a[i];
	acum.pb(0);
    for(int i = 1 ; i <= n; i++){
    	ll aux  = acum[i-1] + a[i];
    	acum.pb(aux);
    }
    //f(i,1,n+1) trace(acum[i]);
    ll ans = inf;
	for(int i = 1; i <= n; i++){
		//vector <ll> pos;
		ll id1 = upper_bound(acum.begin(),acum.begin()+i,acum[i]/2)- acum.begin();
		ll id2 = upper_bound(acum.begin()+i+1,acum.end(),(acum[n]+acum[i])/2)- acum.begin();
		for(int k = -1; k<=1;k++){
			for(int k1 = -1;k1<= 1;k1++){
				ll id11 = id1 +k;
				ll id22 = id2 +k1;
				if(1<=id11 && id11<i && i<id22 && id22<n){
					vector <ll> pos;
					pos.pb(acum[id11]);
					pos.pb(acum[i] - acum[id11]);
					pos.pb(acum[id22]-acum[i]);
					pos.pb(acum[n]-acum[id22]);
					sor(pos);
					ans = min(ans,pos.back()-pos.front());
					pos.clear();
				}
			}
		}
		
		//trace(ans);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6864
X,N = map(int,input().split())
p = list(map(int,input().split()))
p2 = []

for i in range(0,102):
    if not i in p:
        p2.append(i)

p3 = p2[::-1]
Ans = X
sa = 1000
for j in range(len(p3)):
    if abs(p3[j]-X) <= sa:
        sa = abs(p3[j]-X)
        Ans = p3[j]

print(Ans)

Measured memory_bytes: 9228
// 16:26
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[6];
    REP(i,6){
        cin >> a[i];
    }
    cout << ((a[4]-a[0]<=a[5])?"Yay!":":(") << endl;
}

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

//00:15

string sed(string c,string a,string b){
	vector<int> m(c.size());
	for(int i = 0 ; i < c.size() ; i++){
		if( c.substr(i,a.size()) == a ){
			m[i] = true;
		}
	}
	string w;
	for(int i = 0 ; i < c.size() ; ){
		if( m[i] ){
			w += b;
			i += a.size();
		}else w += c[i],i++;
	}
	return w;
}


int main(){
	int n;
	while(cin >> n && n){
		vector<string> ra(n),rb(n);
		for(int i = 0 ; i < n ; i++) cin >> ra[i] >> rb[i];
		string alpha,beta;
		cin >> alpha >> beta;
		map<string,int> memo;
		memo[alpha] = 0;
		queue<string> Q;
		Q.push(alpha);
		int ans = -1;
		while( Q.size() ){
			string q = Q.front(); Q.pop();
			if( q.size() > beta.size() ) continue;
			if( q == beta ){	
				ans = memo[q];
				break;
			}
			for(int i = 0 ; i < n ; i++){
				string x = sed(q,ra[i],rb[i]);
				if( !memo.count(x) ){
					memo[x] = memo[q] + 1;
					Q.push(x);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1904
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  vector<pair<string,pair<ll,ll>>>psl(a);
  for(int i=0;i<a;i++){
    cin>>s;cin>>b;
    psl[i]=mp(s,mp(-b,i));
  }
  sort(ALL(psl));
  for(int i=0;i<a;i++)
    cout<<psl[i].S.S+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 109
using namespace std;
typedef long long ll;
map<int,int>mr,mg,mb;
int main(void)
{
    //freopen("in.txt","r",stdin);

    ll n;
    string s;
    cin>>n>>s;
    vector<ll>r,g,b;
    for(int i=0;i<n;i++)
    {
        if(s[i] == 'R') r.push_back(i),mr[i]=1;
        if(s[i] == 'G') g.push_back(i),mg[i]=1;
        if(s[i] == 'B') b.push_back(i),mb[i]=1;
    }

    ll ans=r.size()*g.size()*b.size();
ll cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int v=1; ;v++)
        {
            int v1=i+v;
            int v2=i+2*v;
            if(v1<n && v2<n)
            {
                if(s[i]!=s[v1] && s[v1]!=s[v2] && s[i]!=s[v2])
                    cnt++;
            }
            else break;
        }
    }
cout<<ans-cnt<<endl;
    return 0;
}


Measured memory_bytes: 3748