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

int main(void) {
  char S[101];
  long K;
  int i,len;
  
  scanf("%s",S);
  scanf("%ld",&K);
  
  i = 0;
  len = strlen(S);
  
  while((i+1 < K)&&(S[i] == '1')&&(i+1 < len)) 
  	i++;  
  printf("%c\n",S[i]);
  return(0);
}
  


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<string.h>
#include<set>
#define LL long long
#define fr first
#define sc second
//#define mp make_pair
using namespace std;
LL read( ){LL sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) return -sum;return sum;}
void read(int &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
void read(LL &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
const int N=105;
int n,m,a,res;
char S[N][N];
queue<int>qx,qy;
int d[N][N];
const int dx[ ]={1,0};
const int dy[ ]={0,1};
vector<int>E[N];
struct ex{int num,next,w,c;}map[100*50*50*2+1005];
int head[100+50*50+105],len=1;
inline void link(int x,int y,int w,int c)
{
  len++;map[len].num=y;map[len].next=head[x];map[len].w=w;map[len].c=c;head[x]=len;
  len++;map[len].num=x;map[len].next=head[y];map[len].w=0;map[len].c=-c;head[y]=len;
}
void BFS(int x,int y)
{
  int i,j,xx,yy,mx=1;
  qx.push(x);qy.push(y);
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      d[i][j]=0;
  d[x][y]=1;
  while(!qx.empty( ))
    {
      x=qx.front( );qx.pop( );
      y=qy.front( );qy.pop( );
      for(i=0;i<=1;i++)
	{
	  xx=x+dx[i];
	  yy=y+dy[i];
	  if(xx>n||yy>m||S[xx][yy]=='#'||d[xx][yy]) continue;
	  d[xx][yy]=d[x][y]+1;
	  mx=max(mx,d[xx][yy]);
	  qx.push(xx);
	  qy.push(yy);
	}
    }
  res+=mx;
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      if(d[i][j]) link(a,100+(i-1)*m+j,1,mx-d[i][j]+1);
}
const int DN = 100+50*50+105;
int s,t,ans,dis[DN],pr[DN];
bool in[DN];
queue<int>q;
const int orz=1e9;
bool SPFA( )
{
  int i,x,y,c,w;
  for(i=1;i<=t;i++) dis[i]=orz;
  q.push(s);
  while(!q.empty( ))
    {
      x=q.front( );q.pop( );in[x]=0;
      for(i=head[x];i;i=map[i].next)
	if(map[i].w)
	  {
	    y=map[i].num;c=map[i].c;
	    if(dis[y]>dis[x]+c) 
	      {
		dis[y]=dis[x]+c;pr[y]=i;
		if(!in[y]) in[y]=1,q.push(y);
	      }
	  }
    }
  if(dis[t]==orz) return 0;
  for(w=orz,i=t;i!=s;i=map[x^1].num) x=pr[i],w=min(w,map[x].w);
  for(i=t;i!=s;i=map[x^1].num) x=pr[i],map[x].w-=w,map[x^1].w+=w;
  ans+=dis[t]*w;
  return 1;
}
int main( )
{
  int i,j;
  read(n);read(m);
  for(i=1;i<=n;i++) scanf("%s",S[i]+1);
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      {
	if(S[i][j]=='o')
	  {
	    a++;
	    BFS(i,j);
	  }
      }
  s=0;
  t=100+n*m+1;
  for(i=1;i<=a;i++) link(s,i,1,0);
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      link(100+(i-1)*m+j,t,1,0);
  while(SPFA( ));
  printf("%d",res-ans);
  return 0;
}


Measured memory_bytes: 5924
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    cout << 'x';
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int Hikyori = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int min = int.Parse(input[0]);
            int max = int.Parse(input[1]);
            for(int i = min; i <= max; i++)
            {
                if(i%Hikyori == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }
            Console.WriteLine("NG");

        }
            
    }
}


Measured memory_bytes: 27536
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(K, A, B) ? "OK" : "NG");

        sc.close();
    }

    static boolean solve(int K, int A, int B) {
        return IntStream.rangeClosed(A, B).anyMatch(x -> x % K == 0);
    }
}

Measured memory_bytes: 35724
#include <stdio.h>

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

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			scanf("%d",&B[i][j]);
		}
	}

	for(int i = 0; i < n; i++){
		for(int k = 0; k < l; k++){
			for(int j = 0; j < m; j++){
				C[i][k] += A[i][j]*B[j][k];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l-1; j++){
			printf("%lld ",C[i][j]);
		}
		printf("%lld\n",C[i][l-1]);
	}
}


Measured memory_bytes: 2104
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
int h,w,k;
cin>>h>>w>>k;
vector<vector <char> > c(h,vector<char>(w));
rep(i,h){
    rep(j,w){
        cin>>c[i][j];
    }
}
vector<vector <char> > d(h,vector<char>(w));
rep(i,h){
    rep(j,w){
        d[i][j]=c[i][j];
    }
}

int ans=0;
for(int bit=0;bit<(1<<h);++bit){
    for(int i=0;i<h;i++){
        if(bit&(1<<i)){
            rep(x,w)c[i][x]=',';}}
vector<vector <char> > vec(h,vector<char>(w));
rep(i,h){rep(j,w){vec[i][j]=c[i][j];}}
            for(int xx=0;xx<(1<<w);++xx){
                for(int j=0;j<w;j++){
                    if(xx&(1<<j)){
                        rep(x,h)c[x][j]=',';
                    }}
                    int count=0;
                    rep(p,h){
                        rep(q,w)if(c[p][q]=='#')count++;
                        }
                        if(count==k)ans++;
rep(e,h){rep(f,w)c[e][f]=vec[e][f];}
}   
rep(e,h){rep(f,w)c[e][f]=d[e][f];}
}

cout<<ans;
return 0;





}

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

int main() {
  int h, w, a, b;

  cin >> h >> w >> a >> b;
  int s[1005][1005];
  int row;
  vector<int> col(h);

  string ans;
  rep(i, h) {
    rep(j, w) {
      if (i < b && j < a) s[i][j] = 1;
      if (i >= b  && j >= a) s[i][j] = 1;
    }
  }


  rep(i, h) {
    rep(j, w) {
      cout << s[i][j];
    }
    puts("");
  }

  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int n,k;
    cin>>n>>k;
    if(n%k==0){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
l=[1 for i in range(26)]
L=[chr(i) for i in range(97,97+26)]
for j in range(len(s)):
  l[L.index(s[j])]+=1
ans=1
for k in range(26):
  ans*=l[k]
  ans%=(10**9+7)
print(ans-1)

Measured memory_bytes: 3188
#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())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 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 b, c, d;
lint memo[1001][1001];
lint perm[1001][1001];
lint fact[1001];
lint inv[1001];

long long power(long long x, long long n){
    long long res = 1;
    x %= MOD;
    while(n > 0LL){
        if(n & 1LL){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

lint factorial(lint n){
    if(fact[n] >= 0LL){
        return fact[n];
    }
    if(n == 0LL){
        return 1LL;
    }

    return fact[n] = n * factorial(n - 1) % MOD;
}

lint inv_fact(lint n){
    if(inv[n] >= 0LL){
        return inv[n];
    }

    return inv[n] = power(factorial(n), MOD - 2);
}

lint nPr(lint n, lint r){
    if(perm[n][r] >= 0LL){
        return perm[n][r];
    }

    return perm[n][r] = factorial(n) * inv_fact(n - r) % MOD;
}

lint solve(int n, int a){
    if(n == 0){
        return 1LL;
    }
    if(n < 0 || a > b){
        return 0LL;
    }
    if(memo[n][a] >= 0LL){
        return memo[n][a];
    }

    lint res = solve(n, a + 1);

    for(int i = c ; i <= d ; ++i){
        if(i * a > n){
            break;
        }
        res += ((solve(n - i * a, a + 1) * nPr(n, i * a) % MOD) * power(power(factorial(a), i), MOD - 2) % MOD) * inv_fact(i) % MOD;
        res %= MOD;
    }

    return memo[n][a] = res;
}

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

    int n, a;
    cin >> n >> a >> b >> c >> d;

    fill(memo[0], memo[n + 1], -1LL);
    fill(perm[0], perm[1001], -1LL);
    fill(fact, fact + 1001, -1LL);
    fill(inv, inv + 1001, -1LL);

    lint ans = solve(n, a);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;

#define rep(i,n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

const int mod = 1000000007;
const int INF = 1001001001;
int L[10];
int N, A, B, C;
int dfs(int i, int a, int b, int c, int cost) {
    if(i == N) {
        if(min({a, b, c}) == 0) return INF;
        else return abs(A-a) + abs(B-b) + abs(C-c) + cost - 30;
    }

    int ans1 = dfs(i+1, a + L[i], b, c, cost + 10);
    int ans2 = dfs(i+1, a ,b + L[i], c, cost + 10);
    int ans3 = dfs(i+1, a , b,c + L[i], cost + 10);
    int ans4 = dfs(i+1, a , b, c, cost);
    return min({ans1, ans2, ans3, ans4});
}
int main() {
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> L[i];
    int ans = dfs(0, 0, 0, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	int n;
	char w[100][11];
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%s", w[i]);
	}
	
	// 複数回発言していないかチェック
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (strcmp(w[i], w[j]) == 0) {
				printf("No\n");
				return 0;
			}
		}
	}
	
	// 一つ前の言葉の最後の文字が次の言葉の最初と違っていないか
	for (int i = 1; i < n; i++) {
		if (w[i-1][strlen(w[i-1])-1] != w[i][0]) {
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>

using namespace std;
 
struct UnionFind{
private:
  vector<int> data;
public:
  int N;
  UnionFind(int n) : data(n, -1), N(n){}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    --N;
    if(data[y] < data[x]) swap(x,y);
    data[x] += data[y];
    data[y] = x;
    return x != y;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x){ return -data[find(x)]; }
};

int main(){
  int N, R;
  cin >> N >> R;
  vector<int> P(N);
  UnionFind uf(N);
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
    uf.unite(i,P[i]);
  }
  map<long long,int> T;
  for(int i = 0; i < N; ++i){
    if(i != uf.find(i)) continue;
    ++T[uf.size(i)];
  }

  vector<bool> dp(R+1,false);
  dp[0] = true;

  for(auto e : T){
    int w, m;
    tie(w,m) = e;
    for(int k = 0; m > 0; ++k){
      int c = min(m, (1<<k));
      m -= c;
      vector<bool> dp_ = dp;
      for(int j = 0; j <= R; ++j){
        if(not dp[j]) continue;
        if(j+c*w > R) break;
        dp_[j+c*w] = true;
      }
      dp = dp_;
    }
  }
  if(dp[R]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 5212
//
//  main.cpp
//  Atcoder
//
//  Created by Keita on 2020/06/21.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

void doProblemA(){
    char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
    cin >> s;
    //>> a >> A >> b >> B >> c >> C >> d >> D >> e >> E >> f >> F >> g >> G >> h >> H >> i >> I >> j >> J >> k >> K >> l >> L >> m >> M >> n >> N >> o >> O >> p >> P >> q >> Q >> r >> R >> s >> S >> t >> T >> u >> U >> v >> V >> w >> W >> x >> X >> y >> Y >> z >> Z;
    if(s >= 'A' && s <= 'Z'){
  //if(isupper(s)){
       //α == a or α == b or α == c or α == d or α == e or α == f or α == g or α == h or α == i or α == j or α == k or α == l or α == m or α == n or α == o or α == p or α == q or α == r or α == s or α == t or α == u or α == v or α == w or α == x or α == y or α == z){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
}

void doProblemB(){
    int N, K;
    cin >> N >> K;
    vector<int> v;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    
    sort(v.begin(),v.end());
    
    int answer;
    
    for(int i = 0; i < K; i++){
        answer += v[i];
    }
    
    cout << answer << endl;
}

void doProblemC(){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemC();
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
const long mod=1e9+7;
long dp[102][N+2],aa[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=n;i++)
    cin>>aa[i];
  for(int i=0;i<=k;i++)dp[0][i]=1;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=k;j++)
    {
      long sm=dp[i-1][j];
      int ii=max(j-aa[i],0LL);
      if(ii)sm=(sm-dp[i-1][ii-1]+mod)%mod;
      dp[i][j]=sm;
    }
    if(i==n)continue;
    for(int j=1;j<=k;j++)
      dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
  }
  cout<<dp[n][k]<<endl;
  return 0;
}

Measured memory_bytes: 79360
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 
 
//a*x + MOD*y = 1の整数解を求める。その中で最小の正数xがaの逆元となる。
//解き方は、ユークリッドの互除法
//参考：http://arc360.info/algo/privatekey.html
long modinv(long a, long m) {
  long b = m, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; SWAP(long,a, b);
    u -= t * v; SWAP(long,u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

//nCmを求める
long combination(int n, int m){
    long ans=1;

    for(int i=n;i>(n-m);i--) ans=(ans*i)%MOD;
    for(int i=2;i<=m;i++) ans=(ans*modinv(i,MOD))%MOD;

    return ans;
}

int main(void){
    int X,Y;
    scanf("%d%d",&X,&Y);

    long ans;
    if((X+Y)%3!=0) ans=0;
    else{
        int m=(2*Y-X)/3; //(i+1,j+2)の回数
        int n=(2*X-Y)/3; //(i+2,j+1)の回数

        if(m<0 || n<0) ans=0;
        else ans=combination(m+n,n);
    }

    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,a,b;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    }else{
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,m;
	string s,t;
	cin >> n;
	map<string, int> mp;
	REP(i,n){
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	REP(i,m){
		cin >> t;
		mp[t]--;
	}
	int ans = 0;
	for(auto a : mp) ans = max(ans,a.second);
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int ans=1;
    if(n<4){cout<<1<<endl;return 0;}
    for(int i=2;i<=31;i++){
        if(i*i>n)continue;
        int p=i;
        while(p*i<=n){
            p*=i;
        }
        ans=max(ans,p);
    }
    cout<<ans<<endl;
}


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

int main(){
    string S ,T;
    cin >> S >> T;
    bool ans = false;
    rep(i,S.size()){
        if(S == T) ans = true;
        S = S.back() + S.substr(0,S.size()-1);
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}   


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll X;
    cin >> X;
    ll init = 100;
    const double interest = 1.01;
    ll count = 0;
    while(init < X)
    {
        init *= interest;
        count++;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3640
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

#define endl codeforces

#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
using size_type = ssize_t;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T, std::size_t Head, std::size_t... Tail> 
struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };

template <typename T, std::size_t Head> 
struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };

template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { 
    if constexpr (std::is_invocable<F, Args...>::value) { 
        t = f(args...); 
    } else { 
        for (size_type i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); 
    } 
}
#endif

template <typename T> vec<T> make_v(size_type sz) { return vec<T>(sz); }

template <typename T, typename... Tail> 
auto make_v(size_type hs, Tail&&... ts) { 
    auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); 
    return vec<decltype(v)>(hs, v); 
}

namespace init__ { 
struct InitIO { 
    InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } 
} init_io; 
}
#define CPP17


int main() {
    ll n;
    std::cin >> n;
    std::cout << (1000 - n % 1000) % 1000 << "\n";
    return 0;
}


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

int main() {
    string s;
    int cnt=0;
    cin >> s;
    if(s[0]=='o') ++cnt;
    if(s[1]=='o') ++cnt;
    if(s[2]=='o') ++cnt;
    cout << 700+100*cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;

using namespace std;

int main()
{
    int N, M, X, Y, tmp;
    int xma = -200;
    int ymi = 200;
    cin >> N >> M >> X >> Y;

    REP(i, N)
    {
        cin >> tmp;
        xma = max(xma, tmp);
    }
    xma = max(X, xma);

    REP(i, M)
    {
        cin >> tmp;
        ymi = min(ymi, tmp);
    }
    ymi = min(Y, ymi);

    if (xma < ymi)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# GRL_3_A : Articulation Point

import sys

sys.setrecursionlimit(100000)

# input
v, e = map(int, sys.stdin.readline().strip().split())
G = [[] for _ in range(v)]
indeg = [0] * v
for i in range(e):
    s, t = map(int, sys.stdin.readline().strip().split())
    G[s].append(t)
    G[t].append(s)
    indeg[t] += 1

# calc
visit = [False] * v
lowest = [v+1] * v
prenum = [-1] * v
parent = [-1] * v
time = 0


def dfs(current, prev):
    global time
    prenum[current] = time
    lowest[current] = time
    visit[current] = True
    time += 1

    for i in G[current]:
        next = i
        if not visit[next]:
            parent[next] = current

            dfs(next, current)
            lowest[current] = min(lowest[current], lowest[next])
        elif next != prev:
            lowest[current] = min(lowest[current], prenum[next])


def art_points():
    dfs(0, -1)

    np = 0  # root が子を2つ以上持つかカウントする
    articulationPoint = [] # 関節点を保存するリスト
    for i in range(1, v):
        if parent[i] == 0:
            np += 1
        elif lowest[i] >= prenum[parent[i]]:
            if parent[i] not in articulationPoint:
                articulationPoint.append(parent[i])

    if np > 1:
        articulationPoint.append(0)

    # articulationPoint = list(set(articulationPoint))
    articulationPoint.sort()

    return articulationPoint


def main():
    ans = art_points()
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()



Measured memory_bytes: 19432
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    K = int(input())
    if K % 2 == 0:
        print(int((K / 2) ** 2))
    else:
        print(int(((K - 1) / 2) * int((K + 1) / 2)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
f=lambda:map(int,input().split())
n,m=f()
g=[set() for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1].add(b-1)
  g[b-1].add(a-1)
from itertools import *
p=[*permutations(range(1,n))]
c=0
for t in p:
  v=0
  for i in t:
    if i in g[v]: v=i
    else: break
  else: c+=1
print(c)

Measured memory_bytes: 9364
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
using namespace std;


int main(int argc, const char * argv[]) {
  int n, l;
  cin >> n >> l;
  vector<int> taste(n,0);
  for(int i = 1; i <= n; i++){
    taste.at(i-1) = l + i - 1;
  }

  int mIndex = -1;
  int m = 99999;
  for(int i = 0; i < n; i++){
    if(m > abs(taste.at(i))){
      m = abs(taste.at(i));
      mIndex = i;
    }
  }
  int result = 0;
  for(int i = 0; i < n; i++){
    if(mIndex == i){
      continue;
    }
    result += taste.at(i);
  }
  cout << result << endl;
  return 0;
}


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

// https://www.geeksforgeeks.org/z-algorithm-linear-time-pattern-searching-algorithm/

vector<int> Z_Algorithm(const string& s) {
    int n = s .size();
    vector<int> z(n+1);
    int l = 0, r = 0, k;
    for ( int i = 1; i < n; i++ ) {
        if ( i > r ) {
            l = r = i;
            while ( r < n && s[r-l] == s[r]) r++;
            z[i] = r - l;
            r--;
        } else {
            k = i - l;
            if ( z[k] < r - i + 1 ) {
                z[i] = z[k];
            } else {
                l = i;
                while ( r < n && s[r-l] == s[r] ) r++;
                z[i] = r - l;
                r--;
            }
        }
    }
    return z;
}

ll solve() {
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll ans = 0;
    for ( int k = 0; k < N; k++ ) {
        auto z = Z_Algorithm(S.substr(k));
        for ( int i = 1; i < z.size(); i++ ) {
            int x = min(z[i], i);
            if ( ans < x ) ans = x;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
	std::string input;
	int sum;
	while(1){
		sum = 0;
		std::cin >> input;
		if(input == "0")
			break;
		for(int i=0; i<input.size(); i++)
			sum += input[i] - '0';
		std::cout << sum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h> 
double round(double);
using namespace std;
int main(){
  int A, B, C, D, s, t;
  cin>>A>>B>>C>>D;
  s=(A+D-1)/D;
  t=(C+B-1)/B;
    if(s>=t){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }   
}


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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> ans(n,k);
    for(int i=0;i<q;i++){
        int a;
        cin >> a;
        ans.at(a-1)++;
    }
    for(int i=0;i<n;i++){
        //cout << i<< ": " << ans.at(i) - q << ": ";
        if(ans.at(i)-q<=0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
using namespace std;
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=1009;
vector<int> v;
int main(){
    GO();
    string st;
    cin>>st;
    string ss;
    ss="";
    for(int i=0;i<sz(st);i++){

        if(st[i]=='/'){
            int num=atoi(ss.c_str());
            v.pb(num);
            ss="";
        }
        else{
            ss+=st[i];
        }
    }
    int num=atoi(ss.c_str());
    v.pb(num);

    if(v[0]<2019){
        cout<<"Heisei"<<endl;
    }
    else if(v[0]>2019){
        cout<<"TBD"<<endl;
    }
    else{
        if(v[1]<4){
            cout<<"Heisei"<<endl;
        }
        else if(v[1]>4){
            cout<<"TBD"<<endl;
        }
        else{
            if(v[2]<30){
                cout<<"Heisei"<<endl;
            }
            else if(v[2]>30){
                cout<<"TBD"<<endl;
            }
            else{
                cout<<"Heisei"<<endl;
            }
        }
    }

}


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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];
            if (B%A == 0 )
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(B-A);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <algorithm>

using namespace std;

int a[2000];
int dp1[2000001];
int dp2[2000001];

int main() {
    int n, sum1 = 0, sum2 = 0, mid, ans, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    dp1[0] = dp2[0] = 1;
    
    for (i = 0; i < n / 2; i++) {
        sum1 += a[i];
        
        for (j = sum1; j >= a[i]; j--) dp1[j] |= dp1[j - a[i]];
    }
    
    for (i = n / 2; i < n; i++) {
        sum2 += a[i];
        
        for (j = sum2; j >= a[i]; j--) dp2[j] |= dp2[j - a[i]];
    }
    
    dp2[sum2] = sum2;
    
    for (j = sum2 - 1; j >= 0; j--) {
        if (dp2[j] == 1) {
            dp2[j] = j;
        } else {
            dp2[j] = dp2[j + 1];
        }
    }
    
    mid = (sum1 + sum2 + 1) / 2;
    ans = sum1 + sum2;
    
    for (j = max(mid - sum2, 0); j <= sum1; j++) {
        if (dp1[j] == 1) ans = min(ans, j + dp2[max(mid - j, 0)]);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 15744
from collections import defaultdict

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

H,W = map(int, input().split())
S = [input() for _ in range(H)]

uf = UnionFind(H*W)

for i in range(H):
    for j in range(W):
        if 0 <= i < H-1:
            if S[i][j] != S[i+1][j]:
                uf.unite(W*i+j, W*(i+1)+j)
 
        if 0 <= j < W-1:
            if S[i][j] != S[i][j+1]:
                uf.unite(W*i+j, W*i+j+1)


black = defaultdict(int)
white = defaultdict(int)
unions = set(uf.parent)
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            black[uf.root(W*i+j)] += 1
        else:
            white[uf.root(W*i+j)] += 1
ans = 0
for u in unions:
    ans += black[u] * white[u]

print(ans)

Measured memory_bytes: 37100
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")
// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < (int)bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1), ans(Q);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];
   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());
   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }
   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);
   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);
   BIT<int> bit(N);
   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }
   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      {
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }
      if (pos[c[l]].empty())
         continue;
      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }
   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62628
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  string s;cin>>s;
  int n=s.length();
  int po=0;
  rep(i,n){
    if(s[i]=='x')po++;
  }
  if(po>=8)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, a[11][11];
  int i, j, add;

  scanf("%d", &n);
  while(n != 0){
    for(i = 0; i < n; i++){
      a[i][n] = 0;
      a[n][i] = 0;
    }
    add = 0;
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
        scanf("%d", &a[i][j]);
        a[i][n] += a[i][j];
        a[n][j] += a[i][j];
        add += a[i][j];
      }
    }
    a[n][n] = add;

    for(i = 0; i <= n; i++){
      for(j = 0; j <= n; j++){
        printf("%5d", a[i][j]);
      }
      printf("\n");
    }
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 1808
import math

def distance(N, D, point):
    count = 0
    for i in range(N):
        if math.sqrt(points[i][0]**2 + points[i][1]**2) <= D:
            count += 1
    return count


if __name__ == "__main__":
    N, D = map(int, input().split())
    points = []
    for _ in range(N):
        x, y = map(int, input().split())
        points.append([x,y])
    print(distance(N,D,points))

Measured memory_bytes: 39232
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

}

Measured memory_bytes: 21844
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto A = readln.chomp.to!int;
    auto B = readln.chomp.to!int;
    auto C = readln.chomp.to!int;
    auto D = readln.chomp.to!int;
    auto E = readln.chomp.to!int;

    auto ts = [A, B, C, D, E];
    sort!"(a+9)%10 < (b+9)%10"(ts);
    auto r = ts[0];
    foreach (t; ts[1..$]) {
        r += (t+9)/10*10;
    }
    writeln(r);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;
bool P(int x){
  for (int i = 2; i * i <= x; i++){
    if (x % i == 0){
      return false;
    }
  }
  return true;
}
int main(){
  FASTER;
  int n;
  cin >> n;
  vector<int>ar;
  ar.push_back(2);
  for (int i = 3; i <= n; i += 2){
    if (P(i)){
      ar.push_back(i);
    }
  }
  ll ans = 1;
  for (int i = 0; i < ar.size(); i++){
    ll x = ar[i];
    ll mul = x;
    ll cnt = 1;
    while (mul <= n){
      cnt += (n / mul);
      mul *= x;
    }
    ans = ((ans % MOD) * (cnt % MOD)) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int minCost(int index, int n, int k, vector<int> &cost, vector<int> &res) {
    if (index == n-1)
        return 0;
    if (res[index] != -1)
        return res[index];
    int minm = INT_MAX;
    for (int jump = 1; jump <= k && (index + jump < n); jump++) {
        minm = min (minm, abs(cost[index] - cost[index+jump]) + minCost(index+jump, n, k, cost, res));
    }
    return res[index] = minm;
}
int main() {
    int n, k;
    cin>>n>>k;
    vector<int> cost(n);
    for (int i = 0; i < n; i++) {
        cin>>cost[i];
    }
    vector<int> res(n, -1);
    cout<<minCost(0, n, k, cost, res)<<"\n";
}


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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int cnt=0;
    for(int i=1; i<n-1; i++){
        if(p[i-1]<=p[i]&&p[i]<p[i+1])cnt++;
        if(p[i+1]<=p[i]&&p[i]<p[i-1])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var m = 0
    var i = 0
    var cnt = 0
    while (i < n - 1) {
        if (h[i] >= h[i + 1]) {
            cnt++
            m = Math.max(m, cnt)
        } else {
            cnt = 0
        }
        i++
    }
    println(m)
}


Measured memory_bytes: 59488
program main
integer N,I
character H*3
read *, N
I = mod(N,10)
Select case(I)
	case(2,4,5,7,9)
    	H = 'hon'
    case(0,1,6,8)
		H = 'pon'
    case(3)
    	H = 'bon'
end select
print '(A)',H
end program main

Measured memory_bytes: 2924
import itertools
s = input()
k = int(input())
g = itertools.groupby(s)
v = -1
t = -1
for a,b in g:
    if v == -1:
        v = len(list(b))
    elif t == -1:
        t = a
        break
if s[0]=='1':
    if k<=v:
        print(1)
    else:
        print(t)
else:
    print(s[0])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
template<class T>
void p(const T& s) {
	std::cout << s << "\n";
}

using vec = std::vector<size_t>;
using deq = std::deque<size_t>;
int main() {
	size_t N{0},t;
	std::cin >> N;

	vec a;
	deq b;
	for (size_t i{ 0 }; i < N; i++) {
		std::cin >> t;
		a.emplace_back(t);
	}
	
	for (size_t i{ 0 }; i < a.size();i++) {
		i % 2 == 0 ? b.emplace_back(a[i]) : b.emplace_front(a[i]);
		//std::reverse(std::begin(b),std::end(b));
	}

	if (N % 2 == 0) {

		for (size_t i{ 0 }; i < b.size() - 1; i++) {
			std::cout << b[i] << " ";
		}
		std::cout << b.back() << "\n";
		//	std::cout << ss.size() << "\n";
	}
	else {
		for (size_t i{ b.size()-1 }; 1<=i; i--) {
			std::cout << b[i] << " ";
		}
		std::cout << b.front() << "\n";
	}
	return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // OUT((ll)1e12);
  // OUT((1LL<<40));
  ll N,K;cin>>N>>K;
  vector<bitset<40>> AS(N);
  REP(i,N) {
    ll a;cin>>a;
    bitset<40> bs(a);
    AS[i] = bs;
  }

  // まずは理想の数
  bitset<40> idealb;
  REP(n,40) {
    // one_cnt = N-zero_cnt
    int zero_cnt = 0;
    REP(i,N) if (AS[i][n]==0) zero_cnt++;
    if (zero_cnt>N/2) idealb.set(n);
  }

  // idealbをKより下にする
  bitset<40> kb(K);

  // 左からbitの差分を見ていって初めて違った箇所で判定
  for (int i=39;i>=0;i--) {
    if (kb[i]==1 && idealb[i]==0) {
      // これ以降は全て理想通りでもOK
      break;
    } else if (kb[i]==0 && idealb[i]==1) {
      // K以下にするために調整して継続
      idealb.reset(i);
    }
  }
  // idealb完成

  ll ans = 0;
  REP(i,N) {
    ans += (AS[i]^idealb).to_ullong();
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 1024
program main
  implicit none
  integer(8) i,N
  integer(8),allocatable :: A(:),score(:)
  read(*, *) N
  allocate(A(N))
  allocate(score(N))
  read(*, *) (A(i), i = 1,N)
  do i = 1,N
    score(i) = i + A(i)*10**6
  end do
  !write(*, *) score
  call qsort(score)
  do i = 1,N
    score(i) = mod(score(i),10**6)
  end do
  write(*, *) score

  
contains

recursive subroutine qsort(a)
implicit none
!integer(8),intent(in) :: n
integer(8),intent(inout) :: a(:)
integer(8)::i,j,toobig,toosmall,pv,n
n = size(a)
i = 1
j = n
pv = a((i+j)/2)
do
   do
     if (a(i) < pv) then
       i = i+1
     else
       exit
     end if
   end do
   do
     if(a(j) > pv) then
       j = j-1
     else
       exit
     end if
   end do
   if (i>=j) then
     exit
   else
     toobig = a(j)
     toosmall = a(i)
     a(i) = toobig
     a(j) = toosmall
     i = i+1
     j = j-1
   end if
 end do
 if (i > 2) then
   call qsort(a(1:i-1))
 end if
 if (j < n-1) then
   call qsort(a(j+1:n))
 end if
end subroutine qsort
end program main


Measured memory_bytes: 4992
def validate(n, d: set) -> bool:
    while n > 0:
        # print(n)
        r = n%10
        if r in d:
            return False
        n //= 10
    return True


def solve(n, d):
    d = set(d)
    for i in range(n, 10**6):
        if validate(i, d):
            return i
    return -1


def main():
    n, k = map(int, input().split())
    d = [int(x) for x in input().split()]
    print(solve(n, d))


if __name__ == '__main__':
    assert validate(2000, [1,3,4,5,6,7,8,9])
    assert not validate(1002, [1,3,4,5,6,7,8,9])
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

const int limit = 100010;

typedef struct edge {
  int to;
  ll cost;
} edge;

vector<edge> tree[limit];
ll depth[limit];

void dfs (int v, int p, ll d) {
  depth[v] = d;
  for (auto e : tree[v]) {
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
}

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

  for (int i = 0; i < n - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    tree[a].pb({b,c});
    tree[b].pb({a,c});
  }

  int q,k;
  cin >> q >> k;
  k--;

  dfs(k, -1, 0);
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
}


Measured memory_bytes: 14336
#include <stdio.h>

int main(void) {
	int a[100],n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0)printf(" ");
		}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600