akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		    var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
          var a = inputArray[0];
          var ans = a + a*a + a*a*a;
          Console.WriteLine(ans);
          
        }
		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

namespace AtTest.ABC_104
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int d = int.Parse(input[0]);
            long g = int.Parse(input[1]);
            var scores = new List<long[]>();
            for (int i = 0; i < d; i++)
            {
                string[] inputs = Console.ReadLine().Split(' ');
                scores.Add(new long[int.Parse(inputs[0])]);
                for (int j = 0; j < scores[i].Length; j++)
                {
                    scores[i][j] = 100 * (i + 1) * (j + 1);
                }
                scores[i][scores[i].Length - 1] += long.Parse(inputs[1]);
            }

            long allPat = 1 << d;
            int resultCnt = 1000000000;
            for (long i = 0; i < allPat; i++)
            {
                long score = 0;
                int restIndex = 0;//中途半端に解き、配点最大のもの
                int cnt = 0;
                for (int j = 0; j < d; j++)
                {
                    if (((i >> j) & 1) == 1)
                    {
                        score += scores[j][scores[j].Length - 1];
                        cnt += scores[j].Length;
                    }
                    else
                    {
                        restIndex = j;
                    }
                }

                if (score < g)
                {
                    if (score + scores[restIndex][scores[restIndex].Length - 1] < g) continue;

                    for(int k = 0; k < scores[restIndex].Length; k++)
                    {
                        if (score + scores[restIndex][k] >= g)
                        {
                            cnt += k + 1;
                            break;
                        }
                    }
                }

                if(cnt< resultCnt)
                {
                    resultCnt = cnt;
                }
            }

            Console.WriteLine(resultCnt);
        }
    }
}

Measured memory_bytes: 13268
N, M = gets.split.map(&:to_i)
W = [0]
V = [0]

N.times do
  w, v = gets.split.map(&:to_i)
  W << w 
  V << v 
end

def larger(a, b)
 a > b ? a : b
end

dp = Array.new(N + 1) do |i|
  Hash.new do |h, j|
    if j < W[i]
      h[j] = dp[i - 1][j]
    else
      h[j] = larger(dp[i - 1][j], dp[i - 1][j - W[i]] + V[i])
    end
  end
end

dp[0] = Hash.new(0)

puts dp[N][M]

Measured memory_bytes: 8188
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), H = cin.getInt();
    let A = new Array(N), B = new Array(N);
    let maxA = 0;
    for (let n = 0; n < N; n++) {
        A[n] = cin.getInt();
        if (maxA < A[n]) maxA = A[n]; 
        B[n] = cin.getInt();
    }
    B.sort((a, b) => b - a);
    let ans = 0;
    for (let n = 0; n < N && 0 < H && maxA < B[n]; n++) {
        H -= B[n];
        ans++;
    }
    if (H > 0) ans += Math.ceil(H / maxA);
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34380
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        q.push(temp);
    }

    for (ll i = 0; i < m; i++)
    {
        ll temp = q.top();
        q.pop();
        q.push(temp / 2);
    }

    ll sum = 0;
    while(!q.empty())
    {
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <deque>
using namespace std;

int main()
{
    int n, a[100010], c=1,idb, ids=1;
    long long ans1=0, ans2=0;
    bool big=false;
    deque<int> deq1, deq2;
    cin>>n;
    idb=n-1;
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    deq1.push_back(a[0]);
    while (c!=n)
    {
        big=!big;
        if (big==true)
        {
            if (c==n-1)
            {
                if (abs(deq1[0]-a[idb])>=abs(deq1[deq1.size()-1]-a[idb])) deq1.push_front(a[idb]);
                else deq1.push_back(a[idb]);
                c++;
                idb--;
            }
            else
            {
                deq1.push_front(a[idb]);
                idb--;
                deq1.push_back(a[idb]);
                idb--;
                c+=2;
            }
        }
        else
        {
            if (c==n-1)
            {
                if (abs(deq1[0]-a[ids])>=abs(deq1[deq1.size()-1]-a[ids])) deq1.push_front(a[ids]);
                else deq1.push_back(a[ids]);
                c++;
                ids++;
            }
            else
            {
                deq1.push_front(a[ids]);
                ids++;
                deq1.push_back(a[ids]);
                ids++;
                c+=2;
            }
        }
    }
    for (int i=0; i<n-1; i++) ans1+=abs(deq1[i+1]-deq1[i]);

    ids=0; idb=n-2; big=true; c=1;
    deq2.push_back(a[n-1]);
    while (c!=n)
    {
        big=!big;
        if (big==true)
        {
            if (c==n-1)
            {
                if (abs(deq2[0]-a[idb])>=abs(deq2[deq2.size()-1]-a[idb])) deq2.push_front(a[idb]);
                else deq2.push_back(a[idb]);
                c++;
                idb--;
            }
            else
            {
                deq2.push_front(a[idb]);
                idb--;
                deq2.push_back(a[idb]);
                idb--;
                c+=2;
            }
        }
        else
        {
            if (c==n-1)
            {
                if (abs(deq2[0]-a[ids])>=abs(deq2[deq2.size()-1]-a[ids])) deq2.push_front(a[ids]);
                else deq2.push_back(a[ids]);
                c++;
                ids++;
            }
            else
            {
                deq2.push_front(a[ids]);
                ids++;
                deq2.push_back(a[ids]);
                ids++;
                c+=2;
            }
        }
    }
    for (int i=0; i<n-1; i++) ans2+=abs(deq2[i+1]-deq2[i]);
    cout<<max(ans1, ans2);
    return 0;
}


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

long N;

int main(void) {

    cin >> N;
    vector<long> A(1000010);

    for (long i = 0; i < N; i++) {
        long tmp; cin >> tmp;
        A[tmp]++;
    }

    for (long i = 1; i < A.size(); i++) {
        if (A[i] != 0) {
            for (long j = i * 2; j < A.size(); j += i) {
                A[j] = -1;
            }
        }

        if (A[i] != 1) A[i] == -1;
    }

    long ans = 0;
    for (long i = 0; i < A.size(); i++) {
        if (A[i] == 1) {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
string rot1(string s)
{
    string t = s;
    int n = s.size();
    for(int i=0;i<n;++i)
        t[(i+1)%n] = s[i];
    return t;   
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    string s,t;
    cin>>s>>t;
    bool flg = 0;
    for(int i=0;i<=s.size()+1;++i)
    {
        if(s==t)
            flg=1;
        s = rot1(s);
    }
    if(flg)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<'\n';
    return 0;
}   

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = np.array(readline().split(), dtype=np.int64)
    B = np.array(readline().split(), dtype=np.int64)
    C = np.array(readline().split(), dtype=np.int64)

    A.sort()
    B.sort()
    C.sort()

    A_bisect = np.searchsorted(A, B, side="left")
    C_bisect = np.searchsorted(C, B, side="right")

    ans = A_bisect * (N - C_bisect)
    print(ans.sum())


if __name__ == "__main__":
    main()


Measured memory_bytes: 26776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int k;
	cin >> k;
	queue<ll> q;
	for (int i = 1; i < 10; i++)
	{
		q.push(i);
	}
	for (int i = 1; i < k; i++) {
		ll f = q.front();
		q.pop();
		if (f % 10 != 0)
			q.push(f * 10 + f % 10 - 1);
		q.push(f * 10 + f % 10);
		if (f % 10 != 9)
			q.push(f * 10 + f % 10 + 1);
	}
	cout << q.front() << endl;
}


Measured memory_bytes: 5148
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int k = scan.nextInt();
		int x = scan.nextInt();
        
        out.println(500 * k >= x ? "Yes" : "No");
        out.close();
        
    }
}

Measured memory_bytes: 35732
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;


int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(3 * n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;

		g[u].emplace_back(v + n);
		g[u + n].emplace_back(v + 2 * n);
		g[u + 2 * n].emplace_back(v);
	}

	int s, t;
	cin >> s >> t;
	s--;
	t--;



	vector<ll> d(3 * n, INF);
	vector<bool> isChecked(3 * n, false);
	d[s] = 0;
	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(make_pair(0, s));
	while (!pq.empty()) {
		int v = pq.top().second;
		pq.pop();
		for (auto it = g[v].begin(); it != g[v].end(); it++) {
			if (!isChecked[*it] && d[*it] > d[v] + 1) {
				d[*it] = d[v] + 1;
				pq.push(make_pair(d[*it], *it));
			}
		}

		isChecked[v] = true;
	}

	ll dt = INF;
	for (int i = 0; i < 3; i++) {
		if (d[t + i * n] % 3 == 0) {
			dt = min(dt, d[t + i * n] / 3);
		}
	}

	if (dt == INF) {
		dt = -1;
	}
	cout << dt << endl;
}




Measured memory_bytes: 19072
N = int(input())

def dfs(value, use):
    if int(value) > N:
        return 0

    res = int(use == 0b111)
    res += dfs(value + "7", use | 0b001)
    res += dfs(value + "5", use | 0b010)
    res += dfs(value + "3", use | 0b100)

    return res

print(dfs("0", 0))


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

using namespace std;

bool judge(string s){
    int length = static_cast<int>( s.size());
    if(length%2==1){
    for(int i=0;i<(length-1)/2;i++){
        if(s[i] !=s[length-i-1]){
            return false;
        }
    }
    return true;
    }
    if(length%2==0){
    for(int i=0;i<length/2;i++){
        if(s[i] !=s[length-i-1]){
            return false;
        }
    }
    return true;
    }
}

int main(){
    string s;
    cin >> s;
    if(judge(s)){
        if(judge(s.substr(0,(s.size()-1)/2))){
            cout <<"Yes" <<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    static class Shopping {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            Set<Integer> se = new HashSet<>();
            for (int i = 0; i < M; i++) {
                int c = in.nextInt() - 1;
                int d = in.nextInt() - 1;
                for (int j = c; j < d; j++) {
                    se.add(j);
                }
            }
            int ans = 0;
            for (int i = 0; i <= N; i++) {
                if (se.contains(i)) {
                    ans += 2;
                }
                ans++;
            }
            out.println(ans);
        }

    }
}




Measured memory_bytes: 33772
from sys import stdin, setrecursionlimit

WEEK = {
    'SUN': 0,
    'MON': 1,
    'TUE': 2,
    'WED': 3,
    'THU': 4,
    'FRI': 5,
    'SAT': 6
}


def main():
    input = stdin.buffer.readline
    s = input()[:-1].decode()
    print(7 - WEEK[s])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

char s[MAXN];

void read(){
	scanf("%s", s);
	scanf("%d", &n);
}

void solve(){
	int l = strlen(s);
	for(int i = 0; i < l; i++){
		if (s[i] != 'a' && 'z' - s[i] + 1 <= n){
			n -= ('z' - s[i] + 1);
			s[i] = 'a';
		}
	}
	if (n){
		s[l-1] -= 'a';
		s[l-1] = (s[l-1] + n) % 26;
		s[l-1] += 'a';
	}
	printf("%s\n", s);
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n, k;
	cin >> n >> k;
	vector<ll> v(n);
	ll sum = 0;
	for(ll& x : v){
		cin >> x;
		sum += x;
	}
	sort(v.begin(), v.end(), greater<ll>());
	for(int i = 0; i < min(k, n); i++){
		sum -= v[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int a,d,n;
  bool prime[1000005]={};
  int i,j;

  for(i=2;i<1000005;i++)
    if(prime[i]==false)
      for(j=2;i*j<1000005;j++)
	prime[i*j]++;
  prime[0]=prime[1]=true;

  while(1){
    cin>>a>>d>>n;
    if(a==0 && d==0 && n==0)break;
    int ans=0;
    while(1){
      if(prime[a]==false)ans++;
      if(ans==n)break;
      a+=d;
    }
    cout<<a<<endl;
  }
}

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

int main() {
	string a, b;
	cin >> a >> b;
	int num = stoi(a+b);
	bool f = false;
	for (int i = 4; i < 320; i++) {
		if (i * i == num) {
			f = true;
			break;
		}
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int F[MAX],i;

void fib(int n){
  F[0] = F[1] = 1;

  for( i = 2 ; i <= n ; i++ ) F[i] = F[i-1]+F[i-2];
 }

int main(){
  int n;

  scanf("%d",&n);

  fib(n);
  
  printf("%d\n",F[n]);

  return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 100;
int T,n,m;
char s[50];



int main() {
    int a,b;
	cin>>a>>b;
	cin>>s;
	for(int i=0;i<a;i++){
		if(s[i]>='0'&&s[i]<='9') continue;
		else {
			cout<<"No"<<endl;
			return 0;
		}
	} 
	if(s[a]!='-') {
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=a+1;i<=a+b;i++){
		if(s[i]>='0'&&s[i]<='9') continue;
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.exec();
	}
	
	public void exec() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		
		long minDist = n;
		
		for(long i = 1L; i*i <= n; i++) {
			if(n % i == 0) {
				minDist = Math.min(minDist, i + n/i -2);
			}
		}
		
		System.out.println(minDist);
	}
}


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

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

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

ll mod = 998244353;

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

  int n,k;
  cin >> n >> k;
  vi cnt(n);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int a;
      cin >> a;
      a--;
      cnt[a]++;
    }
  }

  int ret = 0;
  rep(i,n){
    if(cnt[i] == 0)ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100100;
const int MOD = (int) 1e9 + 7;

int d[N][15];
char s[N];

int main() {

	scanf("%s", s);

	int n = strlen(s);

	memset(d, 0, sizeof d);

	d[0][0] = 1;

	for (int i = 0; i < n; i++) {
		if (s[i] == '?') {
			for (int j = 0; j < 13; j++) {
				int k = j * 10 % 13;
				for (int digit = 0; digit <= 9; digit++) {
					int l = k + digit;
					if (l >= 13) {
						l -= 13;
					}
					d[i + 1][l] += d[i][j];
					if (d[i + 1][l] >= MOD) {
						d[i + 1][l] -= MOD;
					}
				}
			}
		} else {
			for (int j = 0; j < 13; j++) {
				int k = (j * 10 + s[i] - '0') % 13;
				d[i + 1][k] += d[i][j];
				if (d[i + 1][k] >= MOD) {
					d[i + 1][k] -= MOD;
				}
			}
		}
	}

	printf("%d\n", d[n][5]);

	return 0;

}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


constexpr ll mod = 998244353;

long long mod_pow(long long x,long long n,long long MOD=1000000007LL){
    long long res=1;
    if(x==0) return 0;
    while(n){
        if(n&1LL) res=(res*x)%MOD;
        x=(x*x)%MOD;
        n>>=1;
    }
    return res;
}

int main(){
    ll N; cin >> N;
    vector<ll> D(N);
    rep(i,N) cin >> D[i];
    if(D[0]>0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    map<ll,ll> mp;
    rep(i,N){
        mp[D[i]]++;
    }

    if(mp[0] >= 2){
        cout << 0 << endl;
        return 0;
    }

    ll mx = 0;
    rep(i,N) mx=max(mx,D[i]);

    //cout << mp << endl;

    for(ll i=2;i<=mx;i++){
        ll pre = mp[i-1];
        ll now = mp[i];
        /* if(now > 0 and pre == 0){ */
        /*     cout << 0 << endl; */
        /*     return 0; */
        /* } */
        ll p = mod_pow(pre,now,mod) % mod;
        //cout << pre << " " << now << " " << p << endl;
        ans *= p;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include <string.h>

#include <algorithm>
#include <iostream>
#include <vector>

#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main(void) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  //端だけ比べればよい
  ll temp[4];
  ll max = a * c;

  temp[0] = a * c;
  temp[1] = a * d;
  temp[2] = b * c;
  temp[3] = b * d;

  rep1(i, 4) {
    if (max < temp[i]) {
      max = temp[i];
    }
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

void solve(){
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
        cout<<"A";
    else if(c>='a' && c<='z')
        cout<<"a";
   
}

int main(){
    FAST
    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     solve();
    // }
    solve();
return 0;

}

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

int main () {
  int N;
  cin >> N;
  N %= 10;
  if (N == 3) cout << "bon" << endl;
  else if ((N%2== 0) && (N >= 6)) cout << "pon" << endl;
  else if ((N == 0) || (N == 1)) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[110],b[110];
	int l;
	scanf("%s",a);
	scanf("%s",b);
	l = strlen(a);
	int i,j;
	for(i=0;i<l;i++)
	{
		for(j=0;j<l;j++)
		{
			if(a[j] != b[(i+j)%l])
				break;
		}
		if(j == l)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, d[maxn];

int main() {
	scanf("%d", &n);
	if((n + 1) % 4 == 0) {
		printf("Yes\n");
		for (int i = 2; i <= 2 * n; ++i) printf("%d %d\n", i - 1, i);
		return 0;
	}
	for (int i = 2; i <= n; ++i) d[i] = d[i >> 1] + 1;
	if(n == (1 << d[n])) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	if(n & 1) {
		int U = (1 << d[n]);
		for (int i = 2; i < U; ++i) 
			printf("%d %d\n%d %d\n", i - 1, i, i - 1 + n, i + n);
		printf("%d %d\n", U - 1, n + 1);
		for (int i = U + 1; i <= n; ++i) 
			printf("%d %d\n%d %d\n", i - 1, i, i - 1 + n, i + n);
		printf("%d 1\n1 %d\n", n, U + n);
		return 0;
	}
	if((n + 1) % 4 == 1) {
		int U = (1 << d[n]);
		for (int i = 2; i < U; ++i) 
			printf("%d %d\n%d %d\n", i - 1, i, i - 1 + n, i + n);
		printf("%d %d\n", U - 1, n + 1);
		for (int i = U + 1; i <= n - 1; ++i) 
			printf("%d %d\n%d %d\n", i - 1, i, i - 1 + n, i + n);
		printf("%d %d\n", n - 1, U + n);
		printf("%d %d\n%d %d\n%d %d\n", n, U, U, (n ^ U), (n ^ U), 2 * n);
		return 0;
	}
	printf("%d 1\n1 2\n2 %d\n%d %d\n", n - 1, n, n, 2 * n - 1);
	printf("%d %d\n%d %d\n%d %d\n", 2 * n - 1, 1 + n, 1 + n, 2 + n, 2 + n, 2 * n);
	printf("%d %d\n1 %d\n", n - 2, n - 1, 2 * n - 2);
	printf("3 1\n2 %d\n", 3 + n);
	for (int i = 5; i < n - 2; ++i) 
		printf("%d %d\n%d %d\n", i - 1, i, i - 1 + n, i + n);
	if(n > 6) printf("%d %d\n3 %d\n", n - 3, 4 + n, 4 + n);
	return 0;
}

Measured memory_bytes: 4112
#include <iostream>

using namespace std;

int main() {
    int N, X;
    cin >> N >> X;

    int i, m[N], min=1001, count=N;
    for(i=0; i<N; i++) {
        cin >> m[i];
        if(m[i]<min) {
            min = m[i];
        }
        X -= m[i];
    }

    count += X/min;

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
    int n , m;

    cin >> n >> m;

    int k;

    cin >> k;

    int i = 1 , j = 1 , y = 1;

    for(int ii = 1 ; ii<=k ; ii++)
    {
        int x;

        cin >> x;

        while(x--)
        {
            a[i][j] = ii;
            j += y;
            if(j>m)
            {
                i++;
                y = -1;
                j--;
            }
            else if(j==0)
            {
                i++;
                y = 1;
                j++;
            }
        }
    }

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

    return 0;
}


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

const int MAX = 10000;
int plist[MAX + 1] = {};

void primeNumber(){
	
	//0 -> prime, 1 -> composite
	
	plist[0] = 1;
	plist[1] = 1;
	
	for(int i = 2; i <= MAX; ++i){
		if(plist[i] == 0){
			int c = i * 2;
			while(c <= MAX){
				plist[c] = 1;
				c += i;
			}
		}
	}
}

int main(){
	int n;
	
	primeNumber();
	
	while(cin >> n, n){
		int k;
		if(n % 2 == 0){
			k = n - 1;
		}else{
			k = n;
		}
		
		while(k >= 3){
			if(plist[k] == 0 && plist[k - 2] == 0){
				cout << k - 2 << " " << k << endl;
				break;
			}
			k -= 2;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

const ll MAX = 1e6;

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	string str;
	cin >> str;
	cout << ((str.size()&1)!=(str.front()==str.back())?"First":"Second") << endl;
			return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	int pasta[3], juice[2];
	int i, j;
	
	for(i=0; i<3; i++)
		scanf(" %d", &pasta[i]);
	for(i=0; i<2; i++)
		scanf(" %d", &juice[i]);
		
	int min = pasta[0]+juice[0]-50;
	
	for(i=0; i<3; i++){
		for(j=0; j<2; j++){
			if(min > pasta[i]+juice[j]-50)
				min = pasta[i]+juice[j]-50;
		}
	}
	
	printf("%d\n", min);

	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

int N;
int a[100];

int main() {
  cin >> N;
  int maxa = -inf;
  int maxi = 0;
  int mina = inf;
  int mini = 0;
  repe(i, 1, N) {
    cin >> a[i];
    if (chmax(maxa, a[i])) {
      maxi = i;
    }
    if (chmin(mina, a[i])) {
      mini = i;
    }
  }

  if (abs(maxa) > abs(mina)) {
    cout << 2 * N - 2 << "\n";
    repe(i, 1, N) {
      if (i == maxi) continue;

      cout << maxi << " " << i << "\n";
    }

    repe(i, 1, N - 1) { cout << i << " " << i + 1 << "\n"; }
  } else {
    cout << 2 * N - 2 << "\n";
    repe(i, 1, N) {
      if (i == mini) continue;

      cout << mini << " " << i << "\n";
    }

    for (int i = N; i >= 2; --i) {
      cout << i << " " << i - 1 << "\n";
    }
  }
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b, c; cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

vector<double> out;

int main(){
    int n;
    do{
        cin>>n;
        if (n!=0){
            int *s;
            s = new int[n];
            if (s==NULL){
                cout<<"Error!"<<endl;
                return -1;
            }
            int i;
            for (i=0;i<n;i++){
                cin>>s[i];
            }
            double ave=0.0;
            for (i=0;i<n;i++){
                ave+=s[i];
            }
            ave/=n;
            double var=0;
            for (i=0;i<n;i++){
                var+=(s[i]-ave)*(s[i]-ave);
            }
            var/=n;
            var=sqrt(var);
            out.push_back(var);
            delete [] s;
        }
    }while (n!=0);
    for (vector<double>::iterator i=out.begin();i!=out.end();i++){
        cout<<fixed<<setprecision(8)<<*i<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
def solve():
    import sys
    input_lines = sys.stdin.readlines()
    
    while True:
        R, C = map(int, input_lines[0].split())
        if R == 0:
            break
        
        rows = map(lambda x: x.rstrip().replace(' ', ''), input_lines[1:R+1])
        cols = [int(''.join(t_c), base=2) for t_c in zip(*rows)]
        
        ans = []
        b = 2 ** R
        flip_check = [True] * (b)
        
        for m in range(b):
            if flip_check[m]:
                flip_check[~m] = False
                shipment = 0
                for s in cols:
                    bit_cnt = bin(m ^ s).count('1')
                    shipment += max(bit_cnt, R - bit_cnt)
                ans.append(shipment)
        
        print(max(ans))
        
        del input_lines[:R+1]

solve()


Measured memory_bytes: 6308
n, k = map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(k):
    print(cmb(n-k+1,i+1,mod)*cmb(k-1,i,mod)%mod)
    

Measured memory_bytes: 4712
#include <stdio.h>
#define N 25
 
void Defpre(int);

void Defin(int);

void Defpost(int);
 
typedef struct node{int nump,numl,numr;}Node;

Node array[N];

int n;
 
int main(){
  int i,numl,numr,nump;

int root,numv;
 
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    array[i].nump = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d%d",&numv,&numl,&numr);

    array[numv].numl = numl;

    array[numv].numr = numr;

    if(numl != -1) array[numl].nump = numv;

    if(numr != -1) array[numr].nump = numv;
  }
 
  for(i = 0;i < n;i++){
    if(array[i].nump == -1) 
      root = i;
  }
 
  printf("Preorder\n");
  
Defpre(root);

  printf("\n");

  printf("Inorder\n");

  Defin(root);

  printf("\n");

  printf("Postorder\n");

  Defpost(root);

  printf("\n");
 
  return 0;
}
 
void Defpre(int num){
  if(num == -1) {
    return;
  }
  printf(" %d",num);

  Defpre(array[num].numl);

  Defpre(array[num].numr);
}
 
void Defin(int num){
  if(num == -1) {
    return;
  }
  Defin(array[num].numl);
  
printf(" %d",num);

  Defin(array[num].numr);
}
 
void Defpost(int num){
  if(num == -1){
    return;
  }
  Defpost(array[num].numl);

  Defpost(array[num].numr);

  printf(" %d",num);
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;

	for(int i=0; i<s.size(); i++){
		if(s[i] + n > 90){
			s[i] = 'A' + (n - ('Z' - s[i]) - 1) ;
		} else {
			s[i] += n;
		}
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int x, n;
    scanf("%d%d", &x, &n);
    int p[102] = {0};
    int i = 0, j;
    for(i = 0; i < n; i++){
        scanf("%d", &j);
        p[j]++;
    }
    for(i = 0; i <= n; i++){
        if(p[x - i] == 0 && x - i >= 0){
           
            printf("%d\n", x - i);
            return 0;
            
        }
        if(p[x + i] == 0 && x + i <= 101){
            
            printf("%d\n", x + i);
            return 0;
            
        }
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 1736
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

from collections import Counter

sc=Counter(s)
tc=Counter(t)

ans=0
for i,j in sc.items():
  tmp=j-tc[i]
  if tmp>0:
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 38384
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Input.nextInt() % 2 == 0 || Input.nextInt() % 2 == 0 ? "Even" : "Odd");


    }

}


class Input
{
    static string[] line = { };
    static int index = 0;
    static void readLine()
    {
        line = Console.ReadLine().Split(' ');
        index = 0;
    }
    public static int nextInt()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return int.Parse(line[index - 1]);
    }
    public static long nextLong()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return long.Parse(line[index - 1]);
    }
    public static string next()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return line[index - 1];
    }
}




Measured memory_bytes: 11092
A, B, C = map(int, input().split())

lst = [A, B, C]
lst.sort(reverse = True)
ctr = 0

while lst[0] > lst[1]:
    lst[1] += 1
    lst[2] += 1
    ctr += 1

while lst[1] > lst[2]:
    lst[2] += 2
    ctr += 1

if lst[2] > lst[1]:
    ctr += 1

print(ctr)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int h,a;
    cin>>h>>a;

    if ( h % a == 0 )
    {
        cout<<h/a<<endl;
    }
    else
    {
        cout<<(h/a) + 1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
S,T=input().split()
for i in range(len(S)):
    print("{}{}".format(S[i],T[i]),end="")

print("")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
int main() {
    cin>>a>>b;
    cout<<a+(b/2)<<endl;
    return 0;
}

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

int main()
{
  string s = "";
  getline(cin, s);
  for (int i = 0; i < s.size(); i++)
  {
    if (s.at(i) == ' ')
    {
      cout << " ";
    }
    else if (s.at(i) == ',')
    {
      cout << ',';
    }
    else if (s.at(i) == '.')
    {
      cout << '.';
    }
    else if (s.at(i) >= 65 && s.at(i) <= 90)
    {
      char c = s.at(i) + 32;
      cout << c;
    }
    else if (s.at(i) >= 97 && s.at(i) <= 122)
    {
      char c = s.at(i) - 32;
      cout << c;
    }
    else
    {
      cout << s.at(i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(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 int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
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){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a = pow(2.0,m);
    cout << (1900 * m * a) + (100 * (n - m) * a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N;

	vector<int>v(30000001);
	for (int i = 1; i <= 10000000; i *= 10) {
		v[i]++;
	}
	for (int i = 2; i <= 30000000; i++) {
		v[i] += v[i - 1];
	}
	for (int i = 2; i <= 30000000; i++) {
		v[i] += v[i - 1];
	}
	L = 1;
	R = 1;
	while (R <= 30000000) {
		if (v[R] - v[L - 1] >= N) {
			if (v[R] - v[L - 1] == N) {
				K++;
			}
			L++;
		}
		else {
			R++;
		}
		if (N % 8 == 0 && L == 10000000) {
			break;
		}
	}
	for (int i = 1; i <= N / 8; i++) {
		if (N%i == 0) {
			long long int box = power(10, N / i, MOD);
			box -= power(10, N / i - 1, MOD);
			box -= i - 1;
			box += MOD*2;
			box %= MOD;
			K += box;
			L %= MOD;
		}
		else {
			K++;
		}
	}
	cout << K%MOD << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> v(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    sort(v.begin(), v.end());
    int ans = 1;
    sum -= v[n - 1];
    for (int i = n - 2; i >= 0; --i) {
        if (sum * 2 >= v[i + 1]) {
            ++ans;
        } else {
            break;
        }
        sum -= v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;cin>>s>>t;
    int a,b;cin>>a>>b;
    string u;cin>>u;
    if(s==u)cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
    return 0;
}

Measured memory_bytes: 256
from math import sqrt


def f(x):
    ret = []
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)

    return ret


n = int(input())

ans = 1
for k in range(2, int(sqrt(n)) + 1):
    r = n
    while r % k == 0:
        r //= k

    if r % k == 1:
        ans += 1

li = f(n - 1)
for e in li:
    if e > int(sqrt(n)):
        ans += 1

print(ans)


Measured memory_bytes: 40044
#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);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a;
	sort(a.begin(), a.end());
	int pos1 = 0, pos2 = n - 2;
	bool turn = true;
	deque<int> deq;
	deq.push_back(a[n - 1]);
	while (pos1 <= pos2) {
		if (turn) {
			if (pos1 <= pos2) {
				deq.push_back(a[pos1]);
				pos1++;
			}
			if (pos1 <= pos2) {
				deq.push_front(a[pos1]);
				pos1++;
			}
			turn = false;
		}
		else {
			if (pos1 <= pos2) {
				deq.push_back(a[pos2]);
				pos2--;
			}
			if (pos1 <= pos2) {
				deq.push_front(a[pos2]);
				pos2--;
			}
			turn = true;
		}
	}
	reverse(a.begin(), a.end());
	deque<int> deq2;
	pos1 = 0, pos2 = n - 2;
	turn = true;
	deq2.push_back(a[n - 1]);
	while (pos1 <= pos2) {
		if (turn) {
			if (pos1 <= pos2) {
				deq2.push_back(a[pos1]);
				pos1++;
			}
			if (pos1 <= pos2) {
				deq2.push_front(a[pos1]);
				pos1++;
			}
			turn = false;
		}
		else {
			if (pos1 <= pos2) {
				deq2.push_back(a[pos2]);
				pos2--;
			}
			if (pos1 <= pos2) {
				deq2.push_front(a[pos2]);
				pos2--;
			}
			turn = true;
		}
	}
	ll res1 = 0, res2 = 0;
	/*for (int c : deq) cout << c << ' ';
	cout << endl;*/
	rep(i, deq.size() - 1) {
		res1 += abs(deq[i + 1] - deq[i]);
		res2 += abs(deq2[i + 1] - deq2[i]);
	}
	cout << max(res1, res2) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	ll a, b, c;
	cin >> a >> b >> c;
	
	ll x = c % b;
	for (int i = 1; i <= 100; i++) {
		if ((a * i % b) == x) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Monad
main = do
    k <- read <$> getLine 
    print $ ans !! (k-1)

ans = [1..9] ++ concatMap f ans

f :: Integer -> [Integer]
f n = do
  ms <- [m-1,m,m+1]
  guard (0 <= ms && ms <= 9)
  res <- [10*n]
  return (res+ms)
  where m = n `mod` 10

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int val=a-(2*b);
    if (val>0)
      printf("%d\n",val);
    else
      printf("0\n");
    return 0;
}

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

int main()
{
    int n,k;
    long long m=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<(n-k);i++) m+=a[i];
    cout<<m<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))


#if 1
//No.1
int main()
{
	string S, T;
	cin >> S >> T;

	bool a = true;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] < 'a' || S[i] > 'z') { a = false; break; }
	}
	for (int i = 0; i < T.length(); ++i) {
		if (T[i] < 'a' || T[i] > 'z') { a = false; break; }
	}
	string S_tmp = S;
	S_tmp += T[T.length() - 1];
	if (S_tmp != T) { a = false; }

	bool b = false;
	if (S.length() >= 1 && S.length() <= 10) { b = true; }

	bool c = false;
	if (S.length() + 1 == T.length()) { c = true; }

	if (a && b && c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}
#endif


Measured memory_bytes: 3624
import math

A, B, H, M = map(int, input().split(' '))

angle_h = 2 * math.pi * H / 12 + 2 * math.pi * M / (12 * 60)
angle_m = 2 * math.pi * M / 60

print(math.sqrt(A * A + B * B - (2 * A * B * math.cos(angle_h - angle_m))))


Measured memory_bytes: 9500