akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long ans=0;
  for(long long i=0;i<=N;i++){
    if(i*i<=N)  ans=i*i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        
        int x,
        max=-1000000,
        min=1000000,
        temp;
        long sum=0;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        x = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");
        
        for(int i = 0; i < x; i ++){
            temp = Integer.parseInt(str[i]);
            if(temp>max){
                max = temp;
            }
            if(temp<min){
                min = temp;
            }
            sum = sum + temp;
        }
        System.out.println(min + " " + max + " " +sum);
    }
}

Measured memory_bytes: 28540
n, m = gets.chomp.split.map(&:to_i)
arr = []
n.times{arr << gets.chomp.split.map(&:to_i)}
arr.sort_by!{|a, b| a}
sum = 0
arr.each{|a, b|
    c = [b, m].min
    sum += a * c
    m -= c
    break if c == 0
}
puts sum

Measured memory_bytes: 13560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll m;
    cin>>m;
    int v,p;
    cin>>v>>p;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int ng=-1,ok=n-1;
    while(ok-ng>1){
        int mi = (ok+ng)/2;
        vector<ll> b(n);
        rep(i,n)b[i]=a[i];
        b[mi]+=m;
        int cnt=v-1;
        rep(i,mi){
            if(cnt==0)break;
            b[i]+=m;
            --cnt;
        }
        for(int i=n-1;i>n-p;--i){
            if(cnt==0)break;
            b[i]+=m;
            --cnt;
        }
        ll res = cnt*m;
        bool can=true;
        for(int i=n-p;i>mi;--i){
            if(b[i]>b[mi]){
                can=false;
                continue;
            }
            res-=min(b[mi]-b[i],m);
            b[i]+=min(m,b[mi]-b[i]);
        }
        if(can && res<=0)ok=mi;
        else ng=mi;
    }
    cout<<n-ok<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int mil = days(1000,1,1);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			System.out.println(mil-days(y,m,d));
		}
	}
	
	public static int days(int y,int m,int d) {
		y--; m--; d--;
		int days = 0;
		days += (y/3) * ((20+19)*5*2 + 20*10);
		days += (y%3) * ((20+19)*5);
		if (y%3 <= 1) {
			days += (m/2) * (20+19);
			days += (m%2) * 20;
		}else{
			days += m * 20;
		}
		days += d;
		return days;
	}

}

Measured memory_bytes: 20520
n,m = map(int,input().split())

dic={}
for _ in range(n):
    a,b = map(int,input().split())
    if a in dic:
        dic[a]+=b
    else:
        dic[a]=b
dic = sorted(dic.items())

count=0
sum=0
for tup in dic:
    if tup[1] > m-count:
        sum+=tup[0]*(m-count)
        break
    sum+=tup[0]*tup[1]
    count+=tup[1]

print(sum)

Measured memory_bytes: 22992
def main():
    a, b, c, d = map(int, input().split())
    x = 0
    while 0 < a and 0 < c:
        if x%2 == 0:
            c -= b
        else:
            a -= d
        x += 1
    if a <= 0:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9080
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

 
int main() {
  ll N, ans = 0;;

  cin >> N;

  for (ll i = 2; i * i <= N; i++){
    if(N % i != 0) continue;
    ll num = 0;
    while(true){
      if(N % i == 0){
        N /= i;
        num++;
      }else{
        break;
      }
    }

    ll cnt = 1;
    while(true){
      if(num >= cnt){
        num -= cnt;
        ans++;
        cnt++;
      }else{
        break;
      }
    }
  }

  if(N != 1) ans++;
  cout << ans << endl;

}



Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    string s, t;
    cin >> s;
    bool f = false;
    int n = s.size();
    rep(j, 0, n + 10){
        t = "";
        if(s == "ABC"){
            f = true;
            break;
        }
        int d[3] = {};
        rep(i, 0, s.size()){
            if(i < s.size() - 2 && s.substr(i, 3) == "ABC"){
                t += '?';
                i += 2;
            }else{
                t += s[i];
                d[s[i] - 'A'] = 1;
            }
        }
        char c;
        int tmp = 0;
        rep(i, 0, 3) tmp += d[i];
        if(tmp != 2) break;
        rep(i, 0, 3) if(d[i] == 0) c = 'A' + i;
        rep(i, 0, s.size()){
            if(t[i] == '?') t[i] = c;
        }
        // cout << t << endl;
        s = t;
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string n; cin >> n;
    ll ans = 0;
    rep(i, n.size()) ans += n[i] - '0';
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

class Main {
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        int minFactor[] = new int[a[n - 1] + 100];
        for (int i = 2; i < minFactor.length; i++) {
            if (minFactor[i] != 0)
                continue;
            for (int j = i; j < minFactor.length; j += i) {
                minFactor[j] = i;
            }
        }

        long lcm = 1;
        int totalCount[] = new int[a[n - 1] + 100];

        for (int i = 0; i < n; i++) {
            int target = a[i];
            while (target >= 2) {
                int div = minFactor[target];
                int count = 0;
                while (target % div == 0) {
                    count++;
                    target /= div;
                }
                totalCount[div] = Math.max(totalCount[div], count);
            }
        }

        for (int i = 0; i < totalCount.length; i++) {
            for (int j = 0; j < totalCount[i]; j++) {
                lcm = (lcm * i) % mod;
            }
        }

        long answer = 0;

        for (int i = 0; i < n; i++) {
            answer = (answer + (lcm * (pow(a[i], mod - 2)) % mod) % mod);
        }

        System.out.println(answer % mod);
        sc.close();

    }

    public static long pow(long a, long n) {
        if (n == 0)
            return 1;
        if (n == 1)
            return a;
        if (n % 2 == 0)
            return pow((a * a) % mod, n / 2);
        return (a * pow((a * a) % mod, (n - 1) / 2)) % mod;
    }
}


Measured memory_bytes: 46316
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n,x;
    while (cin >> n) {
        vector<int> cnt;
        while (n--){
            cin>>x;
            cnt.push_back(x);
        }
        int counts = 0;
        int key = cnt.size() - 1;
        for (int i = 0; i < cnt.size(); i++) {
            int minv = cnt[cnt.size() - 1];
            for (int j = cnt.size()-2; j >= i; j--) {
                if (minv < cnt[j]) {
                    counts++;
                    cnt[j+1] = cnt[j];
                } else {
                    cnt[j+1] = minv;
                    minv = cnt[j];
                }
            }
            cnt[i] = minv;
        }
        cout<<cnt[0];
        for (int i = 1; i < cnt.size(); i++) {
            cout<<" "<<cnt[i];
        }
        cout<<endl;
        cout<<counts<<endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    ll n;
    int p=0,w=0,g=0,y=0;
    cin >>n;
    rep(i, n) {
        string s;
        cin >> s;
        if(s=="G") g++;
        if(s=="W") w++;
        if(s=="Y") y++;
        if(s=="P") p++;
    }
    if (y!=0) {
        pr("Four");
    }else{
        
        pr("Three");
    }
    
    return 0;
}



Measured memory_bytes: 256
// AOJ 1093: KND Runs for Sweets
// 2017.11.16 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define KAI 70
int x[101], y[101], v[101]; int n;
int max;

double fx(double a, double b)
{
	int i;
	double d, max;
	
	max = 0;
	for (i = 0; i < n; i++) {
		d = hypot(a-x[i], b-y[i]) / v[i];
		if (d > max) max = d;
	}
	return max;
}

double srchy(double x)
{
	int i;
	double l, r, a, b;

	l = 0, r = max;
	i = KAI; while (i--) {
		a = (2*l + r) / 3;
		b = (l + 2*r) / 3;
		if (fx(x, a) < fx(x, b) ) r = b;
		else                      l = a;
	}
	return fx(x, (l+r)/2);
}

double srch3()
{
	int i;
	double l, r, a, b;
	
	l = 0, r = max;
	i = KAI; while (i--) {
		a = (2*l + r) / 3;
		b = (l + 2*r) / 3;
		if (srchy(a) < srchy(b)) r = b;
		else                     l = a;
	}
	return srchy((l+r) / 2) ;
}

int main()
{
	int i;

	while (scanf("%d", &n) && n > 0) {
		max = 0;
		for (i = 0; i < n; i++)	{
			scanf("%d%d%d", x+i, y+i, v+i);
			if (x[i] > max) max = x[i];
			if (y[i] > max) max = y[i];
		}
		printf("%.8f\n", srch3());
	}
	return 0;
}

Measured memory_bytes: 1808
n, x, y = list(map(int, input().split()))

dist = [0 for _ in range(n - 1)]

for i in range(n):
    for j in range(i + 1, n):
        k = min(j - i,
                abs(x - 1 - i) + 1 + abs(y - 1 - j))
        dist[k - 1] += 1

for k in range(1, n):
    print(dist[k - 1])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
//#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int N= 50000;
using namespace std;


ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 
ll lcm(int a, int b)  
 {  
    return a/gcd(a, b) *b;  
 }
  
int prime(int n)
{
	rep(i,2,n+1)
	{
		if(n%i==0)return i;
	}
	
}


void solve() 
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n==1 || n%2==1)
	{
		cout<<"No"<<endl;
		return ;
	}
	if(s.substr(0,n/2)==s.substr(n/2,n/2))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    if (s.size() == 2) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(m)]
l,r = {k:False for k in range(1,n+1)},{k:False for k in range(1,n+1)}
for a,b in ab:
    if a == 1:  l[b] = True
    if b == n:  r[a] = True
for i in range(1,n+1):
    if r[i] is True and l[i] is True:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 88048
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    S = input().strip()
    T = input().strip()

    D = {chr(i): [] for i in range(ord("a"), ord("z") + 1)}

    for i, s in enumerate(S):
        D[s].append(i)
    
    res = 0
    p = 0
    for t in T:
        if D[t] == []:
            print(-1)
            return
        
        j = bisect.bisect_left(D[t], p)
        if j == len(D[t]):
            p = D[t][0] + 1
            res += 1
        else:
            p = D[t][j] + 1
        
    print(res * len(S) + p)


if __name__ == "__main__":
    main()



Measured memory_bytes: 82060
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll M, D, ans = 0;
    in >> M >> D;

    REP_AB(i, 22, D+1){
        if( (M >= (i%10)*(i/10)) && (i%10 > 1) ){
            ans++;
        } 
    }
    out << ans << endl;

    
 
    //vector<ll> X(N);

}

Measured memory_bytes: 256
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val queue = ArrayDeque<Long>()
    for (i in 1..9L) queue.addLast(i)

    repeat(k - 1) {
        val x = queue.removeFirst()
        if (x % 10 != 0L) queue.addLast(x * 10 + x % 10 - 1)
        queue.addLast(x * 10 + x % 10)
        if (x % 10 != 9L) queue.addLast(x * 10 + x % 10 + 1)
    }

    println(queue.removeFirst())
}

Measured memory_bytes: 38708
#include <bits/stdc++.h>
using namespace std;
int N = 0;//文字列中の数字の数
string num;

long int ans(string S){
    stack<string> stk;
    long int sum = 0;
    stk.push({});
    for(int i=0;i<S.length();i++){
        if(S[i] == '+'){
            sum += stoi(stk.top());
            stk.pop();
            stk.push({});
        }else{
            stk.top().push_back(S[i]);
        }
    }
    sum += stol(stk.top());
    stk.pop();
    return sum;
}



long int dfs(int i,string S){
    string S2 = S + "+";
    if(i == N-1) return ans(S);
    else{
        S2.push_back(num[i+1]);
        S.push_back(num[i+1]);
        return dfs(i+1,S2) + dfs(i+1,S);
    }
}

int main(){
    string S;
    cin >> S;
    num = S;
    N = S.length();
    S = {num[0]};
    cout << dfs(0,S) << endl;
    return 0;
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	int s;
	bool a = x >= r && x <= W -r && y >= r && y <= H - r;
	if (a){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    int r = 0;
    for(int i=a; i <= b; i++){
        int s = i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i / 1000 % 10;
        if (s == t&&u == v) r++;
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  if(a>9||b>9) cout << "-1" << endl;
  else cout << a*b << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
A=[]
for i in range(h):
    a_list=list(map(int,input().split()))
    A.append(a_list)
B=[]
for i in range(h):
    b_list=list(map(int,input().split()))
    B.append(b_list)
dp=[]
for i in range(w):
    sub_list=[False]*12802
    dp.append(sub_list)
dp[0][0]=True
for i in range(h):
    for j in range(w):
        c=A[i][j]-B[i][j]
        l=[False]*12802
        for x in range(12802):
            if dp[j][x]:
                l[abs(x+c)]=True
                l[abs(x-c)]=True
                if j<w-1:
                    dp[j+1][abs(x+c)]=True
                    dp[j+1][abs(x-c)]=True
        dp[j]=l
ans=20000
for x in range(12802):
    if dp[w-1][x]:
        ans=min(ans,x)
print(ans)        
    


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll n,a[1001],ans=1;
bool prime(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}
void fuc(ll n){
	for(int i=2;i<=n;i++){
		if(n%i==0&&prime(i)){
			int t=n;
			while(t%i==0){
				a[i]++;
				t/=i;
			}
		}
	}
	return;
}

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	for(int i=2;i<=n;i++){
		a[i]++;
		fuc(i);
	}
	for(int i=2;i<=n;i++){
		ans*=a[i];
//		cout<<i<<' '<<a[i]<<endl;
		ans%=INF;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import itertools 



N=int(input())
A=tuple(map(int,input().split()))
B=tuple(map(int,input().split()))
before=0
after=0
count=0

T=[]
for i in range(1,N+1):
    T.append(i)


D=list(itertools.permutations(T))
for Z in D:
    count+=1
    if A==Z:
        
        before=count
    if B==Z:
       
        after=count
    
print(abs(before-after))


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

using namespace std;

#define int long long

int n,k;
map<int,int> cnt;
int a[200001];
int psum[200001];

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

	cin >> n >> k;
	int res = 0;
	cnt[0]++;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		if (i >= k)
		{
			int cur = (psum[i-k] - (i-k))%k;
			cnt[cur]--;
		}
		psum[i] = psum[i-1] + a[i];
		int cur = (psum[i] - i)%k;
		res += cnt[cur];
		cnt[cur]++;
	}	
	cout << res;
}

Measured memory_bytes: 15872
/*
 * 题目: Aizu - 0525 
 * 题意: 
 * 类型: 
 * 算法：暴力搜索
 * Date: 2020-07-07 09:37:58
 * LastEditors: loeije
 * LastEditTime: 2020-07-08 07:01:33
*/

#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int maxn = 1024 + 10;
const int row = 10 + 5, col = 10000 + 5;
int grid[row][col];
int r, c, ans = 0;

void process(int idx) {
    if(idx == r) {
        int sum = 0;
        for(int i = 0; i < c; ++i) {
            int tempsum = 0;
            for(int j = 0; j < r; ++j) {
                if(grid[j][i] == 1) {
                    tempsum++;
                }
            }

            sum += max(tempsum, r - tempsum);
        }
        ans = max(ans, sum);
        return ;
    }

    process(idx + 1);
    for(int i = 0; i < c; ++i) grid[idx][i] = !grid[idx][i];
    process(idx + 1);
}

int main() {
    while(scanf("%d%d", &r, &c) && (r + c != 0)) {
        for(int i = 0; i < r; ++i) {
            for(int j = 0; j < c; ++j) {
               scanf("%d", &grid[i][j]); 
            }
        }

        // process
        ans = 0;
        process(0);
        
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2952
# 
import math
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,m,x,y=nm()
X = nl()
Y = nl()
Z = []
z = 0
if max(X)<min(Y):
    z=max(X)+1
else:
    print('War')
    exit()

for i in range(z,min(Y)+1):
    Z.append(i)


if len(Z)==0:
    print('War')
    exit()

is_war = True
for i in range(len(Z)):
    if x<Z[i]<=y:
        is_war = False
    else:
        pass
if is_war:
    print('War')
else:
    print('No War')


Measured memory_bytes: 3064
// AOJ 3016: Fissure Puzzle Easy
// 2018.2.3 bal4u

#include <stdio.h>

#define MAX 16384	// 128x128
/* UNION-FIND library */
int id[MAX], size[MAX];
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

char map[130][130];
int tr[128][128], sz;
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int main()
{
	int N, r, c, i, ans;

	scanf("%d", &N);
	for (sz = 0, r = 0; r < N; r++) {
		scanf("%s", map[r]);
		for (c = 0; c < N; c++) {
			map[r][c] &= 1, tr[r][c] = id[sz] = sz, sz++;
		}
	}

	for (r = 0; r < N; r++) for (c = 0; c < N; c++) if (map[r][c]) {
		for (i = 0; i < 4; i++) {
			int r2 = r + mv[i][0], c2 = c + mv[i][1];
			if (r2 >= 0 && r2 < N && c2 >= 0 && c2 < N && map[r2][c2])
				unite(tr[r][c], tr[r2][c2]);
		}
	}

	ans = 0;
	for (r = 0; r < N; r++) for (c = 0; c < N; c++) if (map[r][c]) {
		if (root(tr[r][c]) == tr[r][c]) ans++;
	}
	printf("%d\n", (ans-1)/3);
	return 0;
}


Measured memory_bytes: 2076
import sys

sys.setrecursionlimit(10 ** 5 * 2)
input = sys.stdin.readline
N, M = map(int, input().split())
Ps = [[] for _ in range(N)]
deg = [0] * N
for i in range(M):
    x, y = map(int, input().split())
    Ps[x - 1].append(y - 1)
    deg[y - 1] += 1

stack = []
for i in range(N):
    if deg[i] == 0:
        stack.append(i)

dp = [0] * N
while (stack):
    n = stack.pop()
    for p in Ps[n]:
        dp[p] = max(dp[p], dp[n] + 1)
        deg[p] -= 1
        if deg[p] == 0:
            stack.append(p)

print(max(dp))


Measured memory_bytes: 55728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,i,j;
    cin>>n>>k;
    int d,sw[n],p;
    for(i=0; i<n; i++){
        sw[i]=0;
    }
    
    for(i=0; i<k; i++){
        cin>>d;
        for(j=0; j<d; j++){
            cin>>p;
            sw[p-1]++;
        }
    }
    
    int cntr=0;
    for(i=0; i<n; i++){
        if(sw[i]==0){
            cntr++;
        }
    }
    cout<<cntr<<endl;
    
    return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B&&B==C){
   cout << "No" << endl;
  }
  else if(A==B ||B==C||A==C){
   cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n[4]={0},i;
	for(i=0;i<4;i++){
		cin>>n[i];
	}
	sort(n,n+4);
	if(n[0]==n[1]&&n[2]==n[3]){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3116
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            String c = in.next();
            if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0))
                out.println("YES");
            else
                out.println("NO");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N;

  cin>>N;
  
  int a[101];

  int cnt[8]={ };
  
  for(int i=0;i<N;i++){

    cin>>a[i];

    if(a[i]<3200){

      cnt[a[i]/400]=1;

    }

  }

  int ans=0;
 
  for(int i=0;i<=7;i++){
    
    if(cnt[i]==1){
      ans++;
    }
  }

  sort(a,a+N);

  if(ans){
    cout<<ans<<" ";
  }else{
    cout<<1<<" ";
  }
  
  for(int i=N-1;i>=0;i--){

    if(a[i]<3200){
      break;
    }

    ans++;
    
  }

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

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500001
#define NIL -1
typedef struct node{
  int left;
  int right;
  int key;
  int p;
  int leftid;
  int rightid;

}Node;
Node node[MAX];
int root=NIL;
void inorder(int);
void preorder(int);
int search(int s,int r){
  if(r==NIL){
    return 0;
  }
  if(node[r].key==s){
    return 1;
  }
  else {
    if(node[r].key>s &&node[r].left!=NIL){
    return  search(s,node[r].leftid);
    }
    if(node[r].key<s&&node[r].right!=NIL){
      return search(s,node[r].rightid);
    }
    return 0;
  }

}
void addTree(int n,int num){
  int tmp;
  //rootが空の場合
  if(node[n].key==root){
    root=n;
    node[root].key=num;
    
  }
  else{
  tmp=root;

  while(1){
    if(node[tmp].key>num){
      if(node[tmp].left!=NIL){
	tmp=node[tmp].leftid;
      }
      else{
	node[tmp].left=num;
	node[tmp].leftid=n+1;
	node[n+1].key=num;
	
	break;
      }
    }
    else{
      if(node[tmp].right!=NIL){
	tmp=node[tmp].rightid;
	
      }
      else{
	node[tmp].right=num;
	node[n+1].key=num;
	node[tmp].rightid=n+1;
	break;
      }
    }
  }
  
  node[n].p=tmp;
  
  }
}
int main(){
  int num,i,n,l=0,tmp,s,flag=0;
  char name[100];
  int judge;
  scanf("%d",&n);
 for(i=0;i<MAX;i++){//初期化
    node[i].p=NIL;
    node[i].left=NIL;
    node[i].right=NIL;
    node[i].key=NIL;
    judge=0;
  }


 for(i=0;i<n;i++){
    scanf("%s",name);
    if(name[0]=='i'){
      scanf("%d",&num);
      addTree(l,num);
      l++;
      }
      
   else if(name[0]=='p'){

    inorder(root);
   printf("\n");
   preorder(root);
   printf("\n");
   continue;
    }
   else if(name[0]=='f'){
     scanf("%d",&s);
     judge= search(s,root);
    
    if(judge==0){

      
    printf("no\n");
    }
    else{
    
      printf("yes\n");
    }
    judge=0;
    continue;
   }
  }
 
  return 0;
}
void inorder(int t){
  if(node[t].left!=NIL){
    inorder(node[t].leftid);
  }
    printf(" %d",node[t].key);
  if(node[t].right!=NIL){
    inorder(node[t].rightid);
  }
}
void preorder(int t){
 
      printf(" %d",node[t].key);
  if(node[t].left!=NIL){
    preorder(node[t].leftid);
  }
  if(node[t].right!=NIL){
    preorder(node[t].rightid);
  }
}



Measured memory_bytes: 13448
def permute(s, low, high, arr):
    if low == high:
        arr.append(''.join(s))
    for i in range(low, high+1):
        s[i], s[low] = s[low], s[i]
        permute(s, low+1, high, arr)
        s[low], s[i] = s[i], s[low]



n = int(input())
A = input()
B = input()
A = A.replace(' ', '')
B = B.replace(' ', '')
arr = []
permute(list(A), 0, n-1, arr)
arr.sort()
print(abs(arr.index(A)-arr.index(B)))

Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m, a, b;
  cin >> n >> m;
  int p[n-1];
  for (int i = 0; i < n-1; ++i) p[i] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (a>b) {int d = a; a = b; b = d;}
    if (a!=1) p[a-2]++;
    p[b-2]++;
  }
  for (int i = 0; i < n-1; ++i) {
    if (p[i]%2!=0) {cout << "NO" << endl; return 0;}
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var dic = new Dictionary<char, int>();
            string s = string.Empty;
            var march = new char[] { 'M', 'A', 'R', 'C', 'H' };
            foreach(char c in march)
            {
                dic[c] = 0;
            }
            for(int i = 0; i < n; i++)
            {
                s = Console.ReadLine();
                if (!march.Contains(s.First())) continue;
                dic[s.First()]++;
            }

            var check = new int[] { 7, 11, 13, 14, 19, 21, 22, 25, 26, 28 };
            long comb = 1;
            long sum = 0;
            for(int i = 7; i <= 28 ; i++)
            {
                if (!check.Contains(i)) continue;
                comb = 1;
                for(int j = 0; j < 5; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        comb *= dic[march[j]];
                    }
                }
                sum += comb;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 17480
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	String strA[]=new String[a];
	String strB[]=new String[b];
	for(int i=0;i!=a;i++) {
		strA[i]=scan.next();
	}
	for(int i=0;i!=b;i++) {
		strB[i]=scan.next();
	}
	int fig=0;
	loop:for(int i=0;i!=a-b+1;i++) {
		for(int k=0;k!=a-b+1;k++) {
			if(strA[i].substring(k,k+b).equals(strB[0])) {
				for(int j=1;j!=b+1;j++) {
					if(j==b) {
						fig=1;
						break loop;
					}
					if(strA[i+j].substring(k,k+b).equals(strB[j])){	
					}
					else {
						break;
					}
				}
			}	
		}
	}
	System.out.println(fig==1?"Yes":"No");
}
}

Measured memory_bytes: 24020
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    int N;cin >> N;
    vector<int> A,B,C;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        A.push_back(b);
    }
    ll ans = 0;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        B.push_back(b);
        ans += b;
    }
    for(int i = 0;i < N-1;i++){
        int b;cin >> b;
        C.push_back(b);
    }
    int prev = -1;
    for(int i = 0;i < N;i++){
        if(prev + 1 == A.at(i)){
            ans += C.at(prev-1);
        }
        prev = A.at(i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	std::vector<int> grundy(k + 1, 0);
	for(int i = 1; i <= k; i++) {
		std::set<int> st;
		for(auto v: a) if(i - v >= 0) st.insert(grundy[i - v]);
		
		int g = 0;
		while(st.count(g)) g++;
		grundy[i] = g;
	}
	
	if(grundy[k]) printf("First\n");
	else printf("Second\n");
	return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    int i=0;
    for(auto v:s){
        if(i==k-1){
            char p = v+0x20;
            cout<<p;
        }
        else{
            cout<<v;
        }
        i++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

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

int main(void)
{
        int n;
        int m;
        cin >> n;
        m=n;
        int sum = 0;
        while(n>0){
                sum+=n%10;
                n/=10;
        }
        if(m%sum==0){
                cout << "Yes" << endl;
        }else{
                cout << "No" << endl;
        }
        return 0;
}

Measured memory_bytes: 256
S = str(input())
a = S[0]
b = S[1]
c = S[2]
d = S[3]
if a == b and c ==d and a != c:
  print('Yes')
elif a == c and b == d and a != b:
  print('Yes')
elif a == d and b == c and a != b:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,pri[1111],ans=1;
long long ced(long long i){
	long long a=0,q=n;
	while(q>=i){
		q/=i;
		a+=q;
	}
	return a;
}
int main(){
	cin>>n;
	pri[0]=1;pri[1]=1;
	for(long long i=2;i<=n;i++){
		if(!pri[i]){
			for(long long j=i+i;j<=n;j+=i)pri[j]=1;
		}
	}
	for(long long i=2;i<=n;i++){
		if(!pri[i]){
			ans*=ced(i)+1;
			while(ans>1e9+7)ans=ans-(1e9+7);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int i,j,ws[10],ks[10],koukan;


  for(i=0;i<10;i++){
    scanf("%d",&ws[i]);
  }
  for(i=0;i<10;i++){
    scanf("%d",&ks[i]);
  }

  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(j==9)break;
      if(ws[j]>ws[j+1]){
	koukan=ws[j];
	ws[j]=ws[j+1];
	ws[j+1]=koukan;
      }
      if(ks[j]>ks[j+1]){
	koukan=ks[j];
	ks[j]=ks[j+1];
	ks[j+1]=koukan;
      }

    }
  }
  printf("%d %d\n",ws[7]+ws[8]+ws[9],ks[7]+ks[8]+ks[9]);
  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int n; cin >> n;
    ll dp[n+1]; dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i-1] * i;
        dp[i] %= MOD;
    }
    out(dp[n]);






    

    
    return 0;
}






Measured memory_bytes: 1024
import collections

s = list(input())
q = int(input())

s2 = collections.deque(s)

inn = []
jun = 0

for i in range(q):
    inn = list(input().split())
    if inn[0] == "1":
        if jun == 0:
            jun = 1
        else:
            jun = 0#jun = 0はそのまま　jun = 1は逆をする
    elif inn[0] == "2":
        if inn[1] == "1" and jun == 0:
            s2.appendleft(inn[2])
        elif inn[1] == "2" and jun == 0:
            s2.append(inn[2])
        if inn[1] == "1" and jun == 1:
            s2.append(inn[2])
        elif inn[1] == "2" and jun == 1:
            s2.appendleft(inn[2])
    
if jun == 0:
    news = ''.join(s2)
else:
    s2.reverse()
    news = ''.join(s2)

print(news)
               

Measured memory_bytes: 9332
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void){
	int i,abcp[3],abcl[3],p;
	char abc[3][101],x;
	for(i=0;i<3;i++){
		cin>>abc[i];
		abcl[i]=strlen(abc[i]);
		abcp[i]=0;
	}
	p=0;
	while(1){
		if(abcp[p]==abcl[p]) break;
		x=abc[p][abcp[p]];
		abcp[p]++;
		if(x=='a') p=0;
		if(x=='b') p=1;
		if(x=='c') p=2;
	}
	if(p==0) cout<<'A'<<endl;
	if(p==1) cout<<'B'<<endl;
	if(p==2) cout<<'C'<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input){
  let data = input.split('\n');
  let arr, row, col;
  for (let i = 0; i < data.length; i++){
    arr = data[i].split(' ');
    row = arr[0];
    col = arr[1];
    if (row === '0' && col === '0'){
      break;
    }
    let s ='';
    let t = '';
    for (let j = 0; j < col; j++){
      s += "#";
      if (j === 0){
      t += "#";
      } else if (j === col -1) {
        t += "#";
        break;
      } else{
        t+='.';
      }
    }
    for (let k = 0; k < row; k++){
      if(k === 0){
        console.log(s);
      } else if (k === row - 1){
        console.log(s);
        break;
      } else {
        console.log(t);
      }      
    }
    console.log('');
    }
  }

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


Measured memory_bytes: 17460
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var d = new int[N];
        for (int i = 0; i < N; i++)
        {
            d[i] = int.Parse(Console.ReadLine());
        }
        var c = 0;
        var b = true;
        for (int i = 0; i < N; i++)
        {
            c = Math.Max(c, i + d[i] / 10);
            if (i != N-1 && c < i + 1)
            {
                b = false;
                break;
            }
        }
        c = N - 1;
        for (int i = N - 1; i >= 0; i--)
        {
            c = Math.Min(c, i - d[i] / 10);
            if (i != 0 && c > i - 1)
            {
                b = false;
                break;
            }
        }
        Console.WriteLine(b ? "yes" : "no");
    }
}


Measured memory_bytes: 22676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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 namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  ll ans = INF;
  for (int i = -100; i <= 100; i++) {
    ll tmp = 0;
    for (int j = 0; j < n; j++) {
      tmp += (i - a[j]) * (i - a[j]);
    }
    ans = min(ans, tmp);
  }

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


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

int main() {
  int N;
  cin >> N;
  int d1 = N % 100 % 10;

  switch (d1) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default:
      break;
  }

  return 0;
}


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

int main() {
	ll n;
	vector<ll> p(5);
	cin >> n;
	rep(i, 5) cin >> p[i];
	ll res = 1e16;
	rep(i, 5) res = min(res, p[i]);
	ll ans1 = (n - 1) / res;
	if (n == res) ans1 = 0;
	cout << 5 + ans1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using P = pair<int, int>;


int main() {
    char alpha;
    cin >> alpha;

    int i_alpha = (int)alpha;
    if (65 <= i_alpha && i_alpha <= 90) {
        i_alpha = 65;
    } else if (97 <= i_alpha && i_alpha <= 122) {
        i_alpha = 97;
    }
    cout << (char)i_alpha << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <queue>
#include <vector>


#define rep(i,a,b)(long long i=a;i<b;i++)

using namespace std;


struct POINT {
	int x;
	int y;
	POINT(int X, int Y){
		x = X;y = Y;
	}
};

queue<POINT>	usedWay;
int SizeX,SizeY;
int Map[50][50] = {0};
vector<int>	result;


void SearchIsland(int X, int Y){
	usedWay.push(POINT(X,Y));
	Map[X][Y] = 2;

	while(usedWay.empty() == false){
		POINT NowPos = usedWay.front();
		usedWay.pop();

		if(NowPos.y-1 >= 0){
			//	左上
			if(NowPos.x-1 >= 0 && Map[NowPos.x-1][NowPos.y-1] == 1){
				Map[NowPos.x-1][NowPos.y-1] = 2;
				usedWay.push(POINT(NowPos.x - 1,NowPos.y - 1));
			}
		
			//	真上
			if(					  Map[NowPos.x][NowPos.y-1] == 1){
				Map[NowPos.x][NowPos.y-1] = 2;
				usedWay.push(POINT(NowPos.x,NowPos.y - 1));
			}

			//	右上
			if( NowPos.x + 1 < SizeX && Map[NowPos.x+1][NowPos.y-1] == 1){
				Map[NowPos.x+1][NowPos.y-1] = 2;
				usedWay.push(POINT(NowPos.x + 1,NowPos.y - 1));
			}
		}

		//	左
		if(NowPos.x-1 >= 0 && Map[NowPos.x-1][NowPos.y] == 1){
			Map[NowPos.x-1][NowPos.y] = 2;
			usedWay.push(POINT(NowPos.x - 1,NowPos.y));
		}

		//	右
		if( NowPos.x + 1 < SizeX && Map[NowPos.x+1][NowPos.y] == 1){
			Map[NowPos.x+1][NowPos.y] = 2;
			usedWay.push(POINT(NowPos.x + 1,NowPos.y));
		}

		if(NowPos.y + 1 < SizeY){
			//	左下
			if(NowPos.x-1 >= 0 && Map[NowPos.x-1][NowPos.y+1] == 1){
				Map[NowPos.x-1][NowPos.y+1] = 2;
				usedWay.push(POINT(NowPos.x - 1,NowPos.y + 1));
			}
		
			//	真下
			if(					  Map[NowPos.x][NowPos.y+1] == 1){
				Map[NowPos.x][NowPos.y+1] = 2;
				usedWay.push(POINT(NowPos.x,NowPos.y + 1));
			}

			//	右下
			if( NowPos.x + 1 < SizeX && Map[NowPos.x+1][NowPos.y+1] == 1){
				Map[NowPos.x+1][NowPos.y+1] = 2;
				usedWay.push(POINT(NowPos.x + 1,NowPos.y + 1));
			}
		}


	}
}

int main(void){

	while(true){

		int NumIsland = 0;

		cin >> SizeX;
		cin >> SizeY;

		if(SizeX == 0 && SizeY == 0)
			break;

		int tmp = SizeX;
		SizeX = SizeY;
		SizeY = tmp;

		//	読み込み
		for(int i = 0 ; i < SizeX; ++i)
			for(int j = 0 ; j < SizeY ; ++j)
				cin >> Map[i][j];


		for(int i = 0 ; i < SizeX ; ++i){
			for(int j = 0 ; j < SizeY ; ++j){
				if(Map[i][j] == 1){
					SearchIsland(i,j);
					NumIsland++;
				}
			}
		}

		result.push_back(NumIsland);
	}

	for(vector<int>::iterator it = result.begin() ; it != result.end(); ++it)
		cout << *it << endl;

	return 0;
}

Measured memory_bytes: 1228