akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// rep macro
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
// vector macro
#define all(v) v.begin(), v.end()
// math macro
#define lcm(a, b) a / __gcd(a, b) * b
// print macro
#define println(x) cout << x << endl
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
// pair macro
#define x first
#define y second
using pii = pair<int, int>;
using pdd = pair<double, double>;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m, vector<int>());
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i])
        {
            int sij; cin >> sij;
            s[i].push_back(sij - 1);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    int cnt = 0;
    bitrep(b, n)
    {
        bitset<10> bs(b);
        bool all_on = true;
        rep(i, m)
        {
            int switch_on = 0;
            rep(j, k[i])
            {
                if (bs[s[i][j]] == 1) { switch_on++; }
            }
            if (switch_on % 2 != p[i]) { all_on = false; break; }
        }
        if (all_on) cnt++;
    }
    cout << cnt << endl;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> hs;
    for (int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        hs.push_back(h);
    }
    sort(hs.begin(), hs.end(), [](int x, int y) { return x > y; } );
    int i = 0;
    for (; i < hs.size() && i < K; ++i) {}
    int64_t sum = 0;
    for (int j = i; j < hs.size(); ++j) {
        sum += hs[j];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
A=input()
char=len(A)-7
flag=0

if A[:7]=="keyence":
    flag=1

for i in range(len(A)-char):
    if A[:i]+A[i+char:]=="keyence":
        flag=1
    #print(A[:i]+A[i+char:])
if flag==1:
    print("YES")
else:
    print("NO")
    

Measured memory_bytes: 2940
import math

a, b, C = map(int, input().split())

S = a * b * math.sin(math.radians(C)) / 2
c = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C))) ** 0.5
L = a + b + c
h = b * math.sin(math.radians(C))

print(S)
print(L)
print(h)


Measured memory_bytes: 5716
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
	 int length[3];
	 int n;
	 cin>>n;
	while(n>0){
		cin>>length[0]>>length[1]>>length[2];
		sort(length,length+3);
		if (length[2]*length[2]==length[1]*length[1]+length[0]*length[0]){
			cout<<"YES"<<endl;
		}
		else cout<<"NO"<<endl;
		n--;
	}
	return 0;
}

Measured memory_bytes: 1168
#include<cstdio>
int z[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		if(b==z[a-1])
		printf("1\n");
		else
		printf("0\n");
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int cnt;
int n;
bool func(int num)
{
    if(num==2)return true;
    else if(num%2==0)return false;
    else if(num==1)return false;
    else
    {
        for(int i=3;i<=sqrt(num);i+=2)
        {
            if(num%i==0)return false;
        }
    }
    return true;
}
int main()
{
    while(cin>>n,n)
    {
        cnt=0;
        for(int i=n+1;i<=2*n;i++)
        {
            if(func(i))
            {
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
use proconio::input;
use std::cmp;
fn main() {
    input!{
        n: usize, m: usize, k: i64,
        _a: [i64; n],
        _b: [i64; m],
    }

    let mut a = vec![0; n+1];
    for i in 0..n {
        a[i + 1] = a[i] + _a[i];
    }

    let mut b = vec![0; m+1];
    for i in 0..m {
        b[i + 1] = b[i] + _b[i];
    }

    let mut j = m;
    let mut ans = 0;
    for i in 0..=n {
        if a[i] > k {
            break;
        }
        while b[j] > k - a[i] {
            j -= 1;
        }
        ans = cmp::max(ans, i + j);
    }
    println!("{}", ans);
}

Measured memory_bytes: 12372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, L; cin >> N >> L;
    vector<ll> a(N+1, 0);
    for(int i=1; i<=N; ++i) cin >> a[i];

    for(int i=1; i<N; ++i){
        if(a[i]+a[i+1] >= L){
            cout << "Possible" << endl;
            for(int j=1; j<i; ++j) cout << j << endl;
            for(int j=N-1; j>i; --j) cout << j << endl;
            cout << i << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;   
}

Measured memory_bytes: 1664
// D - Water Bottle
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	double a, b, x, ans = 0;
	cin >> a >> b >> x;
	x /= a;
	double r = a * b - x;
	if (x < a * b / 2.0) {
		double d = x * 2 / b;
		double c = sqrt(b * b + d * d);
		ans = acos(d / c) / acos(-1) * 180;
	} else {
		double c = sqrt(a * a + (r * 2.0 / a) * (r * 2.0 / a));
		ans = acos(a / c) / acos(-1) * 180;
	}

	cout << fixed << setprecision(15) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
    };

    let mut spf = vec![0; n + 1];
    for i in 0..n + 1 {
        spf[i] = i;
    }
    for p in 2.. {
        if p * p > n {
            break;
        }
        for i in (p..n + 1).step_by(p) {
            if spf[i] == i {
                spf[i] = p;
            }
        }
    }

    let mut ans = 0_usize;
    for i in 1..=n - 1 {
        let mut x = i;
        let mut map = std::collections::BTreeMap::new();
        while x != 1 {
            let p = spf[x];
            *map.entry(p).or_insert(0) += 1;
            x /= p;
        }

        let mut c = 1;
        for (_, v) in map {
            c *= v + 1;
        }
        ans += c;
    }
    println!("{}", ans);
}


Measured memory_bytes: 9924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) + "..." << endl;
  return 0;
}

Measured memory_bytes: 3632
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	s := getNextInt(scanner)

	for i := 0; i < k; i++ {
		fmt.Fprintln(writer, s)
	}
	for i := 0; i < n-k; i++ {
		if s == int(1e9) {
			fmt.Fprintln(writer, 1)
			continue
		}
		fmt.Fprintln(writer, s+1)
	}
}


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

int main(){
  long long int a,b,c,d;
  long long int ll,lr,rl,rr;
  long long int max1,max2;
  
  cin >> a >> b >> c >> d;
  
  ll = a*c;
  lr = a*d;
  rl = b*c;
  rr = b*d;
  
  max1 = max(ll,lr);
  max2 = max(rl,rr);
  
  cout << max(max1,max2);
  
  
 
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
using namespace std; 
int main() {
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int y[n];
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }
    
    int absf[n];
    for(int i = 0; i < n; i++){
        absf[i] = abs(x[i] - y[i]);
    }
    double d_1=0, d_2=0, d_3=0, d_inf=absf[0]; 
     
    for(int i = 0; i < n; i++){
        d_1 += absf[i];
    }
    cout << d_1 << endl;
     
    for(int i = 0; i < n; i++){
        d_2 += pow(absf[i], 2);
    }
    printf("%.6lf\n", sqrt(d_2));
     
    for(int i = 0; i < n; i++){
        d_3 += pow(absf[i], 3);
    }
    printf("%.6lf\n", cbrt(d_3));
     
    for(int i = 1; i < n; i++){
        if(d_inf < absf[i]){
            d_inf = absf[i];
        }
    }
    cout << d_inf << endl;
    
    return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, t) for(ll i = 0; i < t; i++)

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

int main() {
    ll n;
    cin >> n;
    
    ll sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    if (sum == 1)
        sum = 10;
    cout << sum << endl;
    

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N;
    ll ans=0;
    string S;
    bool F;
int main(){
    cin>>A>>B;
    if(A>=10)cout<<B;
    else cout<<B+100*(10-A);



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

bool** table;

void func(int n,int m,int a){

	int height,p,q;

	for(int i = 0; i < m; i++){
		scanf("%d %d %d",&height,&p,&q);
		if(p < q){
			table[height][p] = true;
		}else{
			table[height][q] = true;
		}
	}

	int calc[n+1];
	for(int i = 1; i <= n; i++)calc[i] = i;

	for(int i = 1000; i >= 1; i--){
		for(int k = 1; k <= n-1; k++){
			if(table[i][k] == true){
				swap(calc[k],calc[k+1]);
			}
		}
	}

	int ans;

	for(int i = 1; i <= n; i++){
		if(calc[i] == a){
			ans = i;
			break;
		}
	}
	printf("%d\n",ans);
}

int main(){

	int n,m,a;

	table = new bool*[1001];
	for(int i = 0; i < 1001; i++){
		table[i] = new bool[101];
	}

	while(true){
		scanf("%d %d %d",&n,&m,&a);
		if(n == 0 && m == 0 && a == 0)break;

		for(int i = 1; i <= 1000; i++){
			for(int k = 1;k <= 100; k++)table[i][k] = false;
		}

		func(n,m,a);
	}

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << 'A' << b[0] << 'C' << endl;
	return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
int s[100005];
int t;
int n;
int q;

int my_bsearch(int key){
    int left, right, mid;
    left = 0;
    right = n;
    while (left < right){
        mid = (left+right)/2;
        if (s[mid] == key){
            return mid;
        }else if(s[mid] < key){
            left = mid + 1;
        }else if(s[mid] > key){
            right = mid;
        }
    }
    return -1;
}

int main(void){
    char input[1005];
    char direction[10] = "NSEW"; 
    int flag[4] = {0};
    scanf("%s", input);
    int len = strlen(input);
    for (int j = 0; j < len; j++){
        for (int i = 0; i < 4; i++){
            if (direction[i] == input[j]){
                flag[i] = 1;
            }
        }
    }

    if (flag[0] ^ flag[1]){
        printf("No\n");
        return 0;
    }
    if (flag[2] ^ flag[3]){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
    

}

Measured memory_bytes: 128
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]
import itertools

A = []
M = []
for i in range(1, m+1):
    M.append(i)
for team in itertools.combinations_with_replacement(M, n):
    A.append(team)
    
B = [0]*len(A)
for i in range(q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    for j in range(len(A)):
        if A[j][b-1] - A[j][a-1] == c:
            B[j] += d

print(max(B))



Measured memory_bytes: 25076
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[100005];
map<ll,ll> help;
int main(){
    ll n,m;
    cin>>n;
    ll li=1e18;
    ll ans=1ll;
    ll f=1;
    for(ll i=1;i<=n;i++)cin>>a[i],help[a[i]]++;
    if(help[0])cout<<0;
    else{
    for(ll i=1;i<=n;i++){
    	if(ans>li/a[i]){
    		f=0;
    		ans=-1;
    		break;
		}
		else{
			ans*=a[i];
		}
	}	
	
	
	
	cout<<ans;
    
	
	
   }
	
	
	
	  	  
    
}

Measured memory_bytes: 10624
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(answer049c(s))
}

fun answer049c(s: String): String {
    val list = listOf("dreameraser", "dreamerase", "eraser", "dreamer", "erase", "dream")
    var t = s
    loop@ while (t.isNotBlank()) {
        for (word in list) {
            if (t.length >= word.length && t.take(word.length) == word) {
                t = t.drop(word.length)
                continue@loop
            }
        }
        return "NO"
    }
    return "YES"
}

Measured memory_bytes: 120620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,k,a[100005],ans,kk,f;f=1;k=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        k=max(k,a[i]);
        if(a[i]>k)
        f=i;
    }
    kk=(k+1)/2;
    ans=a[1];
    for(i=2;i<=n;i++)
    {
        if((abs(a[i]-kk)<=abs(kk-ans))&&i!=f)
            ans=a[i];
    }
    printf("%d %d",k,ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int	main(void)
{
	int n,a,min=1000000,max=-1000000,i;
	long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
        if(a<min) min=a;
        if(a>max) max=a;
		sum+=a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return	0;
}

Measured memory_bytes: 600
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       int a = scan.nextInt();
       int b = scan.nextInt();
       int c = scan.nextInt();
       int d = scan.nextInt();
       while(a > 0 && c > 0) {
           c -= b;
           if(c <= 0) {
               System.out.println("Yes");
               break;
           }
           a -= d;
           if(a <= 0) {
               System.out.println("No");
               break;
           }
       }


    }
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ; 
#define rep(i,n) for(ll i = 0; i<n; ++i)
#define pb push_back
const ll MAXN = 2e5 + 7; 
ll c[MAXN];
ll cnt[MAXN]; 
vector<int> *ver[MAXN];
vector<int> g[MAXN];
ll sze[MAXN]; 


int main(int argc, char const *argv[])
{
    int a[3]; 
    for(int i = 0; i<3; ++i)
    	cin >> a[i]; 
    sort(a, a + 3); 
    int ans = a[2] *10 + a[1] + a[0]; 
    cout << ans; 
    return 0;  

}


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

using namespace std;

const int N = 200000 + 77;
long long a , b , c;
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> a >> b >> c;
   c = min(c , a + b + 1);
   cout << c + b;

   return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 100005
#define MD 10 
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
struct edge{
	int to,nxt;
}e[MN<<2];
int f[MD+1][MN],c[MN],h[MN];
int n,m,q,x,y,u,d,cnt;
inline void ins(int x,int y){
	e[++cnt].to=y;e[cnt].nxt=h[x];h[x]=cnt;
}
int main()
{
	n=in();m=in();
	for (int i=1;i<=m;++i){
		x=in();y=in();
		ins(x,y);ins(y,x);
	}q=in();
	for (int i=1;i<=q;++i){
		u=in();d=in();c[i]=in();
		f[d][u]=i;
	}
	for (int j=MD-1;j>=0;--j)
	for (int i=1;i<=n;++i){
		f[j][i]=max(f[j][i],f[j+1][i]);
		for (int k=h[i];k;k=e[k].nxt){
			int v=e[k].to;
			f[j][v]=max(f[j][v],f[j+1][i]);
		}
	}
	for (int i=1;i<=n;++i) 
	printf("%d\n",c[f[0][i]]);return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(b % a == 0) return a;
  else gcd(b % a, a);
}

int main(){
  int N;
  cin >> N;
  
  int i;
  int a[N];
  for(i=0; i<N; i++)
    cin >> a[i];
  
  sort(a, a+N);
  int answer = a[0];
  for(i=1; i<N; i++)
    answer = gcd(answer, a[i]);
  
  cout << answer << endl;
    
  return 0;
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ary = new int[5];
            bool ft = true;
            for(int i = 0; i<5; i++)
            {
                ary[i] = int.Parse(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());
            
                if(ary[4]-ary[0]>k)
                {
                    ft = false;
                }
            
            switch(ft)
            {
                case false:
                    Console.Write(":(");
                    break;

                case true:
                    Console.Write("Yay!");
                    break;
            }


            //System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
typedef long long lint;
const int N=1005;
const int M=2e5+5;
int n,m;
bool irp[N][N],lnk[N][N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int rt,cnt,fir[N];
	bool col[N];
	std::vector <int> g[N];
	struct edge{
		int fr,to;
	}eg[M];

	inline void add(const int a,const int b){
		g[a].push_back(b);
		eg[++cnt]=(edge){a,b};
	}

	void dfs(const int x){
		col[x]=lnk[rt][x]=1;
		for(std::vector <int> ::iterator it=g[x].begin(); it!=g[x].end(); ++it){
			if(!col[*it]) dfs(*it);
		}
	}

	void set(const int x){
		rt=x;
		memset(col+1,0,n*sizeof(col[0]));
		col[x]=1;
		for(std::vector <int> ::iterator it=g[x].begin(); it!=g[x].end(); ++it){
			if(col[*it]) irp[x][*it]=1;
			else dfs(*it);
		}
		std::reverse(g[x].begin(),g[x].end());
		memset(col+1,0,n*sizeof(col[0]));
		col[x]=1;
		for(std::vector <int> ::iterator it=g[x].begin(); it!=g[x].end(); ++it){
			if(col[*it]) irp[x][*it]=1;
			else dfs(*it);
		}
	}
}

int main(){
	n=nxi(),m=nxi();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
	}
	for(int i=1; i<=n; ++i){
		G::set(i);
	}
	for(int i=1; i<=m; ++i){
		int x=G::eg[i].fr,y=G::eg[i].to;
		puts(irp[x][y]^lnk[y][x]?"diff":"same");
	}
	return 0;
}


Measured memory_bytes: 6272
/*  ex9_2
    potter0723sw  */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    int i = 0,ans = 0;
    //入力を受け取る配列をヌル文字分まで確保
    char color,block[SIZE + 1];
    //最初のノードの指す先
    node *first = NULL;
    scanf("%s", block);
    //blockを順番に見ていってもしスタックに何も入っていないかスタックの先頭と同じ色だったらスタックに入れていく。
    while(block[i] != '\0'){
        if(first == NULL || first->elem == block[i]){
            push(&first, block[i]);
        }else{
            pop(&first);
            ans += 2;
        }
        i++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4920
using System;
using System.Linq;
class c
{
  public static void Main()
  {
    int[] abc=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(abc);
    if((abc[0]+abc[1])==abc[2])Console.WriteLine("Yes");
    else Console.WriteLine("No");
    
  }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int parent[200005];
int sie[200005];
int find(int i) {
    if(parent[i]==i)
        return i;
    else
        return parent[i]=find(parent[i]);
}
void union_set(int i,int j) {
    int x=find(i);
    int y=find(j);
    if(sie[x]<sie[y])swap(x,y);
    parent[y]=x;
    if(x!=y)sie[x]+=sie[y];
}


int main()
{
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++){
    parent[i]=i;
    sie[i]=1;
    }
    while(m--){
    int l,r;cin>>l>>r;
    union_set(l,r);
    }
    int mx=1;
    for(int i=1;i<=n;i++)
    mx=max(mx,sie[find(i)]);
    cout<<mx<<endl;
    
    
    return 0;
}

Measured memory_bytes: 5164
N, M = gets.split.map(&:to_i)
a_list = gets.split.map(&:to_i)
bc_list = M.times.map { gets.split.map(&:to_i) }

a_to_count = Hash.new { 0 }
a_list.each do |a|
  a_to_count[a] += 1
end
bc_list.each do |(b, c)|
  a_to_count[c] += b
end
sorted = a_to_count.sort_by { |k, _| -k }
sum = 0
rest = N
sorted.each do |(a, c)|
  c = [rest, c].min
  sum += a * c
  rest -= c
  break if rest == 0
end
puts sum


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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

ll mod;
int N;
int dp[6060][10010];
int base = 3030;

int main() {
	scanf("%d%lld", &N, &mod);
	dp[0][base] = 1;
	for(int i=0;i<=3*N;i++) {
		for(int j=1;j<=3 && i+j<=3*N;j++) {
			ll mul = 1;
			if(j >= 2) mul = (3*N-i-1);
			if(j >= 3) mul *= (3*N-i-2);
			for(int a=base-N;a<=base+3*N;a++) {
				if(dp[i][a]) {
					int na = a + (j == 1) - (j == 2);
					dp[i+j][na] = (dp[i+j][na] + dp[i][a] * mul) % mod;
				}
			}
		}
	}
	int ans = 0;
	for(int i=0;i<=3*N;i+=3) ans = (ans + dp[3*N][base+i]) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 233984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,m; cin>>n>>m;
  vector<ll> x(m);
  vector<ll> y(m);
  rep(i, m) {
    cin>>x[i]>>y[i];
    x[i]--; y[i]--;
  }

  vector<bool> flg(n, false);
  flg[0] = true;
  vector<ll> a(n, 1);
  rep(i, m) {
    if (a[x[i]] <= 0) continue;

    if (flg[x[i]]) flg[y[i]] = true;
    a[x[i]]--;
    if (a[x[i]] <= 0) flg[x[i]] = false;
    a[y[i]]++;
  }

  ll ans = 0;
  rep(i, n) {
    if (flg[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5552
#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 ld long double
#define pb push_back
#define eb emplace_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 llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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;
};

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

  int N;
  cin >> N;
  string S;
  cin >> S;

  int x = 0;
  int ans = 0;
  for (char ch: S) {
    if (ch == 'I') x++;
    if (ch == 'D') x--;
    chmax(ans, x);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v,w;
int main(){

	cin >> n >> k;
	v.resize(n+10);
	w.resize(n+10);
	for(int i =0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	ll dp[100005];
    for(int j=0;j<=1e5;j++){
           dp[j]=0;           
    }

	for(int i =0;i<n;i++){
		for(int j=k;j>=0;j--){
			if(!j){
				dp[j] = 0;
				continue;
			}

			if(w[i]<=j){
				dp[j] =  max(dp[j-w[i]]+v[i],dp[j]);
			}
		}

	}
	cout << dp[k];


	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;


int n,q;
struct cc {
        i64 s;
        i64 x;
        cc(i64 _s, i64 _x) {
                s = _s;
                x = _x;
        }
};
bool cmp(cc &l, cc &r) {
        return l.s < r.s;
}
vector<cc> in;
vector<cc> out;

i64 dd[200005];

//multiset<i64> b;
priority_queue<i64, vector<i64>, greater<i64> > bb;
priority_queue<i64, vector<i64>, greater<i64> > ld;


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

        cin >> n >> q;
        REP(i,n) {
                i64 s,t,x;
                cin >> s >> t >> x;
                in.push_back(cc(s-x, x));
                out.push_back(cc(t-x, x));
        }
        REP(i,q)
                cin >> dd[i];

        sort(in.begin(), in.end(), cmp);
        sort(out.begin(), out.end(), cmp);

        int inidx = 0;
        int outidx = 0;
        REP(i,q) {
                i64 d = dd[i];

                while (inidx < n && in[inidx].s <= d) {
                        //b.insert(in[inidx].x);
                        bb.push(in[inidx].x);
                        inidx++;
                }
                while (outidx < n && out[outidx].s <= d) {
                        //auto it = b.find(out[outidx].x);
                        //b.erase(it);
                        ld.push(out[outidx].x);
                        outidx++;
                }

                while (bb.size() > 0 &&  ld.size() > 0 && bb.top() == ld.top()) {
                        bb.pop();
                        ld.pop();
                }

                if (bb.size() == 0) {
                        cout << -1 << endl;
                } else {
                        //cout << *min_element(b.begin(), b.end()) << endl;
                        cout << bb.top() << endl;
                }
        }


        return 0;
}


Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
class DAG
{
    int n;
    vector<vector<int>> adj;
    vector<int> visited;
    vector<int> dp;
    void dfs(int v)
    {
        if (visited[v] == 2)
        {
            is_acyclic = false;
            return;
        }
        else if (!visited[v])
        {
            visited[v] = 2;
            for (int s : adj[v])
            {
                dfs(s);
            }
            visited[v] = 1;
            sorted.push_back(v);
        }
    }

public:
    vector<int> sorted;
    DAG(int n) : n(n), adj(n), visited(n), dp(n, 0) {}
    bool is_acyclic = true;
    int longest_path = 0;

    //add directed link node a to node b
    void add_arc(int a, int b)
    {
        assert(0 <= a && a < n && 0 <= b && b < n);
        adj[a].push_back(b);
    }

    void tsort()
    {
        for (int i = 0; i < n; i++)
        {
            if (!visited[i])
                dfs(i);
        }
        reverse(sorted.begin(), sorted.end());
    }
    void build()
    {
        for (auto i : sorted)
        {
            for (auto j : adj[i])
            {
                dp[j] = max(dp[j], dp[i] + 1);
                longest_path = max(longest_path, dp[j]);
            }
        }
    }
};

int main(){
int n,m;
cin >> n >> m;
DAG dag(n+10);
rep(i,m){
    int x,y;
    cin >> x >> y;
    dag.add_arc(x,y);
}
dag.tsort();
dag.build();
cout << dag.longest_path << endl;
return 0;
}

Measured memory_bytes: 8188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    int ans = 0;
    FOR(i,a,b+1){
        string s = to_string(i);
        string t = s; REVERSE(t);
        if(s==t) ans++;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 3005;
const int MM = 1000000007;

int N, M;
int T[MX][MX][2], U[MX];
int vst[MX][MX], t = 0;
// int C[MX*2][MX*2];

int add(int x, int y){ return x+y >= MM? x+y-MM : x+y; }

int main()
{
	scanf("%d%d", &N, &M); N--; M--;
	/*
	for(int i = 0; i < MX*2; i++){
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	} // */
	T[0][0][1] = 1;
	for(int i = 1; i <= N; i++) T[0][i][0] = 1;
	for(int i = 1; i <= M; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 0; k < 2; k++){
				T[i][j][0] = add(T[i-1][j][0], T[i-1][j][0]);
				T[i][j][1] = add(T[i-1][j][1], T[i-1][j][1]);
				if( j ){
					T[i][j][1] = add(T[i][j][1], T[i-1][j-1][1]);
					T[i][j][0] = add(T[i][j][0], T[i-1][j-1][0]);
				}
				if( j < N ){
					T[i][j][1] = add(T[i][j][1], T[i-1][j+1][1]);
					if( j == 0 ) T[i][j][1] = add(T[i][j][1], T[i-1][j+1][0]);
					else T[i][j][0] = add(T[i][j][0], T[i-1][j+1][0]);
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= N; i++) ans = add(ans, T[M][i][1]);
	printf("%lld\n", ans*4 % MM);
}


Measured memory_bytes: 71168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)
#define MOD 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 1;
    vector<int> count(26, 0);
    
    for(int i = 0; i < n; i++) {
        count[s[i]-'a']++;
    }

    rep(i, 0, count.size()) {
        if(count[i] == 0) {
            continue;
        }
        ans *= count[i]+1;
        ans %= MOD;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 512
#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;
    cin>>n;
    vector<int>a(n*3);
    rep(i,n*3){
        cin>>a[i];
    }
    sort(a.rbegin(),a.rend());
    ll cnt=0,ans=0;
    rep(i,n*3){
        if(i%2==1){ans+=a[i]; cnt++;}
        if(cnt==n)break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 3005;

string s, t;
int dp[MAX_N][MAX_N];
int dpPrevI[MAX_N][MAX_N], dpPrevJ[MAX_N][MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> s >> t;

	for (int i = 0; i < MAX_N; i++)
		for (int j = 0; j < MAX_N; j++)
		{
			dpPrevI[i][j] = -1;
			dpPrevJ[i][j] = -1;
		}

	for (int i = 0; i <= (int)s.length(); i++)
		for (int j = 0; j <= (int)t.length(); j++)
		{
			if (i == 0 || j == 0)
				continue;
			else if (s[i - 1] == t[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
				dpPrevI[i][j] = i - 1;
				dpPrevJ[i][j] = j - 1;
			}
			else
			{
				if (dp[i - 1][j] >= dp[i][j - 1])
				{
					dp[i][j] = dp[i - 1][j];
					dpPrevI[i][j] = dpPrevI[i - 1][j];
					dpPrevJ[i][j] = dpPrevJ[i - 1][j];
				}
				else
				{
					dp[i][j] = dp[i][j - 1];
					dpPrevI[i][j] = dpPrevI[i][j - 1];
					dpPrevJ[i][j] = dpPrevJ[i][j - 1];
				}
			}
		}

	int maxRes = dp[(int)s.length()][(int)t.length()], maxI = (int)s.length(), maxJ = (int)t.length();
	vector<char> result;
	result.reserve(maxRes);
	while (maxI != -1)
	{
		result.push_back(s[maxI]);
		int nextMaxI = dpPrevI[maxI][maxJ], nextMaxJ = dpPrevJ[maxI][maxJ];
		maxI = nextMaxI; maxJ = nextMaxJ;
	}
	reverse(result.begin(), result.end());
	result.pop_back();
	for (char c : result)
		cout << c;
	cout << endl;
}

Measured memory_bytes: 106112
#include <iostream>
#include <cstdio>
int k;
long long ans;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main(void)
{
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            int q=gcd(i,j);
            for(int l=1;l<=k;l++)
            {
                ans+=gcd(q,l);
            }
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;



int wa(int n) {

	int result = 0;

	while (n > 0) {
		result += n % 10;
		n /= 10;
	}

	return result;


}


int main()
{
    
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<long long int> p(a);
	vector<long long int> q(b);
	vector<long long int> r(c);

	for (auto& i : p)cin >> i;
	for (auto& i : q)cin >> i;
	for (auto& i : r)cin >> i;




	sort(p.begin(), p.end(), greater<long long int>());
	sort(q.begin(), q.end(),greater<long long int>());
	
	for (int i = 0; i < x; i++) {
		r.push_back(p[i]);
	}

	for (int i = 0; i < y; i++) {
		r.push_back(q[i]);
	}

	sort(r.begin(), r.end(), greater<long long int>());

	long long int ans = 0;

	for (int i = 0; i < x + y; i++) {
		ans += r[i];
	}

	cout << ans << endl;
	



	return 0;

}




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

int n, m;

int main(){
  cin >> n >> m;
  int left = 0, right = n;
  rep(i, m){
    int l, r;
    cin >> l >> r;
    l--;
    left = max(l, left);
    right = min(r, right);
  }
  cout << max(right - left, 0) << endl;
  return 0;
}


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

int main() {
    string O, E;
    cin >> O >> E;
    if (O.length() == E.length()){
        for (int i = 0; i < O.length(); i++){
            cout << O[i] << E[i];
        }
    }
    else{
        for (int i = 0; i < E.length(); i++){
            cout << O[i] << E[i];
        }
        cout << O[O.length() - 1];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

vector<int> Eratosthenes(ll n){
  vector<int> res(n+1,1);
  res[0] = res[1] = 0;
  for(ll i=2; i*i<=n; i++) if(res[i]){
    for(ll j=2; i*j<=n; j++) res[i*j] = 0;
  }
  return res;
}

int main(){
  ll n; cin >> n;
  vector<int> is_prime = Eratosthenes(55555);
  vector<ll> ans;
  ll cnt = 0;
  for(ll i=1; 5*i+1<=55555; i++){
    if(is_prime[5*i+1]){
      ans.push_back(5*i+1);
      cnt++;
      if(cnt==n) break;
    }
  }
  REP(i,cnt){
    cout << ans[i];
    if(i==cnt-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

struct Item
{
  int w;
  long long v;
};

int main()
{
  int n, W;
  cin >> n >> W;
  Item items[n];
  for (int i = 0; i < n; ++i)
    cin >> items[i].w >> items[i].v;
  long long dp[n+1][W+1];
  for (int i = 0; i < W + 1; ++i)
    dp[0][i] = 0LL;
  for (int i = 1; i < n+1; ++i)
    for (int j = 0; j < W+1; ++j)
      dp[i][j] = max(dp[i-1][j], (j >= items[i-1].w) ? dp[i-1][j-items[i-1].w] + items[i-1].v : 0LL);
  cout << dp[n][W] << '\n';
}


Measured memory_bytes: 79104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	if(n*500 >= m){
		cout << "Yes" << endl;
	}else{
		cout << "No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1e15
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;


int dx[] = { -1, 0, 0, 1};
int dy[] = {0, 1, -1, 0};




int32_t main()
{
	std::ios::sync_with_stdio(false);

#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif

	int n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3608