akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    string S;
    cin>>S;
    int A[4];
    for(int i=0;i<4;++i){
        A[i] = S[i] - '0';
    }
    int ans;
    int tmpans;
    for(int bit=0;bit<(1<<3);++bit){
        tmpans = A[0];
        for(int i=0;i<3;++i){
            if((bit&(1<<i))!=0) tmpans += A[i+1];
            else tmpans -= A[i+1];
        }
        if(tmpans == 7){
            ans = bit;
            break;
        }
    }
    cout<<A[0];
    for(int i=0;i<3;++i){
        if((ans&(1<<i))!=0){
            cout<<'+';
        }
        else{
            cout<<'-';
        }
        cout<<A[i+1];
    }
    cout<<"=7"<<endl;
}



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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    double res = (n/3.0)*(n/3.0)*(n/3.0);
    cout << setprecision(8) << res << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    n, m = map(int, input().split())
    print((n - 1) * (m - 1))

if __name__ == '__main__':
    main()


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


int main(void)
{
	char s[1000001];
	scanf("%s", s);
	int i, st = strlen(s);
	int k, min = st;
	for (i = 0; i < st-1; i++){
		//printf("%d:\n", i);
		if (s[i] != s[i + 1])  {
			k = (i+1 > st -(1 + i)) ? i+1 : st-1  - i; if (k < min) min = k;
			//printf("k=%d, min=%d\n", k, min);
		}
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
using ll=long long int;

int n;
vector<string> bsa, bs, sa, s;
int bsac, bsc, sac, sc;

int abcnt(vector<string> s) {
	int ret = 0;
	for (int i = 0; i < s.size(); i++) {
		string si = s[i];
		for (int j = 0; j < si.size() - 1; j++) {
			if (si[j] == 'A' && si[j + 1] == 'B')
				ret++;
		}
	}
	return ret;
}

int main(void) {
	cin >> n;
	string tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (tmp[0] == 'B') {
			if (tmp.back() == 'A') {
				bsa.push_back(tmp);
				continue;
			}
			bs.push_back(tmp);
		}
		else if (tmp.back() == 'A') {
			sa.push_back(tmp);
		}
		else
			s.push_back(tmp);
	}
	int ret = 0;

	bsac = abcnt(bsa);
	bsc = abcnt(bs);
	sac = abcnt(sa);
	sc = abcnt(s);
	ret += bsac + bsc + sac + sc;
	if (bsa.size() > 0)
		ret += bsa.size() - 1;
	ret += min(bs.size(), sa.size());
	if (bs.size() + sa.size() > 0 && bsa.size()>0)
		ret++;
	cout << ret << endl;
	return 0;

}

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }
  sort(D.begin(), D.end());
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    T[i] = abs(24 * (i % 2) - D[i]);
  }

  int res = D[0];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      res = min({res, abs(T[i] - T[j]), 24 - abs(T[i] - T[j])});
    }
  }

  cout << res << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力を取得
    String s = sc.next();
    int[] count = new int[2];
    for(int i=0;i<s.length();i++){
      if(s.charAt(i) == '0'){
        count[0]++;
      }else{
        count[1]++;
      }
    }

    // 出力
    System.out.println(Math.min(count[0],count[1]) *2);
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int N, K;
	cin >> N >> K;
	double arr[N], tmp;
	double ans = 0;
	REP(i, 0, N){
		cin >> tmp;
		tmp = (tmp*(tmp+1)/(2*tmp));
		arr[i] = (i==0? tmp:arr[i-1]+tmp);
		
		if(i == K-1) ans = arr[i];
		else if(i > K-1) ans = max(ans, arr[i] - arr[i-K]);
	}
	cout << fixed << setprecision(6)<< ans;

}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int ans = 1;
    int max = sc.nextInt();

    for (int i = 1; i < n; i++) {
      int h = sc.nextInt();
      if (h >= max) {
        ans++;
        max = h;
      }
    }

    System.out.println(ans);

  }
}

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

int main(){
  string S; long long K;
  cin>>S>>K;
  long long N = S.size();
  
  
  for(int i=0;i<min(N,K);i++){
    if(S.at(i)!='1'){
      cout<<S.at(i);
      break;
    }
    else if(i==min(N,K)-1)
      cout<<'1';
  }
}
  


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

int main()
{
    int H, W;
    cin >> H >> W;

    char img[H+1][W+1];
    char res[2*H+1][W+1];
    for(int i = 1; i <= H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            cin >> img[i][j];
        }
    }
    for(int i = 1; i <= 2*H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            res[i][j] = img[(i+1)/2][j];
            cout << res[i][j];
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    while(true){
      int n = sc.nextInt();
      if(n == 0) break;

      //nテ」ツ?ョ8テゥツ?イテヲツ閉ーティツ。ツィティツィツ?
      String octal = Integer.toString(n, 8);

      octal = octal.replaceAll("7", "9");
      octal = octal.replaceAll("6", "8");
      octal = octal.replaceAll("5", "7");
      octal = octal.replaceAll("4", "5");
      System.out.println(octal);
    }
  }
}

Measured memory_bytes: 13000
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	string s;
	string t;
	cin>>n>>s>>t;
	for(int i = n; i <= 2*n; i++){
		bool f = true;
		for(int j = 0; j < n; j++){
			if(j+i-n<n && t[j]!=s[j+i-n]) f = false;
		}
		if(f){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = list(input())
t = list(input())

snum = [(0,0)] #snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数
for i in range(len(s)):
    if s[i] == 'A':
        snum.append((snum[-1][0]+1,snum[-1][1]))
    else:
        snum.append((snum[-1][0],snum[-1][1]+1))

tnum = [(0,0)]
for i in range(len(t)):
    if t[i] == 'A':
        tnum.append((tnum[-1][0]+1,tnum[-1][1]))
    else:
        tnum.append((tnum[-1][0],tnum[-1][1]+1))

q = int(input())
for i in range(q):
    a,b,c,d = map(int,input().split())
    sa = snum[b][0]-snum[a-1][0]
    sb = snum[b][1]-snum[a-1][1]
    ta = tnum[d][0]-tnum[c-1][0]
    tb = tnum[d][1]-tnum[c-1][1]
    
    #全てbにする
    b1 = sb+sa*2
    b2 = tb+ta*2
    if abs(b2-b1)%3==0:
        print('YES')
        continue
    
    #全てaにする
    a1 = sa+sb*2
    a2 = ta+tb*2
    if abs(a2-a1)%3==0:
        print('YES')
        continue
    
    print('NO')


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (a >= b ? "delicious" : (b - a > x ? "dangerous" : "safe")) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<long long> A(N);
  long long  minnum=0;
  long long S=0;
  long long minn=LLONG_MAX;
  for(int i=0;i<N;i++){
    cin >>A.at(i);
    if(A.at(i)<0){minnum++;}
    A.at(i)=abs(A.at(i));
    S+=A.at(i);
    minn=min(minn,A.at(i));
  }
  
  if(minnum%2==0){cout <<S<<endl;}
  else{S=S-2*minn;
    cout <<S<<endl;}
}

Measured memory_bytes: 1024
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b, c ,d;
  cin >> a >> b >> c >> d;
  ll ct = 0;
  while(a > 0 and c > 0) {
    if(ct == 0) {
      c-= b;
      if(c <= 0) {
        cout << "Yes";
        return 0;
      }
    } else {
      a-=d;
      if(a<= 0) {
        cout << "No";
        return 0;
      }
    }
    ct^=1;
  }
  return 0;
} //good night.


Measured memory_bytes: 3608
//           ––=‹‹BISMILLAHITR RAHMANIR RAHIM››=––
//  Problem name: 
//  Lang: C++
//  ©: _Shakib Hossen Shanto   _ CSE Dept__Begum Rokeya University,Rangpur
#include<bits/stdc++.h>
using namespace std;
 
#define uns unsigned
#define ll long long
#define dl double
#define st string
#define ch char
#define tc ll t;cin>>t;while(t--)
 
int main()
{
    ll a;
    cin >> a;
    if(a==1) cout<<"0\n";
    else cout<<"1\n";
    return 0;
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.readline

N = int(readline())
L = list(map(int,readline().split()))
L = sorted(L)

# 2本固定すると、もう一本として選べるのは、2本の和より長いものだけ
# これを二分探索で数える

#print(L)
import bisect
ans = 0
for i in range(N - 1):
  for j in range(i + 1,N):
    limit = L[i] + L[j]
    ok = bisect.bisect_left(L, limit)
#    print("i",i,"j",j,"L[i]",L[i],"L[j]",L[j],"limit",limit,"ok",ok,"ok - j",ok - 1 - j)
    ans += ok - 1 - j
        
print(ans)

Measured memory_bytes: 9348
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        Restaurant R[] = new Restaurant[N];
        for(int i = 0; i < N; i++){
            R[i] = new Restaurant(in.next(), in.nextInt(), i+1);
        }
        Arrays.sort(R, (r1, r2) -> r1.name.equals(r2.name) ? r2.score - r1.score : r1.name.compareTo(r2.name));

        for(int i = 0; i < N; i++){
            println(R[i].id);
        }

        in.close();
        out.close();
    }

    static class Restaurant{
        String name;
        int score;
        int id;
        Restaurant(String n, int s, int i){
            name = n;
            score = s;
            id = i;
        }
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 26444
def main():
    x, k, d = map(int, input().split())
    y = abs(x) // d
    if y == k:
        print(abs(x) % d)
    elif y < k:
        if (k-y) % 2 == 0:
            print(abs(x) % d)
        else:
            print(min(abs(abs(x) % d - d), abs(abs(x) % d + d)))
    else:
        print(min(abs(abs(x)-d*k), abs(abs(x)+d*k)))




if __name__ == '__main__':
    main()


Measured memory_bytes: 61920
from fractions import gcd
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a,b,c,d = A[i]
    g = gcd(b,d)
    if a < b or b > d or b-g+(a%g)>c:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 5688
main(i,m,h,t,a){
    char s[201];
    for(;scanf("%s%d",s,&m),s[0]!='-';puts("")){
    for(i=t=0,a=strlen(s);i<m;scanf("%d",&h),t+=h,i++);
    for(i=0;i<a;printf("%c",s[(t+i++)%a]));
    }
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>
using namespace std;
int main() {
	string s;
	getline(cin, s);
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1176
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()
#とりあえずサンプルコードを提出

Measured memory_bytes: 4468
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N; cin>>N;
    long long T; cin>>T;
    int Q; cin>>Q;

    vector<long long> A(N);
    vector<int> D(N);
    for (int i=0; i<N; i++)
        cin>>A[i]>>D[i];
    //  ????????¢???????????????P[i]=A[i]????????°??¢????????????
    vector<long long> P = A;

    for (int i=0; i<N-1; i++)
    if (D[i]==1 && D[i+1]==2)
    {
        long long p = (A[i]+A[i+1])/2;
        for (int j=i; j>=0 && D[j]==1; j--)
            P[j] = p;
        for (int j=i+1; j<N && D[j]==2; j++)
            P[j] = p;
    }

    for (int i=0; i<Q; i++)
    {
        int X; cin>>X;
        X--;

        long long t = A[X] + (D[X]==1 ? T : -T);
        if (P[X]==A[X])
            cout<<t<<endl;
        else if (D[X]==1)
            cout<<min(P[X], t)<<endl;
        else
            cout<<max(P[X], t)<<endl;
    }
}

Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;
ll dp[100001];
void digi()
{
	memset(dp,0,sizeof(dp));
	dp[1]=1;
	for(ll i=2;i<100001;i++)
	{
		ll count=0;
		ll x=i;
		while(x)
		{
			x/=10;
			count++;
		}
		if(count%2)
		dp[i]=dp[i-1]+1;
		else
		dp[i]=dp[i-1];
	}
}
void solve()
{ll t,n,k,x,y,z,d=0,p,q,l=INT_MAX,mini=0,prev;
  digi();
  cin>>n;
  cout<<dp[n];
}
 
int main()
{
  fast
ll t=1;
 
while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

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

int main(){
  int k;
  int num[3];
  cin>>num[0]>>num[1]>>num[2]>>k;
  int mnum = max(num[0],num[1]);
  mnum = max(mnum,num[2]);
  int log;
  for(int i=0;i<3;i++){
	if(num[i]==mnum){
      log=i;
      break;
    }
  }
  int sum =num[0]+num[1]+num[2]-num[log]+mnum*pow(2,k);
  cout<<sum<<endl;
}

Measured memory_bytes: 512
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  string S = readln.chomp;
  int[char] arr;

  foreach (c; 'a'..'z') {
    arr[c] = 0;
  }

  foreach (c; S) {
    arr[c]++;
  }

  char add_char = 'z' + 1;
  foreach (c; arr.byKey) {
    if (arr[c] != 0) continue;
    add_char = min(add_char, c);
  }

  if (add_char != 'z' + 1) {
    writeln(S ~ add_char);
    return;
  }

  char min_char = 'z' + 1;
  bool f = false;
  for (long i = S.length - 2; i != ulong.max; i--) {
    for (long j = i + 1; j < S.length; j++) {
      if (S[j] > S[i]) {
        min_char = min(min_char, S[j]);
        f = true;
      }
    }
    if (f) {
      writeln(S[0..i] ~ min_char);
      return;
    }
  }

  writeln(-1);
}


Measured memory_bytes: 256
H, W = map(int,input().split( ))
a = []
for i in range(H):
	a_i = str(input())
	a.append(a_i)

s = ''
for i in range(W+2):
	s += '#'
for i in range(H+2):
	if i == 0 or i == H+1:
		print(s)
	else:
		print('#' + a[i-1] + '#')



Measured memory_bytes: 3060
#include<iostream>

int main(){
    int n;
    std::cin >> n;
    int a[n],key;
    for (int i = 0;i<n; i++){
        std::cin >> a[i];
    }
    for (int i=1;i<n;i++){
        for (int k=0; k<n; k++){
            if (k>0) std::cout << ' ';
            std::cout << a[k] ;
        }
        std::cout << '\n';
        key = a[i];
        for (int j = i; j>=0; j--){
            if(key < a[j-1]){
                a[j] = a[j-1];
            }else {
                a[j] = key;
                break;
            }
        }
    }
    for (int k=0; k<n; k++){
        if (k>0) std::cout << ' ';
        std::cout << a[k] ;
    }
    std::cout << '\n';
    
    return 0;
}



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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int a[4][3][10];

int main(){
	cin.tie(0);
	
	int n;
	int b, f, r, v;
	cin>>n;
	rep(i, n) {
	    cin>>b>>f>>r>>v;
	    a[b-1][f-1][r-1] += v;
	}
	
	rep(i, 4) {
	    rep(j, 3) {
	        rep(k, 10) {
	            cout<<' '<<a[i][j][k];
	        }
	        cout<<endl;
	    }
	    if(i<3)cout<<"####################"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3084
n = int(input())
a_li = list(map(int, input().split()))

if 0 in a_li:
    print(0)
    exit()

ans = 1
a_li = [a for a in a_li if a != 1 and a != 0]
a_li.append(1)
for a in a_li:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21720
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;


void solve() {
	ll n, l; ll k; cin >> n >> l >> k;
	ll d = k / l;
	vector<ll> a(n),b(n);
	vector<ll> s(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
		s[i] = l * a[i] + l * (l - 1) / 2 * b[i];
	}
	ll sum = 0;
	rep(i, d)sum += s[i];
	{
		ll cur = a[d];
		rep(i, (k%l)) {
			sum += cur;
			cur += b[d];
		}
	}
	ll ans = sum;
	int le = 0, ri = d;
	int cl = 0, cr = k%l;
	while (ri < n) {
		//cout << le << " " << cl << " " << ri << " " << cr << " " << sum << endl;
		ll ad = a[ri] + b[ri] * cr - (a[le] + b[le] * cl);
		ll rad = b[ri] - b[le];
		ll len = min(l - cl, l - cr);
		if (rad < 0) {
			ll u = ad / (-rad);
			u++;
			if (u < len&&u>=0) {
				ll csum = sum + ad * u + u * (u - 1) / 2 * rad;
				ans = max(ans, csum);
			}
		}
		sum += ad * len + len * (len - 1) / 2 * rad;
		ans = max(ans, sum);
		cl += len; cr += len;
		if (cl == l) {
			le++; cl = 0;
		}
		if (cr == l) {
			ri++; cr = 0;
		}
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> n>>h>>m>>s,n)solve();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 5064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		for (int i=0;i<(1<<N);i++) {
			int[] arr = new int[N];
			int tmp = i;
			String red = "";
			String blue = "";
			for (int j=0;j<N;j++) {
				arr[j] = tmp%2;
				tmp /= 2;
				if (arr[j]==1) red += S.charAt(j);
				else blue += S.charAt(j);
			}
			String key = red + " " + blue;
			if (map.containsKey(key)) {
				map.put(key, map.get(key)+1);
			} else {
				map.put(key, 1);
			}
		}

		long ans = 0L;

		for (int i=0;i<(1<<N);i++) {
			int[] arr = new int[N];
			int tmp = i;
			String red = "";
			String blue = "";
			for (int j=N-1;j>=0;j--) {
				arr[j] = tmp%2;
				tmp /= 2;
				if (arr[j]==1) red += S.charAt(N+j);
				else blue += S.charAt(N+j);
			}
			String key = red + " " + blue;
			if (map.containsKey(key)) {
				ans += map.get(key);
			} else {
			}
		}
		System.out.println(ans);
	}
}

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

int parity(int n){
  if(n*n*n*n%10 == 1)
    return 1;
  else
    return 0;
}

int power(int x, int y){
  int64_t n = 1ll;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  for(int i = 1; i < n; i++){
    if(s.at(i-1) != s.at(i))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
#include <map>

// namespace
using namespace std;

struct edge { int from, to, cost; };
vector<int> bellman_ford(int start, int num_vertex, const vector<edge> &edges) {
    vector<int> d(num_vertex, INT_MAX);
    d[start] = 0;
    while (true) {
        bool updated = false;
        // for (const auto &e: edges) {
        for (int i = 0; i < edges.size(); ++i) {
            edge e = edges[i];
            if (d[e.from] != INT_MAX && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }
        if (!updated) break;
    }
    return d;
}

vector<int> dijkstra(int start, int num_vertex, map<int, vector<edge> > &edges) {
    // using P = pair<int, int>;
    typedef pair<int, int> P;
    priority_queue<P, vector<P>, greater<P> > q;
    vector<int> d(num_vertex, INT_MAX);
    d[start] = 0;
    q.push(P{0, start});
    while (!q.empty()) {
        P p = q.top(); q.pop();
        if (d[p.second] < p.first) continue;  // if this item is not the smallest distance to v
        // for (const auto &e: edges[p.second]) {
        for (int i = 0; i < edges[p.second].size(); ++i) {
            edge e = edges[p.second][i];
            if (d[e.from] != INT_MAX && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                q.push(P{d[e.to], e.to});
            }
        }
    }
    return d;
}

int main() {
    int v, e, s, from, to, cost;
    cin >> v >> e >> s;
    vector<edge> es;
    // map<int, vector<edge> > es;
    for (int i = 0; i < e; ++i) {
        cin >> from >> to >> cost;
        es.push_back(edge{from, to, cost});
        // es[from].push_back(edge{from, to, cost});
    }
    vector<int> ans = bellman_ford(s, v, es);
    // vector<int> ans = dijkstra(s, v, es);
    for (int i = 0; i < ans.size(); ++i) {
        if (ans[i] != INT_MAX) cout << ans[i] << endl;
        else cout << "INF" << endl;
    }
    return 0;
}



Measured memory_bytes: 9184
#include <stdio.h>

// ユーザ入力により枠の縦・横の長さを受け取り、
// 枠を#、中身を.で表示する
int main()
{
	// 変数定義と初期化
	int iTate = -1;		// 縦の長さ
	int iYoko = -1;		// 横の長さ
	int iInCount = 0;	// 入力回数
	int iCountA;		// ループカウンタA
	int iCountB;		// ループカウンタB

	while (1)
	{
		// 入力：縦横の長さ
		scanf("%d %d", &iTate, &iYoko);
		iInCount++;

		// 縦横ともに0を指定されたら終了する
		if (iTate + iYoko == 0)
		{
			break;
		}

		// 出力：枠を表示
		for (iCountA = 0; iCountA < iTate; iCountA++)
		{
			for (iCountB = 0; iCountB < iYoko; iCountB++)
			{
				// 最初と最後の行は#
				if (iCountA == 0 || iCountA == iTate - 1)
				{
					printf("#");
				}
				// 各行の最初と最後の列は#
				else if (iCountB == 0 || iCountB == iYoko - 1)
				{
					printf("#");
				}
				// 枠内部は.
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>

int n, A[50];

int solve (int i, int m) {
	if (m == 0 ) return 1;
	if (i >= n ) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;
	
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ) scanf ("%d", &A[i]);
	scanf ("%d", &q);
	for (i = 0; i < q; i++ ) {
		scanf("%d", &M);
		if ( solve(0, M) ) printf ("yes\n");
		else printf ("no\n");
	}
	
	return 0;
}


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

using namespace std;

int main () {
	long long a, b, c;
	char tmp;
	scanf("%lld%lld%c%lld", &a, &b, &tmp, &c);
	b = b * 100 + c;
	a = a * b / 100;
	printf("%lld", a);
	return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x) cerr << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cerr << a << " "; cerr << endl;
#define debug3(x) rep(i, sizeof(x)) cerr << x[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

struct data {
    int d1, d2, d3;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L;
    cin >> L;
    vector<int> v;
    while (L > 0) {
        v.push_back(L % 2);
        L /= 2;
    }
    vector<data> ans;
    int N = v.size();
    for (int from = 1, to = 2, weight = 1; to <= N; from++, to++, weight *= 2) {
        ans.push_back({from, to, 0});
        ans.push_back({from, to, weight});
    }
    int ever = 1 << (N - 1);

    for (int i = (int) v.size() - 2; i >= 0; --i) {
        if (v[i] == 0) continue;
        ans.push_back({i + 1, N, ever});
        ever += 1 << i;
    }
    cout << N << " " << ans.size() << endl;
    for (auto a : ans) {
        cout << a.d1 << " " << a.d2 << " " << a.d3 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    /////////////////////
    // Write code below /
    /////////////////////
    int A, B;
    string op;
    cin >> A >> op >> B;
    
    if (op == "+") {
        cout << A + B << endl;
    } else if (op == "-") {
        cout << A - B << endl;
    } else {
        cout << "error" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
'''
if n==1:
    print(input())
    quit()
 '''   
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

ans = int(input())
for i in range(n-1):
    tmp = int(input())
    ans = lcm(tmp,ans)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int k,a,b;
	int flag =0;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
		for(int i=a;i<=b;i++){
			if(i%k==0){
				flag=1;
			}
		}
	if(flag==1){
		printf("OK\n");
	}
	else{
				printf("NG\n");

	}
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  int ans = 0;
  string acgt = "ACGT";
  for (int i = 0; i < s.size(); i++) {
    int cnt = 0, j = i;
    while (acgt.find(s[j]) != string::npos) {
      j++;
      cnt++;
    }

    ans = max(ans, cnt);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    for(int i = 0; i < a; i++){
        if(!(s[i] >= '0' && s[i] <= '9')){
            cout << "No";
            return;
        }
    }
    if(s[a] == '-'){
        for(int i = a + 1; i < a + b + 1; i++){
            if(!(s[i] >= '0' && s[i] <= '9')){
                cout << "No";
                return;
            }
        }
        cout << "Yes";
        return;
    }
    cout << "No";
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  int p[1005];
  int ans=0;

  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>p[i];
  sort(p,p+n);

  for(int i=0;i<k;i++) ans+=p[i];

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


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, N;
  cin>>H>>W>>N;
  int Sr, Sc;
  cin>>Sr>>Sc;
  Sr--;
  Sc--;
  string S, T;
  cin>>S>>T;
  int migi=W, hidari=-1, ue=-1, shita=H;
  bool can = true;
  for(int i=N-1;i>=0;--i) {
    if(T[i]=='L') {
      migi = min(W, migi+1);
    }
    if(T[i]=='R') {
      hidari = max(-1, hidari-1);
    }
    if(T[i]=='U') {
      shita = min(H, shita+1);
    }
    if(T[i]=='D') {
      ue = max(-1, ue-1);
    }
    if(S[i]=='L') {
      hidari++;
    }
    if(S[i]=='R') {
      migi--;
    }
    if(S[i]=='U') {
      ue++;
    }
    if(S[i]=='D') {
      shita--;
    }
    if(ue+1>=shita || hidari+1>=migi) can = false;
  }
  if(Sr<=ue || Sr>=shita || Sc>=migi || Sc<=hidari) can = false;
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3908
function Main(input) {
    var eigo = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]        

    input = input.split("\n")
    var a = parseInt(input[0])
    var b = input[1]    
    var text =""

    for (var i=0;i<b.length;i++){
        var e=b[i]                
        var index = eigo.findIndex(f=>f==e)        
        var c = (index+a)%26
        text +=eigo[c]        
    }


    console.log(text);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 8252
#include<iostream>

using namespace std;
 
int main(){
    int n,x,a;
    while(1){
        cin>> n>> x;
        if(n==0 && x==0)break;
        a=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        a++;
                    }
                }
            }
        }
        cout<< a<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
def findr(str, s, e)
  d, i = 0, s
  while i < e
    d+= 1 if str[i] == '('
    d-= 1 if str[i] == ')'
    return i if d == 1 and str[i] == ','
    i += 1
  end
end

def solve(s1, e1, s2, e2)
  f1, f2, m1, m2 = s1 < e1, s2 < e2, e1 - 1, e2 - 2
  m1 = findr($t1, s1, e1) if f1
  m2 = findr($t2, s2, e2) if f2
  if ($isI and f1 and f2) or (not $isI and (f1 or f2))
    printf("("); solve(s1 + 1, m1, s2 + 1, m2)
    printf(","); solve(m1 + 1, e1 - 1, m2 + 1, e2 - 1)
    printf(")")
  end
end

while line = gets
  op, a, b = line.chomp.split(/\s/)
  $t1, $t2 = a.split(//), b.split(//)
  $isI = (op == "i")
  solve(0, $t1.size, 0, $t2.size)
  puts
end

Measured memory_bytes: 6116
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);

  char s[300001];
  scanf("%s", s);

  int a[300001][2] = {0};
  int ans = n+10;

  for(int i=0; i<=n; i++){
    if(i==0){
      a[0][0] = 0;     
      a[n-1][1] = 0;      
      continue;
    }

    if(s[i-1] == 'W'){
      a[i][0] = a[i-1][0]+1;
    }
    else{
      a[i][0] = a[i-1][0];
    }

    if(s[n-i] == 'E'){
      a[n-1-i][1] = a[n-i][1]+1;
    }
    else{
      a[n-1-i][1] = a[n-i][1];
    }
  }

  int change = 0;
  for(int k = 0; k<n; k++){
    change = a[k][0] + a[k][1];
    //    printf("k=%d, a[k][0]=%d, a[k][1]=%d\n", k,a[k][0],a[k][1]);
    if(ans>change){
      ans = change;
    }
  }
  
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2816
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    
   return 0;
}



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

using ll = long long;
using namespace std;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll n, ans = (ll)1e12;

int main(){
		cin >> n;
		vector< ll > div = divisor(n);
		
		for(auto itr = div.begin(); itr != div.end(); ++itr){
			ans = min(ans, (n / *itr) + *itr - 2);
		}
		
		cout << ans << endl;
}

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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<int> alphabetCounts(26, 0);
  for (int y = 0; y < H; y++) {
    string S;
    cin >> S;
    for (int x = 0; x < W; x++) {
      alphabetCounts[S[x] - 'a']++;
    }
  }
  sort(alphabetCounts.begin(), alphabetCounts.end());

  for (int y = 0; y < (H + 1) / 2; y++) {
    for (int x = 0; x < (W + 1) / 2; x++) {
      int y2 = H - 1 - y;
      int x2 = W - 1 - x;
      int count = 0;
      if (x == x2 and y == y2) {
        count = 1;
      } else if (x == x2) {
        count = 2;
      } else if (y == y2) {
        count = 2;
      } else {
        count = 4;
      }

      if (count == 1) {
        for (int i = 0; i < 26; i++) {
          if (alphabetCounts[i] % 2 == 1) {
            alphabetCounts[i] -= 1;
            break;
          }
        }
      } else if (count == 4) {
        bool found = false;
        for (int i = 0; i < 26; i++) {
          if (alphabetCounts[i] >= 4) {
            alphabetCounts[i] -= 4;
            found = true;
            break;
          }
        }
        if (!found) {
          printf("No\n");
          return 0;
        }
      } else if (count == 2) {
        bool found = false;
        for (int i = 0; i < 26; i++) {
          if (alphabetCounts[i] % 4 == 2) {
            alphabetCounts[i] -= 2;
            found = true;
            break;
          }
        }
        if (!found) {
          for (int i = 0; i < 26; i++) {
            if (alphabetCounts[i] >= count) {
              alphabetCounts[i] -= 2;
              found = true;
              break;
            }
          }
        }
        if (!found) {
          printf("No\n");
          return 0;
        }
      }
    }
  }

  printf("Yes\n");

  return 0;
}


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

using namespace std;
int main()
{
    ll n,i,f1=0,f2=0,f3=0,x,j;
    string a="",b="",c="";
    cin>>a;
    n=a.length();
    b=a;
    reverse(b.begin(),b.end());
    if(a==b)
    {
        f1=1;
    }
    else
    {
        f1=0;
    }
    b.clear();

    x = ((n-1)/2);
    b=a.substr(0,x);
    c=b;
    reverse(c.begin(),c.end());
    if(c==b)
    {
        f2=1;
    }
    else
    {
        f2=0;
    }
    b.clear();
    c.clear();
    x = ((n+3)/2);
    j=0;
    b=a.substr(x-1,x);
    c=b;
    reverse(c.begin(),c.end());
    // cout<<b<<endl; cout<<c<<endl;
    if(c==b)
    {
        f3=1;
    }
    else
    {
        f3=0;
    }
    if((f1+f2+f3)==3)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}



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

int main(void){
	int N;
	string r;
	cin >> N;
	vector<string> kinds = {"AC", "WA", "TLE", "RE"};
	vector<int> res(4, 0);
	for(int i = 0; i < N; i++){
	       	cin >> r;
		if(r == "AC") res[0]++;
		else if(r == "WA") res[1]++;
		else if(r == "TLE") res[2]++;
		else res[3]++;
	}
	for(int i = 0; i < 4; i++)
		cout << kinds[i] << " " << "x" << " " << res[i] << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {


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

		int ans = s.length();

		for (int i = 0; i < 2; i++) {

			int cnt = 0;

			for (int j = 0; j < s.length(); j++) {
				if(j % 2 == 0 && s.charAt(j) != (char)(i + '0')) cnt++;
				if(j % 2 == 1 && s.charAt(j) == (char)(i + '0')) cnt++;
			}

			ans = Math.min(ans, cnt);
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 26948
import java.util.Scanner;

/**
 * B : ??????????????? / Lie with Mean Value
 */
public class Main {

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

		//?????????: 0 - m

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] ns = new int[n];

		if (n > 2) {
			for (int i = n / 2 + 1; i < n; i++) {
				ns[i] = m;
			}
		}
		
		System.out.print(ns[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + ns[i]);
		}
		System.out.println();
	}
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    
    for (int i = 1; i < N; i++)
    {
        vector<int> g;
        int ab = N - i;
       for (int j = 1; j * j <= ab; j++)
       {
           if (ab % j == 0)
           {
               g.push_back(j);
               if (j * j != ab)
               {
                   g.push_back(ab / j);
               }
               
           }
           
       }
      
           ans += g.size();
           
    }
    cout << ans << endl;
     
    return 0;

}


Measured memory_bytes: 3628
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;

  int answer = 0;
  for (int i = 1; i < N; ++i) {
    vector<bool> kind(26, false);
    for (int j = 0; j < i; ++j) {
      kind[S[j] - 'a'] = true;
    }
    int count = 0;
    for (int j = i; j < N; ++j) {
      if (kind[S[j] - 'a']) {
        count++;
        kind[S[j] - 'a'] = false;
      }
    }
    answer = max(answer, count);
  }
  cout << answer << endl;
  return 0;
}


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

ll n,a,b,c,d;
map<ll,ll> memo;

ll solve(ll N){
  if(N==0) return 0;
  if(N==1) return d;
  if(memo.count(N)) return memo[N];
  ll cal=1e18;
  ll l2=(N/2)*2;
  ll r2=((N+1)/2)*2;
  ll l3=(N/3)*3;
  ll r3=((N+2)/3)*3;
  ll l5=(N/5)*5;
  ll r5=((N+4)/5)*5;

  if(N<cal/d) cal=d*N;

  cal=min(cal,llabs(l2-N)*d+a+solve(l2/2));
  cal=min(cal,llabs(r2-N)*d+a+solve(r2/2));

  cal=min(cal,llabs(l3-N)*d+b+solve(l3/3));
  cal=min(cal,llabs(r3-N)*d+b+solve(r3/3));

  cal=min(cal,llabs(l5-N)*d+c+solve(l5/5));
  cal=min(cal,llabs(r5-N)*d+c+solve(r5/5));
  memo[N]=cal;
  return cal;
}

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;++i){
    memo.clear();
    cin >> n >> a >> b >> c >> d;
    cout << solve(n) << endl;
  }
  return 0;
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 1;
    int mi = p[0];
    repSE(i,1,n) {
        if (p[i] <= mi) {
            ans ++;
            mi = p[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4028