akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASTring solver = new ASTring();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASTring {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            int tCnt = 0;
            int sCnt = 0;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == 'S') {
                    // S
                    sCnt++;
                } else {
                    // T
                    if (sCnt > 0) sCnt--;
                    else tCnt++;
                }
            }

            out.println(sCnt + tCnt);
        }

    }
}



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

typedef long long ll;

int main() {
  ll n,m;
  cin>>n>>m;
  ll mcm = 1;
  ll mcd = 0;
  ll numeros [ n];
  for(int i=0;i<n;i++ ){
    ll numero2;
    cin>>numero2;
    numero2 /= 2;
    numeros[i] = numero2;
    mcd = __gcd(mcd,numero2);
    ll mcd2=__gcd(mcm,numero2);
    mcm = (mcm/mcd2)*numero2;
    
  }
  bool valor = 1;
  for(int i= 0; i<n; i++){
  	if((mcm / numeros[i]) % 2 == 0) valor=0;
  }
  if(!valor) cout<<0;
  else{
  	ll numero = m / mcm;//total de multiplos de mcm menores que m
  	cout<<(numero + 1)/2<<endl;
  }
  
  
  
  return 0;
}

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


int main(){
  vector<char> s(4);
  for(int i=0;i<4;i++){
    cin >> s[i] ;
  }
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if(A > B) {
            System.out.println(-1);
            return;
        }

        for(int i = 1; i < 99999999; i ++) {
            if((int)(i * 0.08) == A &&  (int)(i * 0.10) == B) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>

int d[1010],m,n,i,a,x;

int main(){
	scanf("%d%d",&n,&m);
	while(n!=0 && m!=0){
		for(i=1;i<=n;i++)d[i]=1;
		a=i=n;
		while(a>1){
			x=0;
			while(x<m){
				i++;if(i>n)i=1;
				x+=d[i];
			}
			d[i]=0;a--;
		}
		for(i=1;i<=n;i++)if(d[i]==1)printf("%d\n",i);
		scanf("%d%d",&n,&m);
	}
	
	return 0;
}

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


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());

		for(int i=0;i<N;i++) {
			String[] lc = br.readLine().split(" ");
			int a = Integer.parseInt(lc[0]);
			int b = Integer.parseInt(lc[1]);
			int c = Integer.parseInt(lc[2]);
			
			if(a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b)
			{
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}
}

Measured memory_bytes: 26108
#include<stdio.h>
int main (void)
{
  int n,x,t,ans;
  scanf("%d%d%d",&n,&x,&t);
  ans=((n-n%x)/x)*t;
  if(n%x!=0)ans+=t;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

bool dp[100100];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<=k;i++){
        if(!dp[i]){
            for(int j=0;j<n;j++){
                if(i+a[j]<=k){
                    dp[i+a[j]]=1;
                }
            }
        }
    }
    if(dp[k]){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    string s,t;cin>>s>>t;
    ll ans=1;
    int now=0;
    int zen=-1;
    for(;;){
        if(s[now]==t[now]){
            if(now==0)ans*=3;
            else{
                if(zen==1)ans*=2;
                
            }
            zen=1;
            now++;
        }
        else{
            if(now==0)ans*=6;
            else{
                if(zen==1)ans*=2;
                else ans*=3;
            }
            zen=0;
            now+=2;
        }
        ans%=mod;
        if(now>=n)break;
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   ll n,d,a;
   cin >> n >> d >> a;
   vector<pll>m(n);
   for(int i = 0;i<n;i++){
    cin >> m[i].first >> m[i].second;
   }
   sort(m.begin(),m.end());
   queue<pll>q;
   ll total = 0;ll ans = 0;
   for(int i = 0;i<n;i++){
    ll x = m[i].first;
    ll h = m[i].second;
    while(q.size()&&q.front().first<x){
         total -= q.front().second;
         q.pop();
    }
    h -= total;
    if(h>0){
        ll num = (h + a - 1) / a;
  		ans += num;
  		ll damage = num * a;
  		total += damage;
  		q.emplace(x + 2*d, damage);
    }
   }
   cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 7892
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

class binomial_coefficients {
public:
	long long MAX_VAL;
	vector<long long> fac, mmi;


	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = (x%MOD + MOD)%MOD;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};

binomial_coefficients bc;
vector<int> a, b, ans;

int N;
vector<vector<int>> tree;

void dfs1(int cur = 0, int per = -1){
	int pro = 0;
	
	b[cur] = 1;
	
	for(int nex : tree[cur]){
		if(nex == per) continue;
		dfs1(nex, cur);
		
		a[cur] += a[nex] + 1;
		b[cur] = (b[cur] * b[nex]) % MOD;
		b[cur] = (b[cur] * bc.mmi[a[nex]+1])%MOD;
	}
	
	b[cur] = (b[cur] * bc.fac[a[cur]]) % MOD;
}

void dfs2(int cur = 0, int per = -1, int A = -1, int B = 1){
	int sum = 0;
	
	ans[cur] = 1;
	
	
	sum += A + 1;
	
	ans[cur] = (ans[cur] * B) % MOD;
	ans[cur] = (ans[cur] * bc.mmi[A+1])%MOD;
	
	for(int nex : tree[cur]){
		if(nex == per) continue;
		sum += a[nex] + 1;
		ans[cur] = (ans[cur] * b[nex]) % MOD;
		ans[cur] = (ans[cur] * bc.mmi[a[nex]+1])%MOD;
	}
	
	
	for(int nex : tree[cur]){
		if(nex == per) continue;
		dfs2(nex, cur, N - (a[nex] + 1) - 1, bc.fac[sum - (a[nex] + 1)] * ans[cur] % MOD * bc.fac[a[nex]+1] % MOD * bc.power(b[nex], MOD-2) % MOD);
	}
	
	
	ans[cur] = (ans[cur] * bc.fac[sum]) % MOD;
}


signed main(){
	cout<<fixed<<setprecision(10);
	
	
	cin>>N;
	
	tree.resize(N);
	a.resize(N);
	b.resize(N);
	ans.resize(N);
	
	bc.init(N * 2);
	
	
	for(int i = 0; i < N-1; i++){
		int a, b;
		
		cin>>a>>b;
		
		a--,b--;
		
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	
	
	dfs1();
	dfs2();
	
	for(int i = 0; i < N; i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 26760
N,A,B = gets.split.map(&:to_i) #N,A,Bを取得
ans = 0
def calu(n) #各桁の和を計算する関数を宣言
  a = n #rubyの関数の仕様を把握してないので一応
  @i = 0 #各桁の和を代入する変数
  while a >= 10 #各桁の和を求める
    @i += a%10
    a /= 10
  end
  @i += a%10 #1桁の数を拾うために
  @i
end
w = 1
while w != N+1
  if calu(w) >= A&&calu(w) <= B #各桁の和がA以上B以下の数のみ
    ans += w
  end
  w += 1
end
puts ans


Measured memory_bytes: 1788
class BIT():
    def __init__(self,number):
        self.n=number
        self.list=[0]*(number+1)
        
    def add(self,i,x):#ith added x  1indexed
        while i<=self.n:
            self.list[i]+=x
            i+=i&-i
            
    def search(self,i):#1-i sum
        s=0
        while i>0:
            s+=self.list[i]
            i-=i&-i
        return s
    
    def suma(self,i,j):#i,i+1,..j sum
        return self.search(j)-self.search(i-1)
N=int(input())
A=[int(i) for i in input().split()]
if ((N*(N+1))//2)%2==1:
    a=((N*(N+1))//2)//2+1
else:
    a=((N*(N+1))//2)//2
#a=((N*(N+1))//2)-((N*(N+1))//2)//2-1
def f(s):#ans is ijou s
    X=[1 if a>=s else -1 for a in A]
    p=[0]*(N+1)
    ma=0
    mi=0
    for i in range(1,N+1):
        p[i]=p[i-1]+X[i-1]
        ma=max(p[i],ma)
        mi=min(p[i],mi)
    tree=BIT(ma-mi+1)
    num=0
    for i in range(1,N+2):
        num+=tree.search(p[i-1]-mi+1)
        tree.add(p[i-1]-mi+1,1)
    if num>=a:
        return True
    else:
        return False
x=10**9+1
y=-1
while x-y>1:
    mid=(x+y)//2
    if f(mid):
        y=mid
    else:
        x=mid
print(y)


Measured memory_bytes: 120216
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100;
struct P { int x,y; };
bool operator<(const P &a,const P &b) { if(a.x!=b.x) return a.x<b.x; return a.y<b.y; }

int n;
P a[MAXN],b[MAXN];

multiset<int> av;

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d%d",&a[i].x,&a[i].y); REP(i,n) scanf("%d%d",&b[i].x,&b[i].y);
	
	sort(a,a+n);
	sort(b,b+n);
	int at=0; av=multiset<int>();
	int ret=0;
	REP(i,n) {
		while(at<n&&a[at].x<b[i].x) av.insert(a[at++].y);
		//printf("testing (%d,%d), av:",b[i].x,b[i].y); for(auto z=av.begin();z!=av.end();++z) printf(" %d",*z); puts("");
		auto it=av.lower_bound(b[i].y);
		if(it==av.begin()) continue; else --it;
		++ret; av.erase(it);
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, k; cin >> n >> k;
  string s; cin >> s; s.push_back('2');
  vi32 v;
  char prev;
  int cnt = 1;
  if (s[0] == '0') v.push_back(0);
  prev = s[0];
  reps(i, n) {
    if (s[i] != prev) {
      v.push_back(cnt);
      cnt = 1; prev = s[i];
    } else {
      cnt++;
    }
  }
  if (s[n - 1] == '0') v.push_back(0);
  int r = k * 2 + 1;
  if (v.size() < r) {
    cout << n << endl;
    return 0;
  }
  vi32 sums(v.size() + 1);
  partial_sum(all(v), sums.begin() + 1);
  i32 ans = 0;
  for (int i = 0; i <= v.size() - r; i += 2) {
    amax(ans, sums[i + r] - sums[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
=begin
なに一つわからないから下記を参照して勉強する
https://qiita.com/shiroux/items/16173c1588d22e81333c
https://qiita.com/scivola/items/ee37b686d0b36d6e9b39#_reference-59ee3759dcc7717d083a
=end

n = gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
c=n.times.map{|i|(a[i]-b[i]).abs}
p c.sum
p c.map{|i| i**2}.inject(:+)**0.5
p c.map{|i| i**3}.inject(:+)**(1/3.to_f)
p c.max


Measured memory_bytes: 8944
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t x = 4LL * a * b;
  int64_t y = (c - a - b) * (c - a - b);
  if (x < y && c - a - b >= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int main( ){
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if( op == '?' )break;
    if( op == '+' )printf("%d\n",a+b);
    if( op == '-' )printf("%d\n",a-b);
    if( op == '*' )printf("%d\n",a*b);
    if( op == '/' )printf("%d\n",a/b);
  }
  return 0;
}

Measured memory_bytes: 3148
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a_s = Vec::new();
    for _ in 0..n {
        let a: usize = iter.next().unwrap().parse().unwrap();
        a_s.push(a);
    }
    let mut b_s = Vec::new();
    for _ in 0..n {
        let b: u32 = iter.next().unwrap().parse().unwrap();
        b_s.push(b);
    }
    let mut c_s = Vec::new();
    for _ in 0..(n - 1) {
        let c: u32 = iter.next().unwrap().parse().unwrap();
        c_s.push(c);
    }
    let mut ans = 0;
    ans += a_s.iter().map(|&i| b_s[i - 1]).sum::<u32>();
    ans += (0..(n - 1))
        .filter(|&i| (a_s[i + 1] as isize - a_s[i] as isize) == 1)
        .map(|i| c_s[a_s[i] - 1])
        .sum::<u32>();
    println!("{}", ans);
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;

using pii = pair<int,int>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) {
    for(T &a : v) is >> a; return is;
}

using pdd = pair<double, double>;
#define mp(x, y) make_pair(x, y)
#define Y first
#define X second
const int INF = 1 << 30;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

// (x, y)???????????????????????§???????????????(????????????, ??????), ?????????
// ??????????????? ?????? = 0 ??§??????
pair<pdd, int> rec(vector<string> &G, int y, int x) {
    int W = G[0].size(), H = G.size();
    vector<pair<pdd, int>> grav;
    char c = G[y][x];
    set<pii> visited;
    
    queue<pii> q;
    q.push(mp(y, x));
    int xl = INF, xr = -INF;
    while(!q.empty()) {
        pii now = q.front(); q.pop();
        if(G[now.Y][now.X] != c) continue;
        G[now.Y][now.X] = '*';
        visited.insert(now);
        grav.push_back(mp(mp(now.Y + 0.5, now.X + 0.5), 1));

        char down = now.Y == H - 1 ? '*' : G[now.Y + 1][now.X];
        if(not visited.count(mp(now.Y + 1, now.X))
           and down != c and (down == '*' or isdigit(down))) {
            xl = min(xl, now.X);
            xr = max(xr, now.X + 1);
        }
        
        rep(i, 4) {
            int nx = now.X + dx[i];
            int ny = now.Y + dy[i];
            if(nx < 0 or W <= nx or ny < 0 or H <= ny) continue;
            if(G[ny][nx] == c) {
                q.push(mp(ny, nx));
            } else if(i == 0 and isdigit(G[ny][nx])) {
                // ???????????????
                auto ret = rec(G, ny, nx);
                if(ret.second == 0) return mp(mp(0.0, 0.0), 0);
                grav.push_back(ret);
            }
        }        
    }
    // ???????¨????
    int sum = 0;
    double xg = 0, yg = 0;
    rep(i, grav.size()) {
        sum += grav[i].second;
        xg += grav[i].second * grav[i].first.X;
        yg += grav[i].second * grav[i].first.Y;
    }

    xg /= sum;
    yg /= sum;

    return ((xl < xg and xg < xr) ? mp(mp(yg, xg), sum) : mp(mp(0.0, 0.0), 0));
}

bool solve() {
    int W, H; cin >> W >> H;
    if(W == 0 and H == 0) return 0;
    vector<string> G(H); cin >> G;
    
    rep(i, W) if(isdigit(G[H - 1][i])) {
        cout << (rec(G, H - 1, i).second > 0 ? "STABLE" : "UNSTABLE") << endl;
        return 1;
    }

    assert(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3188
#!/usr/bin/env python3
import numpy as np


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W, K = list(map(int, input().split()))
    c = []
    for h in range(H):
        c.append(list(input()))

    field = np.zeros([H, W]).astype(int)
    for i in range(H):
        for j in range(W):
            if c[i][j] == '.':
                field[i][j] = 0
            else:
                field[i][j] = 1

    raw_field = field.copy()
    count = 0
    for i in range(2 ** (W+H)):
        field = raw_field.copy()
        searching = bin(i)[2:]
        searching = '0' * ((W+H) - len(searching)) + searching
        for k in range(W+H):
            if k < W and searching[k] == '1':
                field[:, k] = 0
            elif W <= k < W+H and searching[k] == '1':
                field[k-W, :] = 0
        if field.sum() == K:
            count += 1
    print(count)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 27248
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)    cin>>a.at(i);

    sort(all(a));

    int ans=true;
    rep(i,n-1) {
        if(a[i]==a[i+1])    ans=false;
    }

    if(ans==true)   cout<<"YES"<<endl;
    else    cout<<"NO"<<endl;

 return 0;
}

Measured memory_bytes: 1024
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M) {
  cout << (N==M?YES:NO)<<endl;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
s = input()
mod = 10**9+7

init = [0 for i in range(13)]
if s[0] == '?':
  dp = [1] * 10 + [0] * 3
else:
  dp = [0 for i in range(13)]
  dp[int(s[0])] = 1

for c in s[1:]:
  d = [0 for i in range(13)]
  if c == '?':
    for i in range(13):
      for j in range(10):
        idx = (i * 10 + j) % 13
        d[idx] = (dp[i] + d[idx]) % mod 
  else :
    for i in range(13):
      idx = (i * 10 + int(c)) % 13
      d[idx] = (dp[i] + d[idx]) % mod
  dp = d
print(dp[5])


Measured memory_bytes: 43628
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
//#include <fstream>

using namespace std;

typedef pair<int, int> T;

int main()
{
//	cut here before submit 
//	freopen ("testcase.traffic", "r", stdin );
	string str = "";
	int n, m;

	while (1){
		cin >> n >> m;

		if (!n && !m ){
			break;
		} // end if
		queue <int> tl, tr;

		vector <T> ta (n + m + 2);

		int a,b;
		int i,j,k;

		for (i = 0; i < n; ++i){
			cin >> a;
			tl.push (a);
		} // end for

		for (j = 0;j < m; ++j){
			cin >> b;
			tr.push (b);
		} // end for

		int res = 0;

		for (k = 0; k < n + m; ++k){
			if (!tr.empty() && !tl.empty() ){
				if (tr.front() < tl.front() ){
					ta[k].first = tr.front();
					tr.pop();
				}else{
					ta[k].first = tl.front();
					tl.pop();
				} // end if
			}else if (tr.empty() && !tl.empty() ){
					ta[k].first = tl.front();
					tl.pop();
			}else if (!tr.empty() && tl.empty() ){
					ta[k].first = tr.front();
					tr.pop();
			} // end if
			ta[k].second = (k == 0 ? ta[k].first : ta[k].first - ta[k-1].first );
			res = max (res, ta[k].second );
		} // end for

		cout << res << endl;	

	} // end loop

		
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll h[n];
  for(i = 0; i < n; ++i) scanf("%lld", &h[i]);
  for(i = 0; ; ++i) {
    bool f = true;
    for(j = 0; j < n; ++j) if(h[j]) {
      f = false;
      for(k = j; k < n; ++k) {
        if(h[k]) --h[k];
        else break;
      }
      break;
    }
    if(f) break;
  }
  printf("%lld", i);
  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate
mod = 10 ** 9 + 7

N = int(input())
X = tuple(map(int, input().split()))
DX = [xr - xl for xl, xr in zip(X[:-1], X[1:])]

from1 = [1]
fromN = [1]
for i in range(1, N):
    from1.append(from1[-1] * i % mod)  # 1, 1*2, 1*2*3,...
    fromN.append(fromN[-1] * (N - i) % mod)  # 4, 4*3, 4*3*2, ...
fromN.reverse()

cnt = []
for a, b in zip(fromN[1:], from1[:-1]):
    cnt.append(a * b % mod)
cnt = list(accumulate(cnt))

ans = 0
for dx, c in zip(DX, cnt):
    ans = (ans + dx * c) % mod
print(ans)

Measured memory_bytes: 29076
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=100005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[n+1]={0};
    rep(i,0,n-1) {
    	ll x;
    	cin >> x;
    	a[x]++;
    }
    rep(i,1,n+1) cout << a[i] << endl;
}

Measured memory_bytes: 5208
#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;



#define MOD 998244353
#define NUM 100005

ll uniformity[8*NUM],partial[8*NUM];
ll N = 1;
ll first_N,K,P;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
		uniformity[node_id] %= MOD;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		partial[node_id] %= MOD;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return ((node_right-node_left)*uniformity[node_id]+partial[node_id])%MOD;

	}else{

		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];
		sum %= MOD;

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum %= MOD;

		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		sum %= MOD;

		return sum;
	}
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main(){

	scanf("%lld %lld %lld",&first_N,&K,&P);

	init(K+first_N);

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	ll inverse_N = mod_inverse(first_N,MOD);
	ll mult = mod_inverse(100*first_N,MOD)*P;
	mult %= MOD;

	//クリア状態
	for(ll i = K; i <= K+first_N-1; i++){

		add(i,i+1,1,0,0,N);
	}

	//i枚ある状態からクリアする確率を求める
	for(ll i = K-1; i >= 0; i--){

		ll tmp = 0;

		//1発でクリア状態に行ける場合
		if(i+first_N >= K){

			tmp += getSum(K,i+first_N+1,0,0,N);
			tmp *= inverse_N;
			tmp %= MOD;
		}

		ll tmp2 = 0;

		//クリア状態ではない状態に行ける場合
		if(i+1 <= K-1){

			tmp2 += getSum(i+1,min(K-1,i+first_N)+1,0,0,N);
			tmp2 *= mult;
			tmp2 %= MOD;
		}
		tmp += tmp2;
		tmp %= MOD;
		add(i,i+1,tmp,0,0,N);
	}

	printf("%lld\n",getSum(0,1,0,0,N)); //★注意:開区間★

	return 0;
}



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


//a b c  a b c a-b b-c c-a a-b-c
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    //---------------------Code-------------------------------------
    vector<char> alpha;
    //alpha.push_back('z');
    for(int i=0;i<26;i++)
    {
        alpha.push_back('a'+(i));
    }
    int n;
    cin>>n;
    string s="";
    while(n>0)
    {
        if(n%(26)==0)
        {
            s='z'+s;
            n=(n/26)-1;
        }
        else
        {
            s=alpha[(n%26)-1]+s;
            n=(n/26);
        }
        
        
        
    }
    cout<<s<<endl;

    //--------------------------------------------------------------

}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 501010

ll T,N,M,P,a,b;
ll A[MAXN];
ll flip=0;
deque<char> dq;
char c;
string S;
ll ans=0;
ll offset = 0;

int main(){
	cin>>N>>P>>S;
	if (P == 2 || P == 5){
		ll ans= 0;
		for (int i=0;i<N;++i){
			if ((S[i] - '0')%P == 0)ans += i+1;
		}
		cout<<ans;
		return 0;
	}
	A[0] = 1;
	ll mlt = 1;
	while (SZ(S)){
		// cout<<"offset "<<offset<<'\n';
		int t = S.back() - '0';S.pop_back();
		ll m = (mlt * t)%P;
		mlt = mlt*10%P;
		ll tar = (2*P-offset-m)%P;
		ans += A[tar];
		// cout<<"Adding "<<A[tar]<<'\n';
		offset = (offset + m)%P;
		A[(P-offset)%P]++;
		// cout<<"Inc "<<(P-offset)%P<<'\n';
	}
	cout<<ans;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    vi h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h.begin(),h.end(),greater<int>());
    int L=1,R=1e9,ans=-1;
    while(L<=R)
    {
        int mid=L+R>>1;
        ll cur=0;
        for(int i=0;i<n;i++)
        {
            ll rem=1LL*b*mid;
            rem=h[i]-rem;
            if(rem>0)
                cur+=(rem+a-b-1)/(a-b);
        }
        if(cur<=mid)
        {
            ans=mid;
            R=mid-1;
        }
        else L=mid+1;
    }
    cout<<ans<<'\n';

}

Measured memory_bytes: 640
a, b = list(map(int, input().split()))
if a == 1 and b == 1:
  print("Draw")
else:
  if a == 1:
    print("Alice")
  elif b == 1:
    print("Bob")
  elif a > b:
    print("Alice")
  elif b > a:
    print("Bob")
  else:
    print("Draw")

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> pll;

int main(){
	const LL mod = 1000000007LL;

	int pra[128] = {}, prs[128] = {};
	pra['|'] = 15;
	pra['&'] = 25;
	pra[')'] = 5;

	prs['|'] = 16;
	prs['&'] = 26;
	prs['~'] = 34;
	prs['('] = 4;

	string s;
	cin >> s;
	s += ')';

	vector<pll> v(1, pll('(', -1));
	v.reserve(s.size());

	for(size_t i = 0; i < s.size(); ++i){
		LL c = s[i];
		if(c == 'x'){
			v.push_back(pll(1, 1));
		}
		else if(!isdigit(c)){
			if(c != '(' && c != '~'){
				while(v.size() > 1){
					LL op = v[v.size() - 2].first;

					if(prs[op] < pra[c]){ break; }

					pll y = v.back();
					v.pop_back();
					v.pop_back();

					if(op == '~'){
						v.push_back(pll(y.second, y.first));
					}
					else if(op == '&'){
						pll x = v.back();
						LL tr = x.first * y.first;
						LL fl = x.first * y.second + x.second * (y.first + y.second);
						v.back() = pll(tr % mod, fl % mod);
					}
					else if(op == '|'){
						pll x = v.back();
						LL tr = x.second * y.first + x.first * (y.first + y.second);
						LL fl = x.second * y.second;
						v.back() = pll(tr % mod, fl % mod);
					}
					else{
						throw op;
					}
				}
			}
			
			if(c == ')'){
				v[v.size() - 2] = v.back();
				v.pop_back();
			}
			else{
				v.push_back(pll(c, -1));
			}
		}
	}
	
	cout << v[0].first << endl;
}

Measured memory_bytes: 11028
s = input()
result = 753

for i in range(len(s)-2):
	a,b,c = int(s[i]),int(s[i+1]),int(s[i+2])
	x = (a*100)+(b*10)+(c)
	y = abs(x-753)
	if y <= result:
		result = y


print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    int c1=0,c2=0,c3=0,c4=0;
    while (t--)
    {
        string s;
        cin>>s;
        if (s=="AC")
        c1++;
        else if (s=="WA")
        c2++;
        else if (s=="TLE")
        c3++;
        else if (s=="RE")
        c4++;
    }
    printf("AC x %d\n",c1);
    printf("WA x %d\n",c2);
    printf("TLE x %d\n",c3);
    printf("RE x %d\n",c4);
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
    using namespace std;
     
    int n;
    vector<vector<pair<int, int>>> v;
     
    int solve(int bits) {
        int res = 0;
        vector<bool> isHonest(n + 1);
     
        for(int i = 1; i <= n; i++) {
            if(bits & 1 << (i - 1)) {
                isHonest[i] = true;
                res++;
            }
            else {
                isHonest[i] = false;
            }
        }
     
        for(int i = 1; i <= n; i++) {
            if(isHonest[i] == true) {
                for(auto e : v[i]) {
                    if(isHonest[e.first] == (e.second ^ isHonest[i])) {
                        return -1;
                    }
                }
            }
        }
        return res;
    }
     
    int main() {
     
        if(fopen("input_muntu.in", "r")) {
            freopen("input_muntu.in", "r", stdin);
            freopen("output_muntu.out", "w", stdout);
        }
        
        cin >> n; v.resize(n + 1);
        for(int i = 1; i <= n; i++) {
            int a; cin >> a;
            for(int j = 1; j <= a; j++) {
                int x, y; cin >> x >> y;
                v[i].emplace_back(x, y);
            }
        }
     
        int ans = 0;
        for(int i = 1; i < (int)(pow(2.0, n) + 0.5); i++) {
            ans = max(ans, solve(i));
        }
        cout << ans << endl;
     
        return 0;
    }
     
    // compile and run : g++ wtf.cpp -o wtf -std=c++11 && wtf

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; ++i){
		if (i % 3 == 0 || i % 5 == 0){
			continue;
		}
		ans += i;
	}
	cout << ans;
	return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  bitset<100001> bs;bs[1] = 1;
  vector<int> v(100001,1);
  rep(i,0,m){
    int x,y; cin >> x >> y;
    if(bs[x]){
      bs[y] = 1;
      if(v[x]==1)bs[x] = 0;
    }
      v[x]--;
      v[y]++;
  }
  int ans = (int)bs.count();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    PI            acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const long double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100000+9;
vector< vector<int> > v(N);
int vis[N],par[N],dist[N],ass[N];
void bfs(int src){

  queue<int> q;
  q.push(src);
  vis[src]=1;
  dist[src]=0;
  par[src]=-1;
  int lv=-1;
  while(sz(q)>0){
    int siz=sz(q);
    lv++;
    while(siz--){

        int cur=q.front();
        q.pop();
        dist[cur]=lv;

        for(int i=0;i<sz(v[cur]);i++){
            int nw=v[cur][i];
            if(vis[nw]) continue;
            vis[nw]=1;
            par[nw]=cur;
            q.push(nw);
        }
    }
  }
}
bool go(int no){

   int cur=no,cnt=0;
   while(1){

    int pp=par[cur];
  //  cout<<pp<<endl;
    if(pp==-1) break;
    cnt++;
    if(ass[cur]==-1){

        ass[cur]=pp;
        cur=pp;
    }
    else if(ass[cur]==pp){

        if(dist[no]==cnt+dist[pp]){
            return 1;
        }
        else{
            return 0;
        }
    }
    else{
        return 0;
    }

   }
  return 1;
}
int main(){
    GO();
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    bfs(1);
    /*
    for(int i=1;i<=n;i++){
        cout<<dist[i]<<endl;
    }
    */
    clr(ass,-1);
    for(int i=2;i<=n;i++){

        int ret=go(i);
        if(ret==0){
            //cout<<i<<endl;
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(int i=2;i<=n;i++){
      cout<<ass[i]<<"\n";
    }

}

























Measured memory_bytes: 11368
#include<bits/stdc++.h>
#define pi pair<int,int>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e16
using namespace std;
typedef long long ll;

const int N = 109;

void slv()
{
    string s;
    cin>>s;
    int mx=0;
    int cnt=0;
    for(int i=0;i<s.size();i++) {
        if(s[i]=='R') cnt ++;
        else {
            mx=max(mx,cnt);
            cnt=0;
        }
    }
    mx=max(mx,cnt);
    cout<<mx<<endl;
}
int main()
{
    int t;
    t=1;
    for(int cs=1;cs<=t;cs++)
    {
        //printf("Case #%d: ",cs);
        slv();
    }
    return 0;
}


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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<int> yx(N, 0);
  
  for (int i = 0; i < N; i++) {
    int in1;
    
    cin >> in1;
    
    yx[i] = in1;
  }
  
  for (int i = 0; i < N; i++) {
    int in2;
    
    cin >> in2;
    
    yx[i] -= in2;
  }
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    if (yx[i] > 0) {
      sum += yx[i];
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007

ll n,a[100005],fact[100005];
ll pos[100005];
ll mod_pow(ll base){
    ll ret=1,exp=M-2;
    while (exp){
        if (exp%2) ret =(ret*base)%M;
        exp=exp>>1;
        base=(base*base)%M;
    }
    return ret;
}
ll C(ll n,ll r){
    return (fact[n]*(mod_pow((fact[n-r]*fact[r])%M)))%M;
}

int main(){
    cin>>n;
    ll lt,rt;
    rep(i,1,n+1) {
        cin>>a[i];
        if(pos[a[i]]==0) pos[a[i]]=i;
        else {lt=pos[a[i]],rt=i;}
    }
    ll rem=n+1-rt+lt-1;
    fact[0]=1;
    rep(i,1,n+1) fact[i]=(fact[i-1]*i)%M;
    rep(i,1,n+1){
        ll val=C(n+1,i);
        if(rem>=i-1) val=((val-C(rem,i-1))%M+M)%M;
        cout<<val<<'\n';
    }

}


Measured memory_bytes: 3584
n = int(input())
w = []
for i in range(n):
  w.append(input())
k = 0
for i in range(n-1):
  if w[i][-1] == w[i+1][0]:
    k += 1

print('Yes' if k == n-1 and len(set(w)) == n else 'No')
  


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main() {
    int n;
    double p1 = 0.0, p2 = 0.0, p3 = 0.0, pInf = 0.0, tempFabs = 0.0;
    scanf("%d", &n);
    int x[n], y[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    for (int j=0; j<n; j++) {
        scanf("%d", &y[j]);
    }
    for (int k=0; k<n; k++) {
        tempFabs = fabs((double)x[k] - y[k]);   // |x - y|
        p1 += tempFabs;             // p = 1
        p2 += pow(tempFabs, 2.0);   // p = 2
        p3 += pow(tempFabs, 3.0);   // p = 3
        if (tempFabs > pInf) {
            pInf = tempFabs;        // p = ∞
        }
    }
    p2 = sqrt(p2);
    p3 = cbrt(p3);
    printf("%f\n%f\n%f\n%f\n", p1, p2, p3, pInf);
    return 0;
}



Measured memory_bytes: 2132
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long
#define MAX 200000000000
#define MOD 1000000007
ll int bin(ll int);

int main(void){
 ll int N,P;
 scanf("%lld%lld",&N,&P);
 ll int i;
 ll int A[100];
 ll int odd=0,even=0;
 for(i=0;i<N;i++){
  scanf("%d",&A[i]);
  if(A[i]%2) odd++;
  else even++;
 }
  if(odd!=0)
  printf("%lld\n",bin(even)*bin(odd-1));
  else
  {
    if(P==1) printf("0\n");
    else printf("%lld\n",bin(N));
  }
 return 0;
}

ll int bin(ll int a){
    if(a==0) return 1;
    return 2*bin(a-1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    ll k;
    cin >> k;
    if(k % 2 == 0 || k % 5 == 0){
        cout << -1 << endl;
        return 0;
    }
    ll now = 7 % k, i = 1;
    while(true){
        if(now % k == 0){
            cout << i << endl;
            return 0;
        }
        i++;
        now *= 10;
        now += 7;
        now %= k;
    }
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();

    bool ok = true;
    if (n % 2) ok = false;
    else {
        REP(i, n) {
            if (i % 2) {
                if (s[i] != 'i')
                    ok = false;
            } else {
                if (s[i] != 'h')
                    ok = false;
            }
        }
    }

    if (ok) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
N, A, B = gets.chomp.split.map(&:to_i)
ans = 0

(N+1).times do |i|
  sum = 0
  n = i
  while n > 0
    sum += n % 10
    n = n / 10
  end
  ans += i if A <= sum && sum <= B
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/*  Writen by : AS7
 *  "JUST KEEP GOING..."
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
const int N = 2e5+5;
void solve(){
    ll n;
    cin>>n;
    deque<char> ans;
    while(n){
        if(n%26==0)
            ans.push_front('z'),n--;
        else
        ans.push_front('a'+n%26-1);
        n-=n%26;
        n/=26;
    }
    Forr(i,ans)cout<<i;

}
int main() {
    int t = 1;
    //  cin>>t;
    while (t--)solve();
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>

using namespace std;

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

    int nagame = 1;
    int high = H[1];

    for (int i=1; i<N; i++) {
        if (high < H[i-1]) {high = H[i-1];}
        if (H[i-1] <= H[i] && high <= H[i]) {
            nagame += 1;
        }
    }

    cout << nagame;

    return 0;
}   


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  int ans;
  repr(i, s.size() - 2) {
    if((i + 1) % 2 == 0 && s.substr(0,i / 2 + 1) == s.substr(i / 2 + 1,i/2 + 1)) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

int main(){

    int r, g, b;
    int sum;
    cin >> r >> g >> b;
    sum = r*100 + g*10 + b;

    if(sum % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    bool f = false;
    if (a%3 == 0){
        f = true;
    }
    else if (b%3 == 0){
        f = true;
    }
    else if ((a+b)%3 == 0){
        f = true;
    }
    if (f == true) puts("Possible");
    else puts("Impossible");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto &i:a)cin>>i,i--;
  int p=0;
  for(int i=0;i<n;++i){
    if(p==1)return cout<<i,0;
    p=a[p];
  }
  cout<<-1;
}

Measured memory_bytes: 640