akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int N;
        long K; 
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        int[] A = r.ii();
        int MOD = 1000000007;
        int n1 = 0;
        int n2 = 0;
        for (int i = 0; i < N; i++) {
            long Ai = A[i];
            for (int j = 0; j < i; j++)
                if(Ai > A[j])
                    n1++;
            for (int j = i+1; j < N; j++)
                if(Ai > A[j])
                    n2++;
        }
        long num = K*(K-1)/2%MOD*n1+K*(K+1)/2%MOD*n2;
        print(num%MOD);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 21716
# unihernandez22 & Vicfred
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math, probability
from random import randint

n = int(input())

for _ in range(10**6):
    x = randint(-200,200)
    y = randint(-200,200)
    if x**5 - y**5 == n:
        print(x,y)
        break;

Measured memory_bytes: 9572
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
using P = pair<int, int>;

int main(){
    stack<int> a;
    stack<P> b;
    string g;
    getline(cin, g);

    int sum = 0;
    for(int i = 0; i < g.size(); i++){
        if(g[i] == '\\') a.push(i);
        else if(g[i] == '/' && !a.empty()){
            int a_left = a.top(); a.pop();
            int s = i - a_left;
            sum += s;
            while(!b.empty() && b.top().first > a_left){
                s += b.top().second; b.pop();
            }
            b.push(make_pair(a_left, s));
        }
    }
    cout << sum << endl << b.size();

    vector<int> o;
    while(!b.empty()){
        o.push_back(b.top().second);
        b.pop();
    }
    for(int i = o.size() - 1; i >= 0; i--) cout << ' ' << o[i];
    cout << endl;
    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int mod = 998244353;

int pow(int a, int b) {
    if(b == 0) return 1;
    if(b%2) {
        return a*pow(a, b-1)%mod;
    } else {
        return pow(a*a%mod, b/2);
    }
}

int32_t main() {

    int n; cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; ++i) cin >> a[i];

    int total_poss = pow(3LL, n);

    int tot_sum = 0;
    for(int aa : a) tot_sum += aa;
    
    vector<vector<int>> dp(n+1, vector<int>(tot_sum+1, 0));
    dp[0][0] = 1;

    for(int i = 1; i <= n; ++i) {
        int cur = a[i];
        for(int j = 0; j <= tot_sum; ++j) {
            dp[i][j] = dp[i-1][j]*2%mod;
            if(j-cur >= 0) {
                dp[i][j] += dp[i-1][j-cur];
            }
            dp[i][j] %= mod;
        }
    }

    vector<vector<int>> dp2(n+1, vector<int>(tot_sum+1, 0));
    dp2[0][0] = 1;

    for(int i = 1; i <= n; ++i) {
        int cur = a[i];
        for(int j = 0; j <= tot_sum; ++j) {
            dp2[i][j] = dp2[i-1][j];
            if(j-cur >= 0) {
                dp2[i][j] += dp2[i-1][j-cur];
            }
            dp2[i][j] %= mod;
        }
    }
    
    int dont_work = 0;
    for(int i = (tot_sum+1)/2; i <= tot_sum; ++i) {
        dont_work += dp[n][i];
    }
    if(tot_sum%2 == 0)
        dont_work -= dp2[n][tot_sum/2];
            
    dont_work*=3;
    int ans = total_poss - dont_work;
    while(ans < 0) ans += mod;
    ans %= mod;
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    int e;
    while(cin >> e, e != 0){
        int m = e;
        for(int z=0;z<=100;++z){
            for(int y=0;y<=1000;++y){
                int x = e - (z*z*z + y*y);
                if(x >= 0){
                    m = min(m, x+y+z);
                }
            }
        }
        cout << m << endl;
    }

    return 0;
}



Measured memory_bytes: 3032
import java.util.*;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int D = sc.nextInt();
        int[][] A = new int[H][W];
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int Q = sc.nextInt();
        int[] L = new int[Q];
        int[] R = new int[Q];
        for(int i = 0; i < Q; i++) {
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }

        Map<Integer,Integer> Ax = new HashMap<>();
        Map<Integer,Integer> Ay = new HashMap<>();

        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                Ax.put(A[i][j], j);
                Ay.put(A[i][j], i);
            }
        }

        int[] cost = new int[H * W + 1];
        for(int i = 1; i <= H * W; i++) {
            if(i + D > H * W) continue;
            int costTmp = Math.abs(Ax.get(i + D) - Ax.get(i)) + Math.abs(Ay.get(i + D) - Ay.get(i));
            cost[i + D] = costTmp + cost[i];
        }

        for(int i = 0; i < Q; i++) {
            System.out.println(cost[R[i]] - cost[L[i]]);
        }
        
    }
}

Measured memory_bytes: 95500
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAX 100005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;

void solve(){
    int n;
    cin>>n;
    cout<<(n*n*n)+(n*n)+n<<"\n";

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;

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

    return 0;
    
}

Measured memory_bytes: 3644
def d_gathering_children(S):
    s = list(S)
    n = len(S)
    ans = [0] * n

    for _ in range(2):
        # 'R'についてのみ考える(理由は後述)
        count = 0
        for i in range(n):
            if s[i] == 'R':
                count += 1
            else:
                # 'RL' が現れた。LとRのマスにそれぞれ下の数だけ子供が増える
                ans[i - 1] += (count + 1) // 2
                ans[i] += count // 2
                count = 0

        # LとRをひっくり返す。すると、上の処理でLとRを別に処理しなくてよくなる
        ans = list(reversed(ans))
        s = list(reversed(s))
        for i in range(n):
            if s[i] == 'L':
                s[i] = 'R'
            else:
                s[i] = 'L'
    return ' '.join(map(str, ans))

S = input()
print(d_gathering_children(S))

Measured memory_bytes: 11188
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int sa = 1000;
  cin >> s;
  int siz = s.size();
  for(int i=0;i<siz-2;i++){
    int s1 = s[i]-'0';
    int s2 = s[i+1]-'0';
    int s3 = s[i+2]-'0';
    int ss = s1*100 + s2*10 + s3;
    sa = min(sa,abs(753-ss));
  }
  cout << sa << endl;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall

N, M, L, *I = map(int, open(0).read().split())
ABC, ST = I[:3 * M], I[3 * M + 1:]

E = [[0] * N for _ in range(N)]
for a, b, c in zip(*[iter(ABC)] * 3):
    E[a - 1][b - 1] = E[b - 1][a - 1] = c

E = floyd_warshall(E)

for i in range(N):
    for j in range(N):
        E[i][j] = (E[i][j] <= L)

E = floyd_warshall(E)

INF = float("inf")

for s, t in zip(*[iter(ST)] * 2):
    a = E[s - 1][t - 1] - 1
    print(-1 if a == INF else int(a))


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

int main()
{
	int A[5][2],i,min=10,ans =0;
	for(i=0;i<5;i++){
		cin >>A[i][0];
		A[i][1]=A[i][0]%10;
		if((A[i][1]<min) && (A[i][1]>0)){
			min = A[i][1];
		}else if (A[i][1]==0){
			A[i][0]-=10;
		}
		ans+=A[i][0]-A[i][1]+10;
	}
	cout << ans-10+min;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define MAXN 52
#define MOD 1000000007
#define sz(a) static_cast<long long>(a.size())
#define INF 2000000000000000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
int n,sum,ans=INF;
int tong(int val,int coso){
	int i,j,dem=0;
	while (val>0){
		dem+=val%coso; val/=coso;
	}
	return dem;
}
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".INP","r",stdin); freopen(".OUT","w",stdout);
	cin>>n>>sum; int i,j,k,so=n-sum;
	if (so<0){
		cout<<-1; return 0;
	}
	if (so==0){
		cout<<n+1; return 0;
	}
	for (i=1;i<=sqrt(so);i++){
		if (so%i==0){
			if (tong(n,i+1)==sum) ans=min(ans,i+1);
			if (tong(n,so/i+1)==sum) ans=min(ans,so/i+1);
		}
	}
	if (ans==INF) cout<<-1;
	else cout<<ans;
}

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

using namespace std;

bool map[22][22] = {false};
int main(){
	int m;
	cin >> m;
	while(m != 0){
		int x,y;
		for(int i = 0; i < 22; i++){
			for(int j = 0; j < 22; j++){
				map[i][j] = false;
			}
		}

		for(int i = 0; i < m; i++){
			cin >> x >> y;
			map[x][y] = true;
		}

		int n;
		int ans = 0;
		cin >> n;
		x = y = 10;
		for(int i = 0; i < n; i++){
			char com;
			int move;
			cin >> com >> move;
			if(com == 'N'){
				for(int j = 1; j <= move; j++){
					if(map[x][y + j]){
						map[x][y + j] = false;
						ans++;
					}
				}
				y += move;
			}
			if(com == 'S'){
				for(int j = 1; j <= move; j++){
					if(map[x][y - j]){
						
						map[x][y - j] = false;
						ans++;
					}
				}
				y -= move;
			}
			if(com == 'E'){
				for(int j = 1; j <= move; j++){
					if(map[x + j][y]){
						
						map[x + j][y] = false;
						ans++;
					}
				}
				x += move;
			}
			if(com == 'W'){
				for(int j = 1; j <= move; j++){
					if(map[x - j][y]){
						
						map[x -j][y] = false;
						ans++;
					}
				}
				x -= move;
			}
		}
		if(m == ans){
			cout<< "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}

		cin >> m;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
    int x,y,a,i,b=0,c;
    scanf("%d %d",&x,&y);
    if(4*x<y)
        printf("No");
    else
    {
        for(i=1;i<=x;i++)
        {
            a=i*2+(x-i)*4;
            c=i*4+(x-i)*2;
            if(a==y || c==y)
                b=1;
        }
        if(b==1)
            printf("Yes");
        else
            printf("No");
    }
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int K, X;
  cin >> K >> X;
  int k = K - 1;
  for (int i = X - k; i < X + k; i++) {
    cout << i << " ";
  }
  cout << X + k << endl;
};


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string s;
    cin >> s;
    for(int i=0; i < s.size(); i++){
        if(s.at(i) == ','){
            s.at(i) = ' ';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline

class Node:
    def __init__(self):
        self.link = []
        self.costs = []
        self.check = False
        self.ans = -1

def main():
    V, E, r = map(int, input().split())

    nodes = [Node() for i in range(V)]

    for i in range(E):
        s, t, d = map(int, input().split())
        nodes[s].link.append(t)
        nodes[s].costs.append(d)
    
    q = []
    heapq.heappush(q, (0, r))
    while len(q) > 0:
        cost, num = heapq.heappop(q)
        # print(cost, num)
        node = nodes[num]
        if node.check:
            continue
        node.check = True
        node.ans = cost
        for next_num, p_cost in zip(node.link, node.costs):
            if not nodes[next_num].check:
                heapq.heappush(q, (cost + p_cost, next_num))
    
    for i in range(V):
        print(nodes[i].ans if nodes[i].ans != -1 else "INF")

if __name__ == "__main__":
    main()


Measured memory_bytes: 91948
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX_N 100
#define MAX_M 1000
#define keta 8

int main()
{
	int n,m;
	while(cin >> n >> m &&(n&&m))
	{
		string tosen[MAX_N];
		string kuji[MAX_M];
		int kin[MAX_N];
		REP(i,n)
		{
			cin >> tosen[i] >> kin[i];
		}
		REP(i,m)
		{
			cin >> kuji[i];
		}
		unsigned int uke=0;
		REP(i,n)
		{
			REP(j,m)
			{
				bool get=true;

				REP(k,keta)
				{
					if((tosen[i])[k]==kuji[j][k]||(tosen[i])[k]=='*')continue;
					get=false;
					break;
				}
				if(get) uke += kin[i];

			}
		}
		cout << uke << endl;

	}

	return 0;
}

Measured memory_bytes: 964
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N;
	cin >> N;
	vector<ll> An(N+1, 0);
	rep(i, N) cin >> An[i+1];

	ll cash = 1000;
	ll stock_num = 0;
	for (int i = 1; i < N; ++i)
	{
		stock_num = 0;
		if (An[i] < An[i+1]) {
			stock_num = cash / An[i];
		}
		cash += (An[i+1] - An[i]) * stock_num;
	}

	cout << cash << endl;
	return 0;
}

Measured memory_bytes: 3632
from sys import stdin
def main():
  from builtins import int, list, map, min
  readline = stdin.readline
  n, m = map(int, readline().split())
  data = [list(map(int, readline().split())) for _ in range(n)]
  data.sort(key = lambda x: x[0])
  purchased = 0
  amount = 0
  for a, b in data:
    t = min(m - purchased, b)
    amount += t * a
    purchased += t
    if purchased == m:
      break
  print(amount)
main()

Measured memory_bytes: 28952
# -*- coding: utf-8 -*-
#
# N = int(input())
#
# a = []
#
# for i in range(N):
#     a.append(input().split())
#
# Y = 0
#
# for figure, kind in a:
#
#     if kind == 'JPY':
#         Y += int(figure)
#     else:
#         figure = float(figure) * 380000.00000000
#         Y += figure
# print(Y)
#

import sys

N = int(input())

a = [i.strip().split() for i in sys.stdin.readlines()]

ans = 0

for b, c in a:
    if c == 'JPY':
        ans += int(b)
    else:
        ans += float(b) * 380000

print(ans)













Measured memory_bytes: 2940
/* ****GT_18**** */
//Motivational Source->FUHPD

#include<bits/stdc++.h>
#define	MIN(a,b,c)	min(min(a,b),c)
#define	MAX(a,b,c)	max(max(a,b),c)
#define ll          long long
#define itr         vector<ll int>::iterator
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;
struct disset
{
	int data,rank,parent;
};
int find_set(struct disset *sets,int node)
{
	if(sets[node].parent!=node)
	sets[node].parent=find_set(sets,sets[node].parent);
	return sets[node].parent;
}
void merge_set(struct disset *sets,int x,int y)
{
	int xparent=find_set(sets,x);
	int yparent=find_set(sets,y);

	if(sets[xparent].rank>sets[yparent].rank)
	sets[yparent].parent=xparent;
	else if(sets[xparent].rank<sets[yparent].rank)
	sets[xparent].parent=yparent;
	else
	{
		sets[xparent].parent=yparent;
		sets[yparent].rank++;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin>>n;
		vector<pii> x(n),y(n);
		vector<pair<ll,pii> > a;
		rep(i,0,n)
		{
			cin>>x[i].F>>y[i].F;
			x[i].S=i;
			y[i].S=i;
		}
		sort(all(x));
		sort(all(y));
		rep(i,1,n)
		{
			a.pb({x[i].F-x[i-1].F,{x[i].S,x[i-1].S}});
			a.pb({y[i].F-y[i-1].F,{y[i].S,y[i-1].S}});
		}
		sort(all(a));
		disset sets[n];
		rep(i,0,n)
		{
			sets[i].data=i;
			sets[i].parent=i;
			sets[i].rank=0;
		}
		ll ans=0;
		rep(i,0,sz(a))
		{
			if(find_set(sets,a[i].S.F)!=find_set(sets,a[i].S.S))
			{
				ans+=a[i].F;
				merge_set(sets,a[i].S.F,a[i].S.S);
			}
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 11632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
  }
  vector<vector<int> > dp(n, vector<int>(60));
  for (int i = 0; i < n; ++i) {
    dp[i][0] = a[i];
  }
  for (int j = 1; j < 60; ++j) {
    for (int i = 0; i < n; ++i) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  int pos = 0;
  for (int i = 0; i < 60; ++i) {
    if (k >> i & 1) {
      pos = dp[pos][i];
    }
  }
  cout << pos + 1 << endl;
  return 0;
}

Measured memory_bytes: 58640
S = str(input())

ans = [0] * 13
ans[0] = 1
MOD = 10**9 + 7

for i in S:
    dp = [0] * 13
    for j in range(13):
        dp[(j * 10) % 13] = ans[j] % MOD
    dp += dp
    if i == '?':
        for j in range(13):
            ans[j] = sum(dp[j+4:j+14])
    else:
        for j in range(13):
            ans[j] = dp[j + 13 - int(i)]

print(ans[5] % MOD)

Measured memory_bytes: 3188
import sys,math

def input():
    return sys.stdin.readline()[:-1]
def yakusuu(N):
    P = [1,N]
    for k in range(2,math.floor(math.sqrt(N))+1):
        if N % k == 0:
            P.append(k)
            P.append(N//k)
    return P
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def main():
    A, B = map(int,input().split())
    C = sorted(list(set(yakusuu(A))&set(yakusuu(B))))

    if len(C) == 1:
        print(1)
        exit(0)
    D = [1]
    for k in range(1,len(C)):
        f = 1
        for l in range(k):
            if gcd(C[k],C[l]) != 1:
                f = 0
                break
        if f == 1:
            D.append(C[k])
    print(len(D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 41840
n = gets.to_i
as = gets.split.map(&:to_i).sort!

nums = Hash.new(0)
ans = Array.new(as.last + 1, 0)
ans[0] = 0
res = 0

as.each do |a|
  nums[a] += 1
  ans[a] = 1
end

as.each do |a|
  next if ans[a] == 0
  res += 1 if nums[a] == 1

  a.step(as.last, a) do |i|
    ans[i] = 0
  end
end

puts res


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>s;
  a=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o')a++;
  }
  if(15-s.size()+a>=8)
  cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int h;
int f[10000][4]={};

bool check(int bit, int shift)
{
    if(bit>>shift & 1) return false;
    if(bit>>(shift+1) & 1) return false;
    return true;
}

int dp[10000][1<<4];
int dfs(int y, int b)
{
    if(dp[y][b]>=0) return dp[y][b];
    if(y==h-1) return 0;

    int nx = 0;
    rep(i,4) nx |= f[y+1][i]<<i;
    int ret = 0;
    // 0???
    ret = max(ret, dfs(y+1,nx));
    // 1???
    rep(i,3)if(check(b,i) && check(nx,i))
    {
        int t = nx;
        t |= 1<<i;
        t |= 1<<(i+1);
        ret = max(ret, dfs(y+1,t)+1);
    }
    // 2???
    if(b==0 && nx==0) ret = max(ret, dfs(y+1,15)+2);

    return dp[y][b] = ret;
}

int main()
{
    int n;
    cin >>h >>n;
    rep(i,n)
    {
        int x,y;
        cin >>x >>y;
        f[y][x] = 1;
    }

    int s = 0;
    rep(i,4) s |= f[0][i]<<i;

    memset(dp,-1,sizeof(dp));
    cout << dfs(0,s) << endl;
    return 0;
}

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

signed main(){
	int t,d,l;
	while(cin >> t >> d >> l,t){
		int ans = 0,cnt = 0;
		for(int i = 0;i < t;i++){
			int x;
			cin >> x;
			if(x >= l) cnt = d;
			if(cnt && i != t - 1){
				ans++;
				cnt--;
			}
		}
		cout << ans << endl;
	}
}


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

char *s;
bool error;

bool equation();
int64_t expr();
int64_t mul();
int64_t unary();
int64_t num();

bool consume(char c){
    if(*s != c) return false;
    ++s;
    return true;
}

bool equation(){
    error = false;
    int64_t lhs, rhs;
    lhs = expr();
    if(error || !consume('=')) return false;
    rhs = expr();
    if(error || *s != '\0') return false;
    return lhs == rhs;
}

int64_t expr(){
    if(error) return 0;
    int64_t value = mul();
    while(*s == '+' || *s == '-'){
        if(error) return 0;
        if(consume('+')) value += mul();
        else if(consume('-')) value -= mul();
    }
    return value;
}

int64_t mul(){
    if(error) return 0;
    int64_t value = unary();
    while(consume('*')){
        if(error) return 0;
        value *= unary();
    }
    return value;
}

int64_t unary(){
    if(error) return 0;
    int64_t value;
    if(consume('-')) return -unary();
    else if(consume('(')){
        value = expr();
        if(!consume(')')) error = true;
        return value;
    }
    else return num();
}

int64_t num(){
    if(error) return 0;
    int64_t value = 0;
    switch(*s){
    case '0':
        ++s;
        return 0;
    case '1':
        while(*s == '0' || *s == '1'){
            value = value * 2 + (*s - '0');
            ++s;
        }
        return value;
    default:
        error = true;
        return 0;
    }
}

int main(){
    char code[32], *ss = new char[32];
    map<char, int> decl;
    int cnt = 0;
    scanf("%s", code);
    for(int i=0;i < 32 && code[i] != '\0';++i){
        if('A' <= code[i] && code[i] <= 'Z' || 'a' <= code[i] && code[i] <= 'z'){
            if(decl.count(code[i]) == 0) decl[code[i]] = cnt++;
        }
    }

    if(cnt > 8){
        printf("0\n");
        return 0;
    }

    int ptn[] = {0, 1, 2, 3, 4, 5, 6, 7};
    int64_t ans = 0;
    
    do{
        int i;
        s = ss;
        for(i=0;i < 32 && code[i] != '\0';++i){
            if(decl.count(code[i])) s[i] = "01+-*()="[ptn[decl[code[i]]]];
            else s[i] = code[i];
        }
        for(;i<32;++i) s[i] = '\0';
        if(equation()) ++ans;
    }while(next_permutation(ptn, ptn + 8));

    int64_t fact[9];
    fact[0] = 1;
    for(int i=1;i<=8;++i) fact[i] = i * fact[i-1];
    printf("%" PRId64 "\n", ans / fact[8-cnt]);

    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
long long ret5(long long num){
  return num*num*num*num*num;
}
int main()
{
  int X;
  cin>>X;
  for(int i=-100;i<100000;i++){
    for(int j=-100;j<10000;j++){
      if((long long)ret5(i)==(long long)X+ret5(j)){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
  cout<<0;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
int a[101];
int i;
i=1;
a[1]=1;
while(scanf("%d",&a[i])!=EOF){
if(a[i]==0){
i--;
printf("%d\n",a[i]);
a[i]=0;
continue;
}
i++;
}

return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
///--//
int popcount(int n)
{
    int count = 0;
    while (n) {
        n &= (n - 1);
        count++;
    }
    return count;
}

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int n; cin>>n;
    string s; cin>>s;
    int sb=0;

    for(int i=0; i<n; i++){
        if( s[i] == '1') ++sb;
    }

    vector<int> f(2e5+10,0);
    for(int i=1; i<f.size(); i++){
        f[i]=f[i%(popcount(i))]+1;
    }

    vector<int> mods{sb-1, sb, sb+1};
    vector<vector<int>> modpow(n,vector<int>(3,1));
    for(int i=1 ; i<n; i++){
        for(int j=0; j<3; j++){
            if(mods[j] <=0 ) continue;
            modpow[i][j]=(modpow[i-1][j]*2)%mods[j];
        }
    }
    vector<int> modsum(3,0);
    reverse(s.begin(),s.end());
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            if(mods[j] <= 0) continue;
            modsum[j]+=(s[i] == '1')*modpow[i][j];
            modsum[j]%=mods[j];
        }
    }
    vector<int> ans(n);
    for(int i=0; i<n; i++){
        if( s[i] == '1'){
            if( sb == 1) {
                ans[i]=0;
                continue;
            }
            int x=modsum[0];
            x-=modpow[i][0];
            x+=mods[0];
            x%=mods[0];
            ans[i]=f[x]+1;
        }
        else{
            int x=modsum[2];
            x+=modpow[i][2];
            x%=mods[2];
            ans[i]=f[x]+1;
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0; i<n; i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 16016
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 19;
const int Q = 2e5 + 5;
const ll OO = 1e18;
const int mod = 1e9 + 7;

int n,a[N],ans;
multiset<pair<int,int> > s;

int main() {

    ios_base::sync_with_stdio(false);
    //cin.tie(0);

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        auto x = s.lower_bound({a[i],0});
        if(x==s.begin()) ++ans;
        else s.erase(*(--x));
        s.insert({a[i],i});
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdlib>
#define MAX_N 40
#define INF 400000
#define RATE 160802
using namespace std;

int dp[41][160802];

int n,ma,mb;
int a[41];
int b[41];
int c[41];
int res;
void solve()
{
    int xa,xb,cost;
    int pa,pb;
    int tmp;
    //memset(dp,0,sizeof(int));
    //for(int i = 0;i<RATE;i++)dp[0][i]=0;
    for(int i = 0;i<n;i++){
        xa = a[i];xb = b[i];cost = c[i];
        for(int j = 0;j<RATE;j++){
            dp[i+1][j]=dp[i][j];
            pa = j/401;
            pb = j%401;
            if(pa>400 || pb>400)continue;
            if(pa-xa<0 || pb-xb<0)continue;
            if(((pa-xa)!=0 ||(pb-xb)!=0) && dp[i][(pa-xa)*401+(pb-xb)]==0)continue;
            tmp = dp[i][(pa-xa)*401+(pb-xb)]+c[i];
            if(dp[i+1][j]==0)
                dp[i+1][j]=tmp;
            else{
                dp[i+1][j]=min(dp[i+1][j],tmp); 
                if(dp[i][j]!=0)dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }

        }
    }
    res = INF;
    for(int i = 1;i<=n;i++){
        for(int j = 0;j<RATE;j++){
            pa=j/401;pb=j%401;
            
            /*
            if(dp[i][j]!=0 && pa<10 && pb<10){
                cout<<pa<<" "<<pb<<" "<<j<<" "<<dp[i][j]<<endl;
            }
            */ 
            if(ma*pb==mb*pa && dp[i][j]!=0){
                res = min(res,dp[i][j]); 
            }
        }
    }
}

int main()
{
    cin>>n>>ma>>mb;
    for(int i = 0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    solve();
    if(res==INF)cout<<"-1"<<endl;
    else cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 25344
n, m = map(int, input().split())
x = [[0] * 2 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        x[b - 1][0] = 1
    elif b == n:
        x[a - 1][1] = 1
if [1, 1] in x:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 23412
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def xor0(x):
    if (x+1) % 4 == 0:
        return 0
    elif (x+1) % 2 == 0:
        return 1
    else:
        pair = (x+1) // 2
        if pair % 2 == 0:
            return x
        else:
            return x^1

def main():
    a, b = list(map(int,ipti().split()))
    am1 = max(a-1,0)

    am1_xor = xor0(am1)
    b_xor = xor0(b)

    print(am1_xor^b_xor)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n , a[N];
vector<int> e[N];

bool dfs(int x , int fa) {
    int w = 0;
    for (auto &y : e[x]) {
        if (y != fa && a[y] < a[x]) {
            w |= !dfs(y , x);
        }
    }
    return w;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d" , &a[i]);
    }
    for (int i = 1 ; i < n ; ++ i) {
        int x , y;
        scanf("%d%d" , &x , &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for (int i = 1 ; i <= n ; ++ i) {
        if (dfs(i , 0)) {
            printf("%d " , i);
        }
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1007;
struct nod
{
	int to,id;
	nod(int a,int b)
	{
		to=a;
		id=b;
	}
	nod(){}
};
int n,m,tim;
int vis[MAXN],can[MAXN][MAXN][2];
int u[MAXN*MAXN],v[MAXN*MAXN];
vector<nod> edge[MAXN];
void dfs(int now,int fa,int b,int f)
{
	vis[now]=tim; can[fa][now][f]=b;
	for(int i=0;i<edge[now].size();i++){
		int v=edge[now][i].to;
		if(vis[v]!=tim) dfs(v,fa,b,f);
	}
}
inline void solve(int now)
{
	tim++; vis[now]=tim;
	for(int i=0;i<edge[now].size();i++){
		int v=edge[now][i].to;
		if(vis[v]!=tim) dfs(edge[now][i].to,now,edge[now][i].id,0);
	}
	reverse(edge[now].begin(),edge[now].end());
	tim++; vis[now]=tim;
	for(int i=0;i<edge[now].size();i++){
		if(vis[edge[now][i].to]!=tim) dfs(edge[now][i].to,now,edge[now][i].id,1);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i];
		edge[u[i]].push_back(nod(v[i],i));
	}
	for(int i=1;i<=n;i++) solve(i);
	for(int i=1;i<=m;i++){
		if((can[v[i]][u[i]][0]!=0)^0^(can[u[i]][v[i]][0]!=i||can[u[i]][v[i]][1]!=i))
			cout<<("diff\n");
		else cout<<("same\n");
	}
}

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


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

    int ans = 0;
    for (int l=0; l<=k; l++) {
        for (int r=0; r<=k; r++) {
            if (l+r>n || l+r>k) break;
            vector<int> V;
            rep(i,l) V.push_back(a[i]);
            rep(i,r) V.push_back(a[n-i-1]);
            sort(V.begin(), V.end());

            int d = k-l-r;
            int tot = 0;
            rep(i,V.size()) {
                if (i < d && V[i]<0) continue;
                tot += V[i];
            }
            ans = max(ans, tot);
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"

if len(S) == 26:
    if S == alpha[::-1]:
        print(-1)
        exit()
    for i in reversed(range(25)):
        for j in reversed(range(i, 26)):
            if S[i] < S[j]:
                print(S[:i] + S[j])
                exit()
else:
    for x in alpha:
        if x not in S:
            print(S + x)
            break


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int n,m,ans,cnt;
string s1,s2;
int main()
{
	cin>>s1>>s2;
	if(s1==s2)
	{
	cout<<"Yes"<<endl;
	return 0;
	}
	s2=s2+s2;
	int p=s1.size();
	for(int i=0;i<p;i++)
	{
	bool flag=true;
	for(int j=0;j<p;j++)
    {
	if(s2[i+j]!=s1[j])
	flag=false;
    }	
    if(flag)
    {
cout<<"Yes"<<endl;
return 0; 
	}
	}
	cout<<"No"<<endl;
    return 0;
	 }

Measured memory_bytes: 256
io = STDIN
k=io.gets.to_i
ar=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts ar[k-1]


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
  int H, W;
  while(1){
  cin >> H >> W;
  if (H == 0 && W == 0)
   break;
    for(int j=1; j<=H; j++){
      for(int i=1; i<=W; i++){
        if(H > 2 && j > 1 && j < H && i > 1 && i < W)
         cout << '.';
         else
         cout << '#';
    }
    cout << endl;
  }
  cout << endl;
}
return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int h, w;
    pair<int, int> v[6];
    rep(i, 6){
        cin>>h>>w;
        if(h>w){
            swap(h, w);
        }
        v[i] = {h, w};
    }
    sort(v, v + 6);
    if(v[0] != v[1] || v[2] != v[3] || v[4] != v[5]){
        cout<<"no"<<endl;
    }else{
        if(v[0].first == v[2].first && v[2].second == v[4].second && v[4].first == v[0].second){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
}



Measured memory_bytes: 3212
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define all(v) 			((v).begin()), ((v).end())
#define sz(v) 			((int)((v).size()))
#define endl			"\n"

typedef long long ll;

void File()
{
	//freopen("output.txt", "w", stdout);
	freopen("coffee.in", "r", stdin);
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
const double pi = 2 * acos(0.0);
const int nn = 2e5 + 5;
const int oo = 0x3f3f3f3f;

int main()
{
	fast();
	int n;
	cin >> n;
	map<int, int> ans, ans1,lans;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		lans[x]++;
		if (i % 2 == 0)
			ans[x]++;
		else
			ans1[x]++;
	}
	if (sz(lans) == 1)
		return cout << n / 2 << endl, 0;
	ll mx[4] = {},tmp;
	for (auto it : ans)
	{
		if (it.second > mx[0])
			mx[0] = it.second, tmp = it.first;
	}
	for (auto it : ans1)
	{
		if (it.second > mx[1] && tmp != it.first)
			mx[1] = it.second;
	}
	ll sum[2] = {};
	tmp = 0;
	sum[0] = mx[0] + mx[1];
	for (auto it : ans1)
	{
		if (it.second > mx[2])
			mx[2] = it.second, tmp = it.first;
	}
	for (auto it : ans)
	{
		if (it.second > mx[3] && tmp != it.first)
			mx[3] = it.second;
	}
	sum[1] = mx[3] + mx[2];
	cout << n - max(sum[0], sum[1]) << endl;
#if _DEBUG
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#include <limits.h>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //問題文中の添え字が0-indexか1-indexか確認!

    ll n;
    std::cin>>n;
    std::vector<ll> a(n);
    rep(i,0,n){
        std::cin>>a[i];
    }
    ll ans=0;
    for(ll i=n-1;i>1;i--){
        if(a[i]==i+1){
            a[i]^=a[i-1];
            a[i-1]^=a[i];
            a[i]^=a[i-1];
            ans++;
        }
    }

    if(a[0]==1||a[1]==2){
        ans++;
    }
    std::cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll NON = -1e18;
vector<ll> lr(100000,-1e18);
vector<pair<ll,ll>> g[100000];

void dfs(int x,int par)
{
	for(auto i:g[x])
	{
		if(i.first==par)continue;
		
		if(lr[i.first]==NON)
		{
			lr[i.first] = lr[x] - i.second;
			dfs(i.first,x);
		}
		else
		{
			if(lr[i.first]-lr[x]!=-i.second)
			{
				cout<<"No"<<endl;
				exit(0);
			}
		}
		
	}
}


int main()
{
	int n,m;
	cin >> n >> m;
	for(int i = 0;i<m;i++)
	{
		ll l,r,d;
		cin >> l >> r >> d;
		l--;
		r--;
		g[r].emplace_back(l,d);
		g[l].emplace_back(r,-d);
	}
	for(int i = 0;i<n;i++)
	{
		if(lr[i]!=NON)continue;
		lr[i]=0;
		dfs(i,-1);
	}
	
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
#define NMAX 100005

int main(){
    string contest;
    cin>>contest;
    cout<< (contest == "ABC" ? "ARC" : "ABC");
    return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");

}

void insertionSort(int A[], int N){
  int j,i,v;
  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for(i=0; i<N; i++)
  scanf("%d",&A[i]);

  trace(A,N);
  insertionSort(A,N);

  return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string S;
	cin >> S;

	int K;
	cin >> K;

	char target = S[K - 1];
	for (int i = 0; i < N; i++) {
		if (S[i] != target)
			S[i] = '*';
	}
	
	cout << S << endl;

	return 0;
}


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

template <typename T>
T calc(T a, T b, T p) {
    if (b == 0) return 1;

    if (b % 2 == 0) {
		T d = calc(a, b / 2, p);
		return (d * d) % p;
    } else {
		return (a * calc(a, b - 1, p)) % p;
    }

    return 0;
}

template <typename T>
void ModConb(T& v, T& vi, ll mod) {
	v[0] = 1;
	vi[0] = 1;
	for (int i = 1; i < v.size(); i++) {
		v[i] = v[i - 1] * i;
		v[i] %= mod;

		vi[i] = calc(v[i], mod - 2, mod);
		vi[i] %= mod;
	}
}

int main() {
	const ll MOD = 1e9 + 7;
	ll N;
	cin >> N;
	vector<ll> a(N + 1);
	vector<int> cnt(N + 1, 0);
	int r, l;
	for (int i = 0; i < a.size(); i++) {
		cin >> a[i];
		if (++cnt[a[i]] > 1) r = i;
	}
	for (int i = 0; i < N; i++) {
		if (a[i] == a[r]) {
			l = i;
			break;
		}
	}

	vector<ll> v(N + 2);
	vector<ll> vi(N + 2);
	ModConb(v, vi, MOD);

	for (int k = 1; k <= N + 1; k++) {
		int x = N + 1, y = k;
		ll res = (((v[x] * vi[y]) % MOD) * vi[x - y]) % MOD;

		x = l + N - r;
		y = k - 1;
		ll tmp = 0;
		if (x >= y) tmp = (((v[x] * vi[y]) % MOD) * vi[x - y]) % MOD;

		res = (res - tmp + MOD) % MOD;
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
uintmax_t combination(unsigned int n, unsigned int r)
{
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i )
    {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}
 
int main()
{
    unsigned n,m;
    cin>>n>>m;
    uintmax_t ans=0;
    if(n>=2)ans+=combination(n,2);
    if(m>=2)ans+=combination(m,2);
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	ll N, K;
	cin >> N >> K;
	ll A1 = N - K * (N / K);
	ll A2 = abs(N - K * ((N / K) + 1));
	if (A1 < A2)cout << A1 << '\n';
	else cout << A2 << '\n';
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	bool CFound = false;
	for (char c : s) {
		if (c == 'C') CFound = true;
		if (CFound && c == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c = c-b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a = a-d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, k;

	string s;

	cin>>n>>k>>s;

	vll num;

	if(s[0]=='0') num.push_back(0);

	int num0=0;
	rep(i, n-1){
		if(s[i]!=s[i+1]){
			num.push_back(num0+1);
			num0=0;
		} else{
			num0++;
		}
	}
	num.push_back(num0+1);

	vll sum(num.size()+1, 0);

	rep(i, num.size()) sum[i+1]=sum[i]+num[i];

	ll ans=0;
	rep(i, sum.size()){
		if(i%2==0){
			int ptr=min((ll)num.size(), i+2*k+1);
			ans=max(ans, sum[ptr]-sum[i]);
		}
	}
	cout<<ans<<endl;
	//rep(i, sum.size()) cout<<sum[i]<<" ";
}

Measured memory_bytes: 2164
n = int(input())
a = []
for i in range(n):
	s,x = input().split()
	x = int(x)
	a.append([s,x])
gg = input()
f = 0
ans = 0
for i in range(n):
	if f: ans += a[i][1]	
	if a[i][0] == gg: f = 1
print(ans)	

Measured memory_bytes: 3064
#include <cstdio>

int max(int a, int b) {
	if (a > b) return a;
	else return b;
}
int min(int a, int b) {
	if (a < b) return a;
	else return b;
}
int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	int m = min(min(a, b), c);
	int M = max(max(a, b), c);
	printf("%d %d %d\n", m, (a + b + c) - (m + M), M);
}

Measured memory_bytes: 1024