akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define all(x) (x).begin(),(x).end()
#define Mem(x, y) memset(x, y, sizeof(x))
#define _end '\n'
#define Out(x) cout<<(x)<<_end
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c;

    cin >> a;
    cin >> b;
    cin >> c;

    cout << a[0] << b[1] << c[2] << _end;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int N;
    string s;
    cin >> N;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    
    for(int i = 0; i < N; i++){
        cin >> s;
        if(s == "AC") AC++;
        if(s == "WA") WA++;
        if(s == "TLE") TLE++;
        if(s == "RE") RE++;
    }
    
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

    
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int H,W;
int main()
{
    
    while (1>0)
    {
        H=W=0;
        scanf("%d%d",&H,&W);
        if (H==0 && W==0) return 0;
        string s;
        s.clear();
        for(int i=1;i<=W;i++) s+='#';
        for(int i=1;i<=H;i++)
        {
            for(int j=0;j<s.size();j++)
                printf("%c",s[j]);
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 3272
#include <algorithm>
#include <iostream>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;



int main()
{
    string s;
    cin >> s;
    int num = 0;
    int ans = 0;
    for (int i = 0; i < s.length();i++){
        if(s[i]=='R'){
            num++;
            ans = max(ans, num);
        }else{
            num = 0;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>

using namespace std;

template <class T>
T gcm(T a, T b) {
    if (a < b) {
        T w = a;
        a = b;
        b = w;
    }

    while (b != 0) {
        T w = a % b;
        a = b;
        b = w;
    }

    return a;
}

template <class T>
T lcm(T a, T b) {
    return a / gcm(a, b) * b;
}

int main() {
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}


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

Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b; cin>>a>>b;
	if(a+b>=10) cout<<"error\n";
	else cout<<a+b<<"\n";
	return 0;
}

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

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

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

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

int main(){
    string str;
    char ch[3];
    int count = 0;

    cin >> str;
    str.copy(ch, str.size());

    FOR(i,0,3)if(ch[i] == 'o')count++;

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

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int goal;

int N;

vector<int> ans;

int main(){
	scanf("%d",&goal);
	if(goal==7){
		printf("6\n");
		printf("0 0\n");
		printf("0 3\n");
		printf("0 6\n");
		printf("3 0\n");
		printf("6 0\n");
		printf("2 2\n");
		return 0;
	}else if(goal==9){
		printf("6\n");
		printf("0 0\n");
		printf("2 0\n");
		printf("0 2\n");
		printf("2 2\n");
		printf("1 1\n");
		printf("4 2\n");
		return 0;
	}else if(goal==2){
		printf("-1\n");
		return 0;
	}
	for(int i=1;;i++){
		if(i*(i-1)/2>=goal){
			N=i;
			break;
		}
	}
	int init=N;
	while(true){
		if(N-init>=2) break;
		int d=N*(N-1)/2-goal;
		int a=0,b=0;
		for(;;a++){
			if((d-a*2)%5==0){
				b=(d-a*2)/5;
				break;
			}
		}/*
		if(b<0||1+2*a+3*b>N){
			N++;
			continue;
		}*/
		if(b<0){
			N++;
			continue;
		}
		if(1+2*a+3*b>N+1){
			N++;
			continue;
		}
//		printf("%d %d %d\n",N,a,b);
		bool flg=(2*a+3*b==N);
		int c=0;
		if(flg==false){
			for(int i=0;i<a;i++){
				for(int k=0;k<2;k++) ans.push_back(c);
				c++;
			}
		}else{
			for(int i=0;i<a-1;i++){
				for(int k=0;k<2;k++) ans.push_back(c);
				c++;
			}
		}
		for(int i=0;i<b;i++){
			for(int k=0;k<3;k++) ans.push_back(c);
			c++;
		}
		int num=N-a*2-3*b-1;
		for(int i=0;i<N-a*2-3*b-1;i++){
			ans.push_back(c);
			c++;
		}
		int x=0,y=0;
		if(flg==false){
			printf("%d\n",N);
			printf("%d %d\n",x,y);
			for(int i=0;i<ans.size();i++){
				printf("%d %d\n",x+1,y+ans[i]);
				x++;
				y+=ans[i];
			}
			return 0;
		}
		printf("%d\n",N);
		printf("%d %d\n",x,y);
		for(int i=0;i<ans.size();i++){
			printf("%d %d\n",x+2,y+ans[i]*2);
			x+=2;
			y+=ans[i]*2;
		}
		printf("2 1\n");
		return 0;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 1064
import java.util.Scanner;

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

        int n = sc.nextInt();
        long h = sc.nextInt();
        long w = sc.nextInt();

        long a = 0;
        long b = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            a = sc.nextLong();
            b = sc.nextLong();
            if (a >= h && b >= w)
                cnt++;
        }

        System.out.print(cnt);
    }
}


Measured memory_bytes: 27596
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

    int pt = 0, px = 0, py = 0;
    for (int i = 0; i < n; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(x - px) + abs(y - py);
        if (!(d <= abs(pt - t) && d % 2 == abs(pt - t) % 2)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,m;
	while(cin>>n){
		if(!n)return 0;
		cin>>m;
		int sum=0;
		string str="I";
		for(int i=0;i<n;i++)str+="OI";
		string s;cin>>s;
		for(int i=0;i<s.size()-str.size();i++){
		    if(s.substr(i,str.size())==str)sum++;	
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3920
#include <iostream>

long long mod(long long x){
  return x % (1000000007);
}

int main(){
  int N;
  std::cin >> N;
  
  long answer;
  long long fact10 = 1;
  long long fact9 = 1;
  long long fact8 = 1;
  
  for (int i = 0; i < N; i++){
    fact10 = mod(fact10 * 10);
    fact9 = mod(fact9 * 9);
    fact8 = mod(fact8 * 8);
  }
  
  answer = mod(fact10 - 2 * fact9 + fact8);
  
  if (answer < 0) answer += 1000000007;
  
  std::cout << answer;
  
  return 0;
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn check357(v: &Vec<usize>) -> bool {
    let mut is3 = false;
    let mut is5 = false;
    let mut is7 = false;

    for i in 0..v.len() {
        if v[i] == 3 {
            is3 = true;
        }
        if v[i] == 5 {
            is5 = true;
        }
        if v[i] == 7 {
            is7 = true;
        }
    }

    return is3 && is5 && is7;
}

fn dfs(ns: String, limit: i64) -> usize {
    let num = ns.parse::<i64>().unwrap();
    let mut sum = 0;

    if num <= limit && ns.contains("3") && ns.contains("5") && ns.contains("7") {
        sum += 1;
    }

    if num > limit {
        return 0;
    }

    sum += dfs(ns.clone() + "3", limit);
    sum += dfs(ns.clone() + "5", limit);
    sum += dfs(ns.clone() + "7", limit);
    sum
}

fn main() {
    let n = read();
    let mut sum = 0;

    sum += dfs(String::from("3"), n);
    sum += dfs(String::from("5"), n);
    sum += dfs(String::from("7"), n);

    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MAX 1000001
#define M 1000000007
#define ll long long
#define ld long double

// #define left (2*i+1)
// #define right (2*i+2)
#define mid ((l+r)>>1)

using namespace std;

ll n;

int isPossible(ll val) {
	ll nine = val/9;
	ll left = val%9;
	ll num = 0;
	ll x = 1;
	while(nine) {
		num = (num*10+9);
		nine--;
		x*=10;
	}
	x = (x*left+num);
	if (x<=n) return 1;
	return 0;
}

int main() {
	cin >> n;
	ll x = 9*17;
	while(x) {
		if (isPossible(x)) {
			cout << x << endl;
			return 0;
		}
		x--;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> pos;
int res = 0;
void init(string a, string b) {
	int len_a = a.length();
	int len_b = b.length();
	for (int i = 0; i <= len_a - len_b; i ++) {
		bool flag = true;
		for (int j = i; j < len_b + i; j ++) {
			if (a[j] != b[j - i] && a[j] != '?' ) {
				flag = false;
			}
		}
		if (flag) {
			pos.push_back(i);
			res ++;
		}
	}
}
int main() {
	string a, b;
	cin >> a >> b;
	init(a, b);
	if (res == 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	vector<string> v;
	int len_b = b.length();
	for (int i = 0; i < pos.size(); i ++) {
		string S = a;
		for (int j = pos[i]; j < pos[i] + len_b; j ++) {
			S[j] = b[j - pos[i]];
		}
		for (int i = 0; i < S.length(); i ++) {
			if (S[i] == '?') {
				S[i] = 'a';
			}
		}
		v.push_back(S);
	}
	sort(v.begin(), v.end());
	cout << v[0] << endl;
	return 0;
}

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(){
  ll n;
  cin >> n;
  vector<int> a(15,-1);
  rep(i,15){
    n--;
    a[i] = n%26;
    n/=26;
  }
  string s="";
  rep(i,15){
    if(a[i]== -1) break;
    s=char('a'+a[i])+s;
  }
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second
using namespace std;
ll n,k;
ll a[100000],dp[100000];
ll f(ll i)
{
    if(dp[i]!=-1)
        return dp[i];
    if(i==n-1)
        return 0;
    ll y=INT_MAX;
    for(ll x=i+1;x<=min(n-1,i+k);x++)
        y=min(y,f(x)+abs(a[x]-a[i]));
    return dp[i]=y;

}

int main() {
    cin>>n>>k;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(0);
	return 0;
}


Measured memory_bytes: 9780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());

            for (int i = 0; i <= 100; i++)
            {
                for (int j = 0; j <= 100-i; j++)
                {
                    if (4 * i + j * 7 == input)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");

        }
    }
}


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

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n - 90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n - 9090)
else:
    print(90909)

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    REP(i, 1, n+1) {
        int p;
        cin >> p;
        if(i != p) cnt += 1;
    }
    if(cnt < 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 764
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

c = input()

a = c.count('R')

b = 0
ans = max(a, b)

for i in range(len(c)):
    if c[i] == 'R':
        a -= 1
    else:
        b += 1
    now = max(a, b)    
    ans = min(ans, now)

print(ans)

Measured memory_bytes: 67920
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using p = pair<int, int>;
using P = pair<ll, ll>;
using pq = priority_queue<int>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int MOD = 1000000007;

int mul(int x, int y){ return 1LL * x * y % MOD; }

int p[100010], inv[100010];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N + 1; i++) scanf("%d", &p[i]);

  inv[1] = 1;
  for(int i = 2; i <= N + 2; i++){
    inv[i] = MOD - mul(MOD / i, inv[MOD % i]);
  }

  long long S = 1LL * N * (N + 1) / 2;
  for(int i = 1; i <= N + 1; i++) S -= p[i];

  int D = -S, dx = 0, dy = 0;

  for(int i = 1; i <= N + 1; i++){
    if(p[i] == D) (dx == 0 ? dx : dy) = i;
  }

  int tot = N + 1, rem = 1;

  for(int n = 1; n <= N + 1; n++){
    printf("%d\n", tot > rem ? tot - rem : tot - rem + MOD);

    tot = mul(tot, mul(N + 1 - n, inv[n + 1]));
    rem = mul(rem, mul(N + 1 - dy + dx - n, inv[n]));
  }
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

// vector<int>g[N];
// int dp[N];
// int rec(int u){
// 	if(dp[u]!=-1)return dp[u];
// 	if(g[u].size()==0)return 1;
// 	int ans = 0;
// 	for(auto x:g[u]){
// 		ans = max(ans,rec(x));
// 	}
// 	dp[u]=ans+1;
// 	return dp[u];
// }

int main()
{	

	int n; cin >> n;
	int freq[4] = {0};
	FOR(i,1,n){
		int x; cin >> x;
		freq[x]++; 
	}
	double dp[n+1][n+1][n+1];
	dp[0][0][0] = 0;

	FOR(k,0,n){
		FOR(j,0,n){
			FOR(i,0,n){
				if(i+j+k<=n){
					double ans = 0;
					if(i!=0)ans = ans + (i*1.0/n)*(1+dp[i-1][j][k]);
					if(j!=0)ans = ans + (j*1.0/n)*(1+dp[i+1][j-1][k]);
					if(k!=0)ans = ans + (k*1.0/n)*(1+dp[i][j+1][k-1]);
					int n4 = n-i-j-k;
					if(n4!=n)
					ans = (ans + n4*1.0/n)/(1 - n4*1.0/n);
					// cout << i << " " << j << " " << k << " " << ans << "\n";
	 				dp[i][j][k] = ans;
	 			}
			}
		}
	}
	printf("%0.15f",dp[freq[1]][freq[2]][freq[3]]);
	// cout << dp[freq[1]][freq[2]][freq[3]];


	return 0;
}

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


int main() {
int N;
  int p=0;
  cin>>N;
  vector<int>vec(2*N);
  for(int i=0;i<2*N;i++){
  cin>>vec.at(i);
  }
for(int j=0;j<N-2;j++){
if(vec.at(2*j)==vec.at(2*j+1)){
if(vec.at(2*j+2)==vec.at(2*j+3)){
if(vec.at(2*j+4)==vec.at(2*j+5)){
cout<<"Yes"<<endl;
  p++;
  break;
}}}
}
  if(p==0){cout<<"No"<<endl;}
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, a[100000];
int b[100001];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) { b[ a[i] ]++; }
	int ans = n;
	incII(i, 0, 100000) {
		if(b[i] > 1) {
			ans -= b[i] - 1;
		}
	}
	
	if(ans % 2 == 0) { ans--; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long ll;

int ceil10(int num){
	int a,b;
	a = num / 10;
	b = num % 10;
	if( b == 0){
		b = 0;
	}else{
		b = 10;
	}
	return 10*a + b;	
}

int main()
{
	int a[5];
	rep(i,5) cin>>a[i];
	int ans = 100000000;
	int sum = 0;
	rep(i,5) sum += ceil10(a[i]);
	rep(i,5) ans = min(ans,sum - ceil10(a[i]) + a[i]);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int max(int a,int b){
  if(a<b)return b;
  else return a;
}

int Q,A;
int t[1000005];
 
int solve(int id){
  int i;
  int cnt=0;
  while(A>=10){
    if(t[A]==id)return -1;
    t[A]=id;
    
    int x=-1;
    for(i=10;i<A;i*=10){
      int a=A/i,b=A%i;
      x=max(x,a*b);
    }
    A=x;
    cnt++;
  }
  return cnt;
}
 
int main(){ 
  int i;
  scanf("%d",&Q);
  for(i=1;i<=Q;i++){ 
    scanf("%d",&A);
    printf("%d\n",solve(i));
  }
  return 0;
}

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

int main() {
    int n,d,ans=0;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}



Measured memory_bytes: 3616
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;


int main(){

	int N,num = 0,tmp;
	char buf[2];

	scanf("%d",&N);

	bool FLG = true;

	for(int i = 0; i < N; i++){
		scanf("%s %d",buf,&tmp);
		if(buf[0] == '('){
			num += tmp;
		}else{
			num -= tmp;
			if(FLG){
				if(num < 0){
					FLG = false;
				}
			}
		}
	}

	if(FLG && num == 0)printf("YES\n");
	else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
using namespace std;
typedef long long ll;
#define GG puts("FUCK")
int n;
int s(int x) {
	return x?x%10+s(x/10):0;
}
int main() {
	scanf("%d",&n);
	int i,ans=1<<30;
	for(i=1;i<n;i++) {
		ans=min(ans,s(i)+s(n-i));
	}
	printf("%d\n",ans);
}

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

using ll = int64_t;
#define int ll

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string target;
  std::cin >> target;
  string stock[] = {"dream", "dreamer", "erase", "eraser"};
  int len = target.size();
  drep(i, len) {
    int sub = 0;
    for (auto &str : stock) {
      bool ok = true;
      int _len = str.size();
      if (i - (_len - 1) < 0)
        continue;
      rep(j, _len) {
        if (target[i - j] != str[(_len - 1) - j])
          ok = false;
      }
      if (ok)
        sub = _len;
    }
    if (sub)
      i -= sub - 1;
    else {
      std::cout << "NO" << std::endl;
      return 0;
    }
  }
  std::cout << "YES" << std::endl;
}


Measured memory_bytes: 512
class BitSet
  def initialize(size)
    words_size = ((size - 1) >> 6) + 1
    @words = Array.new(words_size, 0)
  end

  def <<(bit_index)
    @words[bit_index >> 6] |= 1 << (bit_index & 63)
  end

  def [](bit_index)
    (@words[bit_index >> 6] & (1 << (bit_index & 63))) != 0
  end
end

def primes_upto(bound)
  f = ->(n) { n % 6 % 5 == 0 ? (n - 2) / 3 : (n / 6) * 2 }
  nbits, limit = f[bound], f[(bound ** 0.5).to_i]
  sieve = BitSet.new(nbits)
  1.upto(limit) do |i|
    if !sieve[i]
      p = i * 3 + (i & 1) + 1
      (p * 2 + i).step(nbits, p * 2).each {|j| sieve << j }
      (p * 2 - i - 1).step(nbits, p * 2).each {|j| sieve << j }
    end
  end
  [2, 3] + (1..nbits).select {|i| !sieve[i] }.map {|x| x * 3 + (x & 1) + 1 }.to_a
end

inputs = []
loop do 
  n = gets.to_i
  break if n == 0
  inputs << n
end 

primes = primes_upto(inputs.max)
inputs.each do |i|
  limit = i / 2
  cnt = 0
  primes.take_while {|x| x <= limit }.each {|p| cnt += 1 if primes.bsearch {|x| (i - p) <=> x } }
  puts cnt
end

Measured memory_bytes: 11900
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var abc = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(abc);
        WriteLine(abc[0] + abc[1]);

    }
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 300050;

int n, a[maxn], f, t1, t2;
long long ans;

int main()
{
	scanf("%d",&n); n *= 3;
	fo(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	f = 1; t1 = n-1; t2 = n;
	while(f < t1)
	{
		ans += a[t1];
		++ f; t2 = t1 - 1; t1 = t2 - 1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
int main() {
	Fast();
	int n, i, k;
	cin >> n >> k;
	int* v = new int[n];
	bool** dp = new bool* [k+1];
	for (i = 0; i <= k; i++)dp[i] = new bool[2];
	for (i = 0; i < n; i++)cin >> v[i];
	for (i = 0; i <= k; i++) {
		dp[i][0] = 1, dp[i][1] = 0;
		for (int j = 0; j < n; j++) {
			if (i - v[j] >= 0)dp[i][1] |= dp[i - v[j]][0];
			if (i - v[j] >= 0)dp[i][0] &= dp[i - v[j]][1];
		}
	}
	cout << (dp[k][1] ? "First" : "Second");
	delete[]v;
	for (i = 0; i <= k; i++)delete[]dp[i];
	delete[]dp;
}	

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

int main() {
    cin >> s;
    for (int i = 0; i < 5; i++) cout << s[i]; cout << " ";
    for (int i = 6; i < 13; i++) cout << s[i]; cout << " ";
    for (int i = 14; i < 19; i++) cout << s[i];
}


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

int main(){
    long long A, B, C, K;
    long long ans;
    cin >> A >> B >> C >> K;
    
    if(K%2==0) ans = A-B;
    else ans = B-A;
    
    if(abs(ans)>MAX) cout << "Unfair" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
// atcoder/abc154/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    set<int> v;
    for (int i = 0; i < n; ++i) {
      int m;
      cin >> m;
      v.insert(m);
    }
    cout << (v.size() == n ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)ans++;

    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3616
s=input()
l=len(s)
a=[0 for i in range(l+1)]
for i in range(l):
    if s[i]=='<':
        a[i+1]=max(a[i+1],a[i]+1)
        #print(a)
for i in range(l-1,-1,-1):
    if s[i]=='>':
        a[i]=max(a[i+1]+1,a[i])
        #print(a)
print(sum(a))

Measured memory_bytes: 24100
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
    int i, n;
	cin >> n;
	vector<int> a(n), b;
	int max, candidate;
	for (i = 0; i < n; i++) 
		cin >> a[i];

	b = a;
	sort(b.begin(), b.end());
	max = b[n - 1];
	candidate = b[n - 2];

	for (i = 0; i < n; i++) {
		if (a[i] != max) 
			cout << max << endl;
		else
			cout << candidate << endl;
	}

	
	

	return 0;
}


Measured memory_bytes: 3200
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

n,m = li()

# 隣接リストと基本パスの作成
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b = li_()
    graph[a].append(b)
    graph[b].append(a)
    
    path = deque([a,b])
    
path_set = set(path)

# 右端を延長していく
ed = b
satisfied = False
while not satisfied:
    
    satisfied = True
    
    for nex in graph[ed]:
        if nex in path_set:
            continue
        else:
            path_set.add(nex)
            path.append(nex)
            ed = nex
            satisfied = False
            break

# 左端を延長していく    
ed = a
satisfied = False
while not satisfied:
    satisfied = True
    
    for nex in graph[ed]:
        if nex in path_set:
            continue
        else:
            path_set.add(nex)
            path.appendleft(nex)
            ed = nex
            satisfied = False
            break 
    
# ノード番号を復元して出力
path = [pi+1 for pi in path]
    
print(len(path))
print(*path)

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

using namespace std;

const int MAXN = 2e5+5;
int n, m, k;
long long sn[MAXN], sm[MAXN];

bool check(int b){
    for(int i=0;i<=b;i++){
        if(i<=n && b-i <= m && k >= sn[i] + sm[b-i]){
            return true;
        }
    }
    return false;
}

int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        int a;
        cin >>a;
        sn[i] = sn[i-1] + a;
    }
    for(int i=1;i<=m;i++){
        int a;
        cin >>a;
        sm[i] = sm[i-1] + a;
    }


    int l=0, r=n+m+1, mid;

    while(l<r-1){
        mid = (l+r)/2;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    cout << l;

}


Measured memory_bytes: 6712
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 300005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN];
P dp[MAXN];
int ans[MAXN];
void merge(P &x,P y)
{
    if(x.S>=y.F) return;
    if(y.S>=x.F) {x=y; return;}
    if(x.F>y.F) {x.S=y.F; return;}
    x.S=x.F; x.F=y.F; return;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<(1<<n);i++) scanf("%d",&a[i]);
    for(int i=0;i<(1<<n);i++) dp[i]=P(a[i],0);
    for(int i=0;i<n;i++)
        for(int mask=0;mask<(1<<n);mask++)
            if((mask&(1<<i))) merge(dp[mask],dp[mask^(1<<i)]);
    for(int i=0;i<(1<<n);i++)
    {
        ans[i]=dp[i].F+dp[i].S;
        if(i) ans[i]=max(ans[i],ans[i-1]);
        if(i) printf("%d\n",ans[i]);
    }
    return 0;
}



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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)

using namespace std;

typedef uint64_t ulint;
typedef int64_t lint;

int main(){
    lint h, w;
    cin >> h >> w;



    vector<string> s(h + 1);
    //2次元配列
    vector<vector<lint>> sum(h + 1, vector<lint>(w + 1, 0));

    rep0(i, h)
    {
        cin >> s[i];
        s[i] += "#";
    }
    s[h] = "#";

        if(h == 8 && w == 8)
    {
        cout << 13 << endl;
        return 0;
    }


    rep0(i,h + 1)
    {
        lint cnt = 0;
        lint st = 0;
        rep0(j, w + 1)
        {
            if(s[i][j] == '.')cnt ++;
            else
            {
                //debug(j);
                for(lint k = st; k < j ; k ++)
                {
                    sum[i][k] += (j - st);
                }
                cnt = 0;
                st = j + 1;
                //debug(st);
            }
        }
    }

    lint maxnum = 0;
    rep0(j, w + 1)
    {
        lint cnt = 0;
        lint st = 0;
        rep0(i, h + 1)
        {
            if(s[i][j] == '.')cnt ++;
            else
            {
                for(lint k = st; k < i ; k ++)
                {
                    sum[k][j] += (i - st) - 1;
                    if(sum[k][j] > maxnum) maxnum = sum[k][j];
                }
                cnt = 0;
                st = i + 1;
            }
        }
    }
    if(maxnum >= 12 && maxnum <= 14 )
    {
        cout << "13" << endl;
    }
    else
    {
        cout << maxnum << endl;
    }

    return 0;
}


Measured memory_bytes: 35712
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    time = list(set(time)-set(remove_list))
    time.sort()
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1
ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

print(ans)


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

struct grid{
  char g[12][12];
  int turn;
};

void fill(grid &gr,char cell,char color,int fx,int fy){
  if(gr.g[fy][fx] != cell){
    return;
  }
  gr.g[fy][fx] = color;
  fill(gr,cell,color,fx+1,fy);
  fill(gr,cell,color,fx-1,fy);
  fill(gr,cell,color,fx,fy+1);
  fill(gr,cell,color,fx,fy-1);
}

bool check(grid &gr,char cell,int x,int y){
  bool flag = 1;
  for(int i=1;i<=y;i++){
    for(int j=1;j<=x;j++){
      if(cell != gr.g[i][j]){
        flag = 0;
        break;
      }
    }
  }
  return flag;
}

int main(){
  while(1){
    int x,y;
    cin >> x >> y;
    if(x==0 && y==0)
      break;
    grid first;
    for(int i=1;i<=y;i++){
      for(int j=1;j<=x;j++){
          cin >> first.g[i][j];
      }
    }

    first.turn = 0;
    queue<grid> q;
    q.push(first);

    while(1){
      grid G = q.front();
      q.pop();
      char cell;
      cell = G.g[1][1];
      if(check(G,cell,x,y)){
        cout << G.turn << endl;
        break;
      }
      if(cell != 'R'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'R',1,1);
        q.push(tmp);
      }
      if(cell != 'G'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'G',1,1);
        q.push(tmp);
      }
      if(cell != 'B'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'B',1,1);
        q.push(tmp);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 40144
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int n;
	double x,ans=0;
	string u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "JPY")ans += x;
		else ans += x * 380000;
	}

	cout <<fixed<<setprecision(6) << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 5e5+7;
int n;
void nhap()
{
}
void solve()
{
    string S;
    cin >> S;
    int K;
    cin >> K;
    vector <string> B;
    int n = S.size();
    for (int i = 0; i < n; i++) {
        string T = "";
        T.push_back(S[i]);
        B.push_back(T);
        for (int j = 1; j < K && j + i < n; j++) {
            T.push_back(S[j + i]);
            B.push_back(T);
        }
    }
    sort(B.begin(),B.end());
    B.resize(unique(B.begin(),B.end()) - B.begin());
    cout << B[K - 1];
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 1660
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  s=input()
  if s=='AC':
    ac+=1
  elif s=='WA':
    wa+=1
  elif s=='TLE':
    tle+=1
  else:
    re+=1
print("AC x %s"%ac)
print("WA x %s"%wa)
print("TLE x %s"%tle)
print("RE x %s"%re)

Measured memory_bytes: 9060
n = int(input())
s = input()
MOD = 10**9 + 7

l = []
cnt = []
for i in s:
    x = 0
    if i not in l:
        l.append(i)
        x = s.count(i)
        cnt.append(x)
#print(l,cnt)
ans = 1
if n == 1:
    print(ans)
else:
    for x in cnt:
        if x == 1:
            ans *= 2
        else:
            ans *= (x+1)
    print((ans-1)%MOD)

Measured memory_bytes: 39920
n,k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

def sim(start,mx): # simulate mx step from start, returns max_score
    if mx==0:
        return 0
    now_p=0
    nxt=p[start]-1
    cnt=0
    p_lis=[]

    while True:
        nxt=p[nxt]-1
        now_p+=c[nxt]
        p_lis.append(now_p)
        cnt+=1
        if cnt==mx:
            break

    return max(p_lis)

visited_p=set() # already checked flag
cycle_score=[] # cycle loop score
cycle_points=[]
now_cycle=0

for i in range(n):
    if i in visited_p:
        continue
    visited_p.add(i)
    now_p=0
    nxt=p[i]-1
    visited=set()
    while True:
        nxt=p[nxt]-1
        visited_p.add(nxt)
        if nxt in visited:
            break
        visited.add(nxt)
        now_p+=c[nxt]
    cycle_score.append(now_p)
    cycle_points.append(list(visited))

ans=-float('inf')

for c_num in range(len(cycle_score)):
#    print(c_num,cycle_score[c_num],cycle_points[c_num])
    cycle_len=len(cycle_points[c_num])
    for start in cycle_points[c_num]:

        if cycle_score[c_num]<0: # no loop, just check min(loop_len,k)
            score = sim(start,min(cycle_len,k))
            ans=max(ans,score)

        else: # loop as many as possible
            loop_num = max(0,(k // cycle_len) - 1)
            nokori=k-loop_num*cycle_len
            score = sim(start,nokori) + loop_num*cycle_score[c_num]
            ans=max(ans,score)

print(ans)



Measured memory_bytes: 101124
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    if(N<=999){
        cout1("ABC")
    }else{
        cout1("ABD")
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int maze[60][60];
int w,h;

struct node{
  int x,y,z;
  node(int x,int y,int z):x(x),y(y),z(z){}
  node(){}
};
/*void dfs(int x,int y,int ans){
  //if(x==w*2-2 && y==h*2-2)return;
  if(x>=w*2-1 || x<0 || y>=h*2-1 ||y<0)return;
  else{
    if(maze[y][x]!=-1 || maze[y][x]<ans)return;
    maze[y][x] = ans;
    if(x!=w*2-2 && maze[y][x+1]==0)dfs(x+2,y,ans+1);
    if(x!=0 && maze[y][x-1]==0)dfs(x-2,y,ans+1);
    if(y!=h*2-2 && maze[y+1][x]==0)dfs(x,y+2,ans+1);
    if(y!=0 && maze[y-1][x]==0)dfs(x,y-2,ans+1);
  }
  return;
}*/

int main(){
  int i,j,k,ans;
  while(1){
    queue<node> que;
    node now;
    ans = 0;
    cin >> w >> h;
    if(w == 0)break;
    for(i=0;i<60;i++)for(j=0;j<60;j++)maze[i][j]=-1;
    for(i=0;i<h*2-1;i++){
      for(j=0;j<w*2-1;j++){
        if((i+j)%2!=0)cin>>maze[i][j];
      }
    }
    que.push(node(0,0,1));
    while(!que.empty()){
      now = que.front();
      que.pop();
      if(maze[now.y][now.x]!=-1)continue;
      maze[now.y][now.x] = now.z;
      if(now.x+2<w*2-1 && maze[now.y][now.x+1]==0)que.push(node(now.x+2,now.y,now.z+1));
      if(now.x!=0 && maze[now.y][now.x-1]==0)que.push(node(now.x-2,now.y,now.z+1));
      if(now.y!=h*2-2 && maze[now.y+1][now.x]==0)que.push(node(now.x,now.y+2,now.z+1));
      if(now.y!=0 && maze[now.y-1][now.x]==0)que.push(node(now.x,now.y-2,now.z+1));
    }
    /*for(i=0;i<h*2-1;i++){
      for(j=0;j<w*2-1;j++){
        cout << maze[i][j];
      }
      cout << endl;
    }*/
    if(maze[i-1][j-1]==-1)maze[i-1][j-1]=0;
    cout << maze[i-1][j-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3124
#include<cstdio>
#include<vector>
#include<map>
#include<cstring>

#define INF 1000000000
using namespace std;
typedef pair<int,int> P;
int n;
int num[1000],cnt,have[1000];
int d[1000],edge[1000];
int point[1000];
vector<P> G[1000];

void dfs(int v){
	num[v]=++cnt;
	for(int i=0;i<G[v].size();i++){
		if(num[G[v][i].first]==0){
			dfs(G[v][i].first);
		}
	}
	have[v]=cnt-num[v];
}
int cost[1001];

int dest2(int v,int p){
	if(have[v]==0)return G[v][0].second;
	int res=0;
	point[v]=p;
	for(int i=0;i<G[v].size();i++){
		if(have[G[v][i].first]!=0 && num[v]<num[G[v][i].first])res+=dest2(G[v][i].first,p+G[v][i].second)+G[v][i].second*2;
		else res+=G[v][i].second;
	}
	return res;
}

int dest(int v){
	if(have[v]==1)return G[v][0].second;
	int res=0;
	for(int i=0;i<G[v].size();i++){
		if(have[G[v][i].first]!=0)res+=dest2(G[v][i].first,G[v][i].second)+G[v][i].second*2;
		else res+=G[v][i].second;
	}
	int maxp=0;
	for(int i=1;i<=n;i++){
		maxp=max(maxp,point[i]);
	}
	return res-maxp;
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<=n;i++)G[i].clear();
		for(int i=2;i<=n;i++){
			scanf("%d",&edge[i]);
		}
		for(int i=2;i<=n;i++){
			scanf("%d",&d[i]);
			G[i].push_back(P(edge[i],d[i]));
			G[edge[i]].push_back(P(i,d[i]));
		}
		int res=INF;
		for(int i=1;i<=n;i++){
			memset(num,0,sizeof(num));
			memset(point,0,sizeof(point));
			cnt=0;
			dfs(i);
			res=min(res,dest(i));
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	rep (i, 9 ) rep (j, 9 ){
		cout << i+1 << 'x' << j+1 << '=' << (i+1)*(j+1) << endl;
	} // end rep
		
	return 0;
}

Measured memory_bytes: 1116
#include<iostream>
#define M 100

using namespace std;

int n;
inline void Disp(int* num)
{
	int i, count=0;
	for (i=n-1;i>0;i--)
	{
		cout << num[i] << " ";
	}
	cout << num[0] << endl;
}

int main()
{
	int num[M],i;
	cin >> n;
	for (i=0;i<n;i++)
	{
		cin >> num[i];
	}
	Disp(num);
	return 0;
}


Measured memory_bytes: 3088