akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> v(H);
  vector<vector<char>> a(H, vector<char>(W));
  vector<bool> h(H), w(W);
  rep(i, H) cin >> v[i];
  rep(i, H){
    rep(j, W) a[i][j] = v[i][j];
  }
  rep(i, H){
    bool b = 1;
    rep(j, W){
      if(a[i][j] == '#'){
        b = 0;
        break;
      }
    }
    if(b) h[i] = 0;
    else h[i] = 1;
  }
  rep(i, W){
    bool b = 1;
    rep(j, H){
      if(a[j][i] == '#'){
        b = 0;
        break;
      }
    }
    if(b) w[i] = 0;
    else w[i] = 1;
  }
  rep(i, H){
    if(h[i]){
      rep(j, W) if(w[j]) cout << a[i][j];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


n,m = li()
a = []
b = []
for _ in range(n):
    a.append(ns())
for _ in range(m):
    b.append(ns())

# n-m+1行,列を探索
contain = False
for row in range(n-m+1):
    for col in range(n-m+1):
        match = True
        for r in range(m):
            if a[row+r][col:col+m] != b[r]:
                match = False
                
        if match:
            contain = True
            
if contain:
    print("Yes")
else:
    print("No")
            
        


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

int main() {
  int R, G, B, K;
  cin >> R >> G >> B >> K;
  
  int count =0;
  while(R>=G){
    G*=2;
    count++;
  }
  
  while(G>=B){
    B*=2;
    count++;
  }
  
  if(count<=K)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main (void)
{
  int R;

  scanf ("%d",&R);

  if (R<1200)
  {
    puts ("ABC");
  }
    else
    {
      if (R<2800)
      {
        puts ("ARC");
      }
      else
      puts ("AGC");
    }

  return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n;
    cin>>n;
    string a;
    if(n%10==3)a="bon";
    else if(n%10==0 or n%10==1 or n%10==6 or n%10==8)a="pon";
    else a="hon";
    cout<<a<<endl;
return 0;
}

Measured memory_bytes: 3624
#!python3

# import numpy as np


# input
a, b, c = list(map(int, input().split()))


def main():
    x = 4 * a * b
    y = c - a - b
    if y >= 0 and x < y ** 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std; 
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < int(n); ++i)
typedef pair<int, int> pii;
const int MAX = 100+10;

char grid[MAX][MAX];
int path[MAX][MAX];
void solve(){
	int H,W;
	cin>>H>>W;
	forn(i,H){
		cin>>grid[i];
	}
	if(grid[0][0] =='.'){
		path[0][0] = 0;
	}
	else{
		path[0][0] = 1;
	}
	for(int i = 1;i<W;i++){
		if(grid[0][i] == '.'){
			path[0][i] = path[0][i-1];
		}
		else{
			if(grid[0][i-1] == '.'){
				path[0][i] = path[0][i-1]+1;
			}
			else{
				path[0][i] = path[0][i-1];
			}
		}
	}
	for(int i = 1;i<H;i++){
		if(grid[i][0] == '.'){
			path[i][0] = path[i-1][0];
		}
		else{
			if(grid[i-1][0] == '.'){
				path[i][0] = path[i-1][0]+1;
			}
			else{
				path[i][0] = path[i-1][0];
			}
		}
	}
	for(int i = 1 ;i<H;i++){
		for(int j = 1;j<W;j++){
			if(grid[i][j] == '.'){
				path[i][j] = min(path[i-1][j],path[i][j-1]);
			}
			else{
				int p , q;
				if(grid[i-1][j] == '.'){
					p = path[i-1][j] +1;
				}
				else{
					p = path[i-1][j];
				}
				if(grid[i][j-1] == '.'){
					 q = path[i][j-1] +1;
				}
				else{
					q = path[i][j-1];
				}
				path[i][j] = min(p,q);
			}
		}
	}
	cout<<path[H-1][W-1]<<endl;
	
}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	solve();
	
	return 0;	
}

Measured memory_bytes: 256
l=list(input())

MOD=10**9+7
#桁DP
#各桁にとりうる値は、(0,1),(1,0),(0,0)の3パターン
#ただし、(0,1)が取れないケースもある（ギリギリの値）
#i桁目
#dp[i][smaller]

lenl=len(l)

dp=[[0]*2 for _ in range(lenl)]

#(0,0)
dp[0][0]=1
#(0,1),(1,0)
dp[0][1]=2

for i in range(1,lenl):
    if l[i]=="1":
        dp[i][0]+=(dp[i-1][0]*3+dp[i-1][1])%MOD
        dp[i][1]+=dp[i-1][1]*2%MOD
    else:
        dp[i][0]+=dp[i-1][0]*3%MOD
        dp[i][1]+=dp[i-1][1]%MOD

print(sum(dp[-1])%MOD)




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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll ans=(n/11)*2;
    ll rad=n%11;
    if(rad>=1&&rad<=6)
    {
        ans++;
    }
    else if(rad>6&&rad<11)
    {
        ans+=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

s = deque(input())

ans = 0
while len(s) > 1:
    if s[0] == s[-1]:
        s.pop()
        s.popleft()
    elif s[0] == 'x':
        s.popleft()
        ans += 1
    elif s[-1] == 'x':
        s.pop()
        ans += 1
    elif s[0] != s[-1]:
        print(-1)
        break
else:
    print(ans)


Measured memory_bytes: 10132
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int f(int n, int p) {
    int res = 0;
    while (n >= p) {
        res += n / p;
        n /= p;
    }
    return res;
}

bool prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n >= 2;
}

int main() {
    // 75 = 5*5*3
    // p^4 * q^4 * r*2
    // p^14 * q^4
    // p^24 * q^2
    // p^74
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 2; i <= n; i++) if (prime(i)) {
        ans += f(n, i) >= 74;
        for (int j = i + 1; j <= n; j++) if (prime(j)) {
            ans += f(n, i) >= 24 && f(n, j) >= 2;
            ans += f(n, i) >= 2 && f(n, j) >= 24;
            ans += f(n, i) >= 14 && f(n, j) >= 4;
            ans += f(n, i) >= 4 && f(n, j) >= 14;
            for (int k = j + 1; k <= n; k++) if (prime(k)) {
                ans += f(n, i) >= 4 && f(n, j) >= 4 && f(n, k) >= 2;
                ans += f(n, i) >= 4 && f(n, j) >= 2 && f(n, k) >= 4;
                ans += f(n, i) >= 2 && f(n, j) >= 4 && f(n, k) >= 4;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int dp[110][4][2][2], n;
string s;
ll fun(int a, int b, int c, int t){
	if(b < 0)
		return 0;
	if(a == n){
		if(b == 0)
			return 1;
		return 0;
	}
	if(dp[a][b][c][t] != -1)
		return dp[a][b][c][t];
	int low = 0;
	int high = (t == 1) ? (s[a] - '0') : 9;
	ll ans = 0;
	for(int i = low; i <= high; i++){
		if(i){
			ans += fun(a + 1, b - 1, c, i == (s[a] - '0') ? t : 0);
		}
		else ans += fun(a + 1, b, 1, i == (s[a] - '0') ? t : 0);
	}
	return dp[a][b][c][t] = ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	int k;
	cin >> k;
	n = s.length();
	memset(dp, -1, sizeof(dp));
	cout << fun(0, k, 0, 1) << '\n';

}

Measured memory_bytes: 256
import collections
def main():

    N, M = map(int, input().split())
    graph = collections.defaultdict(set)
    for _ in range(M):
        A, B = map(int, input().split())
        graph[A].add(B)
        graph[B].add(A)

    visited = set()
    min_count = 0
    for i in range(1, N+1):
        if i not in visited:
            cur = set([i])
            visited.add(i)
            cnt = 1
            while cur:
                temp = set()
                for i in cur:
                    for j in graph[i]:
                        if j not in visited:
                            visited.add(j)
                            cnt += 1
                            temp.add(j)
                cur = temp
            min_count = max(min_count, cnt)
    return min_count




if __name__ == '__main__':
    print(main())

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

int main(){
  
  string S;
  cin>>S;
  int pos=0;
  long long ans=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='W'){
      if(i!=0)ans+=i-pos;
      pos++;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for(int i=1; i<=n; i++) {
			int x = i;
			if(x%3 == 0) {
				System.out.print(" " + i);
			} else {
				while(x != 0){
					if(x%10 == 3){
						System.out.print(" " + i);
						break;
					} else {
						x /= 10;
					}
				}
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 28732
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N;
    string S;
    cin >> N >> S;

    int x = 0;
    int ret = 0;
    rep(i, N) ret = max(x += S[i] == 'I' ? 1 : -1, ret);

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val cntAndMax = (0, A.head)
    A.foldLeft(cntAndMax) { case ((cnt, max), h) =>
      if(h >= max) (cnt+1, Math.max(max, h)) else (cnt, max)
    }._1
  }

  println(solve())

}



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

int main() {
  int n ;
  cin >> n ;
  
  vector<vector<int>> x(2,vector<int>(n));
  
  for(int i = 0;i<2 ;i++){
    for(int j = 0 ;j< n;j++){
    cin >> x.at(i).at(j);
    }
  }
  
  vector<int> y(n);
  for(int i = 0;i<n ;i++){
    y.at(i)=x.at(0).at(0);
    for(int j = 0 ;j< 2;j++){
      if(j==0){
        for(int k = 1 ;k<=i ;k++){
          y.at(i)+=x.at(j).at(k);
        }
      }
      if(j==1){
        for(int l = i ;l<n;l++){
          y.at(i)+=x.at(j).at(l);
        }
      }
    }
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  cout << y.at(0) << endl;
}
  

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 55
#define int long long
using namespace std;
const int s = ('a'-1);
const int mod = (1e9)+7;
int n;
string str[N];

int mem[N][N][22][30],used[N][N][22][30];
int calc(int y,int x,int ch){
  int res = 0;
  if(x>=(int)str[y].size() || ch>=27) return 0;
  
  if(str[y][x] != '?') res = 1;
  if(str[y][x] == '?') res = 27 - ch;
  for(++x;x<(int)str[y].size();x++) if(str[y][x]=='?') res = (res*26)%mod;
  return res;
}


bool check(int u,int d,int x,char ch){
  static bool memc[N][N][22][30],usedc[N][N][22][30];
  if(usedc[u][d][x][ch-s]) return memc[u][d][x][ch-s];
  usedc[u][d][x][ch-s] = 1;
  for(int y=u;y<=d;y++) if(str[y][x] != '?' && str[y][x] != ch) return memc[u][d][x][ch-s]=0;
  return  memc[u][d][x][ch-s]=1;
}

bool check2(int u,int d,int x,char ch){
  static bool memc[N][N][22][30],usedc[N][N][22][30];
  if(usedc[u][d][x][ch-s]) return memc[u][d][x][ch-s];
  usedc[u][d][x][ch-s] = 1;
  for(int y=u;y<=d;y++) if(str[y][x] != '?' && str[y][x] <= ch) return memc[u][d][x][ch-s]=0;
  return memc[u][d][x][ch-s]=1;
}

bool check3(int u,int d,int x,int ch){
  while(u<=d&&str[u][x] == s) u++;
  for(int y=u;y<=d;y++) if(str[y][x]==s) return 0;
  return 1;
}

int dfs(int u,int d,int x,int c){
  if(u > d) return 1;
  if(u == d) return calc(u,x,c);
  if(x >= 21) return 0;
  if(str[u][x] == s) return c == 1 && str[u+1][x] != s ? dfs(u+1,d,x,c):0;
  if(used[u][d][x][c]++) return mem[u][d][x][c];

  int res = 0; 
  //[u,y]?????????????????????????????????????????????
  for(int ch=c;ch<=26;ch++){
    for(int y=u;y<=d;y++){
      if(check(u,y,x,ch+s) == false)continue;
      if(check2(y+1,d,x,ch+s) == false)continue;
      res = (res+(dfs(u,y,x+1,1)*dfs(y+1,d,x,ch+1))%mod)%mod;
    }
  }
  return mem[u][d][x][c] = res;
}


signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str[i];
    while(str[i].size()<21) str[i]+=s;
  }
  cout<<dfs(0,n-1,0,1)<<endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    vector<int> pos;

    rep(i, s.size()) {
        if(s.at(i) == 'B') pos.push_back(i);
    }
    
    ll ans  = 0;
    rep(i, pos.size()) {
        ans += s.size() - pos.size() +i - pos.at(i);
    }

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

Measured memory_bytes: 1532
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int;
  if (n % 2 == 0) {
    n.writeln;
  } else {
    writeln(2 * n);
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, a[MAXN], b[MAXN], ans=INF;
char s[MAXN];

int main()
{
    scanf("%d%s", &n, s+1);
    for(rint i=1; i<=n; ++i)
    {
        a[i]=a[i-1];
        if(s[i]=='#') a[i]++;
    }
    for(rint i=n; i>=1; --i)
    {
        b[i]=b[i+1];
        if(s[i]=='.') b[i]++;
    }
    for(rint i=0; i<=n; ++i) ans=min(ans, a[i]+b[i+1]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#define MOD 1000000007
#define INF (1ll<<60)
typedef long long ll;
using namespace std;

int main(){
    int n, i;
    cin >> n >> i;
    cout << n - i  + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
using namespace std;
inline ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
inline ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline void umax(ll &p,ll q){if(p<q)p=q;}
inline void umin(ll &p,ll q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,a[maxn];
int dfs()
{
    int cnt1=0,cnt2=0,x,i;
    rep(i,1,n)
    {
        if(a[i]&1)cnt1++,x=i;
        else cnt2++;
    }
    if(cnt2&1)return 0;
    else
    {
        if(cnt1>1)return 1;
        else
        {
            if(--a[x]==0)return 1;
            int y=a[1];
            rep(i,2,n)y=gcd(y,a[i]);
            rep(i,1,n)a[i]/=y;
            return dfs()^1;
        }
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)a[i]=read();
    puts(dfs()==0?"First":"Second");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

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

int main(void)
{
  int a, b;

  while (~scanf("%d%d", &a, &b)) {
    int g = gcd(a, b);
    printf("%d %d\n", g, a / g * b);
  }

  return (0);
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
#define rep(i,n) for(int i =0;i<(int)n;i++)

int main()
{
    int N;
    cin>>N;
    int d[N];
    rep(i,N)
    {
        cin>>d[i];
    }
    vector<int>v;
    rep(i,N)
    {
        v.push_back(d[i]);
    }
    sort(v.begin(),v.end());
    
    cout<<v[N/2]-v[N/2-1]<<endl;
}

Measured memory_bytes: 1276
n, a, b = map(int, input().split())
s = input()
c = a+b
for i in s:
  if i=="a":
    if c > 0:
      c -= 1
      print("Yes")
    else:
      print("No")
  elif i=="b":
    if c > 0 and b > 0:
      c -= 1
      b -= 1
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 4016
text = raw_input().rstrip()

words = text.split(" ")

d = {}

longest_word=""
frequency_word=""
max_count=0

for word in words:
  if len(longest_word) < len(word):
    longest_word = word
  if d.has_key(word):
    d[word] = d[word]+1
  else:
    d[word] = 1
  if max_count < d[word]:
    max_count = d[word]
    frequency_word=word

print "{} {}".format(frequency_word, longest_word)

Measured memory_bytes: 6300
n = int(input())
s = input()

import re


def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
        
d = nchars(s, 2)
for d_ in d:
    n -= len(d_) - 1
print(n)

Measured memory_bytes: 12864
##### 解けた #####

N,T=list(map(int,input().split(" ")))
minc,mint=1001,0

for _ in range(N):
    c,t=list(map(int,input().split(" ")))

    if t<=T: # T以内に帰宅できる
        minc=min(minc,c)

if minc<=1000: # 最小値が存在するなら
    print(minc)
else: # どの経路もダメな場合
    print("TLE")

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

long long n;
string s;
vector<long long> ans;

void solve();

int main() {
  cin >> s;
  n = s.size();
  solve();
  for(int i = 0; i < n; ++i) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

void solve() {
  ans.assign(n, 0);
  long long l = 0, r = 0, id = 0, mid = 0;
  while(l < n) {
    while(s[id] == 'R') ++id;
    mid = id - 1;
    while(s[id] == 'L' && id < n) ++id;
    r = id - 1;
    ans[mid] = (mid - l + 1) / 2 + (r - mid) / 2 +
               +((mid - l + 1) % 2 == 1);
    ans[mid + 1] = (mid - l + 1) / 2 + (r - mid) / 2 +
                   ((r - mid) % 2 == 1);
    l = r + 1;
  }
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

func solve(sum int, elem []int, idx, limit int) bool {
	if sum == 0 {
		// 合計が一致
		return true
	}
	if idx >= limit {
		return false
	}

	//     使わないパターン               || 使うパターン
	return solve(sum, elem, idx+1, limit) || solve(sum-elem[idx], elem, idx+1, limit)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	n := eGetInt(reader)
	a := eGetInts(reader)
	eGetInt(reader)
	ms := eGetInts(reader)
	for _, m := range ms {
		if solve(m, a, 0, n) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N;
ll dp[610][8];
ll f[610];
ll ans[610];

void solve() {
	cin >> N;
	rep(i, 0, 7) dp[0][i] = 1;
	f[0] = 1;
	rep(i, 1, 600) {
		dp[i][6] = 1;
		rer(j, 6, 0) {
			rep(k, 0, i + 1) dp[i][j] += dp[k][j + 1];
		}
		f[i] = dp[i][0] + f[i - 1];
	}
	rer(i, 600, 0) {
		while(N - f[i] >= 0) {
			N -= f[i];
			ans[i]++;
		}
	}
	string res;
	rep(i, 0, 600) {
		res += "FESTIVA";
		rep(k, 0, ans[i]) res += 'L';
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
n, l = list(map(int, input().split()))
taste = [l+i-1 for i in range(1, n+1)]
total = sum(taste)
diff = []
score = []
for i in range(n):
  tmp = sum(taste[i+1:])+sum(taste[:i])
  diff.append(abs(total - tmp))
  score.append(tmp)
print(score[diff.index(min(diff))])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 3007, MOD = 998244353;

int dp[N][N];
int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;

    for (int i = a; i <= c; ++i) {
        for (int j = b; j <= d; ++j) {
            if (i == a && j == b)
                continue;
            dp[i][j] = mod(dp[i - 1][j] * j + dp[i][j - 1] * i - mod(dp[i - 1][j - 1] * (i - 1)) * (j - 1));
        }   
    }   
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 73992
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int A, B; string S;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
int check(char c) { return '0' <= c and c <= '9'; }
string solve() {
    rep(i, 0, A) if (!check(S[i])) return no;
    if (S[A] != '-') return no;
    rep(i, A + 1, A + B + 1) if (!check(S[i])) return no;
    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 256
program atcoder
    implicit none
    integer(8) :: ans,k,a,b
    logical x
    read*,k,a,b
    ans = 1
    x = (b-a)>2_8
    do while(k>0_8)
        if(ans>=a .and. x .and. k>1_8)then
            ans = ans + (b-a)
            k = k-1_8
        else
            ans = ans + 1_8
        endif
        k = k-1_8
    enddo
    write(*,'(I0)')ans
    stop 
contains
end program atcoder


Measured memory_bytes: 256
n,m,c=map(int, input().split())
b=list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(n)]
buf=0
for i in range(n):
    a_sum=0
    for j in range(m):
        a_sum+=a[i][j]*b[j]
    a_sum+=c
    if a_sum>0:
        buf+=1
    else:
        continue
print(buf)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

#define INF 200000000

#include <cmath>
using namespace std;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

int main() {
    
    int N = in();
    
    vector<int> v;
    for(auto a = 0; a < N; a++){
        v.push_back(in());
    }
    
    int cost = INF;
    int temp;
    for(auto i = -100; i<= 100; i++){
        temp = 0;
        
        for(auto a: v){
            temp += (i-a)*(i-a);
        }
        
        if (temp < cost) cost = temp;
        
    }
    
    cout << cost << endl;
}




Measured memory_bytes: 384
n,m=map(int,input().split())
d={}
for i in range(m):
  d[i]=tuple(map(int,input().split()))[1:]
p=tuple(map(int,input().split()))
ans = 0
for i in range(2**n):
  cnt=[0]*n
  num = 0
  for j in range(n):
    if (i>>j)&1:
      cnt[j]=1
  for i in range(m):
    tmp = 0
    v=d[i]
    for s in v:
      if cnt[s-1]==1:
        tmp += 1
    if tmp%2==p[i]:
      num += 1
  if num == m:
    ans += 1
print(ans)

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  ll a, b, c, k;

  cin >> a >> b >> c >> k;

  ll numb = max(k-(a+b), 0LL);

  cout << min(a, k) - numb << endl;
  
  return 0;
}


Measured memory_bytes: 3652
main = do
  _ <- getLine
  bs <- map read . words <$> getLine
  mapM_ print $ f bs []

maxIns :: [Int] -> Maybe Int
maxIns bs = fmap fst $ safeLast . filter ((==) <$> fst <*> snd) $ zip bs [1..]

safeLast :: [a] -> Maybe a
safeLast [] = Nothing
safeLast xs = Just (last xs)

rm :: [Int] -> Int -> [Int]
rm bs i = take (i-1) bs ++ drop i bs

f :: [Int] -> [Int] -> [Int]
f [] as = as
f bs as = case maxIns bs of
            Nothing -> [-1]
            Just i  -> f (rm bs i) (i:as)

Measured memory_bytes: 1020
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        var line = Console.ReadLine();
        int X = int.Parse(line);
        int kyu = 0;
        if (400 <= X && X <= 599)
        {
            kyu = 8;
        }
        else if (600 <= X && X <= 799)
        {
            kyu = 7;
        }
        else if (800 <= X && X <= 999)
        {
            kyu = 6;
        }
        else if (1000 <= X && X <= 1199)
        {
            kyu = 5;
        }
        else if (1200 <= X && X <= 1399)
        {
            kyu = 4;
        }
        else if (1400 <= X && X <= 1599)
        {
            kyu = 3;
        }
        else if (1600 <= X && X <= 1799)
        {
            kyu = 2;
        }
        else if (1800 <= X && X <= 1999)
        {
            kyu = 1;
        }
        System.Console.WriteLine(kyu);
    }
}

Measured memory_bytes: 27516
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

		Integer a = sc.nextInt();
		Integer b = sc.nextInt();

		if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}

	}

}



Measured memory_bytes: 26228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
template <int mod>
struct ModInt {
    using ll = long long;
    ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &rhs) {
        x = x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(const ModInt &rhs) {
        *this *= rhs.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) {
        return os << rhs.x;
    }
    friend istream &operator>>(istream &is, ModInt &rhs) {
        ll t;
        is >> t;
        rhs = ModInt<mod>(t);
        return (is);
    }

   private:
    ModInt inverse() const {
        ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    vector<int> hoge{2 * A - 1, A + B, 2 * B - 1};
    sort(all(hoge));
    cout << hoge[2] << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
l=0
r=0
for i in s:
    if i ==')' and l==0:
        r+=1
    elif i==')':
        l-=1
    elif i=='(':
        l+=1
s1 = '('*r
s2 = ')'*l
s=s1+s+s2
print(s)


Measured memory_bytes: 3060
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [A, B, K] = r.nn()

    const d = A - K

    if (d >= 0) {
      return [d, B]
    }

    return [0, Math.max(0, B + d)]
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7372
/**
 *    author:  tootal    
 *    created: 2020/03/28 16:00:43
**/
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7
     ||a==5&&b==7&&c==5
     ||a==7&&b==5&&c==5)cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
int main() {
    double d,t,s;
    cin >> d >> t >> s;
    if(d / t <= s){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int w,h,x,y;
    scanf("%d%d%d%d", &w, &h, &x, &y);
    printf("%lf %d\n", double(w)*double(h)/2,2*x==w&&2*y==h);
    return 0;
}

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

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


/*
同じのが3枚あったらそれを対消滅 -> 1枚に
同じのが4枚あったらそれを対消滅-> 2枚に
これはそれぞれ1ずつ

同じのが2枚あるセクションがk個あったら
k/2はそれぞれ1ずつで完了する-> (k+1)/2 で切り上げればよーし
*/

int main() {
    int N; cin >> N;
    vector<int> a(N), c(N+2,0);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(),a.end());
    for (int i = 0; i < N; i++) {
        int tmp = a[i], j = i;
        while (i+1 < N && a[i+1] == tmp) i++;
        c[i-j+1]++;
    }
    int res = 0;
    for (int i = N-1; i >= 2; i--) {
        c[i] += c[i+2];
        res += c[i+2];
    }
    res += c[3] + (c[2]+1)/2;
    cout << N - 2 * res << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vi as(n-1), bs(n-1);
	vector<vi> gr(n);
	rep(i,0,n-1){
		cin >> as[i] >> bs[i];
		--as[i], --bs[i];
		gr[as[i]].push_back(bs[i]);
		gr[bs[i]].push_back(as[i]);
	}
	int h = k/2;
	int rek = 0;
	rep(i,0,n - (k&1)){
		int cnt = 0;
		stack<int> st;
		vi dist(n), par(n);
		if(k%2 == 0){
			st.push(i);
			par[i] = -1;
		} else {
			st.push(as[i]);
			st.push(bs[i]);
			par[as[i]] = bs[i];
			par[bs[i]] = as[i];
		}
		while(!st.empty()){
			int v = st.top();
			st.pop();
			if(dist[v] > h) continue;
			++cnt;
			trav(u, gr[v]) if(u != par[v]){
				par[u] = v;
				dist[u] = dist[v]+1;
				st.push(u);
			}
		}
		rek = max(rek, cnt);
	}
	cout << n - rek << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

        b[a]++;
    }

    vector<int> c(n + 1);
    for (int i = 0; i < n; i++) {
        c[b[i]]++;
    }

    int n1 = n, m1 = 0, k = 1;
    for (int h = n; h >= 0; h--) {
        int k1 = h > 0 ? n1 / h + m1 : n;
        for (; k <= k1; k++) {
            cout << h << '\n';
        }
        n1 -= c[h] * h;
        m1 += c[h];
    }

    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main(){
    int a,b,c,buf;
    cin >> a >> b >> c;
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    if(b>c){
        buf=b;
        b=c;
        c=buf;
    }
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    cout << a << " "<< b << " " << c << endl;
     
    return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

    public int lcs(char str1[], char str2[], int len1, int len2) {

        if (len1 == str1.length || len2 == str2.length) {
            return 0;
        }
        if (str1[len1] == str2[len2]) {
            return 1 + lcs(str1, str2, len1 + 1, len2 + 1);
        } else {
            return Math.max(lcs(str1, str2, len1 + 1, len2), lcs(str1, str2, len1, len2 + 1));
        }
    }

    public int lcsDynamic(char str1[], char str2[]) {

        int temp[][] = new int[str1.length + 1][str2.length + 1];
        int max = 0;
        for (int i = 1; i < temp.length; i++) {
            for (int j = 1; j < temp[i].length; j++) {
                if (str1[i - 1] == str2[j - 1]) {
                    temp[i][j] = temp[i - 1][j - 1] + 1;
                } else {
                    temp[i][j] = Math.max(temp[i][j - 1], temp[i - 1][j]);
                }
                if (temp[i][j] > max) {
                    max = temp[i][j];
                }
            }
        }
        return max;

    }

    public static void main(String[] args) {
        Main lcs = new Main();
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        for(int i = 0; i < N; i++) {
            String tmp1 = scan.next();
            String tmp2 = scan.next();
            int count = lcs.lcsDynamic(tmp1.toCharArray(), tmp2.toCharArray());
            System.out.println(count);
        }
    }
}



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

int main(){
    int n,k;
    cin>>n>>k;
    int tmp=0;
    int ans=0;
    rep(i,n){
        cin>>tmp;
        ans+=min(abs(0-tmp), abs(k-tmp));
    }

    ans*=2;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int min = 101;
		int sum = 0;
		for (int i = 0; i < N; i++) {
			int a = in.nextInt();
			sum += a;
			if (a % 10 != 0) {
				min = Math.min(min, a);
			}
		}
		System.out.println(sum % 10 != 0 ? sum : min == 101 ? 0 : sum - min);
		in.close();
	}
}

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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> x(N);
	vector<int> y(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i];
	}
	
	
	// 村の順列を使用するための準備
	vector<int> village(N);
	for (int i = 0; i < N; i++)
	{
		village[i] = i;
	}
	// 村の順列の計算
	int count = 0;
	double distanceSum = 0.0;
	do {
		// ループ回数で分母の計算
		count++;
		
		for (int i = 0; i < N - 1; i++)
		{
			// 距離の計算
			// villageには1つの順列が格納されているので、その値を距離計算に使用
			double disX = x[village[i]] - x[village[i + 1]];
			double disY = y[village[i]] - y[village[i + 1]];
			// ルートの計算
			double distance = pow(disX * disX + disY * disY, 0.5);
			distanceSum += distance;
		}
		
	} while(next_permutation(village.begin(), village.end()));
	
	// 出力計算
	double answer = distanceSum / (double)count;
	// 例題の出力に合わせる
	cout << std::fixed << std::setprecision(10) << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();

		int x = 0;
		int y = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			int ti = sc.nextInt();
			int xi = sc.nextInt();
			int yi = sc.nextInt();
			int dt = ti - t;
			int d = manhattan(x, y, xi, yi);
			if (dt < d) {
				System.out.println("No");
				return;
			} else if ((dt - d) % 2 == 1) {
				System.out.println("No");
				return;
			} else {
				x = xi;
				y = yi;
				t = ti;
			}
		}
		System.out.println("Yes");
		sc.close();
	}

	private int manhattan(int x0, int y0, int x1, int y1) {
		return Math.abs(x0 - x1) + Math.abs(y0 - y1);
	}

}

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

int main(){
  while(1){
    string s;
    int m, sum=0;
    cin>>s;
    if(s=="-")break;
    cin>>m;
    for(int i=0;i<m;i++){
      int x;
      cin>>x;
      sum+=x;
    }
    int n=s.size();
    for(int i=0;i<n;i++){
      cout<< s[ (i+sum)%n ];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
using namespace std;
const ll mx = 4010;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};
map<ll, ll>mp;

void solve(ll a)
{
    mp[a]++;
    //cout << a << endl;
}

void calc(ll n){
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=n; j++){
            for(ll k=1; k<=n; k++){
                ll x = i*i+j*j+k*k+i*j+j*k+k*i;
                solve(x);
            }
        }
    }
}
int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t = 1, n, k, l, r, d;
    //cin >> t;
    calc(100);



    while(t--){
        cin >> n;
        for(ll i=1; i<=n; i++){
            cout << mp[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5992
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	string s;
	cin >> s;

	ll res = inf;
	for (ll i = 0; i < 26; i++)
	{
		char c = 'a' + i;

		ll cnt = 0;
		ll x = 0;
		for (ll j = 0; j < s.length(); j++)
		{
			if (s[j] == c)
			{
				cnt = max(cnt, x);
				x = 0;
			}
			else
			{
				x++;
			}
		}
		cnt = max(cnt, x);

		res = min(res, cnt);
		
	}

	println(res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO  
int n,m;
cin>>n>>m;
vector<int> a(n);
int s=0;
for(int i=0;i<n;i++){
  cin>>a[i];
  s+=a[i];
}
sort(a.begin(),a.end());
bool is=false;
for(int i=0;i<n;i++){
   if(s<=(4*m*a[i])){
       if((n-i)>=m){
         is=true;
         break;
       }
       else{
         is=false;
         break;
       }
   }
}
if(is){
  cout<<"Yes";
}
else{
  cout<<"No";
}
return 0;
}


Measured memory_bytes: 256