akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vll P(N*N, 0);
    rep(i, N*N) cin >> P[i];

    vll d(N*N, 0), s(N*N, 0);
    rep(y, N) rep(x, N) d[y*N+x] = min({x, N-x-1, y, N-y-1});
    vvll dirs = vvll{{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

    ll total = 0;
    rep(i, N*N){
        ll p = P[i] - 1;
        s[p] = 1;
        queue<ll> q;
        q.push(p);
        total += d[p];
        while(!q.empty()){
            ll xy = q.front();
            ll x = xy%N, y = xy/N;
            q.pop();
            for(auto &dir : dirs){
                ll nx = x+dir[0], ny = y+dir[1];
                ll nxy = ny*N + nx;
                if(nx<0 || nx>=N || ny<0 || ny>=N) continue;
                if(d[nxy]>d[xy]+1 || (s[xy] && d[nxy]>d[xy])){
                    --d[nxy];
                    q.push(nxy);
                }
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    int n; cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];

    sort(all(v));
    double ans=v[0];
    for(int i=1; i<n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n;cin>>n;
    map<ll,ll> pp;
    ll sum=0;
    rep(i,n){
        int a;cin>>a;
        pp[a]++;
        sum+=a;
    }
    int q;cin>>q;
    rep(i,q){
        int b,c;cin>>b>>c;
        if(pp.count(b)){
            int ss=pp[b];
            pp.erase(b);
            pp[c]+=ss;
            sum+=ss*(c-b);
        }
        cout<<sum<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 7584
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int n;

struct card{
  char suit;
  char num;
};

void bubble_sort(card c1[]){

  for( int i = 0 ; i < n ; i++ ){
    for( int j = n - 1 ; j > i ; j-- ){
      if( c1[j - 1].num > c1[j].num ){
	card t = c1[j - 1];
	c1[j - 1] = c1[j];
	c1[j] = t;
      }
    }
  }
}

void selection_sort(card c2[]){

  for( int i = 0 ; i < n ; i++ ){
    int mini = i;
    for( int j = i ; j < n ; j++ ){
      if( c2[j].num < c2[mini].num ) mini = j;
    }
    card t = c2[i];
    c2[i] = c2[mini];
    c2[mini] = t;
  }
}

void output(card a[]){

  for( int i = 0 ; i < n ; i++ ){
    if(i) cout << " ";
    cout << a[i].suit << a[i].num;
  }
  cout << endl;

}

bool isStable(card c1[], card c2[]){

  for( int i = 0 ; i < n ; i++ ){
    if( c1[i].suit != c2[i].suit ) return false;
  }
  return true;
}

int main(void){

  struct card c1[100],c2[100];
 
  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    cin >> c1[i].suit >> c1[i].num;
    c2[i] = c1[i];
  }

  bubble_sort(c1);
  output(c1);
  cout << "Stable" << endl;

  selection_sort(c2);
  output(c2);
  bool f = isStable(c1,c2);
  if(f) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  return 0;
}

Measured memory_bytes: 1160
H,W = [int(i) for i in input().split()]
li = ['0']*H
al = [chr(ord('A') + i) for i in range(26)]
for i in range(H):
    li[i] = input().split()
for i in range(H):
    for j in range(W):
        if li[i][j] == 'snuke':
            k = str(i+1)
            r = al[j]
            print(r+k)
            exit()

Measured memory_bytes: 3064
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, tmp;
    int mx = 0, mn = 1e9;

    cin >> n;
    rep(i, n){
        cin >> tmp;
        mn = min(mn, tmp);
        mx = max(mx, tmp);
    }

    cout << abs(mx - mn) << endl;

}



Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0

    const A = {}
    for (let i = 0; i < N; i++) {
        if (A[lines[i + 1]]) {
            A[lines[i + 1]] = 0
        } else {
            A[lines[i + 1]] = 1
        }
    }

    let count = 0
    for (let i in A) {
        count += A[i]
    }

    console.log(count)

})(input)


Measured memory_bytes: 57604
def main():
    N, A, B = map(int, input().split())
    S = input()

    passed = 0
    passed_b = 0
    for i in range(len(S)):
        if S[i] == 'c':
            print('No')
            continue
        if passed >= A + B:
            print('No')
            continue
        if S[i] == 'b':
            if passed_b < B:
                print('Yes')
                passed += 1
                passed_b += 1
            else:
                print('No')
        else:
            print('Yes')
            passed += 1


if __name__ == '__main__':
    main()


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

int main() {
    string str;
    cin>>str;
    for(int i=0;i<str.length();i++){
        int k=i+1;
        if(k%2==1){
            if(str[i]=='R' || str[i]=='U' || str[i]=='D'){
                
            }
            else{
                cout<<"No";
                return 0;
            }
        }
        else{
            if(str[i]=='L' || str[i]=='U' || str[i]=='D'){
                
            }
            else{
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

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

using namespace std;
typedef long long Int;

vector<Int> factorize(Int M)
{
  vector<Int> ret;
  
  for (Int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      ret.push_back(i);
      if (i * i != M) ret.push_back(M / i);
    }
  }
  return ret;
}

int main()
{
  Int N;
  
  scanf("%lld", &N);
  
  set<Int> ans;
  
  vector<Int> cand1 = factorize(N - 1);
  for (auto n : cand1) {
    if (n != 1) ans.insert(n);
  }
  
  vector<Int> cand2 = factorize(N);
  for (auto n : cand2) {
    if (n == 1) continue;
    Int tmp = N;
    while (tmp % n == 0) tmp /= n;
    if (tmp % n == 1) ans.insert(n);
  }
  
  printf("%d\n", ans.size());
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
 import java.math.BigInteger;
public class Main
{
	static int ans[];
	public static  void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		// String h[]=sc.nextLine().split(" ");
		String a=sc.nextLine();
		String b=sc.nextLine();
		String ans="No";
		if(a.length()+1==b.length())
		{
			ans=a.equals(b.substring(0,b.length()-1))?"Yes":"No";
		}
		System.out.println(ans);
		
	}
	static long get3(double n, int steps)
	{
		if(n<1){return Integer.MAX_VALUE;}
		if(n==1){return steps;}

		System.out.println(n);
		return get3(n/2.0-1,steps+1);
	}
	static String get(long a, long b)
	{long y=1;
		while(true)
		{

			long z=y-a;
			long q=get2(y,z);
			// System
			if(q==b){return y+" "+z;}
			else if(q>b){return "-1";}
			y+=1;
		}
		// return "-1";
	}
	static long get2(long y, long z)
	{
		return (long)(Math.pow(y,4)+Math.pow(y,3)*z+Math.pow(y,2)*Math.pow(z,2)+y*Math.pow(z,3)+Math.pow(z,4));
	}
	static void get(ArrayList<ArrayList<Integer>>arr, int i , int p,int val[], int arr1[], int len)
	{
		for(int j=0;j<arr.get(i).size();j++)
		{
			if(ans[arr.get(i).get(j)]==0 && arr.get(i).get(j)!=p){
			if(val[arr.get(i).get(j)]>arr1[len-1])
			{
				arr1[len]=val[arr.get(i).get(j)];
				ans[arr.get(i).get(j)]=len+1;
				get(arr,arr.get(i).get(j),i,val,arr1,len+1);
				
			}
			else
			{
				int index=bin(arr1, val[arr.get(i).get(j)], len-1);
				ans[arr.get(i).get(j)]=len;
				// int g=arr1[index];
				arr1[index]=val[arr.get(i).get(j)];
				get(arr,arr.get(i).get(j),i,val,arr1,len);
				// arr1[index]=g;
			}}

		}
	}
	static int bin(int arr[], int val, int len)
	{
		if(arr[0]>=val){return 0;}
		int l=0;
		int r=len;
		while (r - l > 1) { 
            int m = l + (r - l) / 2; 
            if (arr[m] >= val) 
                r = m; 
            else
                l = m; 
        } 
  
        return r; 
		// return l;
	}
	
	

}
class Pair
{
	int a;
	int b;
	int c;
	int d;
	Pair(int e,int f, int g,int h){
		a=e;
		b=f;
		c=g;
		d=h;
	}
}



	


Measured memory_bytes: 35808
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n=I()
  ans=1
  for _ in range(n):
    ans=lcm(ans,I())

  return ans

# main()
print(main())


Measured memory_bytes: 5168
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
inline void print(int x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) print(x/10);
	putchar(x%10+48);
}
int d,t,s;
int main(){
	d=read(),t=read(),s=read();
	if(t*s>=d) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3544
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    vector<string> player(3);

    cin>>player[0]>>player[1]>>player[2];

    int pre=0;
    int now=player[0][0] - 'a';

    while(1){


        player[pre].erase(player[pre].begin());
        pre=now;
        if(player[now].empty()){
            break;
        }

        now=player[now][0] - 'a';

    }
    

    if(now==0){
        cout<<"A"<<endl;
    }else if(now==1){
        cout<<"B"<<endl;
    }else{
        cout<<"C"<<endl;
    }


}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

cand_dict = defaultdict(lambda:0)
for a in A:
    cand_dict[a-1] += 1
    cand_dict[a] += 1
    cand_dict[a+1] += 1
print(max(cand_dict.values()))    

Measured memory_bytes: 20004
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();
            var a = s[0] * s[1];
            var b = s[2] * s[3];

            Console.WriteLine(a >= b ? a : b);
        }
    }
}


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;

int main() {
  ll N;
  cin >> N;
  ll m = INF;
  for(int i = 0; i < 5;i++) {
    ll A;
    cin>>A;
    chmin(m,A);
  }
  ll ans=5LL+((N-1)/m);
  cout<<ans<<endl;
}

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


using namespace std;


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

    int center = 0;
    for (int i=0; i<n; i++) center += x[i]; center /= n;

    int ans = 1001001001;
    for (int diff=-3; diff<=3; diff++) {
        int sum = center + diff;
        int _ans = 0;
        for (int i=0; i<n; i++) {
            _ans += pow(x[i] - sum, 2);
        }
        ans = min(ans, _ans);
    }

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



Measured memory_bytes: 256
import java.util.*;

class Main {
	static int map[][] = new int[100][100];
	static int dx[] = {1,1,0,-1,-1,-1,0,1};
	static int dy[] = {0,1,1,1,0,-1,-1,-1};
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int w = in.nextInt(), h = in.nextInt();
			if(w==0) return ;
			for(int i=1; i<=h; i++)
				for(int j=1; j<=w;j++)
					map[i][j] = in.nextInt();
			int ans = 0;
			for(int i=1; i<=h; i++)
				for(int j=1; j<=w; j++)
					if(map[i][j] == 1){
						ans++;
						dfs(i,j);
					}
			System.out.println(ans);
		}
	}
	
	private static void dfs(int x, int y){
		if(map[x][y] != 1) return ;
		map[x][y] = 0;
		for(int i=0; i<8; i++){
			dfs(x+dx[i], y+dy[i]);
		}
	}
}

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

int main() {
  int jikan, a, b, Pa, Pb;
  cin >> jikan >> a >> b;
  Pa = jikan * a;
  Pb = b;
  
  if ( Pa <= Pb  ) {
    cout << Pa << endl;
  }
  
  else {
    cout << Pb << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int total = 0;
        //分解して足し算
        for(int i=0; i < n.length(); i++) {
            int num = Character.getNumericValue(n.charAt(i));
            total += num;
        }
        //判断
        if (total%9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 40780
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size();
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int main(){
  long long N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  FOR(i,0,N){
    if(C*(N-1-i)-D*i<=B-A&&B-A<=D*(N-1-i)-C*i){
      YES(1);
      return 0;
    }
  }
  YES(0);
  return 0;
}


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

using namespace std;
#define N 200200

long long v[N];

bool triangle (long long a, long long b, long long c) {
    if (a == b || b == c || a == c)
        return false;
    if (a < b + c && b < a + c && c < a + b)
        return true;
    return false;
}
int main(){
    int i, n, j, k;
    cin >> n;
    for (i = 0; i < n; ++i){
        cin >> v[i];
    }
    int ans = 0;
    for (i = 0; i < n; ++i){
        for (j = i + 1; j < n; ++j){
            for (k = j + 1; k < n; ++k){
                if (triangle (v[i], v[j], v[k])){
                    ++ans;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int isPrime(int n)
{
    int i;
    for(i = 2; i < n; i++) if (n % i == 0) return 0;
    return 1;
}
int main(){
long long int i,x;
scanf("%lld",&x);
for(i=x;i<100000000;i++){
 if(isPrime(i))
  {
  printf("%lld",i);
  break;
  }
}
return 0;
}    

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S[i] == 'o'){
      count++;
    }
  }
  cout << 700 + (100 * count) << endl;
  return 0;
}
 

Measured memory_bytes: 256
def goal?(amida,m,s)
  s == 1 + (amida.inject(m-1) do |s,i|
    if s>=1 && i[s-1]=="1"
      s-1
    elsif i[s]=="1"
      s+1
    else
      s
    end
  end)
end

loop do
  n = gets.to_i
  break if n==0
  m,s,d = 3.times.map{ gets.to_i }
  amida = d.times.map{ gets.chomp }
  if goal?(amida,m,s)
    puts 0
    next
  end
  catch :find do
    amida.each_with_index do |a,i|
      n.times do |j|
        if "0#{a}0"[j,3]=="000"
          added = amida.dup
          b = a.dup
          b[j] = "1"
          added[i] = b
          if goal?(added,m,s)
            puts "#{i+1} #{j+1}"
            throw :find
          end
        end
      end
    end
    puts 1
  end
end

Measured memory_bytes: 6120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    set<string> st;
    REP(i,n){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }

    sort(a.begin(),a.end(),greater<int>());
    int alice = 0;
    int bob = 0;

    for(int i=0;i<n;i++){
        if(i%2){
            bob += a.at(i);
        }else{
            alice += a.at(i);
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
s=deque(list(input()))
q=int(input())
direction=0 #0:順 1:逆

for i in range(q):
    query=input()
    if query[0]=='1':
        direction=direction^1
    elif query[0]=='2':
        i,f,c=query.split()
        if f=='1' and direction==0:
            s.appendleft(c)
        elif f=='1' and direction==1:
            s.append(c)
        elif f=='2' and direction==0:
            s.append(c)
        elif f=='2' and direction==1:
            s.appendleft(c)


if direction==0:
    print(''.join(s))
else:
    s=''.join(s)
    s=s[::-1]
    print(s)


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

int main(){
   vector<char> s(6);
   
   rep(i,6){
      cin >> s.at(i);
   }
   
   if((s.at(2)==s.at(3))&&(s.at(4)==s.at(5)))
   cout << "Yes";
   else
   cout << "No"; 

   return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  unsigned long N,Q;
  cin>>N>>Q;
  vector<unsigned long> A(N),S(N),X,a;
  for(auto&i:A)cin>>i;
  partial_sum(rbegin(A),rend(A),begin(S));
  for(unsigned long i{(N+1)/2},s{0};i--;s+=A[N-i*2-1])a.push_back(S[i]+s);
  for(unsigned long i{(N+1)/2};--i;)X.push_back(A[N-i-1]+A[N-i*2-1]);
  for(unsigned long i{0},x;i<Q;++i){
    cin>>x;
    cout<<a[lower_bound(begin(X),end(X),x*2)-begin(X)]<<endl;
  }
}

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

int keta(int x){
    if (x == 0) return 1;

    int ketasuu = 0; 
    while (x)
    {
        x /= 10;
        ketasuu++;
    }
    return ketasuu;
}

int main(){

    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    rep (i, M){
        cin >> s[i] >> c[i];
    }

    rep (i, 1000){
        if (keta(i) != N){
            continue;
        }
        string i_str = to_string(i);

        int flag = false;
        rep (j, M){
            if (i_str[s[j]-1] != c[j]){
                flag = true;
                break;
            }
        }
        if (flag) continue;
        cout << i_str << endl;
        return 0;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
#ifndef BTW
	#define cerr if(false)cerr
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){
	fastio;
	vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	k--;
	cout<<a[k];
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    static long MOD = 109+7;

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

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

        int countOdd = 0;
        int count2 = 0;
        int count4 = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if(a[i] % 4 == 0) count4++;
            else if(a[i] % 2 == 0) count2++;
            else countOdd++;
        }

        if(count2 == 0) {
            if(count4 + 1 >= countOdd) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if(count4 >= countOdd) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 50664
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
    auto L = scanElem+scanElem;
    auto R = scanElem+scanElem;
  if(L<R){
    writeln("Right");
  }else if(L>R){
    writeln("Left");
  }else{
    writeln("Balanced");
  }
      
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
int a,i,p;
int main() {
    cin >> a;
    while (p < a){
        i++;
        p += i;
    }
    string s;
    REP(j,i) s = s + ')';
    REP(j,i) s = s + '(';
    swap(s[i], s[i-p+a]);
    cout << s << endl;
    return 0;
}

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

using namespace std;


vector< int > g[100000];
int dist[100000], ans[100000];


void dfs1(int idx, int par)
{
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    dist[idx] = max(dist[idx], dist[to] + 1);
  }
}

void dfs2(int idx, int d_par, int par)
{
  vector< pair< int, int > > d_child;
  d_child.emplace_back(0, -1);
  for(int &to : g[idx]) {
    if(to == par) d_child.emplace_back(d_par + 1, to);
    else d_child.emplace_back(dist[to] + 1, to);
  }
  sort(d_child.rbegin(), d_child.rend());
  ans[idx] = d_child[0].first;
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, d_child[d_child[0].second == to].first, idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs1(0, -1);
  dfs2(0, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << (N - 1) * 2 - ans[i] << endl;
  }
}

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

int main(){
  string S;
  cin >> S;
  
  int N = (int)(S.length());
  
  char prev = 'R';
  vector<int> ans(N, 0);
  int kid = 0, gat = 0;
  
  for (int i = 0; i < N; i++){
    if (prev == 'R' && S.at(i) == 'L'){
      gat = i - 1;
      int Rget = kid / 2;
      ans.at(gat) += Rget + 1;
      ans.at(gat + 1) += kid - Rget + 1;
      kid = 0;
    }
    else if (S.at(i) == 'L'){
      if ((i - gat) % 2 == 1){
        ans.at(gat + 1)++;
      }
      else{
        ans.at(gat)++;
      }
    }
    else if (S.at(i) == 'R' && S.at(i + 1) == 'R'){
      kid++;
    }
    
    prev = S.at(i);
  }
  
  for (int i = 0; i < N; i++){
    cout << ans.at(i) << ' ';
  }
  cout << endl;


}

Measured memory_bytes: 3836
#include<stdio.h>
int c=1e9+10,l[100010];
int ta[100010],to[100010],nt[100010],fr[100010],q[100010],u[100010];
void f(int s){
  int i,t,r;
  q[t=0]=s;
  for(i=0;i<1010;i++)u[i+1]=0;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(to[i]==s)goto END;
      if(u[to[i]]==0){
	u[to[i]]=u[q[t]]+1;
	fr[to[i]]=q[t];
	q[r++]=to[i];
      }
    }
  }
  return ;
 END:;
  if(c>u[q[t]]){
    c=0;
    for(i=q[t];i-s;i=fr[i])l[c++]=i;
    l[c++]=s;
  }
  return ;
}    
int main(){
  int i,j,n,m,a,b;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)ta[i+1]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    to[i]=b;
    nt[i]=ta[a];
    ta[a]=i;
  }
  for(i=0;i<n;i++)f(i+1);
  if(c<1e9){
    printf("%d\n",c);
    for(i=0;i<c;i++)printf("%d\n",l[i]);
  }
  else printf("-1\n");
  return 0;
}


Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

MAX=10**6+1

n=ni()
a=nl()

s = [0]*(MAX)

for ai in a:
  if s[ai]!=0:
    s[ai]=2
    continue
  for i in range(ai,MAX,ai):
    s[i]+=1

cnt=0
for ai in a:
  if s[ai]==1:
    cnt+=1

print(cnt)

Measured memory_bytes: 132748
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
string s;
int a[28];
int dp[27][100010];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{    int n;
     cin>>n;
     for(int i=0;i<n;i++)
     {
         cin>>s[i];
         a[s[i]-'a'+1]++;
     }
     ll ans=1;
     for(int i=1;i<28;i++)
     {
         if(a[i]==0)
           continue;
           ans*=(a[i]+1);
           ans%=mod;
     }
     cout<<ans-1<<endl;


    return 0;
}


Measured memory_bytes: 384
/*gcc -o b B.c -lmでコンパイル*/
#include <stdio.h>
#include <math.h>

int main(void){
  int i,j,n,d,k,count=0;
  /*ここに書くとscanがうまくいかない
  int a[n][d];*/
  double distance,sum;
  scanf("%d %d",&n,&d);
  int a[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      scanf("%d",&a[i][j]);
    }
  }
  /*debug
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      printf("a[%d][%d]=%d ",i,j,a[i][j]);
    }
    printf("\n");
  }*/
  //距離
 for(i=0;i<n;i++){
    for(k=i+1;k<n;k++){
      for(j=0;j<d;j++){
        sum+=((a[i][j]-a[k][j])*(a[i][j]-a[k][j]));
      }
      distance=sqrt(sum);
    //  printf("%f ",distance);
      if(distance==floor(distance)){
        count+=1;
      }
      sum=0;
    }
  }

  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s; 

  cin >> s;

  int N = s.size();

  int ans = 0;
  int cnt = 0;
  REP(i, N){
    if(s[i] == 'W'){
      ans += i-cnt;
      cnt++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  int al;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  int ans;
  
  if((N-1)%(K-1)==0){
    ans = (N-1) / (K-1);
  }
   else{
    ans = ((N-1)/(K-1))+1;
  }
  
  cout << ans << endl;
 
    
}

Measured memory_bytes: 3636
def main2():
    N, M, K = map(int, input().split())

    for i in range(N + 1):
        for j in range(M + 1):
            b = i * (M - j) + j * (N - i)

            if b == K:
                print("Yes")
                exit()

    print("No")

if __name__ == "__main__":
    main2()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)
char mp[100][100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int h,w;
  cin>>h>>w;
  rep(i,h) {
    string tmp;
    cin>>tmp;
    rep(j,w) {
      mp[i][j] = tmp[j];
    }
  }
  vector<int> tate;
  rep(i,w) {
    rep(j,h) {
      if(mp[j][i]=='#') {
        tate.push_back(i);
        break;
      }
    }
  }
  vector<int> yoko;
  rep(i,h) {
    rep(j,w) {
      if(mp[i][j]=='#') {
        yoko.push_back(i);
        break;
      }
    }
  }
  for(auto &x : yoko) {
    for(auto &y : tate) {
      cout << mp[x][y];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<deque>
#include<algorithm>
#define x first
#define y second
using namespace std;

const int N = 1005, M = 1000005;
const long long INF = 0x3f3f3f3f3f3f3f3f;
typedef pair<int, int> PII;
int n, m, ans, sx, sy, Tx, Ty, d[N][N];
char g[N][N];
bool st[N][N];
string s;

void bfs()
{
	deque<PII> q;
	q.push_back({sx, sy});
	memset(d, 0x3f, sizeof d);
	d[sx][sy] = 0;
	while(q.size())
	{
		int ux = q.front().x, uy = q.front().y;
		q.pop_front();
		if(st[ux][uy]) continue;
		st[ux][uy] = true;
		if(ux == Tx && uy == Ty) return;
		for(int i = ux - 2; i <= ux + 2; ++i) if(0 < i && i <= n)
			for(int j = uy - 2; j <= uy + 2; ++j) if(0 < j && j <= m)
			{
				if(i == ux && j == uy) continue;
				if(st[i][j]) continue;
				if(g[i][j] == '#') continue;
				int dx = abs(i - ux), dy = abs(j - uy);
				if(dx == 0 && dy == 1 || dx == 1 && dy == 0)
				{
					d[i][j] = min(d[i][j], d[ux][uy]);
					q.push_front({i, j});
				}
				else
				{
					d[i][j] = min(d[i][j], d[ux][uy] + 1);
					q.push_back({i, j});
				}
			}
	}
	d[Tx][Ty] = -1;
}

int main()
{
	scanf("%d %d", &n, &m);
	scanf("%d%d", &sx, &sy);
	scanf("%d%d", &Tx, &Ty);
	for(int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
	bfs();
	cout << d[Tx][Ty] << endl;
	return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int h, w,d;
	cin >> h >> w >>d;
	map<int,P> mp;
	rep(i,h){
		rep(j,w){
			int a;
			cin >> a;
			mp[a] = {i,j};
		}
	}
	ll cost[h*w+1];
	for(int i = 1; i <= h * w; i++) {
		if(i <= d) {
			cost[i] = 0;
			continue;
		}
		cost[i] = cost[i-d] + abs(mp[i].first - mp[i-d].first) + abs(mp[i].second - mp[i-d].second);
	}
	int q;
	cin >> q;
	rep(i,q){
		int l, r;
		cin >> l >> r;
		cout << cost[r] - cost[l] << endl;
	}
}


Measured memory_bytes: 7424
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=[int(i) for i in input().split()]
ans=10**10

for i in range(n):
    p=abs(a-(t-h[i]*0.006))
    if p<ans:
        ans=p
        ansnum=i+1

print(ansnum)

Measured memory_bytes: 9188
#include<iostream>
#include<cstring>
using namespace std;
const int MAX_S=2000;
int main(){
	char s[MAX_S+1];
	fgets(s,MAX_S,stdin);
	for(int i=0;i+4<strlen(s);i++){
			if(s[i]=='a'&&s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e'){
				s[i]='p';
				s[i+1]='e';
				s[i+2]='a';
				s[i+3]='c';
				s[i+4]='h';
			}
		else if(s[i]=='p'&&s[i+1]=='e'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='h'){
			s[i]='a';
			s[i+1]='p';
			s[i+2]='p';
			s[i+3]='l';
			s[i+4]='e';
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<map>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=1e5+3;
int n,a[mn],b[mn],cnt[mn],par[mn];
map<int,int>re;
int get(int x){
	return (par[x]==x)?x:par[x]=get(par[x]);
}
int main(){
	scanf("%d",&n);
	int tmp=0;
	fo(i,1,n)scanf("%d",&a[i]),a[n+1]^=a[i];
	fo(i,1,n)scanf("%d",&b[i]),b[n+1]^=b[i];
	n++;
	fo(i,1,n){
		if(!re[a[i]])re[a[i]]=++tmp;
		if(!re[b[i]])re[b[i]]=++tmp;
		cnt[re[a[i]]]++;
		cnt[re[b[i]]]--;
	}
	fo(i,1,tmp)if(cnt[i]){printf("-1");return 0;}
	re.clear();
	tmp=0;
	fo(i,1,n)if((a[i]!=b[i])||(i==n)){
		if(!re[a[i]])re[a[i]]=++tmp;
		if(!re[b[i]])re[b[i]]=++tmp;
	}
	int ans=0;
	fo(i,1,tmp)par[i]=i;
	fo(i,1,n)if(a[i]!=b[i]){
		ans+=i!=n;
		par[get(re[a[i]])]=get(re[b[i]]);
	}
	fo(i,1,tmp)ans+=par[i]==i;
	printf("%d",ans-1);
	return 0;
}


Measured memory_bytes: 8064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	var nums []int

	for i := 0; i < n; i++ {
		var num int
		fmt.Scan(&num)
		nums = append(nums, num)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	var sum int
	for i := 1; i < n; i++ {
		sum += nums[i]
	}

	if nums[0] < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: u32,
        x: u32,
        m: [u32; n],
    };
    println!("{}", n + (x - m.iter().sum::<u32>()) / m.iter().min().unwrap());
}


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

int main() {
    long long n, all=0; cin >>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i); all+=a.at(i);
    }
    long long ret = all, tmp = 0;
    for (int i = 0; i < n; i++) {
        tmp += a.at(i);
        all -= a.at(i);
        ret = min(ret, abs(tmp-all));
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    std::map<int, int> attendMap;
    attendMap[a] += 1;
    attendMap[b] += 1;
    attendMap[c] += 1;

    if(attendMap[a] == 2) {
        cout << "Yes" << endl;
        return 0;
    }
    if(attendMap[b] == 2) {
        cout << "Yes" << endl;
        return 0;
    }
    if(attendMap[c] == 2) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int modpow(int x, int n, const int mo) {
	int res = 1;
	while (n > 0) {
		if (n & 1) (res *= x) %= mo;
		(x *= x) %= mo;
		n >>= 1;
	}
	return res;
}

int inverse(int x, const int mo) {
	return modpow(x, mo - 2, mo);
}

int N;
vector<int> G[200010];
int DP[200010];
int TSIZE[200010];

void dfs1(int idx, int par)
{
	DP[idx] = 1;

	for (auto e : G[idx])
	{
		if (e == par)continue;
		dfs1(e, idx);
		TSIZE[idx] += TSIZE[e];
		DP[idx] *= DP[e];
		DP[idx] %= MOD;
		DP[idx] *= COM(TSIZE[idx], TSIZE[e]);
		DP[idx] %= MOD;
	}

	TSIZE[idx]++;
}

void dfs2(int idx, int par)
{
	if (par != -1)
	{
		int tdp = DP[par];
		int tsz = TSIZE[par];
		int div = DP[idx] * COM(tsz - 1, TSIZE[idx]);
		div %= MOD;
		tdp *= inverse(div, MOD);
		tdp %= MOD;
		tsz -= TSIZE[idx];
		TSIZE[idx] += tsz;
		DP[idx] *= tdp;
		DP[idx] %= MOD;
		DP[idx] *= COM(TSIZE[idx] - 1, tsz);
		DP[idx] %= MOD;
	}

	for (auto e : G[idx])
	{
		if (e == par)continue;
		dfs2(e, idx);
	}
}

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

	COMinit();

	cin >> N;
	int a, b;
	rep(i, 0, N - 1)
	{
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs1(0, -1);
	dfs2(0, -1);

	rep(i, 0, N)
	{
		cout << DP[i] << endl;
	}

	return 0;
}

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

#define int long long
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; }

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

	int a[110];
	int sum = 0;

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

	if(sum % 10 != 0){
		cout << sum << endl;
	}else{
		sort(a, a+n);
		for(int i = 0;i < n;i++){
			if(a[i] % 10 != 0){
				sum -= a[i];
				break;
			}
		}
		cout << (sum % 10 != 0 ? sum : 0) << endl;
	}

	return 0;
}


Measured memory_bytes: 384
// ABC 152-D
// 2020.1.19 bal4u

#include <stdio.h>

int f[100];

int main()
{
	int i, k, N, ans;
	int t;
	
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		k = i;
		t = k%10;
		while (k >= 10) k /= 10;
		++f[k*10 + t];
	}

	ans = 0;
	for (i = 1; i <= N; ++i) {
		k = i;
		t = k%10;
		while (k >= 10) k /= 10;
		ans += f[t*10 + k];
	}
	printf("%d\n", ans);
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<string,ll>myMap;
set<string>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll n,f=0,last=0;
 string s;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>s;
     mySet.insert(s);
     myMap[s]++;
     last=max(last,myMap[s]);
 }
 for(auto i:mySet)
 {
     if(myMap[i]==last)
     {
         cout<<i<<endl;
     }
 }
return 0;
}



Measured memory_bytes: 33280
#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>

using namespace std;

typedef long long ll;

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) {
    int N;
    cin >> N;

    // int a = (int) ((N * 100.0 + 100) / 108.0); // this may be wrong
    int a = (int) ((N * 100.0 + 99) / 108.0);
    int b = (int) ( a * 108.0 / 100.0);

    if (N == b) {
        cout << a << endl;
    } else {
        cout << ":(" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256