akhauriyash/Code-Regression huggingface dataset:
count=0
str=gets.chomp
num=Array.new
number=str.split
for i in 0..2 do
  num[i]=number[i].to_i
end
for j in 0..10000 do
  if j==num[0] && count<2 then
    print "#{j} "
    count+=1
  elsif j==num[0] && count==2 then
    print "#{j}"
    count+=1
  end
  if j==num[1] && count<2 then
    print "#{j} "
    count+=1
  elsif j==num[1] && count==2 then
    print "#{j}"
    count+=1
  end
  if j==num[2] && count<2 then
    print "#{j} "
    count+=1
  elsif j==num[2] && count==2 then
    print "#{j}"
    count+=1
  end
end
print "\n"

Measured memory_bytes: 8704
#include<stdio.h>

  int n,m;
  int graph[51][51] = {0};
  int visited[51] = {0};

void dfs(int a, int b){

  if(visited[b] == 1){
    return;
  }

  visited[b] = 1;
  for(int i = 1; i <= n; ++i){
    if(( i != a ) && graph[b][i] == 1 ){
      dfs(b, i);
    }
  }
}

int main(){


  scanf("%d %d",&n, &m);
  int a[51],b[51];
  for(int i = 1; i <= m; ++i){
    scanf("%d %d",&a[i], &b[i]);
    graph[a[i]][b[i]] = 1;
    graph[b[i]][a[i]] = 1;
  }

  int bridge = 0;
  int flag = 0;
  for(int i = 1; i <= m ; ++i){
    graph[a[i]][b[i]] = 0;
    graph[b[i]][a[i]] = 0;
    dfs(0,1);

    for(int j = 1; j <= n ; ++j){
      if(visited[j] == 0){
        flag = 1;
      }
      visited[j] = 0;
    }
    if(flag == 1) bridge ++;
    graph[a[i]][b[i]] = 1;
    graph[b[i]][a[i]] = 1;
    flag = 0;
  }

  printf("%d",bridge);

  return 0;

}


Measured memory_bytes: 128
while True:
    a,b = map(int,input().split())
    
    if a == 0 and b == 0:
        break
    
    for i in range(a):
        for j in range(b):
            if (i+j)% 2 == 0:
                print("#", end="")
            else:
                print(".",end="")
                
        print()
    print()


Measured memory_bytes: 7004
#include <stdio.h>
int main ()
{
	char s[5];
	scanf("%c",&s);
	
	if(s[0]=='S')
	{
		printf("Cloudy\n");
	}
	else if(s[0]=='C')
	{
		printf("Rainy\n");
	}
	else if(s[0]=='R')
	{
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n];
  for(int i= 0; i< n; ++i) cin >> a[i];
  int c[3] = {1,0,0};
  long conv = 0;
  if(a[0] == 0) conv = 3;
  for(int i= 1; i< n; ++i){
    int candidate = 0;
    int num = 0;
    if(c[0] == a[i]){
      candidate++;
      num = 0;
    }
    if(c[1] == a[i]){
      candidate++;
      num = 1;
    }
    if(c[2] == a[i]){
      candidate++;
      num = 2;
    }
    c[num]++;
    conv *= candidate;
    conv %= 1000000007;
  }

  printf("%d\n", conv);
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ld long double
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
 /*struct cmp{ bool operator() ( const, const )const{}};
  use as set<ll> ,cmp> a*/
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  //freopen("input.txt" , "r" , stdin );
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans = 0;
  if(a>=k)
    ans = k;
  else if( a+b >= k)
    ans = a;
  else if( a+b+c >= k)
    ans = a - (k-(a+b));
  cout<<ans;

  return 0;

}



Measured memory_bytes: 3568
A, B = gets.split(' ').map(&:to_i)
str = gets.chomp.split('')
str.each.with_index(1) do |c,i|
  #puts "c: #{c}, i: #{i}"
  if i == A+1
    unless c == '-'
      puts 'No'
      exit
    end
  else
    unless c =~ /\d/
      puts 'No'
      exit
    end
  end
end
puts 'Yes'


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

using namespace std;
int main(){
 long long a;
 cin>>a;
if(a%11==0) cout<<a/11*2<<endl;
else if(a%11<=6) cout<<a/11*2+1<<endl;
 else  cout<<a/11*2+2<<endl; 
}

Measured memory_bytes: 256
N=int(input())
BA=[]
for _ in range(N):
    A,B=map(int,input().split())
    BA.append([B,A])
BA.sort()
T=0
for i in range(N):
    T+=BA[i][1]
    if T>BA[i][0]:
        print("No")
        break;
else:
    print("Yes")


Measured memory_bytes: 38132
#<100q.順列全探索>
#<15>
from itertools import combinations
n = int(input())
town = []
for i in range(n):
    x, y = map(int,input().split())
    town.append((x,y))

ans = 0
for i, j in combinations(town, 2):
    
    ans += ((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2) ** (0.5)
print(2 * ans / n)
    
    


Measured memory_bytes: 9368
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()


# ===CODE===
def main():
    n, k = ns()
    pos = []
    for _ in range(k):
        l, r = ns()
        pos.append([l, r])

    imos = [0 for _ in range(n + 1)]
    imos[0] = 1
    imos[1] = -1
    total = 0

    for i in range(n):
        total += imos[i]
        total %= MOD
        if total > 0:
            for l, r in pos:
                if i + l <= n:
                    imos[i + l] += total
                    imos[i + l] %= MOD
                if i + r + 1 <= n:
                    imos[i + r + 1] -= total
                    imos[i + r + 1] %= MOD

    print(total % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86756
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int n, i, x, l, ans = 1,d=0;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> l;
		d += l;
		if (d <= x)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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]);
    System.out.println(a<=8 && b<=8 ?"Yay!":":(");
  }
}

Measured memory_bytes: 32760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    string S;
    cin>>S;
    int w;
    cin>>w;
    int a=S.size();
  	if(w!=1){
    for(int i=1; i<a+1; i++){
        if(i%w==1){
            cout<<S[i-1];
        }
    }
    }
  else{
rep(i,S.size()){
  cout<<S[i];
}
  }
    cout<<""<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;

ll dp[100][100001]={};
int main(){
    ll N,K;
    cin >> N >> K;
    ll a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    
    for(int i=0; i<N; i++){
        dp[i][0]=1;
    }
    
    for(int j=1; j<=min(K,a[0]); j++){
        dp[0][j]=1;
    }
    
    
    for(int i=1; i<N; i++){
        for(int j=1; j<=K; j++){
            if(j>a[i]){
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1-a[i]] +MOD;
            }else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            dp[i][j]%=MOD;
        }
    }
    
    cout<<dp[N-1][K]<<endl;
    return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI 3.141592653589793

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}
  cout << sum;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int n, i, j,ans = 0,count;
	cin >> n;
	for (i = 1; i <= n; i+=2) {
		count = 0;
		for (j = 1; j <= i; j++)
			if (i%j == 0)
				count++;
		if (count == 8)
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
@dp=Array.new(100000,0)
@dp[0]=1




@n,@m=gets.split.map(&:to_i)
unless @n==@m+1 || @n==@m || @n==@m-1
p 0
exit
end

if @n>=@m
for i in 1..@n+1
  @dp[i]=(@dp[i-1]*i)%(10**9+7)
end
n_pattern=@dp[@n]
#p n_pattern
m_pattern=@dp[@m]
else
for i in 1..@m+1
  @dp[i]=(@dp[i-1]*i)%(10**9+7)
end
n_pattern=@dp[@n]
#p n_pattern
m_pattern=@dp[@m]
end

#p m_pattern
if @n>@m
result=(n_pattern*m_pattern)%(10**9+7)
elsif @n==@m
result=(n_pattern*m_pattern*2)%(10**9+7)
else
result=(n_pattern*m_pattern)%(10**9+7)

end
p result


Measured memory_bytes: 15148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> m(n);
  for(int i = 0;i < n;i++)cin >> m[i];
  int res = 0;
  res = INT_MAX;
  for(int i  = 0;i < n;i++){
    int count = 0;
    while(m[i] % 2 == 0){
      count++;
      m[i] /= 2;
    }
    res = min(res,count);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.* ;
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // ??\?????????
       String str = br.readLine();  //???????????????
       int r = Integer.parseInt(str); //???????????°?????????
  	   int i = 1;
  	while ( r != 0 ) {  
  		System.out.println(  "Case " + i + ": " + r);
 		i++;
        str = br.readLine();  //???????????????
        r = Integer.parseInt(str); //???????????°?????????
  	
  	}	
  		
  	}
  }

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map <string, int> memo;
  for(int i = 0; i < n; ++i){
	string a;
	cin >> a;
	memo[a]+=1;
  }
  int maxa = 0;
  for (const auto x : memo){
	int b = x.second;
	if (b > maxa) maxa = b;
  }
	for (auto it = memo.begin(); it != memo.end(); ++it){
	if (it->second == maxa){
	cout << it->first << "\n";
	}
	}
return 0;
}


Measured memory_bytes: 23808
// ABC175A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	string S;
	cin >> S;

	if (S == "RRR") {
		cout << 3 << endl;
	} else if (S == "SRR" || S == "RRS") {
		cout << 2 << endl;
	} else if (S == "SSS") {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
import Data.Array.IO

rInt = read :: String -> Int

type Ary = IOArray Int Int

increment :: Ary -> Int -> IO ()
increment ary x = do
    v <- readArray ary x
    writeArray ary x (v + 1)

main = do
    n <- rInt <$> getLine
    a <- ((map rInt) . words) <$> getLine
    ary <- newArray (-1,100001) 0 :: IO Ary
    let a' = (map (+) [-1..1]) <*> a
    mapM_ (increment ary) a'
    list <- getElems ary
    print $ maximum list
    

Measured memory_bytes: 36476
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program { 
     static long[] stairs;
     const long beki = 1000000007;
     static void Main(string[] args) {
     //入力を受け取る 
     int[] NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
     int N =　NM[0];
     int M =　NM[1];
     stairs = new long[N+1];
     
     stairs[0] = 1;
     stairs[1] = 1;
     
     for(int i = 2; i < N+1 ;i++){
          stairs[i] = -1;
     }
      
     for(int i = 1; i < M+1 ;i++){
          var num = int.Parse(Console.ReadLine());
          stairs[num] = 0;
     } 
      Console.WriteLine(CountWay(N)); }
      
     static long CountWay(long dan){
         if(stairs[dan] != -1){
             return stairs[dan]%beki;
         }else{
             stairs[dan] = CountWay(dan-1)+CountWay(dan-2);
             return stairs[dan]%beki;
         }
     }
     }


Measured memory_bytes: 15444
#include <iostream>
#include <string.h>
using namespace std;


int main() {
	int k;
	cin >> k;
	char input[101];
	cin >> input;
	int length = strlen(input);
	if (length <= k) {
		for (int i = 0; i < length; ++i)
			cout << input[i];
	}
	else {
		for (int i = 0; i < k; ++i)
			cout << input[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N,vector<int>());
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  
  queue<int> seen;
  int dist[N];
  bool judge[N];
  for(int i=0;i<N;i++){
    dist[i]=0;
    judge[i]=false;
  }
  
  judge[0]=true;
  seen.push(0);
  int ct=0;
  
  while(!(seen.empty())){
    int S=seen.front();
    for(int i=0;i<G.at(S).size();i++){
      int nv=G.at(S).at(i);
      if(judge[nv]){
        continue;
      }
      dist[nv]=S;
      seen.push(nv);
      judge[nv]=true;
    }
    seen.pop();
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<dist[i]+1<<endl;
  }
}


Measured memory_bytes: 10372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using ll = long long;

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

    vector<ll> a(n);
    vector<ll> pos(n + 1);

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

    long long ans = 0;

    set<ll> s;
    s.insert(-1);
    s.insert(n);

    for (int i = 1; i <= n; ++i) {
        auto res = s.insert(pos[i]);

        ll l = *prev(res.first);
        ll r = *next(res.first);

        ans += (pos[i] - l) * (r - pos[i]) * i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12800
<?php
$a=array_fill(0,123456*2,1);

for($i=2;$i<=123456;$i++){
    for($j=$i*2;$j<=123456*2;$j+=$i){
        $a[$j]=0;
    }
}

while(1){
    fscanf(STDIN,"%d\n",$n);
    if($n==0)
        break;
    $sum=0;
    for($i=$n+1;$i<=2*$n;$i++){
        $sum+=$a[$i];
    }
    echo $sum."\n";
}

?>

Measured memory_bytes: 40244
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>

using namespace std;

char s[4];
int flag = 3;
string f[4] = {"YYMM", "MMYY", "AMBIGUOUS", "NA"};

int main()
{
    cin >> s;
    int prefix = (s[0] - '0') * 10 + (s[1] - '0');
    int suffix = (s[2] - '0') * 10 + (s[3] - '0');
    if (prefix >= 1 && prefix <= 12) flag = 1;
    if (suffix >= 1 && suffix <= 12)
    {
        if (flag == 1) flag = 2;
        else flag = 0;
    }
    cout << f[flag] << endl;
    return 0;
} 

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n+100);
    ll tot=0;
    rep(i,n)cin >> a[i];
    rep(i,n)tot+=a[i];
    bool ans = true;
    sort(a.begin(),a.end(),greater<int>());
    rep(i,m){
        if(a[i]*4*m < tot)ans=false;
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

signed main(){

  int n,k; cin >> n >> k;
  vector<int> d(k);
  for(int i = 0; i < k; i++){
    cin >> d[i];
  }

  while(1){
    bool judge = true;
    int t = n;
    while(t > 0){
      for(int i = 0; i < k; i++){
        if(t%10 == d[i]) judge = false;
      }
      t /= 10;
    }
    if(judge){
      cout << n << endl;
      return 0;
    }
    n++;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
cin >>N;
  
vl t(N+1);
  vl x(N+1);
  vl y(N+1);
  repl(i,1,N+1) {
    cin >>t.at(i)>>x.at(i)>>y.at(i);
  }
  t.at(0)=0;
  x.at(0)=0;
  y.at(0)=0;
  
  bool ans=true;
  
  ll data[N][4];
  rep(i,N) {
   
      data[i][0]=t.at(i+1)-t.at(i);
    data[i][1]=abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i));
    data[i][2]=data[i][0]%2;
    data[i][3]=data[i][1]%2;
  }
  
  
  rep(i,N) {
    if(data[i][0]<data[i][1]) {
      ans=false;
      break;
    }
    if((data[i][0]>=data[i][1]) &&(data[i][2]!=data[i][3])) {
      ans=false;
      break;
    }
  }
  
  
  if(ans) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}
      
  
 

Measured memory_bytes: 5760
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem104b(s))
}

fun problem104b(s: String): String {
    return if (s[0] == 'A' && s.drop(2).dropLast(1).count { it == 'C' } == 1 && s.filter { it in ('A'..'Z') }.length == 2) "AC" else "WA"
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

    int n;
    int count=0;
    string s;
    cin >> n >> s;

    for(int i=0;i<n/2;i++){
        if(s[i] == s[(n/2)+i]){
            count++;
        }
    }

    if(n <= 1 || n%2 == 1){
        count = -100;
    }
    
    if((n/2) == count){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

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

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif

	ll a,p;
	cin>>a>>p;

	ll ans = (3*a + p)/2;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans =  0;
		ans = a * x + b * y;
		if(ans > c * x * 2 + b * Math.max(0, (y - x))) {
			ans = c * x * 2 + b * Math.max(0, (y - x));
		}
		if(ans > c * y * 2 + a * Math.max(0, (x-y))) {
			ans = c * y * 2 + a * Math.max(0, (x-y));
		}
		System.out.println(ans);
	}
}


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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i <= n-1; i++) {
		cin >> a[i];
	}
	
	int count = 0;
	for (int i = 0; i <= n-1; i++) {
		int minj = i;
		for (int j = i; j <= n-1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			int tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			count++;
		}
	}
	
	for (int i = 0; i <= n-1; i++) {
		cout << a[i];
		if (i < n-1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
	cout << count << endl;
	return 0;
}


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

int a,b,i,j,m,n,t,s,k;

int main() {
	scanf("%d%d",&a,&b);
	k = 0;
	while(k!=999){
		k++;
		n += k;
		m += k;
		if(n>a&&m+k+1>b&&n-a==m+k+1-b){
			printf("%d",n-a);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n, D[MAX];
int rec(int,int);

int main(){
  int i, j, n, l, r, p, num, degree, child;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&num, &degree);
    for(j = 0; j < degree; j++){
      scanf("%d", &child);
      if(j == 0) T[num].left = child;
      else T[l].right =child;
      l = child;
      T[child].parent = num;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == -1) r = i;
  }
  rec(r,0);
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i, T[i].parent, D[i]);
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else printf("internal node, [");
    p = T[i].left;
    for(j = 0; p != -1; j++, p = T[p].right){
      if(j) printf(", ");
      printf("%d", p);
    }
    printf("]\n");
  }

  return 0;
}

int rec(int r, int p){
  D[r] = p;
  if(T[r].right != -1) rec(T[r].right,p);
  if(T[r].left != -1) rec(T[r].left,p+1);
}

Measured memory_bytes: 5296
#include <stdio.h>
int main(){
    int N,T,c[999]={},t[999]={},i,m=0,o= 0,temp;
    scanf("%d%d",&N,&T);
    for(i = 0;i<N;i++){
        scanf("%d%d",&c[i],&t[i]);
    }
    temp = c[0];
    while(m < N){
        if(t[m] <= T){
            o = 1;
            if(c[m] <=temp){
                temp = c[m];
            }
        }
        m++;
    }
    if(o)
    printf("%d",temp);
    else
    puts("TLE");
    
    return 0;
}

Measured memory_bytes: 128
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

x,k,d = MI()
if x<0:
  x = -x
q = x//d
if q <= k:
  if (k - q)%2 == 1:
    print(min(x%d + d,abs(x%d - d)))
  else:
    print(x%d)
else:
  print(x-d*k)

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

#define int long long

using namespace std;

unsigned euclidean_gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

signed main(void){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=euclidean_gcd(a[0],a[1]);
	for(int i=0;i<n;i++){
		ans=euclidean_gcd(ans,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a, b,c) {

		int q[350];
		for (int i = 0;i < a + b + c;i++)q[i] = 2;
		int n;
		cin >> n;
		int z = 0;
		int ls[1200][5];

		for (int i = 0;i < n;i++) {
			int d, e, f, g;
			cin >> d >> e >> f >> g;
			if (g == 0) {  
				ls[z][0] = d;
				ls[z][1] = e;
				ls[z][2] = f;
				z++;
			}

			else {
				q[d - 1] = 1;
				q[e - 1] = 1;
				q[f - 1] = 1;
			}
		}

		for (int i = 0;i < z;i++) {
			int d=0, e=0, f=0;
			if (q[ls[i][0] - 1] == 1)d = 1;
			if (q[ls[i][1] - 1] == 1)e = 1;
			if (q[ls[i][2] - 1] == 1)f = 1;

			if (d == 1 && e == 1) {
				q[ls[i][2] - 1] = 0;
			}
			if (d == 1 && f == 1) {
				q[ls[i][1] - 1] = 0;
			}
			if (e == 1 && f == 1) {
				q[ls[i][0] - 1] = 0;
			}
		}

		for (int i = 0;i < a+b+c;i++) {
			cout << q[i] << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3100
package main

import "fmt"

func main() {
	var n, a, b, i int
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	x := make([]int, n)
	for i=0; i<n; i++ {
		fmt.Scan(&x[i])
	}
	var result int = 0
	for i=1; i<n; i++ {
		if a * (x[i] - x[i-1]) > b {
			result += b
		} else {
			result += a * (x[i] - x[i-1])
		}
	}
	fmt.Printf("%v\n", result)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using i64 = long long;

template <typename T, typename U, typename V>
constexpr auto pow(T x_, U n_, V mod_) {
    std::common_type_t<T, U, V> ret = 1, x = x_, n = n_, mod = mod_;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    constexpr i64 mod = 998244353;
    int n;
    std::cin >> n;
    std::vector<int> a(n), d(n);
    for (int i = 0; i < n; i++) {
        std::cin >> d[i];
        a[d[i]]++;
    }

    i64 ret = d[0] == 0 && a[0] == 1;
    int max = *std::max_element(d.begin(), d.end());
    for (int i = 1; i <= max; i++) {
        ret = ret * pow(a[i - 1], a[i], mod) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main()
{
  string txt, pat;
 
  cin >> txt >> pat;  if(txt[0] == pat[2] && txt[1] == pat[1] && txt[2] == pat[0]){
    cout << "YES" << endl;
  }else cout << "NO" << endl;
 
  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
const int maxn = int(1e5)+5;
 
int sz[maxn], P[maxn];
vector<int> graph[maxn];
 
void dfs(int node, int par)
{
	sz[node] = 1, P[node] = par;
	for(auto it: graph[node])
	{
		if(it != par)
		{
			dfs(it, node);
			sz[node] += sz[it];
		}
	}
}
 
int main(void)
{
	int n, a, b;
	scanf("%d", &n);
 
	for(int i = 1;i < n;i++)
	{
		scanf("%d%d", &a, &b);
		a--, b--;
		graph[a].push_back(b), graph[b].push_back(a);
	}
 
	dfs(0, -1);
 
	int cur = n-1;
	vector<int> path;
	while(cur != -1)
	{
		path.push_back(cur);
		cur = P[cur];
	}
	reverse(path.begin(), path.end());
 
	int patha = 0, pathb = int(path.size())-1, tot = 0, aa = -1, bb = -1;
	while(patha < pathb-1)
	{
		if(tot%2) pathb--, bb--;
		else patha++, aa--;
		tot++;
	}


	int meet = pathb;
 
	aa += n-sz[path[meet]], bb += sz[path[meet]];
	while(true)
	{
		if(tot%2)
		{
			if(bb <= 0)
			{
				printf("Fennec\n");
				exit(0);
			}
			bb--;
		}
		else
		{
			if(aa <= 0)
			{
				printf("Snuke\n");
				exit(0);
			}
			aa--;
		}
		tot++;
	}
}


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

using namespace std;

int const maxn = 2e5 + 5;
int x[maxn], y[maxn];
char r[maxn];
int inf = 1e9;
vector < pair < int, char > > ask_x[maxn], ask_y[maxn];
map < int, int > lst, was;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = inf;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i] >> r[i];
    for (int i = 1; i <= n; ++i) {
        if (r[i] == 'U' || r[i] == 'D') ask_x[x[i]].push_back({y[i], r[i]});
        else ask_y[y[i]].push_back({x[i], r[i]});
    }
    for (int i = 0; i < maxn; ++i) {
        sort(ask_x[i].begin(), ask_x[i].end());
        for (int j = 1; j < (int)ask_x[i].size(); ++j) {
            if (ask_x[i][j].second == 'D' && ask_x[i][j - 1].second == 'U') ans = min(ans, (ask_x[i][j].first - ask_x[i][j - 1].first) * 5);
        }
        ask_x[i] = ask_y[i];
        sort(ask_x[i].begin(), ask_x[i].end());
        for (int j = 1; j < (int)ask_x[i].size(); ++j) {
            if (ask_x[i][j].second == 'L' && ask_x[i][j - 1].second == 'R') ans = min(ans, (ask_x[i][j].first - ask_x[i][j - 1].first) * 5);
        }
    }
    vector < int > grra;
    for (int i = 1; i <= n; ++i) grra.push_back(i);
    sort(grra.begin(), grra.end(), [](int s, int d) {
        return x[s] < x[d];
    });
    for (auto elem : grra) {
        if (r[elem] == 'R') lst[x[elem] + y[elem]] = x[elem], was[x[elem] - y[elem]] = x[elem];
        if (r[elem] == 'U') {
            if (lst.find(x[elem] + y[elem]) != lst.end()) ans = min(ans, (x[elem] - lst[x[elem] + y[elem]]) * 10);
        }
        if (r[elem] == 'D') {
            if (was.find(x[elem] - y[elem]) != was.end()) ans = min(ans, (x[elem] - was[x[elem] - y[elem]]) * 10);
        }
    }
    lst.clear(), was.clear();
    reverse(grra.begin(), grra.end());
    for (auto elem : grra) {
        if (r[elem] == 'L') lst[x[elem] + y[elem]] = x[elem], was[x[elem] - y[elem]] = x[elem];
        if (r[elem] == 'D') {
            if (lst.find(x[elem] + y[elem]) != lst.end()) ans = min(ans, (-x[elem] + lst[x[elem] + y[elem]]) * 10);
        }
        if (r[elem] == 'U') {
            if (was.find(x[elem] - y[elem]) != was.end()) ans = min(ans, (-x[elem] + was[x[elem] - y[elem]]) * 10);
        }
    }
    if (ans == inf) cout << "SAFE";
    else cout << ans;
    return 0;
}



Measured memory_bytes: 30980
import java.util.*;

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

        System.out.println(solve(L, R, d));
    }

    private static int solve(int l, int r, int d) {
        int base = r / d - l / d;
        if (l % d == 0) base++;
        return base;
    }
}


Measured memory_bytes: 35512
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int res = 0;
    rep(i, s.sz)if(s[i] != t[i])res++;
    cout << res << endl;
}



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

int main(){
  int N;
  cin>>N;
  int n;
  for( n=N;1;n++){
  int a=n/100;
    int b=(n-a*100)/10;
    int c=(n-a*100-10*b);
    if(a==b && b==c) break;
    
  }
  
  cout<<n<<endl;
  return 0;}

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

using namespace std;

struct pct {
    int x, y;
};

double dist(pct &A, pct &B) {
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}

int main() {
    int n;
    cin >> n;
    vector <pct> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    vector <vector <double> > d(n, vector <double> (n));
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            d[i][j] = d[j][i] = dist(p[i], p[j]);
        }
    }

    vector <int> idx(n);
    for (int i = 0; i < n; i++) {
        idx[i] = i;
    }

    double sum = 0;

    do {
        for (int i = 0; i < n - 1; i++) {
            sum += d[idx[i]][idx[i + 1]];
        }
    }
    while (next_permutation(idx.begin(), idx.end()));

    int fact = 1;
    while (n > 1) {
        fact *= n;
        n--;
    }
    cout << fixed << setprecision(10) << sum / fact;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
//const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1;
    bool ok = true;
    rep(i, n){
        string anss = to_string(ans);
        string next = to_string(a[i]);
        if(a[i] == 0){
            ans = 0;
            ok = true;
            break;
        }
        //cout << anss.size() + next.size() << endl;
        if(anss.size() + next.size() - 2 >= 18){
            if(ans * a[i] != 1e18){
                ok = false;
            } else {
                ans *= a[i];
            }
        } else {
            if(ans * a[i] > (ll)1e18){
                ok = false;
            }
            ans *= a[i];
        }
    }
    if(ok){
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


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

int main() {
  string x;
  string ans ="Yes";
  cin >> x;
  int N = x.size();
  int m = N/2;
  if (m > 0) {
    for (int i = 0; i < m; i++) {
      if (x.at(2*i) =='L' || x.at(2*i+1) =='R') {
        ans = "No";
        break;
      }
    }
  }
  if (N % 2 != 0 && x.at(N-1) =='L') {
      ans = "No";
  }
  cout << ans << endl;
}



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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}



signed main(void){
    int n;cin>>n;
    vvint a(2,vint(n));
    rep(i,2){
        rep(j,n)cin>>a[i][j];
    }

    vvint dp(2,vint(n));
    dp[0][0]=a[0][0];
    dp[1][0]=a[0][0]+a[1][0];
    rep(i,n-1)dp[0][i+1]=a[0][i+1]+dp[0][i];
    
    rep(i,n-1){
        dp[1][i+1]=a[1][i+1]+max(dp[1][i], dp[0][i+1]);
    }
    cout << dp[1][n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,k,c = map(int,input().split())
    s = input()

    cuml = [0] * (n + 1)
    cumr = [0] * (n + 1)
    idx = []

    for i in range(n):
        if s[i] == 'o':
            idx.append(i)
            cuml[i + 1] = cuml[max(i - c,0)] + 1
        else:
            cuml[i + 1] = cuml[i]
    
    for i in range(n - 1,-1,-1):
        if s[i] == 'o':
            cumr[i] = cumr[min(i + c + 1,n)] + 1
        else:
            cumr[i] = cumr[i + 1]
    
    ans = []
    #print(idx,cuml,cumr)
    if c != 0:
        for i in idx:
            flag = False
            for j in range(i - c,i):
                if cuml[max(j + 1,0)] + cumr[min(j + c + 1,n)] >= k:
                    flag = True
                    break

            if flag:
                continue
            else:
                ans.append(i + 1)
    else:
        for i in idx:
            if cuml[i] + cumr[i + 1] < k:
                ans.append(i + 1)
    
    for i in range(len(ans)):
        print(ans[i])
 
if __name__ =='__main__':
    main()   


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

using namespace std;

int recurse(int i,int j,vector<vector<int>> &dp,string &s,string &t)
{
    if(i ==0 || j == 0) return 0;
    else
    {
        if(dp[i][j] != -1) return dp[i][j];
        else
        {
            if(s[i-1] == t[j-1]) dp[i][j] = recurse(i-1,j-1,dp,s,t)+1;
            else dp[i][j] = max(recurse(i-1,j,dp,s,t) , recurse(i,j-1,dp,s,t));
            return dp[i][j];
        }
    }
}


int main(int argc, char const *argv[])
{
    string s , t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    vector<vector<int>> dp(n+1,vector<int>(m+1,-1));
    dp[n][m]= recurse(n,m,dp,s,t) ;


    int i = n;
    int j = m;
    int k = 1;
    char lcs[dp[n][m] +1];
    lcs[dp[n][m]] = '\0';
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            lcs[dp[n][m] - k] = s[i-1];
            k++;     
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1]) i--;
            else j--;
        }
    }
    cout << lcs;
    return 0;
}


Measured memory_bytes: 39016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,i=0,d;
  cin>>n;
  ll a[n+1]={};
  while(i<n-1)
  {
    cin>>d;
    a[d]++;
    i++;
  }
  i=1;
  while(i<=n)
  {
    deb(a[i]);
    i++;
  }
}

Measured memory_bytes: 5216
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=b*2){
        cout<<a-b*2<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;

const int maxN = 1 << 11;

char in[2][maxN];

int main()
{
	int n, pref = 0;
	scanf ("%d", &n);
	FOR(i, 1, n+1)
	{
		int a;
		scanf ("%d", &a);
		if (a == pref+1)
			pref++;
	}
	
	printf("%d", pref == 0 ? -1 : n-pref);
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B;

int main(){
    cin>>A>>B;

    if(B%A==0){
        cout<<A+B<<endl;
    }else{
        cout<<B-A<<endl;
    }
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int cnt[200200];
int main() {
	int n,k;
	scanf("%d%d", &n, &k);
	FOR(i,n) {
		int a;
		scanf("%d", &a);
		cnt[a]++;
	}
	sort(cnt,cnt+n+1);
	int res=0;
	FORI(i,n-k) res+=cnt[i];
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 1024
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>


#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

mt19937 mrand(random_device{} ());
int rnd() {
	return mrand();
}

const int maxn = 1e5 + 7;

vector<int> getFactor(int x){
	vector<int> s;
	if (x < 0){
		s.push_back(-1);
		x *= -1;
	}
	for (int i = 2; i * i <= 1e8; i++){
		if (x % i == 0){
			int cnt = 0;
			while (x % i == 0){
				cnt++;
				x /= i;
			}
			if (cnt & 1)
				s.push_back(i);
		}
	}
	if (x > 1)
		s.push_back(x);
	return s;
}

vector<int> compress(vector<vector<int> > s){
	int n = s.size();
	vector<vector<int> > ss(n);
	// print(s[0]);
	for (int i = 0; i < n; i++){
		sort(s[i].begin(), s[i].end());
		for (int j : s[i])
			ss[i].push_back(j);
	}
	// print(s[0]);
	sort(ss.begin(), ss.end());
	ss.resize(unique(ss.begin(), ss.end()) - ss.begin());
	// cout << ss.size() << endl;
	vector<int> answer(n);
	for (int i = 0; i < n; i++){
		// print(s[i]);
		answer[i] = lower_bound(ss.begin(), ss.end(), s[i]) - ss.begin();
	}
	return answer;
}

int main(){
    srand(17);
 	ios_base::sync_with_stdio(0);
 	int n;
 	cin >> n;
 	vector<pair<int, int> > s(n);
 	for (int i = 0; i < n; i++){
 		cin >> s[i].first;
 		s[i].second = i;
 	}
 	sort(s.begin(), s.end());
 	vector<int> answer(n);
 	for (int i = 0; i < n - 1; i++)
 		answer[s[i].second] = s[n - 1].first;
 	answer[s[n - 1].second] = s[n - 2].first;	
 	print(answer);
    return 0;
}

Measured memory_bytes: 4736