akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	map<string,int> v;
	cin >> n;


	FOR(i,n){
		string s;
		cin >> s;
		v[s]+=1;
	}

	int mm=0;

	for(auto& x : v){
		int z=x.second;
		chmax(mm,z);
	}

	for(auto it=v.begin();it!=v.end();it++){
		if(it->second==mm){
			cout << it->first << endl;
		}
	}
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int a, b; cin >> a >> b;
    if(a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if(0 < a) cout << "Positive" << endl;
    else{
        int kosuu = b - a + 1;
        if(kosuu % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        R = N - 1
        lim = (N - 1 - C) if (N - 1) % C else (N // 2)
        while L < lim:
            tmp += S[L] + S[R]
            ans = max(ans, tmp)
            L += C
            R -= C
    return ans

print(main())

Measured memory_bytes: 14860
#include<stdio.h>
#include<string.h>
#define _A_ 1

 
int main(){
  int n,AC=0,i,j,strA,strB;
  int dp[1010][1010];
  char A[1001],B[1001];
  scanf("%d",&n);
  while(_A_){
    if(AC == n)break;
    scanf("%s",A);
    scanf("%s",B);
    for(i=0;i<1010;i++)for(j=0;j<1010;j++)dp[i][j]=0;
    strA=strlen(A);
    strB=strlen(B); 

    for(i=0;i<strA;i++){
      for(j=0;j<strB;j++){
	if(A[i] == B[j]){
      dp[i+1][j+1]=dp[i][j]+1;
    }
    else{
      if(dp[i+1][j] > dp[i][j+1]){
        dp[i+1][j+1]=dp[i+1][j];
      }
      else {
        dp[i+1][j+1] = dp[i][j+1];
      }
    }
      }
    }
    printf("%d\n",dp[strA][strB]);
    AC++;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var v = ScanIntArray();
      var c = ScanIntArray();
      var r = Enumerable.Range(0,n).Select(i=>v[i]-c[i]).Where(_=>_>0).ToList().Sum();
      
      WriteLine($"{r}");
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13524
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val T = listOf(0L) + readLine()!!.split(" ").map{it.toLong()} + listOf(1e10.toLong())
    val A = listOf(1e10.toLong()) + readLine()!!.split(" ").map{it.toLong()} + listOf(0L)

    var res = ModInt(1L, 1e9.toLong() + 7L)
    for (i in 1.. N) {
        if (T[i - 1] != T[i] || A[i] != A[i + 1]) {
            if (T[i - 1] != T[i] && A[i] != A[i + 1] && T[i] != A[i]) {
                res *= 0L
            } else if (T[i - 1] != T[i] && T[i] > A[i] || A[i] != A[i + 1] && A[i] > T[i]) {
                res *= 0L
            }
        } else {
            res *= Math.min(T[i], A[i])
        }
    }

    println(res.value)
}

private class ModInt (value: Long, val mod: Long) {
    init {
        if (mod <= 0) {
            throw IllegalArgumentException("ModInt cannot be created for non-positive modulus: $mod")
        }
    }

    val value = (value % mod + mod) % mod

    private fun assertSameMod(other: ModInt) {
        if (mod != other.mod) {
            throw IllegalArgumentException(
                "You cannot operate summation, subtraction and multiplication for ModInts with different moduli: $mod, ${other.mod}"
            )
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value + other.value) % mod, mod)
    }

    operator fun plus(other: Long) = plus(ModInt(other, mod))

    operator fun minus(other: ModInt): ModInt {
        assertSameMod(other)

        return plus(-other)
    }

    operator fun minus(other: Long) = minus(ModInt(other, mod))

    operator fun times(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value * other.value) % mod, mod)
    }

    operator fun times(other: Long) = times(ModInt(other, mod))

    fun pow(k: Long): ModInt {
        var res = 1L
        var a = value
        var l = k

        while (l > 0) {
            if ((l and 1L) == 1L) {
                res = (res * a) % mod
            }

            a = a * a % mod
            l /= 2L
        }

        return ModInt(res, mod)
    }

    /**
     * Returns an inverse element of the value.
     * To ensure `m * m.inv() = 1`, the modulus should be prime, since it uses Fermat's little theorem.
     */
    fun inv() = pow(mod - 2)

    operator fun div(other: ModInt): ModInt {
        assertSameMod(other)
        if (other.value == 0L) {
            throw ArithmeticException()
        }

        return times(other.inv())
    }

    operator fun div(other: Long) = div(ModInt(other, mod))
}


Measured memory_bytes: 85056
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int W = sc.nextInt();
		final int H = sc.nextInt();
		
		int[] x_all = new int[W];
		int[] y_all = new int[H];
		
		for(int i = 0; i < N; i++){
			final int x = sc.nextInt();
			final int y = sc.nextInt();
			final int w = sc.nextInt();
			
			final int x_min = Math.max(0, x - w);
			final int x_max = x + w - 1;
			final int y_min = Math.max(0, y - w);
			final int y_max = y + w - 1;
			x_all[x_min]++;
			if(x_max < (W - 1)){ x_all[x_max + 1]--; }
			y_all[y_min]++;
			if(y_max < (H - 1)){ y_all[y_max + 1]--; }
			//System.out.println(x_min + " " + y_min + " : " + x_max + " " + y_max);
		}
		
		boolean x_ok = x_all[0] >= 1;
		for(int i = 1; i < W; i++){
			x_all[i] += x_all[i - 1];
			x_ok &= (x_all[i] >= 1);
		}
		boolean y_ok = y_all[0] >= 1;
		for(int i = 1; i < H; i++){
			y_all[i] += y_all[i - 1];
			y_ok &= (y_all[i] >= 1);
		}
		
		//System.out.println(Arrays.toString(x_all));
		//System.out.println(Arrays.toString(y_all));
		
		System.out.println((x_ok || y_ok) ? "Yes" : "No");
		
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
 
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
typedef std::queue<Int> QI;
#define rep(i,n) for(Int i = 0; i < (Int)n; ++i)
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   std::vector<std::pair<long, long>> compress(const LI &xs) {
      std::vector<std::pair<long, long>> res;
      long n = xs.size();
      for(long i = 0; i < n; ++i) {
         if( i == 0 or xs[i-1] != xs[i] ) {
            res.push_back(std::make_pair(xs[i], 1));
         }
         else {
            res.back().second += 1;
         }
      }
      return res;
   }
   void solve() {
      Int n; scan(n);
      LI xs(n); scan(xs);
      LI ys(n);
      for(Int i = 0; i < n; ++i) {
         ys[i] = xs[i] == i + 1 ? 1 : 0;
      }
      auto zs = compress(ys);
      Int res = 0;
      for(auto z : zs) {
         // dumpll(z.first, z.second);
         if( z.first == 1 ) {
            res += (z.second + 1) / 2;
         }
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 3956
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, m, q): (usize, usize, usize) = read();
    let trains: Vec<(usize, usize)> = readn(m);
    let queries: Vec<(usize, usize)> = readn(q);

    let mut dp: Vec<Vec<i32>> = vec![vec![0; n+10]; n+10];

    for (u, v) in trains {
        dp[u][v] += 1;
    }

    for i in 1..n+10 {
        for j in 1..n+10 {
            let l = dp[i-1][j];
            let u = dp[i][j-1];
            let lu = dp[i-1][j-1];
            let base = dp[i][j];
            dp[i][j] = l + u - lu + base;
        }
    }

    for (f, t) in queries {
        let a = dp[f-1][t];
        let b = dp[t][f-1];
        let c = dp[f-1][f-1];
        let d = dp[t][t];
        println!("{}", d-a-b+c);
    }
}


Measured memory_bytes: 10400
import sys
input = sys.stdin.readline

N,K = map(int,input().split())
E = [[] for _ in range(N)]
MOD = 10**9+7

for _ in range(N-1):
	u,v = map(int,input().split())
	u -= 1
	v -= 1
	E[u].append(v)
	E[v].append(u)

color = [-1 for _ in range(N)]

stack = []
color[0] = 1
ans = K
for i,v in enumerate(E[0]):
	stack.append(v)
	ans *= (K-i-1)
	ans %= MOD

while stack:
	u = stack.pop()
	color[u] = 1
	length = 0
	for v in E[u]:
		if color[v] == -1:
			stack.append(v)
			length += 1
	tmp = 1
	for i in range(K-1-length,K-1):
		tmp *= i
		tmp %= MOD
	ans *= tmp
	ans %= MOD

print(ans%MOD)


Measured memory_bytes: 23660
void main(){
	long n, m;
	readf("%d %d\n", &n, &m);
	long[] a = _scanln!long();
	writeln(n-a.sum()<0? -1: n-a.sum());
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 3204
#include <stdio.h>

int main(void)
{
	int wPoint;
	int kPoint;
	int i;
	int val;
	
	int wBigPoint[3] = {0};
	int kBigPoint[3] = {0};
	
	for( i = 0; i < 10; i++ )
	{
		scanf("%d", &val);
		
		if( wBigPoint[0] < val )
		{
			wBigPoint[2] = wBigPoint[1];
			wBigPoint[1] = wBigPoint[0];
			wBigPoint[0] = val;
		}
		else if( wBigPoint[1] < val )
		{
			wBigPoint[2] = wBigPoint[1];
			wBigPoint[1] = val;
		}
		else if( wBigPoint[2] < val )
		{
			wBigPoint[2] = val;
		}
	}
	for( i = 0; i < 10; i++ )
	{
		scanf( "%d", &val );
		
		if( kBigPoint[0] < val )
		{
			kBigPoint[2] = kBigPoint[1];
			kBigPoint[1] = kBigPoint[0];
			kBigPoint[0] = val;
		}
		else if( kBigPoint[1] < val )
		{
			kBigPoint[2] = kBigPoint[1];
			kBigPoint[1] = val;
		}
		else if( kBigPoint[2] < val )
		{
			kBigPoint[2] = val;
		}
	}
	
	wPoint = wBigPoint[0] + wBigPoint[1] + wBigPoint[2];
	kPoint = kBigPoint[0] + kBigPoint[1] + kBigPoint[2];
	
	printf( "%d %d\n", wPoint, kPoint );
	
	return (0);
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
for i in range(N):
    if B[i] > A[i]:
        total += A[i]
        B[i] -= A[i]
        A[i] = 0
    else:
        total += B[i]
        A[i] -= B[i]
        B[i] = 0
    if B[i] > A[i+1]:
        total += A[i+1]
        B[i] -= A[i+1]
        A[i+1] = 0
    else:
        total += B[i]
        A[i+1] -= B[i]
        B[i] = 0
print(total)

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

int main() {
  int N, Q;
  cin >> N >> Q;
  queue<pair<string, int>> que;
  for (int i = 0; i < N; i++) {
    string name;
    int time;
    cin >> name >> time;
    que.push(make_pair(name, time));
  }
  int total_time = 0;
  while (que.size()) {
    auto p = que.front(); que.pop();
    total_time += min(p.second, Q);
    p.second -= Q;
    if (p.second <= 0) {
      cout << p.first << ' ' << total_time << endl;
    } else {
      que.push(p);
    }
  }
}


Measured memory_bytes: 6316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
const ll INF = 1e18;
const int MOD = 1e9+7;

int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if(a >= 0 && c >=0) cout << b*d;
	else if(b < 0 && d < 0) cout << a*c;
	else {
		
		ll num1 = a * c;
		ll num2 = a * d;
		ll num3 = b * c;
		ll num4 = b * d;
		
		ll ans1 = max(num1, num2);
		ll ans2 = max(num3, num4);
		
		cout << max(ans1, ans2) << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3636
a,b = list(map(int,input().split()))

class LCM():
    #a、bに最小公倍数または最大公約数を求めたい二つの整数の組を入れる
    def __init__(self,a,b):
        if a < b:a,b = b,a
        self.a = a
        self.b = b

    #最大公約数
    def gcd(self):
        a,b = self.a,self.b
        def nono(a,b):
            if a < b:a,b = b,a
            if a % b == 0:return b
            else:return nono(b,a % b)
        return nono(a,b)

    #最小公倍数
    def lcm(self):
        a,b = self.a,self.b
        def nono(a,b):
            if a < b:a,b = b,a
            if a % b == 0:return b
            else:return nono(b,a % b)
        num = nono(a,b)
        return a*b//num

l = LCM(a,b)

print(l.lcm())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 100005;
int n, m, q, a[MX], b[MX], c[MX], m1 = 1e9, m2 = 1e9, res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++) { cin >> a[i]; m1 = min(m1, a[i]); } 
	for (int i = 1; i <= m; i++) { cin >> b[i]; m2 = min(m2, b[i]); }
	res = m1 + m2;

	while (q--) {
		int x, y, c;
		cin >> x >> y >> c;
		res = min(res, a[x] + b[y] - c);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
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};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}

int n;

int main(){
	cin>>n;
	cout<<(n>=30?"Yes":"No")<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    ll x, y;
    cin >> x >> y;
    if(x % y == 0) {
        cout << -1 << "\n";
        return 0;
    }else {
        cout << x*(y-1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<iostream>
using namespace std;

string s,sl,sr,s1,s2;
int n;

long long ans;
map<pair<string,string>,long long> m;

void dfsl(int x){
    if(x==n){
        decltype(m) :: iterator it=m.find(make_pair(s1,s2));
        if(it==m.end()){
            m.insert(make_pair(make_pair(s1,s2),1));
        }
        else{
            m[make_pair(s1,s2)]++;
        }
    }
    else{
        s1+=sl[x];
        dfsl(x+1);
        s1.pop_back();
        s2+=sl[x];
        dfsl(x+1);
        s2.pop_back();
    }
}

void dfsr(int x){
    if(x==-1){
        decltype(m) :: iterator it=m.find(make_pair(s1,s2));
        if(it==m.end());
        else{
            ans+=m[make_pair(s1,s2)];
        }
    }
    else{
        s1+=sr[x];
        dfsr(x-1);
        s1.pop_back();
        s2+=sr[x];
        dfsr(x-1);
        s2.pop_back();
    }
}

int main(){
    scanf("%d",&n);
    cin>>s;
    sl=s.substr(0,n);
    sr=s.substr(n);
    dfsl(0);
    dfsr(n-1);
    printf("%lld\n",ans);
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int p, q, r; cin >> p >> q >> r;

  cout << min({p+q, q+r, r+p}) << endl;
  
  return (0);
}

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

int main()
{
	int n;
	cin >> n;
	int t,s;
	cin >> t >> s;
	double mi = 999999999;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int ss;
		cin >> ss;
		if(mi > abs(t - 0.006 * ss - s)){
			ans = i;
			mi = abs(t - 0.006 * ss - s);
		}
	}
	cout <<ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000

int A[101][101];
int d[101];
int color[101];
int pi[101];
int n;

int main(){
  int i,j,mincost,u,sum=0,k,v,r;
  scanf("%d",&n);
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      A[i][j]=-1;
    }
  }
  for(i=1;i<=n;i++){
    d[i]=INF;
    color[i]=WHITE;
    pi[i]=-1;
    scanf("%d%d",&r,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      /* printf("r=%d,v=%d\n",r,v);*/
      scanf("%d",&A[r][v]);
    }
  }
  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",A[i][j]);
    }
    printf("\n");
    }*/
  d[0]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(A[i][j]!=-1){
	  if(color[i]!=BLACK && d[i]<mincost){
	    mincost=d[i];
	    /*   printf("mincost=%d\n",mincost);*/
	    u=i;
	  }
	}
      }
    }
	if(mincost==INF) break;
	color[u]=BLACK;
	for(i=0;i<n;i++){
	  if(A[u][i]!=-1){
	    if(color[i]!=BLACK &&d[u]+A[u][i]<d[i]){
	      pi[i]=u;
	      d[i]=A[u][i]+d[u];
	    }
	  }
	}
  }
    for(i=0;i<n;i++){
       printf("%d %d\n",i,d[i]);
    sum+=d[i];
  }
    /*  printf("%d\n",sum);*/
    
  return 0;
}
      
	    
	
			
  



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

int main(){
	int k;
	std::cin >> k;
	int s = 0;
	for(int a = 1; a <= k; ++a){
		for(int b = 1; b <= k; ++b){
			for(int c = 1; c <= k; ++c){
				std::vector<int> v = {a, b, c};
				std::sort(v.begin(), v.end());
				int gcd;
				for(int i = 1; i <= v.front(); ++i){
					if(a%i == 0 && b%i == 0 && c%i == 0)gcd = i;
				}
				s += gcd;
			}
		}
	}

	std::cout << s << std::endl;

	return 0;
}



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

int hurui(vector<bool>& isPrime, int n, int m){
	int ret=0;
	for(int i=m;i<=7368791+1;i++){
		if(isPrime[i]){
			ret++;
			if(ret==n+1){
				return i;
			}
			for(int j=i;j<7368791+1;j+=i){
				isPrime[j]=false;
			}
		}
	}
}

int main (){
	int m,n;
	while(cin>>m>>n && m && n){
		vector<bool> isPrime(7368791+1,true);
		cout<<hurui(isPrime,n,m)<<endl;
		// int count=0;
		// for(int i=m;;i++){
		// 	if(isPrime[i])count++;
		// 	if(count==n+1){
		// 		cout<<i<<endl;
		// 		break;
		// 	}
		// }
	}
}




Measured memory_bytes: 3952
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int N,K;
	int *SNUKE,loop,buff;
	int i,j,trick;
	char str[100000];
 
	fgets(str, sizeof(str), stdin);
	N=atoi(strtok(str," "));
	K=atoi(strtok(NULL," "));

	SNUKE=(int*)calloc(N,sizeof(int));//始めはすべて0

	for(i=0;i<K;i++){
		fgets(str, sizeof(str), stdin);
		loop=atoi(strtok(str," "));
		fgets(str, sizeof(str), stdin);
		buff=atoi(strtok(str," "));
		SNUKE[buff-1]=1;
		for(j=1;j<loop;j++){
			buff=atoi(strtok(NULL," "));
			SNUKE[buff-1]=1;
		}
	}

	trick=0;
	for(i=0;i<N;i++){
		if(SNUKE[i]==0) trick++;
	}

	printf("%d\n",trick);

	free(SNUKE);

	return 0;
}


Measured memory_bytes: 2140
n,m=map(int,input().split())
ks=[[int(i) for i in input().split()] for j in range(m)]
p=[int(i) for i in input().split()]

ans=0
for i in range(2**n):
    for j in range(m):
        k=ks[j][0]
        s=ks[j][1:]
        pid=p[j]
        check=0

        for x in s:
            if i >>(x-1) &1:
                check+=1
        if pid == check%2:
            continue
        else:
            break
    else:
        ans+=1
print(ans)

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

vector<int> A, B;

int root(int x, vector<int> &G){
    if(x == G[x]) return x;
    else return G[x] = root(G[x], G);
}

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    
    A.resize(n); B.resize(n);
    for(int i = 0; i < n; i++){
        A[i] = i; B[i] = i;
    }

    for(int i = 0; i < k; i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        int tp, tq;
        tp = root(p, A);
        tq = root(q, A);
        if(tp < tq) A[tp] = tq;
        else A[tq] = tp;
    }
    
    for(int i = 0; i < l; i++){
        int r, s;
        cin >> r >> s;
        r--; s--;
        int tr, ts;
        tr = root(r, B);
        ts = root(s, B);
        if(tr < ts) B[tr] = ts;
        else B[ts] = tr;
    }

    map<pair<int, int>, int> mp;
    for(int i = 0; i < n; i++){
        mp[make_pair(root(i, A), root(i, B))]++;   //道路の親、鉄道の親のペアの個数
    }
    for(int i = 0; i < n; i++){
        int ans = mp[make_pair(root(i, A), root(i, B))];
        if(i) cout << " " << ans;
        else cout << ans;
    }

    return 0;
}

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

#define ll long long
#define mx 200005
#define mod 1000000007
#define lim 1000000
using namespace std;

int main(){
	ios_base ::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k%2)
    	cout<<b-a<<"\n";
	else
		cout<<a-b<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	
	char flag1[26];
	for(int i = 0; i < 26; i++) {
		flag1[i] = 'a' + i;
	}
	
	char flag2[26];
	for(int i = 0; i < 26; i++) {
		flag2[i] = 'a' + i;
	}
	
	bool check1[26] = {false};
	bool check2[26] = {false};
	for(int i = 0; i < s.size(); i++) {
		if(check1[s[i] - 'a'] == false) {
			flag1[s[i] - 'a'] = t[i];
			check1[s[i] - 'a'] = true;
		}
		
		if(check2[t[i] - 'a'] == false) {
			flag2[t[i] - 'a'] = s[i];
			check2[t[i] - 'a'] = true;
		}
		
	
		if(flag1[s[i] - 'a'] != t[i] || flag2[t[i] - 'a'] != s[i]) {
			cout << "No" << endl;
			return 0;
		}
		
	}
	
	cout << "Yes" << endl;
	
    return 0;
}

Measured memory_bytes: 776
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		String[] arr = r.rsaml(r.ria()[0]);
		Arrays.sort(arr);
		print(Arrays.toString(arr).replace("[","").replace("]", "").replace(",", "").replaceAll(" ", ""));
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(string());
		}

		long rl() {
			return Long.parseLong(string());
		}

		double rd() {
			return Double.parseDouble(string());
		}

		String string() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return string().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = string();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = string();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(string());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(string());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 22356
#encoding=utf-8
import itertools as iter
import sys
for i in sys.stdin:
    omori = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    x = int(i)
    for i in xrange(1,11):
        for element in iter.combinations(omori,i):
             if sum(element) == x:
                 for k in xrange(len(element) - 1):
                     print element[k],
                 print element[len(element) -1]

Measured memory_bytes: 6296
import sys
sys.setrecursionlimit(100000)
n,K=map(int,input().split())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append(b)
        kilist[b-1].append(a)
def search(P):
        searchedlist[P-1]=1
        visitedlist[P-1]=1
        flag=0
        for j in kilist[P-1]:
            if visitedlist[j-1]<0:
                visitedlist[j-1]=1
                flag+=1
                anslist[j-1]=anslist[P-1]+1
        else:
            pass

        if flag>0:    
            for k in kilist[P-1]:
                if searchedlist[k-1]==-1:
                    search(k)
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7) 
    return uselist
search(1)
power=find_power(100000)
invpower=find_inv_power(100000)
distancelist=[(i+1,anslist[i]) for i in range(n)]
distancelist=sorted(distancelist,key=lambda x:x[1])
answer=1
for some in distancelist:
    if some[1]==0:
        answer*=K
        howmuch=len(kilist[some[0]-1])   
        if K-1<howmuch:
            answer=0
            break
        else:
            answer=answer*power[K-1]*invpower[K-1-howmuch]
            answer=answer%(10**9+7)        
    else:
        howmuch=len(kilist[some[0]-1])-1
        if howmuch==0:
            pass
        else:
            if K-2<howmuch:
                answer=0
                break
            else:
                answer=answer*power[K-2]*invpower[K-2-howmuch]
                answer=answer%(10**9+7)
print(answer)


Measured memory_bytes: 97568
# -*- coding: utf-8 -*-
n = int(input())
if n==0:
    print(0)
    exit()
s = []

while n != 0:
    x = n%-2
    if x<0:
        s.append("1")
        n = n//-2 +1
    else:
        s.append("0")
        n = n//-2
s.reverse()
print("".join(s))


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

int main(){

  int c[3];
  cin >> c[0] >> c[1] >> c[2];
  sort(c,c+3);
  if(c[0]==5&&c[1]==5&&c[2]==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include "stdio.h"

int main(int argc, char const *argv[])
{
    long long int N, a, p, c = 0;
    scanf("%lld", &N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a);
        i || (p = a);
        i && (p > a) && (c += p - a);
        p = a > p ? a : p;
    }
    printf("%lld\n", c);

    return 0;
}


Measured memory_bytes: 3228
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    int m = 2000005;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    vector<int> cnt(m);
    for (int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < m; i += x) cnt[i]++;
    }
    int ans=0;
    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
  cout << ans << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 11980
a,b,c = map(int, input().split())
k = int(input())

count = 0
while count < k:
  if a<b and b<c:
    print('Yes')
    exit()
  elif a >= b:
    b *= 2
    count += 1
  elif b >= c:
    c *= 2
    count += 1

if a<b and b<c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9172
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	string s;
	cin>>s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad";
    else cout << "Good";
    cout << endl;
    return 0;

}

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

long long n;
vector<long long> a;
map<long long, long long> mp;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res += mp[i + 1 - a[i]];
    ++mp[a[i] + i + 1];
  }
  return res;
}

Measured memory_bytes: 27348
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int n; 

void dfs(string s,int m){
    if(s.size()==n){
        cout<<s<<endl; return;
    }
    rep(i,m) dfs(s+(char)('a'+i),m);
    dfs(s+(char)('a'+m),m+1);
}

int main(){
    cin>>n;
    dfs("a",1);
}

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

ll M = 1000000007;

ll fact[500005];
ll invfact[500005];

/* Iterative Function to calculate (x^y)%p in O(log y) */
ll power(ll x,ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res%p; 
}

ll nCr(ll n,ll r)
{
	return ((((fact[n])*(invfact[n-r])) % M)*(invfact[r]))%M;

} 


int main()
{
	ll i,j,k,l,m,n,t;

	cin >> n >> m;

	fact[0] = 1;
	invfact[0] = 1;



	for(i=1;i<500005;i++)
	{
		fact[i] = ((i)*(fact[i-1]))%M;
		invfact[i] = power(fact[i],M-2,M);
	}

	

	k = 0;
	l = 1;
	for(i=0;i<=n;i++)
	{
		
		k = (k%M+l*((((nCr(m-i,n-i)*nCr(n,i))%M)*(fact[n-i]))%M)+M)%M;

		

		l = -l;

	}

	k = k%M;

	t = (nCr(m,n)*fact[n])%M;

	// cout << k << " " << t << '\n';

	cout << (t*k)%M << '\n';







	// cin >> n >> m;

	// cin >> n;


}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

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

  int n, k;
  cin >> n >> k;
  vector<ll> min_v(n + 1), max_v(n + 1);
  rep(i, 1, n + 1) min_v[i] = min_v[i - 1] + i;
  max_v[n] = n;
  repr(i, 0, n) { // test
    max_v[i] = max_v[i + 1] + i;
  }
  sort(max_v.begin(), max_v.end());

  mint ans = 0;
  rep(i, k - 1, n + 1) ans += max_v[i] - min_v[i] + 1;

  cout << ans << endl;
}


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

struct B{long long p,sum;};

int main(){
	long long n,x,ans=0;
	cin>>n>>x;
	B b[n];
	b[0].p=1;
	b[0].sum=1;
	for(int i=1;i<=n;i++){
		b[i].p=b[i-1].p*2+1;
		b[i].sum=b[i-1].sum*2+3;
	}
	for(int i=n;i>=0;i--){
		if(x>=b[i].sum){
			ans+=b[i].p;
			x-=b[i].sum;
			if(x){
				x--;
				ans++;
			}
			i++;
		}
		else x--;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

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

    int sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            // cout << "i " << i << " j " << j << endl;
            int val = v[i] + v[j];
            // cout << "val " << val << endl;
            auto it = lower_bound(v.begin() + j + 1, v.end(), val);
            int idx = it - v.begin() - 1;
            if (idx <= j) continue;
            // cout << "idx " << idx << endl;
            sum += max(0, idx - j);
            // cout << "sum " << sum << endl;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<climits>
#include<stack>
#include<queue>
#include<cmath>
#define int long long
#define INF 100000000000
#define EPS 0.0000000001

using namespace std;

signed main() {
	int sc[6] = { 0 };
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		cin >> sc[i];
		if (sc[i] <= 40)sc[i] = 40;
		ans += sc[i];
	}
	cout << ans/5 << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}


ll dp[110][100010];

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i = 0; i < N; ++i){
        cin >> w[i] >> v[i];
    }

    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= W; ++j){
            dp[i+1][j] = dp[i][j];
            if(j < w[i]) continue;
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << '\n';
    
    return 0;
}


Measured memory_bytes: 79360
// luogu-judger-enable-o2
// luogu-judger-enable-o2
#pragma GCC optimize("-O2")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<bitset>
#include<ctime>
#include<cstdlib> 
#define LL long long
#define DB long double
#define pa pair<LL,int>
#define ctz __builtin_ctz
using namespace std;

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline void Out(LL x){
    if(x>9) Out(x/10);
    putchar(x%10+'0'); 
}
const int N=2e5+10;
map<int,int> mp;
int n,ans=0;
LL a[N];
LL t,x,y,z;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+1+n);
    for(int i=1;i<=n;++i) ++mp[a[i]];
    for(int i=n;i>=1;--i){
    	if(!mp[a[i]]) continue;
    	--mp[a[i]];
    	t=1;
    	while(t<=a[i]) t<<=1;
    	x=a[i]&-a[i];
    	y=(t-1)^a[i];
    	++y;
    	if(mp[y]) ++ans,--mp[y];
	}
	printf("%d\n",ans);
	return 0;
}
/*
10
100 8 8

*/

Measured memory_bytes: 20608
#include <iostream>
using namespace std;
 
int main() {
    int n,m,a[100][100],b[100];
    int ans[100]={0};
     
    cin>>n>>m;
     
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans[i]+=a[i][j]*b[j];
        }
        cout<<ans[i]<<endl;
    }
     
    return 0;
}

Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

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

int main() {
    string s;
    cin >> N;
    cin >> s;
    rep(i, s.size()){
        if(s[i]+N > 'Z') s[i] = s[i] + N - 26;
        else s[i] = s[i] + N;
    }
    cout << s;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
     
    void main(){
    	auto ip = readln.split.to!(int[]), A=ip[0], B=ip[1];
     
    	if(A<6) writeln(0);
    	else if(A<13) writeln(B/2);
    	else writeln(B);
    }

Measured memory_bytes: 256