akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

H,W = II()
S = [list(map(str, input())) for _ in range(H)]

def bfs(c,s):
    X=[[-1]*W for i in range(H)]
    if c[s[0]][s[1]]=='#':
        return X
    X[s[0]][s[1]]=0
    q=[s]
    counter=1
    d = [(0,1),(0,-1),(1,0),(-1,0)]
    #f = float('inf')
    while q:
        q1=[]
        for i in q:
            for d0 in d:
                j = (i[0]+d0[0],i[1]+d0[1])
                if 0<=j[0]<=H-1 and 0<=j[1]<=W-1:
                    if c[j[0]][j[1]]=='.':
                        #if j[0]==g[0] and j[1]==g[1]:
                        #    f = min(f,counter)
                        if X[j[0]][j[1]]==-1:
                            X[j[0]][j[1]]=counter
                            q1.append(j)
        q=q1
        counter+=1
    return X

ans = 0
for si in range(H):
    for sj in range(W):
        d = bfs(S,(si,sj))
        #print(d)
        now = 0
        for i in range(len(d)):
            for j in range(len(d[0])):
                if d[i][j]>now:
                    now = d[i][j]
        if now==-1:
            continue
        if now>ans:
            ans = now
print(ans)

Measured memory_bytes: 48092
import sys
input = sys.stdin.readline

x1,y1,x2,y2 = list(map(int,input().split()))
x = x2 - x1
y = y2 - y1

x3 = x2 -y
y3 = y2 +x

x4 = x3 - x
y4 = y3 - y

print(x3,y3,x4,y4)


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

int INF = 100100100;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  vector<vector<int>> C(M);
  rep(i,M) {    
    cin >> A[i] >> B[i];
    vector<int> C_element(B[i]);
    rep(j,B[i]) {      
      cin >> C_element[j];
      C_element[j]--;
    }
    C[i] = C_element;
  }

  // keyの作成(値段と宝箱セットのpair)
  vector<pair<int,int>> key(M);
  rep(i,M){
    // 宝箱セットを2進数で表す
    int treasure_box_set = 0;
    rep(j, B[i]) treasure_box_set |= 1<<C[i][j];
    // keyに代入
    key[i] = make_pair(treasure_box_set,A[i]);
  }
  // dp
  vector<int> dp(1<<N, INF);
  dp[0] = 0;
  rep(i,1<<N) {
    rep(j,M){
      int treasure_box_set_plus_key = i | key[j].first;
      int cost = dp[i] + key[j].second;
      dp[treasure_box_set_plus_key] = min(cost,dp[treasure_box_set_plus_key]);
    }
  }
  int ans = dp[(1<<N) - 1];
  if(ans == INF){
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int s,w;
  cin>>s>>w;

  if(w>=s)
  cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;

    

  return 0;
}

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

using namespace std;

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

	int A,B;

	cin >> A >> B;

	if(A%2==1 && B%2==1)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
		
	return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
mapping = {'R' => 0, 'G' => 1, 'B' => 2}
s = gets.chomp.split(//).map{|c| mapping[c]}

left = Array.new(3){Array.new(n+2)}
right = Array.new(3){Array.new(n+2)}
3.times do |i|
  left[i][0] = 0
  left[i][-1] = 0
  right[i][0] = 0
  right[i][-1] = 0
end


1.upto(n) do |j|
  3.times do |i|
    if s[j-1] == i
      left[i][j] = left[i][j-1] + 1
    else
      left[i][j] = left[i][j-1]
    end
  end
end
n.downto(1) do |j|
  3.times do |i|
    if s[j-1] == i
      right[i][j] = right[i][j+1] + 1
    else
      right[i][j] = right[i][j+1]
    end
  end
end
# p left
# p right

ans = 0
1.upto(n-2) do |j|
  current = s[j]
  n1, n2 = nil
  if current == 0
    n1, n2 = 1, 2
  elsif current == 1
    n1, n2 = 0, 2
  else
    n1, n2 = 0, 1
  end
  # p [j, current, [left[n1][j-1+1], right[n2][j+1+1]], [left[n2][j-1+1], right[n1][j+1+1]]]
  ans += left[n1][j-1+1] * right[n2][j+1+1]
  ans += left[n2][j-1+1] * right[n1][j+1+1]
  [j, n - j - 1].min.times do |ik|
    l, r = s[j - ik - 1], s[j + ik + 1]
    ans -= 1 if (l == n1 && r == n2) || (l == n2 && r == n1)
  end
end
puts ans


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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long d[31];
  d[1]=1;d[2]=2;d[3]=4;
  REP(i,4,31)d[i]=d[i-1]+d[i-2]+d[i-3];
  int n;
  while(cin>>n,n){
  if(d[n]%3650==0)cout<<d[n]/3650<<endl;
  else cout<<d[n]/3650+1<<endl;
  }
  return 0;
}




Measured memory_bytes: 3016
#include<stdio.h>

int main(void) {
	int n, number, k = 1, i, j;
	int cards[4][14];
	char mark, m;

	for (i = 0; i<4; i++) {
		for (j = 1; j<14; j++) {
			cards[i][j] = 0;
		}

	}


	scanf("%d", &n);

	while (k<=n) {
		scanf(" %c %d", &mark, &number);


		if (mark == 'S') {
			cards[0][number] = 1;
		}

		else if (mark == 'H') {
			cards[1][number] = 1;
		}

		else if (mark == 'C') {
			cards[2][number] = 1;
		}

		else if (mark == 'D') {
			cards[3][number] = 1;
		}

		k++;


	}


	for (i = 0; i < 4; i++) {
		for (j = 1; j < 14; j++) {
			if (cards[i][j] == 0 && i == 0) {
				m = 'S';
				printf("%c %d\n", m, j);
			}
			if (cards[i][j] == 0 && i == 1) {
				m = 'H';
				printf("%c %d\n", m, j);
			}
			if (cards[i][j] == 0 && i == 2) {
				m = 'C';
				printf("%c %d\n", m, j);
			}

			if (cards[i][j] == 0 && i == 3) {
				m = 'D';
				printf("%c %d\n", m, j);
			}

		}
	}
		return 0;
	}

	



Measured memory_bytes: 2604
#include <iostream>
using namespace std;
int main(){
    int N, L;
    cin >> N >> L;
    string s[N+10];
    string tmp;
    for(int i=0; i<N; i++){
        cin >> s[i];
    }
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(s[i] > s[j]){
                tmp = s[i];
                s[i] = s[j];
                s[j] = tmp;
            }
        }
    }
    for(int i=0; i<N; i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program {
    static void Main() {
        var n = int.Parse(Console.ReadLine());

        for (var i = 0; i < n; i++) {
            var l = Console.ReadLine().Split();
            var r = int.Parse(l[0]);
            var t = int.Parse(l[1]);

            var x = r / 100 + (t / 30) * 5;
            Console.Write(x);

            if (r % 100 != 0) {
                Console.Write(" " + (x + 1));
            }

            if (t % 30 != 0) {
                Console.Write(" " + (x + 5));

                if (r % 100 != 0) {
                    Console.Write(" " + (x + 6));
                }
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9176
#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll N,M,K;
    cin >> N >> M >> K;
    rep(n,N+1){
        rep(m,M+1){
            ll ans = N*m+M*n-2*m*n;
            if(ans==K){
                P("Yes");
                return 0;
            }
        }
    }
    P("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
	

int main(){
	char s[100000];
	char buf;
	int i=1,ans=0;
	scanf("%s",s);
	for(i=1;i<=100000;i++){
	    if(s[i]!='W' && s[i]!='B'){
	        break;
	    }
	    if( (s[i-1]=='W'&&s[i]=='B') || (s[i-1]=='B'&&s[i]=='W')) ans++;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
int n;
int main() 
{
	rd(n);
	for (int i = 0; ; i++)
		for (int j = -1280; j <= 1280; j++)
			if (i * i * i * i * i - j * j * j * j * j == n)
				return !printf("%d %d\n", i, j);
    return 0;
}

Measured memory_bytes: 1604
#include<stdio.h>

int main()
{
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if (op=='?') {
      break;
    }
    switch (op) {
      case '+':
        printf("%d\n", a+b);
        break;
      case '-':
        printf("%d\n", a-b);
        break;
      case '*':
        printf("%d\n", a*b);
        break;
      case '/':
        printf("%d\n", a/b);
        break;
      default :
        break;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define Maxn 1000006
using namespace std;
char a[Maxn],b[Maxn],c[Maxn];
int n,ans;
 
int tot1,tot2,pc[Maxn],pcc[Maxn];
int main()
{
//	freopen("1.txt","r",stdin);
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=strlen(a+1);i++)
	{
		if(a[i]!='x') 
		{
			b[++tot1]=a[i];
		}
		else
		{
			pc[tot1]++;
		}
	}
	if(tot1==0)
	{
		cout<<0;
		return 0;
	}
	for(int i=1;i<=tot1;i++)
	{
		if(b[i]!=b[tot1-i+1])
		{
			printf("-1\n");
			return 0;
		}
	}
	for(int i=0;i<=tot1;i++)
	{
		pcc[i]=pc[tot1-i];
	}
	for(int i=0;i<=tot1;i++)
	{
		ans+=abs(pc[i]-pcc[i]);
	}
	cout<<(ans/2);
//	for(int i=1;i<=strlen(a+1);i++)
//	{
//		c[i]=c[strlen(a+1)-i+1];
//	}
//	pc=1;pcc=1;
//	while(pc<=n&&pcc<=n)
//	{
//		while(a[pc]!=b[pcc])
//		while(a[pc]!=b[pcc])
//		{
//			
//		}
//	}
} 

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    bool ok=true;
    while(n--)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3==0 || a%5==0)
                    continue;
            else
                    ok=false;
        }
    }
    if(ok==true)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<ll> a(n+1);
	for(int i=0; i<n+1; i++) cin >> a[i];

	vector<ll> v(n+2);
	v[0] = 1;
	const ll INF = 1e18;
	for(int i=0; i<=n; i++){
		v[i+1] = min(INF, 2*(v[i] - a[i]));
		if(v[i+1]<0) {
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = a[n];
	ll m = a[n];
	for(int i=n-1; i>=0; i--){
		m = min(m + a[i], v[i]);
		ans += m;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> oisisa(N);
    for(int i=0; i< N; i++) {
        int d; cin >> d;
        oisisa[i] = d;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            ans += oisisa[i] * oisisa[j];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;

const int N = 3e5 + 10, M = 1e5 + 10;
int n, m;
int l[N], r[N], idx[N], len[N];
int a[M];

bool cmp(int x, int y) {
    return len[x] < len[y];
}

void add(int x, int v) {
    for (; x <= m + 1; x += x & -x) a[x] += v;
}

int query(int x) {
    int ret = 0;
    for (; x; x -= x &-x) ret += a[x];
    return ret;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", l + i, r + i); 
        len[i] = r[i] - l[i] + 1;
        idx[i] = i;
    }
    sort(idx, idx + n, cmp);
    int j = 0;
    for (int i = 1; i <= m; i++) {
        while (j < n && len[idx[j]] < i) {
            add(l[idx[j]], 1);
            add(r[idx[j]]+1, -1);
            j++;
        }
        int ans = 0;
        for (int k = i; k <= m; k += i) ans += query(k);
        printf("%d\n", ans + n - j);
    }
    return 0;
}


Measured memory_bytes: 6016
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main() {
    val n = readInt()

    var sum = 0
    for (i in 1..n) {
        sum += i
        if (sum < n) continue

        val diff = sum - n
        val ans = StringBuilder()
        for (j in 1..i) {
            if (j == diff) continue
            ans.append("$j\n")
        }
        print(ans.toString())
        return
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 35264
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld", &N);
	while(N) {
		if(N % 10 == 7) {
			printf("Yes\n");
			quit;
		}
		N /= 10;
	}	
	printf("No\n");
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3772
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    z=s.count("0")
    o=s.count("1")
    print(min(z,o)*2)

main()


Measured memory_bytes: 39024
import math

while True:
    n = int(input())
    if n == 0:
        break
    x = 0
    ans = 0
    s = list(map(int, input().split()))
    for i in s:
        x += i
    x = x / n
    for i in s:
        ans += (i - x) ** 2
    ans = ans / n
    ans = math.sqrt(ans)
    print(ans)



Measured memory_bytes: 5692
#include<iostream>

using namespace std;

const int MAX = 2 * 100000;
const int MOD = 1000000007;

typedef long long ll;

ll factorial[MAX], factorialInvers[MAX], invers[MAX];

void ComInit(){
    factorial[0] = factorial[1] = 1;
    factorialInvers[0] = factorialInvers[1] = 1;
    invers[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        factorial[i] = factorial[i - 1] * i % MOD;
        invers[i] = MOD - (MOD / i) * invers[MOD % i] % MOD;
        factorialInvers[i] = factorialInvers[i - 1] * invers[i] % MOD;
    }
}

ll Combination(ll n,ll k)
{
    if(n<k)
        return 0;
    if(n<0||k<0)
        return 0;
    return (factorial[n] * factorialInvers[k] % MOD) * factorialInvers[n - k] % MOD;
}

int main (){
    ComInit();
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
    {
        ll ans = Combination(n - k + 1, i) * Combination(k - 1, i - 1) % MOD;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
n = int(input())
s = input()
if n%2 == 0:
  flag = True
  for i in range(n//2):
    if s[i] != s[n//2+i]:
      flag = False
      
  if flag:
    print('Yes')
  else:
    print('No')
    
else:
  print('No')

Measured memory_bytes: 2940
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline


def main():
    k = int(input())
    s = input()
    if len(s) <= k:
        print(s)
    else:
        print("{}...".format(s[:k]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27092
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string s; cin >> s;
    int n=26, done[n]; REP(i,n) done[i]=1;
    REP(i,s.size()) done[s[i]-'a'] = 0;
    string ans = "None";
    REP(i,n){
        if(done[i]){
            ans = i+'a';
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] diff = new long[n];

        for (int i = 0; i < n; i++) {
            diff[i] = sc.nextLong() - i - 1;
        }

        Arrays.sort(diff);
        long median = diff[n/2];

        long ans = 0;
        for (long i : diff) {
            ans += Math.abs(i - median);
        }

        System.out.println(ans);
    }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size() / 2; i++) {
        if(S[i] != S[S.size() - 1 - i]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

//returns 1 instead of true
//also 0 - false
inline int isPrime(const int& n){
    if(n == 2){
        return 1;
    }

    if(!(n & 1)){
        return 0;
    }

    float root = std::sqrt(n);
    for(int div = 3; div <= root; div += 2){
        if(!(n % div)){
            return 0;
        }
    }
    return 1;
}

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

    std::vector<int> vec(n);
    for(auto& e : vec){
        std::cin >> e;
    }

    int numOfPrime = 0;
    for(const auto& e : vec){
        numOfPrime += isPrime(e);
    }

    std::cout << numOfPrime << '\n';
}


Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	var re int64

	for index := int64(1); index < n; index++ {
		re += index
	}

	fmt.Println(re)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  char left[] = {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
  string s;
  while(1){
    cin >> s;
    if(s[0]=='#') break;
    int count = 0;
    int flag=-1;//left 0 right 1
    int mflag = -1;
    rep(i,s.size()){
      flag = -1;
      rep(j,15){
        if(left[j]==s[i]){
          flag = 0;
        }
      }
      if(flag==-1) flag = 1;
      if(i==0){
        mflag = flag;
      }else{
        if(mflag!=flag) count++;
      }
      mflag = flag;
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
const int Mod = 1e9+7;
int a[2002];
int l[2002];
int32_t main(){

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int n,k;
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    int inv = 0;
    for(int i = 0; i < n; i++){
        for(int j = i +1; j < n; j++){
            if(a[i]>a[j]) inv++,l[i]++;
            else if(a[i]<a[j]) l[j]++;
        }
    }
    int ans = inv*k%Mod;
    for(int i = 0; i<n; i++){
        int x = l[i]*(k*(k-1)/2%Mod)%Mod;
        ans = (ans+x)%Mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    private static P[,] p;
    struct bw
    {
        public long w;
        public long b;
    }
    struct P
    {
        public int h;
        public int w;
        public bool isBlack;
        public bool isSearch;
        public P(int h,int w,bool isBlack)
        {
            this.h = h;
            this.w = w;
            this.isBlack = isBlack;
            isSearch = false;
        }
    }
    static void Main(string[] args)
    {
        var hw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var s = new string[hw[0]];
        for (var i = 0; i < hw[0]; i++)
            s[i] = ReadLine();
        p = new P[hw[0], hw[1]];
        var res = 0L;
        for(var i = 0; i < hw[0]; i++)
        {
            for(var j = 0; j < hw[1]; j++)
            {
                p[i, j] = new P(i, j, s[i][j] == '#');
            }
        }
        for(var i = 0; i < hw[0]; i++)
        {
            for(var j = 0; j < hw[1]; j++)
            {
                if (!p[i, j].isSearch)
                {
                    var bw = new bw();
                    Get(i, j, hw[0], hw[1],ref bw);
                    res += bw.b * bw.w;
                }
            }
        }
        WriteLine(res);
    }

    private static void Get(int i,int j,int h,int w,ref bw bw)
    {
        p[i, j].isSearch = true;
        if (p[i, j].isBlack) bw.b++;
        else bw.w++;
        if (i != 0 && !p[i-1,j].isSearch && (p[i - 1, j].isBlack ^ p[i,j].isBlack))
        {
            Get( i - 1, j, h, w,ref bw);
        }
        if (j != 0 && !p[i,j-1].isSearch&& (p[i, j - 1].isBlack ^ p[i,j].isBlack))
        {
            Get(i, j - 1,h,w,ref bw);
        }
        if (i != h - 1 && !p[i+1,j].isSearch && (p[i + 1, j].isBlack ^ p[i,j].isBlack))
        {
            Get( i + 1, j,h,w,ref bw);
        }
        if (j != w - 1 && !p[i,j+1].isSearch && (p[i, j + 1].isBlack ^ p[i,j].isBlack))
        {
            Get( i, j + 1,h,w,ref bw);
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int A, B;
   cin >> A >> B;
   if (A == B) cout << "Draw" << endl;
   else if (A == 1) cout << "Alice" << endl;
   else if (B == 1) cout << "Bob" << endl;
   else if (A > B) cout << "Alice" << endl;
   else cout << "Bob" << endl;
 }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
	return(a/ gcd(a, b)*b);
}
int main() {
	int n;
	cin >> n;
	vector<ll>t(n);
	for (int i = 0; i < n; ++i)cin >> t[i];
	for (int j = 0; j < n - 1; ++j) {
		ll base = t[0];
		for (int i = 1; i < t.size(); ++i) {
			t[i - 1] = lcm(base, t[i]);
		}
	}
	cout << t[0] << endl;
	return 0;
}

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

long long cnt=0;
const int MAX=200000;
int L[MAX/2+2], R[MAX/2+2];

inline void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++){
        L[i] = A[left+i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid+i];
    }
    L[n1] = 2000000000;
    R[n2] = 2000000000;

    int i=0, j=0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
            cnt += n1-i;
        }
    }
}

inline void merge_sort(int A[], int left, int right){
    if (left+1 < right){
        int mid = (left+right)/2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}




int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int A[n];
    for(int i=0; i<n; i++){
        cin >> A[i];
    }

    merge_sort(A, 0, n);
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 2760
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
dp = [[0] * (k+1) for i in range(n+1)]
dp[0][0] = 1
for j in range(1,n+1):
  rui = [0] * (k+2)
  for i in range(k+1):
    rui[i+1] += rui[i] + dp[j-1][i]
  for i in range(k+1):
    if i - a[j-1] >= 0:
      dp[j][i] = (rui[i+1] - rui[i-a[j-1]])%mod
    else:
      dp[j][i] = rui[i+1]%mod
print(dp[n][k]%mod)

Measured memory_bytes: 135768
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  long long N=S.size();
  long long zero_even=0,zero_odd=0;
  for(int i=0;i<N;i++){
    if(i%2==0 && S.at(i)=='0'){
      zero_even++;
    }  
    else if(i%2==1 && S.at(i)=='0'){
      zero_odd++;
    }  
  }
  long long a_1,a_2;
  a_1=N/2+N%2-zero_even+zero_odd;
  a_2=zero_even+N/2-zero_odd;
  cout<<min(a_1,a_2)<<endl;
}


Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    vector<ll>vec(5);
    for(int i = 0; i < 5; i++)cin >> vec[i];
    ll mn = *min_element(vec.begin(), vec.end());
    cout << (N + mn - 1) / mn + 4 << endl;

    return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    double fa=a,fb=b;
    cout<<fixed;
    cout<<setprecision(8)<<(a/b)<<" "<<(a%b)<<" "<<(fa/fb);
    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  int A, B, K;
  cin >> A >> B >> K;
  if(B- A+1 <= K*2){
    for(int i=A;i<=B;i++){
      cout << i << endl;
    }
  }
  else{
    for(int i=A;i<A+K;i++){
      cout << i << endl;
    }
    for(int i=B-K+1;i<=B;i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
-- A Point in a Triangle
main = getContents >>= putStr . solve
--
solve :: String -> String
solve = unlines . map (isIn . toTuples . map read . words) . lines


cross :: (Float, Float) -> (Float, Float) -> Float
cross a b = (fst a) * (snd b) - (snd a) * (fst b)

toTuples :: [Float] -> [(Float, Float)]
toTuples [] = []
toTuples (x1:x2:xs) = (x1,x2) : toTuples xs

sub :: (Float, Float) -> (Float, Float) -> (Float, Float)
sub a b = (fst a - fst b, snd a - snd b)

-- case: counter clock wise
--         C(x3,y3)
--        / \
--       /   \
--      /  P  \
--     /(xp,yp)\
--    A---------B
-- (x1,y1)   (x2,y2)
--
-- case: clock wise
--         B(x2,y2)
--        / \
--       /   \
--      /  P  \
--     /(xp,yp)\
--    A---------C
-- (x1,y1)   (x3,y3)
--
-- AB = b - a = (abx, aby) = (x2-x1, y2-y1)
-- BC = c - b = (bcx, bcy) = (x3-x2, y3-y2)
-- CA = a - c = (cax, cay) = (x1-x3, y1-y3)
-- BP = p - b = (bpx, bpy) = (xp-x2, yp-y2)
-- CP = p - c = (cpx, cpy) = (xp-x3, yp-y3)
-- AP = p - a = (apx, apy) = (xp-x1, yp-y1)
isIn :: [(Float, Float)] -> String
isIn [a,b,c,p]
  | counterClockWise || clockWise = "YES"
  | otherwise = "NO"
    where
      counterClockWise= cross (b `sub` a) (p `sub` b) > 0 && cross (c `sub` b) (p `sub` c) > 0 && cross (a `sub` c) (p `sub` a) > 0
      clockWise = cross (b `sub` a) (p `sub` b) < 0 && cross (c `sub` b) (p `sub` c) < 0 && cross (a `sub` c) (p `sub` a) < 0

Measured memory_bytes: 4464
fun main(args:Array<String>) {
  val (w, a, b) = readLine()!!.split(" ").map { x -> x.toInt() }
  val (a1, a2) = Pair(a - w, a + w)
  if( a1 <= b && b <+ a2 ) {
    println(0)
  }else {
    println( listOf(a1, a2).map { x ->
      b - x
    }.map { x ->
      Math.abs(x)
    }.min() )
  }
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double a,t;
    int g,b;
    cin >> a >> b >> t;
    g=(t+0.5)/a;
    cout << g*b;
}



Measured memory_bytes: 256
fn main() {
    let cin = std::io::stdin();
    let mut sc = Scanner { stdin: cin.lock() };

    let w: u32 = sc.read();
    let h: u32 = sc.read();
    let x: u32 = sc.read();
    let y: u32 = sc.read();

    let way = if x * 2 == w && y * 2 == h { '1' } else { '0' };
    println!("{} {}", (w as f64 * h as f64) / 2.0, way);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let token = self
            .stdin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("token parse error")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();




		System.out.println(A>8||B>8?":(":"Yay!");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23124
#include "bits/stdc++.h"

using namespace std;

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}
long long gcd(long long num1, long long num2) {
	return num2 == 0 ? num1 : gcd(num2, num1 % num2);
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Registration(void) {

	string S, T; cin >> S >> T;

	if (S.size() + 1 == T.size() && S == T.substr(0, S.size())) cout << "Yes" << endl;
	else														cout << "No" << endl;
	return;
}

int main(void) {

	cout << fixed << setprecision(15);
	
	A_Registration();
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  vector<vector<ll>> dp(h, vector<ll>(w));
  vector<string> m(h);
  for(int i = 0; i < h; i++) cin >> m[i];
  for(int i = 0; i < h; i++) {
    if(m[i][0] == '#') break;
    dp[i][0] = 1;
  }
  for(int i = 0; i < w; i++) {
    if(m[0][i] == '#') break;
    dp[0][i] = 1;
  }
  for(int i = 1; i < h; i++) {
    for(int j = 1; j < w; j++) {
      if(m[i][j] == '.') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
    }
  }
  printf("%lld\n", dp[h - 1][w - 1]);
}

Measured memory_bytes: 9088
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

for(int i =1;;i++){
    int x=sc.nextInt();
    if(x>0){
    System.out.println("Case "+i+": "+x);
    }
    else
    break;
    
}
    }}


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

using namespace std;

int INF=1e9;

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

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

    int n,k;
    cin>>n>>k;

    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];

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

    int G=gcd(a[0],a[1]);

    for(int i=2;i<n;i++)G=gcd(G,a[i]);

    if(a[n-1]>=k && k%G==0)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 640
N=gets.chomp.to_i
H=gets.chomp.split.map(&:to_i)


diff_ary = (H.size-1).times.map{|i|
  H[i]-H[i+1]
}

max_count = 0
tmp_count = 0
diff_ary.each_with_index do |attr,idx|
  if attr>=0
    tmp_count += 1
    if idx == diff_ary.size-1
      max_count = tmp_count if max_count < tmp_count
    end
  else
    max_count = tmp_count if max_count < tmp_count
    tmp_count = 0
  end
end


puts max_count

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

typedef pair<int, int> PII;

const int MAX_N = 110;
const int MAX_H = 25;
const int INF = 1e9;

struct edge{
  int to, cost, hour, r;
  edge(int to, int cost, int hour, int r):
    to(to), cost(cost), hour(hour), r(r){}
};

struct State{
  int v, hour, cost;
  State(int v, int hour, int cost):
    v(v), hour(hour), cost(cost){}
};

int N, M, H, K;
vector<edge> G[MAX_N];
vector<PII> V;
int S, T, P;
int money[(1<<8)];
int dp[MAX_H][MAX_N];
int ans;

void init(){
  for(int i = 0 ; i < MAX_N ; i++) G[i].clear();
  V.clear();
  fill(money, money+(1<<8), INF);
}

int solve(int bit){
  for(int i = 0 ; i < MAX_H ; i++)
    for(int j = 0 ; j < MAX_N ; j++) dp[i][j] = INF;

  queue<State> que;
  que.push(State(S, 0, 0));  
  
  dp[0][S] = 0;
  
  int res = INF;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    
    if(ans < q.cost) continue;
    if(res < q.cost) continue;
    
    if(q.v == T){
      res = min(res, q.cost);
    }
    
    int v = q.v;
    for(int i = 0 ; i < (int)G[v].size() ; i++){

      int r = G[v][i].r;
      int nexv = G[v][i].to;
      int nexh = q.hour + G[v][i].hour;      
      int nexc;
      
      nexc = q.cost + G[v][i].cost;
      if((bit>>r) & 1) nexc = q.cost;
      
      if(nexh > H) continue;
      
      if(dp[nexh][nexv] > nexc){     
	dp[nexh][nexv] = nexc;
	
	que.push(State(nexv, nexh, nexc));
      }
    }    
  }
  return res;
}

void rec(int bit, int cost){
  if(money[bit] <= cost) return;
  money[bit] = cost;
  for(int i = 0 ; i < (int)V.size() ; i++){
    int t = bit | V[i].first;
    if(t == bit) continue;
    rec(t, cost + V[i].second);
  }
}

int main(){
  while(cin >> N >> M >> H >> K, N|M|H|K){
    init();
    
    int from, to, cost, hour, r;
    for(int i = 0 ; i < M ; i++){
      cin >> from >> to >> cost >> hour >> r;
      from--, to--, r--;
      G[from].push_back(edge(to, cost, hour, r));
      G[to].push_back(edge(from, cost, hour, r));
    }
    
    cin >> S >> T;
    S--, T--;
    cin >> P;
    
    for(int i = 0 ; i < P ; i++){
      int l, d;
      cin >> l >> d;
      int k;
      int bit = 0;
      for(int j = 0 ; j < l ; j++){
	cin >> k;
	k--;
	bit += (1<<k);
      }      
      V.push_back(PII(bit, d));
    }
    
    rec(0, 0);
    
    ans = INF;
    for(int i = 0 ; i < (1<<K) ; i++){
      ans = min(ans, solve(i) + money[i]);
    }
    
    cout << (ans == INF ? -1 : ans) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <string>
#include <deque>
using namespace std;
string S; int Q;
int main() {
  cin >> S >> Q;
  deque<char> dq(S.begin(), S.end());
  int T, F; char C; bool l2r = true;
  for(int i = 0; i < Q; ++i) {
    cin >> T;
    if(T == 1) {
      l2r = !l2r;
    } else {
      cin >> F >> C;
      if((l2r && F == 1) || (!l2r && F == 2)) dq.push_front(C);
      else dq.push_back(C);
    }
  }
  if(l2r) {
    while(!dq.empty()) printf("%c", dq.front()), dq.pop_front();
  } else {
    while(!dq.empty()) printf("%c", dq.back()), dq.pop_back();
  }
}

Measured memory_bytes: 896
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

type Command struct {
	inst string
	val  int
}

type LinkedList struct {
	head int
	tail int
	list []int
}

func main() {
	n, _ := strconv.Atoi(nextLine())

	list := LinkedList{head: -1, tail: -1, list: make([]int, 0)}

	for i := 0; i < n; i++ {
		command := nextLine()

		c := parseCommand(command)

		switch c.inst {
		case "insert":
			insert(c.val, &list)
		case "delete":
			delete(c.val, &list)
		case "deleteFirst":
			deleteFirst(&list)
		case "deleteLast":
			deleteLast(&list)
		}
	}

	ans := make([]string, len(list.list))
	for idx := len(list.list) - 1; idx >= 0; idx-- {
		tmp := list.list[idx]

		ansIdx := len(list.list) - 1 - idx
		ans[ansIdx] = strconv.Itoa(tmp)
	}

	fmt.Println(strings.Join(ans, " "))
}

func parseCommand(command string) Command {
	c := strings.Split(command, " ")

	if len(c) == 2 {
		v, _ := strconv.Atoi(c[1])

		return Command{c[0], v}
	}
	return Command{c[0], -1}
}

func insert(n int, l *LinkedList) {
	l.list = append(l.list, n)
	l.head = n

	if l.tail == -1 {
		l.tail = n
	}
}

func delete(n int, l *LinkedList) {
	for idx := len(l.list) - 1; idx >= 0; idx-- {
		v := l.list[idx]

		if n == v {

			if idx == 0 {
				l.head = n
			} else if idx == len(l.list)-1 {
				l.tail = n
			}

			l.list = append(l.list[:idx], l.list[idx+1:]...)
			return
		}
	}
}

func deleteFirst(l *LinkedList) {

	if len(l.list) == 1 {
		l.tail = l.list[0]
		l.list = l.list[1:]
		return
	}
	l.head = l.list[len(l.list)-2]
	l.list = l.list[:len(l.list)-1]
}

func deleteLast(l *LinkedList) {

	if len(l.list) == 1 {
		l.tail = l.list[0]
		l.list = l.list[1:]
		return
	}

	l.tail = l.list[1]
	l.list = l.list[1:]
}



Measured memory_bytes: 33408
N=int(input())
f=[0]*(10**4+1)
for x in range(1,10**2):
    for y in range(1,10**2):
        for z in range(1,10**2):
            n=x**2+y**2+z**2+x*y+y*z+z*x
            if n<=10**4:
                f[n]+=1
for i in range(1,N+1):
    print(f[i])

Measured memory_bytes: 9424
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>
#include <thread>


#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;

    int iMax = 0;
    int iMin = 1000;

    REP(i,N)
    {
        int a;
        cin >> a;

        iMax = max(iMax, a);
        iMin = min(iMin, a);
    }
    int res = iMax - iMin;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ans=0;
    for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++)
    for(int k=1; k<=n; k++) {
        ans+=gcd(gcd(i,j),k);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

string nchar(char c, int n){
    string s = "";
    rep(i, n){
        s.push_back(c);
    }

    return s;
}

vector<string> s(2100);
vector<vector<ll>> a(2100, vector<ll>(2100, 0));
int main(){

    int h, w;
    cin >> h >> w;
    rep(i, h){
        cin >> s[i];
        s[i].push_back('#');
    }
    s.push_back(nchar('#', w));
    ++h; ++w;
    rep(i, h){
        int cnt = 0;
        int st = 0;
        rep(j, w){
            if(cnt == 0 and s[i][j] == '.') st = j;
            // eee(st);
            if(s[i][j] == '#' or j == w-1){
                for(int k = st; k < st+cnt; ++k){
                    a[i][k] = cnt;
                }
                st = j+1;
                cnt = 0;
            }
            else ++cnt;
        }
    }
    rep(i, w){
        int cnt = 0;
        int st = 0;
        rep(j, h){
            if(cnt == 0 and s[j][i] == '.') st = j;
            if(s[j][i] == '#' or j == h-1){
                for(int k = st; k < st+cnt; ++k){
                    a[k][i] += cnt;
                    a[k][i]--;
                }
                st = j+1;
                cnt = 0;
            }
            else ++cnt;
        }
    }
    // rep(i, h){
    //     rep(j, w){
    //         cerr << a[i][j] << sp;
    //     }
    //     cerr << endl;
    // }

    ll mx = 0LL;
    rep(i, h-1){
        rep(j, w-1){
            mx = max(mx, a[i][j]);
        }
    }


    ppp(mx);



    return 0;
}


Measured memory_bytes: 42496