akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    N, K = map(int, rl().split())
    MOD = 10 ** 9 + 7
    
    com = Combination(2010, MOD)
    
    ans = []
    for i in range(1, K + 1):
        ans.append(com.ncr(N - K + 1, i) * com.ncr(K - 1, i - 1) % MOD)
    print(*ans, sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
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; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int second_gcd(int a,int b, int k){
    int c = min(a, b);
    while(k != 0){
        if(a % c == 0 && b % c == 0){
            k--;
        }
        c--;
    }
    return c + 1;
}

int main()
{
    INIT;
    int a, b, k;
    scanf("%d%d%d",&a, &b, &k);
    printf("%d",second_gcd(a, b, k));
    return 0;
}

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	vector<long long> prefix(m);
	for (int i = 0; i < m; i++) {
		prefix[i] = b[i];
		if (i)
			prefix[i] += prefix[i - 1];
	}
	int ans = 0, ptr = m - 1;
	for (int i = 0; i <= n; i++) {
		if (k < 0)
			break;
		while (ptr >= 0 && prefix[ptr] > k) {
			ptr--;
		}
		ans = max(ans, i + ptr + 1);
		if (i < n)
			k -= a[i];
	}
	cout << ans << '\n';
}



Measured memory_bytes: 6348
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
INF = 10000000000000000000
M = [[-1]*n for _ in range(n)]
for i in data:
    for j in range(i[1]):
        M[i[0]][i[2+j*2]] = i[3+j*2]
color = ['White']*n
d = [INF]*n
p = [None]*n

d[0] = 0
p[0] = -1

while True:
    minct = INF
    for i in range(n):
        if color[i] != 'Black' and d[i] < minct:
            minct = d[i]
            u = i
    if minct == INF:
        break
    color[u] = 'Black'
    for j in range(n):
        if color[j] != 'Black' and M[u][j] != -1:
            if d[u] + M[u][j] < d[j]:
                d[j] = d[u] + M[u][j]
                p[j] = u
                color[j] = 'Gray'
for i in range(n):
    print('{} {}'.format(i, d[i]))


Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin h,w;
lin a[501][501];
vector<lin> p,q,r,s;

int main(void)
{
    cin >> h >> w;
    rep(i,h)
    {
        rep(j,w)
        {
            cin >> a[j][i];
        }
    }

    rep(y,h)
    {
        rep(i,w)
        {
            lin x = y % 2 == 0 ? i : (w-i-1);
            if(a[x][y] % 2 == 1)
            {
                lin nx = y % 2 == 0 ? (x+1) : (x-1);
                lin ny = y;
                if(nx < 0)
                {
                    nx = 0;
                    ny++;
                }
                else if(nx >= w)
                {
                    nx = w-1;
                    ny++;
                }

                if(ny < h)
                {
                    a[nx][ny]++;
                    p.push_back(y+1);
                    q.push_back(x+1);
                    r.push_back(ny+1);
                    s.push_back(nx+1);
                }
            }
        }
    }

    cout << p.size() << endl;
    rep(i, p.size())
    {
        cout << p[i] << " ";
        cout << q[i] << " ";
        cout << r[i] << " ";
        cout << s[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 8148
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

string s;
int idx;

int number() {
	int res = 0;
	while(idx < (int)s.size() && isdigit(s[idx])) {
		res *= 10;
		res += s[idx] - '0';
		++idx;
	}

	return res;
}

int rec() {
	if(s[idx] == '[') {
		vector<int> lis;
		while(s[idx] == '[') {
			++idx;
			lis.push_back(rec());
 			++idx;
		}

		int res = 0;
		sort(lis.begin(), lis.end());
		const int m = (lis.size() + 1) / 2;
		for(int i = 0; i < m; ++i) {
			res += lis[i];
		}

		return res;
	}
	else {
		return (number() + 1) / 2;
	}
}

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

	int n;
	cin >> n;

	while(n--) {
		cin >> s;
		idx = 0;
		cout << rec() << endl;
	}

	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
    vector<string> S(3);
    for(int i=0;i<3;i++){
        cin>>S.at(i);
    }
    for(int i=0;i<3;i++){
        cout<<S.at(i).at(i);
    }
    cout<<endl;
  }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int n = 0;
		string ans = "YES";
		while(n < str.Length){
			if(str.Length - n < 5){
				ans = "NO";
				break;
			}
			if(str.Substring(n,5) == "dream"){
				if(str.Length - n >= 7 && str.Substring(n,7) == "dreamer"){
					if(str.Length - n >= 10 && str.Substring(n,10) == "dreamerase"){
						if(str.Length - n >= 11 && str.Substring(n,11) == "dreameraser"){
							n += 11;
						} else {
							n += 10;
						}
					} else {
						n += 7;
					}
				} else {
					n += 5;
				}
			} else if(str.Substring(n,5) == "erase"){
				if(str.Length - n >= 6 && str.Substring(n,6) == "eraser"){
					n += 6;
				} else {
					n += 5;
				}
			} else {
				ans = "NO";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13116
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N;
  cin>>N;
  ll red=0;
  ll green=0;
  ll blue=0;
  string S;
  cin>>S;
  rep(i,N){
    if(S[i]=='R')red++;
    else if(S[i]=='B')blue++;
    else green++;
  }
  ll ans=red*green*blue;
  rep(i,N-2){
    rep(j,N){
      if(i+2*j+3<=N){
        if(S[i]!=S[i+j+1]&&S[i]!=S[i+2*j+2]){
          if(S[i+j+1]!=S[i+2*j+2])ans--;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;
int N;
vector<vector<pint>> v;
bool judge(int bit){
    for (int i=0;i<N;i++){
        if (!(bit&(1<<i))) continue;
        for (auto xy : v[i]){
            int x = xy.first;
            int y = xy.second;
            if (y==1 && !(bit & (1<<x))) return false;
            if (y==0 && (bit & (1<<x))) return false;
        }
    }
    return true;
}
int main() {
    cin >> N;
    v.resize(N);
    for (int i=0;i<N;i++){
        int A; cin >> A;
        v[i].resize(A);
        for (int j=0;j<A;j++){
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }
    int res = 0;
    for (int bit=0; bit < (1<<N);bit++){
        if (judge(bit)){
            int cnt = 0;
            for (int i=0;i<N;i++) if (bit&(1<<i)) cnt++;
            res = max(cnt, res);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import collections as cl

N, P = map(int, input().split())
if P == 1:
    print(1)
    exit()
P_prime = []
while P % 2 == 0:
    P_prime.append(2)
    P //= 2
odd = 3
while odd * odd <= P:
    if P % odd == 0:
        P_prime.append(odd)
        P //= odd
    else:
        odd += 2
if P != 1:
    P_prime.append(P)

ans = 1
dic_P = cl.Counter(P_prime)
for prime, num in dic_P.items():
    ans *= pow(prime, num // N)
print(ans)


Measured memory_bytes: 3316
N = int(input())
hxy = []
for _ in range(N):
    x, y, h = map(int, input().split())
    hxy.append((h, x, y))
hxy.sort(reverse=True)
for x in range(101):
    for y in range(101):
        H = abs(hxy[0][1] - x) + abs(hxy[0][2] - y) + hxy[0][0]
        for j in range(1, N):
            if max(0, H - abs(x - hxy[j][1]) - abs(y - hxy[j][2])) == hxy[j][0]:
                continue
            else:
                break
        else:
            print(x, y, H)

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int N; cin >> N;
	auto profits = vector<int>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> profits[i];
	}
	int  c;
	for (size_t i = 0; i < N; i++) {
		cin >> c;
		profits[i] -= c;
	}
	auto sum = 0;
	for (size_t i = 0; i < N; i++) {
		sum += max(0, profits[i]);
	}
	cout << sum << endl;
	return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> L(M);
  vector<int> R(M);
  for (int i = 0; i < M; i++) cin >> L.at(i) >> R.at(i);
  
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  
  if (L.at(M - 1) > R.at(0)) {
    cout << 0 << endl;
  } else {
    cout << R.at(0) - L.at(M - 1) + 1 << endl;
  }
}

Measured memory_bytes: 1024
fn main() {
    let n = read::<usize>();
    let mut titles = vec![];
    let mut times = vec![];

    for _ in 0..n {
        let v = read_vec::<String>();
        let title = v[0].clone();
        let time = v[1].parse::<u32>().unwrap();
        titles.push(title);
        times.push(time);
    }
    let last_title = read::<String>();

    let mut f = false;
    let mut count = 0;
    for i in 0..n {
        if f {
            count += times[i];
        }
        if last_title == titles[i] {
            f = true;
        }
    }
    println!("{}", count);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  string s;
  cin>>n>>s;
  Int ans=0;
  for(Int i=1;i<n;i++){
    string a=s.substr(0,i);
    string b=s.substr(i);
    set<char> x(a.begin(),a.end()),y(b.begin(),b.end());
    Int res=0;
    for(char c:x) res+=y.count(c);
    chmax(ans,res);
  }  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};




int main(){
  string s;
  cin >> s;
  int N = s.size()-1;
  int ans = 0;
  rep(i,N/2 + 1) if(s[i] != s[N-i]) ans++;
  cout << ans << endl;
  return 0;
}



// int gcd(int a, int b){
//   if (b==0) return a;
//   else return gcd(b,a%b);
// }


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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


Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(n, m int, ab [][2]int) int {
        // 友達集合を作る
        uf := NewUnionFind(n)
        for i := 0; i < m; i++ {
                a := ab[i][0] - 1
                b := ab[i][1] - 1
                uf.unite(a, b)
        }

        // 最大の友達集合を求める
        max := func(x, y int) int {
                if x > y {
                        return x
                }
                return y
        }
        out := 0
        for i := 0; i < n; i++ {
                out = max(out, uf.size(i))
        }
        return out
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n, m int
        fmt.Fscan(r, &n, &m)
        ab := make([][2]int, m)
        for i := range ab {
                fmt.Fscan(r, &ab[i][0], &ab[i][1])
        }
        fmt.Println(solution(n, m, ab))
}

type UnionFind struct {
        d []int
}

func NewUnionFind(n int) *UnionFind {
        d := make([]int, n)
        for i := 0; i < n; i++ {
                d[i] = -1
        }
        return &UnionFind{d: d}
}

func (uf *UnionFind) find(x int) int {
        if uf.d[x] < 0 {
                return x
        }
        uf.d[x] = uf.find(uf.d[x])
        return uf.d[x]
}

func (uf *UnionFind) unite(x, y int) bool {
        x, y = uf.find(x), uf.find(y)
        if x == y {
                return false
        }
        if uf.d[x] > uf.d[y] {
                x, y = y, x
        }
        uf.d[x] += uf.d[y]
        uf.d[y] = x
        return true
}

func (uf *UnionFind) same(x, y int) bool {
        return uf.find(x) == uf.find(y)
}

func (uf *UnionFind) size(x int) int {
        return -uf.d[uf.find(x)]
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S;
    cin >> S;
    bool ok = true;
    for (i32 i = 1; i <= S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i - 1] == 'R') ok = false;
        } else {
            if (S[i - 1] == 'L') ok = false;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
using namespace std;
long long N, W, w[1000], v[1000]; vector<long long>a[4];
int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; a[w[i] - w[0]].push_back(v[i]); }
	for (int i = 0; i < 4; i++) {
		sort(a[i].begin(), a[i].end(), greater<long long>());
		for (int j = 1; j < a[i].size(); j++)a[i][j] += a[i][j - 1];
	}
	long long maxn = 0;
	for (int i = 0; i <= a[0].size(); i++) {
		for (int j = 0; j <= a[1].size(); j++) {
			for (int k = 0; k <= a[2].size(); k++) {
				for (int l = 0; l <= a[3].size(); l++) {
					long long P = 1LL * (w[0] + 0LL)*i + 1LL * (w[0] + 1LL)*j + 1LL * (w[0] + 2LL)*k + 1LL * (w[0] + 3LL)*l;
					if (P > W)continue;
					long long cnt = 0;
					if (i >= 1)cnt += a[0][i - 1];
					if (j >= 1)cnt += a[1][j - 1];
					if (k >= 1)cnt += a[2][k - 1];
					if (l >= 1)cnt += a[3][l - 1];
					maxn = max(maxn, cnt);
				}
			}
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dp[101][100001];


int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, maxn;

    cin >> n >> maxn;

    int w[n+1];
    int v[n+1];

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

    for(int j=0; j <= maxn; j++)dp[0][j] = 0;
    //for(int j=0; j <= 104; j++)dp[j][0] = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= maxn; j++){
                if(j >= w[i]){
                    dp[i][j] = max((v[i]+dp[i-1][j-w[i]]),(dp[i-1][j]));
                }
                else{
                    dp[i][j] = dp[i-1][j];
                }
        }
    }

    cout << dp[n][maxn] << endl;
/*
    FOR(i,0,n+1){
        FOR(j,0,maxn+1)
            cout << dp[i][j] << "   ";
        cout << endl;
    }
*/


	return 0;
}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean[] is=new boolean[1299710];
		Arrays.fill(is, true);
		is[0]=is[1]=false;
		for(int i=2;i*i<is.length;i++){
			if(is[i]){
				for(int j=i+i;j<is.length;j+=i){
					is[j]=false;
				}
			}
		}
		for(int i=0;i<100;i++){
//			System.out.println(i+" "+is[i]);
		}
		while(true){
			int n=cin.nextInt();
			if(n==0)break;
			if(is[n]){
				System.out.println(0);
				continue;
			}
			int res=1;
			for(int i=n+1;i<is.length;i++){
				if(!is[i]){
					res++;
				}
				else{
					break;
				}
			}
			for(int i=n-1;i>=0;i--){
				if(!is[i]){
					res++;
				}
				else{
					break;
				}
			}
			System.out.println(res+1);
		}

	}

}

Measured memory_bytes: 24348
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 100;
ll mod = INF;

int n;
int b[maxn];
int ans=0;

int main(){
    cin >> n;
    rep(i,n-1)cin >> b[i];
    rep(i,n){
        if(i==0)ans+=b[0];
        else if(i==n-1)ans+=b[n-2];
        else ans+=min(b[i],b[i-1]);
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
N = int(input())
n = 10**4
tmp = [0]*((10**4)+1)
for x in range(1,int(-(-n**0.5//1))+1):
    for y in range(1,x+1):
        for z in range(1, y+1):
            if x*x + y*y + z*z + x*y + y*z + z*x <= 10**4:
                if x == y and y == z and z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x] +=1
                elif x == y or y == z or z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 3
                else:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 6
for i in range(1, N+1):
    print(tmp[i])

Measured memory_bytes: 69648
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		if(N%1000 == 0) {
			System.out.println("0");
		}else {
			System.out.println(1000 - N%1000);
		}
		stdIn.close();
	}
}

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

namespace ABC025A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,d;
            a = int.Parse(Console.ReadLine());
            b= int.Parse(Console.ReadLine());
            c= int.Parse(Console.ReadLine());
            d = (a + b) * c / 2;
            Console.WriteLine(d);
            Console.ReadKey();
                }
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////


int main() {
	ll a, b;
	cin >> a >> b;
	if (a + b == 15) wrln("+");
	else if (a * b == 15) wrln("*");
	else wrln("x");
	return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.range;
import std.stdio;
import std.typecons;

void main ()
{
	int n, m, s, t;
	while (readf (" %s %s %s %s", &n, &m, &s, &t) > 0)
	{
		s -= 1;
		t -= 1;
		alias Edge = Tuple !(int, q{v}, int, q{c});
		auto g = new Edge [] [n];
		auto h = new Edge [] [n];
		foreach (j; 0..m)
		{
			int u, v, a, b;
			readf (" %s %s %s %s", &u, &v, &a, &b);
			u -= 1;
			v -= 1;
			g[u] ~= Edge (v, a);
			g[v] ~= Edge (u, a);
			h[u] ~= Edge (v, b);
			h[v] ~= Edge (u, b);
		}

		auto shortestPaths (ref Edge [] [] a, int x)
		{
			auto d = new long [n];
			d[] = long.max;
			d[x] = 0;
			alias Record = Tuple !(long, q{d}, int, q{v});
			auto t = redBlackTree !(Record);
			foreach (v; 0..n)
			{
				t.insert (Record (d[v], v));
			}
			while (!t.empty)
			{
				auto v = t.front.v;
				t.removeFront ();
				foreach (ref edge; a[v])
				{
					auto u = edge.v;
					auto r = d[v] + edge.c;
					if (d[u] > r)
					{
						t.removeKey (Record (d[u], u));
						d[u] = r;
						t.insert (Record (d[u], u));
					}
				}
			}
			return d;
		}

		auto d = shortestPaths (g, s);
		auto e = shortestPaths (h, t);

		auto f = new long [n + 1];
		f[$ - 1] = long.max;
		foreach_reverse (i; 0..n)
		{
			f[i] = min (f[i + 1], d[i] + e[i]);
		}

		f[] = 10L ^^ 15 - f[];
		writefln ("%(%s\n%)", f[0..n]);
	}
}


Measured memory_bytes: 36988
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b,c;
    ll k;
    cin>>a>>b>>c>>k;
    
    if(k%2==0){
        cout<<a-b<<endl;
    }else{
        cout<<b-a<<endl;
    }
}


Measured memory_bytes: 256
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll pow2(ll a, ll b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	ll d = pow2(a, b / 2);
	d = d * d % MOD;
	if (b % 2) return d * a % MOD;
	return d;	
}

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	ll ans = pow2(10, n);
	ans += pow2(8, n);
	ans += MOD;
	ans %= MOD;
	ans -= pow2(9, n);
	ans += MOD;
	ans %= MOD;
	ans -= pow2(9, n);
	ans += MOD;
	ans %= MOD;
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

int constexpr MAXW = 100009;
int dp[MAXW];
int N, W;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> W;
    for(int i = 1; i <= N; ++i) {
        int w, v;
        cin >> w >> v;
        for(int j = 0; j <= W; ++j) {
            if(j - w < 0) continue;
            dp[j - w] = max(dp[j - w], dp[j] + v);
        }
    }
    int ans = *max_element(dp, dp + W + 1);
    cout << ans << endl;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  ll n,m;
  cin >> n >> m;
  ll h[n];
  ll ans = 0;
  vector<bool> check(n);
  rep(i,n){
    check[i] = true;
  }
  vector<int> a(m);
  vector<int> b(m);
  rep(i,n)cin >> h[i];
  rep(i,m){
    cin >> a[i] >> b[i];
    if(h[a[i]-1] > h[b[i]-1])check[b[i]-1] = false;
    else if(h[a[i]-1] < h[b[i]-1])check[a[i]-1] = false;
    else{
      check[b[i]-1] = false;
      check[a[i]-1] = false;
    }
  }
  rep(i,n){
    if(check[i] == true)ans++;
  }
  cout << ans << endl;
}

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


int main(){
	bool array[101]={};
	int A,B,C;
	cin >> A >> B >> C;
	int count=0;
	
	while(true){
		count++;
		int D=A*count;
		if(D%B==C){
			cout << "YES" << endl;
			break;
		}
		if(array[D%B]){
			cout << "NO" << endl;
			break;
		}
		array[D%B]=true;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 1000000009 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;
void solve(){
string s,g;
cin>>s>>g;
int n=s.length();
int t=g.length();
int ans=Mod;
fo(i,n-t+1){
    string h=s.substr(i,t);
    int count=0;
    fo(j,t){
     if(h[j]!=g[j])count++;
    }
   ans=min(count,ans);
}
cout<<ans;
}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
  solve();
  


}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 998244353ll;

int main() {
  string S;
  while (cin >> S) {
    int N = S.size();
    vector<ll> dp(2 * N + 10, 0ll);
    dp[0] = 1;
    int sr = 0, sb = 0;
    for (int i = 0; i < 2 * N; i++) {
      if (i < N) {
        if (S[i] == '0') {
          sr += 2;
        } else if (S[i] == '1') {
          sr += 1;
          sb += 1;
        } else {
          sb += 2;
        }
      }
      vector<ll> ndp(2 * N + 10, 0ll);
      for (int r = 0; r <= i; r++) {
        int b = i - r;
        if (sr - r > 0) {
          (ndp[r + 1] += dp[r]) %= MOD;
        }
        if (sb - b > 0) {
          (ndp[r] += dp[r]) %= MOD;
        }
      }
      dp.swap(ndp);
    }
    cout << dp[sr] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize,
    }
    let mut count = 0;
    for d in (1..101).rev() {
        if a % d == 0 && b % d == 0 {
            count += 1;
            if count == k {
                println!("{}", d);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

lint dp[MAXN],a[MAXN];

int main(){
	lint n,k;cin>>n>>k;
	rep(i,n)cin>>a[i];
	rep(i,n+1)dp[i]=linf;dp[0]=0;
	rep(i,n){
		for(int j=1;j<=k;++j)dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
	}cout<<dp[n-1]<<endl;
}

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

int main(){
  string str;

  for(;;){
    getline(cin,str);
    if(str == "END OF INPUT")break;
    
    int pos = 0;
    int ans = 0;
    while(pos<(int)str.size()){
      if(str[pos]==' '){
	cout << ans;
	ans = 0;
      }else ans++;
      pos++;
    }
    cout << ans << endl;
  }
}
      

Measured memory_bytes: 0
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, m, d[10005], pre[10005];

vector<int> g[1005];

struct node
{
	int v, next;
}a[20005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	scanf("%d %d", &n, &m);
	for (int i = 1, u, v; i <= m; i++){
		scanf("%d %d", &u, &v);
		g[u].emplace_back(v);
	}
	int ans = n + 1;
	vector<int> res;
	for (int i = 1; i <= n; i++){
		memset(d, -1, sizeof(d));
		memset(pre, -1, sizeof(pre));
		queue<int> q;
		q.push(i);
		d[i] = 0;
		while(q.size()){
			int x = q.front();
			q.pop();
			for (auto v : g[x]){
				if(d[v] == -1) d[v] = d[x] + 1, pre[v] = x, q.push(v); 
			}
		}
		for (int j = 1; j <= n; j++){
			if(i == j || d[j] == -1) continue;
			for (auto v : g[j]){
				if(v != i) continue;
				vector<int> ve({i});
				int tp = j;
				while(tp != i) ve.push_back(tp), tp = pre[tp];
				if(ans > (int)ve.size()){
					ans = ve.size();
					res = ve;
				}
			}
		}
	}
	if(ans == n + 1) printf("-1\n");
	else{
		printf("%d\n", res.size());
		for (int i = 0; i < (int)res.size(); i++) printf("%d\n", res[i]);
	}

	return 0;
}
/**/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int A = (s[0] - '0') * 10 + (s[1] - '0');
    int B = (s[2] - '0') * 10 + (s[3] - '0');
    if ((A <= 12 && A >= 1) && (B <= 12 && B >= 1)) cout << "AMBIGUOUS" << endl;
    else if (A <= 12 && A >= 1) cout << "MMYY" << endl;
    else if (B <= 12 && B >= 1) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
a, b, k = gets.chomp.split.map(&:to_i)
array = []
a.upto([a + k - 1, b].min) {|i| array << i }
b.downto([b - k + 1, a].max) {|i| array << i }
array = array.uniq.sort
array.each {|i| puts i }

Measured memory_bytes: 1788
N=int(input())
A=list(map(int,input().split()))
ans=1000
st=0

B=[]
T=[]
if A[0]<A[1]:
    st=ans//A[0]
    ans%=A[0]
for i in range(1,N-1):
    if A[i-1]<=A[i] and A[i]>=A[i+1]: #極大
        ans+=A[i]*st
        st=0
    
    elif A[i-1]>=A[i] and A[i]<=A[i+1]: #極小
        st+=ans//A[i]
        ans%=A[i]
#    print(i,ans,st)

if st>0:
    ans+=st*A[-1]
print(ans)

Measured memory_bytes: 9220
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
	int days[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string d[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

	while (1)
	{
		int month;
		int day;
		cin >> month >> day;
		if ( month == 0 && day == 0 )
			break;

		for ( int i = 1; i < month; i++ )
		{
			day += days[i];
		}

		day--;
		int index = day % 7;
		cout << d[index] << endl;

	}

	return 0;
}

Measured memory_bytes: 0
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string S; cin >> S;
  sort(S.begin(), S.end());
  if (S[0] != S[3] && S[0] == S[1] && S[2] == S[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 764
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
     
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[]str= br.readLine().split(" ");
        double a = Double.parseDouble(str[0]);
        
        double circumference  = 2*a*Math.PI;
        double area = a*a*Math.PI;
        System.out.printf("%.6f %.6f",  area, circumference);
    }
}

Measured memory_bytes: 16928
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define bc __builtin_popcount
#define MAXN 200005
#define debug cout<<"we are debuuging"<<endl;
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
bool prime[10000001];
ll prime1[100000001];
void sieve(){
    for(ll i=2;i<1e7+1;i++)
        {//prime[i]=true;
        prime1[i]=2;}
    prime1[0]=prime1[1]=1;
for(ll i=2;i<=1e7+1;i++)
{
    for(ll j=2*i;j<1e7+1;j+=i)
    {

        prime1[j]++;
    }
}
}
int main()
{

     sieve();
     ll n;
     cin>>n;
     if(n==1)
          cout<<1;
     else{
     ll ans=0;
     for(ll i=2;i<=n;i++)
     {
      ans+=(i*prime1[i]);
     }
     cout<<ans+1<<'\n';
     }


}


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

#define int long long
//#define ll int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(vec) (vec).begin(),(vec).end()
#define vint vector<int>
#define pint pair<int,int>
#define vpint vector<pint>

signed main(){
    int n,c;
    cin>>n>>c;
    
    vpint xv(n);
    REP(i,n){
        cin>>xv[i].first>>xv[i].second;
    }
    sort(ALL(xv));
    vint x(n),v(n);
    REP(i,n){
        x[i]=xv[i].first;
        v[i]=xv[i].second;
    }
    
    vint sum(n);
    REP(i,n){
        sum[i]=v[i];
        if(i)sum[i]+=sum[i-1];
    }
    
    int res=0;
    int all=sum[n-1];
    
    vint cz(n),az(n);
    int cw=0,aw=0;
    
    REP(i,n){
        cz[i]=cw=max(cw,sum[i]-x[i]);
    }
    for(int i=n;i--;){
        az[i]=aw=max(aw,(i?(all-sum[i-1]):all)-(c-x[i]));
    }
    REP(i,n){
        res=max(res,(i+1==n?0:az[i+1])+sum[i]-x[i]*2);
    }
    for(int i=n;i--;){
        res=max(res,(i?cz[i-1]:0)+(i?(all-sum[i-1]):all)-(c-x[i])*2);
    }
    
    res=max({res,cw,aw});
    cout<<res<<endl;
}


Measured memory_bytes: 5760
import sys
a,b,c,d,e,f=map(int,input().split())

if a>b:
    a, b = b, a

ans1 = a*100
ans2 = 0

for _a in range(f//(a*100) + 1):
    for _b in range((f - _a*100)//(b*100) + 1):
        
        max_sugar = min(f-(_a+_b)*100, (f-(_a+_b)*100)//100*e)
        
        for _c in range(max_sugar//c + 1):
            for _d in range((max_sugar-c*_c)//d + 1):
                if a*100*_a+b*100*_b+c*_c+d*_d == 0:
                    continue                
                if a*100*_a+b*100*_b+c*_c+d*_d > f:
                    continue  
                    
                if (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) == e/(100+e):
                    print(a*100*_a+b*100*_b+c*_c+d*_d, c*_c+d*_d)
                    sys.exit(0)
                elif (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) > e/(100+e):
                    continue
                else:
                    if ans2/ans1 < (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d):
                        ans1 = a*100*_a+b*100*_b+c*_c+d*_d
                        ans2 = c*_c+d*_d


else:
    print(ans1, ans2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;
 
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}
 
int main() {
	int N;
  	cin >>N;
	ll power = 1;
  	for(int i =1 ; i<= N; i++){
      power = power*i;
      power = power % MOD;
    }
  	cout << power << endl;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


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

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑




int main() {
	string h;
	cin >> h;
	sort(all(h));

	if (h[0] == h[1] && h[1] != h[2] && h[2] == h[3]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
N = int(input())
A = [input() for _ in range(N)]
a = {}
for i in range(N):
  if A[i] in a:
    a[A[i]] += 1
  else:
    a[A[i]] = 1

ans = 0
for i in a.values():
  if i % 2 != 0:
    ans += 1
print(ans)

Measured memory_bytes: 19468
#include<iostream>
using namespace std;
int main()
{
 int k;
 string s;
 cin>>k>>s;
 if(s.length()<=k)
 {
  cout<<s<<"\n";
 }
 else
 {
  for(int i=0;i<k;i++)
  {
   cout<<s[i];
  }
  cout<<"...\n";
 }
 return 0;
 

}

Measured memory_bytes: 3604
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define PI 3.14159265358979323846264338327950L

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

// c^2 = a^2 + b^2 − 2.a.b.cosA

	ll a, b, h, m;
	cin >> a >> b >> h >> m;
	ldb angle = (ldb)((11 * m) - (60 * h)) / 2.0;
	// cout << angle << '\n';
	ldb a_b_cosa = 2 * a * b * cos((PI * angle) / 180);
	// cout << cosa << '\n';
	a *= a; b *= b;
	cout << fixed << setprecision(20) << sqrt((ldb)((a + b) - a_b_cosa)) << '\n';
	return 0;
}

Measured memory_bytes: 4064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var n int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	ans := 1
	for i := 1; i <= n; i++ {
		ans = (ans * i) % 1000000007
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640