akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
vector< vector<int> > G(100002);
int n_v, n_e;
int prenum[100001], parent[100001], lowest[100001], n_child[100001];
bool is_cut[100001];


void dfs(int u, int f, int t_stamp){
    prenum[u] = t_stamp;
    parent[u] = f;
    lowest[u] = t_stamp;
    int v;
    for(int i=0; i<G[u].size(); i++){
        v = G[u][i];
        if(prenum[v]!=0){
            //this edge is a backedge
            lowest[u] = min(lowest[u], prenum[v]);
        }else{
            n_child[u] += 1;
            dfs(v, u, t_stamp+1);
            lowest[u] = min(lowest[u], lowest[v]);
        }
    }
    return;
}


int main(){
    
    scanf("%d %d", &n_v, &n_e);
    int u, v;
    for(int i=0; i<n_e; i++){
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(prenum, 0, sizeof(prenum));
    memset(parent, 255, sizeof(parent));
    memset(n_child, 0, sizeof(n_child));

    for(int i=0; i<n_v; i++){
        if(parent[i]==-1){
            dfs(i, -1, 1);
        }
    }

    memset(is_cut, 0, sizeof(is_cut));
    for(int i=0; i<n_v; i++){
        if(parent[i]==-1 && n_child[i]>=2)
            is_cut[i] = true;
        else if(prenum[parent[i]] <= lowest[i]){
            if(parent[parent[i]] == -1 && n_child[parent[i]]>=2){
                //the parent is a root
                is_cut[parent[i]] = true;
            }else if(parent[parent[i]] != -1){
                //the parent is not a root
                is_cut[parent[i]] = true;
            }
        }
    }
    
    for(int i=0; i<n_v; i++)
        if(is_cut[i])
            printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 7392
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll N;
ll x[110], y[110], h[110];
ll xt, yt, ht;

int main() {
	cin >> N;
	REP(i, N) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) {
			xt = x[i];
			yt = y[i];
			ht = h[i];
		}
	}
	REP(i, 101) {
		REP(j, 101) {
			//i = x座標,j = y座標が頂点のとき
			ll hij = ht + abs(i - xt) + abs(j - yt);
			REP(k, N) {
				if (max(hij - abs(x[k] - i) - abs(y[k] - j), (ll)0) != h[k]) break;
				if (k == N - 1) {
					cout << i << " " << j << " " << hij << endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	d := nextInt()
	t := nextInt()
	s := nextInt()

	ans := "No"
	if d <= t*s {
		ans = "Yes"
	}
	_, _ = fmt.Fprintf(writer, "%s", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1772
#include <stdio.h>

int main(void)
{
	int a,b,c,d,n;
	int count;
	
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		for(a=0;a<10;a++)
		{
			for(b=0;b<10;b++)
			{
				for(c=0;c<10;c++)
				{
					for(d=0;d<10;d++)
					{
						if(a+b+c+d==n)
						{
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	
	
	return 0;
}

Measured memory_bytes: 596
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) (63-__builtin_clzll((bm)))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,A[MAXN];
map<ll,ll>mp;
vector<ll>d;
vector<ll>pos[MAXN],o[MAXN];
bool can(vector<ll>v) {
	while(v.size()!=n){
		ll a=v[v.size()-2],b=v[v.size()-1];
		auto p=lbd(d,(a^b)); if(p==d.end() || (*p != (a^b))){ return 0; }
		if(pos[p-d.begin()].empty()) { return 0; }
		pos[p-d.begin()].pop_back();
		v.pb(a^b);
	}
	for(ll i=1;i<v.size();++i){
		if(v[i-1]^v[i]^v[(i+1)%siz(v)]) {return 0; }
	}
	return 1;
}
int main()
{	
	FAST
	cin>>n;
	FOR(i,0,n)cin>>A[i]; FOR(i,1,n) mp[A[i]]=i;
	ll a=A[0],b=-1,c=-1; ll co1=0,co2=0;
	FOR(i,1,n){
		if(mp[A[0]^A[i]]&&mp[A[0]^A[i]]!=i) {
			b=A[i];
			c=A[0]^A[i];
			co1=i;
			co2=mp[A[0]^A[i]];
			break;
		}
	}
	if(b==-1) { cout<<"No\n"; return 0; }
	FOR(i,0,n) d.pb(A[i]);
	sort(all(d)); d.resize(unique(all(d))-d.begin());
	FOR(i,1,n) if(i!=co1&&i!=co2) pos[lbd(d,A[i])-d.begin()].pb(i);
	vector<ll>v;
	v.pb(a),v.pb(b),v.pb(c);
	if(n==3) { cout<<"Yes\n"; return 0; }
	FOR(i,0,MAXN)o[i]=pos[i];
	sort(all(v));
	bool ans=0;
	do {
		ans|=can(v);
		FOR(i,0,MAXN)pos[i]=o[i];	
	}while(next_permutation(all(v))); 
	cout<<(ans?"Yes\n":"No\n");
}


Measured memory_bytes: 29044
#include<bits/stdc++.h>
using namespace std;
int main(){
  		int k; cin>>k;
  		string s; cin>>s;
  		if(s.size() <= k){
        	cout<<s;
        }
  		else{
          for(int i=0; i<k; ++i){
          	cout<<s[i];
          }
        	cout<<"...";
        }
	}


Measured memory_bytes: 3572
N=int(input())
A=list(map(int,input().split()))
b=0
c=0

for j in range(0,len(A)):
    c+=A[j]

for i in range(0,len(A)):
        c=c-A[i]
        b+=A[i]*c
        
print(b%(10**9+7))

Measured memory_bytes: 31412
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  string S;
  cin >> S;
  vi arr;
  int temp = 0;
  rep(i,S.length()){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      temp++;
    } else {
      arr.push_back(temp);
      temp = 0;
    }
  }
  arr.push_back(temp);
  int ans = 0;
  rep(i,sz(arr)) {
    ans = max(ans,arr[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {

	int n;
	cin >> n;
	int sol = 1e9;
	for (int i = 1; i < n; i ++) {
		int x = i;
		int zbr = 0;
		while (x > 0) {
			zbr += x % 10;
			x /= 10;
		}
		
		x = n-i;
		while (x > 0) {
			zbr += x % 10;
			x /= 10;
		}
		
		sol = min(sol, zbr);
	}
	cout <<sol;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> d(n);
    REP(i, n) cin >> d[i];
    sort(ALL(d));
    ll mid = n / 2;
    cout << d[mid] - d[mid-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
from _collections import deque
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
ab=[[0,0]  for i in range(m)]
for i in range(m):
    ab[i][0],ab[i][1]=map(int,input().split())
ans=0
for i in range(m):
    edg=[[] for j in range(n+1)]
    for j in range(m):
        if j!=i:
            a,b=ab[j][0],ab[j][1]
            edg[a].append(b)
            edg[b].append(a)
    che=[0]*(n+1)
    che[0]=1
    def search(x):
        che[x]=1
        for j in edg[x]:
            if che[j]==0:
                search(j)
    search(1)
    if not all(che[j]==1 for j in range(n+1)):
        ans+=1
print(ans)



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

int main()
{
	int a[3],ans=0;
	for(int i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	int x=a[0],y=a[1],z=a[2];
	x+=z-y;
	ans+=z-y;
	y=z;
	int k=y-x;
	
	if(k%2==0)
	cout<<ans+k/2;
	else
	cout<<ans+k/2+2;
}

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

int H, W, K, A[309][309], num;
int cnt[309];
char c[309][309];

void solve(int cl, int cr) {
    vector<int> P;
    for (int i = cl; i <= cr; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (c[i][j] == '#') {
                P.push_back(j);
            }
        }
    }
    sort(P.begin(), P.end());
    for (int i = 0; i < P.size(); ++i) {
        int v1 = 1, v2 = W;
        if (i >= 1) v1 = P[i - 1] + 1;
        if (i < (int)P.size() - 1) v2 = P[i];
        num++;
        for (int j = cl; j <= cr; ++j) {
            for (int k = v1; k <= v2; ++k) {
                A[j][k] = num;
            }
        }
    }
}

int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin >> c[i][j];
            if (c[i][j] == '#') cnt[i]++;
        }
    }
    vector<int> vec;
    for (int i = 1; i <= H; ++i) {
        if (cnt[i] >= 1) {
            vec.push_back(i);
        }
    }

    for (int i = 0; i < vec.size(); ++i) {
        int v1 = 1, v2 = H;
        if (i >= 1) v1 = vec[i - 1] + 1;
        if (i < (int)vec.size() - 1) v2 = vec[i];
        solve(v1, v2);
    }
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (j >= 2) {
                cout << " ";
            }
            cout << A[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
// abc152-A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>

int main()
{
    using namespace std;

    int a, b;
    string s_a = "", s_b = "";
    cin >> a >> b;

    for (int i = 0; i < b; i++) {
        s_a += to_string(a);
    }
    for (int j = 0; j < a; j++) {
        s_b += to_string(b);
    }
    if (stoi(s_a) > stoi(s_b)) {
        cout << s_a;
    }
    else {
        cout << s_b;
    }


}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//ACソースコピペ 
int main() {
  int n;
  cin >> n;
  int kotae = 0;
  for (int i = 1; i <= 9; i++) {
	for (int j = 1; j <= 9; j++) {
	  for (int k = 1; k <= 9; k++) {
		if (i + j + k > 9) continue;
        string s = string(i, '3') + string(j, '5') + string(k, '7');
		do {
		  if (atoi(s.c_str()) <= n) kotae++;
		} while (next_permutation(s.begin(), s.end()));
	  }
	}
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

int main() {

    get(n);
    gets(s);

    s.insert(0,1,'<');

    vector<vector<ll>> dp(n+1, vector<ll>(n+1,0));
    dp[n][0]=1;

    repr(i,n-1) {
        ll nums = n-i;
        rep(j,nums+1) {
            if(s[i]=='<')
                dp[i][j] = ((dp[i][j] + (j-1>=0 ? dp[i+1][j-1] : 0))%N+N)%N;
            else
                dp[i][j] = ((dp[i][j] + (nums-1>=0 ? dp[i+1][nums-1] : 0) - (j-1>=0 ? dp[i+1][j-1] : 0))%N+N)%N;
        }

        rep2(j,1,n+1) {
            dp[i][j] = (dp[i][j] + dp[i][j-1])%N;
        }
    }

    printf("%lld\n", (N+dp[0][n]-dp[0][n-1])%N);

    return 0;  
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s;
    if(s[0] == 'S')t = "Cloudy";
    else if(s[0] == 'C')t = "Rainy";
    else t = "Sunny";
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int x = 0; x <= n/r; x++) {
        for (int y = 0; y <= (n-x*r)/g; y++) {
            int rem = n - x*r - y*g;
            if (rem == 0) ans++;
            else if (rem % b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[55][55][111];
ll c[55][55];
int n;
int main(){
	rep(i,55)rep(j,i+1){
		if(j==0||j==i)c[i][j]=1;
		else c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	cin>>n;
	dp[0][1][55+0] = dp[0][1][55-1] = n;
	for(int i=0;i<54;i++){
		for(int a=0;a<54;a++){
			for(int j=0;j<=110;j++){
				if(dp[i][a][j] == 0) continue;
				//1...,2^i -> 2^(i+1) * (j-55) + 1
				for(int k=0;k<=54-a;k++){
					for(int l=0;l<=54-a-k;l++){
						//2^(i+1) wo k ko
						//-2^(i+1) wo l ko
						if(k+l == 0) continue;
						if(a+k+l > n) continue;
						if(j-55-k-l <= 0 && 0 <= j-55+k+l){
							//1....2^(i+1) -> 2^(i+2) * ? + 1
							int x = j-55+k-l;
							if(x%2 == 0){
								dp[i+1][a+k+l][x/2+55] += dp[i][a][j]*c[n-a][k]%mod*c[n-a-k][l]%mod;
							}
						}
					}
				}
			}
		}
		for(int a=0;a<55;a++) for(int b=0;b<111;b++) dp[i+1][a][b] %= mod;
	}
	ll ans = 0;
	for(int i=0;i<55;i++) ans = (ans+dp[i][n][55])%mod;
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

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

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations
from random import random

import numpy as np

sys.setrecursionlimit(200000)


class Solver:
    def __init__(self):
        pass

    def input(self):
        """
            faster input function than builtin stdin.
        """
        return sys.stdin.readline()[:-1]

    def ii(self, t: type = int):
        """
            input single value.
        """
        return t(self.input())

    def il(self, t: type = int):
        """
            input single line.
        """
        return list(map(t, self.input().split()))

    def imi(self, N: int, t: type = int):
        return [self.ii(t) for _ in range(N)]

    def iml(self, N: int, t: type = int):
        return [self.il(t) for _ in range(N)]

    def solve(self):
        N = self.ii()
        d = self.il()
        ans = 0
        for x, y in combinations(d, 2):
            ans += x * y
        return ans


if __name__ == "__main__":
    solver = Solver()
    print(solver.solve())


Measured memory_bytes: 24680
#include <iostream>
#include <vector>
#include <iomanip>
#include <stdio.h>
using namespace std;

double prob(int n,int pos,int t,int d)
{
	double map[9]={0};
	map[pos] = 1;
	for(int i=0; i<n; i++)
	{
		double nmap[9]={0};
		for (int j=0; j<9; j++)
		{
			if ((j-3<0)||(j-3==d)){
				nmap[j]+=map[j]/4.0;
			} else {
				nmap[j-3]+=map[j]/4.0;
			}
			if ((j%3 == 0)||(j-1==d)){
				nmap[j]+=map[j]/4.0;
			} else {
				nmap[j-1]+=map[j]/4.0;
			}
			if ((j%3 == 2)||(j+1==d)){
				nmap[j]+=map[j]/4.0;
			} else {
				nmap[j+1]+=map[j]/4.0;
			}
			if ((j+3>8)||(j+3==d)){
				nmap[j]+=map[j]/4.0;
			} else {
				nmap[j+3]+=map[j]/4.0;
			}
		}
		for (int j=0; j<9; j++)
		{
			map[j]=nmap[j];
		}
	}
	return map[t];
}

int main() {
	vector<double> r;
	while(true)
	{
		int n;
		cin >> n;
		if (n==0){break;}
		char a[2],b[2],c[2];
		int s=0,t=0,d=0;
		scanf("%s %s %s",a,b,c);
		s = a[0] - 'A';
		t = b[0] - 'A';
		d = c[0] - 'A';
		r.push_back(prob(n,s,t,d));
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << setprecision(10) << r[i] << endl;
	}
	return 0;
}

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

int main(){
	string S;
	cin >> S;
	string::iterator itr = S.begin();
	int N = (int)S.size();
	int ans = 0;
	int now = 0;
	for(int i=0;i<N;i++){
		if(*(itr+i)=='A') now++;
		else if(*(itr+i)=='T') now++;
		else if(*(itr+i)=='C') now++;
		else if(*(itr+i)=='G') now++;
		else {
			ans = max(now,ans);
			now =0;
		}
	}
	ans = max(now,ans);
	cout << ans << endl;
}

Measured memory_bytes: 256
// 全然ダメ！

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define scns(s) scanf("%s", &s)
#define pri(n) printf("%d", n)
#define priln(n) printf("%d\n", n)
#define pris(s) printf("%s", s)
#define prisln(s) printf("%s\n", s)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> groups;
vector<vector<int>> connects;

void dfs(int val, int no)
{
  groups[val] = no;

  for (auto next_val : connects[val]) {
    if (groups[next_val] >= 0) continue;
    dfs(next_val, no);
  }
}

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

  vector<int> friends(n, 0);
  vector<int> blocks(n, 0);
  vector<int> counts(n, 0);
  connects.resize(n);
  groups.resize(n);
  groups.assign(n, -1);
  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    connects[a - 1].push_back(b - 1);
    connects[b - 1].push_back(a - 1);
    friends[a - 1]++;
    friends[b - 1]++;
  }

  int no = 0;
  for (int i = 0; i < n; ++i) {
    if (groups[i] >= 0) continue;

    dfs(i, no);
    no += 1;
  }

  for (int i = 0; i < n; ++i) {
    counts[groups[i]]++;
  }

  for(int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    if(groups[a - 1] == groups[b - 1]){
      blocks[a - 1]++;
      blocks[b - 1]++;
    }
  }

  for(int i=0;i<n;++i){
		cout << counts[groups[i]] - 1 - friends[i] - blocks[i];
		if(i != n-1) cout << " ";
	}

  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S=="ABC") {
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  if(s.at(0)==s.at(2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

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

  ll n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  rep(i, n) {
    for(int j = i + 1; j < n; ++j) {
      if(a[j] > a[i]) {
        ans += k * (k-1) / 2;
        ans %= MOD;
      } else if(a[i] > a[j]) {
        ans += k * (k+1) / 2;
        ans %= MOD;
      }
    }
  }

  cout << ans << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
	int a, b;
	cin >> a >> b;
	cout << (a-1) * (b-1) << endl;
	return;
}

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

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val monsters = readLine.trim.split(' ').map(_.toInt)
  println(monsters.reduce(gcd))
  def gcd(a: Int, b: Int): Int = {
    b match {
      case 0 ⇒ a
      case _ ⇒ gcd(b, a % b)
    }
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }

}

Measured memory_bytes: 42708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
#define pll pair<ll,ll>
using namespace std;
const int maxn=200010;
const int mod=1000000007;
int n,id[maxn],d[maxn],num;
ll mor[maxn];
vector<pll > f[maxn];
struct edge
{
    int t;
    edge *next;
}*con[maxn];
void ins(int x,int y)
{
    edge *p=new edge;
    p->t=y;
    p->next=con[x];
    con[x]=p;
}
void dp(int v,int fa)
{
    int mx=n+1;
    for(edge *p=con[v];p;p=p->next)
        if(p->t!=fa)
        {
            dp(p->t,v);
            if(d[p->t]>d[mx]) mx=p->t;
        }
    if(mx<=n) id[v]=id[mx],d[v]=d[mx]+1;
    else id[v]=++num;
    f[id[v]].push_back(make_pair(1,1));
    bool flag=0;
    for(edge *p=con[v];p;p=p->next)
        if(p->t!=fa&&p->t!=mx)
        {
            flag=1;
            for(int i=d[v]-d[p->t]-1;i<d[v];i++)
            {
                pll t=f[id[p->t]][i-d[v]+d[p->t]+1];
                mor[i]=(mor[i]*(t.first+t.second)%mod+f[id[v]][i].second*t.second%mod)%mod;
                f[id[v]][i].second=(f[id[v]][i].second*t.first%mod+f[id[v]][i].first*t.second%mod)%mod;
                f[id[v]][i].first=f[id[v]][i].first*t.first%mod;
            }
        }
    if(flag) 
        for(int i=0;i<d[v];i++)
            f[id[v]][i].first=(f[id[v]][i].first+mor[i])%mod,mor[i]=0;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        ins(i,x);
        ins(x,i);
    }
    d[n+1]=-1;
    dp(0,-1);
    ll tot=1,sum=0;
    for(int i=0;i<=d[0];i++)
    {
        int sz=(f[id[0]][i].first+f[id[0]][i].second)%mod;
        sum=(sum*sz%mod+f[id[0]][i].second*tot%mod)%mod;
        tot=tot*sz%mod;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 46704
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    bool b = false;
    if (n % 2) {
        for (int i = n - 1; i >= 0; i -= 2) {
            if (b) cout << " ";
            else b = true;
            cout << a[i];
        }
        for (int i = 1; i < n; i += 2) {
            if (b) cout << " ";
            else b = true;
            cout << a[i];
        }
        cout << endl;
    } else {
        for (int i = n - 1; i >= 0; i -= 2) {
            if (b) cout << " ";
            else b = true;
            cout << a[i];
        }
        for (int i = 0; i < n; i += 2) {
            if (b) cout << " ";
            else b = true;
            cout << a[i];
        }
        cout << endl;
    }
    
     return 0;
}

Measured memory_bytes: 2944
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	string s;cin >> s;
	map<char, int> m;
	for(auto i:s)m[i]++;
	for(auto i:m){
		if(i.second % 2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N >> A;
  //500円で払える分だけ払う
  int x = N - (N / 500) * 500;
 
  if (x <= A) {
    cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 3680
import math


def main():
    N = int(input())
    x = []
    y = []
    total = 0
    
    for i in range(N):
        a, b = map(int, input().split())
        x.append(a)
        y.append(b)
    for i in range(N):
        now_x = x[i]
        now_y = y[i]
        for j in range(N):
            if i == j:
                continue
            total += math.sqrt(abs(now_x - x[j]) ** 2 + abs(now_y - y[j]) ** 2) * math.factorial(N - 1)
    print("{0:.7f}".format(total / math.factorial(N)))

if __name__ == "__main__":
    main()


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

#define ll long long
#define el cout << '\n';
#define lcm(a, b) a / __gcd(a, b)*b
#define IOS   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define mod 1000000007
#define pr pair<int, int>

//debug
template <class... Args>
auto &see(const Args &... args) { return ((cerr << " " << args), ...) << '\n'; }
#define bug(...)  cerr << "[ " #__VA_ARGS__ " ] = "; see(__VA_ARGS__) << '\n';

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

int main()
{
    IOS
    int n, k, i; cin >> n ; 

    cout << !n ; el

   
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(){
  int h, w;
  scanf( "%d %d", &h, &w);
  char c[h+2][w+2];
  int lr[h+2][w+2], ud[h+2][w+2];
  
  for (int i=0; i<h+2; i++) {
    for (int j=0; j<w+2; j++) {
      c[i][j] = '#';
    }
  }
  for (int i=1; i<h+1; i++) {
    char str[w+1];
    scanf("%s", str);
    for (int j=1; j<w+1; j++) {
      c[i][j] = str[j-1];
    }
  }
  for (int i=1; i<h+1; i++) {
    int cnt = 0;
    for (int j=1; j<w+1; j++) {
      if (c[i][j]=='.') {
        cnt++;
      } else {
        cnt = 0;
      }
      lr[i][j] = cnt;
    }
    cnt = 0;
    for (int j=w; j>0; j--) {
      if (lr[i][j]==0) {
        cnt = 0;
      } else if (cnt==0) {
        cnt = lr[i][j];
      } else {
        lr[i][j] = cnt;
      }
    }
  }
  for (int j=1; j<w+1; j++) {
    int cnt = 0;
    for (int i=1; i<h+1; i++) {
      if (c[i][j]=='.') {
        cnt++;
      } else {
        cnt = 0;
      }
      ud[i][j] = cnt;
    }
    cnt = 0;
    for (int i=h; i>0; i--) {
      if (ud[i][j]==0) {
        cnt = 0;
      } else if (cnt==0) {
        cnt = ud[i][j];
      } else {
        ud[i][j] = cnt;
      }
    }
  }

  int ans = 0;
  for (int i=1; i<h+1; i++) {
    for (int j=1; j<w+1; j++) {
      int cnt = lr[i][j] + ud[i][j];
      if (ans<cnt) {
        ans = cnt;
      }
    }
  }
  ans -= 1;
  printf ("%d", ans);
  
  return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
//#define _GLIBCXX_DEBUG

void dfs(vector<vector<int>> &tree, int v, int p, vector<bool> &seen, vector<int> &counter) {
    seen[v] = true;
    counter[v] += p;
    for (auto i : tree[v]) {
        if (seen[i]) continue;
        dfs(tree, i, counter[v], seen, counter);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> tree(N+1, vector<int>(0));
    rep(i,0,N-1) {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> counter(N+1,0);
    rep(i,0,Q) {
        int p, x;
        cin >> p >> x;
        counter[p] += x;
    }

    vector<bool> seen(N+1, false);
    dfs(tree, 1, 0, seen, counter);

    rep(i,1,N+1) cout << (i-1 ? " " : "") << counter[i];
    cout << endl;
}

Measured memory_bytes: 29824
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<double> arr(n);
    for(int i = 0; i < n; i++)
        cin >>arr[i];
    double den = 0.0;
    for(auto ele : arr)
        if(ele != 0)
            den += (1.0 / ele);
    cout <<(1.0 / den);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
    ll i,j,k,l,m,n,a,c,b;
    cin>>n;
    vector<ll> v,vi;
    for(i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);

    }
    l=0;
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
    {
        vi.push_back(-v[i]*v[j]);
       // cout<<vi[l++]<<endl;
    }
    sort(vi.begin(),vi.end());
    for(i=0;i<vi.size();i++)
    {
        //v[i]=-1*v[i];
       // cout<<vi[i]<<endl;
        stringstream ss;
     ss << abs(vi[i]);
       string s = ss.str();
       // string s = to_string(abs(vi[i]));
       if(s.length()==1)
        {cout<<s<<endl;
                return 0;}
        for(j=0;j<s.length()-1;j++)
        {
           // cout<<s[j]<<" "<<s[j+1];

            if(s[j+1]-s[j]!=1)
               {
                //cout<<s[j+1]-s[j]<<endl;
                break;
               }
            else
            {

                if(j==s.length()-2)
                {cout<<s<<endl;
                return 0;}
            }
        }
    }
    cout<<"-1"<<endl;
    return 0;

}

Measured memory_bytes: 7100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k,a,b;
		k = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		int flag=0;
      
		for(int i=a;i<=b;i++) {
			if(i%k==0) {
				flag=1;
				break;
			}
		}
      
	if(flag==1)System.out.println("OK");
	else System.out.println("NG");
		sc.close();
	}
}

Measured memory_bytes: 35764
a,b=map(int,input().split())

if a==b:
    print("Draw")


elif a!=b:
    if a!=1 and b!=1:
        if a>b:
            print("Alice") 
        elif a<b:
            print("Bob") 
    
    elif a==1:
        print("Alice") 
    else:
        print("Bob")



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

string S;

int main() {
    cin >> S;

    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') cnt++;
    } 

    cout << 700 + 100*cnt << endl;

    return 0;
}


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

#define MOD 1000000007

long long kai[100010];

int segTree[500000] = {};
int segSize;

void init(int n){

  segSize = 1;
  while(segSize < n){
    segSize *= 2;
  }

  for(int i = 0;i < segSize;i++){
    if(i < n) segTree[segSize-1+i] = 1;
    else segTree[segSize-1+i] = 0;
  }

  for(int i = segSize-2;i >= 0;i--){
    segTree[i] = segTree[i*2+1] + segTree[i*2+2];
  }

  return;
}

void update(int i){
  i = segSize-1+i;
  segTree[i] = 0;

  while(i > 0){
    i = (i-1) / 2;
    segTree[i] = segTree[i*2+1] + segTree[i*2+2];
  }

  return;
}

int search(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return 0;
  if(a <= l && b >= r) return segTree[k];
  return search(a, b, 2*k+1, l, (l+r)/2) + search(a, b, 2*k+2, (l+r)/2, r);
}


int main(){

  kai[0] = 1;
  for(int i = 1;i < 100010;i++) kai[i] = (kai[i-1] * i) % MOD;

  int n;

  while(cin >> n, n != 0){
   int memo[100010];
   for(int i = 0;i < n;i++) memo[i] = i;

   int r, a, b;
   cin >> r;

   for(int i = 0;i < r;i++){
     cin >> a >> b;
     a--; b--;
     int tmp = memo[a];
     memo[a] = memo[b];
     memo[b] = tmp;
   }

   init(n);

   long long ans = 0;
   for(int i = 0;i < n-1;i++){
     int size = search(0,memo[i]+1,0,0,segSize)-1;
     ans = (ans + size * kai[n-i-1]) % MOD;
     update(memo[i]);
   }
   cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 5308
n, k = map(int, input().split())
x = list(map(int, input().split()))

inf = 10**12
z = len(x)

if n == 1 and k == 1:
    print(0)
    exit()

for i in range(len(x)):
    if x[i] >= 0:
        z = i
        break

r = [inf] * (n - z)
l = [inf] * z

for i in range(n-z):
    r[i] = x[z+i]

for i in range(z):
    l[i] = abs(x[z-i-1])

# 左からすべて取る場合
tl = inf
if len(l) < k:
    tl = inf
else:
    tl = abs(l[k-1])

if z == n-1:
    print(tl)
    exit()

# 右からすべて取る場合
tr = inf
if len(r) < k:
    tr = inf
else:
    tr = abs(r[k-1])
    
# 両方から取る場合
# 右からi個取る
t_arr = []
for i in range(1,k):
    if i-1 >= len(r):
        pass
    else:
        if k-i-1 >= len(l):
            pass
        else:
            t1 = r[i-1]
            t2 = l[k-i-1]
            t_arr.append(t1*2 + t2*2 - max(t1,t2))
tc = inf
if len(t_arr) != 0:
    tc = min(t_arr)
else:
    tc = inf
print(min(tl,tr,tc))


Measured memory_bytes: 20900
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A, B = ZIP(N)
A = np.array(A)
B = np.array(B)

dp = np.zeros(10001, dtype=np.int64)

for i in range(1, H+1):
	dp[i]=(dp[i-A]+B).min()

print(dp[H])


Measured memory_bytes: 13596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
#define mxsize (int)1e6
ll fastexp(ll a,ll n,ll nod){
    if(nod==0)	nod=LLONG_MAX;
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%nod;
        a=(a*a)%nod;
        n>>=1;
    }
    return ans;
}
void fun(){
    int n;
    cin>>n;
    int a[n],b[n];
    fi(0,n) cin>>a[i];
    fi(0,n) cin>>b[i];
    reverse(b,b+n);
    int i=0,j=n-1;
    int k=0;
    while(k<n){
        if(a[k]==b[k]){
            if(i!=-1&&(a[i]==a[k]||b[i]==a[k])){
                i=-1;
            }
            else if(i!=-1){
                swap(b[i++],b[k]);
            }
            if(i==-1&&(a[j]==a[k]||b[j]==a[k])){
                j=-1;
            }
            else if(i==-1){
                swap(b[j--],b[k]);
            }
            if(i==-1&&j==-1){
                cout<<"No\n";
                return ;
            }
        }
        k++;
    }
    cout<<"Yes\n";
    fi(0,n) db(b[i]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

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

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

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

	while(true){
		int n,m; cin >> n >> m;
		if(n == 0 && m == 0) break;

		int ans = 0;

		int r[1000];
		P d[100005];
		memset(r,-1,sizeof(r));
		for (int i = 0;i < m;i++){
			int a,b; cin >> a >> b;
			d[i] = P(a,b);
			if(a == 1) r[b] = 1;
			//if(b == 1) r[a] = 1;
		}
		for (int i = 0;i < m;i++){
			int a = d[i].first, b = d[i].second;
			if(a != 1){
				if(r[a] == 1 && r[b] != 1) r[b] = 2;
				if(r[b] == 1 && r[a] != 1) r[a] = 2;
			}
		}
		for (int i = 0;i <= n;i++){
			if(r[i] > 0){ ans++;}
		}

		cout << ans << endl;
	}	

	return 0;

}



Measured memory_bytes: 3916
N = int(input())
INF = 2*10**10
dp = [INF for x in range(N + 1)]

dp[0] = 0
for i in range(1, N + 1) :
    power = 1
    while power <= i :
        dp[i] = min(dp[i], dp[i - power] + 1)
        power *= 6
        
    power = 1
    while power <= i :
        dp[i] = min(dp[i], dp[i - power] + 1)
        power *= 9
        
print(dp[N])

Measured memory_bytes: 3864
n = int(input())
l = list(map(int, input().split()))

count = 0
for i in range(len(l)-2):
    for j in range(i, len(l)-1):
        for k in range(j, len(l)):
            if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
                count += 1
                
print(count)

Measured memory_bytes: 9200
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int s=N%10;
		switch(s) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:System.out.println("hon");break;
		case 0:
		case 1:
		case 6:
		case 8:System.out.println("pon");break;
		case 3:System.out.println("bon");break;
		}
	}

}

Measured memory_bytes: 35868
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e6;


ll a[N];

int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	ll n,k;
	cin>>n>>k;
	for(int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);

	ll L=-1e18-7,R=1e18+7;
	while(R-L>1) {
		ll Mid=(L+R)/2;
		ll cnt=0;
		for(int i=0; i<n; i++) {
			if(a[i]<0) {
				int l=i,r=n;
				while(r-l>1) {
					int mid=(l+r)/2;
					if(a[i]*a[mid]<=Mid) r=mid;
					else l=mid;
				}
				cnt+=n-r;
			} else {
				int l=i,r=n;
				while(r-l>1) {
					int mid=(l+r)/2;
					if(a[i]*a[mid]<=Mid) l=mid;
					else r=mid;
				}
				cnt+=l-i;
			}
		}

		if(cnt<k)L=Mid;
		else R=Mid;

	}
	cout<<R<<endl;






	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vaibhav ios_base::sync_with_stdio(false);cin.tie(NULL);
 
 
int main()
{
    vaibhav
    ll a,b;
    cin>>a>>b;
    ll sum=1,co=0;
    while(1)
    {

      if(sum>=b)
      {
        cout<<co;
        break;

      }
      else
      {
        sum=sum-1+a;
        co++;
      }
      
     
    }
 
  return 0;
}

Measured memory_bytes: 256