akhauriyash/Code-Regression huggingface dataset:
program ABC167C
    implicit none
    integer(8)::N,M,X,i,j,ans,csum,k
    character(16)::b
    integer(8),allocatable,dimension(:)::C,P
    integer(8),allocatable,dimension(:,:)::A
    read*,N,M,X
    allocate(C(N))
    allocate(P(M))
    allocate(A(M,N))
    do i=1,N
        read(5,*)C(i),(A(j,i),j=1,M)
    end do
    ans=10**9

    do i=1,2**N
        P=0
        csum=0
        write(b,'(b16.16)')i
        !print'(A)',b
        do j=0,N-1
            if(b(16-j:16-j)=="1")then
                csum=csum+C(j+1)
                do k=1,M
                    P(k)=P(k)+A(k,j+1)
                end do
            end if
        end do
        if(minval(P)>=X)ans=min(ans,csum)
    end do
    if(ans==10**9)ans=-1
    print'(i0)',ans
end program ABC167C

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

using namespace std;

int main(){
  string s;
  cin >> s;
  char prev = s[0];
  int cnt = 1;
  int maxc = 0;
  for(int i = 1; i < s.size(); i++){
    if(s[i] != prev){
      cnt = 1;
      prev = s[i];
      continue;
    }
    prev = s[i];
    cnt++;
    maxc = max(maxc,cnt);
  }
  //cout << maxc;
  if(maxc > 2) cout << "Yes";
  else cout << "No";
}


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int k, n;
    cin >> k >> n;
    
    vector<int> pos(n);
    for (int i = 0; i < n; ++i)
        cin >> pos[i];
    
    vector<int> dist(n);
    for (int i = 0; i < n; ++i)
    {
        int j = i + 1;
        
        if ((i + 1) >= n)
            dist[i] = k - pos[i] + pos[0];
        else        
            dist[i] = pos[i + 1] - pos[i];
    }
    
    int start = 0, len = n;
    int currDist = 0;
    for (int i = start; i < (start + len - 1); ++i)
        currDist += dist[i];
    
    int minDist = currDist;
    for (int i = 0, j = len - 1; i < n; ++i, j = (j + 1) % len)
    {
        currDist -= dist[i];
        currDist += dist[j];
        
        minDist = min(minDist, currDist);
    }

    cout << minDist << "\n";

    return 0;
}


Measured memory_bytes: 1792
a = 3.times.map { gets.split.map(&:to_i) }
n = gets.chomp.to_i
b = []
ans = "No"
n.times do
  b.push(gets.chomp.to_i)
end

b.each do |b|
  3.times do |i|
    3.times do |j|
      if a[i][j] == b then
        a[i][j] = -1
      end
    end
  end
end

ans = "Yes" if (a[0][0] + a[0][1] + a[0][2] == -3)
ans = "Yes" if (a[1][0] + a[1][1] + a[1][2] == -3)
ans = "Yes" if (a[2][0] + a[2][1] + a[2][2] == -3)

ans = "Yes" if (a[0][0] + a[1][0] + a[2][0] == -3)
ans = "Yes" if (a[0][1] + a[1][1] + a[2][1] == -3)
ans = "Yes" if (a[0][2] + a[1][2] + a[2][2] == -3)

ans = "Yes" if (a[0][0] + a[1][1] + a[2][2] == -3)
ans = "Yes" if (a[0][2] + a[1][1] + a[2][0] == -3)

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define BUFF_SIZE 1024
char buffer[1024 * 1024];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

__attribute__((always_inline)) int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }

    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 1380
import collections
MOD = 998244353

n = int(input())
d = [int(_) for _ in input().split()]

ans = 1
if d[0] != 0:
    ans = 0
else:
    D = sorted(collections.Counter(d).most_common())
    if D[0][1] != 1:
        ans = 0
    else:
        cnt = 0
        prev = 1
        for i in D:
            if i[0] == cnt:
                ans = ans * pow(prev, i[1], MOD) % MOD
                prev = i[1]
            else:
                ans = 0
                break
            cnt += 1
print(ans)

Measured memory_bytes: 21980
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {

	string s;
	cin >> s;
	ll ans = 0, cnt = 0;
	FOR(i, s.length())if (s[i] == 'W') {
		ans += i - cnt;
		cnt++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.math.BigInteger;
import java.io.PrintWriter;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    in.close();
    
    BigInteger ba = BigInteger.valueOf(a);
    BigInteger bb = BigInteger.valueOf(b);
    BigInteger gcd = ba.gcd(bb);
    PrintWriter pw = new PrintWriter(System.out);
    pw.println(ba.multiply(bb).divide(gcd).toString());
    pw.flush();
  }
}

Measured memory_bytes: 23380
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int n,a[100008]; int o,p;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];if(a[i]%2==0)o++;if(a[i]%4==0) o--,p++;
	}
	int an=0;
	if(o==n)
	{
		cout<<"Yes"<<endl;return 0;
	}
	an=an+max(0,o-1);if(p==0) an--;an+=2*p+1;if(an<n) cout<<"No"<<endl;else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
s = input()+"T"
n = len(s)
x,y = map(int, input().split())

fcnt = 0
tcnt = 0
xd = set()
yd = set([0])
for i in range(n):
    if s[i]=="F":
        fcnt += 1
        continue

    if tcnt==0:
        xd.add(fcnt)
    elif tcnt%2==0:
        # x軸の移動
        tmp = set()
        for xx in xd:
            tmp.add(xx-fcnt)
            tmp.add(xx+fcnt)
        xd = tmp
    else:
        # y軸の移動
        tmp = set()
        for yy in yd:
            tmp.add(yy-fcnt)
            tmp.add(yy+fcnt)
        yd = tmp
    tcnt += 1
    fcnt = 0

if x in xd and y in yd:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3816
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var dn = Sarray();
            var ans = 0;
            for(var i=0;i<N;i++)
            {
                for(var j=i+1;j<N;j++)
                {
                    ans += dn[i] * dn[j];
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18832
def main():
    import sys
    input = sys.stdin.readline
    #重み付きUnion-Find

    #xの根を求める
    def find(x):
        if par[x] < 0:
            return x
        else:
            px = find(par[x])
            wei[x] += wei[par[x]]
            par[x] = px
            return px

    #xの根から距離
    def weight(x):
        find(x)
        return wei[x]


    #w[y]=w[x]+wとなるようにxとyを併合
    def unite(x,y,w):
        w += wei[x]-wei[y]
        x = find(x)
        y = find(y)
        
        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if par[x] > par[y]:
                x,y = y,x
                w = -w
            par[x] += par[y]
            par[y] = x
            wei[y] = w
            return True

    #xとyが同じ集合に属するかの判定
    def same(x,y):
        return find(x) == find(y)

    #xが属する集合の個数
    def size(x):
        return -par[find(x)]

    #x,yが同じ集合に属するときのwei[y]-wei[x]
    def diff(x,y):
        return weight(y)-weight(x)

    n,m = map(int,input().split())

    #初期化
    #par:根なら-size,子なら親の頂点
    #wei:親からの距離,根なら0
    par = [-1]*n
    wei = [0]*n

    for i in range(m):
        l,r,d = map(int,input().split())
        l,r = l-1,r-1
        if same(l,r):
            if d != diff(l,r):
                print('No')
                exit()
        else:
            unite(l,r,d)
    print('Yes')
            
if __name__ == '__main__':
    main()

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

#define INF (int)1e+9
using namespace std;

void dumpmat(vector<vector<int> >& a,int n){

  for( int i=1; i<=n; i++ ){
    for( int j=1; j<=n; j++ ){
      cout << a[i][j] << " ";
    }
    cout << "\n";
  }
  cout << "\n";
}

int main(){

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

  vector<vector<int> > m(n+1, vector<int>(n+1,INF));
  // dp[i][k] : i (0 <= i <= n-1)???????????? k (1 <= k <= n) ??????????????????????°????
  /*
  for(int i=0; i<=n; i++) m[i][1] = 0;
 
  for(int l=2; l<=n; l++){
    for(int i=1; i<n-l+1; i++){
      int j=i+l-1;
      dp[i][j]=INF;
      for(int k=i; k<=j-1; k++){
	dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
      }
      dumpmat(dp,n);
    }
  } 
  cout << dp[1][n] << endl;
*/
  for ( int i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( int l = 2; l <= n; l++ ) {
    for ( int i = 1; i <= n - l + 1; i++ ) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for ( int k = i; k <= j - 1; k++ ) {
	m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
      //      dumpmat(m,n);
    }
  }

  cout << m[1][n] << endl;
  return 0; 
}

Measured memory_bytes: 1252
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    r = II()
    print(r*r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import java.lang.*;

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

    while(true){
      int h=Integer.parseInt(scan.next());
      int w=Integer.parseInt(scan.next());
      if(h==0 && w==0)break;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){

          if(i%2==0){
            if(j%2==0){
              System.out.print("#");
            }else{
              System.out.print(".");
            }
          }else{
            if(j%2==0){
              System.out.print(".");
            }else{
              System.out.print("#");
            }
          }

        }
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 35184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int cnt=(a-(b+b));
    if(a>(b+b))
    {
        cout<<cnt<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }


}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin >>n;
    V ans;
    const int A_MAX=55556;
    vector<bool>isprime(A_MAX,true);
    for (ll i = 2; i <A_MAX; ++i) {
        if(isprime[i]){
            if(i%5==1)ans.push_back(i);
            if(ans.size()==n)break;
            for (ll j =i*2 ; j <A_MAX; j+=i) {
                isprime[j]=false;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout <<ans[i]<<" ";
    }
    cout <<"\n";
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,K,a[3000005],i,st,cnt;
char s[200005];
int main()
{
	scanf("%d%d",&n,&K);
	scanf("%s",s+1);
	for(i=1;i<=n;++i)
		a[i]=(s[i]=='A'?0:1);
	cnt=min(K,10*n);
	st=1;
	while(cnt--)
	{
		/*for(i=1;i<=n;++i)
			printf("%d ",a[st+i-1]^(st&1^1));
		puts("");*/
		if(a[st]==(st-1)%2)
		{
			a[st]^=1;
			continue;
		}
		a[st+n]=(st&1?1:0);
		++st;
	}
	if(K<=10*n)
	{
		for(i=1;i<=n;++i)
			printf("%c",(a[st+i-1]^(st&1^1))?'B':'A');
		return 0;
	}
	if((K-10*n)%2)
	{
		if(a[st]==(st-1)%2)
			a[st]^=1;
		else
		{
			a[st+n]=(st&1?1:0);
			++st;
		}
	}
	for(i=1;i<=n;++i)
		printf("%c",(a[st+i-1]^(st&1^1))?'B':'A');
	return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	
	ll point = 0;	
	for(int i = 0; i < k; ++i) {
		if( t[i] == 'r' ) point += p;
		if( t[i] == 's' ) point += r;
		if( t[i] == 'p' ) point += s;
	}
	
	for(int i = k; i < n; ++i) {
		if( t[i - k] == t[i] ) t[i] = 'a';
		if( t[i] == 'r' ) point += p;
		if( t[i] == 's' ) point += r;
		if( t[i] == 'p' ) point += s;
	}
	
	cout << point << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int a[3];	
	FOR(i,0,3) cin >> a[i];
	sort(a, a + 3);

	string ans = "No";
	if (a[0] + a[1] == a[2]) ans = "Yes";

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct Edge{
    int ver;
    int wei;
    Edge(int v,int w) : ver(v),wei(w) {}
};
using WGraph = vector<vector<Edge>>;

int main(){
    int n;
    cin >> n;
    WGraph G(n);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;a--;b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    queue<int> q;
    vi dis(n,-1);
    dis[0] = 0;
    q.push(0);
    vi ans(n);
    ans[0] = 0;
    while(q.size()){
        int v = q.front();
        q.pop();

        for(auto t : G[v]){
            if(dis[t.ver]!=-1) continue;
            dis[t.ver] = dis[v] + t.wei;
            ans[t.ver] = (dis[t.ver]&1);
            q.push(t.ver);
        }
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

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

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

	string s;
	cin >> s;
	bool ok=true;
	for(int i=0; i<s.length(); i++){
		if(i%2){
			// add condition of even pos
			if(s[i]!='L' and s[i]!='U' and s[i]!='D') ok=false;

		}
		else{
			// add condition of odd pos
			if(s[i]!='R' and s[i]!='U' and s[i]!='D') ok=false;
		}
	}
	if(ok) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3656
//
// Created by Chisec Coin on 17/7/15.
//

#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <sstream>
#include <map>
const int NIL = -1;
typedef long long ll;
using std::cin;using std::cout;using std::endl;using std::max;using std::min;

int l[200];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    std::sort(l, l + n, [](const int& a, const int& b){ return a > b; });
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        sum += l[i];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] abcxy = br.readLine().split(" ");
        int a = Integer.parseInt(abcxy[0]);
        int b = Integer.parseInt(abcxy[1]);
        int c = Integer.parseInt(abcxy[2]);
        int x = Integer.parseInt(abcxy[3]);
        int y = Integer.parseInt(abcxy[4]);
        
        int cost = 0;
        
        if(a+b > c*2){
            int min = x < y ? x : y;
            x -= min; 
            y -= min;
            
            cost += c * min * 2;
            int rest = x > 0 ? a : b;
            if(rest > c*2)
                cost += c * (x+y) * 2;
            else
                cost += a*x + b*y;
        }
        else{
            cost += a*x + b*y;
        }
        System.out.println(cost);
    }
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N, R;
  cin >> N >> R;
  if (N >= 10) cout << R << endl;
  else cout << R + 100 * (10 - N) << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL dis[2022][2022];
LL cun[2022];
int main()
{
	LL n,x,y;n=read();x=read();y=read();
	for(LL i=1;i<=n;++i)
	for(LL j=1;j<=n;++j)
	dis[i][j]=abs(i-j);
	for(LL i=1;i<=n;++i)
	for(LL j=1;j<=n;++j)
	{
		dis[i][j]=min(dis[i][j],dis[i][x]+dis[y][j]+1);
	}
	for(LL i=1;i<=n;++i)
	for(LL j=i+1;j<=n;++j)
	cun[dis[i][j]]++;
	for(int i=1;i<n;++i)printf("%d\n",cun[i]);
}

Measured memory_bytes: 31872
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    int answer = 1;
    int ansMemo = 2;
    int[][] answers = new int[n][];
    int[] pairs = new int[n];
    for(int i = 0; i < n; i++)
    {
      answers[i] = new int[n];
    }
    while(true)
    {
      if(ansMemo >= n) break;
      ansMemo *= 2;
      answer++;
    }
    //Console.WriteLine(2);
    for(int i = 0; i < n; i++)
    {
      if(i % 2 == 1) pairs[i] = 1;
    }
    

    for(int i = 0; i < answer; i++)
    {
      for(int j = 0; j < n; j++)
      {
        for(int k = j; k < n; k++)
        {
          //Console.WriteLine(k);
          if(pairs[j] + pairs[k] == 1 && answers[j][k] == 0)
          {
            answers[j][k] = i+1;
            //Console.WriteLine(i+" "+j+" "+k);
          }
        }
      }

      for(int j = 0; j < n; j++)
      {
        if(j%Math.Pow(2,(i+2)) <= Math.Pow(2,i+1)-1)
        {
          pairs[j] = 1-pairs[j];
        }
      }
    }
    //Console.WriteLine("aa");

    
    int[][] answersSub = new int[n-1][];
    for(int i = 0; i < n-1; i++)
    {
      answersSub[i] = new int[n-1-i];
      for(int j = 0; j < n-1-i; j++)
      {
        answersSub[i][j] = answers[i][j+i+1];
      }
    }
    //Console.WriteLine("aaa");
    
    for(int i = 0; i < n-1; i++)
    {
      Console.WriteLine(string.Join(" ", answersSub[i]));
    }
	}
}

Measured memory_bytes: 19408
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 2e5+5;
const int MOD = 1e9+7;


int arr[MSIZE], ht[MSIZE];
map<int,ll> m; 
ll dp[MSIZE];

ll solve(int& n) {
    dp[0] = arr[0];
    m[ht[0]] = dp[0];
    f(i,1,n-1) {
        dp[i] = arr[i];
        auto it = m.lower_bound(ht[i]);
        if(it!=m.begin())   dp[i]+= (--it)->second;
        m[ht[i]] = dp[i];
        it = m.upper_bound(ht[i]);
        while(it!=m.end() && (it->second)<=dp[i]) {
            auto t = it; it++;
            m.erase(t);
        }
    }
    return *max_element(dp,dp+n);
}

int main(){

    FIO
    int n; cin>>n;
    f(i,0,n-1)  cin>>ht[i];
    f(i,0,n-1)  cin>>arr[i];
    cout<<solve(n)<<endl;
    return 0;

}
    


Measured memory_bytes: 15872
n, a, b = map(int, input().split())

if (b-a)%2 == 0:
    print((b-a)//2)
elif n-a < b-1:
    al = n-b+1
    b = n
    a += al
    r = (b-a)//2+al
    print(max(r, 1))
else:
    be = a
    b -= a
    a = 1
    r = (b-a)//2+be
    print(max(r, 1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const int MOD=1e9+7;

int N;
int G[21][21];
void input(){
    cin>>N;
    rep(i,N)rep(j,N){
        cin>>G[i][j];
    }
}

int dp[1 << 21];
int dfs(int i, int s){
    if(dp[s]!=-1)return dp[s];
    if(i==N && s==(1<<N)-1){
        dp[s]=1;
        return 1;
    }
    int tmp=0;
    rep(d,N)if(((s>>d) & 1) ==0)if(G[i][d]){
        tmp=(tmp+dfs(i+1, s ^ (1<<d)))%MOD;
    }
  	dp[s]=tmp;
  	return tmp;
}

int ans;
void solve(){
    rep(s,1<<N)dp[s]=-1;
    ans=dfs(0,0);
}

void output(){
    cout<<ans<<endl;
}

int main(){
    input();
    solve();
    output();
}

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

// ------ disjoint set ------ //
struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m), y(m), z(m);
    UnionFind uf(n * 2);
    // 0 .. n-1
    // n .. 2n-1
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> z[i]; x[i]--, y[i]--;
        if (z[i] % 2) { // Axi + Ayi は奇数
            uf.unionSet(x[i], y[i] + n);
            uf.unionSet(x[i] + n, y[i]);
        } else {
            uf.unionSet(x[i], y[i]);
            uf.unionSet(x[i] + n, y[i] + n);
        }
    }
    cout << uf.size() / 2 << endl;
    return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int k = s.nextInt(), a = s.nextInt(),b=s.nextInt();
        boolean flag= false;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                flag = true;
                break;
            }
        }
        System.out.println(flag?"OK":"NG");


    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25408
import sys
from itertools import permutations

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, M = map(int, input().split())
    Adj = [[0]*N for i in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        Adj[a][b] = 1
        Adj[b][a] = 1

    cnt = 0

    for line in permutations(range(1, N)):
        path = [0] + list(line)
        # debug(path, locals())

        for i in range(N - 1):
            if not Adj[path[i]][path[i + 1]]:
                break
        else:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
counter = int(input())
result_flg = False

fir_fir, fir_sec = map(int, input().split())
sec_fir, sec_sec = map(int, input().split())


for i in range(2, counter):
  thi_fir, thi_sec = map(int, input().split())

  if fir_fir == fir_sec:
    if sec_fir == sec_sec:
      if thi_fir == thi_sec:
        result_flg = True
        break

  # reset content
  fir_fir = sec_fir
  fir_sec = sec_sec
  sec_fir = thi_fir
  sec_sec = thi_sec

if result_flg == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,s,t;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};
ll sude[ohara];
V g[ohara];
V dat;
int judge;
map<P,int> mp;

//-------------------------↓↓↓↓↓↓------------------------

/*
void dfs(ll now,ll nannkai){
    if(judge)return;
    //bool vi[n+10]={};
    if(now==s&&nannkai%3==0){
        Cout(nannkai/3);
        judge=1;
    }
    cout<<now<<" "<<nannkai<<"\n";
    rep(i,Size(g[now])){
        ll to=g[now][i];
        /* if(!vi[to])dfs(to,nannkai+1);
        /* vi[to]=true;
    }
    return;
}
*/

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

    cin>>n>>m;
    rep(i,m)cin>>a[i]>>b[i],a[i]--,b[i]--;
    rep(i,m)g[b[i]].push_back(a[i]);
    cin>>s>>t;
    s--;t--;
    /* dfs(t,0LL);*/
    queue<P> que;
    que.push({t,0});
    while(!que.empty()){
        P moto=que.front();
        if(moto.fi==s&&moto.se%3==0){
            Cout(moto.se/3);
            return 0;
        }
        que.pop();
        rep(i,Size(g[moto.fi])){
            ll to=g[moto.fi][i];
            if(mp[{to,(moto.se+1)%3}]==1)continue;
            cnt++;
            if(cnt==1000000)break;
            que.push({to,moto.se+1});
            mp[{to,(moto.se+1)%3}]=1;
        }
        if(cnt==1000000)break;
    }
    Cout(-1);
    return 0;
}


Measured memory_bytes: 50944
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;
typedef pair<double,double>pdd;

const int MAX_N = 100005;

int Q;

pdd projection(P p1,P p2,P p)
{
	P a = P(p2.first-p1.first,p2.second-p1.second);
	P b = P(p.first - p1.first,p.second - p1.second);
	double sa = sqrt(a.first*a.first + a.second*a.second);
	double sb = sqrt(b.first*b.first + b.second*b.second);
	double rt = (a.first*b.first+a.second*b.second)/(sa*sa);
	return pdd(p1.first+rt*a.first,p1.second+rt*a.second);
}

int main()
{
	P p1,p2,p;
	scanf("%d%d%d%d",&p1.first,&p1.second,&p2.first,&p2.second);
	scanf("%d",&Q);
	rep(i,Q){
		pdd res;
		scanf("%d%d",&p.first,&p.second);
		res = projection(p1,p2,p);
		printf("%.10f %.10f\n",2*res.first - p.first,2*res.second - p.second);
	}
	return 0;
}

Measured memory_bytes: 3224
D,G=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(D)]
c=0
d=0
for i in range(D):
  d+=p[i][0]
dp=[[0]*(d+1)for i in range(D)]
for i in range(D):
  for j in range(p[i][0]+1):
    if i==0:
      if j==p[i][0]:
        dp[i][j]+=p[i][1]
      dp[i][j]+=100*j
    else:
      for k in range(c+1):
        if j==p[i][0]:
          dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
        else:
          dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
  c+=p[i][0]
for i in range(d+1):
  if dp[D-1][i]>=G:
    print(i)
    break

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

using namespace std;

int main()
{
    string acgt = "ACGT";
    string s;
    cin>>s;

    int count = 0;
    int max_count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        bool flag = false;
        for (int j = 0; j < acgt.size(); j++)
        {
            if (s.at(i) == acgt.at(j))
            {
                flag = true;
                break;
            }
        }
        if(flag)
        {
            count++;
            if (max_count < count)
            {
                max_count = count;
            }
        }
        else
        {
            count = 0;
        }
    }

    cout << max_count << endl;
}


Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  string s;
  cin >> s;
  if (s[1] == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var N = int.Parse(Console.ReadLine());
        var dic = new Dictionary<string,long>();
        long resultCount = 0;
        for (var i = 0; i < N; i++)
        {
            var s = Console.ReadLine();
            var array = new char[s.Length];
            array = s.ToCharArray();
            Array.Sort(array);
            string word = new string(array);
            Console.WriteLine();
            if (dic.ContainsKey(word))
            {
                dic[word]++;
            }
            else
            {
                dic.Add(word, 1);
            }
        }

        foreach (var v in dic)
        {
            resultCount += v.Value * (v.Value-1) /2;
        }

        Console.WriteLine(resultCount);
    }



    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }
}



Measured memory_bytes: 30288
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
    int w=1,c,ret;
    while((c=getchar())> '9'||c< '0')
    w=(c=='-'?-1:1); ret=c-'0';
    while((c=getchar())>='0'&&c<='9')
    ret=ret*10+c-'0';
    return ret*w;
}
int a,b,c;
int main(){
    a=qread(),b=qread(),c=qread();
    swap(a,b),swap(a,c);
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(n % (a + b), a);
}
/*

*/  

Measured memory_bytes: 384
n,m = map(int,input().split())
a=[[0]*n for _ in range(n)]
b=[[0]*m for _ in range(m)]

for i in range(n):
    a[i] = input()
for i in range(m):
    b[i] = input()
    
f=0
for i in range(n-m+1):
    for j in range(n-m+1):
        acut = [aa[i:i+m] for aa in a[j:j+m]]

        if acut==b:
            f=1
            break
    if f==1: break
print(f*"Yes"+(1-f)*"No")

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  int X; cin >> X;
  vector<int> m(N); rep(i, 0, N){ cin >> m[i]; }
  cout<<N+(X-accumulate(all(m),0))/ *min_element(all(m))<<endl;
  

    return 0;
}


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

vector<pair<int, pair<int,int> > >vec;
pair<int,int>temp[152][152];
void gen(){
	for (int i=1;i<=150;i++){
		for (int j=i+1;j<=150;j++){
			vec.push_back(make_pair(i*i+j*j, make_pair(i,j)));
		}
	}
	sort(vec.begin(), vec.end());
	for (int i=0;i<vec.size()-1;i++){
		temp[vec[i].second.first][vec[i].second.second] = make_pair(vec[i+1].second.first, vec[i+1].second.second);
	}
}
int a,b;
int main(){
	gen();
	while(1){
		scanf("%d %d", &a, &b);
		if (a==0 && b==0) return 0;
		else printf("%d %d\n", temp[a][b].first, temp[a][b].second);
	}
	return 0;
}


Measured memory_bytes: 2972
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> posi(n);
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp); tmp--;
        posi[tmp] = i;
    }
    ll ans = 0;
    set<int> s;
    for (i=0; i<n; i++) {
        int tmp = posi[i];
        auto it=s.insert(posi[i]).first;
        int tmp0 = -1;
        if (it != s.begin()) {
            auto it2 = it;
            it2--;
            tmp0=(*it2);
        }
        int tmp1 = n;
        {
            auto it2 = it;
            it2++;
            if (it2 != s.end()) {
                tmp1 = (*it2);
            }
        }
        ans+=(ll)(tmp - tmp0)*(tmp1 - tmp)*(i + 1);
    }
    printf("%lld\n", ans);
    
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

using namespace std;

long long int K;

int main() {
  cin >> K;
  long long int a = K / 50, b = K % 50;
  cout << 50 << endl;
  for (int i = 0; i < b; i++) {
    cout << 100 - b + a << " ";
  }
  for (int i = 0; i < 50 - b; i++) {
    cout << 49 - b + a << " ";
  }
  cout << endl;

  return 0;
}

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

int main() {

	int x[5];

	int size = sizeof x / sizeof * x;
	
	for (int i = 0; i < size; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < size; i++) {
		if (x[i] == 0) {
			cout << i + 1 << "\n";
			break;
		}
	}


	return 0;

}

Measured memory_bytes: 3572
function main(input) {
  input = input.trim();
  const [a, b, c] = input.split(' ').map(n => Number(n));
  const cnt = Math.floor(b/a);
  const result = Math.min(c, cnt);
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    ll Q;
    cin >> S >> Q;
    deque<char> d;
    ll size = S.size();
    rep(0, i, size)
    {
        d.push_back(S.at(i));
    }
    ll T, F;
    ll count = 0;
    char x;
    char y;
    rep(0, i, Q)
    {
        cin >> T;
        if (T == 1)
        {
            count++;
        }
        else
        {
            cin >> F;
            if (F == 1 + count % 2)
            {
                cin >> x;
                d.push_front(x);
            }
            else
            {
                cin >> y;
                d.push_back(y);
            }
        }
    }
    if (count % 2 == 1)
    {
        while (d.empty() != true)
        {
            cout << d.back();
            d.pop_back();
        }
    }
    else
    {
        while (d.empty() != true)
        {
            cout << d.front();
            d.pop_front();
        }
    }
    cout << endl;
}

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

bool IsPrime(int n){
    if(n < 2) return false;
    else if(n == 2) return true;
    else if(n % 2 == 0) return false;

    double sqrtNum = sqrt(n);
    for(int i = 3; i <= sqrtNum; i += 2){
        if(n % i == 0){
            return false;
        }
    }

    return true;
}

int main(){
    int n,k; // k個の整数
    int count = 0;
    cin >> k;
    for(int i = 0; i < k; ++i){
        cin >> n;
        if(IsPrime(n)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3100
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    int y;
    int x;
    cin>>a>>b>>c>>y>>x;
    if (c<a && c<b){
    int sm=min(y,x);
    long long SUM=sm*c*2;
    long long ddd;
    long long eee;
    eee=abs(y-x)*c*2;
    if (y>x) ddd=(y-x)*a;
    else ddd=(x-y)*b;
    SUM+=min(ddd,eee);
    cout<<SUM<<endl;
    }
    else if (c<a || c<b) {
                            int aaa=y*a+x*b;
                            int bbb=max(y,x);
                            bbb*=c*2;
                            int ccc=min(y,x)*c*2;
                            if (y>x) ccc+=(y-x)*a;
                            else ccc+=(x-y)*b;
                            int ddd=min(aaa,bbb);
                            int eee=min(ccc,ddd);
                            cout<<eee<<endl;
                         }
    else cout<<y*a+x*b<<endl;
    return 0;
}

Measured memory_bytes: 256