akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	int num,i,j,flag,cnt;
	int prime[170];

	for(i = 0;i < 170;i++){
		prime[i] = 0;
	}
	prime[0] = 2;

	while(scanf("%d",&num) != EOF){
		if(num == 1){
			cnt = 0;
		}else{
			cnt = 1;
		}
		for(i = 3;i <= num;i += 2){
			flag = 1;
			for(j = 0;prime[j]*prime[j] <= i;j++){
				if(i % prime[j] == 0){
					flag = 0;
					break;
				}
			}
			if(flag){
				if(cnt < 170 && prime[cnt] == 0){
					prime[cnt] = i;
				}
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> vec(N, vector<int>(N,99));

  rep(i, N){
    cin >> A[i];
    int x,y;
    rep(j,A[i]){
      cin >> x >> y;
      vec[i][x - 1] = y;
    }
  }

  int anstmp = 0;
  int ans = 0;
  // すべての選び方を試して調べる
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);  // 最大15個なので15ビットのビット列として扱う
    bool ok = true;
    rep(i, N){
      if(s.test(i)){
        rep(j, N){
          if(vec[i][j] == 99) continue;
          else if(vec[i][j] == s.test(j)) ok = true;
          else{
            ok = false;
            break;
          }
        }
      }
      if(!ok) break;
    }
    if(ok){
      anstmp = s.count();
      ans = max(ans, anstmp);
    }
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n;
vector<ll> v;
ll d[100001];

int main(int argc, char **argv) {
	cin >> n;
	ll t = 1;
	v.push_back(1);
	REP(i, 10) if (t*6 <= n) v.push_back(t *= 6);
	t = 1;
	REP(i, 10) if (t*9 <= n) v.push_back(t *= 9);
	d[0] = 0;
	REP(i, n) d[i+1] = INF;
	REP(i, n) REP(j, v.size()) if (i + v[j] <= n) d[i + v[j]] = min(d[i + v[j]], d[i] + 1);
	cout << d[n] << endl;
	return 0;
}
 

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 37348
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define inf 2000000007
#define pb push_back
#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;

int32_t main(){
	fastio;
	int n;
	cin>>n;
	int pre[n+1];
	pre[0]=0;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pre[i] = pre[i-1]+a[i];
	}
	int res=inf;
	for(int T=1;T<=n;T++){
		int a1 = pre[T];
		int a2 = pre[n]-pre[T];
		res=min(res,abs(a1-a2));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2005;
int n,m,ans,tot,lnk[maxn],son[2*maxn],nxt[2*maxn];
bool vis[maxn];
struct edge{
	int x,y;
}a[maxn];
void adde(int x,int y){
	son[++tot]=y,nxt[tot]=lnk[x],lnk[x]=tot;
	son[++tot]=x,nxt[tot]=lnk[y],lnk[y]=tot;
}
void dfs(int x,int lim){
	if (lim==0) return;
	for (int j=lnk[x];j;j=nxt[j])
	if (!vis[son[j]]){
		vis[son[j]]=1;
		dfs(son[j],lim-1);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		adde(a[i].x,a[i].y);
	}
	if (m%2==0){
		for (int i=1;i<=n;i++){
			memset(vis,0,sizeof(vis));
			vis[i]=1; dfs(i,m/2);
			int sum=0;
			for (int j=1;j<=n;j++) sum+=vis[j];
			ans=max(ans,sum);
		}
	} else {
		for (int i=1;i<n;i++){
			memset(vis,0,sizeof(vis));
			vis[a[i].x]=vis[a[i].y]=1;
			dfs(a[i].x,(m-1)/2); dfs(a[i].y,(m-1)/2);
			int sum=0;
			for (int j=1;j<=n;j++) sum+=vis[j];
			ans=max(ans,sum);
		}
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
int main(){
    std::string s,t;std::cin>>s>>t;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s==t){
            std::cout<<"Yes"<<std::endl;
            return 0;
        }
        std::rotate(t.begin(),t.begin()+1,t.end());
    }
    std::cout<<"No"<<std::endl;
}



Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
N, L = F.readline().rstrip().split()
N = int(N)
L = int(L)
a = [F.readline().rstrip() for x in range(N)]

a.sort()
answer = ''.join(a)
print(answer)



Measured memory_bytes: 5248
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, B, C;
  cin >> A >> B >> C;
  cout << min(B/A,C) << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> cnt(n);
    for (ll i = 1; i < n; i++)
    {
        ll a;
        cin >> a;
        cnt[a - 1]++;
    }
    for (ll i = 0; i < n; i++)
        cout << cnt[i] << endl;
}


Measured memory_bytes: 4760
using System;
using System.Collections.Generic;
using System.Linq;

namespace csat
{
    class Program
    {
        static void Main(string[] args)
        {
            var num=int.Parse(Console.ReadLine());
            var hs=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var len=0;
            var res=0;
            for(int i=num-2;i>=0;i--)
                if(hs[i]>=hs[i+1])
                    len++;
                else {res=Math.Max(res,len);len=0;}
            Console.WriteLine(Math.Max(res,len));
        }
    }
}


Measured memory_bytes: 24156
#include <stdio.h>

int main(int argc, char *argv[])
{
        int H, W;
        int i, j;

        while (1) {
                scanf("%d %d", &H, &W);
                if (H == 0 && W == 0) break;

                for (i = 0; i < H; i++) {
                        for (j = 0; j < W; j++) {
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }

        return 0;
}

Measured memory_bytes: 572
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

class Node{
public:
	int data;
	Node *prev,*next;
};

Node *nil;

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
} 

void insert(int x){
	Node *ins = (Node *)malloc(sizeof(Node));
	ins->data = x;
	ins->next = nil->next;
	nil->next->prev = ins;
	nil->next = ins;
	ins->prev = nil;
}

void deleteNode(Node *n){
	if(n == nil) return;
	n->prev->next = n->next;
	n->next->prev = n->prev;
	free(n);
}

void deleteNodeData(int x){
	Node *t = nil->next;
	while(true){
		if(t == nil) break;
		if(t->data == x) {
			deleteNode(t);
			break;
		}
		t = t->next;
	}
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void printNode(){
	Node *t = nil->next;
	while(true){
		if(t == nil) break;
		cout << t->data;
		if(t->next != nil){
			cout << " ";
		}
		t = t->next;
	}
	printf("\n");
}

int main(){
	char s[20];
	int x,n;
	cin >> n;
	string ss;
	init();
	for(int i = 0 ;i < n;i++){
		scanf("%s",s);
		ss = s;
		if(ss == "insert"){
			cin >> x;
			insert(x);
		}else if(ss == "deleteFirst"){
			deleteFirst();
		}else if(ss == "deleteLast"){
			deleteLast();
		}else{
			cin >> x;
			deleteNodeData(x);
		}
	}
	printNode();
	return 0;
}

Measured memory_bytes: 32488
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	ll ans = 0;
	if(p == 2) {
		rep(i, n) if((s[i]-'0') % 2 == 0) ans += i + 1;
		cout << ans << endl;
		return 0;
	}
	if(p == 5) {
		rep(i, n) if((s[i]-'0') % 5 == 0) ans += i + 1;
		cout << ans << endl;
		return 0;
	}

	reverse(s.begin(), s.end());
	ll base = 1;
	ll cur = 0;
	map<ll, ll> mp;
	rep(i, n) {
		cur = (base * (s[i]-'0') + cur) % p;
		if(cur == 0) ans++;
		base = (base * 10) % p;
		ans += mp[cur];
		mp[cur]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
const int maxn=10000005;
bool cmp(int a,int b)
{
	return a>b;
}
int a[maxn],s;
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n,cmp);
	for(int i=0;i<k;i++)
	{
		s+=a[i];
	}
	cout<<s<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int d;
    cin >> d;
    if (d == 25)
        OP("Christmas");
    if (d == 24)
        OP("Christmas Eve");
    if (d == 23)
        OP("Christmas Eve Eve");
    if (d == 22)
        OP("Christmas Eve Eve Eve");

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MMS(x, y) memset((x), (y), sizeof(x))
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define EPS 1e-9
#define EPSS 1e-10

#define MAXN 1010
#define MAXL 5010
#define SEGN 300030
using namespace std;

int N;
int X[MAXN], dp[MAXN];
vector <int> adj[MAXN];
int tdp[MAXL];
void dfs(int cur) {
    if (adj[cur].size() == 0) {
        dp[cur] = 0;
        return;
    }
    ll totw = 0;
    bool flag = false;
    for (int i : adj[cur])
        dfs(i);
    memset(tdp, 0, sizeof tdp);
    for (int i : adj[cur]) {
        totw += X[i];
        totw += dp[i];
        if (!flag) {
            flag = true;
            if (X[i] < MAXL) tdp[X[i]] = 1;
            if (dp[i] < MAXL) tdp[dp[i]] = 1;
        } else {
            for (int j = MAXL - 1; j >= 0; j--) {
                if (tdp[j]) {
                    tdp[j] = 0;
                    if (j + X[i] < MAXL) tdp[j + X[i]] = 1;
                    if (j + dp[i] < MAXL) tdp[j + dp[i]] = 1;
                }
            }
        }
    }
    int ans = INF;
//    cout << cur << ":    " << ans << "\n";
//    for (int i = 0; i < 10; i++)
//        cout << tdp[i] << " ";
    for (int i = 0; i <= X[cur]; i++) {
        if (tdp[i])
            ans = i;
    }
    if (ans > X[cur]) {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    dp[cur] = totw - ans;
}
void print(int i) {
    cout << i << "\n";
}
int main() {
    cin >> N;
    for (int i = 2, a; i <= N; i++) {
        cin >> a;
        adj[a].push_back(i);
    }
    for (int i = 1; i <= N; i++) {
        cin >> X[i];
    }
    dfs(1);
//    for_each(dp + 1, dp + N + 1, print);
    cout << "POSSIBLE";
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n = int(input())
d = {}

for x in input().split():
    a = int(x)
    if a not in d:
        d[a] = 0
    d[a] += 1

ret1 = 0
ret2 = 0
kk = list(d.keys())
kk.sort(reverse=True)
for k in kk:
    if d[k]>=4 and ret1==0:
        ret1 = k**2
        if ret2==0:
            break
    if d[k]>=2:
        if ret2==0:
            ret2 = k
        elif ret2>0:
            ret2 *= k
            break
print(max(ret1,ret2))


Measured memory_bytes: 23848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            char a = in.next().charAt(0);
            out.println('a' <= a && a <= 'z' ? "a" : "A");

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 32720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

}

Measured memory_bytes: 24364
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

//------------------------------------------------------------------------------
const int UF_SIZE = 100010;

int par[UF_SIZE];
int rnk[UF_SIZE];
int siz[UF_SIZE];

void union_find_init(int n) {
  REP(i, n) {
    par[i] = i;
    rnk[i] = 0;
    siz[i] = 1;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
    siz[y] += siz[x];
  } else {
    par[y] = x;
    siz[x] += siz[y];
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int size(int x) {
  return siz[find(x)];
}

//------------------------------------------------------------------------------
const int N_MAX = 100000;
const int M_MAX = 100000;

int N, M;
int p[N_MAX];
int x[M_MAX];
int y[M_MAX];

void solve() {
  union_find_init(N);
  REP(i, M) unite(x[i], y[i]);
  int ans = 0;
  REP(i, N) {
    if (size(i) == 1) {
      if (p[i] == i) ans++;
    } else {
      if (find(i) == find(p[i])) ans++;
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) {
    scanf("%d", p + i);
    --p[i];
  }
  REP(i, M) {
    scanf("%d%d", x + i, y + i);
    --x[i];
    --y[i];
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 2560
n=int(input())
#L=list(map(int,input().split()))
#a,b=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))

ans=sum(B)
for i in range(n-1):
  if A[i+1]==A[i]+1:
    ans+=C[A[i]-1]
print(ans)
#data_list = [ list(map(int,input().split(" "))) for i in range(3)]

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

vector<vector<int>> roads;
vector<int> query;

void dfs(int now, int back){
    for(int i: roads[now]){
        if(i == back){
            continue;
        }
        query[i] += query[now];
        dfs(i, now);
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    roads.resize(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        roads[a].push_back(b);
        roads[b].push_back(a);
    }
    query.resize(N, 0);
    for(int i = 0; i < Q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        query[p] += x;
    }
    dfs(0, -1);
    for(int i = 0; i < N - 1; i++){
        cout << query[i] << " ";
    }
    cout << query[N - 1] << endl;
}


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

int main()
{
    long long N, K;
    cin>>N>>K;

    vector<long long> A, B;
    A.push_back(1);
    B.push_back(N);
    for (long long i=2; i*i<=N; i++)
        if (N/i != N/(i-1))
        {
            A.push_back(i);
            B.push_back(N/i);
        }

    for (int i=(int)A.size()-1; i>=0; i--)
        if (A[i]!=B[i])
        {
            A.push_back(B[i]);
            B.push_back(A[i]);
        }

    //cout<<A.size()<<endl;

    //for (int i=0; i<(int)A.size(); i++)
    //    cout<<A[i]<<" "<<B[i]<<endl;
    //cout<<"--"<<endl;

    long long n = (long long)A.size();
    
    map<long long, long long> R;
    for (long long i=0; i<n; i++)
        R[A[i]] = i;

    vector<long long> TN(n);
    TN[0] = A[0];
    for (long long i=1; i<n; i++)
        TN[i] = A[i]-A[i-1];

    vector<long long> T = TN;

    //cout<<0<<endl;
    //for (long long t: T)
    //    cout<<" "<<t;
    //cout<<endl;

    long long M = 1000000007LL;
    for (int k=1; k<K; k++)
    {
        vector<long long> P(n);
        P.swap(T);

        vector<long long> D(n+1);
        for (long long i=0; i<n; i++)
        {
            D[0] += P[i];
            D[0] %= M;
            long long t = R[B[i]];
            D[t+1] -= P[i];
            D[t+1] = (D[t+1]+M)%M;
        }
        long long t = 0;
        for (long long i=0; i<n; i++)
        {
            t += D[i];
            t %= M;
            T[i] = t*TN[i]%M;
        }

        //cout<<k<<endl;
        //for (long long t: T)
        //    cout<<" "<<t;
        //cout<<endl;
    }

    long long ans = 0;
    for (long long i=0; i<n; i++)
    {
        ans += T[i];
        ans %= M;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7236
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        byte[] S;
        S = scanner.next().getBytes();
        int abcCount=0;
        for(int i=0;i<N-2;i++){
            if(S[i]=='A' && S[i+1]=='B'&& S[i+2]=='C'){
                abcCount++;
            }
        }
        System.out.println(abcCount);
    }
}






Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 51;

int a[MAX_N];

int main()
{
    while(1){
        int n,p;
        cin >> n >> p;
        if(n == 0){
            break;
        }
        rep(i,n){
            a[i] = 0;
        }
        int np = p;
        bool flag = false;
        int ans;
        while(1){
            rep(i,n){
                if(np == 0){
                    np = a[i];
                    a[i] = 0;
                }else if(np == 1){
                    a[i]++;
                    np--;
                    if(a[i] == p){
                        flag = true;
                        ans = i;
                        break;
                    }
                }else{
                    a[i]++;
                    np--;
                }
            }
            if(flag){
                break;
            }
        }
        cout << ans << "\n";
    }
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	int K, N;
	vector<int> A;
	vector<int> B;
	cin >> K >> N;
 
	for(int i = 0; i<N; i++){
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

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

	for(int i = 0; i<N; i++){
		int tmp;
		if(i == N-1){
			tmp = A[0] - A[N-1];
		}else{
			tmp = A[i+1] - A[i];
		}
		if(tmp < 0){
			tmp = K + tmp;
		}
		B.push_back(tmp);
	}

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

	cout << (K - B[N-1]);

	return 0;
}

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

int main() {
 long long M,D,X=0;
  cin >> M >> D;
  for(int i=1; i <= M; i++){
     for(int j=22; j <= D; j++){
       if(j%10 >= 2 && j/10 >= 2 && (j%10)*(j/10) == i){
         X++;
       }
     }
  }
  cout << X << endl;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        for(int i=0;i<s.Length;i++){
            Console.Write(s[i]);
            if(i == 3){
                Console.Write(" ");
            }
        }
        Console.WriteLine("");
    }
    void getinput(){
        s = Console.ReadLine();
    }    
}

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

int main() {
  while(true) {
    int ncard1, ncard2;
    cin >> ncard1 >> ncard2;
    if(!ncard1 && !ncard2) break;
    set<int> cards1;
    set<int> cards2;
    int total1 = 0;
    int total2 = 0;
    for(int i = 0; i < ncard1; ++i) {
      int n;
      cin >> n;
      cards1.insert(n);
      total1 += n;
    }
    for(int i = 0; i < ncard2; ++i) {
      int n;
      cin >> n;
      cards2.insert(n);
      total2 += n;
    }
    if((total1 + total2) % 2) {
      cout << -1 << endl;
      continue;
    }
    bool flag = false;
    for(auto i = cards1.begin(); i != cards1.end(); ++i) {
      auto j = cards2.find(((total1 + total2) / 2) - (total1 - *i));
      if(j != cards2.end()) {
        cout << *i << " " << *j << endl;
        flag = true;
        break;
      }
    }
    if(!flag) cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc140/tasks/abc140_b

N = int(input())
A = list(map(int, input().split()))  # 料理を食べた順番
B = list(map(int, input().split()))  # 料理の基本満足度
C = list(map(int, input().split()))  # 料理の追加満足度

satisfaction = 0
for idx in range(N):
    satisfaction += B[A[idx] - 1]
    if 0 < idx and A[idx - 1] + 1 == A[idx]:
        satisfaction += C[A[idx - 1] - 1]

print(satisfaction)


Measured memory_bytes: 3060
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;
 
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
 
  ll H,N; cin>>H>>N;
  vl A(N), B(N); REP(i,N) cin>>A[i]>>B[i];
 
  vvl dp(N+MGN, vl(H+MGN, LINF));
  REP(i,N) {
    FOR(j,1,H+MGN) {
      int num = (j+A[i]-1)/A[i];
      dp[i][j] = B[i]*num;
    }
  }
 
  FOR(i,1,N) {
    FOR(j,1,H+MGN) {
      dp[i][j] = min(dp[i][j], dp[i-1][j]);
      if (j-A[i]>=0) {
        dp[i][j] = min(dp[i][j], dp[i][j-A[i]]+B[i]);
      }
      assert(dp[i][j] > 0);
    }
  }
  
  ll ans = dp[N-1][H];
  cout << ans << endl;
 
 
  return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int b[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	sort(b+1,b+n+1);
	if(b[n]/2>b[n-1]){
		printf("%d %d\n",b[n],b[n-1]);
		return 0;
	}
	if(b[n]/2<b[1]){
		printf("%d %d\n",b[n],b[1]);
		return 0;
	}
	int x1=lower_bound(b+1,b+n+1,b[n]/2)-b;
	int x2=x1-1;
	if(b[n]%2==0){
		if(b[x1]-b[n]/2>b[n]/2-b[x2])
			printf("%d %d\n",b[n],b[x2]);
		else
			printf("%d %d\n",b[n],b[x1]);
	}
	else{
		int x3=max(0,b[x1]-b[n]/2-1),x4=b[n]/2-b[x2];
		if(x3>x4)
			printf("%d %d\n",b[n],b[x2]);
		else
			printf("%d %d\n",b[n],b[x1]);
	}
	return 0;
}

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

using namespace std;

long long gcd(long long a, long long b)
{
    if(b == 0)
        return a;
    if(a % b == 0)
        return b;
    return gcd(b, a % b);
}

int main()
{
    long  long n, i, j, k, sum = 0, x;

    cin >> n;

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++)
        {
            for(k = 1; k <= n; k++)
            {
                x = gcd(i, j);
                sum += gcd(x, k);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;

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

  ll n, k;
  cin >> n >> k;
  vector < ll > a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  ll m = 64 - __builtin_clzll(k);

  if(k == 0){
    ll sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];
    cout << sum << endl;
    exit(0);
  }

  vector < pair < ll, ll > > bt(55, {0, 0});
  for(int i = 0; i < 55; i++){
    ll st = 0, nst = 0;
    for(int j = 0; j < n; j++){
      if((a[j] >> i) & 1){
        nst += ((ll)1 << i);
      }else st += ((ll)1 << i);
    }

    bt[i] = {nst, st};
  }

  vector < ll > p(m);
  p[0] = max(bt[0].first, bt[0].second);
  for(int i = 1; i < m; i++){
    p[i] = p[i - 1] + max(bt[i].first, bt[i].second);
  }

  ll ans = LLONG_MIN, sum = 0;
  for(int i = m; i < 55; i++) sum += bt[i].first;
  for(int i = m - 1; i >= 0; i--){
    if((k >> i) & 1){
      if(bt[i].first >= bt[i].second){
        ans = max(ans, sum + p[i]);
      }else{
        sum += bt[i].second;
      }
    }else{
      sum += bt[i].first;
    }
  }
  ans = max(ans, sum);

  cout << ans << '\n';
}


Measured memory_bytes: 1024
n = int(input())
m = len(str(n))
if m == 1:
  print(n)
elif m == 2:
  print(9)
elif m == 3:
  print(9 + n - 99)
elif m == 4:
  print(909)
elif m == 5:
  print(909 + n -9999)
else:
  print(90909)

Measured memory_bytes: 9084
import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

for _ in range(N-1):
    a, b = (int(x) - 1 for x in input().split())
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

print(*cnt)


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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,a[200000],t;
	cin>>n;
	vector<pair<int,int>> g;
	for (i=0;i<n;i++){
		cin>>t;
		g.push_back(make_pair(t,i));
	}
	sort(g.begin(),g.end());
	for (i=0;i<g.size();i++){
		int d1=g[i].second;
		if (2*i>=n){
			a[d1]=g[n/2-1].first;
		}
		else {
			a[d1]=g[n/2].first;
		}
	}
	for (i=0;i<n;i++){
		cout<<a[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4720
M,D=map(int, input().split())
count=0

for m in range(1,M+1):
    for dd in range(1,D+1):
        d_1=dd%10
        d_10=dd//10
        
        if (d_1>1 and d_10>1) and d_10*d_1==m:
            count+=1
            
print(count)
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

#define ll long long

const int maxn = 135000;
int f[maxn];

struct UnionSet {
    UnionSet(int n) {
        for (int i = 1; i <= n; i++) {
            f[i] = i;
        }
    }
    UnionSet(){}

    void uni(int x, int y) {
        f[find(x)] = find(y);
    }

    bool query(int x, int y) {
        return find(x) == find(y);
    }

    int find(int x) {
        return f[x] == x ? x : (f[x] = find(f[x]));
    }

} us;

int main(){
    int n,m;
    cin>>n>>m;
    us=UnionSet(n);
    int cnt=n;
    FOR(i,1,m){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(!us.query(x,y))us.uni(x,y),cnt--;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
typedef pair<int,int> pii;
int M[15][15],N[15][15];
int D[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
int main(){
	int n,m,x,y,o,r,c,s,a;
	scanf("%d%d",&n,&m);
	for(y=0;y<n;y++)for(x=0;x<n;x++)scanf("%d",M[y]+x);
	for(;m--;){
		scanf("%d%d",&o,&r);r--;
		if(o==0){
			scanf("%d%d%d",&c,&s,&a);c--;
			if(a){
				memcpy(N,M,sizeof(M));
				for(y=0;y<s;y++)for(x=0;x<s;x++){
					if(a==90)N[r+y][c+x]=M[r+s-x-1][c+y];
					else if(a==180)N[r+y][c+x]=M[r+s-y-1][c+s-x-1];
					else if(a==270)N[r+y][c+x]=M[r+x][c+s-y-1];
				}
				memcpy(M,N,sizeof(M));
			}
		}else if(o==1){
			scanf("%d%d",&c,&s);c--;
			for(y=r;y<r+s;y++)for(x=c;x<c+s;x++)M[y][x]^=1;
		}else if(o==2){
			y=M[r][0];for(x=0;x<n-1;x++)M[r][x]=M[r][x+1];
			M[r][n-1]=y;
		}else if(o==3){
			y=M[r][n-1];for(x=n-1;x>0;x--)M[r][x]=M[r][x-1];
			M[r][0]=y;
		}else if(o==4){
			scanf("%d",&c);c--;
			queue<pii>q;
			a=M[r][c],M[r][c]^=1;
			q.push(make_pair(r,c));
			for(;!q.empty();){
				pii p=q.front();q.pop();
				for(s=0;s<4;s++){
					y=p.first+D[s][0],x=p.second+D[s][1];
					if(0<=x&&x<n&&0<=y&&y<n&&M[y][x]==a){
						M[y][x]^=1;
						q.push(make_pair(y,x));
					}
				}
			}
		}
	}
	for(y=0;y<n;y++)for(x=0;x<n;x++)printf(x<n-1?"%d ":"%d\n",M[y][x]);
}

Measured memory_bytes: 1036
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)

typedef unsigned long ul;
using namespace std;

int n;
int A, B;

int main() {
    cin >> n;
    if (n == 1) cout << "Hello World";
    else {
        cin >> A >> B;
        cout << A + B;
    }
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    // aとbに入力
    for(int i=0; i < n; i++){
        cin >> a.at(i);
    }
    for(int i=0; i < m; i++){
        cin >> b.at(i);
    }

    rep(i,n-m+1){
        rep(j,n-m+1){
            bool x = true;
            //左から右にスライドさせ、一致しているか確認
            rep(k,m){
                // str.substr(開始位置,取り出す長さ)
                if(b.at(k) != a.at(i+k).substr(j,m)){
                    //どれか1つでも一致していない行があったらfalseに
                    x = false;
                }
            }
            if(x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

ll ans = 0;
ll N;

void func(bool seven,bool five,bool three,string now){
   if(now!=""&&atol(now.c_str()) > N)return;
   if(seven&&five&&three&&atoi(now.c_str())<=N)ans++;
   func(true,five,three,'7'+now);
   func(seven,true,three,'5'+now);
   func(seven,five,true,'3'+now);
}

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

   cin>>N;
   func(false,false,false,"");
   cout<<ans;
   return 0; 
}


Measured memory_bytes: 256
<?php
list($n) = ints();
$base = [
    [0, 0],
    [0, 10 ** 9],
    [10 ** 9, 0],
    [10 ** 9, 10 ** 9]
];
$mins = array_fill(0, 4, PHP_INT_MAX);
$maxs = array_fill(0, 4, 0);
for ($i = 0; $i < $n; ++$i) {
    list($x, $y) = ints();
    for ($j = 0; $j < 4; ++$j) {
        $d = abs($base[$j][0] - $x) + abs($base[$j][1] - $y);
        if ($d < $mins[$j]) $mins[$j] = $d;
        if ($d > $maxs[$j]) $maxs[$j] = $d;
    }
}
$max = 0;
for ($i = 0; $i < 4; ++$i) {
    if ($maxs[$i] - $mins[$i] > $max) $max = $maxs[$i] - $mins[$i];
}
echo $max;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    bool flag = false;
    rep(i, 8){
        string t = s.substr(0, i) + s.substr((int)s.size() - (7 - i), 7 - i);
        flag |= t == "keyence";
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    ans = 0
    N = parseInt(readline())
    for i in 1:N
        if (i % 3 != 0) && (i % 5 != 0)
            ans += i
        end
    end
    println(ans)
end


main()

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

int main(){
  int N,K,x;
  int sum=0;
  cin >> N >> K;
  
  for(int i=0; i < N; i++){
    cin >> x;
    
    if(x < K - x){
      sum += x*2;
    }else{
      sum += (K-x)*2;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for i in range(N)]

INF = 10**9+1000
SUM_V = sum([A[1] for A in WV])
dp = [[INF]*(SUM_V+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(N+1):
    dp[i][0] = 0

for n in range(0, N):
    for v in range(0, SUM_V+1):
        if v >= WV[n][1]:
            dp[n+1][v] = min(dp[n][v-WV[n][1]] + WV[n][0], dp[n][v])
        else:
            dp[n+1][v] = dp[n][v]

for n in range(0, N+1):
    for v in range(0, SUM_V+1):
        if dp[n][v] <= W:
            dp[n][v] = -1

print(max([max([i for i,v in enumerate(dd) if v == -1]) for dd in dp]))

Measured memory_bytes: 124932
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <functional>
using namespace std;
struct neiber
{
  int node;
  int dist;
};
struct distAndDiameter
{
  int dist;
  int diameter;
};
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<neiber>> neiberss(n, vector<neiber>(0));
  for (int i = 0; i < n - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    neiberss[s].push_back({t, w});
    neiberss[t].push_back({s, w});
  }
  function<distAndDiameter(int, int)> findDistAndDiameter = [&](int node, int parent) {
    // cout << "call findDistAndDiameter" << node << ","<<parent << endl;
    int maxDist = 0, secondMaxDist = 0, maxDiameter = 0;
    for (auto child : neiberss[node])
    {
      if (parent != child.node)
      {
        auto res = findDistAndDiameter(child.node, node);
        int temp = res.dist + child.dist;
        if (maxDist < temp)
          swap(maxDist, temp);
        if (secondMaxDist < temp)
          swap(secondMaxDist, temp);
        if (maxDiameter < res.diameter)
          maxDiameter = res.diameter;
      }
    }
    return distAndDiameter{maxDist, max(maxDist + secondMaxDist, maxDiameter)};
  };
  // cout << "World" << endl;
  auto res = findDistAndDiameter(0, -1);
  // cout << "!!" << endl;
  // cout << res.dist << endl;
  cout << res.diameter << endl;
}


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

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

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

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

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

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

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

// ---- ----

LL n, k, a[5000];
bool sum[5000];

bool f(LL x) {
	if(a[x] >= k) { return true; }
	
	inc(i, k) { sum[i] = false; }
	sum[0] = true;
	inc(i, n) {
		if(i == x) { continue; }
		dec(j, k) {
			if(sum[j] && j + a[i] < k) { sum[j + a[i]] = true; }
		}
	}
	
	incID(j, k - a[x], k) {
		if(sum[j]) { return true; }
	}
	return false;
}

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	sort(a, a + n);
	
	LL L = -1, R = n;
	while(R - L > 1) {
		LL M = (L + R) / 2;
		(f(M) ? R : L) = M;
	}
	
	cout << R << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string S;	cin >> S;
	for (int i = 0; i < S.size(); ++i) {
		for (int j = i + 1; j < S.size(); ++j) {
			if (S[i] == S[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
bool is(string s, string rs){
    rep(i, s.size()){
        if(s[i] != rs[i]){
            return false;
        }
    }
    return true;
}
int main(void){
    string s;
    cin >> s;
    string rs = s;
    reverse(all(rs));
    if(!is(s, rs)){
        cout << "No" << endl;
        return 0;
    }

    string s1 = s.substr(0, s.size() / 2);
    string rs1 = s1;
    reverse(all(rs1));

    if(!is(s1, rs1)){
        cout << "No" << endl;
        return 0;
    }

    string s2 = s.substr((s.size() + 1) / 2, s.size());
    string rs2 = s2;
    reverse(all(rs2));

    if(!is(s2, rs2)){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;


}

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    string s;
    cin >> s;
    int count=0;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R') count++;
        if(s[i]=='S') count=0;
        ans=max(count,ans);
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q), score(n);
    rep(i, n) score[i] = k;
    rep(i, q) {
        cin >> a[i];
        score[a[i] - 1]++;
    }
    rep(i, n) {
        if(score[i] <= q) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n, c = 0;
    cin >> n;
    int p[n], ans[n];
    REP(i, n) {
        cin >> p[i];
        if (p[i] != i + 1)
            c++;
    }
    if (c > 2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}


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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  
  if ( a + W < b ){
    cout << b - a- W ;
  }
  else if ( a - W <= b && b <= a + W ){
    cout << "0";
  }
  else if ( b + W < a ){
    cout << a - b - W;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(r) r.begin(),r.end()
using namespace std;
static const int32_t INF = 0x3F3F3F3F;
typedef int64_t ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x)x = y; }
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, m, r;
        in >> n >> m >> r;
        vll rr(r);
        rep(i, r) in >> rr[i];
        vvll cost(n, vll(n, INF));
        rep(i, m) {
            ll a, b, c;
            in >> a >> b >> c;
            cost[a - 1][b - 1] = c;
            cost[b - 1][a - 1] = c;
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (cost[i][j] > cost[i][k] + cost[k][j]) {
                        cost[i][j] = cost[i][k] + cost[k][j];
                    }
                }
            }
        }
        sort(all(rr));
        ll ans = INF;
        do {
            ll tmp = 0;
            for (int i = 0; i < r - 1; i++) {
                tmp += cost[rr[i] - 1][rr[i + 1] - 1];
            }
            amin(ans, tmp);
        } while (next_permutation(all(rr)));
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 640
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false)


int main()
{
    fastio;
    ll n,ct=0, c = 0,mx = -L;
    cin>>n;
    map<string,ll> m; 
    vector<string> v(n);
    set<string> ans;
    loop(i,0,n){
        cin>>v[i];
        m[v[i]]++;
    }
    loop(i,0,n){
        mx = max(m[v[i]], mx);
    }
    loop(i,0,n){
        if(m[v[i]] == mx){
            ans.insert(v[i]);
        }
    }
    for(auto itr = ans.begin();itr!=ans.end();itr++){
        cout<<*itr<<endl;
    }
}


    

Measured memory_bytes: 34816