akhauriyash/Code-Regression huggingface dataset:
n = int(input())

l = [[1,0]]

for _ in range(n - 1):
    l1 = []
    for i in range(len(l)):
        l2 = l[i]
        for j in range(l2[0]+1):
            l3 = l2 + [j]
            if j == l2[0]:
                l3[0] = j + 1
            l1.append(l3)
    l = l1
w = ["a","b","c","d","e","f","g","h","i","j"]
ls = []
for i in range(len(l)):
    s = "a"
    for j in range(2,len(l[i])):
        s += w[l[i][j]]
    ls.append(s)

ls.sort()

for i in range(len(l)):
    print(ls[i])

Measured memory_bytes: 32716
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;
    string s;
    int len;


    public void calc()
    {
        cin = new Scanner();
        s = cin.next();
        len = s.Length;
        Console.WriteLine(dfs(0, ""));
        Console.Read();
    }

    long dfs(int n,string str)
    {
        if (n == len) return str.Split('+').Select(long.Parse).Sum();

        long ret = 0;
        if (str.Length > 0 && str[str.Length - 1] == '+')
        {
            ret += dfs(n + 1, str + s[n]);
        }
        else
        {
            if (str.Length > 0)
            {
                ret += dfs(n, str + "+");
            }
            ret += dfs(n + 1, str + s[n]);
        }
        return ret;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11220
#include <iostream>
    #include <sstream>
    #include <vector>
    #include <cmath>
    #include <ctime>
    #include <cassert>
    #include <iomanip>
    #include <cstdio>
    #include <float.h>
    #include <queue>
    #include <set>
    #include <map>
    #include <fstream>
    #include <cstdlib>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <numeric>
    #include <stack>
    #include <functional>
           
    using namespace std;
           
    #define endl '\n'
    #define MOD 1000000007
    #define INF 1ll<<30
     
    // #define MAX 100010
     
    #define eps 1e-11
    #define bit_max 1ll<<32
    #define _USE_MATH_DEFINES


    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        // #ifndef ONLINE_JUDGE
        //     freopen("input.txt","r",stdin);
        //     freopen("output.txt","w",stdout);
        // #endif
        int n;
        cin>>n;
        int temp,ce=0,co=0;
        for(int i=0;i<n;i++)
        {
            cin>>temp;
            if(temp%2==0)
                ce++;
            else
                co++;
        }
        if(co%2==0)
            cout<<"YES";
        else
            cout<<"NO";
cout<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>
#define N 210000
#define ll long long
#define ls (now<<1)
#define rs ((now<<1)|1)
#define RG register
using namespace std;
inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

string a[200]; int n,len[200];

int main(){
	n=read();
	for(RG int i=1;i<=n;++i){
		cin>>a[i]; len[i]=a[i].length();
		if(i==1) continue ;
		for(RG int j=1;j<i;++j)
			if(a[i]==a[j]){
				puts("No");
				return 0;
			}
		if(a[i-1][len[i-1]-1]!=a[i][0]) { puts("No"); return 0; }
	}   puts("Yes");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	res := "No"
	if len(s) == 6 {
		if s[2:3] == s[3:4] && s[4:5] == s[5:6] {
			res = "Yes"
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, L;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if ( (K - x) <= x )
      L += (K - x) * 2;
    
    else
      L += x * 2;
  }
  
  cout << L << endl;
}

Measured memory_bytes: 256
import sys, itertools, collections
sys.setrecursionlimit(10000)

read_ints = lambda: list(map(int, input().split()))
read_int  = lambda: int(input())

MOD = 2019

l, r = read_ints()
r = min(r + 1, l + MOD)

ans = min(
    (i * j) % MOD
    for i in range(l, r)
    #for j in range(l + 1, r)  # WA
    for j in range(i + 1, r)
)

print(ans)


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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] h = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                h[i] = int.Parse(words[i]);
            }
        }

        int answer = 0;
        int tmpAnswer = 0;
        int before = 0;
        for (int i = 0; i < n; i++)
        {
            if (i == 0)
            {
                before = h[0];
                continue;
            }
            int now = h[i];
            if (now <= before)
            {
                tmpAnswer++;
            }
            if (now > before || i == n - 1)
            {
                answer = Math.Max(tmpAnswer, answer);
                tmpAnswer = 0;
            }
            before = now;
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 27104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define L 13
#define SIZE 1000000

typedef struct node *link;
struct node{
	char str[L];
	link next;
};
link map[SIZE];

int hash(char *str){
	int i,h=0;
	for(i=0;str[i]!='\0';i++)
		h=(h*137+str[i])%SIZE;
	return h;
}

link NEW(char *str, link next){ 
	link x = malloc(sizeof(*x));
	strcpy(x->str,str); 
	x->next = next;     
	return x;                         
}


void add_hash(char *str){
	int h=hash(str);
	map[h]=NEW(str,map[h]);
}

void remove_hash(char *str){
	int h=hash(str);
	link t,temp;
	//for(t=map[h];t!=NULL;t=t->next);
	
	if(!strcmp(str,map[h]->str)){
		map[h]=NULL;
	}else{
		for(t=map[h];t->next!=NULL;t=t->next){
			if(!strcmp(t->next->str,str)){
				temp=t->next;
				t->next=temp->next;
				break;
			}
		}
	}
}

int find_hash(char *str){
	int h=hash(str);
	link t;
	for(t=map[h];t!=NULL;t=t->next){
		if(!strcmp(str,t->str)){
			return 1;
		}
	}
	return 0;
}

int main(void){
	int n,i;
	char str[L];
	char c[L];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",c,str);
		
		if(!strcmp(c,"insert")){
			add_hash(str);
		}else if(!strcmp(c,"remove")){
			remove_hash(str);
		}else if(!strcmp(c,"find")){
			if(find_hash(str)==1)printf("yes\n");
			else printf("no\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 27448
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B;

int main(){
	cin>>A>>B;
	cout<<(A+B)/2<<endl;
}


Measured memory_bytes: 3104
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var n = int.Parse(line[2]);
            if (h == 0 && w == 0 && n == 0) break;
            n -= 1;
            var map = new bool[h, w];
            for (int i = 0; i < h; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++)
                    map[i, j] = line[j] == "0" ? true : false;
            }
            var map2 = goDP(map, h, w, n);
            getAns(map2, h, w);
        }
    }
    static void getAns(bool[,] map, int h, int w)
    {
        var x = 0;
        var y = 0;
        while (true)
        {
            if (x == h | y == w) { Console.WriteLine("{0} {1}", x + 1, y + 1); break; }
            if (map[x, y]) x++;
            else y++;
        }
    }
    static bool[,] goDP(bool[,] map, int h, int w, int n)
    {
        var dp = new int[h, w];
        var map2 = new bool[h, w];
        dp[0, 0] = n;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
            {
                var t = dp[i, j];
                if (i + 1 < h) dp[i + 1, j] += t / 2;
                if (j + 1 < w) dp[i, j + 1] += t / 2;
                if (t % 2 == 1)
                {
                    if (map[i, j] && i + 1 < h) dp[i + 1, j]++;
                    else if (!map[i, j] && j + 1 < w) dp[i, j + 1]++;
                }
                map2[i, j] = t % 2 == 0 ? map[i, j] : !map[i, j];
            }
        return map2;
    }
}


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

#define ll long long
#define UN unsigned
#define pb push_back
#define mod 1000000007
#define mt make_tuple
typedef tuple<int, int> tii;
typedef pair<int, int> pii;

const int N = 1e5 + 1;

void solve(){
    int n, W;
    cin >> n >> W;

    int w[105], v[105];
    for(int i=1; i<=n; i++){
        cin >> w[i] >> v[i];
    }

    ll dp[101][N];
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=W; j++){
            if(j < w[i]){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            }
        }
    }

    cout << dp[n][W];
}

int main(void){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
    solve();
    return 0;
}

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

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split(' ');
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);

            if (a <= 5)
                Console.WriteLine(0);

            else if (a >= 13)
                Console.WriteLine(b);

            else
                Console.WriteLine(b / 2);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    map<string, int> m;
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        ++m[s];
    }
    vector<string> v{"AC", "WA", "TLE" ,"RE"};
    for (auto x : v) {
        cout << x << " x " << m[x] << endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
ll Ceil(ll x, ll y) {
	return (x + y - 1) / y;
}
bool judge(ll x, VL& a, VL& b, ll k) {
	ll used = 0;
	rep(i, a.size()) {
		if (a[i] * b[i] > x) {
			ll tot = a[i] * b[i];
			tot -= x;
			used += Ceil(tot, b[i]);
		}
	}
	return used <= k;
}
int main() { // 問題文はしっかり読め!!!
	int n; ll k;
	cin >> n >> k;
	VL a(n);
	VL b(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	sort(all(a));
	sort(all(b), greater<ll>());
	ll ok = 1e12 + 1, ng = -1;
	while (ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		if (judge(mid, a, b, k)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 3328
// written by @kakira9618
// problem: https://www.ioi-jp.org/joi/2016/2017-yo/2017-yo-t4/2017-yo-t4.html

#include <iostream>
#include <vector>

using namespace std;
  
int sum[20][100000]; // sum[c][i]: ???c???i???????????§??????????????????
int count[20]; // count[c]: ???c??????????????????
int dp[1 << 20]; // dp[i]: i????????£???????????????????????´????????????????????????????????????????????¨???????§£
const int INF = 1 << 29;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> C(N);

    for(int i = 0; i < N; i++) {
        cin >> C[i];
        C[i]--;
        count[C[i]]++;
    }

    // ?´???????????¨????
    // O(NM)
    for(int c = 0; c < M; c++) {
        for(int i = 0; i < N; i++) {
            if (C[i] == c) sum[c][i] = 1;
        }
    }
    for(int c = 0; c < M; c++) {
        int s = 0;
        for(int i = 0; i < N; i++) {
            s += sum[c][i];
            sum[c][i] = s;
        }
    }

    // BitDP?????????
    for(int i = 0; i < 1 << M; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    // BitDP
    // ?????¨?????£???????????????????????¨?´????????????????????????£???????????????????????????????????¬?????????????????°????±????????????????
    // O(2^M M)
    for(int i = 0; i < 1 << M; i++) {
        int s = 0;
        for(int j = 0; j < M; j++) {
            if (i >> j & 1) {
                s += count[j];
            }
        }

        for(int j = 0; j < M; j++) {
            if (!(i >> j & 1)) {
                dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + count[j] - (sum[j][s + count[j] - 1] - (s >= 1 ? sum[j][s - 1] : 0)));
            }
        }
    }

    cout << dp[(1 << M) - 1] << endl;
    return 0;
}

Measured memory_bytes: 15204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int m=0;
  bool f=1;
  for(int i=0;i<n;i++){
    int h;
    cin>>h;
    if(m-h<2)
      m=max(m,h);
    else
      f=0;
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,s,f,t,a,b,c;
	scanf("%d",&t);
	while(t!=0) {
		b=0;
		scanf("%d",&n);
		for(i=1;i<=n;i++) {
			scanf("%d %d",&s,&f);
			a=f-s;
			b+=a;
		}
		if(b>=t) {
			printf("OK\n");
		}
		if(b<t){
			c=t-b;
			printf("%d\n",c);
		}
	scanf("%d",&t);
	}
	return 0;
}

Measured memory_bytes: 612
local read = io.read
local max = math.max
local min = math.min


local function gcd(x, y)
	if y == 0 then
		return x
	else
		return gcd(y, x % y)
	end
end

local function main()
	local n = read("n")
	local last_gcd = 0
	local a_t = {}
	local a_max = 0

	for i = 1, n do
		local a_i = read("n")
		a_t[i] = a_i
		a_max = max(a_max, a_i)
		last_gcd = gcd(max(last_gcd, a_i), min(last_gcd, a_i))
	end
	if last_gcd ~= 1 then
		print("not coprime")
		return
	end

	local num_t = {}
	for i = 1, a_max do
		num_t[i] = 0
	end
	for i = 1, n do
		num_t[a_t[i]] = num_t[a_t[i]] + 1
	end

	-- [2, a_iの最大値]の数を全探索(1は含まない)
	for i = 2, a_max do
		local count = 0
		-- iの倍数の中にa_iが存在するとカウントアップ
		for j = i, a_max, i do
			count = count + num_t[j]
		end
		-- 1つより大きければ重複しているので
		if count > 1 then
			print("setwise coprime")
			return
		end
	end
	print("pairwise coprime")
end

main()

Measured memory_bytes: 35244
N,Y = map(int, input().split())

for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

R = ir()
target = np.array([1200, 2800])
i = np.searchsorted(target, R, side='right')
answer = ['ABC', 'ARC', 'AGC'][i]
print(answer)


Measured memory_bytes: 12384
#include <iostream>

using namespace std;

int main(){

    int n_team;
    int n_paly;
    int team_a, team_b;
    int goal_a, goal_b;
    int i, j;
    int temp;

    cin >> n_team;
    n_paly = n_team * (n_team-1) / 2;

    int score[n_team+1] = {0};
    int rank[n_team+1] = {0};

    for(i=0; i<n_paly; i++){
        cin >> team_a >> team_b >> goal_a >>goal_b;

        if(goal_a > goal_b){
            score[team_a]+=3;
        } else if(goal_b > goal_a){
            score[team_b]+=3;
        } else if(goal_a == goal_b){
            score[team_a]++;
            score[team_b]++;
        }
    }

    for(i=1; i<=n_team; i++){
        rank[i] = 1;

        for(j=1; j<=n_team; j++){
            if(score[i] < score[j]){
                rank[i]++;
            }
        }

    }

    for(i=1; i<=n_team; i++){
        cout << rank[i] << endl;
    }

}


Measured memory_bytes: 3096
import numpy as np

n = int(input())

a = [int(i) for i in input().split()]
a = np.array(a)
b = np.zeros(n)
b_ind = np.arange(1, n + 1)
b[n // 2 + 1:] = a[n // 2 + 1:]

for i in range(n // 2 + 1, 0, -1):
    if np.sum(b[i - 1::i]) % 2 == a[i - 1]:
        b[i - 1] = 0
    else:
        b[i - 1] = 1

m = b[b == 1].shape[0]
print(m)
if m != 0:
    print(" ".join(map(str, b_ind[b == 1])))


Measured memory_bytes: 25600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	static long MOD = 1000_000_000 + 7;

	void run() {
		solver();
	}

	long calc(int[] len, int n) {
		long[][][] dp = new long[4][800][200];

		for (int idx = 0; idx < 4; idx++) {
			if (len[idx] > 0)
				len[idx]--;
			else
				continue;
			dp[idx][0][0] = 1;
			for (int length = 1; length <= 4; length++) {
				for (int k = 0; k < len[length - 1]; k++) {
					for (int i = 799; i >= length; i--) {
						for (int j = 199; j >= 1; j--) {
							if (dp[idx][i - length][j - 1] > 0) {
								dp[idx][i][j] += dp[idx][i - length][j - 1] * j;
								dp[idx][i][j] %= MOD;
							}
						}
					}
				}
			}
			len[idx]++;
		}
		long ans = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 800; j++) {
				for (int k = 0; k < 200 && n - 1 - k >= 0; k++) {
					if (dp[i][j][k] > 0) {
						ans = (ans + dp[i][j][k] * pow10[j] % MOD * sum[i] % MOD * perm[(n - 1) - k]) % MOD;
					}
				}
			}
		}
		return ans;
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] len = new int[4];
		sum = new long[4];
		int zero_idx = -1;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (a[i] == 0)
				zero_idx = i;
			len[(a[i] + "").length() - 1]++;
			sum[(a[i] + "").length() - 1] += a[i];
		}

		pow10[0] = 1;
		for (int i = 1; i < pow10.length; i++) {
			pow10[i] = (pow10[i - 1] * 10) % MOD;
		}
		for (int i = 0; i < 200; i++) {
			long factorial = 1;
			perm[i] = 1;
			for (int j = i; j >= 1; j--) {
				factorial = (factorial * j) % MOD;
				perm[i] = (perm[i] + factorial) % MOD;
			}
		}

		long ans = calc(len, n);
		if (zero_idx != -1) {
			len[0]--;
			ans = (ans - calc(len, n - 1) + MOD) % MOD;
		}
		System.out.println(ans);
	}

	long[] pow10 = new long[810];
	long[] sum;
	long[] perm = new long[200];
}

Measured memory_bytes: 39156
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2+10
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 )

def g(r,c):
    tmp=0
    for i in range(1,r+2):
        tmp+=cmb(i+c,i)
        tmp%=mod
    return tmp

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)

Measured memory_bytes: 224868
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;


constexpr int MAX_V = 1000;

//行先、容量、逆辺
struct edge { LL to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, LL cap) {
	G[from].emplace_back(edge{ to, cap, (LL)G[to].size() });
	G[to].emplace_back(edge{ from,0,(LL)G[from].size() - 1 });
}

//増加パスをDFSで探す
LL dfs(LL v, LL t, LL f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			LL d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

//sからtへの最大流を求める
LL max_flow(int s, int t) {
	LL flow = 0;
	while (true) {
		for (int i = 0; i < MAX_V; i++)used[i] = false;
		LL f = dfs(s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}

int main() {
	int n;
	cin >> n;
	int a;
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a <= 0)add_edge(200, i, -a);
		else add_edge(i, 300, a), sum += a;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if ((j + 1) % (i + 1) == 0)add_edge(i, j, INF);
		}
	}
	cout << sum - max_flow(200, 300) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int n;
	int a;
	int b;
	scanf("%d\n%d %d\n", &n, &a, &b);
	int p[100];
	for(int i=0;i<100;i++){
		p[i]=20;
	}
	for(int i=0;i<n;i++){
		scanf("%d\n", &p[i]);
	}
	int fir=0;
	int sec=0;
	int thi=0;
	int ans=0;
	for(int i=0;i<n;i++){
		if(p[i]<=a){
			fir++;
		}else if(p[i]<=b){
			sec++;
		}else{
			thi++;
		}
	}
	ans=fir;
	if(sec<ans){
		ans=sec;
	}
	if(thi<ans){
		ans=thi;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
from itertools import accumulate

# k個選んだ時の最小値と最大値が分かれば、個数が分かる？？
n,k = list(map(int, input().split()))
cumsum   = list(accumulate(range(n+1)))
cumsum_r = list(accumulate(range(n+1)[::-1]))

MOD = 10**9 + 7
ans = 0
for i in range(k, n+2):
    _min, _max = cumsum[i-1], cumsum_r[i-1]
    ans = (ans + _max - _min + 1) % MOD

print(ans)

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

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int maxx = -101;
    int miny = 101;

    rep(i, n){
        int x_;
        cin >> x_;
        maxx = max(maxx, x_);
    }
    rep(i, m){
        int y_;
        cin >> y_;
        miny = min(miny, y_);
    }

    if(max(maxx, x) < min(miny, y)) puts("No War");
    else puts("War");
}

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

using namespace std;

int main(){
    long long A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if(abs(B-A)+(W-V)*T<=0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3636
from copy import deepcopy
S = input()
n = len(S) - 1
C = 0
for bit in range(2 ** n):
    T = list(S)
    U = []
    for i in range(n + 1):
        U.append(T[i])
        if (bit & (1 << i)):
            U.append('+')
    V = ''
    for u in U:
        V += u
    C += eval(V)
print(C)

Measured memory_bytes: 9248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int sum=0;
		int c1=sc.nextInt();
		sum+=c1;
		int c2=sc.nextInt();
		sum+=c2*5;
		int c3=sc.nextInt();
		sum+=c3*10;
		int c4=sc.nextInt();
		sum+=c4*50;
		int c5=sc.nextInt();
		sum+=c5*100;
		int c6=sc.nextInt();
		sum+=c6*500;
		if(sum>=1000) {
			pl(1);
		}
		else {
			pl(0);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static int root(int a) {

		int ketasu=0;
		int tmp=a;
		while(tmp>0) {
			ketasu++;
			tmp/=10;
		}
		int constant=(ketasu+1)/2;	//よく使うので定数化
		if(ketasu>=1) {
			int[] suuji=new int[constant];
			tmp=a;
			for(int i=0; i<constant; i++) {
				suuji[constant-1-i]=a%100;
				a/=100;
			}
			int ans=0;
			int kai=0;
			int mae=0;
			if(constant<=1) {
				for(int i=10; i>=0; i--) {
					if(suuji[0]>=i*i) {
						return i;
					}
				}
			}
			else {
				for(int i=0; i<constant; i++) {
					mae+=kai*2;
					for(int j=9; j>=0; j--) {
						if((mae*10+j)*j<=suuji[i]) {
							ans=ans*10+j;
							mae*=10;
							kai=j;
							if(i+1<constant) {
								suuji[i+1]+=(suuji[i]-(mae+j)*j)*100;
							}
							break;
						}
					}
				}
			}
			return ans;
		}
		else {
			return 0;
		}
	}
}


Measured memory_bytes: 24360
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// 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;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> B(N-1);
  REP(i, N-1) cin >> B[i];

  int ans = B[0]+B[N-2];
  REP(i, N-2){
    ans += min(B[i], B[i+1]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL N;
  string s;
  cin >> N >> s;
  LL r = 0;
  LL b = 0;
  REP(i, N)
  {
    if(s[i]=='R'){
      r++;
    }else{
      b++;
    }
  }

  if(r>b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def main():
    H,  N = map(int, input().split())
    A = list(map(int, input().split()))

    flag = False

    for a in A:
        H -= a
        if H <= 0:
            flag = True
            break
    if flag:print("Yes")
    else: print("No")






if __name__ == "__main__":
    main()

Measured memory_bytes: 13964
#include <iostream>
#define INF 100000000000000
using namespace std;

int main(){
    long long H, W;
    cin >> H >> W;
    long long dS1 = INF, dS2 = INF, dS3 = INF, dS4 = INF;
    if(H >= 3){
        if(H%3 == 0){
            cout << 0;
            return EXIT_SUCCESS;
        }else{
            dS1 = W;
        }
    }
    if(W >= 3){
        if(W%3 == 0){
            cout << 0;
            return EXIT_SUCCESS;
        }else{
            dS2 = H;
        }
    }
    for(long long i=1; i<=H-1; i++){
        long long S1 = W*i;
        long long S2 = (H-i)*(W/2);
        long long S3 = (H-i)*(W-W/2);
        long long Smin = min(min(S1, S2), S3);
        long long Smax = max(max(S1, S2), S3);
        if(Smax-Smin <= dS3){
            dS3 = Smax-Smin;
        }
    }
    for(long long i=1; i<=W-1; i++){
        long long S1 = H*i;
        long long S2 = (W-i)*(H/2);
        long long S3 = (W-i)*(H-H/2);
        long long Smin = min(min(S1, S2), S3);
        long long Smax = max(max(S1, S2), S3);
        if(Smax-Smin <= dS4){
            dS4 = Smax-Smin;
        }
    }
    cout << min(dS1, min(dS2, min(dS3, dS4)));
    return EXIT_SUCCESS;
}

Measured memory_bytes: 764
//                        Bismillahir Rahmanir Rahim
    //ALGO:
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize ("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define pb push_back
    #define F first
    #define S second
    #define all(v) v.begin(), v.end()
    #define FILL(a, x) memset(a, x, sizeof(a))
    #define ll long long
    #define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define INF INT_MAX
    /*
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
    */
    const double Pi=acos(-1);
    using namespace std;
    int debug=01;
    ll cost[110], value[110], n, mx, dp[110][100010], ans, sum;
    ll solve(ll i, ll x, ll y){
        if(i>n) return 0;
        if(~dp[i][x]) return dp[i][x];
        ans=max(ans, x);
        ll ret=solve(i+1, x, y);
        if(cost[i]+y<=mx) ret=min(ret, solve(i+1, x+value[i], y+cost[i])+cost[i]);
        return dp[i][x]=ret;
    }
    ll solve(int i, ll val){
        if(val<=0) return 0;
        if(i==n) return mx+mx;
        if(~dp[i][val]) return dp[i][val];
        return dp[i][val]=min(solve(i+1, val), solve(i+1, val-value[i])+cost[i]);
    }
    int main() {
        cin>>n>>mx;
        FILL(dp, -1);
        for(int i=0; i<n; i++) scanf("%lld%lld", &cost[i], &value[i]), sum+=value[i];
        while(sum--) if(solve(0, sum+1)<=mx) {cout<<sum+1; return 0;}
        cout<<0;
    }



Measured memory_bytes: 86144
A, B, K = map(int, input().split())

tmp_s = {i for i in range(A, A+K)}
tmp_l = {i for i in range(B+1-K, B+1)}

ans = list(tmp_s.union(tmp_l))
ans = [i for i in ans if A<=i<=B]
ans.sort()

print(*ans, sep="\n")

Measured memory_bytes: 9212
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;


int main(){
	int N,M,K,D,A[10]={};
	cin >> N >> K;
	for(int i=0; i<K; i++){
		cin >> A[i];
	}
	N*=10;
	M=N;
	while(N!=0){
		for(int i=0; i<K; i++){
		if(N%10==A[i]){
			 N=M+1;
		M=N;
		break;
		}
	}N/=10;
	}
	cout << M/10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int k, s;
    cin >> k >> s;

    int res = 0;

    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) res++;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  h[0]--;
  repi(i,1,n){
    if(h[i]>h[i-1])h[i]--;
    else if(h[i]<h[i-1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;


  return 0;

}


Measured memory_bytes: 1024
a=input()
b=input()
c=input()
dic={'a':[_ for _ in a],'b':[_ for _ in b],'c':[_ for _ in c]}
char='a'
for i in range(len(a)+len(b)+len(c)):
    if len(dic[char]) == 0:
        break
    char = dic[char].pop(0)
print(char.upper())

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int tot=0;
	vector<int>a(n);trav(i,a)i=in();
	int neg=count_if(all(a),[&](int x){return x<0;});
	//cout<<neg<<'\n';
	int mn=INT_MAX;for(auto i:a){mn=min(mn,abs(i));tot+=abs(i);}
	
	if(neg%2==1){tot-=2*mn;}
	cout<<tot;
	
}

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);

    for (int &i : a)
        cin >> i;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if ((a[i] != a[j]) && (a[j] != a[k]) && (a[i] != a[k])) {
                    if ((a[i] + a[j] > a[k]) && (a[j] + a[k] > a[i]) && (a[i] + a[k] > a[j])) {
                        ++ans;
                    }
                }
            }
        }
    }

    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int m = 0;
    for (int i = 0; i < n; i++) m = max(a[(i+1)%n] - a[i], m);
    int cnt = 0;
    long long amt = 0;
    int b[n];
    if (m > 0) {
        for (int i = 0; i < n; i++) {
            int d = m - a[(i+1)%n] + a[i];
            if (d % n != 0) { cout << "NO\n"; return 0; }
            else b[i] = d / n;
            cnt += d / n;
            amt += (long long)(n - i) * (d / n);
        }
        for (int i = 0; i < n; i++) {
            a[i] -= amt;
            amt += cnt;
            amt -= n * b[i];
        }
    }

    long long x = (long long)n * (n+1) / 2;
    for (int i = 0; i < n; i++) if (a[0] != a[i] || a[i] % x != 0) { cout << "NO\n"; return 0; }
    cout << "YES\n";
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> mx(n), my(n);
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        mx.at(i) = x + y;
        my.at(i) = x - y;
    }
    sort(mx.begin(), mx.end());
    sort(my.begin(), my.end());
    ll ans = max(mx.at(n-1) - mx.at(0), my.at(n-1) - my.at(0));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6428
# -*- coding: utf-8 -*-
from collections import deque

H,W = list(map(int, input().rstrip().split()))
A_list = [list(input().rstrip()) for i in range(H)]
#-----

def check(matrix):
    for i in range(len(matrix)):
        matrix[i] = ["#"] + matrix[i][:] + ["#"]
    
    matrix = [["#"]*(W+2)] + matrix[:] + [["#"]*(W+2)]
    
    
    # queue = [ (row, column) ]
    # deque = [ (int, int   ) ]
    queue = deque()
    
    for i in range(1,H+1):
        for j in range(1, W+1):
            if matrix[i][j] == "#":
                queue.append( (i, j) )
    
    
    delta = [(1,0),(-1,0),(0,1),(0,-1)]
    step = -1
    
    while queue:
        step += 1
        
        for _ in range(len(queue)):
            r,c = queue.popleft()
            
            for d in delta:
                next_r = r + d[0]
                next_c = c + d[1]
                
                if matrix[next_r][next_c] == ".":
                    matrix[next_r][next_c] = "#"
                    queue.append( (next_r, next_c) )


    return step

#-----

ans = check(A_list)
print(ans)


Measured memory_bytes: 122460
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
template<typename T>T gcd(T a,T b){while(1){swap(a,b);if(a==0)return b;if(b==0)return a;a%=b;}}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
main(){

  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll e=lcm(c,d);

  ll f=(b-(b/c)-(b/d)+(b/e));
  ll g=((a-1)-((a-1)/c)-((a-1)/d)+((a-1)/e));
  cout<<(f-g)<<endl;

}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n k ->
    let m = 1_000_000_000 + 7 in
    let (+@) a b = (a + b) mod m in
    let rec loop i acc =
        if i > n + 1 then acc else
            let mi = i * (i - 1) / 2 in
            let ma = n * i - mi in
            loop (i + 1) (acc +@ (ma - mi + 1))
    in
    loop k 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double st = 2 * M_PI /(12*60)*(H*60+M);
    double lt = M_PI * M/30.0;
    double theta = abs(lt-st);
    if (theta>M_PI)
    {
        theta = 2 * M_PI - theta;
    }
    
    double c = pow(A*A + B*B-2*A*B*cos(theta),0.5);
    cout << fixed << setprecision(15) << c;
    return 0;
}


Measured memory_bytes: 4356
#include<stdio.h>
int main(){
	int n;
	while(~scanf("%d", &n)){
		if(n==1){
			printf("Hello World\n");
			continue;
		}
		else if(n==2){
			int a, b;
			scanf("%d%d", &a, &b);
			printf("%d\n", a+b);
			continue;
		}
	}
	return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc113/tasks/abc113_d
# あみだくじは, 日本に古くから伝わる伝統的なくじ引きである.
# あみだくじを作るには, まず W 本の平行な縦線を引き, 次にそれらを繋ぐ横線を引いていく.
# それぞれの縦棒の長さは H+1 [cm] であり、
# 横線の端点となれるのは上から 1,2,3,...,H [cm] の位置のみである.
# ここで,「正しいあみだくじ」とは, 以下のような条件を満たすあみだくじのことである.
# どの 2 つの横棒も端点を共有しない.
# それぞれの横棒の 2 つの端点は同じ高さになければならない.
# 横棒は隣り合う縦線を繋がなければならない.

# 縦棒 1 の上端から, 横線があれば必ずそれを通るというルールで下へたどったときに,
#  最終的にたどり着く縦棒の番号が K となるような「正しいあみだくじ」の本数を 1 000 000 007 で割った余りを求めなさい.
# H は 1 以上 100 以下の整数
# W は 1 以上 8 以下の整数
# K は 1 以上 W 以下の整数
# H W K
# 15 8 5
# 437760187
H, W, K = gets.split.map(&:to_i)

FIB = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
MOD = (10**9) + 7

def getc(a,b)
  # p "#{a} #{b} #{FIB[a] * FIB[W-b-1]}"
  FIB[a] * FIB[W-1-b]
end

dp = Array.new(H+1) { Array.new(W, 0) }
dp[0][0] = 1
1.step(H) do |h|
  W.times do |w|
    dp[h][w]   += (dp[h-1][w].to_i * getc(w,   w))%MOD
    dp[h][w-1] += (dp[h-1][w].to_i * getc(w-1, w))%MOD if w != 0
    dp[h][w+1] += (dp[h-1][w].to_i * getc(w, w+1))%MOD if w != W-1
  end
end
p dp[H][K-1]%MOD

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l;cin>>l;
    int t1=l;
    int d1=0;
    bool te[20];
    int ce=0;
    rep(i,20)te[i]=0;
    while(l)
    {
        if(l&1)
        {
            te[d1]=1;
            ce++;
        }
        l>>=1;
        d1++;

    }
    cout<<d1<<" "<<(d1-1)*2+ce-1<<endl;
    l=t1;
    int t=1;
    for(int i=1;i<d1;i++)
    {
        cout<<i<<" "<<i+1<<" "<<0<<endl;
        cout<<i<<" "<<i+1<<" "<<t<<endl;
        if(te[i-1])
        {
            cout<<i<<" "<<d1<<" "<<l-t<<endl;
            l-=t;
        }
        t<<=1;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
 
n = int(input())
l = list(map(int,input().split()))

if 0 in l:print(0);exit()

a=10**18
ans=1
for i in l:
    ans*=i
    if ans > a:print(-1);exit()

print(ans)

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

using namespace std;

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

	int m, d;

	cin >> m >> d;

	int ans = 0;

	for(int i = 1; i <= m; ++i){
		for(int j = 20; j <= d; ++j){
			if((j % 10) < 2){
				continue;
			}

			if((j % 10) * (j / 10) == i){
				++ans;
				//cout << j << " " << i << endl;
			}
		}
	}

	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 892
using System;

namespace A___Trapezoids
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var h = int.Parse(Console.ReadLine());
            var area = (a + b) * h / 2;
            Console.WriteLine(area);
        }
    }
}

Measured memory_bytes: 13140
//raja1999

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

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//std::ios::sync_with_stdio(false);
vii ans;
main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,k,i,val,j,ans1;
	cin>>n>>k;
	val=(n-2)*(n-1)/2;
	if(k>val){
		cout<<-1<<endl;
	}
	else{
		ans1=n-1;
		ans1+=val-k;
		cout<<ans1<<endl;
		rep(i,n-1){
			cout<<i+1<<" "<<n<<endl;
		}
		rep(i,n-1){
			f(j,i+1,n-1){
				ans.pb(mp(i+1,j+1));
			}
		}
		i=0;
		while(val>k){
			cout<<ans[i].ff<<" "<<ans[i].ss<<endl;
			i++;
			val--;
		}
	}
	return 0;
} 
	

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

int main() {
    string s; cin >> s; int N = s.size();
    ll ans = 0;
    ll tmp = 0;
    int i = 0;
    while(i<N) {
        if(i+1<N && s[i]=='B' && s[i+1]=='C') {
            ans += tmp;
            i += 2;
        }
        else if(s[i]=='A') {
            tmp ++;
            i ++;
        }
        else {
            tmp = 0;
            i ++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int get_max(int n, vector<int> a, int* max, int* max_idx){
    int i;
    for(i=0; i<n; i++){
        if (a[i] > *max){
            *max = a[i];
            *max_idx = i;
        }
    }
}

int main(){
    int i, n;
    cin >> n;
    vector<int> a(n);
    for(i=0; i<n; i++)
        cin >> a[i];

    int alice = 0, bob = 0;
    int max=0, max_idx=0;
    for (i=0; i<n; i++){
        // get max value of arrray
        get_max(n, a, &max, &max_idx);
        // alice turn
        if (i%2==0){
            alice+=max;
        }
        // bob turn
        else{
            bob+=max;
        }
        // 取得した場所は0にする
        a[max_idx] = 0;
        // 次のループのために初期化
        max = 0;
        max_idx = 0;
    }
    // cout << alice << endl;
    // cout << bob << endl;
    cout << alice-bob << endl;
}

Measured memory_bytes: 256