akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, cnt = 0, ans = 0, tmp = 0;

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int n,x,i,tmp,flag=0,count=0,a[110]={};
    scanf("%d %d",&n,&x);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    do{ flag=0;
        for(i=0; i<n-1; i++){
            if(a[i]>a[i+1]){
                tmp=a[i];
                a[i]=a[i+1];
                a[i+1]=tmp;
                flag=1;
            }
        }
    }while(flag==1);
    i=0;
    flag=0;
    while(x-a[i]>=0){
        x-=a[i];
        count++;
        i++;
        flag=1;
        if(i>=n){
            flag=2;
            break;
        }
    }
    if(flag==2 && x>0){
        printf("%d",n-1);
        return 0;
    }
    if(flag==2){
        printf("%d",n);
        return 0;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W,N;
LL Sr,Sc;
string S,T;

string ans = "NO";

void solve(){
	map<char,LL> num_T,num_A;
	//高橋くんが左に落としにいくとき
	int start_c = Sc;
	for(int i=0;i<N;i++){
		if(S[i]=='L'){
			start_c--;
			if(start_c<=0) return;
		}
		if(T[i]=='R'){
			if(start_c<=W-1)start_c++;
		}
	}
	//右に落としにいくとき
	start_c = Sc;
	for(int i=0;i<N;i++){
		if(S[i]=='R'){
			start_c++;
			if(start_c>W) return;
		}
		if(T[i]=='L'){
			if(start_c>=2)start_c--;
		}
	}
	//上に落としにいくとき
	int start_r = Sr;
	for(int i=0;i<N;i++){
		if(S[i]=='U'){
			start_r--;
			if(start_r<=0) return;
		}
		if(T[i]=='D'){
			if(start_r<=H-1)start_r++;
		}
	}
	//下に落としにいくとき
	start_r = Sr;
	for(int i=0;i<N;i++){
		if(S[i]=='D'){
			start_r++;
			if(start_r>H) return;
		}
		if(T[i]=='U'){
			if(start_r>=2)start_r--;
		}
	}
	ans = "YES";
}
 
int main(){
    cin >> H >> W >> N;
    cin >> Sr >> Sc;
    cin >> S;
    cin >> T;

    solve();

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

Measured memory_bytes: 776
def lower_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m][2] < v then l = m
    else r = m
    end
  end
  l + 1
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  era = []
  n.times do
    name, ey, wy = gets.split
    era << [name, ey.to_i, wy.to_i]
  end
  era.sort_by! { |e| e[2] }
  q.times do
    y = gets.to_i
    x = lower_bound(era, y)
    if x != n && era[x][2] - y < era[x][1]
        puts "#{era[x][0]} #{era[x][1] - (era[x][2] - y)}"
    else puts "Unknown"
    end
  end
end

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

using namespace std;

vector<vector<int>> n;

void allcombination(int size, vector<int> m)
{
    if (size == 0)
    {
        n.push_back(m);
        return;
    }

    for (int i = 0; i < 2; i++)
    {
        m.push_back(i);
        allcombination(size - 1, m);
        m.pop_back();
    }
}

int main()
{
    vector<int> m;

    long long int sum = 0;
    string S;
    cin >> S;
    int size = S.size();
    long long int num;

    allcombination(size - 1, m);
    for (int i = 0; i < n.size(); i++)
    {
        num = S[0] - '0';
        for (int j = 0; j < n.at(0).size(); j++)
        {
            if (n.at(i).at(j) == 0)
                num = num * 10 + (S[j + 1] - '0');
            else
            {
                sum += num;
                num = S[j + 1] - '0';
            }
        }
        sum += num;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  for(char c='a';c<='z';c++){
    bool found = false;
    for(int i=0;i<s.size();i++){
      if(c==s.at(i)) {
        found = true;
        break;
      }
    }
    if(!found){
      cout << c << endl;
      return 0;
    }
  }

  puts("None");
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int T;
    cin >> T;
    for(int loop = 0; loop < T; ++loop){
        int N;
        cin >> N;
        vector<P> NL, NR;
        ll ans = 0;
        for(int i = 0; i < N; ++i){
            int K, L, R;
            cin >> K >> L >> R;
            int X = min(L, R);
            ans += X;
            L -= X, R -= X;
            if(L > 0)   NL.emplace_back(K, L);
            else    NR.emplace_back(N - K, R);
        }
        auto calc = [&](vector<P>& data) -> ll {
            ll res = 0;
            int n = data.size();
            vector<vector<int>> table(n + 1);
            for(int i = 0; i < n; ++i){
                int k = data[i].first, val = data[i].second;
                chmin(k, n);
                table[k].emplace_back(val);
            }
            priority_queue<int> que;
            for(int i = n; i >= 1; --i){
                for(int x : table[i])   que.emplace(x);
                if(!que.empty()){
                    res += que.top();
                    que.pop();
                }
            }
            return res;
        };
        ans += calc(NL);
        ans += calc(NR);
        cout << ans << '\n';
    }
}

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

int main() {
    string s;cin>>s;
    int n;
    n=s.size();
    rep(i,n)cout<<'x';
    cout<<endl;
	return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		
		String str = cin.next();
		reverse(str);
		
	}
	
	private static void reverse(String str){
		int len = str.length();
		for (int i = 0; i < len; i++){
			System.out.print(str.charAt(len - i - 1));
		}
		System.out.println();
	}
}

Measured memory_bytes: 26076
#include<stdio.h>
#include<string.h>
int main(){
	int n;
	scanf("%d",&n);
	for(int j=0;j<n;j++){
		char pro[1000];
		scanf(" %s",pro);
		int num,b[1000]={};
		num=strlen(pro);
		
		int a[1000]={};
		for(int i=0;pro[i]!='\0';i++){
			a[i]=pro[i]-'0';
		}
		int ans=0,count=0;
		for(int i=0;i<1000;i++)ans+=a[i];
		while(ans>9){
			ans-=9;
			count++;
		}
		int x;
		x=(num-1+count);
		if(x%2==0)printf("Audrey wins.\n");
		else printf("Fabre wins.\n");
	}
	return 0;
}

Measured memory_bytes: 2472
# B - Toll Gates
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
tmp = 0
for i in range(M):
    if X < A[i]:
        tmp = i
        break
    else:
        pass
if tmp > M/2:
    print(M-tmp)
else:
    print(tmp)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long long w;
	int n;
	long long v[100];
} list_t;

static int cmp(const void *a, const void *b);
static long long calc(int i, int j, int k, int l, list_t list[4]);

int main(int argc, char *argv[])
{
	int i, j, k, l, N, n = 0;
	list_t list[4] = {{0}};
	long long max = 0, v, W, w;
	scanf("%d %lld", &N, &W);
	for ( i = 0; i < N; i++ ){
		long long w, v;
		scanf("%lld %lld", &w, &v);
		for ( j = 0; j < n; j++ ){
			if ( list[j].w == w ){
				list[j].v[list[j].n] = v;
				list[j].w = w;
				list[j].n++;
				break;
			}
		}
		if ( j == n ){
			list[n].v[0] = v;
			list[n].w = w;
			list[n].n++;
			n++;
		}
	}

	for ( i = 0; i < n; i++ ){
		qsort(list[i].v, list[i].n, sizeof(long long), cmp);
	}

	for ( i = 0; i <= N; i++ ){
		if ( i > list[0].n ){
			break;
		}
		for ( j = 0; i+j <= N; j++ ){
			if ( j > list[1].n ){
				break;
			}
			for ( k = 0; i+j+k <= N; k++ ){
				if ( k > list[2].n ){
					break;
				}
				for ( l = 0; i+j+k+l <= N; l++ ){
					if ( l > list[3].n ){
						break;
					}
					w = i*list[0].w + j*list[1].w + k*list[2].w + l*list[3].w;
					if ( w > W ){
						continue;
					}
					v = calc(i, j, k, l, list);
					if ( v > max ){
						max = v;
					}
				}
			}
		}
	}
	printf("%lld\n", max);

	return 0;
}

static long long calc(int i, int j, int k, int l, list_t list[4])
{
	long long v = 0;
	int x;
	for ( x = 0; x < i; x++ ){
		v += list[0].v[x];
	}
	for ( x = 0; x < j; x++ ){
		v += list[1].v[x];
	}
	for ( x = 0; x < k; x++ ){
		v += list[2].v[x];
	}
	for ( x = 0; x < l; x++ ){
		v += list[3].v[x];
	}
	return v;
}

static int cmp(const void *a, const void *b)
{
	return *((long long *)b) - *((long long *)a);
}


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

using namespace std;

using ll = long long;

ll Divide(ll h1, ll w1, ll h, ll w) {
    ll s1 = h1 * w1, s2 = 0, s3 = 0, min_s = h * w + h1 * w1;

    ll h2 = h / 2, h3 = h - h2;
    s2 = h2 * w;
    s3 = h3 * w;
    min_s = min(min_s, max({s1, s2, s3}) - min({s1, s2, s3}));

    ll w2 = w / 2, w3 = w - w2;
    s2 = h * w2;
    s3 = h * w3;
    min_s = min(min_s, max({s1, s2, s3}) - min({s1, s2, s3}));

    return min_s;
}

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

    ll h, w;
    cin >> h >> w;

    ll min_s = h * w;
    for (int i = 0; i + 1 < h; ++i)
        min_s = min(min_s, Divide(i + 1, w, h - i - 1, w));

    for (int i = 0; i + 1 < w; ++i)
        min_s = min(min_s, Divide(h, i + 1, h, w - i - 1));

    cout << min_s << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
     # print(i,j,k)
      if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
        if 2*max(l[i], l[j], l[k]) < l[i]+l[j]+l[k]:
          #print(i,j,k)
          ans += 1
print(ans)

Measured memory_bytes: 9196
a=int(input())
l=[[0]*10 for _ in range(10)]
l[0]=[1]*10
for i in range(1,10):
    for j in range(10):
        if j!=9 and j!=0:
            l[i][j]=l[i-1][j-1]+l[i-1][j]+l[i-1][j+1]
        elif j==0:
            l[i][j]=l[i-1][j]+l[i-1][j+1]
        else:
            l[i][j]=l[i-1][j-1]+l[i-1][j]
count=0
i=0
while count<a:
    count+=sum(l[i])-l[i][0]
    i+=1
i-=1
count-=sum(l[i])-l[i][0]
j=1
while count<a:
    count+=l[i][j]
    j+=1
j-=1
count-=l[i][j]
k=a-count
ll=[j]
jj=j
for ii in range(i):
    if jj!=0:
        jj-=1
        while k>0:
            k-=l[i-ii-1][jj]
            jj+=1
        jj-=1
        k+=l[i-ii-1][jj]
        ll.append(jj)
    else:
        while k>0:
            k-=l[i-ii-1][jj]
            jj+=1
        jj-=1
        k+=l[i-ii-1][jj]
        ll.append(jj)
        
for jjj in ll:
    print(jjj,end='')
    

Measured memory_bytes: 3188
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

class solver {
public:
	int D;
	vector<int> c;
	vector<vector<int>> s;

	void init() {
		cin >> D;
		c.resize(26);
		s.resize(D);
		rep(i, 26) {
			cin >> c[i];
		}
		rep(j, D) {
			s[j].resize(26);
			rep(i, 26) {
				cin >> s[j][i];
			}
		}
	}

	vector<int> calc(const vector<int>& t) const {
		vector<int> last(26);
		auto down = [&last, this](int d) {
			d++;
			int v = 0;
			rep(i, 26) {
				v += c[i] * (d - last[i]);
			}
			return v;
		};
		int N = t.size();
		vector<int> v(N);
		rep(i, N) {
			if (i > 0)
				v[i] = v[i - 1];
			v[i] += s[i][t[i]];
			last[t[i]] = i + 1;
			v[i] -= down(i);
		}
		return v;
	}
};

int main()
{
	solver solver;
	solver.init();
	vector<int> t(solver.D);
	rep(i, solver.D) {
		cin >> t[i];
		t[i]--;
	}
	auto ans = solver.calc(t);
	for (auto v : ans) {
		cout << v << endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll> h (n);
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    h.at(i) = a;
  }
  ll ma = 0;
  string ans = "Yes";
  for(int i=0; i<n-1; i++){
    if(h.at(i) > h.at(i+1) && h.at(i) > ma){
      ma = h.at(i);
    }
    if(ma > 0 && ma - h.at(i) >= 2){
      ans = "No";
    }
  }
  if(ma > 0 && ma - h.at(n-1) >= 2){
    ans = "No";
  }
  cout << ans << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var C = Console.ReadLine().First();
            var i = (int)C;

            Console.WriteLine((char)(i+1));
        }
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    bool ac[n+1];
    fill(ac,ac+n+1,false);
    int wa[n+1];
    fill(wa,wa+n+1,0);
    int ans = 0;
    for(int i=0; i<m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            if(!ac[p]){
                ans++;
                ac[p] = true;
            }
        }
        else{
            if(!ac[p]){
                wa[p]++;
            }
        }
    }
    int wasum = 0;
    for(int i=1; i<=n; i++){
        if(ac[i]){
            wasum += wa[i];
        }
    }
    cout << ans << ' ' << wasum << endl;

    return 0;
}


Measured memory_bytes: 768
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
            	ans[v]+=1
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //var length = c2i(RL());
            var rl = RL();
            var rl1 = RL();

            var ret=rl1.StartsWith(rl);
            if (ret)
            {
                ret = rl.Length + 1 == rl1.Length;
            }

            Console.WriteLine(bool2ret(ret));
            //Console.ReadLine();
        
        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 26168
ans=10**7
n,m=map(int,input().split())
dp=[10**18]*(2**n)
dp[0]=0
prices=[]
for i in  range(m):
    a,s=map(int,input().split())
    prices.append(a)
    f=0
    for k in map(int,input().split()):
        f+=2**(k-1)
    for j in range(2**n-1,-1,-1):
        dp[j|f]=min(dp[j]+a,dp[j|f])
print(-1 if dp[-1]==10**18 else dp[-1])

Measured memory_bytes: 75740
#!/usr/bin/env python3

import sys

def main():
    h, n = [int(x) for x in sys.stdin.readline().split()]
    atks = [int(x) for x in sys.stdin.readline().split()]

    if sum(atks) >= h:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif
//
//    int tc; cin >> tc;
//    TC(tc) solve();
	int n;
	cin >> n;
	vl a(n);
	READ(a);
	sort(a.rbegin(), a.rend());
	ll sum=a[0]+a[1], ans=(a[0]*a[1])%MOD;
//    ll sum2=(sum*sum)%MOD, k=0;
//    REP(i,n) {
//    	a[i]%=MOD;
//    	int aa=(a[i]*a[i])%MOD;
//    	k=(k+aa)%MOD;
//	}
//	cout << sum2 << " " << k << endl;
	FOR(i,2,n){
		ans=(ans+(sum*a[i]))%MOD;
		sum=(sum+a[i])%MOD;
	}
	OUT((ans%MOD));
    return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, res;
ll A[100000], B[100000], S, D[100000];
priority_queue<ll>q;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A[i];
		S += A[i];
	}
	for (int i = 0; i != N; ++i) {
		cin >> B[i];
		S -= B[i];
	}
	if (S < 0) {
		cout << -1 << endl;
		return 0;
	}
	S = 0;
	for (int i = 0; i != N; ++i) {
		if (A[i] - B[i] < 0) {
			S += A[i] - B[i];
			++res;
		}
		else
			q.push(A[i] - B[i]);
	}
	while (S < 0) {
		++res;
		S += q.top();
		q.pop();
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2936
require 'prime'
loop do
  m, a, b = gets.split.map(&:to_i)
  break if m == 0
  ans = [0, 0]
  prod = 0
  Prime.each.lazy.take_while{ |p| p <= Math.sqrt(100000).to_i }.each do |p|
    q = Prime.each.lazy.drop_while{ |q| q < p  }
                       .take_while{ |q| p * q <= m }
                       .take_while{ |q| a * q <= b * p }.to_a.last
    if q && prod < p * q
      ans = [p, q]
      prod = p * q
    end
  end
  puts ans * ' '
end

Measured memory_bytes: 10016
#include <stdio.h>

int main(void) {
    int n, a, b;
    scanf ("%d", &a);
    n =  1000 - (a % 1000);
    if (n == 1000) {
        printf ("0");
        return 0;
    }
    printf ("%d", n);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

void solve(int n) {
	int ans = INF;
	string s;
	vector<string> ss,vs;
	vvi vv(n, vi(n, 0));
	rep(i, n) {
		cin >> s;
		ss.push_back(s);
	}
	rep(i, n) {
		rep(j, n) {
			if (i != j) {
				if (ss[i].find(ss[j]) != std::string::npos) {
					bool sw = true;
					rep(k, vs.size()) {
						if (vs[k] == ss[j])sw = false;
					}
					if (sw)vs.push_back(ss[j]);
				}
			}
		}
	}
	rep(i, vs.size()) {
		rep(j, ss.size()) {
			if (vs[i] == ss[j]) {
				ss.erase(ss.begin() + j);
				n--;
				break;
			}
		}
	}

	rep(i, n) {
		rep(j, n) {
			if (i != j) {
				int t = 0;
				rep(k, min(ss[i].size(), ss[j].size())) {
					if (ss[i].substr(ss[i].size() - k - 1, k + 1) == ss[j].substr(0, k + 1))t = k + 1;
				}
				vv[i][j] = ss[j].size() - t;
			}
		}
	}
	//bitdp
	vvi dp(pow(2, n), vi(n, INF));
	rep(i, n) {
		dp[1 << i][i] = ss[i].size();
	}
	rep(i, pow(2, n)) {
		rep(j, n){
			rep(k, n) {
				if (!((1 << k) & i)) {
					dp[(1 << k) + i][k] = min(dp[(1 << k) + i][k], dp[i][j] + vv[j][k]);
				}
			}
		}
	}
	cout << *min_element(all(dp.back())) << endl;
}

int main() {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
}



Measured memory_bytes: 4580
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    cout << (intl)pow(n,3) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		List<Integer> v = Arrays.stream(sc.nextLine().split(" ",0)).map(Integer::valueOf).collect(Collectors.toList());
		List<Integer> c = Arrays.stream(sc.nextLine().split(" ",0)).map(Integer::valueOf).collect(Collectors.toList());
		int max = 0;
		for (int i=0;i<N;i++) {
			int d = v.get(i) - c.get(i);
			if (d > 0) {
				max += d;
			}
		}
		System.out.println(max);
		sc.close();
	}

}

Measured memory_bytes: 28756
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int n, k, x, y;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		int sum = 0;
		if (n - k > 0) 
			sum = k * x + y * (n - k);
		else
			sum = n * x;
		System.out.println(sum);
	}
}

Measured memory_bytes: 9676
#include <stdio.h>

int main(){


        int g;
        scanf("%d",&g);
        switch (g){
                case 0: printf("0\n"); break;
                case 1: printf("1\n"); break;
                case 10: printf("1\n"); break;
                case 11: printf("2\n"); break;
                case 100: printf("1\n"); break;
                case 101: printf("2\n"); break;
                case 110: printf("2\n"); break;
                case 111: printf("3\n"); break;
                default: break;
        }
        return 0;

}

Measured memory_bytes: 128
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=set(map(int,input().split()))
  for i in range(N+1):
    if X-i not in p:
      print(X-i)
      break
    elif X+i not in p:
      print(X+i)
      break

Measured memory_bytes: 9112
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n),b(n,0);
  rep(i,n){cin>>a[i];b[i]=a[i];}
  sort(all(b));
  ll k=b[n-1];
  rep(i,n){
    if(a[i]==k){cout<<b[n-2]<<endl;}
    else cout<<k<<endl;}
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			int n = s.length();
			int ioi = 0,joi = 0;
			for(int i=0;i<n-3;i++) {
				String t = s.substring(i, i+3);
				if (t.equals("JOI")) {
					joi++;
				}
				if (t.equals("IOI")) {
					ioi++;
				}
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 23944
#include<stdio.h>

int main(void){
    int N;
    int d[100]={};
    int max =1;
    int maxi = 0;
    int num = 0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
    }
    while(1){
        max = d[0];
        for(int i=0;i<N;i++){
            if(max<=d[i]){
                max = d[i];
                maxi = i;
            }
        }
        for(int i = 0;i<N;i++){
            if(max == d[i]){
                d[i] = 0;
            }
        }
        if(max==0){
            printf("%d",num);
            return 0;
        }
        num++;
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long x,k;
cin >> x>>k;
        long long ans_1,ans_2;
        ans_1 = x%k;
        ans_2 = abs(ans_1-k);
        long long ans = min(ans_1, ans_2);
        cout << ans<< endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int min;
        int K = stdIn.nextInt();
        int N = stdIn.nextInt();

        int[] distances = new int[N];

        for (int i = 0; i < N; i++) {
            distances[i] = stdIn.nextInt();
        }

        stdIn.close();

        int max = distances[0] + K - distances[N-1];
        for (int i = 0; i < N-1; i++) {
            if (max < distances[i+1] - distances[i]) {
                max = distances[i+1] - distances[i];
            }
        }

        System.out.println(K - max);

    }
}

Measured memory_bytes: 65636
import sys
X, K, D = map(int,input().split())

if abs(X) // D >= K:
    print(abs(X) - D * K)
    sys.exit()

if (K - (abs(X) // D)) % 2 == 0:
    print(abs(X) - (abs(X)//D)*D)
else:
    print(((abs(X)//D)+1)*D - abs(X))




Measured memory_bytes: 9192
#include <bits/stdc++.h>
//#include <iostream>
//#include <cstring>
//#include <stack>
//#include <algorithm>
//#include <queue>
//#include <list>
//#include <set>
//#include <map>
using namespace std;

typedef long long ll;


int main() {
	int f=0;
	char s[3];
	cin>>s;
	if(s[1]=='R') {
		if(s[0]=='R'&&s[2]=='R') {
			cout<<"3"<<endl;
		} else if(s[0]=='R'||s[2]=='R'){
			cout<<"2"<<endl;
		}else{
			cout<<"1"<<endl;
		}
	} else {
		if(s[0]=='R'||s[2]=='R'){
			cout<<"1"<<endl;
		}else {
			cout<<"0"<<endl;
		}
	}
	return 0;
}

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

int main() {
    string s;
    cin>>s;
    int cnt=0;
    int tmp=0;
    for(int i=0;i<s.size();i++) {
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') {
            cnt++;
        }
        if(!(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')||i==s.size()-1) {
            tmp=max(tmp, cnt);
            cnt=0;
        }
    }
    cout<<tmp<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< int > S(N + 1, 0);
	rep(i, N) S[i + 1] = (S[i] + A[i]) % M;
	map< int, int > B;
	int ans = 0;
	rep(r, N) {
		B[S[r]]++;
		ans += B[S[r + 1]];
	}
	cout << ans << endl;
	return 0;
}

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
	FASTIO;
	int r;
	cin>>r;
	ld a;
	a=2*3.141592653589793238*r;
	cout<<a<<endl;

}


Measured memory_bytes: 3800
table = {11:'a',12:'b',13:'c',14:'d',15:'e',
         21:'f',22:'g',23:'h',24:'i',25:'j',
         31:'k',32:'l',33:'m',34:'n',35:'o',
         41:'p',42:'q',43:'r',44:'s',45:'t',
         51:'u',52:'v',53:'w',54:'x',55:'y',
         61:'z',62:'.',63:'?',64:'!',65:' '}

while True:
    try:
        mes = input()
        ans = [table.get(int(mes[i:i+2]), 'NA') for i in range(0, len(mes), 2)]
        if 'NA' in ans:
            print('NA')
        else:
            print(''.join(ans))
    except: break

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

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

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

using namespace std;


signed main() {
  string s;
  cin >> s;

  int cnt = 0, ans = 0;
  REP(i, s.size()){
    if(s[i] == 'S') cnt++;
    else{
      if(cnt) cnt--;
      else ans += 2;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
 
int b[1000];
 
int main(){
    int y[2][6];
    int x[6][6]={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
    int a[6];
    int MAX;
    
    for(int i=0;i<2;i++){
        for(int j=0;j<6;j++){
            cin>>y[i][j];
            b[y[i][j]] ++;
        }
    }
    for(int i=0;i<1000;i++){
        MAX=max(MAX,b[i]);
    }
    if(MAX>=6){
        cout<<"Yes"<<endl;
        goto Exit;
    }
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            if(y[0][j]==y[1][i]){
                a[i]=j;
            }
        }
    }
    if(x[a[0]][a[1]]==a[2]+1){
        cout<<"Yes"<<endl;
        goto Exit;
    }
    cout<<"No"<<endl;
    Exit:;
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n,s;

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>

int main(){
	int n, m, c, b[20], a[20], t = 0;
	std::cin >> n >> m >> c;
	for(int i = 0; i < m; i++){
		std::cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			std::cin >> a[j];
		}
		int tmp = c;
		for(int j = 0; j < m; j++){
			tmp += a[j] * b[j];
		}
		if(tmp > 0){
			t++;
		}
	}
	std::cout << t << std::endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] str = sc.next().toCharArray();
		int q = sc.nextInt();
		String order;
		int a, b;
		char[] p;
		char tmp;
		for (int i = 0; i < q; i++) {
			order = sc.next();
			a = sc.nextInt();
			b = sc.nextInt();
			switch (order) {
			case "print":
				for (int j = a; j <= b; j++) {
					System.out.print(str[j]);
				}
				System.out.printf("%n");
				break;
			case "reverse":
				for (int j = a, k = b; j <= (b - a) / 2 + a; j++, k--) {
					tmp = str[j];
					str[j] = str[k];
					str[k] = tmp;
				}
				break;
			case "replace":
				p = sc.next().toCharArray();
				for (int j = a, k = 0; j <= b; j++, k++) {
					str[j] = p[k];
				}
				break;
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 32948
h, w = map(int, input().split())
A = []
A.append(['.'] * (w + 2))
for i in range(h):
    A.append(list('.' + input() + '.'))
A.append(['.'] * (w + 2))

ans = 'Yes'
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if A[i][j] == '#':
            if A[i - 1][j] == '#' or A[i + 1][j] == '#' or A[i][j - 1] == '#' or A[i][j + 1] == '#':
                continue
            else:
                ans = 'No'
                break
                
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  int n,cnt=0,k;
  cin >> n>>k;
  while(n!=0){
	n=n/k;
    cnt++;
  }
  cout << cnt;
  return 0;
}

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

class Program
{
    static void Main()
    {
        var n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int A = n[0];
        int B = n[1];
        if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  cout << fixed << setprecision(10);

  int N; cin >> N;
  double sum = 0;
  REP(i, N) {
    int A; cin >> A;
    sum += 1.0 / A;
  }
  cout << 1.0 / sum << "\n";
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
vector<int> g[111111];
int d1[111111],d2[111111];

void dfs(int v,int pre,int* d,int dist){
  d[v]=dist;
  for(int nv : g[v]){
    if(nv!=pre)dfs(nv,v,d,dist+1);
  }
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b); g[b].push_back(a);
  }
  dfs(0,-1,d1,0);
  dfs(n-1,-1,d2,0);
  int cnt1=0,cnt2=0;
  rep(i,n){
    if(d1[i]<=d2[i])cnt1++;
    else cnt2++;
  }
  if(cnt1<=cnt2)cout<<"Snuke"<<endl;
  else cout<<"Fennec"<<endl;
	return 0;
}


Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3632
def As(b):
	if K==0:
		return N
	q = N//b
	# on each range we have b-K possible A's
	s = (b-K) * q
	if q*b+K <= N:
		s += min((q+1)*b-1,N) - (q*b+K-1)
	return s

N, K = map(int,input().split())
s = 0; b = K+1;
while b <= N:
	s += As(b)
	b += 1
print(s)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int num[10],temp;
  for(int i=0;i<5;i++){
    cin>>num[i];
  }
  for(int i=0;i<5;i++){
    for(int j=4;j>i;j--){
      if(num[j]>num[j-1]){
	temp=num[j];
	num[j]=num[j-1];
	num[j-1]=temp;
      }
    }
  }
  for(int i=0;i<5;i++){
    cout<<num[i];
    if(i!=4){
      cout<<" ";
    }
  }
  cout<<endl;
  return 0;
}

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

int main() {
    vector<int> a;
    for (int i = 0; i < 3; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 3; i++) {
        if (i == 3 - 1)
            cout << a[i] << endl;
        else
            cout << a[i] << " ";
    }
}


Measured memory_bytes: 3160
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,K;cin>>N>>K;
    int p[200010];
    double s[200010];
    double x=0,ans;
    for(int i=1;i<=K;i++){
        cin>>p[i];
        s[i]=(double)(p[i]+1)/2;
        x+=s[i];
    }
    ans=x;
    for(int i=K+1;i<=N;i++){
        cin>>p[i];
        s[i]=(double)(p[i]+1)/2;
        x+=s[i]-s[i-K];
        ans=max(ans,x);
    }
    printf("%0.7lf\n",ans);
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
    public class Program
    {
        public static void Main(string[] args)
        {
            new B().test();
        }
    }

    public class B
    {
        public void test()
        {
            var n = CommonRead.ReadInt();
            var longList = CommonRead.ReadDecimalL();

            decimal exec = 1;
            decimal limit = Convert.ToInt64(Math.Pow(10, 18));

            if (longList.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }

            try
            {
                foreach (var tmp in longList)
                {
                    exec *= tmp;

                    if (exec > limit)
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                }
            }
            catch (OverflowException)
            {
                Console.WriteLine("-1");
                return;
            }


            Console.WriteLine(exec);

        }
    }

static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}


Measured memory_bytes: 38660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  string s;
  cin >> s;
  ll ans;
  if (s == "SUN")
    ans = 7;
  else if (s == "MON")
    ans = 6;
  else if (s == "TUE")
    ans = 5;
  else if (s == "WED")
    ans = 4;
  else if (s == "THU")
    ans = 3;
  else if (s == "FRI")
    ans = 2;
  else
    ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0') count++;
  }
  cout<<min(count,(int)S.size()-count)*2<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PA;
#define int long long
#define MAXN 1003
#define MAXK 100005
#define INF 1000000009
#define pb push_back

int t, n, a[400], b[400], c[400], d[400], res;
set<int> s[400];

int gcd(int k, int r)
{
    if(k % r == 0){
        return r;
    }
    else{
        return gcd(r, k % r);
    }
}

signed main()
{
    cin >> t;
    for(int i = 0; i < t; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    for(int i = 0; i < t; i++){
        if(b[i] > a[i]){
            printf("No\n");
            continue;
        }
        if(b[i] > d[i]){
            printf("No\n");
            continue;
        }
        if(c[i] >= b[i]){
            printf("Yes\n");
            continue;
        }
        int g = gcd(b[i], d[i]);
        n = b[i] - g + a[i] % g;
        if(n > c[i]){
            printf("No\n");
        }
        else{
            printf("Yes\n");
        }
    }


    return 0;
}



Measured memory_bytes: 256