akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
bool mark[1000006];
void solve()
{
   ll n;
   cin>>n;
   
   ll a[n];
   
   for(ll i=0;i<n;i++)
   cin>>a[i];
   
   ll res=a[0];
   
   for(ll i=1;i<n;i++)
   res=__gcd(res,a[i]);
   
   if(res>1){
       cout<<"not coprime\n";
       return;
   }
   
   ll l[1000006];
   
   l[1]=1;
   
   memset(mark,false,sizeof(mark));
   
   for(ll i=2;i<1000006;i++){
       if(!mark[i]){
           l[i]=i;
           
           for(ll j=i*i;j<1000006;j+=i){
               if(!mark[j]){
                   mark[j]=true;
                   l[j]=i;
               }
           }
       }
   }
   
   map<ll,ll>mp;
   
   bool f=true;
   
   for(ll i=0;i<n;i++){
       ll x=a[i];
       
       while(x>1){
          ll y=l[x];
          mp[y]++;
          
          while(x%y==0)
          x/=y;
       }
   }
   
   for(auto x:mp){
       if(x.ss>1){
           f=false;
           break;
       }
   }
   
   if(f)
   cout<<"pairwise coprime\n";
   else
   cout<<"setwise coprime\n";
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

#define ll long long int

int main(){
    int n,m;
    cin>>n>>m;
    int hm[n][m+1];
    for(int i=0;i<n;i++)
        for(int j=0;j<=m;j++)
            hm[i][j] = 0;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int x;
            cin>>x;
            hm[i][x] = 1;
        }
    }
    int ct = 0;
    for(int i=0;i<=m;i++){
        int flag = 0;
        for(int j=0;j<n;j++){
            if(hm[j][i] == 0){
                flag = 1;
                break;
            }
        }
        if(!flag)
            ct++;
    }
    cout<<ct;
    return 0;
}


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

const int rest = 1000001;
int dp[3][rest];
int ac[rest][3];
int it;

int va(int a, int i){
	if(i == it){
      return 0;
	}
	if(dp[a][i] != -1){
      return dp[a][i];
	}
	int& ans = dp[a][i];
	if(a==0){
		ans=max(ans, va(1, i+1)+ac[i][0]);
		ans=max(ans, va(2, i+1)+ac[i][0]);
	}
	if(a==1){
		ans=max(ans, va(0, i+1)+ac[i][1]);
		ans=max(ans, va(2, i+1)+ac[i][1]);
	}
	if(a==2){
		ans=max(ans, va(0, i+1)+ac[i][2]);
		ans=max(ans, va(1, i+1)+ac[i][2]);
	}

	return ans;
}
int main(){
	cin>>it;
	for(int i=0; i<it; i++){
        cin>>ac[i][0];
        cin>>ac[i][1];
        cin>>ac[i][2];
	}

	memset(dp, -1, sizeof dp);
	cout<<max(va(0,0),max(va(1,0),va(2,0)))<<"\n";
	return 0;
}


Measured memory_bytes: 19328
#include <stdio.h>

int main(void)
{
  int N;
  char S[200];
  scanf("%d%s", &N, S);
  int max = 0;
  for(int i = 1; i < N; i++){
    int count = 0;
    for(char c = 'a'; c <= 'z'; c++){
      int cnt = 0;
      for(int j = 0; j < i; j++){
        if(S[j] == c){
          cnt++;
          break;
        }
      }
      for(int j = i; j < N; j++){
        if(S[j] == c){
          cnt++;
          break;
        }
      }
      if(cnt == 2)
        count++;
    }
    if(max < count)
      max = count;
  }
  printf("%d\n", max);
}


Measured memory_bytes: 128
// luogu-judger-enable-o2
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<set>
#include<map>
#include<climits>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int N=100010;
typedef set<int>::iterator It;
set<int> s[N];
map<ll,int> ma;
queue<pair<int,int> > q;
int n,f[N];
int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}
ll change(int x,int y) {return (ll)min(x,y)*n+max(x,y);}
void erase(int x,int y)
{
	s[x].erase(y);
	s[y].erase(x);
	ma.erase(change(x,y));
}
void insert(int x,int y)
{
	s[x].insert(y);
	s[y].insert(x);
	ma[change(x,y)]++;
	if(ma[change(x,y)]==2) q.push(make_pair(x,y));
}
int main()
{
	int i,j,x,y,t1,t2;
	ll t;
	scanf("%d",&n);
	for(i=1;i<=n;i++) f[i]=i;
	for(i=1;i<2*n-1;i++)
	{
	    scanf("%d%d",&x,&y);
		insert(x,y);
	}
	for(i=1;i<n;i++)
	{
		if(q.empty()) break;
		x=q.front().first,y=q.front().second,q.pop();
		t1=find(x),t2=find(y);
		if(s[t1].size()<s[t2].size()) swap(t1,t2),swap(x,y);
		erase(t1,t2);
		f[t2]=t1;
		It it,j;
		for(It it=s[t2].begin();it!=s[t2].end();it=j) 
		{
			j=it;j++;
			erase(t2,find(*it));
			insert(t1,find(*it));
		}
	}
	if(i==n) printf("YES");
	else printf("NO");
	return 0;
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main()
{
    int x,a,b,d1,d2;

    scanf("%d%d%d",&x,&a,&b);

    d1=x-a;
    if(d1<0) d1=d1*(-1);

    d2=x-b;
    if(d2<0) d2=d2*(-1);

    if(d1<d2) printf("A");
    else printf("B");

}


Measured memory_bytes: 256
import java.util.*;


public class Main{

    public static edge[][] V=new edge[30][30];
    public static int[] Vs=new int[30];
    public static int[] ti=new int[30];
    public static Boolean[][] vis=new Boolean[30][1<<8];
    
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);

        while(true){
            int n=cin.nextInt();
            if(n==0)break;
            int m=cin.nextInt();
            int p=cin.nextInt();
            int a=cin.nextInt()-1;
            int b=cin.nextInt()-1;
            for(int i=0;i<n;i++)ti[i]=cin.nextInt();

            for(int i=0;i<m;i++)Vs[i]=0;

            for(int i=0;i<p;i++){
                int x=cin.nextInt()-1;
                int y=cin.nextInt()-1;
                int z=cin.nextInt();
                V[x][Vs[x]++]=new edge(y,z);
                V[y][Vs[y]++]=new edge(x,z);
            }
            Queue<node> q=new PriorityQueue<node>();
            q.add(new node(0,a,0));


            for(int i=0;i<m;i++)
                for(int j=0;j<(1<<n);j++)vis[i][j]=false;
            
            double ans=-1;
            
            while(q.isEmpty()==false){
                node cn=q.poll();


                if(vis[cn.v][cn.st]==true)continue;
                vis[cn.v][cn.st]=true;
                if(cn.v==b){
                    ans=cn.cc;
                    break;
                }

                for(int i=0;i<n;i++){
                    if(((cn.st>>i)&1)==1)continue;
                    for(int j=0;j<Vs[cn.v];j++){
                        int nv=V[cn.v][j].v;
                        int tc=V[cn.v][j].c;
                        int nst=cn.st|(1<<i);
                        if(vis[nv][nst])continue;
                        double nc=cn.cc+1.0*tc/ti[i];
                        q.add(new node(nc,nv,nst));
                    }
                }
            }
            if(ans<0)System.out.println("Impossible");
            else System.out.println(ans);
        }
    }

    public static class edge{
        public int v,c;
        public edge(int iv,int ic){
            v=iv;
            c=ic;
        }
    }

    public static class node implements Comparable{
        public double cc;
        public int v,st;
        public node(double icc,int iv,int ist){
            cc=icc;
            v=iv;
            st=ist;
        }
        public int compareTo(Object object){
            node coto=(node)object;

            return new Double(this.cc).compareTo(new Double(coto.cc));
        }
    }
}

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

int main() {
	long long n, k;
	cin >> n >> k;
	if (k == 0) {
		cout << n*n << endl;
		return 0;
	}
	long long ans = 0;
	for (long long b = k+1; b <= n; b++) {
		ans += n / b * (b - k) + max(0ll, n % b - (k-1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3176
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().rstrip()

    n_w_all = S.count(".")
    n_b_all = S.count("#")
    n_w = 0
    n_b = 0
    ans = min(n_w_all, n_b_all)
    for i in range(N - 1):
        if S[i] == ".":
            n_w += 1
        else:
            n_b += 1
        num = n_b + (n_w_all - n_w)
        if num < ans:
            ans = num

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

set<long long> s;

void go(long long curr, int len) {
    s.insert(curr);
    if (len == 12) return;
    int d = curr % 10;
    for (int nxt = max(0, d-1); nxt <= min(d+1, 9); nxt++) {
        go(curr*10+nxt, len+1);
    }
}

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

    for (int i = 1; i < 10; i++) {
        go(i, 1);
    }
    int k = 0;
    cin >> k;
    int c = 0;
    for (long long x : s) {
        c++;
        if (c == k) {
            cout << x << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 79616
package main

import (
	"fmt"
)

func main() {

	var N, D int
	fmt.Scanf("%d %d", &N, &D)

	if N%(2*D+1) == 0 {
		fmt.Println(N / (2*D + 1))
	} else {
		fmt.Println(N/(2*D+1) + 1)
	}
}


Measured memory_bytes: 1832
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto S = RD!string;
	auto T = RD!string;
	auto A = RD;
	auto B = RD;
	auto U = RD!string;

	if (S == U)
		writeln(A-1, " ", B);
	else
		writeln(A, " ", B-1);
	stdout.flush;
	debug readln;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    string ans = "No";

    if(n%11==0 || n%4==0 || n%7==0) ans = "Yes";
    else{
        for(int i=1; i<100; i++){
            for(int j=1; j<100; j++){
                int d = 4*i+7*j;
                if(n%d==0) ans = "Yes";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (void)
{
    int k, s, ans = 0;

    cin >> k >> s;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    int N, M; cin >> N >> M;
    vector<vector<int>> vec(M);
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

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

    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) { // Swithces
        bool flag = true;
        for (int i = 0; i < M; i++) { // M lights
            int c = 0;
            for (int id : vec[i]) {
                if ((bit >> id) & 1)
                    c++;
            }
            // cout << bit << " " << c << endl;
            c %= 2;
            if (c != p[i]) {
                flag = false;
            }
        }
        if (flag) {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a<b)
                printf("a < b\n");
        else if(a>b)
                printf("a > b\n");
        else
                printf("a == b\n");
        return 0;
}


Measured memory_bytes: 2044
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: ABS
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, z, w;
  scanf("%d%d%d", &n, &z, &w);
  for (int i = 0; i < n; i++) scanf("%d", &as[i]);

  if (n == 1)
    printf("%d\n", abs(as[n - 1] - w));
  else
    printf("%d\n", max(abs(as[n - 1] - w), abs(as[n - 2] - as[n - 1])));
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = [True if i == 0 else False for i in range(n)]
k = [1 for i in range(n)]
for i in range(m):
    xy = list(map(int, input().split()))
    if l[xy[0]-1]:
        if k[xy[0]-1] > 1:
            l[xy[1]-1] = True
        else:
            l[xy[1]-1] = True
            l[xy[0]-1] = False
    k[xy[0]-1] -= 1
    k[xy[1]-1] += 1
print(l.count(True))

Measured memory_bytes: 10772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <map>
using namespace std;

long long N, M, X, Y, A[100009], B[100009];

int main() {
	cin >> N >> M >> X >> Y; A[0] = X; B[0] = Y;
	for (int i = 1; i <= N; i++) { cin >> A[i]; }
	for (int i = 1; i <= M; i++) { cin >> B[i]; }
	sort(A, A + N + 1);
	sort(B, B + M + 1);
	if (A[N] < B[0]) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 10;
const int MOD = 998244353;

int n;
int cnt[maxn];

int power(int n, int k) {
  long long e = 1;
  for (; k; k >>= 1, n = 1ll * n * n % MOD) if (k & 1)
    e = 1ll * e * n % MOD;
  return e;
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    if (!i && x) {
      puts("0");
      return 0;
    }
    cnt[x]++;
  }
  if (cnt[0] != 1) {
    puts("0");
    return 0;
  }
  long long answer = 1;
  for (int i = 0; i < maxn; ++i) answer = 1ll * answer * power(cnt[i], cnt[i + 1]) % MOD;
  cout << answer << "\n";
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    char i = 'a';
    int j = 0;
    for (int k = 0; k < 26; k++){
        char ans = i + k;
        if (S.at(j) != ans){
            cout << ans << endl;
            break;
        }
        else{
            while (S.at(j) == ans){
                j++;
                if (j == S.size() - 1){
                    if (S.at(j) == 'z'){
                        cout << "None" << endl;
                        return 0;
                    }
                    else{
                        string an;
                        an = S.at(j) + 1;
                        cout << an << endl;
                        return 0;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    string N;
    cin >> N;
    string ans = "ABC" + N;
    cout << ans << endl;
}


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

//long long calc(long long x) {
//	long long t = 1;
//	for (long long i = 1; i <= x; i++) {
//		t *= i;
//	}
//	return t / 2;
//}

int main()
{
	int n;
	long long cnt = 0;
	string str;
	map<string, long long> m;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> str;
		sort(str.begin(), str.end());
		if (m.find(str) == m.end()) {
			m[str] = 1;
		}
		else {
			cnt += m[str];
			m[str]++;
		}
	}
	//for (auto it = m.begin(); it != m.end(); it++) {
	//	if (it->second != 1) {
	//		cnt += calc(it->second);
	//	}
	//}
	cout << cnt << endl;

}

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

int main(void){

    int N; cin>>N;
    long long ans=0;
    unordered_map<string, int> mp;
    string tmp;
    for (int i = 0; i < N; ++i) {
        cin>>tmp;
        sort(tmp.begin(), tmp.end());
        ans += mp[tmp];
        mp[tmp]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);

  int N;
  cin>>N;
  vector<int> vecA(N);
  vector<int> vecB(N);
  vector<int> vecC(N-1);
  for(int i=0;i<N;i++){
    cin>>vecA[i];
  }
for(int i=0;i<N;i++){
  cin>>vecB[i];
}
  for(int i=0;i<N-1;i++){
    cin>>vecC[i];
  }

  
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    sum+=vecB[vecA[i]-1];
   
    if(i<N&&vecA[i+1]-vecA[i]==1){
      sum+=vecC[vecA[i]-1];
    }
  //  cout<<sum<<endl;
  }
  
  cout<<sum<<endl;
}




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

const ll INF = 1001001001;


int main(){
  ll h,n;
  cin>>h>>n;
  ll ans = h;
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
    ans -=a[i];
  }

  if(ans<=0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}

Measured memory_bytes: 1024
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = c;
  if (a == c) ans = b;
  if (b == c) ans = a;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll dp[(int)2e5+2];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    ll ans = 1;
    vector<int> c(n);
    vector<vector<int>> g(2e5+2);
    rep(i,n){
        cin >> c[i];
        g[c[i]].push_back(i);
    }
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        dp[i-1]%=mod;
        dp[i]%=mod;
        (dp[i] += dp[i-1])%mod;


        int color = c[i-1];

        int it = lower_bound(ALL(g[color]),i-1) - g[color].begin();
        if(it > 0){
            int j = g[color][it-1];
            if((i-1) - j > 1){
                (dp[i] += dp[j+1]);
                dp[i]%=mod;
                dp[j+1]%=mod;
            }
        }
    }
    cout << dp[n]%mod << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define SZ(a) ll((a).size())
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

struct union_find {
  vector<ll> data;
  union_find(ll size) : data(size, -1) { }
  bool union_set(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  ll m, k;
  ll ans = 0;

  cin >> m >> k;
  ll a = 1 << m;
  if (k >= a) {
    cout << -1 << endl;
  } else if (m == 1) {
    cout << (k == 0 ? "0 0 1 1" : "-1") << endl;
  } else {
    REP(i, a) {
      if (i != k) cout << i << " ";
    }
    cout << k << " ";
    RREP(i, a) {
      if (i != k) cout << i << " ";
    }
    cout << k << endl;
  }
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool solve(string s, string t) {
    sort(ALL(s)), sort(ALL(t), greater<char>());
    if (s < t) return true;
    else return false;
}

int main() {
    string S, T; cin >> S >> T;
    cout << (solve(S, T) ? "Yes" : "No") << endl;
}

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

int main() {
  int N, A, B;
  int total = 0;
  cin >> N >> A >> B;
  
  for (int i = 1; i <= N; i++) {
    int j = i;
    int sum = 0, odd = 0;
    while (j > 0) {
      odd = j % 10;
      sum = sum + odd;
      j = j / 10;
    }
    
    if (A <= sum && sum <= B) {
      total+=i;
    }
  }
  cout << total << endl;
}

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

int main() {
	int x, y, a, b, c;
  cin>>x>>y>>a>>b>>c;
	vector<ll> p(a), q(b), r(c);
	priority_queue<ll, vector<ll>, greater<ll>> que;
	rep(i, a) {
		cin >> p[i];
	}
	rep(i, b) {
		cin >> q[i];
	}
	rep(i, c) cin >> r[i];
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	ll ans = 0;
	for (int i = a - 1; i >= a - x; i--) {
		ans += p[i];
		que.push(p[i]);
	}
	for (int i = b - 1; i >= b - y; i--) {
		ans += q[i];
		que.push(q[i]);
	}
	for (int i = c - 1; i >= 0; i--) {
		ll k = que.top();
		que.pop();
		if (k >= r[i]) {
			cout << ans << endl;
			return 0;
		}
		ans -= k;
		ans += r[i];
	}
  cout<<ans<<endl;
}

Measured memory_bytes: 4724
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1,s2;
	cin >> s1 >> s2;
	int n1 = s1.length();
	int n2 = s2.length();
	vector <vector<int> > dp(n1+1,vector <int> (n2+1,0));
	// vector <vector<pair <int,int>>>dp2(n1+1,vector <pair<int,int>>(n2+1));
	for(int i=0;i<n1;i++)
	{
		for(int j=0;j<n2;j++)
		{
			// dbg2(i,j);
			if(s1[i]==s2[j])
			{
				dp[i+1][j+1]=1+dp[i][j];
			}
			else
			{
				dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
		}
	}
	// for(int i=0;i<=n1;i++)
	// {
	// 	for(int j=0;j<=n2;j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	int a=n1;
	int b=n2;
	vector <char> res;
	while (a>0 && b>0)
	{
		if(dp[a][b]==dp[a-1][b])
		{
			a-=1;

		}
		else if(dp[a][b]==dp[a][b-1])
		{
			b-=1;
		}
		else
		{
			a-=1;
			b-=1;
			res.push_back(s1[a]);
		}
	}
	reverse(res.begin(),res.end());
	for(auto a:res)
		cout << a;
	// for(int i=0;i<=n1;i++)
	// {
	// 	for(int j=0;j<=n2;j++)
	// 	{
	// 		cout << dp2[i][j].first << "," << dp2[i][j].second << " ";
	// 		if(dp[i][j]>=ans)
	// 		{
	// 			ans=dp[i][j];
	// 			a=dp2[i][j].first;
	// 			b=dp2[i][j].second;
	// 		}
	// 	}
	// 	cout << "\n";
	// }
	// cout << ans << "\n";
	// if(s1[a]==s2[b])
	// 	{
	// 		cout << s1[a];
	// 	}
	// while(a!=0&&b!=0)
	// {
	// 	a=dp2[a][b].first;
	// 	b=dp2[a][b].second;
	// 	dbg2(s1[a],s2[b]);
	// 	if(s1[a]==s2[b])
	// 	{
	// 		// cout << s1[a];
	// 	}

	// }
}

Measured memory_bytes: 35584
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

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

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int m,k;
	read(m);read(k);
	for (int i=1;i<=m;i++)
		for (int j=1;j<=k;j++)
			if ((j%10>=2)&(j/10>=2)) ans+=(i==((j%10)*(j/10)));
	cout<<ans;
	return 0;
}









Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
	int q, x;
	char com[50];
	list<int> v;
	list<int>::iterator it;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L') {
			v.pop_back();
		}
		else if (com[6] == 'F') {
			v.pop_front();
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			for (it = v.begin(); it != v.end(); it++) {
				if (*it == x) {
					v.erase(it);
					break;
				}
			}
		}
	}
	int i = 0;
	for (it = v.begin(); it != v.end(); it++) {
		if (i++) printf(" ");
		printf("%d", *it);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 34432
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= n; ++i)
#define fore(i, l, r) for (int i = l; i <= r; ++i)

using namespace std;
int headlines[52][26];
int final_counts[26];

int main(){
	int n; cin >> n;
	
	
	string s;
	forn(i, n){
		cin >> s;
		for (char c : s){
			int index = (int)(c - 'a');
			headlines[i][index]++; 
		}
	}

	fill(final_counts, final_counts+26, 52);
	
	forn(i, n){
		forn(j, 26){
			final_counts[j] = min(final_counts[j], headlines[i][j]);
		}
	}
	
	forn(i, 26){
		forn(j, final_counts[i]){
			cout << (char)(i + 'a');
		}
	}
}

Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
    [n, k] <- readInt
    d      <- words <$> getLine
    let m = filter (\m-> all (\dd -> head dd `notElem` show m ) d ) [n, n+1 .. ] in print $ head m


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        ++mp[tmp_a];
    }
    if ( n % 2 == 0 && mp[0] != 0 ) {
        cout << 0 << endl;
        return 0;
    }
    else if ( n % 2 == 1 && mp[0] != 1 ) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for ( auto tmp_a : mp ) {
        if ( tmp_a.first == 0 ) continue;
        if ( n % 2 == 0 && tmp_a.first % 2 == 0 ) {
            cout << 0 << endl;
            return 0;
        }
        if ( n % 2 == 1 && tmp_a.first % 2 == 1 ) {
            cout << 0 << endl;
            return 0;
        }
        if ( tmp_a.second != 2 ) {
            cout << 0 << endl;
            return 0;
        }
        ans = ( ans * 2 ) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
//解説動画写し
bool check(vector<pair<int,int>>s){
  int h=0;
  for(pair<int,int>p:s){
    int b=h+p.first;
    if(b<0)return false;
    h+=p.second;
  }
  return true;
}
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>ls,rs;
  int total=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    int h=0,b=0;
    for(char c:s){
      if(c=='(')++h;
      else --h;
      b=min(b,h);
    }
    if(h>0)ls.emplace_back(b,h);
    else rs.emplace_back(b-h,-h);
    total+=h;
  }
  sort(ls.rbegin(),ls.rend());
  sort(rs.rbegin(),rs.rend());
  if(check(ls)&&check(rs)&&total==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 18700
use io::*;
use std::cmp::{max, min};

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let k: usize = sc.next();
    let q: usize = sc.next();

    let a: Vec<u32> = sc.next_vec(n);

    let mut ans = u32::max_value();

    for &th in a.iter() {
        let mut tmp = vec![];
        let mut l = 0;
        while l < n {
            let mut r = l;
            while r < n && a[r] >= th {
                r += 1;
            }

            if l == r {
                l += 1;
                continue;
            }

            if r - l > k - 1 {
                let mut t: Vec<u32> = a[l..r].iter().cloned().collect();
                t.sort();
                for i in 0..r - l - k + 1 {
                    tmp.push(t[i]);
                }
            }

            l = r;
        }

        // println!("{:?}", tmp);

        if tmp.len() < q {
            continue;
        }

        tmp.sort();
        ans = min(ans, tmp[q - 1] - th);
    }

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

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

int main(){
	int n;
	cin >> n;
	int64_t a[n][n];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	bool f[n][n];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			f[i][j] = true;
		}
	}
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(a[i][k] + a[k][j] < a[i][j]){
					cout << -1 << endl;
					return 0;
				}
				if(i != k && j != k && a[i][j] == a[i][k] + a[k][j]){
					f[i][j] = false;
				}
			}
		}
	}
	int64_t ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(f[i][j]) ans += a[i][j];
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
#define pp pair<int,int>
#define vector<int> vi
#define vector<int> vll
#define ft first
#define se second

ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	int n; cin>>n;
	n = n%10;
	string ans;
	if(n==3) ans = "bon";
	else if(n==0 || n==1 || n==6 || n==8) ans = "pon";
	else ans = "hon";
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}


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

using namespace std;

int main(){
  string s; cin >> s; int K; cin >> K;
  vector<string> vec; int c = min((int)s.size(),K);
  for(int i = 1; i <= min(5, c); i++){
    for(int j = 0; j <= s.size() - i; j++){
      vec.push_back(s.substr(j,i));}}
  
  sort(vec.begin(),vec.end());
  
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  
  cout << vec[K - 1] << endl; return 0;}

Measured memory_bytes: 1660
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;
int ton[5];

int main()
{
    //File("");
    n = gi();
    for (int i = 1; i <= n; i+=1)
    {
    	string s;
    	cin >> s;
    	char x = s[0];
    	if (x == 'A') ++ton[0];
    	else if (x == 'W') ++ton[1];
    	else if (x == 'T') ++ton[2];
    	else ++ton[3];
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ton[0], ton[1], ton[2], ton[3]);
    return 0;
}

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


char arr[3][3];

int main()
{
	
	for ( int i =0 ; i< 3 ; ++i)
		for ( int j =0 ; j< 3 ; ++j)
			cin >> arr[i][j] ;
	
	for ( int i =0 ; i< 3 ; ++i)
		cout << arr[i][i];

	return 0;
}


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

int N;
string S;

long mpow(long a, long b, int m) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m, b >>= 1;
  }
  return res;
}

int f1(int m) {
  if (!m) return 0;
  int res = 0, now = 1;
  for (int i = N - 1; i >= 0; i--) {
    (res += (S.at(i) - '0') * now) %= m;
    (now *= 2) %= m;
  }
  return res;
}

int f2(int n) {
  return n % __builtin_popcount(n);
}

int main() {
  cin >> N >> S;
  int cnt = count(S.begin(), S.end(), '1');
  int mod1 = cnt - 1, mod2 = cnt + 1;
  int res1 = f1(mod1), res2 = f1(mod2);
  for (int i = 0; i < N; i++) {
    int tmp;
    if (S.at(i) == '1') {
      if (cnt == 1) {
        cout << 0 << "\n";
        continue;
      }
      tmp = res1 - mpow(2, N - i - 1, mod1);
      while (tmp < 0) tmp += mod1;
    } else {
      (tmp = res2 + mpow(2, N - i - 1, mod2)) %= mod2;
    }
    int ans = 1;
    while (tmp) tmp = f2(tmp), ans++;
    cout << ans << "\n";
  }
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String nico = sc.nextLine();
			
			int state = 0;
			String tmp = "";
			
			String m = "";
			for (int i = 0; i < nico.length(); i++) {
				char c = nico.charAt(i);
				 
				if ((c != ' ') && (c != ',') && (c != '.')) {
					state++;
					tmp = tmp + nico.charAt(i);
				} else {
					if ((3 <= state) && (state <= 6)) {
						System.out.print(m + tmp);
						m = " ";
					}
					
					state = 0;
					tmp = "";
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25816
import sys
input=sys.stdin.readline
from bisect import bisect_right
import itertools

N,X= map(int,input().split())
A=list(map(int,input().split()))

A.sort()
Acum = list(itertools.accumulate(A))
answer = bisect_right(Acum,X)
if answer == N:
    if Acum[-1] < X:
        answer -= 1
print(answer)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
typedef struct
{
	long t;
	int s, d;
}Data;
int main()
{
	int N, M;
	while (cin >> N >> M && N != 0 || M != 0)
	{
		Data data[20000];
		for (int i = 0; i < M; i++)
		{
			cin >> data[i].t >> data[i].s >> data[i].d;
			data[i].s--;
			data[i].d--;
		}

		for (int i = 0; i < M - 1; i++)
		{
			for (int j = i + 1; j < M; j++)
			{
				if (data[i].t > data[j].t)
				{
					Data tmp = data[i];
					data[i] = data[j];
					data[j] = tmp;
				}
			}
		}

		bool infected[20000];
		for (int i = 0; i < N; i++)infected[i] = false;
		infected[0] = true;
		for (int i = 0; i < M; i++)
		{
			if (infected[data[i].s])
			{
				infected[data[i].d] = true;
			}
		}

		int ans = 0;
		for (int i = 0; i < N; i++)
		{
			if (infected[i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1492
def main():

    N = int(input())
    S = []
    P = []
    for i in range(N):
        s, p = input().split()
        S.append(s)
        P.append(int(p))

    d = {}
    for i in range(N):
        if S[i] in d.keys():
            d[S[i]].append((i+1, P[i]))
        else:
            d[S[i]] = [(i+1, P[i])]

    for key in sorted(d.keys()):
        a = d[key]
        a = sorted(a, key=lambda x: -x[1])
        for i, score in a:
            print(i)
            

main()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


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

	vector<ll> a(n), b(n);
	REP(i, n) {
		ll p;
		cin >> p;
		p--;

		a[p] += i;
		b[p] += i;

		a[i] += n * i + 1;
		b[i] += n * (n - i - 1) + 1;
	}

	REP(i, n) {
		cout << a[i] << ' ';
	}
	cout << '\n';
	REP(i, n) {
		cout << b[i] << ' ';
	}
	cout << '\n';
}

Measured memory_bytes: 896
#include <stdio.h>
	
	int main(void)
{
	char c;
	scanf("%c",&c);
	
	if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
		printf("vowel\n");
	} else{
		printf("consonant\n");
	}
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll a[N];
ll heros[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n;
    scanf("%d",&n);
    for(int i=0;i<n+1;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",heros+i);
    }
    
    
    ll ans =0;
    for(int i=0;i<n;i++){
        if(a[i]>=heros[i]){
            ans+=heros[i];
            a[i]-=heros[i];
            heros[i]=0;
        }else{
            ans+=a[i];
            heros[i]-=a[i];
        }
        if(a[i+1]>=heros[i]){
            ans+=heros[i];
            a[i+1]-=heros[i];
        }else{
            ans+=a[i+1];
            a[i+1]=0;
        }

    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3072
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	long long n;
	scanf("%lld",&n);
	string s="";
	while(n){
		n--;
		s=(char)(n%26+'a')+s;
		n/=26;
	}
	puts(s.c_str());
}


Measured memory_bytes: 3276
public class Neko{
    public static void Main(){
        int n = int.Parse(System.Console.ReadLine());
        string[] s = System.Console.ReadLine().Split();
        int count = 0;
        
        for (int i=0; i<s.Length; i++){
            int a = int.Parse(s[i]);
            if ((i+1)%2 == 1 && a%2 == 1) count ++;
        }
        
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 27384