akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

bool check(string sub, string t) {
	for (int i = 0; i < t.size(); i++) {
		if (sub[i] != t[i]) {
			if (sub[i] != '?') return false;
		}
	}
	return true;
}
int main() {
	string ss, t; cin >> ss >> t;

	if (t.size() > ss.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	else {
		for (int index = ss.size() - t.size(); index >= 0; index--) {
			string sub = ss.substr(index, t.size());
			if (check(sub, t)) {
				for (int i = index; i < index + t.size(); i++) {
					ss[i] = t[i - index];
				}
				for (int i = 0; i < ss.size(); i++) {
					if (ss[i] == '?') ss[i] = 'a';
				}
				cout << ss << endl;
				return 0;
			}
		}
	}

	cout << "UNRESTORABLE" << endl;
}

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

namespace ABC
{
    class ABC172B
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            String s = Console.ReadLine();
            String t = Console.ReadLine();

            int c = 0;
            for (int i = 0; i < s.Length; ++i)
            {
                if (s[i] != t[i])
                {
                    ++c;
                }
            }

            Console.WriteLine(c);



#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }

        static long RL()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] RLa(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=998244353;
const int N=1e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int32_t main()
{
    IOS;
    int n,x,y;
    cin>>n>>x>>y;
    if((y-x)%2==0)
    {
        cout<<(y-x)/2<<endl;
        return 0;
    }
    int k=x-1;
    int ans=k;
    int z=y-k;
    if(z!=1)
    {
        ans++;
        z--;
        ans+=(z-1)/2;
    }
    
    int k1=n-y;
    int ans1=k1;
    int k2=x+k1;
    if(k2!=n)
    {
        k2++;
        ans1++;
        ans1+=(n-k2)/2;
    }
    cout<<min(ans,ans1)<<endl;

}

Measured memory_bytes: 256
import sys
from collections import defaultdict
dic = defaultdict(list)
s = input()
t = input()
n = len(s)
for i in range(n):
    dic[s[i]].append(i+1)

#print(dic)

for i in t:
    if dic[i]==[]:
        print(-1)
        sys.exit()
        
ans = dic[t[0]][0]

if len(t)==1:
    print(ans)
    sys.exit()

count=0
#print(ans)
for i in range(1, len(t)):
    #print("ans:{}, count:{}, n:{}".format(ans, count, n))
    if ans >= dic[t[i]][-1]:
        count += 1
        ans = dic[t[i]][0]
    elif ans < dic[t[i]][0]:
        ans = dic[t[i]][0]
    else:
        sm = 0
        la = len(dic[t[i]])-1
        while sm+1<la:
            mi = (sm + la)//2
            if ans >= dic[t[i]][mi]:
                sm = mi
            else:
                la = mi
        ans = dic[t[i]][la]
#print("ans:{}, count:{}, n:{}".format(ans, count, n))
print(ans+count*n)



Measured memory_bytes: 78444
#include <iostream>
#include <string>

int max(int a, int b, int c);

int main(){
    int n;
    std::cin >> n;
    std::string str1;
    std::string str2;
    for(int i=0;i<n;i++){
        std::cin >> str1;
        std::cin >> str2;
        int size1 = str1.size();
        int size2 = str2.size();
        int dp[size1+1][size2+1];
        dp[0][0] = 0;
        for(int j=0;j<=size1;j++){
            dp[j][0] = 0;
        }
        for(int j=0;j<=size2;j++){
            dp[0][j] = 0;
        }

        for(int j=0;j<size1;j++){
            for(int k=0;k<size2;k++){
                if(str1[j]==str2[k]){
                    dp[j+1][k+1] = max(dp[j][k+1],dp[j][k] + 1,dp[j+1][k]);
                }else{
                    dp[j+1][k+1] = max(dp[j][k+1],dp[j][k],dp[j+1][k]);
                }
            }
        }

        std::cout << dp[size1][size2] << std::endl;
    }
    return 0;
}

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


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

using namespace std;

typedef long long int ll;

const int mod = 998244353;
const int N = 3e3 + 5;

ll dp[N][N];

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

ll inv(ll a){
  return pwr(a, mod - 2);
}

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

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

  dp[0][0] = 1;
  for(int i = 1; i <= n; i++) dp[i][0] = pwr(2, i);
  ll b = inv(2);
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= s; j++){
      if(j - a[i] >= 0) dp[i][j] = (2 * dp[i - 1][j] + dp[i - 1][j - a[i]]) % mod;
      else dp[i][j] = (2 * dp[i - 1][j]) % mod;
    }
  }

  cout << dp[n][s] << '\n';
}


Measured memory_bytes: 74072
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())

    ans = N * (N - 1) // 2

    print(ans)

sol()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
 string p;
  cin >> p;
  
  rep(i, p.size()) {
    p[i] = 'x';
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;
 
int main() {
        int n,x,y;
        cin >> n >> x >> y;
        --x;--y;
        vector<int> cnt(n+3);
        rep(i,n)for(int j=i+1;j<n;j++){
                int res = j - i;
                res = min(res,abs(x-i)+abs(y-j)+1);
                cnt[res-1] ++;
                //cout << res << endl;
        }
        rep(i,n-1) cout << cnt[i] << endl;
        return 0;
}




Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let mut an: Vec<usize> = read_vec();
    let mut bn: Vec<usize> = read_vec();
    let mut cn: Vec<usize> = read_vec();

    an.sort();
    bn.sort();
    cn.sort();

    let mut ans = 0;
    for b in bn.iter() {
        let count_a = bisect_left(&an, &b);

        let count_c = n - bisect_left(&cn, &(b + 1));

        ans += count_a * count_c;
    }

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

fn bisect_left<T>(seq: &Vec<T>, key: &T) -> usize 
    where T: Ord
{
    use std::cmp::Ordering;
    seq.binary_search_by(|probe| {
        match probe.cmp(key) {
            Ordering::Equal => Ordering::Greater,
            default => default,
        }        
    }).unwrap_or_else(|x| x)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 13560
n,m,q = map(int,input().split())
l = []
def dfs(a):
    if len(a)==n: l.append(a)
    else:
        for i in range(a[-1],m+1):
            dfs(a+[i])
for i in range(m):
    dfs([i+1])
Query = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for li in l:
    tmp = 0
    for a,b,c,d in Query:
        if li[b-1]-li[a-1]==c:
            tmp += d
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 98548
N, P = map(int, input().split())
S = [int(x) for x in input()]
if P == 2:
    ans = 0
    for i in range(N):
        if S[N-1-i] % 2 == 0:
            ans += N-i
elif P == 5:
    ans = 0
    for i in range(N):
        if S[N-1-i] % 5 == 0:
            ans += N-i
else:
    ans = 0
    cnt = [0] * P
    cnt[0] = 1
    dec_mod, pre_mod = 1, 0
    for i in range(N):
        mod = (S[N-1-i] * dec_mod + pre_mod) % P
        ans += cnt[mod]
        cnt[mod] += 1
        dec_mod = dec_mod * 10 % P
        pre_mod = mod
print(ans)


Measured memory_bytes: 48076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100001];
ll knapsack(ll val[],ll wei[],ll n,ll w)
{
    if(n==0||w==0){
        return 0;
    }
    if(dp[n][w]!=-1) return dp[n][w];
    
    ll x=0,y=0;
    if(wei[n-1]<=w){
      x=val[n-1]+knapsack(val,wei,n-1,w-wei[n-1]);
    }
    y=knapsack(val,wei,n-1,w);
     
     dp[n][w]=max(x,y);
     return dp[n][w];
    
}
void ttt(ll val[],ll wei[],ll n,ll w)
{
    ll t[n+1][w+1],i,j;
    for(i=0;i<=n;i++)
     for(j=0;j<=w;j++)
      if(i==0||j==0)
       t[i][j]=0;
     
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
          if(wei[i-1]<=j){
              t[i][j]=max(val[i-1]+t[i-1][j-wei[i-1]] ,t[i-1][j] );
          }else{
              t[i][j]=t[i-1][j];
          }
        } 
    }
    cout<<t[n][w]<<"\n";
    
}
int main(){
  
    ll n,w,i;
    cin>>n>>w;
    ll val[n],wei[n];
    memset(dp, -1, sizeof dp); 
    for(i=0;i<n;i++)
    {
        cin>>wei[i]>>val[i];
    }
    ttt(val,wei,n,w);
}

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

int main()
{
  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> p(M);
  vector<bool> ac(N, false);
  vector<ll> wa(N, 0);
  vector<string> S(M);
  for (int i=0; i<M; i++){
    cin >> p[i];
    cin >> S[i];
    p[i]--;
  }
  ll pena = 0;
  for (int i=0; i<M; i++) {
    if (ac[p[i]]) continue;
    if (S[i]=="WA") {
      wa[p[i]]++;
    } else if (S[i]=="AC") {
      ac[p[i]] = true;
      pena += wa[p[i]];
    }
  }
  ll acnum = 0;
  for (int i=0; i<N; i++) {
    if (ac[i]) acnum++;
  }
  printf("%lld %lld\n", acnum, pena);

  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
using namespace std;






int main()
{
	int n; 
	cin >> n;
	vector<char>b(n);
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> b[i] >> a[i];
	}
	vector<char>s(n);
	for (int i = 0; i < n; i++) {
		s[i] = b[i];
	}
	vector<char>t(n);
	vector<int>a1(n);
	for (int i = 0; i < n; i++) {
		t[i] = b[i];
		a1[i] = a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j >= i+1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				swap(s[j], s[j - 1]);
			}
		}
	}

	
	for (int i = 0; i < n; i++) {
		cout << s[i] << a[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << "Stable" << endl;
	for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (a1[j] < a1[minj]) {
					minj = j;

				}
			}
			swap(a1[i], a1[minj]);
			swap(t[i], t[minj]);
	}
	for (int i = 0; i < n; i++) {
		cout << t[i] << a1[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	if (s == t) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}







Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double a;
  a=w*h;
  a/=2;
  int ans=0;
  if((x*2)==w && (y*2)==h ) ans=1;
  cout<<a<<" "<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
A = []
for _ in range(n):
    A.append(int(input()))

ans = x
day = 0
for e in A:
    while 1 + day * e <= d:
        day += 1
        ans += 1
    # print(day)
    day = 0
print(ans)


Measured memory_bytes: 3064
import sys
import math

n = input()
a = [[[0] * 10] * 3] * 4
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in xrange(n) :
    b, f, r, v = map(int, raw_input().split())

    a[b-1][f-1][r-1] += v;

for i in xrange(4) :
    for j in xrange(3) :
        for k in xrange(10) :
            sys.stdout.write(" " + str(a[i][j][k]))
        print
    if i < 3 :
        print "#" * 20

Measured memory_bytes: 6444
x = int(input())
cand_list = []

for i in range(1, int(x**(1/2))+1):
    if x%i==0:
      cand_list.append([i, x//i])

ans = min([sum(cand_i)-2 for cand_i in cand_list])
if x == 2:
  ans = 1
elif x == 3:
  ans = 2

print(ans)

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,i;

    cin >> n >> l;

    vector<string>s(n);

    for(i=0; i<n; i++)
        cin >> s[i];

    sort(s.begin(),s.end());

    for(i=0; i<n; i++)
        cout << s[i];

    cout << endl;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
;m以上n以下でNの倍数の個数を数える
(defun count-m (m n k)
  (-(floor n k)
    (floor (1- m) k)))

(defun solve (A B C D)
  (let  (( E (lcm C D)))
    (- (1+ (- B A))
       (- (+ (count-m A B C)
	     (count-m A B D))
	  (count-m A B E)))))

(princ (solve (read) (read) (read) (read)))


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

typedef long long ll;
ll N, K;
vector<int> A;
vector<bool> Ab;


int main(){
    cin >> N >> K;
    A = vector<int>(N);
    Ab = vector<bool>(N, false);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i]--;
    }
    vector<int> firstloop;
    for(int i = 0;;){
        if(Ab[i]) {
            firstloop.push_back(i);
            break;
        }
        firstloop.push_back(i);
        Ab[i] = true;
        i = A[i];
    }

   auto firsta =  find(firstloop.begin(), firstloop.end(), firstloop[firstloop.size()-1]);
   int first = distance(firstloop.begin(), firsta);
   vector<ll> loop(firstloop.size() - (first + 1));
   copy(firstloop.begin() + (first + 1), firstloop.end(), loop.begin());
   vector<ll> beforeloop(first + 1);
   copy(firstloop.begin(), firstloop.begin() + (first + 1), beforeloop.begin());

   if((ll)beforeloop.size() - 1 >= K){
       cout << beforeloop[K] + 1 << endl;
   }
   else{
       K -= (ll)beforeloop.size();
       K %= (ll)loop.size();
       cout << loop[K] + 1 << endl;
   }

}

Measured memory_bytes: 6388
#include <stdio.h>
#define N 100

int main(){

  int temp, min;
  int n;
  int i, j, k;
  int A[N];
  int count;

  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);    
  }
  
  /* selection_sort */
  count=0; 
  for(i=0; i<n; i++){
    // i 番目の要素を暫定的に最小値とし添字を保存
    k=i;
    for(j=i; j<n; j++){
      // より小さい値が現れたら最小値の入れ替え
      if(A[j] < A[k]){
	k=j; // 添字を保存
      }
    }
    // このループを抜けるとk に最小値の添字が入っている
    // i 番目の要素と最小値の交換
    if (k > i)
    {
      temp = A[i]; 
      A[i] = A[k];
      A[k] = temp;
      ++count;
    }
  }
  
  for(i=0; i<n; i++){
    if(i == n - 1) printf("%d", A[i]);
    else printf("%d ", A[i]);
  }
  
  printf("\n");
  printf("%d", count);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c){
        cout<<"Yes";
    }
    else cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] array = new int[n];
        
        for (int i = 0; i < n; i++) {
            array[i] = input.nextInt();
        }
        
        for (int i = n - 1; i > -1; i--) {
            if (i == 0) {
                System.out.println(array[i]);
            }
            else {
                System.out.print(array[i] + " ");
            }
        }
    }
}


Measured memory_bytes: 26196
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <regex>
using namespace std;

int N, K;
int A[303030];
int dp[303030];

const int MAX_N = 1 << 18;
int seg_n, dat[4 * MAX_N - 1];
void init(int n_) {
    seg_n = 1;
    while (seg_n < n_) seg_n *= 2;
    for (int i=0; i<2*seg_n-1; i++) dat[i] = INT32_MIN;
}
void update(int k, int a) {
    k += seg_n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}
int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT32_MIN;
    if (a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    } 
}

int dp_dfs(int n) {
    if (dp[n] != 0) return dp[n];

    int res = query(A[n] - K, A[n] + K + 1, 0, 0, seg_n);
    if (res == INT32_MIN) {
        return dp[n] = 1;
    } else {
        return dp[n] = res + 1;
    }
    // for (int i=n+1; i<N; i++) {
    //     if (A[n] - K <= A[i] && A[i] <= A[n] + K) {
    //         max_len = max(max_len, dp_dfs(i) + 1);
    //     }
    // }
}



int kmax[303030];

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

    // cout << 111 << endl;
    init(303030);
    // cout << 222 << endl;
    
    for (int i=N-1; i>=0; i--) {
        // cout << 333 << endl;
        int dp_ret = dp_dfs(i);
        // kmax[A[i]] = max(kmax[A[i]], dp_ret);
        update(A[i], dp_ret);
        // cout << 444 << endl;
    }

    cout << query(0, 303030, 0, 0, seg_n) << endl;
    
    return 0;
}

Measured memory_bytes: 9968
#include<bits/stdc++.h>
using namespace std;
#define MAXSIZE (114514)
vector<int> parent(MAXSIZE);
int findp(int x){
  return x==parent[x]?x:parent[x]=findp(parent[x]);
}
void unite(int x,int y){
  parent[findp(x)]=findp(y);
}
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<MAXSIZE;++i)parent[i]=i;
  for(int i=0;i<m;++i){
    int x,y,z;
    cin>>x>>y>>z;
    unite(x,y);
  }
  map<int,int> group;
  for(int i=1;i<=n;++i)group[findp(i)]++;
  cout<<group.size()<<endl;
  return 0;
}

Measured memory_bytes: 5376
def main():
    n, k = map(int, input().split())
    rs, ss, ps = map(int, input().split())
    s = input()

    score = 0

    winlose_list = [1] * n

    for i in range(n):
        if i-k >= 0 and s[i-k] == s[i] and winlose_list[i-k] == 1:
            winlose_list[i] = 0
            continue
            # if s[i] == 'r':
            #     score += rs
            # elif s[i] == 's':
            #     score += ss
            # elif s[i] == 'p':
            #     score += ps
            # winlose_list[i] = 0
            # print('aiko',i,s[i],score)
        else:
            if s[i] == 'r':
                score += ps
            elif s[i] == 's':
                score += rs
            elif s[i] == 'p':
                score += ss
            # print('Win',i,s[i],score)
            
    print(score)

if __name__ == '__main__':
    main()

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

using namespace std;

using ull = unsigned long long;

int main (void) {
  ull n;
  cin >> n;
  cin.ignore();
  ull a[n];
  ull b[n];
  for (ull i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    cin.ignore();
  }
  sort (a, a + n);
  sort (b, b + n);
  ull res = 0;
  res = a[n-1] + b[0];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] a = new int[n];
	int min = Integer.MAX_VALUE;
	int cnt = 0;
	long total = 0;
	for(int i = 0; i<n; i++) {
	    a[i] = sc.nextInt();
	    min = Math.min(Math.abs(a[i]),min);
	    if(a[i]<0)cnt++;
	    total += Math.abs(a[i]);
	}
	if(cnt % 2 == 0) {
	    System.out.println(total);
	}else {
	    System.out.println(total-min*2);
	}
    }
}

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

int longest_path(int u,int DP[],vector<int> node[]){
	if(DP[u]>0){
		return DP[u];
	}
	int ret=0;
	for(int i=0;i<node[u].size();i++){
		ret=max(ret,longest_path(node[u][i],DP,node)+1);
	}
	return DP[u]=ret;
}

int main(){
	int N,M,ans=0;
	cin>>N>>M;
	vector <int> node[N+1];
	int DP[N+1]={};
	int u,v;
	for(int i=1;i<=M;i++){
		cin>>u>>v;
		node[u].push_back(v);
	}
	for(int i=1;i<=N;i++){
		ans=max(ans,longest_path(i,DP,node));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 8832
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    if(k & 1){
        cout << b - a;
    }else{
        cout << a - b;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
K = int(input())
ball = list(map(int,input().split()))
l = 0
for i in range(len(ball)):
  A = ball[i] * 2
  B = (K - ball[i]) * 2
  if A <= B:
    l += A
  else:
    l += B
print(l)


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

#define MAX 100000

typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
  int i = 0;

  for(int j = 0; j < k; j++){
    llong s = 0;

    while(s + T[i] <= P){
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

int solve(){
  llong left = 0, right = MAX * MAX;
  llong mid;

  while(right - left > 1){
    mid = (left + right) / 2;

    int v = check(mid);

    if(v >= n) right = mid;
    else left = mid;
  }

  return right;
}

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

  for(int i = 0; i < n; i++){
    cin >> T[i];
  }
  llong ans = solve();
  cout << ans << endl;
}
	
			     





Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,d;
  long long ans;
  cin>>a>>b>>c>>d;
  ans=max(a*c,b*d);
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  cout<<ans;
}



Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
        
G = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    
dp = [-1] * (N)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    
    res = 0
    for g in G[v]:
        res = max(res, dfs(g) + 1)
        
    dp[v] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans, dfs(i))
        
print(ans)

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

typedef long long ll;

const ll MOD = 1e9+7;

ll ModPow(ll base,ll exp,ll mod){
  ll ret = 1;
  base %= mod;
  while(exp>0){
    if(exp&1) ret = (ret*base)%mod;
    base = (base*base)%mod;
    exp >>= 1;
  }
  return ret;
}

ll ModInv(ll base,ll mod){
  return ModPow(base,mod-2,mod);
}

ll Comb(ll n, ll r,ll fct[][4001]){
  return fct[0][n]*(fct[1][r]*fct[1][n-r]%MOD)%MOD;
}

int main(){
  ll n,k; cin >> n >> k;

  ll fct[2][4001];
  fct[0][0] = fct[0][1] = 1;
  for(ll i=2; i<=n; fct[0][i]%=MOD,i++)
    fct[0][i] = fct[0][i-1]*(i%MOD);

  for(ll i=0; i<=n; i++)
    fct[1][i] = ModPow(fct[0][i],MOD-2,MOD);

  for(ll i=0; i<k; i++)
    cout << (Comb(k-1,i,fct)*Comb(n-k+1,i+1,fct))%MOD << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w;
    int i,j;
    char pixel[100][100];
    scanf("%d %d%*c",&h,&w);
    for(i=0;i<h;i++){
    	for(j=0;j<w;j++)
    	    scanf("%c",&pixel[j][i]);
        scanf("%*c");
    }
    for(i=0;i<2*h;i++){
    	for(j=0;j<w;j++)
    	    printf("%c",pixel[j][i/2]);
    	printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include <string.h>
#include<iostream>
using namespace std;

int main()
{
    long long a, c=1, n;
    int flag = 1;

    cin >> n;

    for (int i=0; i < n; i++) {
        cin >> a;

        if (a == 0) {
            flag = 0;
            break;
        }

        if (flag == 1) {
            if (c > 1000000000000000000 / a) {
                flag = -1;
            }

            c *= a;
        }
    }

    if (flag==1) {
        cout << c << endl;
    }
    else if(flag==-1) {
        cout << -1 << endl;
    }
    else if (flag == 0) {
        cout << 0 << endl;
    }
    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a(int H){
  if(H==1)
    return 1;
  else
    return a(H/2)*2+1;
}
signed main(){
  int H,i=0;
  cin>>H;
  cout<<a(H)<<endl;
}


Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt(), y = in.nextInt();
            if (x % y == 0) {
                out.println(-1);
                return;
            } else {
                out.println(x);
            }
        }

    }
}



Measured memory_bytes: 21844
li=list(map(int,input().split()))

A=li[0]
B=li[1]
C=li[2]
D=li[3]

while ((A>0) and (C>0)) :
  C=C-B
  if C<=0:
    print('Yes')
    break
  A=A-D
  if A<=0:
    print('No')
    break

Measured memory_bytes: 9192
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] P = new long[N + 1];
		long[] B = new long[N + 1];
		P[0] = 1;
		B[0] = 0;
		for(int i=1;i<=N;i++){
			P[i] = P[i-1] * 2 + 1;
			B[i] = B[i-1] * 2 + 2;
		}
		
		long ans = 0;
		for(int i=N;i>=0;i--){
			if(X == 0) break;
			long tot = B[i] + P[i];
			if(X == tot){
				ans += P[i];
				X -= tot;
				break;
			}
			long t2 = B[i-1] + P[i-1];
			if(X > t2 + 2){
				X -= t2 + 2;
				ans += P[i-1] + 1;
				continue;
			}
			if(X == t2 + 2){
				ans += P[i-1] + 1;
				X -= t2 + 2;
				continue;
			}
			X -= 1;
		}
		Console.WriteLine(ans);
	}
	int N;
	long X;
	public Sol(){
		var d = rla();
		N = (int)d[0]; X = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double n,k;
	cin>>n>>k;
	double sum=0;
	for(ll i=1;i<=n;i++){
		double cnt=1/n;
		ll num=i;
		while(num<k){
			num*=2;
			cnt/=2;
		}
		sum+=cnt;
	}
	printf("%.9f",sum);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

int main(){
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
//整形Shift + alt + f　2回
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/

/*
//桁数取得
unsigned GetDigit(unsigned num)
{
    unsigned digit = 0;
    while (num != 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}
*/

int n;

int main()
{
    string s;

    cin >> s;

    int res = 0;

    if (s[0] == '2')
        res++;
    if (s[1] == '2')
        res++;
    if (s[2] == '2')
        res++;
    if (s[3] == '2')
        res++;

    cout << res;

    return 0;
}


Measured memory_bytes: 384
n,m = map(int, input().split())
left_foods = [i for i in range(1,m+1)]

for _ in range(n):
    temp_left = []
    temps = list(map(int, input().split()))
    n = temps[0]
    # print(temps)
    for j in range(1, n+1):
        # print(temps[j])
        # print(left_foods)
        if temps[j] in left_foods:
            temp_left.append(temps[j])
    left_foods = temp_left
print(len(left_foods))

Measured memory_bytes: 3060
#include <stdio.h>

int A[100][100];
int B[100][100];

int main(){
  int n, m, l, x;
  int i, j, k;
  long c=0;
  
  scanf("%d%d%d", &n, &m, &l);
  
  for(i=0; i<n; i++)//scan array A
    for(j=0; j<m; j++){
      scanf("%d", &x);
      A[i][j] = x;
    }
  for(i=0; i<m; i++)//scan array B
    for(j=0; j<l; j++){
      scanf("%d", &x);
      B[i][j] = x;
    }

  for(i=0; i<n; i++){//cal & print
    for(k=0; k<l; k++){
      c = 0;
      for(j=0; j<m; j++)
	c += A[i][j] * B[j][k];
      printf("%ld%c", c, (k == l-1 ? '\n' : ' '));
    }
  }
  
  return 0;
}

Measured memory_bytes: 676
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sc.nextLine();
		String[] hArray = sc.nextLine().split(" ");
		List<String> hList = Arrays.asList(hArray);

		int current = -1;

		ListIterator<String> ite = hList.listIterator(hList.size());
		while(ite.hasPrevious()) {

			int i = Integer.parseInt(ite.previous());
			if(current == -1) {

				current = i;

			} else {

				if(i - current >= 2) {

					System.out.println("No");
					System.exit(0);

				} else if(i - current != 1) {

					current = i;

				}

			}

		}

		System.out.println("Yes");
		sc.close();

	}

}


Measured memory_bytes: 48740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cctype>

using namespace std;

#define ll long long

int n, m;
int a[1000001];

int main() {
    int num = 0;
    bool flag = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int aa, bb;
        cin >> aa >> bb;
        if (aa == bb) num++;
        else num = 0;
        if (num == 3) flag = true;
    }
    if (flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int n;
string s;
set<string> se;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> s;
		se.insert(s);
	}
	cout << se.size() << endl;
	return 0;
}


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

using namespace std;

const int N = 100005;

int a[N];

int main() {
	int n, x;
	scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	vector <int> b(n);
	for (int i = 0; i < n; i++) {
		b[i] = abs(a[i] - x);
	}
	int ans = b[0];
	for (int i = 1; i < n; i++) {
		ans = __gcd(ans, b[i]);	
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i=0;i<N;i++){
        cin >> p.at(i);
    }    
    sort(p.begin(),p.end());
    int a=0;
    for (int i=0;i<K;i++){
            a=a+p.at(i);
    }        
    cout << a << endl;// Your code here!
    
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
int main(void){
    double x1, y1, x2, y2;
    double X, Y;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    X = pow((x2 - x1), 2);
    Y = pow((y2 - y1), 2);
    printf("%.8f\n", sqrt(X + Y));
    return 0;
}



Measured memory_bytes: 2044
#include <cstdio>
#include <cstring>

#define MAX_M (100010)
using namespace std;

int BALL[MAX_M];
bool RED[MAX_M];

int main() 
{
    int N, M;
    scanf("%d %d", &N, &M);

    for ( int i = 0; i < N; i++ ) BALL[i] = 1;
    
    RED[0] = true;

    for ( int i = 0; i < M; i++ ) {
	int x, y;
	scanf("%d %d", &x, &y);
	x--;
	y--;
	
	if ( RED[x] ) {		// 移動させる箱に赤がある場合
	    if ( BALL[x] == 1 ) {
		RED[x] = false;

	    }
	    RED[y] = true;
	}
	BALL[x]--;
	BALL[y]++;

	// for ( int i = 0; i < N; i++ ) {
	//     if ( RED[i] ) {
	// 	printf("T");
	//     }
	//     else {
	// 	printf("F");
	//     }
	//     printf("%c", ( i == N - 1 ) ? '\n' : ' ');
	// }
    }

    int ans = 0;
    for ( int i = 0; i < N; i++ ) {
	if ( RED[i] ) ans++;
    }

    printf("%d\n", ans);
    
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int n,m;cin >> n >> m;
    vi a(n);rep(i,n)cin >> a[i];

    int Sum = accumulate(ALL(a),0);
    sort(ALL(a),greater<int>());
    double std = 0.25 * 1/m * Sum;
    string ans = "Yes";
    rep(i,m){
        if(a[i] < std)ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = str(input())

def kaibun(mojiretsu):
    n = len(mojiretsu)
    kaibuns = True
    if (n-1)%2 == 0:
        if n >= 3:
            for i in range(0,(n-1)//2):
                if not mojiretsu[i] == mojiretsu[-i-1]:
                    kaibuns = False
                    break
        else:
            kaibuns = True
    else:
        for i in range(0,n//2):
            if not mojiretsu[i] == mojiretsu[-i-1]:
                kaibuns = False
                break

    if kaibuns:
        return True
    else:
        return False
    

kaibun1 = kaibun(s)

if kaibun1:
    N = len(s)
    s2, s3 = s[0:(N-1)//2], s[(N+3)//2-1:N+1]
    kaibun2 = kaibun(s2)
    kaibun3 = kaibun(s3)
    if kaibun2 and kaibun3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

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

double dp[301][301][301];
ll n;

double backtrack(ll a,ll b,ll c)
{
    if(dp[a][b][c]!=-1)
        return dp[a][b][c];

    double t=a+b+c;
    double ans=n/t;
    if(a>0)
    {
        ans+=backtrack(a-1,b,c)*a/t;
    }
    if(b>0)
    {
        ans+=backtrack(a+1,b-1,c)*b/t;
    }
    if(c>0)
    {
        ans+=backtrack(a,b+1,c-1)*c/t;
    }
    dp[a][b][c]=ans;
    return ans;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout.precision(20);
    ll i,j,k;
    cin>>n;
    vector<ll> v(n);
    
    for(i=0;i<n;i++)
        cin>>v[i];
    
    for(i=0;i<301;i++)
    {
        for(j=0;j<301;j++)
        {
            for(k=0;k<301;k++)
                dp[i][j][k]=-1;
        }
    }
    dp[0][0][0]=0;
    ll a=0,b=0,c=0;
    for(i=0;i<n;i++)
    {
        if(v[i]==1)
            a++;
        else if(v[i]==2)
            b++;
        else
            c++;
    }
    
    cout<<backtrack(a,b,c)<<endl;
    
    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	vector<int> X(N, 0);
	Rep0(i, N)
		cin >>X.at(i);
	int S=INF;
	Rep0(i, 101) {
		int ss=0;
		Rep0(j, N)
			ss +=(X.at(j)-i)*(X.at(j)-i);
		S=min(S, ss);
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 1

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

using namespace std;

	vector<lli> p;
	vector<lli> c;		
	lli d;
	lli g;
	lli ans;

void calc(lli nowNum,lli maxNum,lli target,lli nowPoint,lli nowProblemNum){
	//目標点達成していた場合
	if(nowPoint>=g){
		if(ans>=nowProblemNum){
			ans = nowProblemNum;
		}
		return;
	}

	if(nowNum == maxNum)return;

	//中途半端に解くタイプの場合
	if(nowNum == target){
		//0~n-1まで解く
		for(lli i=0;i<p[nowNum];i++){
			calc(nowNum+1,maxNum,target,nowPoint+(nowNum+1)*100*i,nowProblemNum+i);
		}
	}
	else{
		//ここで解く場合と解かない場合とする。
		calc(nowNum+1,maxNum,target,nowPoint+(nowNum+1)*100*p[nowNum]+c[nowNum],nowProblemNum+p[nowNum]);
		calc(nowNum+1,maxNum,target,nowPoint                                   ,nowProblemNum          );
	}
}

int main(){

	cin>>d>>g;

	ans = 1000000000000;

	REP(i,d){
		lli tmpP,tmpC;
		cin>>tmpP>>tmpC;
		p.push_back(tmpP);
		c.push_back(tmpC);
	}

	for(lli i=0;i<=d;i++){
		calc(0,d,i,0,0);
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll cur = 1;
	ll ans = 0;
	while (n > 0) {
		ans += cur;
		cur *= 2;
		n /= 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
	int m = 100000;
	int n;
	cin >> n;

	for ( int i = 0; i < n; i++ )
	{
		m = (int)((double)m * 1.05);
		if ( m % 1000 > 0 )
		{
			m += 1000;
		}
		m /= 1000;
		m *= 1000;
	}

	cout << m << endl;

	return 0;
}

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

Int A, B, C, D;
map<Int,Int> m;


Int solve(Int N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (m.count(N)) return m[N];

    Int l2 = (N/2)*2;
    Int r2 = ((N+1)/2)*2;

    Int l3 = (N/3)*3;
    Int r3 = ((N+2)/3)*3;

    Int l5 = (N/5)*5;
    Int r5 = ((N+4)/5)*5;

    Int res = 1e18;
    if (N < res/D) res = N * D;

    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    m[N] = res;

    return res;
}

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

    for (int t = 0; t < T; t++) {
        m.clear();
        Int N; cin >> N;
        cin >> A >> B >> C >> D;

        cout << solve(N) << endl;
    }

}

Measured memory_bytes: 4264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    int a;
    vector<int> cnt(1e6+1);
    rep(i,n) {
        cin >> a;
        cnt[a]++;
    }
    int ans = 0;
    for (int i = 1; i < 1e6; i++)
    {
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
map<pair<int, int>,int> memo;
int gcd(int a, int b)
{
    if (a < b)
    {
        swap(a, b);
    }
    auto p = mp(a, b);
    if (memo.count(p))
    {
        return memo[p];
    }
    int tmp;
    while (b)
    {
        tmp = a % b;
        a = b;
        b = tmp;
    }
    memo[p] = a;
    return a;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    vector<int> left(N + 1, 0), right(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        left[i + 1] = gcd(left[i], A[i]);
    }
    for (int i = N - 1; i >= 0; i--)
    {
        right[i] = gcd(right[i + 1], A[i]);
    }

    int ans = 0;
    rep(i, N)
    {
        int l = left[i];
        int r = right[i + 1];
        ans = max(ans, gcd(l, r));
    }
    cout << ans << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 1408
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

m = 1_000
k = 0
(0...(n - 1)).each do |i|
  if k == 0 && a[i] < a[i + 1]
    k = m / a[i]
    m %= a[i]
  end

  if k > 0 && a[i] > a[i + 1]
    m += k * a[i]
    k = 0
  end
end

m += k * a[n - 1] if k > 0

puts m


Measured memory_bytes: 14328