akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>

constexpr intmax_t mod = 1e9+7;

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<size_t> a{0};
  for (size_t i = 1; i * i <= N; ++i) {
    a.push_back(i);
    a.push_back(N/i);
  }
  std::sort(a.begin(), a.end());
  a.erase(std::unique(a.begin(), a.end()), a.end());

  size_t M = a.size();
  std::vector<std::vector<intmax_t>> dp(K, std::vector<intmax_t>(M));
  for (size_t j = 1; j < M; ++j) {
    dp[0][j] = a[j] - a[j-1];
    (dp[0][j] += dp[0][j-1]) %= mod;
  }

  for (size_t i = 1; i < K; ++i) {
    for (size_t j = 1; j < M; ++j) {
      dp[i][j] = dp[i-1][M-j] * (a[j]-a[j-1]) % mod;
      (dp[i][j] += dp[i][j-1]) %= mod;
    }
  }

  printf("%jd\n", dp[K-1][M-1]);
}


Measured memory_bytes: 50936
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, max;
    boolean[][] map;
    int[][] size;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;

	    map = new boolean[n][n];
	    size = new int[n][n];
	    max = 0;

	    for(int i=0; i<n; i++){
		String s = sc.next();
		for(int k=0; k<n; k++){
		    map[i][k] = s.substring(k, k+1).equals(".") ? true : false;
		    if(i==0 || k==0)
			size[i][k] = map[i][k] ? 1 : 0;
		}
	    }
	    

	    for(int i=1; i<n; i++)
		for(int k=1; k<n; k++){
		    if(!map[i][k]) size[i][k] = 0;
		    else
			size[i][k] = Math.min(Math.min(size[i-1][k-1], size[i-1][k]), size[i][k-1]) + 1;
		    max = Math.max(size[i][k], max);
		}
	    // show();
	    System.out.println(max);
	}
    }

    void show(){
	for(int i=0; i<n; i++){
	    for(int k=0; k<n; k++)
		System.out.print(size[i][k]+" ");
	    System.out.println();
	}
    }
}

Measured memory_bytes: 100376
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b,c,sum;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	sum=a+b+c;
	if(sum>=22)
		printf("bust");
	else
		printf("win");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<set>
using lint=long long;
using namespace std;

int main()
{
	int N;
	string A,B,C;
	set<char> s;
	int ans=0;
	
	cin >> N >> A >> B >> C;
	
	for(int i=0;i<N;i++)
	{
		s.clear();
		s.insert(A[i]);
		s.insert(B[i]);
		s.insert(C[i]);
		ans+=s.size()-1;
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  const int NUM = 200000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  int n,p,pn;
  while(true){
    cin >> n >> p;
    if (n==-1)
      break;
    int sum[p*p];
    for(int i=0;i<p*p;i++)
      sum[i] = 0;
    pn = n+1;
    for(int i=0;i<p;i++){
      while(!prime[pn])
	pn++;
      for(int j=0;j<p;j++){
	sum[j*p+i] += pn;
	sum[i*p+j] += pn;
      }
      pn++;
    }
    for(int i = 0;i<p*p;i++){
      if(i/p>i%p)
	sum[i] = 1000000;
    }
    
    sort(sum,sum+p*p);
    cout << sum[p-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1100
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n;
vvll d;
vvll best;
const ll inf = 10e50;

template <class T>
void warshall_froyd(vector<vector<T>>& v)
{
	int n{ (int)v.size() };

	REP(k, n)
		REP(i, n)
		REP(j, n)
		v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
}


void init()
{
	cin >> n;
	d.resize(n, vll(n));
	best.resize(n, vll(n));

	REP(i, n)
		REP(j, n)
	{
		cin >> d[i][j];
		best[i][j] = d[i][j];
	}
}

int main()
{
	init();

	REP(k, n)
		REP(i, n)
		REP(j, n)
	{
		if (k == i || k == j || i == j || best[i][k] == inf || best[k][j] == inf)
			continue;

		if (best[i][k] + best[k][j] == d[i][j])
			best[i][j] = inf;

		else if (d[i][j] > best[i][k] + best[k][j])
		{
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = 0;
	REP(i, n)
		REP(j, n)
		if (best[i][j] != inf)
			ans += best[i][j];

	cout << ans / 2 << endl;

}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

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

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	long int n,m,i,j;
	char data[200][2],a;
	
	while(0<=scanf("%ld",&n)){
		if(n==0){
			break;
		}
		
		for(i=0;i<n;i++){
			scanf(" %c ",&data[i][0]);
			scanf(" %c ",&data[i][1]);
		}
		
		scanf("%ld",&m);
		for(i=0;i<m;i++){
			scanf(" %c ",&a);
			for(j=0;j<n;j++){
				if(a==data[j][0]){
					a=data[j][1];
					break;
				}
			}
			printf("%c",a);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
vector<long long> color;

void dfs(const vector<vector<long long> > &graph, long long node, int init =0 ){
    color[node] = init;
    for( long long i = 0; i < graph[node].size(); i = i+2 ){
        long long next_node = graph[node][i];
        if(color[next_node] != -1) continue;
        int weight = graph[node][i+1];
        if( weight!= 0 && weight%2 == 0){
            color[next_node] = init;
            dfs(graph, next_node, init);
        } 
        else if( weight != 0 && weight%2 == 1 ){
            color[next_node] = 1 - init;
            dfs(graph, next_node, 1 - init);
        }                      
    }
}


int main(){
    long long N; cin >> N;
    // init color as -1
    color.resize(N,-1);

    vector<vector<long long> > graph(N);
    
    // input is always 3. init the values as -1
    //graph.assign(N, vector<long long>(N,0));
    for(int i=0; i<N-1; i++){
            long long u, v, w; cin >> u >> v >> w;
            u--;
            v--;
            graph[u].push_back(v);
            graph[v].push_back(u);

            graph[u].push_back(w);
            graph[v].push_back(w);
    }

    //first color to pupolate define as zero;
    for(int i= 0; i< N; i++){
        if(color[i] != -1) continue;
        else dfs(graph, i);
    }

    for(auto a: color) cout << a << endl;
}

Measured memory_bytes: 9984
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		if(S.length() == 2) System.out.println(S);
		else System.out.println("" + S.charAt(2) + S.charAt(1) + S.charAt(0));
	}
}

Measured memory_bytes: 21844
import sys
input = lambda: sys.stdin.readline()
exec("try:sys.stdin=open('in.txt','r');sys.stdout=open('out.txt','w')\nexcept:pass")

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if A[i] == i + 1:
        A[i], A[i + 1] = A[i + 1], A[i]
        ans += 1
if A[-1] == N:
    A[-1], A[-2] = A[-2], A[-1]
    ans += 1
print(ans)


Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







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

 vector <ll> c(n+1,0);
 for (int i = n-1;i >= 0;i--){
   a[i] += c[i+1];
   ll amari = a[i] % b[i];
   ll need = 0;
   if (amari != 0) need = b[i] - amari;
   c[i] = c[i+1] + need;

 }
 cout << c[0] << endl;

}

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

int main(){
    int a, b;
    cin >> a >> b;

    int cou = 0;
    if(b / 10 == 0){
        cou = 10;
    }else if(b / 100 == 0){
        cou = 100;
    }else{
        cou = 1000;
    }

    int sum = a * cou + b;
    int flag = 0;
    for(int i = 4; i < sum / 2 + 1; i++){
        if(i * i > sum){
            break;
        }

        if(i * i == sum){
            flag = 1;
            break;
        }
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

#define ll long long

int n;
ll arr[200005];
ll ans = LLONG_MAX;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
		arr[i] += arr[i-1];
	}
	for(int i = 1; i <= n-1; i++) {
		ll sum1 = arr[i], sum2 = arr[n] - arr[i];
		ans = min(ans,abs(sum1-sum2));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
import copy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,k=MI()
lis=LI()
for i in range(min(k,100)):
    lis2=[0 for i in range(n)]
    for i in range(n):
        lis2[max(0,i-lis[i])]+=1
        if i+lis[i]+1<n:
            lis2[i+lis[i]+1]+=-1
    lis=list(accumulate(lis2))
    #print(lis)
print(*lis)
        
        
        


Measured memory_bytes: 191416
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> pre,in,post;
int root,pos=0;

void rec(int left,int right){
	if(left>=right) return ;
	int root=pre[pos++];
	int m=distance(in.begin(), find(in.begin(), in.end(),root));
	rec(left,m);
	rec(m+1,right);
	post.push_back(root);
	return ;
}

void solve(int n){
	rec(0,n);
	for(int i=0;i<n;i++) {
		if(i) cout<<" "<<post[i];
		else cout<<post[i];
	}
	cout<<endl;
	return ;
}

int main (){
	int n;
	cin>>n;
	int a;
	for(int i=0;i<n;i++){
		cin>>a;
		pre.push_back(a);
	}
	for(int i=0;i<n;i++){
		cin>>a;
		in.push_back(a);
	}
	solve(n);
	return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] H = new int[N];
        for(int i = 0; i < N; i++) {
            H[i] = scanner.nextInt();
        }
        if(N == 1) {
            System.out.println(0);
            return;
        }
        int max = 0;
        int count = 0;
        for(int i = 1; i < N; i++) {
            if(H[i-1] >= H[i]) {
                count++;
                max = Math.max(count, max);
            }else{
                count = 0;
            }
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 52108
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

//------- Union-Find木 ---------
vector<int> par; // 親
// 初期化
void init(int n) {
  par = vector<int>(n);
  par[0] = 0;
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  par[x] = y;
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
  return find(x) == find(y);
}
//-------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // ifstream cin ("2170_input.txt");
  int N, Q;
  while (1) {
    cin >> N >> Q;
    if (!(N | Q)) break;
    init(N);
    int a, i;
    for (i = 1; i < N; i++) {
      cin >> a;
      par[i] = a - 1;
    }
    vector<pair<char, int> > query(Q);
    char q;
    for (i = 0; i < Q; i++) {
      cin >> q >> a;
      query[i] = make_pair(q, a);
    }

    // 先にマークする。つまり木を分離する。親となるノードを覚えておく。
    // 同じノードに2回以上マークしている場合も考慮する。
    map<int, int> ori_par;
    map<int, int> ori_par_cnt;
    for (i = 0; i < Q; i++) {
      if (query[i].first == 'M') {
        a = query[i].second - 1;
        if (!ori_par_cnt.count(a)) {
          ori_par[a] = par[a];
          ori_par_cnt[a] = 1;
          par[a] = a;
        } else {
          ori_par_cnt[a]++;
        }
      }
    }

    // クエリを後ろから処理する
    long long sum = 0;
    reverse(query.begin(), query.end());
    for (i = 0; i < Q; i++) {
      a = query[i].second - 1;
      if (query[i].first == 'Q') {
        sum += find(a) + 1;
      } else if (query[i].first == 'M') {
        if (ori_par_cnt[a] == 1) {
          unite(a, ori_par[a]);
        } else {
          ori_par_cnt[a]--;
        }
      }
    }

    // 出力
    cout << sum << endl;
  }
}

Measured memory_bytes: 6036
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    for(int i=0; i<10; i++){
        int ans = r*x - d;
        cout << ans << "\n";
        x = ans;
    }
    return 0;
}

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

using namespace std;

int main() {
	int n;

	while( true ) {
		cin >> n;

		if( !n ) {
			break;
		}

		vector< int > num(n);

		for(int i = 0; i < n; i++) {
			cin >> num[i];
		}

		int m = num[0];;

		for(int i = 0; i < n; i++) {
			int sum = 0;
			for(int j = i; j < n; j++) {
				sum += num[j];
				m = max(m, sum);
			}
		}
		cout << m << endl;
	}
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int a[]={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;k--;
  cout<<a[k]<<endl;
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[111111];
int seica[111111];
int mp[111111];
vector<vector<int>> v(111111);

int main(){
	
	int n,m;cin >> n >> m;
	REP(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);
		seica[b]++;
	}
	
	queue<int> q;
	REP(i,n)if(seica[i] == 0)q.push(i);
	
	while(!q.empty()){
		int now = q.front();q.pop();
		REP(j,v[now].size()){
			dp[v[now][j]] = max(dp[v[now][j]],dp[now] + 1);
			mp[v[now][j]]++;
			if(mp[v[now][j]] == seica[v[now][j]])q.push(v[now][j]);
		}
	}
	
	ll ans = 0;
	REP(i,n)ans = max(ans,dp[i]);
	
	cout << ans << endl;
	
		
	
	return 0;
}


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

using namespace std;

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

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

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = INF;
	
	cin>>N;
	
	for(int i = 1; i*i <= N; i++){
		if(N%i == 0)ans = min(ans, i + N/i-2);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  int n = 0;

  cin >> n;

  cout << (n >= 30 ? "Yes\n" : "No\n");

  return 0;
}
/*

*/


Measured memory_bytes: 3644
n = int(input())
t = 0
h = 0
for i in range(n):
    taro,hana = input().split()
    if taro == hana:
        t += 1
        h += 1
    else:
        m = list((taro,hana))
        m.sort()
        if m == list((taro,hana)):
            h += 3
        else:
            t += 3
print("{} {}".format(t,h))

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

int main() {
    int s;
    cin >> s;
    set<int> set1;
    set1.insert(s);
    for(int i=1;i<1000000;i++){
        if(s%2==0) s /= 2;
        else s = 3*s+1;
        set1.insert(s);
        if(set1.size()!=i+1){
            cout << i+1 << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009
#define ll long long

int main(){
    string a;
    cin>>a;
    int l=a.size();
    int p=l/2;
    int count=0;
    for (int i=0; i<p; i++){
        if (a[i]!=a[l-1-i]) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,n) for(int i = 1; i < n; i++)
int main(void){
  int n;
  cin >> n;
  vector<int> data(n);
  rep(i,n){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  double ans = data.at(0);
  rep2(i,n){
    ans = (ans + data.at(i))/2;
  }
  cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n, a[105], ans = 0;
  scanf("%d%d", &n, &a[0]);
  for(int i = 1; i < n; i++){
    scanf("%d", &a[i]);
    if(a[i] == a[i-1]) ans++, a[i] = -1;
  }
  printf("%d\n", ans);
}

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

bool next_perm(string& a) {
    int itr = a.size() - 1;
    bool judge = false;
    while (itr > 0) {
        --itr;
        if (a[itr] < a[itr + 1]) {
            judge = true;
            break;
        }
    }

    if (!judge) {
        reverse(a.begin(), a.end());
    } else {
        for (int i = a.size() - 1; i >= 0; --i) {
            if (a[i] > a[itr]) {
                swap(a[i], a[itr]);
                break;
            }
        }
    }

    return judge;
}

int main() {
    string S;
    cin >> S;
    int cnt[26];
    fill(cnt, cnt + 26, 0);

    for (char c : S) {
        ++cnt[c - 'a'];
    }

    for (int i = 0; i < 26; ++i) {
        if (cnt[i] == 0) {
            S.push_back('a' + i);
            cout << S << endl;
            return 0;
        }
    }

    string T = S;
    if (next_perm(S)) {
        for (int i = 0; i < 26; ++i) {
            cout << S[i];
            if (S[i] != T[i]) break;
        }
    } else {
        cout << -1;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>

struct Point {
  double x, y;

  void print() { std::cout << std::fixed<< std::setprecision(8) << x << " " << y << std::endl; }
};

void kock(int n, Point p1, Point p2) {
  if (n <= 0)
    return;

  Point s{(2 * p1.x + p2.x) / 3.0, (2 * p1.y + p2.y) / 3.0};
  Point t{(p1.x + 2 * p2.x) / 3.0, (p1.y + 2 * p2.y) / 3.0};
  Point u{(t.x - s.x) * cos(M_PI / 3.0) - (t.y - s.y) * sin(M_PI / 3.0) + s.x,
          (t.x - s.x) * sin(M_PI / 3.0) + (t.y - s.y) * cos(M_PI / 3.0) + s.y};

  kock(n - 1, p1, s);
  s.print();
  kock(n - 1, s, u);
  u.print();
  kock(n - 1, u, t);
  t.print();
  kock(n - 1, t, p2);
}

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

  Point p1{0.0, 0.0};
  Point p2{100.0, 0.0};

  p1.print();
  kock(n, p1, p2);
  p2.print();
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll l=0;
    ll r=n-1;
    string s;cin>>s;
    ll ans=0;
    while(l<r){
        if(s[r]=='R'){
            rep(i,l,r-1){
                if(s[i]=='W'){
                    //s[i]='R';
                    //s[r]='W';
                    ans++;
                    l=i+1;
                    break;
                }else{
                    l=i+1;
                }
            }
        }
        r--;
    }
    cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 3756
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, L) = nextIntList()
    val S = Array(N) { next() }.sorted().joinToString("")
    println(S)
}

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

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var kn = Console.ReadLine().Split(' ');
            var d = int.Parse(kn[0]);
            var t = int.Parse(kn[1]);
            var s = int.Parse(kn[2]);
            var isOk = (d+t-1)/t <= s;
            Console.WriteLine(isOk ? "Yes" : "No");
            
        }
    }
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;

  cout<<(n*(n-1)/2)<<endl;
  
  
}


Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define time fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define INF 1LL<<61
#define inf 1<<30
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    ll dif = b-a;  // = n+1
    ll ans = dif*(dif+1)/2 - b;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j,v1,v2,l[11]={};
    double t,d,sum;
    
    while(scanf("%d,",&l[1]) != EOF){
        sum=l[1];
        for(i=2;i<=10;i++){
            scanf("%d,",&l[i]);
            sum+=l[i];
        }
        scanf("%d,%d",&v1,&v2);
        if(l[1] == -1)break;
        
        t=sum/(v1+v2);
        d=(double)v1*t;
        j=1;
        
        while(d>0){
            d-=l[j++];
        }
        
        printf("%d\n",j-1);
        
    }
    return 0;
}

Measured memory_bytes: 596
# include <iostream>
# include <vector>
 
 
using namespace std;
 
 
int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
 
    vector<int> p(a); for (int i=0; i<a; i++) cin >> p[i];
    vector<int> q(b); for (int i=0; i<b; i++) cin >> q[i];
    vector<int> r(c); for (int i=0; i<c; i++) cin >> r[i];
 
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
 
    vector<int> s;
    for (int i=0; i<x; i++) s.push_back(p[i]);
    for (int i=0; i<y; i++) s.push_back(q[i]);
 
    sort(s.begin(), s.end());
 
    int cur = 0;
    long long ans = 0;
    for (int i=0; i<x+y; i++) {
        if (cur < x+y and r[cur] > s[i]) {
            ans += r[cur];
            cur++;
        }
        else {
            ans += s[i];
        }
    }
 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2552
d,e,f=[int(i) for i in input().split()]
x,y,z=[int(i) for i in input().split()]
s,t,u=[int(i) for i in input().split()]
b=x-d
c=s-d
if b+e==y and b+f==z and c+e==t and c+f==u:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) (int)s.size()
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
void solve()
{
fastio
string s;
cin>>s;
if(s.back()=='s')
cout<<s<<"es";
else
cout<<s<<"s";
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
typedef long long int LL;

int main(){
	int n;
	int i,j,k;
	int a[105];
	double d,e,f;
	int s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		d+=a[i];
	}
	d/=(double)n;
	f=d;
	for(i=0;i<n;i++){
		e=(double)a[i]-d;
		if(e<0)e=-e;
		if(e<f)s=i,f=e;
	}
	cout<<s<<endl;
	return 0;
	
}


Measured memory_bytes: 256
H,W=map(int,input().split())

arr=[list(map(int,input().split())) for i in range(10)]
wall=[list(map(int,input().split())) for i in range(H)]


for i in range(10):
    for j in range(10):
        for k in range(10):
            arr[j][k]=min(arr[j][i]+arr[i][k],arr[j][k])

ans = 0
for i in range(H):
    for item in wall[i]:
        if item<0:
            continue
        ans += arr[item][1]  
print(ans)

Measured memory_bytes: 9480
N, M = map(int, input().split())
X = [int(i) for i in input().split()]

d = []
X.sort()
p = 0
for x in X:
    d.append(x-p)
    p = x 

d.pop(0)
d.sort()
for i in range(N-1):
    if(len(d)>0):
        d.pop()

if(len(d)>0):
    print(sum(d))
else:
    print(0)

Measured memory_bytes: 13840
import math
N,D=map(int,input().split())
A=[]
count=0
total=0
L=0
for i in range(N):
    B=list(map(int,input().split()))
    A.append(B)
#print(A)
for i in range(N):
    for k in range(i+1,N):
        for j in range(D):
            total +=(A[i][j]-A[k][j])*(A[i][j]-A[k][j])
        #print(total)
        L=math.floor(math.sqrt(total))
        #print(L)
        #print(math.sqrt(total))
        if math.sqrt(total)==L:
            count +=1
        total=0
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(abs(x-k)<x) sum+=(2*abs(x-k));
        else sum+=(2*x);
    }
    cout<<sum;
}


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

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

ll X;
int main(void){
    cin >> X;
    ll a = X / 500;
    ll b = (X%500) / 5;
    cout << a * 1000 + b * 5 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    int N, X;
    cin >> N;

    X = ceil(((float)N) / 1.08);

    if(floor((float)X * 1.08) == N){
        cout << X << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
vector<string> x;
int n;
void dfs(string s){
  char c;
  int k=0;
  if(s.size()==n){
    x.push_back(s);
    return;
  }
  for(int i='a';i<='z';i++){
    for(int j=0;j<s.size();j++){
      if(s[j]==i){
        c=i;
        dfs(s+c);
        k=1;
        break;
      }
    }
    if(k==0){
      c=i;
      dfs(s+c);
      break;
    }
    k=0;
  }
}
int main(){
  int i;
  scanf("%d\n",&n);
  dfs("a");
  sort(x.begin(),x.end());
  for(i=0;i<x.size();i++){
    cout << x[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 9588
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    int n, m, c; cin >> n >> m >> c;
    int b[m]; rep(i, m) cin >> b[i];
    int a[n][m]; rep(i, n) rep(j, m) cin >> a[i][j];
    int cnt = 0;
    rep(i, n) {
        int tmp = 0;
        rep(j, m) {
            tmp += a[i][j] * b[j];
        }
        tmp += c;
        if (tmp > 0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    char C;
    cin >> C;
    printf("%c\n", C+1);
    return 0;
}

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

int x[3];

void solve() {
  if (x[2] == x[0] && x[2] == x[1]) {
    cout << "Yes\n";
    return;
  } else {
    cout << "No\n";
  }
  return;
}

int main() {
  cin >> x[0] >> x[1] >> x[2];
  solve();
  return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];

    LL ans = 0;
    vector<LL> b(n, 0);
    REP(i, n)
    {
        REP(j, n)
        {
            if(a[i] > a[j]) b[i] += 1LL;
        }
    }

    LL s = (k-1)*(k) / 2LL % MOD;
    REP(i, n)
    {
        LL cnt = 0;
        FOR(j, i+1, n)
        {
            if(a[i] > a[j]) cnt += 1;
        }
        ans = (ans + cnt * k % MOD + b[i] * s % MOD) % MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N, K;
  int ansflg=0;
  int cnt=0;
  int tmp;

  cin >> N >> K;

  for(int i=0; i<N; i++){
    int tmp = i+K;
    if(tmp <= N){
      cnt++;
    }
  }
  
    cout << cnt << endl;
}


Measured memory_bytes: 256
k = int(input())

te = [[i for i in range(1, 10)]]
a = te[0]
for i in range(11):
    te2 = []
    for j in te[i]:
        c = j%10
        if c == 0:
            te2 += [j*10 + c + k for k in (0, 1)]
        elif c == 9:
            te2 += [j*10 + c + k for k in (-1, 0)]
        else:
            te2 += [j*10 + c + k for k in (-1, 0, 1)]
    te.append(te2)
    a += te2
print(a[k-1])

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    char s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    string res = "Three";
    for (int i = 0; i < n; i++) {
        if (s[i] == 'Y') {
            res = "Four";
            break;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 892
import collections

def read():
    S = input().strip()
    Q = int(input().strip())
    queries = list()
    for i in range(Q):
        query = input().strip().split()
        t = int(query[0])
        if t == 1:
            queries.append((t, -1, "*"))
        if t == 2:
            f = int(query[1])
            c = query[2]
            queries.append((t, f, c))
    return S, Q, queries

def solve(S, Q, queries):
    head = collections.deque()
    tail = collections.deque()
    is_fliped = False
    for t, f, c in queries:
        if t == 1:
            is_fliped = not is_fliped
        if t == 2:
            is_head = (f == 1) ^ is_fliped
            if is_head:
                head.appendleft(c)
            else:
                tail.append(c)
    s = ''.join(head) + S + ''.join(tail)
    if is_fliped:
        s = ''.join(reversed(s))
    return s


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 24092
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=-1
num=0
for i in range(n):
    num+=a[i]
    if num>x:
        ans=i
        break
if ans==-1:
    if num==x:
        print(n)
    else:
        print(n-1)
else:
    print(ans)


Measured memory_bytes: 3060
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    R, C, K = read_values()
    V = [0] * (R * C)
    for _ in range(K):
        r, c, v = read_values()
        r -= 1
        c -= 1
        V[r * C + c] = v
    
    dp = [0 for _ in range(R * C * 4)]
    for i in range(R * C):
        r = i // C
        c = i % C
        if c + 1 < C:
            # not take
            for k in range(4):
                dp[4 * (i + 1) + k] = max(dp[4 * (i + 1) + k], dp[4 * i + k])

            # take 
            for k in range(3):
                dp[4 * (i + 1) + k + 1] = max(dp[4 * (i + 1) + k + 1], dp[4 * i + k] + V[i])

        # next r
        if r + 1 < R:
            for k in range(4):
                dp[4 * (i + C)] = max(dp[4 * (i + C)], dp[4 * i + k] + (V[i] if k < 3 else 0))

    res = 0
    for k in range(4):
        res = max(res, dp[4 * (R * C - 1) + k] + (V[-1] if k < 3 else 0))

    print(res)


if __name__ == "__main__":
    main()


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

int C[10][10], A[50000];

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> C[i][j];
  for (int i = 0; i < H*W; i++) cin >> A[i];
  for (int k = 0; k < 10; k++)
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < 10; j++)
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
  int sum = 0;
  for (int i = 0; i < H*W; i++) {
    if (A[i] != -1) sum += C[A[i]][1];
  }
  cout << sum << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	int K; cin >> K;
	vector<int> V(N);
	for (int i = 0; i < N; i++) cin >> V[i];

	int ans = 0;
	for (int l = 0; l <= N && l <= K; l++) {
		for (int r = 0; l + r <= N && l+r <= K; r++) {
			vector<int> cur; cur.reserve(l+r);
			for (int i = 0; i < l; i++) cur.push_back(V[i]);
			for (int i = 0; i < r; i++) cur.push_back(V[N-1-i]);

			sort(cur.begin(), cur.end());
			reverse(cur.begin(), cur.end());
			int ops = K - l - r;
			while (ops > 0 && !cur.empty() && cur.back() < 0) {
				--ops;
				cur.pop_back();
			}
			int cnd = 0;
			for (int v : cur) cnd += v;
			ans = max(ans, cnd);
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
from itertools import accumulate

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a_ac=[0]+list(accumulate(a))
b_ac=[0]+list(accumulate(b))

ans=0
for i in range(n+1):
  remain=k-a_ac[i]
  if remain<0:
    continue
  t_ans=i
  t_ans+=bisect_right(b_ac,remain)-1
  ans=max(ans,t_ans)

print(ans)

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

#define INF 1e9

int main(void){
  int n, m, q;
  cin >> n >> m >> q;

  vector<int> r(q);
  for(int i = 0; i < q; i++){
    cin >> r[i];
    --r[i];
  }

  vector<vector<int> > dp(n, vector<int>(n, INF));
  int a, b, c;
  for(int i = 0; i < m; i++){
    cin >> a >> b >> c;
    --a;
    --b;
    dp[a][b] = c;
    dp[b][a] = c;
  }
  for(int k = 0; k < n; k++){ dp[k][k] = 0; }
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);


  int ans = INF;
  for(int x = 0; x < q; x++){
    vector<vector<int> > salesman(q, vector<int>(1 << q, INF));
    salesman[x][(1 << x)] = 0;
    for(int j = 0; j < (1 << q); j++){
      for(int i = 0; i < q; i++){
        for(int k = 0; k < q; k++){
          // まだ地点kに訪れていなかったら
          if((i != k) && (j & (1 << k)) == 0){
            salesman[k][j | (1 << k)] = min(salesman[k][j | (1 << k)], salesman[i][j] + dp[r[i]][r[k]]);
          }
        }
      }
    }
    
    int cost = INF;
    for(int i = 0; i < q; i++){ cost = min(cost, salesman[i][(1 << q) - 1]); }
    
    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
// 簡易競プロテンプレ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,c,k, t[114514];
int main(void){
 cin >> n>>c>>k; for(int i=0;i<n;i++) cin >> t[i];
 sort(&t[0], &t[n]);
 ll ans = 0, offs=0;
 while(offs<n){
  //offsからc人乗せる
  ll now = t[offs] + k;
  for(int i=0;i<c;i++){
   if (offs>=n || now<t[offs]) break;
   offs++;
  } 
  ans++;
 } 

 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    long sum = 0;
    int min = 1000000;
    int max = -1000000;
    for(int x = 0; x < n; x++){
      a[x] = sc.nextInt();
      sum = sum + a[x];
      if(min > a[x]){
        min = a[x];
      }
      if(max < a[x]){
        max = a[x];
      }
    }
    System.out.println(min+" "+max+" "+sum);
  }
}


Measured memory_bytes: 42720
#include<iostream>
using namespace std;
int main()
{
  long long n,d,x,y;
  cin>>n>>d;
  int number=0;
  for(int i=0;i<n;i++)
  {
    cin>>x>>y;
    long long t=x*x+y*y;
    if(t<=(d*d))
      number++;
  }
  cout<<number<<endl;
  return 0;
}

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

using namespace std;

int main(){
    int D,G,p[11],c[11];
    cin >> D >> G;

    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;

    //maskが10101011とかで全ての通りを表してくれる。
    for(int mask = 0; mask < (1 << D); mask++){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; i++){
            // >> と　&なら　>>　優先
            //0 以上 2^D − 1 以下の整数それぞれの 2 進数表記を 
            //D回の選択を表すリストのようなものとして用いる
            //下から i 桁目 (0 ≤ i < D) が 1 なら 100(i + 1) 点を完全
                //に解き、0 なら完全には解かない
            if(mask >> i & 1){
                s += 100*(i+1) * p[i] + c[i];
                num += p[i];            
            }else{
                //別に確たる理由があってここに入るわけではないので
                //下でちゃんと判定してもらわないといけない。
                //結局は最後に０が出たところで代入される
                rest_max = i;
            }
        } 

        if(s < G){
            //一問あたりの得点
            int s1 = 100*(rest_max + 1);
            //必要な残りの問題数。割る数s1を足しておくことで商が一門分足りなくなるのを防ぐ。
            //しかしちょうど割り切れたときに一門分増えるので-1で一門分増えるのを防ぐ。
            int need = (G -s + s1 -1) / s1;
            //残っている問題数より必要な問題数が多かったら最初からやり直し。
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        //最小値の更新
        ans = min(ans,num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256