akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ul NMAX = 8;
const static ul LiMAX = 1000;

static si N, A, B, C;
static si Li[NMAX];

si dfs(si i, si a, si b, si c) {
  if (i == N) {
    if (min(a, min(b, c)) > 0) {
      return abs(A - a) + abs(B - b) + abs(C - c) - 30;
    } else {
      return 1<<30;
    }
  }
  si r1, r2, r3, r4;
  r1 = dfs(i + 1, a, b, c);
  r2 = dfs(i + 1, a + Li[i], b, c) + 10;
  r3 = dfs(i + 1, a, b + Li[i], c) + 10;
  r4 = dfs(i + 1, a, b, c + Li[i]) + 10;
  return min(min(r1, r2), min(r3, r4));
}

void solve(void) {
  cout << dfs(0, 0, 0, 0) << endl;
}

int main(void) {
  cin >> N >> A >> B >> C;
  FOR0(i, N) {
    cin >> Li[i];
  }
  solve();
  return 0;
}

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> s >> n;
  	deque<char> a;
  	bool f = false;
	REP(i,s.length()) {
    	a.push_back(s[i]);
    	//dbg(a.back());
    }
    while (n--) {
    	cin >> m;
      	//a.push_back(m);
      if (!(m-1)) {
      	//reverse(ALL(s));
        f = !f;
      } else {
      	cin >> k >> c;
        if(!(k-1)) {
          	if(f) {
            	a.push_back(c);
            }else{
              a.push_front(c);
            }
        } else {
          if(!f) {
            	a.push_back(c);
            }else{
              a.push_front(c);
            }
        }
      }
    }
  	if(f) {reverse(ALL(a));}
    REP(i,a.size())
  		cout << a[i];
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;cin>>a>>b;
  if(a%2==0||b%2==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
  }


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int i, number;
    for(i = 1; ; i++) {
      number = Integer.parseInt(sc.next());
      if(number == 0) break;
      System.out.println("Case " + i + ": " + number);
    }
  }
}


Measured memory_bytes: 40508
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=2147483647;
const int MAXN=500100;
struct dish{
	int v;
	int p;
}a[MAXN],b[MAXN],c[MAXN];
void msort_a(int L,int r){  
	if (L==r) 
		return;
	int m=(L+r)/2;    
	msort_a(L,m);  
	msort_a(m+1,r);    
	int i=L, j=m+1;    
	while (i<=m && j<=r){    
		if (a[i].p<=a[j].p){
			c[i+j-m-1]=a[i];
			i++;
		}  	  
		else{
			c[i+j-m-1]=a[j];
			j++;
		} 
	}    
	while (i<=m) {
		c[i+j-m-1]=a[i];
		i++;
	}
		  
	while (j<=r){
		c[i+j-m-1]=a[j];
		j++;
	}
		    
	for (int k=L;k<=r;k++)
		a[k]=c[k]; 
	} 

void msort_b(int L,int r){  
	if (L==r) 
		return;
	int m=(L+r)/2;    
	msort_b(L,m);  
	msort_b(m+1,r);    
	int i=L, j=m+1;    
	while (i<=m && j<=r){    
		if (b[i].p<=b[j].p){
			c[i+j-m-1]=b[i];
			i++;
		}  	  
		else{
			c[i+j-m-1]=b[j];
			j++;
		} 
	}    
	while (i<=m) {
		c[i+j-m-1]=b[i];
		i++;
	}
		  
	while (j<=r){
		c[i+j-m-1]=b[j];
		j++;
	}
		    
	for (int k=L;k<=r;k++)
		b[k]=c[k]; 
	} 
 
int n;
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].v,&b[i].v);
		a[i].p=a[i].v+b[i].v;
		b[i].p=a[i].p;
	}
	msort_a(1,n);
	msort_b(1,n);
	for(int i=n;i>=1;i--)
		if((n-i+1)%2==1)
			ans+=a[i].v;
		else
			ans-=b[i].v;
	printf("%lld\n",ans); 
	return 0;
}


Measured memory_bytes: 9344
n, m = map(int, input().split())
a = []
b = []
c = []

for _ in range(m):
	INPUT = list(map(int, input().split()))
	a.append(INPUT[0])
	b.append(INPUT[1])
	c.append(-INPUT[2])

dist = [float("inf") for _ in range(n)]
dist[0] = 0

for _ in range(1, n):
	for j in range(m):
		if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
			dist[b[j] - 1] = dist[a[j] - 1] + c[j]

ans = dist[n - 1]

for j in range(m):
	if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
		dist[b[j] - 1] = dist[a[j] - 1] + c[j]

if dist[n - 1] < ans:
	print("inf")
else:
	print(-ans)


Measured memory_bytes: 3316
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14
int dp[MAX];// dp[v]:= ノードvを始点とした時の, Gの有効バスの長さの最大値
int rec(const Graph &G,int v){
    if(dp[v]!=-1)return dp[v];

    int res=0;
    for(auto nv:G[v]){
        chmax(res,rec(G,nv)+1);
    }
    return dp[v]=res;
}

int main(){
    int n,m;cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int x,y;cin>>x>>y;
        x--;y--;
        G[x].push_back(y);
    }
    rep(i,n)dp[i]=-1;
    int res=0;
    rep(v,n)chmax(res,rec(G,v));
    cout<<res<<endl;
}

Measured memory_bytes: 11896
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  string s; cin >> s;
  if(s[s.size()-1] == 's') s += "es";
  else s += "s";
  
  cout  << s << endl;
  
  
}

Measured memory_bytes: 3600
s = input()
string = []
for i in range(len(s)):
    if s[i] == '0':
        string.append(str(s[i]))
    elif s[i] == '1':
        string.append(str(s[i]))
    else:
        if len(string) == 0:
            continue
        else:
            string.pop(-1)
print("".join(string))

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
	int a, b, x, y;
	scanf("%d%d%d%d", &a, &b, &x, &y);
	printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}

Measured memory_bytes: 128
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

H, W, K = map(int, input().split())
C = [0] * H
for i in range(H):
    C[i] = list(input())

def solve(y, x, B):
    B[y][x] = '.'
    score = 0
    step = 0
    while True:
        updated = False
        # drop step
        for i in range(H - 1, -1, -1):
            for j in range(W - 1, -1, -1):
                if B[i][j] != '.':
                    continue
                k = i - 1
                while k >= 0 and B[k][j] == '.':
                    k -= 1
                if k >= 0:
                    B[i][j] = B[k][j]
                    B[k][j] = '.'
                    updated = True
        if not updated:
            break

        # erase step
        erased = 0
        for i in range(H):
            start = 0
            while start < W:
                count = 1
                if B[i][start] == '.':
                    start += 1
                    continue
                while start + count < W and B[i][start + count] == B[i][start]:
                    count += 1
                if count >= K:
                    erased += count * int(B[i][start])
                    for k in range(start, start + count):
                        B[i][k] = '.'
                start += count
        score += (2 ** step) * erased
        step += 1
    return score

ans = 0
for i in range(H):
    for j in range(W):
        B = [[C[i][j] for j in range(W)] for i in range(H)]
        ans = max(ans, solve(i, j, B))
print(ans)



Measured memory_bytes: 75372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    V<set<int>> pla(26);
    REP(i,26) pla[i].insert(-1);
	REP(i,26) pla[i].insert(366);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol.pb(r);
        pla[r].insert(i);
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,26) loss[i] = 0;
    ll nowres = 0;
    REP(i,d){
        nowres += v[i][sol[i]];
        REP(j,26){
            if(j == sol[i]) loss[j] = 0;
            else loss[j] += c[j];
            nowres -= loss[j];
        }
    }
    int Q = 230000;
    random_device rnd;
    while(Q--){
        int newi = rnd() % 365;
        int newsol = rnd() % 26;
        if(sol[newi] == newsol) continue;
        int old = sol[newi];
        sol[newi] = newsol;
        REP(i,26) loss[i] = 0;
        ll newres = 0;
        REP(i,d){
            newres += v[i][sol[i]];
            REP(j,26){
                if(j == sol[i]) loss[j] = 0;
                else loss[j] += c[j];
                newres -= loss[j];
            }
        }
        if(newres <= nowres) sol[newi] = old;
        else nowres = newres;
    }
    REP(i,d) cout << sol[i] + 1 << '\n';
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

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

	if (s.length() <= k)
		cout << s << endl;
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
}

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

int main() {
    long double A, B, H, M;
    long double argA;
    long double argB;
    long double diff;
    long double ans;

    cin >> A >> B >> H >> M;
    argA = H * 30 + M * 30 / 60;
    argB = (M / 60) * 360;
  	diff = argA - argB;
    if (diff < 0) {
        diff = -diff;
    }
  	if (diff > 180) {
      diff = 360 - diff;
    }
    ans = sqrt(A * A + B * B - 2 * A * B * cos(diff * (M_PI / 180)));
    cout << fixed << setprecision(15) << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4168
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<assert.h>
#define gc getchar()
#define N 100010
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int c[3],v[110][110];bool vis[110][110];
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1},n;
int dfs(int x,int y,int c)
{
	vis[x][y]=true;
	for(int i=0;i<4;i++)
	{
		int s=x+dx[i],t=y+dy[i];
		if(s>0&&s<=n&&t>0&&t<=n&&!vis[s][t]&&v[s][t]==c) dfs(s,t,c);
	}
	return 0;
}
int main()
{
	int a,b,cnt=0;scanf("%d%d",&a,&b),c[1]=1;
	n=100;if(a<b) swap(a,b),swap(c[0],c[1]);b--;
	while(b)
	{
		cnt++;
		for(int i=1;i<=n;i++)
			if((((cnt+i)&1)^1)||!b) v[cnt][i]=c[0];
			else v[cnt][i]=c[1],b--;
	}
	cnt++;
	for(int i=1;i<=n;i++) v[cnt][i]=c[0];
	for(int i=1;i<cnt;i++)
		for(int j=1;j<=n;j++)
			if(v[i][j]==c[0]&&v[i+1][j]!=c[0]) a--;
	a--,cnt++;
	for(int x=cnt&1;cnt<=n;cnt++)
		if((cnt&1)^x^1) for(int i=1;i<=n;i++) v[cnt][i]=c[1];
		else for(int i=1;i<=n;i++)
			if((i&1)&&a) v[cnt][i]=c[0],a--;
			else v[cnt][i]=c[1];
	printf("%d %d\n",n,n);
	for(int i=1;i<=n;i++,printf("\n"))
		for(int j=1;j<=n;j++)
			printf("%c",v[i][j]?'#':'.');
/*	memset(vis,0,sizeof(vis));
	int t=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!vis[i][j]&&v[i][j]==0) t++,dfs(i,j,0);
	assert(t==aa);
	memset(vis,0,sizeof(vis));
	t=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!vis[i][j]&&v[i][j]==1) t++,dfs(i,j,1);
	assert(t==bb);*/
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


n = int(input())
s = input()

rs, gs, bs = [], [], []
for l, c in enumerate(s):
  if c == 'R':
    rs.append(l)
  if c == 'G':
    gs.append(l)
  if c == 'B':
    bs.append(l)
sbs = set(bs)

ans = 0
for r in rs:
  for g in gs:
    m = min(r, g)
    M = max(r, g)
    notbs = [m - (M - m), M + (M - m)]
    if (M + m) % 2 == 0:
      notbs.append((M + m) // 2)
    
    dprint(m, M, notbs, sbs)
    
    # a = len(sbs - set(notbs))

    a = len(sbs)
    for notb in notbs:
      if notb in sbs:
        a -= 1
    if a > 0:
      ans += a


print(ans)


Measured memory_bytes: 68772
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = a+b;
    ans = max(ans,a+a-1);
    ans = max(ans,b+b-1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int N;
int a[10];
int index(int n, int m) {
	int a = 1;
	for (int i = 0; i < n - 1; ++i) {
		a *= m;
	}
	return a;
}
int main() {
	cin >> N;
	int allV = 1, even=1;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		allV *= 3;
		if (a[i] % 2 == 0) even*=2;
	}
	cout << allV - even << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<string> v;
int n;
int d[10][10]={{}};
string ans;

void solve(vector<int> l){
  string b;
  b=v[l[0]];
  for(int i=1;i<n;i++){
    b+=v[l[i]].substr(d[l[i-1]][l[i]],v[l[i]].size()-d[l[i-1]][l[i]]);
    if(b.size()>ans.size()) return;
  }
  //cout << b << endl;
  if(ans.size()>b.size()) ans=b;
  if(ans.size()==b.size()&&b<ans) ans=b;
}

int main(){
  while(cin >> n,n){
    string s;
    int i,j,k;
    v.clear();
    for(i=0;i<n;i++){
      cin >> s;
      v.push_back(s);
    }

    
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	d[i][j]=0;
      }
    }
    
    bool f;
    for(i=0;i<n;i++){
      f=false;
      for(j=0;j<n;j++){
	if(i==j) continue;
	if(v[j].find(v[i])!=-1) f=true;	
      }
      if(f){
	v.erase(v.begin()+i);
	i--;n--;
      }
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i==j) continue;
	for(k=1;k<=v[i].size();k++){
	  if(v[i].substr(v[i].size()-k,k)==v[j].substr(0,k))
	    d[i][j]=max(d[i][j],k);
	}
      }
    }

    
    vector<int> l;
    l.clear();
    ans="";
    for(i=0;i<n;i++) {
      l.push_back(i);
      ans+=v[i];
    }

    do{
      solve(l);
    }while(next_permutation(l.begin(),l.end()));
    
    cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1240
import numpy as np

def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

def solve(N, X, Y):
    def bfs(v):
        q = [v]
        Distance = [-1] * (N+1)
        Distance[v] = 0
        distance = 1
        while q:
            q_new = []
            for v in q:
                u = v-1
                if u >= 1 and Distance[u] == -1:
                    Distance[u] = distance
                    q_new.append(u)
                u = v+1
                if u <= N and Distance[u] == -1:
                    Distance[u] = distance
                    q_new.append(u)
                if v == X:
                    u = Y
                    if Distance[u] == -1:
                        Distance[u] = distance
                        q_new.append(u)
                elif v == Y:
                    u = X
                    if Distance[u] == -1:
                        Distance[u] = distance
                        q_new.append(u)
            distance += 1
            q = q_new
        return Distance

    Ans = np.zeros(N, dtype=np.int64)
    for v in range(1, N+1):
        Distance = bfs(v)
        for d in Distance[v+1:]:
            Ans[d] += 1
    return Ans[1:]

numba_compile([
    [solve, "i8[:](i8,i8,i8)"]
])

N, X, Y = map(int, input().split())
Ans = solve(N, X, Y)
print("\n".join(map(str, Ans.tolist())))


Measured memory_bytes: 27556
#include<stdio.h>

int main(){
	
	long long int tc;
	long long int temp=1;
	
	scanf("%lld",&tc);
	long long int input[100005];
	bool printtemp = false;
	bool nextloop = true;
	for(long long int i=0;i<tc;i++){	
		scanf("%lld",&input[i]);
		if(input[i] == 0){
			printf("0\n");
			nextloop = false;
			break;
		}	
	}
	if ( nextloop ){
		for(long long int i =0;i<tc;i++){
			if(1000000000000000000/temp < input[i]){
				printf("-1\n");
				break;
			}
			temp *=input[i];
			//printf("Temp [%d] : %lld\n",i,temp);
			if(i >= tc-1){
				printtemp = true;
			} 
		}	
	}
	

	if(printtemp) printf("%lld\n",temp);
	
	
	return 0;
}

Measured memory_bytes: 2468
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int mod = 1000000007;
int n;

signed main() {
	cin >> n;
	
	int res1 = powmod(9, n, mod) * 2 % mod;
	int ans = (res1 + mod - powmod(8, n, mod)) % mod;
	ans = (powmod(10, n, mod) + mod - ans) % mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n)(for i-0;i<(n);++i)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int l;
  cin >> l;
  printf("%.6f", (double)l * l * l / 27);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int k;bool v[1000000];
main()
{
	scanf("%d",&k);
	for(register int i=7%k,ans=1;;i=(i*10+7)%k,++ans)
	{
		if(!i){printf("%d",ans);return 0;}
		if(v[i]){puts("-1");return 0;}
		v[i]=1;
	}
}

Measured memory_bytes: 2636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
using ll = long long;
using VI = vector<int>;


int main() {
    int n, k;
    cin >> n >> k;
    VI list(n, 0);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++) {
            int in;
            cin >> in;
            list[in - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < list.size(); i++) {
        if (list[i] == 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>

using namespace std;

set<string>mo;
int N,k;
bool use[15];
map<string,int>memo;
string n[10];
void g(int m,string a){
    if(m==k){
        memo[a]=1;
    return;
    }
        for(int i=0;i<N;i++){
        if(!use[i]){
                string _a=a+n[i];
            use[i]=1;
            g(m+1,_a);
            use[i]=0;
        }
    }
}
//??¨??????????????????(????????????)
int main(){
while(1){
        int ans=0;
        cin >> N >> k;
    if(N==0&&k==0)break;
    for(int y=0;y<N;y++){
        cin >> n[y];
    }
    fill(use,use+15,0);
    memo.clear();
    g(0,"");
    cout << memo.size() << endl;
}

return 0;
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
const int N = 1005, M = 2005;
struct edge {
	int to, nxt;
} graph[M];
int n, m, head[N], par[N], dep[N], cnt = 0, tot = 0;
void addedge (int u, int v) {
	edge x = {v, head[u]};
	graph[head[u] = cnt++] = x;
}
vector<int> ans;
queue<int> q;
void bfs (int s) {
	for (int i = 1; i <= n; i++) dep[i] = -1, par[i] = 0;
	dep[s] = 0, q.push(s);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = head[u]; ~i; i = graph[i].nxt) {
			int v = graph[i].to;
			if (dep[v] < 0) par[v] = u, dep[v] = dep[u] + 1, q.push(v);
		}
	}
}
int main () {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) head[i] = -1;
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	int mn = n + 1, u = 0, v = 0;
	for (int i = 1; i <= n; i++) {
		bfs(i);
		for (int j = 1; j <= n; j++) {
			for (int k = head[j]; ~k; k = graph[k].nxt) {
				int x = graph[k].to;
				if (x == i && dep[j] > 0) {
					if (mn > dep[j] + 1) mn = dep[j] + 1, u = i, v = j;
				}
			}
		}
	}
	if (mn > n) printf("-1\n");
	else {
		bfs(u);
		for (int i = v; i; i = par[i]) ans.push_back(i);
		printf("%d\n", ans.size());
		for (int i = 0; i < ans.size(); i++) printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int s,k,count=0;
	cin >> k >> s;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			int z = s-x-y;
			if(z>=0 && z<=k)
				if(z+y+x==s)count++;
			}
		}
	cout << count << endl;
}

Measured memory_bytes: 3584
n=gets.to_i
h=gets.split.map(&:to_i)
d=Array.new(n+1,-1)
h.unshift(0)

d[1]=0
d[2]=(h[2]-h[1]).abs
3.upto(n){|i|
  d[i]=[(h[i-1]-h[i]).abs+d[i-1],(h[i-2]-h[i]).abs+d[i-2]].min
}
puts d[n]

Measured memory_bytes: 11780
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    var a = sc.nextInt()
    var b = sc.nextInt()
    var c = sc.nextInt()
    var k = sc.nextInt()
    while (a >= b && k > 0) {
        b *= 2
        k--
    }
    while (b >= c && k > 0) {
        c *= 2
        k--
    }
    println(if (a < b && b < c) "Yes" else "No")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34392
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ull unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define meme(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define mod 1'000'000'007
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
} 

ll ks(int wt[],int val[],int n,int w){
    ll dp[n+1][w+1];
    int i,j;
    fo(i,n+1){
        fo(j,w+1){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(wt[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]); 
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    return dp[n][w];
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int n,w,i;
    cin>>n>>w;
    int wt[n],val[n];
    fo(i,n){
        cin>>wt[i];
        cin>>val[i];
    }
    cout<<ks(wt,val,n,w)<<"\n";
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> W(N);
  for (int i = 0; i < N ; i++) {
    cin >> W.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < N - 1 ; i++) {
    if (W.at(i + 1).at(0) != W.at(i).at(W.at(i).size() - 1)){
      count++;
      break;
    }
    for (int j = i + 1; j < N ; j++) {
      if (W.at(i) == W.at(j)){
        count++;
        break;
      }
    }
  }
  
  if (count > 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define all(a)      a.begin(),a.end()
#define getc getchar_unlocked
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n,sum=0;
  cin >> n;
  int a[n];
  map<int,int> m;
  f(i,n)
  {
      cin >> a[i];
      m[a[i]]++;
      sum+=a[i];
  }
  int q;
  cin >> q;
  while(q--)
  {
      int b,c;
      cin >> b >> c;
      m[c]+=m[b];
      sum-=(b*m[b]);
      sum+=(c*m[b]);
      m[b]=0;
      cout << sum << '\n';
  }
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10184
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B, long C, long D, long E) {
    auto times = [A, B, C, D, E];
    return times.map!"(a + 9) / 10 * 10".sum - (10 - (times.map!"a % 10".filter!"a > 0".array ~ 10).reduce!min);
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long D;
    D = input.front.to!long;
    input.popFront;

    long E;
    E = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B, C, D, E);
    else
        solve(A, B, C, D, E).writeln;
}


Measured memory_bytes: 256
"use strict";
// import bigInt from 'big-integer'

const gcd = (a, b) => {
  if (b === 0) return a;

  return gcd(b, a % b);
};

const lcm = (a, b) => {
  return (a * b) / gcd(a, b);
};

const Main = input => {
  input = input.trim().split(" ");
  let a = parseInt(input[0], 10);
  let b = parseInt(input[1], 10);
  if (a < b) {
    const tmp = a;
    a = b;
    b = tmp;
  }

  console.log(lcm(a, b));
};

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  int n;
  cin >> n;
  deque<ll> a;
  REP(i, n) {
    ll tmp;
    cin >> tmp;
    if (i % 2 == 0) {
      a.push_back(tmp);
    } else {
      a.push_front(tmp);
    }
  }
  if (n % 2 == 1) {
    RREP(i, a.size()) { cout << a[i] << endl; }
  } else {
    REP(i, a.size()) { cout << a[i] << endl; }
  }
  return 0;
}

Measured memory_bytes: 3840
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define INF 100000000000ull

#define SOUR (M+7)
#define SINK (M+7+1)

class Node
{
public:	
	vector<int> to;
};

int main()
{
	int M;
	long long N;
	while(cin >> M >> N, (M||N))
	{
		Node n[150];
		long long flow[150][150]={0},cap[150][150]={0},all=0;
		
		for(int i=0; i<M; i++)
		{
			long long T,C;
			cin >> T >> C;
			n[SOUR].to.push_back(i);
			
			cap[SOUR][i]+=T;
			cap[i][SOUR]+=T;
			all+=T;
			
			while(C--)
			{
				string s;
				cin >> s;
				int p;
				if(s=="Sunday") 	p=0;
				if(s=="Monday") 	p=1;
				if(s=="Tuesday") 	p=2;
				if(s=="Wednesday") 	p=3;
				if(s=="Thursday")	p=4;
				if(s=="Friday")		p=5;
				if(s=="Saturday") 	p=6;
				
				n[i].to.push_back(M+p);
				n[M+p].to.push_back(i);
				
				flow[M+p][i]+=N;
				
				cap[i][M+p]+=N;
				cap[M+p][i]+=N;
			}
		}
		
		for(int i=0; i<7; i++)
		{
			n[M+i].to.push_back(SINK);
			cap[M+i][SINK]+=N;
		}
		
		long long total=0;
		while(1)
		{		
			int v[150];
			for(int i=0; i<=SINK; i++)
				v[i]=-1;
				
			v[SOUR]=SOUR;
			
			queue<int> q;
			q.push(SOUR);
			
			bool g=false;
			while(!q.empty())
			{
				int t=q.front(); q.pop();
				if(t==SINK)
				{
					g=true;
					break;
				}
				
				for(int i=0; i<n[t].to.size(); i++)
				{
					int next=n[t].to[i];
					if(flow[t][next]==cap[t][next]) continue;
					if(v[next]>=0) continue;
					
					v[next]=t;
					
					q.push(next);
				}
			}
			
			if(!g) break;
			
			long long f=INF;
			for(int j=SINK; v[j]!=j; j=v[j])
			{
				f=min(f,cap[v[j]][j]-flow[v[j]][j]);
			}
			
			total+=f;
			for(int j=SINK; v[j]!=j; j=v[j])
			{
				flow[v[j]][j]+=f;
				flow[j][v[j]]-=f;
			}
		}
		
		puts((all==total?"Yes":"No"));
	}
}

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

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
using namespace std;

const int N=100010;
int n;
int a[N];

int gcd(int x,int y) {
    return y==0?x:gcd(y,x%y);
}

bool lose() {
    int zero=0;
    int odd=0;
    int cnt=0;
    int idx=-1;
    bool flag=true;
    for (int i=1;i<=n;i++) {
        zero|=(a[i]-1);
        odd=(odd+a[i]-1)%2;
        if ((a[i]&1)&&(a[i]>1)) {
            cnt++;
            idx=i;
        }
        if (a[i]==1) flag=false;
    }
    if (zero==0) return true;
    if (odd) return false;
    if (cnt!=1||!flag) return true;
    a[idx]--;
    int tmp=a[1];
    for (int i=2;i<=n;i++) tmp=gcd(tmp,a[i]);
    for (int i=1;i<=n;i++) a[i]/=tmp;
    return !lose();
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",a+i);
    }
    if (n==1) {
        if ((a[1]-1)&1) printf("First\n");
        else printf("Second\n");
    } else {
        if (lose()) printf("Second\n");
        else printf("First\n");
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

struct UF{
    vl par;
    UF(ll N):par(N){
        rep(i,N)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    void unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
};

int main() {
ll N;
  ll M;
  cin >>N>>M;
  if((N!=1) &&(M!=1)) {
    cout<<(N*(N-1))/2+(M*(M-1))/2<<endl;
  }
  else if(N==1) {
cout<<(M*(M-1))/2<<endl;
  }
  else if(M==1) {
    cout<<(N*(N-1))/2<<endl;
  }
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
int occ[maxn];
int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    if(s.size() != a + b + 1) printf("No\n");
    else{
        for(int e = 0; e < a; e++){
            if('0' <= s[e] && s[e] <= '9');
            else return ! printf("No\n");
        }
        if(s[a] != '-') return ! printf("No\n");
        for(int e = a+1; e < a+b+1; e++){
            if('0' <= s[e] && s[e] <= '9');
            else return ! printf("No\n");
        }
        printf("Yes\n");
    }
    return 0;
}


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

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  int ans = 1e9;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)  {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>()); //降順


  for (int i = 0; i < n - k + 1; ++i)  {
    int diff = v[i] - v[i + k - 1];
    ans = min(ans, diff);
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){

		printf("1\n");
		return 0;
	}

	int ans = 2;

	ll mult = K;

	while(true){

		if(N >= K && N < K*mult){

			printf("%d\n",ans);
			return 0;
		}
		ans++;
		K *= mult;
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np


n, m, c = map(int, input().split())
b = list(map(int, input().split()))
b = np.array(b)
count = 0
for i in range(n):
    a = np.array(list(map(int, input().split())))
    if sum(a*b) + c > 0:
        count += 1
print(count)



Measured memory_bytes: 13368
#include <bits/stdc++.h>
#define INF 100000000
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


// ABC118C - Monsters Battle Royale
// https://atcoder.jp/contests/abc118/tasks/abc118_c
void ABC118C() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	//昇順にソート
	sort(A.begin(), A.end());

	//バトルスタート
	while (SIZE(A) > 1) { //最後の1体になるまで続ける
		int attack = A[0];
		for (int i = 1; i < SIZE(A); i++)
		{
			A[i] %= attack;
		}

		//体力がゼロになったモンスターを削除
		auto removeIt = remove_if(A.begin(), A.end(), [&](int value) {
			return value == 0;
			}
		);
		A.erase(removeIt, A.end());

		//昇順にソート
		sort(A.begin(), A.end());
	}

	cout << A[0] << endl;
}


int main() {
	ABC118C();

	return 0;
}

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

template <class T> T power(T a, long long n) {
  assert(n >= 0);
  T res = 1;
  while (n) {
    if (n & 1) res *= a;
    if (n >>= 1) a *= a;
  }
  return res;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> mint& mint::operator/=(mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, s, t;
  prepare(5e6);
  auto fn = [](int n, int k) -> mint {
    if (k == 0) return n == 0;
    return binom(n + k - 1, n);
  };
  while (cin >> a >> b >> c >> s >> t, a + b + c) {
    mint res;
    for (int x = 0; x <= min(s, t); ++x) {
      int p = s - x - a, q = t - x - b;
      if (p < 0 or q < 0) {
        continue;
      }
      res += fn(p, a) * fn(q, b) * fn(x, a + b + c);
    }
    res *= fact[a + b + c] * inv_fact[a] * inv_fact[b] * inv_fact[c];
    cout << res.v << '\n';
  }
}



Measured memory_bytes: 61264
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cmath>
const int MaxN = 2e5;
using namespace std;
int pre[MaxN * 2 + 5] , last[MaxN + 5] , other[MaxN * 2 + 5];
int all = -1;
int n , tot[3] , ans[3] , vis[MaxN + 5];
void Build(int u , int v){
	pre[++all] = last[u];
	last[u] = all;
	other[all] = v;
}
bool ok = 0;
int len = 0;
void Dfs(int x  , int d){
	if(ok || vis[x]) return;
	vis[x] = 1;
	if(x == n){ ok = 1 , len = d;return;}
	int ed = last[x];
	while(ed != -1){
		int dr = other[ed];
		Dfs(dr , d + 1);
		ed = pre[ed];
	}
	if(!ok) vis[x] = 0;
}
void Dfs2(int x , int fa , int p , int t){
	int ed = last[x];
	if(vis[x]){
		t++;
		if(t > tot[p]) return;
	}
	ans[p]++;
	while(ed != -1){
		int dr = other[ed];
		if(dr != fa) Dfs2(dr , x , p , t);
		ed = pre[ed];
	}
}
int main()
{
	while(~scanf("%d" , &n)){
		all = -1;
		ok = 0;
		ans[1] = ans[2] = tot[1] = tot[2] = 0;
		memset(vis , 0 , sizeof(vis));
		memset(last , -1 , sizeof(last));
		for(int i = 1;i <= n - 1;i++){
			int u , v;
			scanf("%d%d" , &u , &v);
			Build(u , v); Build(v , u);
		}
		Dfs(1 , 1);
		tot[1] = (len + 1) / 2;
		tot[2] = len / 2;
		Dfs2(1 , 0 , 1 , 0);
		Dfs2(n , n + 1 , 2 , 0);
		if(ans[1] > ans[2]) printf("Fennec\n");
		else printf("Snuke\n");
	}
}

Measured memory_bytes: 6912
<?php
/**
 * ABC127
 * B - Algae
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d", $r, $d, $x);

for ($i = 1; $i <= 10; $i++) {
    $x = $r * $x - $d;
    echo $x, PHP_EOL;
}


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

using namespace std;


int main(){
  int q;
  cin >> q;
  for(int i=0;i<q;++i){
    int c,a,n;
    cin >> c >> a >> n;
    int num=0;
    for(;;){
    if(c>=1 && a>= 1 && n>=1){
      num++;
      c--;
      a--;
      n--;
    }else if(c>=2 && a>=1){
      num++;
      c-=2;
      a--;
    }else if(c>=3){
      num++;
      c-=3;
    }else break;
    }

    cout << num << endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3084
n,m=map(int,input().split())
A=list(map(int,input().split()))

B=[]
su=0
for i in range(n):
    su+=A[i]
    B.append(su)

#print(B)

C={}
C[0]=1
for i in range(n):
    C[B[i]%m]=C.get(B[i]%m,0)+1

#print(C)

#D=C.values()
su=0
#print(C.values())
for i in C.values():
    su+=i*(i-1)//2
print(su)


Measured memory_bytes: 16556
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

count = 0


def main():
    N, M = map(int, input().split())
    info = [list(map(int, input().split())) for _ in range(M)]
    g = deque(list())

    def visit(n, memo):
        n_memo = deepcopy(memo)
        n_memo.append(n)
        children = g[n]

        if len(n_memo) == N:
            global count
            count += 1

        for child in children:
            if child not in n_memo:
                visit(child, n_memo)

    for _ in range(N):
        g.append([])

    for p, c in info:
        g[p-1].append(c-1)
        g[c-1].append(p-1)

    visit(0, [])

    print(count)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

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

int main() {

ll m,n; cin >> m >> n ;

cout << modpow(m,n,MOD) << endl;

return 0;
}


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  vector<ll> a(n);
  rep(i,n) {
    cin >>a[i];
    if(a[i]==0){
      cout <<0<<endl;
      return 0;
    }
  }
  ll ans =1;
  rep(i,n){
    if(1000000000000000000/ans>=a[i]){
      ans*=a[i];
    }else {
      cout <<-1<<endl;
      return 0;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 4052