akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (r1, c1, r2, c2) = readLine()!!.split(" ").map(String::toInt)
    val combi = Combination(2000002)
    val ans = combi(r2 + c2 + 2, c2 + 1) - combi(r2 + c1 + 1, c1) - combi(r1 + c2 + 1, c2 + 1) + combi(r1 + c1, c1)
    println(ans)
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a += b
        return a
    }

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a -= b
        return a
    }

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a *= b
        return a
    }

    operator fun div(b: MInt): MInt {
        val a = MInt(v)
        a /= b
        return a
    }

    operator fun plusAssign(b: MInt) {
        v += b.v
        if (v >= MOD) v -= MOD
    }

    operator fun minusAssign(b: MInt) {
        v -= b.v
        if (v < 0) v += MOD
    }

    operator fun timesAssign(b: MInt) {
        v *= b.v
        v %= MOD
    }

    operator fun divAssign(b: MInt) {
        this *= b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(n: Int): MInt {
        var a = MInt(1)
        for (i in 1..n) a = a * this
        return a
    }

    override fun toString(): String {
        return v.toString()
    }
}

class Combination(n: Int) {
    private val fact = arrayOfNulls<MInt>(n + 1)

    init {
        fact[0] = MInt(1)
        (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }
    }

    operator fun invoke(n: Int, k: Int): MInt {
        if (k < 0 || n < k) return MInt(0)
        return (fact[n]!! / (fact[k]!! * fact[n - k]!!))
    }
}

Measured memory_bytes: 121844
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,ans[100002],A,B,C,dp[100002][3][3][3],pre[100002][3][3][3];
char s[12];
long long sum;
inline void work(re int x,re int a,re int b,re int c){
	if(x==0)return;
	re int xx=pre[x][a][b][c];
	if(xx==1)++a,--b;
	if(xx==2)--a,++b;
	if(xx==3)++a,--c;
	if(xx==4)--a,++c;
	if(xx==5)++b,--c;
	if(xx==6)--b,++c;
	work(x-1,a,b,c);
	if(xx==2||xx==4)puts("A");
	if(xx==1||xx==6)puts("B");
	if(xx==3||xx==5)puts("C");
}
signed main(){
	n=read();A=read();B=read();C=read();
//	if(A+B+C==2ll)return 1;
	if(A+B+C!=2ll){
		for(re int i=1;i<=n;++i){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				if(A>B){--A;++B;ans[i]=2;
				}
				else{
					if(B==0){
						puts("No");
						return 0;
					}
					--B;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				if(A>C){
					--A;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				if(B>C){
					--B;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++B;
					ans[i]=2;
				}
			}
		}
		puts("Yes");
		for(re int i=1;i<=n;++i){
			if(ans[i]==1)puts("A");
			if(ans[i]==2)puts("B");
			if(ans[i]==3)puts("C");
		}
	}
	else{
		dp[0][A][B][C]=1;
		for(re int ii=1;ii<=n;++ii){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				for(re int i=0;i<=1;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i+1][j-1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=1;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i-1][j+1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=2;
							}
						}
					}
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				for(re int i=0;i<=1;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i+1][j][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=3;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i-1][j][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=4;
							}
						}
					}
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				for(re int i=0;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i][j+1][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=5;
							}
						}
					}}
				for(re int i=0;i<=2;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i][j-1][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=6;
							}
						}
					}
				}
		}
		}
		for(re int i=0;i<=2;++i){
			for(re int j=0;j<=2;++j){
				for(re int k=0;k<=2;++k){
					if(dp[n][i][j][k]){
						puts("Yes");
						work(n,i,j,k);
						return 0;
					}
				}
			}
		}
		puts("No");
	}
}

Measured memory_bytes: 49080
#include<bits/stdc++.h>
#define pb push_back
#define LL long long
using namespace std;
LL a[10005],b[10005],n,x,y,i;
int main(){
	scanf("%lld",&n);
	for(i=1;i<=n;i++)	scanf("%lld",&a[i]);
	for(i=1;i<=n;i++)	scanf("%lld",&b[i]);
	for(i=1;i<=n;i++){
		if(a[i]>b[i]){
			x+=a[i]-b[i];
		}else{
			y+=(b[i]-a[i])/2;
		}
	}
	printf("%s\n",(x>y)?"No":"Yes");
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long k = sc.nextLong();

		long ans = 0;
		for (long i=k; i<=n+1; i++){
			long min=0;
			long max=0;
			min = i * (i - 1) / 2;
			max = i * (n + n - (i -1)) / 2;
			ans += max - min +1;
		}
		System.out.println(ans % 1000000007);
	}
}

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

int main() {
  ll N, M;
  cin >> N >> M;
  if (N < M / 2) {
    ll rem = M - 2 * N;
    cout << N + rem / 4 << endl;
  } else {
    cout << M / 2 << endl;
  }
}


Measured memory_bytes: 256
N = gets.to_i
edges = (N - 1).times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
edges.each do |(u, v)|
  u -= 1
  v -= 1
  graph[u].push(v)
  graph[v].push(u)
end

INF = 1 << 60
def bfs(graph, s, wall)
  ds = Array.new(N, INF)
  queue = [[s, nil, 0]] # u, parent, depth
  while !queue.empty?
    u, parent, depth = queue.shift
    ds[u] = depth
    graph[u].each do |v|
      next if v == parent
      next if v == wall
      queue.push([v, u, depth + 1])
    end
  end
  ds
end

fds = bfs(graph, 0, N - 1)
sds = bfs(graph, N - 1, 0)
f_count = 0
s_count = 0
fds.zip(sds) do |(fd, sd)|
  if fd <= sd
    f_count += 1
  else
    s_count += 1
  end
end
if f_count > s_count
  puts 'Fennec'
else
  puts 'Snuke'
end


Measured memory_bytes: 21608
#include <stdio.h>
#include <math.h>
 
int main(void) {
    int n, s;
    double sum = 0.0;
    double sum2 = 0.0;
 
    while (true) {
sum=sum2=0.0;
        scanf("%d", &n);
        if (n == 0) break;
 
        for (int i = 0; i < n; i++) {
            scanf("%d ", &s);
            sum += s;
            sum2 += s * s;
        }
 
        printf("%f\n", sqrt(sum2 / n - (sum / n) * (sum / n)));
    }
    return 0;
}

Measured memory_bytes: 2740
import itertools

n = int(input())

counter = [[0] * 10 for _ in range(11)]

for i in range(1, n + 1):
    I = str(i)
    first_d = int(I[0])
    last_d = int(I[-1])
    if first_d == 0 or last_d == 0:
        continue
    counter[first_d][last_d] += 1

result = 0
for i in range(10):
    for j in range(10):
        result += counter[i][j] * counter[j][i]
print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >>a[3] >> a[4];
    int temp = 10, min_id = 0;;
    for (int i =0 ; i < 5; ++i) {
        if (a[i] % 10 != 0) {
            if (temp > a[i] % 10) {
                temp = min(temp, a[i] % 10);
                min_id = i;
            }
            
        }
        
    }
    int ans=0;
    for (int i = 0; i < 5; ++i) {
        if (i!=min_id&&a[i]%10!=0) {
            ans += a[i] + (10 - a[i] % 10);
        }
        else{
            ans += a[i];
        }

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

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] sign = { { 1, 1, 1 }, { 1, 1, -1 }, { 1, -1, 1 }, { -1, 1, 1 }, { 1, -1, -1 }, { -1, 1, -1 },
				{ 1, -1, -1 }, { -1, -1, -1 } };
		long[] x = new long[n];
		long[] y = new long[n];
		long[] z = new long[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
			z[i] = sc.nextLong();
		}
		Long max = Long.MIN_VALUE;
		Long maxtmp;
		Long[] tmp = new Long[n];
		for (int i = 0; i < 8; i++) {
			maxtmp = (long) 0;
			for (int j = 0; j < n; j++) {
				tmp[j] = x[j] * sign[i][0] + y[j] * sign[i][1] + z[j] * sign[i][2];
			}
			Arrays.sort(tmp);
			for (int j = n - 1; j > n - 1 - m; j--) {
				maxtmp += tmp[j];
			}
			max = Math.max(max, maxtmp);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 27708
#include <iostream>
#include <string>
#include <bitset>
#include <algorithm>

int main() {
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());
    const auto len = s.length();
    int64_t result{};
    for (size_t pattern = 0; pattern < (1LL << len - 1); pattern++) {
        int64_t digit = 1;
        std::bitset<32> bits(pattern);
        for (size_t i = 0; i < len; i++) {
            result += digit * (s[i] - '0');
            digit = (bits[i]) ? 1 : digit * 10;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;

	int c1 = 0, c2 = 0;
	rep(i, n) {
		bool flag = false;
		if (s[i] == 'a') {
			if (c1 < a + b) { flag = true; c1++; }
		}
		else if (s[i] == 'b') {
			if (c1 < a + b && c2 < b) { flag = true; c1++; c2++; }
		}
		puts(flag ? "Yes" : "No");
	}
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>

#define MYSTRINGMAX 200000 // 配列20万分取る
#define SIZE MYSTRINGMAX + 2 // MYSTRINGMAX+2した値をSIZEに入れたものを定義する SIZE = 200002

int main(void) {
	char s[SIZE], t[SIZE];
	char c1[SIZE] = {0};
	char c2[SIZE] = {0};

	fgets(s, SIZE, stdin);
	fgets(t, SIZE, stdin);

	int length = strlen(s) - 1; // lengthに文字列の長さを返すstrlen関数を配列sにて判定する
	
	for (int i = 0; i < length; i++) {
		int in1 = s[i] - 'a';
		if (c1[in1] == 0) {
			c1[in1] = t[i];
		} else {
			if (c1[in1] != t[i]) {
				printf("No\n");
				return 0;
			}
		}
		int in2 = t[i] - 'a';
		if (c2[in2] == 0) {
			c2[in2] = s[i];
		} else {
			if (c2[in2] != s[i]) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n"); // それ以外ならYesを実行
	return 0;
}


Measured memory_bytes: 896
# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def int
    gets.to_i
  end

  def ints
    split.map(&:to_i)
  end

  def split
    @input.gets.chomp.split(' ')
  end
  alias_method :strings, :split

  def gets
    @input.gets.chomp
  end

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# Algorithms {{{

def lower_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] < val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] >= val
    low
  else
    high
  end
end

def upper_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] <= val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] > val
    low
  else
    high
  end
end

# }}}

# }}}

# io.set_input('inputs/0.txt')

MOD = 1_000_000_007

while true
  a = io.gets
  break if a == '0'
  b, c = io.gets, io.gets

  # dp[pos][carried][carry] = combinations % MOD
  dp = Array.new(a.length) { Array.new(2) { Array.new(2, 0) } }
  a.reverse!
  b.reverse!
  c.reverse!
  a.length.times do |i|
    (0..9).each do |ad|
      next if (a[i] != '?' && a[i].to_i != ad) || (i == a.length - 1 && ad == 0)
      (0..9).each do |bd|
        next if (b[i] != '?' && b[i].to_i != bd) || (i == a.length - 1 && bd == 0)
        (0..9).each do |cd|
          next if (c[i] != '?' && c[i].to_i != cd) || (i == a.length - 1 && cd == 0)
          carried = nil
          if (ad + bd + 1) % 10 == cd
            carried = 1
          elsif (ad + bd) % 10 == cd
            carried = 0
          else
            next
          end
          next if i == 0 && carried == 1

          carry = ad + bd + carried >= 10 ? 1 : 0
          if i == 0
            dp[i][carried][carry] += 1
          else
            dp[i][carried][carry] = (dp[i][carried][carry] + dp[i-1][0][carried] + dp[i-1][1][carried]) % MOD
          end
        end
      end
    end
  end

  io.puts (dp[a.length - 1][0][0] + dp[a.length - 1][1][0]) % MOD
end

# vim: foldmethod=marker

Measured memory_bytes: 6088
N = [int(e) for e in input().split()]
nums = []
u = 10**9 + 7
t = 0
s = 0
Min =0
Max =0
for i in range(0,N[1]):
    Min += i
    t = i+1
    Max += N[0] - i
    s = N[0] - i -1
ans = Max - Min + 1
for k in range(N[1]+1,N[0]+2):
    Min += t
    t += 1
    Max += s
    s -= 1
    ans += Max - Min + 1
print(ans%u)

Measured memory_bytes: 64596
#include <stdio.h>

int kaneko(int board[8][8], int *v, int *h, int *s, int *d, int n);

int main(int argc, char *argv[])
{
  int emiko[8][8];
  int k, r, c, i, j;
  int vertical[8];
  int horizontal[8];
  int sum[15];
  int diff[15];

  scanf("%d", &k);

  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) emiko[i][j] = 0;
    vertical[i] = 0;
    horizontal[i] = 0;
  }

  for (i = 0; i < 15; i++) {
    sum[i] = 0;
    diff[i] = 0;
  }
  
  for (i = 0; i < k; i++) {
    scanf("%d", &r);
    scanf("%d", &c);

    emiko[r][c] = 1;
    horizontal[r] = 1;
    vertical[c] = 1;
    sum[r+c] = 1;
    diff[r-c+7] = 1;
  }
  kaneko(emiko, vertical, horizontal, sum, diff, 8 - k);

  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (emiko[i][j] == 0) printf(".");
      else printf("Q");
    }
    printf("\n");
  }

  return 0;
}

int kaneko(int emiko[8][8], int *v, int *h, int *s, int *d, int n)
{
  int r, c;
  int res;

  if (n == 0) return 1;

  for (r = 0; r < 8; r++) {
    if (h[r] == 0) {
      for (c = 0; c < 8; c++) {
	if (v[c] == 0) {
	  if (s[r+c] == 0 && d[r-c+7] == 0) {
	    emiko[r][c] = 1;
	    h[r] = 1;
	    v[c] = 1;
	    s[r+c] = 1;
	    d[r-c+7] = 1;
	    res = kaneko(emiko, v, h, s, d, n - 1);
	    if (res == 1) return 1;
	    else {
	      emiko[r][c] = 0;
	      h[r] = 0;
	      v[c] = 0;
	      s[r+c] = 0;
	      d[r-c+7] = 0;
	    }
	  }
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(b&1)cout<<"No"<<endl;
    else
    {
        b/=2;
        if(b-a<=a&&b-a>=0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

using i64 = int64_t;

#define FOR(i,start,end) for(int i=(start); i<(end); ++i)
#define REP(i,n) FOR(i,0,n)

constexpr i64 MOD = 1'000'000'007;

constexpr i64 NMAX = 100'000;

i64 N;
string S;

// i文字目まででj個選択するパターン数
i64 dp[NMAX+1][3+1];

void solve() {
    dp[0][0] = 1;
    dp[0][1] = dp[0][2] = dp[0][3] = 0;

    for(int i = 1; i <= N; ++i) {
        char c = S[i-1];

        if(c == '?') {
            dp[i][0] = 3*dp[i-1][0];
        }
        else {
            dp[i][0] = dp[i-1][0];
        }
        dp[i][0] %= MOD;

        if(c == 'A') {
            dp[i][1] = dp[i-1][1] + dp[i-1][0];
        }
        else if(c == '?') {
            dp[i][1] = 3*dp[i-1][1] + dp[i-1][0];
        }
        else {
            dp[i][1] = dp[i-1][1];
        }
        dp[i][1] %= MOD;

        if(c == 'B') {
            dp[i][2] = dp[i-1][2] + dp[i-1][1];
        }
        else if(c == '?') {
            dp[i][2] = 3*dp[i-1][2] + dp[i-1][1];
        }
        else {
            dp[i][2] = dp[i-1][2];
        }
        dp[i][2] %= MOD;

        if(c == 'C') {
            dp[i][3] = dp[i-1][3] + dp[i-1][2];
        }
        else if(c == '?') {
            dp[i][3] = 3*dp[i-1][3] + dp[i-1][2];
        }
        else {
            dp[i][3] = dp[i-1][3];
        }
        dp[i][3] %= MOD;
    }

    i64 ans = dp[N][3];

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

int main() {
    cin >> S;
    N = S.size();

    solve();
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
	char a[2][3];
	
	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	
	if(a[0][0] == a[1][2] && a[0][1] == a[1][1] && a[0][2] == a[1][0])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    int x,y;cin>>x>>y;
	cout<<abs(abs(x)-abs(y))+((x<0&&y<0)||(x>=0&&y>=0)?(x>=y)*2:1)+(y?0:-1)<<endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
bool check(double sx, double sy, double sz, double tx, double ty, double tz, double ta){
    double ct = (sx * tx + sy * ty + sz * tz) / (sqrt(sx * sx + sy * sy + sz * sz) * sqrt(tx * tx + ty * ty + tz * tz));
    double cta = cos(ta);
    double eps = 1e-8;
    return ct > cta - eps;
}

void solve(int n){
    vector<double> sx(n),sy(n),sz(n);
    rep(i,0,n){
        cin >> sx[i] >> sy[i] >> sz[i];
    }
    int m;
    cin >> m;
    vector<double> tx(m),ty(m),tz(m),ta(m);

    rep(i,0,m){
        cin >> tx[i] >> ty[i] >> tz[i] >> ta[i];
    }
    set<int> num;

    rep(i,0,n){
        rep(j,0,m){
            if(check(sx[i],sy[i],sz[i],tx[j],ty[j],tz[j],ta[j])){
                num.insert(i);
            }
        }
    }
    cout << num.size() << endl;


}

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

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        solve(n);
    }


    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  int M;
  cin >> M;
  int p, x;
  for (int i = 0; i < M; i++) {
    cin >> p >> x;
    int ans = 0;
    for (int j = 0; j < N; j++) {
      ans += (p == j+1) ? x : t[j];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))


N, K = [int(x) for x in input().split()]

# G = [set() for _ in range(N)]
G = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)


def len12(g, st):
    cnt = len(g[st])
    for n1 in g[st]:
        cnt += (len(g[n1]) - 1)
    return cnt


G2 = [[] for _ in range(N)]
opened = set()
opened.add(0)
closed = set()

ans = K
while len(opened) != 0:
    target = opened.pop()
    closed.add(target)
    for n in G[target]:
        if n in closed:
            continue
        opened.add(n)
        G2[target].append(n)
        G2[n].append(target)
        cnt = len12(G2, n)
        ans = ans * (K - cnt)
        ans %= MOD

print(ans)


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    rep(i, q) cin >> T[i] >> D[i];

    int left = 0, right = n;
    int t;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur]) {
                if (D[i] == 'L') --cur;
                else ++cur;
            }
            if (cur == -1) {
                check = true;
                break;
            }
            if (cur == n) {
                break;
            }
        }

        if (check) left = t;
        else right = t;
    }

    int ans1 = right;

    left = 0, right = n;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur2 = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur2]) {
                if (D[i] == 'L') --cur2;
                else ++cur2;
            }
            if (cur2 == n) {
                check = true;
                break;
            }
            if (cur2 == -1) {
                break;
            }
        }

        if (check) right = t;
        else left = t;
    }

    int ans2 = left;

    cout << n - (ans1 + n - ans2) + 1 << endl;

    return 0;
}


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

vector<pair<int, int>> gra[100010]; //
ll dist[100010];                    //

void dfs(ll x, ll y)
{
  for (const auto &it : gra[x])
  {
    ll s = it.first, len = it.second;
    if (dist[s] != -1)
      continue;
    dist[s] = y + len;
    dfs(s, dist[s]);
  }
}

int main()
{
  ll n, q, k;
  cin >> n;
  rep(i, n - 1)
  {
    ll a, b, c;
    cin >> a >> b >> c;
    gra[a].push_back({b, c}); //
    gra[b].push_back({a, c}); //
  }
  cin >> q >> k;
  rep(i, 100010) dist[i] = -1;
  dist[k] = 0; //
  dfs(k, 0);
  rep(i, q)
  {
    ll x, y;
    cin >> x >> y;
    ll ans = dist[x] + dist[y];
    cout << ans << endl;
  }
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    srt(v);
    double sum = v[0] / pow(2,n-1);
    rng(i,1,n){
        sum += v[i] / pow(2,n-i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   ll fib[45] = {1, 1};

   int n;
   cin >> n;
   for (int i=2; i <= n; ++i) {
       fib[i] = fib[i-1] + fib[i-2];
   }

   outl(fib[n]);
}




Measured memory_bytes: 3144
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = int(sys.stdin.readline().rstrip())
    e = K // 2
    o = K // 2 if K % 2 == 0 else K // 2 + 1
    print(e * o)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]
count = 0
for i in range(n):  # それぞれの参加者ごとに
    day_count = 0
    while day_count * a[i] + 1 <= d:
        count += 1
        day_count += 1
print(count + x)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
int A[200100];
std::map<int, int> cnt;

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

  std::cin >> N >> K;

  for(int i=0;i<N;++i){
      std::cin >> A[i];

      A[i] -= 1;
  }

  ll res = 0;

  for(int i=N;i>=0;--i){
      A[i] = (A[i] + A[i+1]) % K;

      if(i + K <= N){
          cnt[A[i+K]] -= 1;
      }
      res += cnt[A[i]];
      cnt[A[i]] += 1;
  }
  
  std::cout << res << std::endl;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main()
{
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  long long ans = 0;
  if ((A + B) >= C) {
    ans = B + C;
  }
  else {
    ans = (A + B + 1) + B;
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		int n;
		int p;
		int result = -1;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string> s(n);
		FOR(i, 0, n - 1) {
			cin >> s[i];
		}

		FOR(k, 1, 50) {
			//cout << k << endl;
			vector<string>t(n);
			FOR(i, 0, n - 1) {
				t[i].push_back(s[i][0]);
				if(t[i].size() >= k) {
					continue;
				}
				p = s[i].size() - 2;
				FOR(j, 0,p) {
					//cout << i << " " << j << " " << p << endl;
					switch (s[i][j]) {
					case 'a':
					case 'i':
					case 'u':
					case 'e':
					case 'o':
						t[i].push_back(s[i][j + 1]);
						break;
					}
					if (t[i].size() >= k) {
						break;;
					}
				}
			}
			sort(t.begin(), t.end());
			FOR(i, 0, n - 2) {
				if (t[i] == t[i + 1]) {
					break;
				}
				if (i == n - 2) {
					result = k;
				}
			}
			if (result != -1) {
				break;
			}
		}

		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
import math
n, m, x0, y0 = map(int, raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

com = set(range(x0+1,y0+1)) & set(range(max(x)+1,min(y)+1))
if len(com) >= 1:
	print 'No War'
else:
	print 'War'

Measured memory_bytes: 2692
import math

N = int(input())
a = [0]+list(map(int, input().split()))

for i in range(1, N+1)[::-1]:
    a[i] = sum(a[i::i]) % 2

ans = [index for index, v in enumerate(a) if v == 1]
print(len(ans))
print(*ans)


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

int main(){
  int n; cin>>n;
  int k; cin>>k;
  if (k > (n-2)*(n-1)/2)
  {
    cout << -1 << endl;
    return 0;
  }
  
  vector<pair<int,int>> e;
  for (size_t i = 2; i <= n; i++)
  {
    pair<int,int> tmp;
    tmp = make_pair(1,i);
    e.push_back(tmp);
  }
  int rem = (n-2)*(n-1)/2 - k;
  int i = 2;
  int j = 3;
  for (size_t _ = 0; _ < rem; _++)
  {
    e.push_back({i,j});
    j++;
    if (j>n)
    {
      i++;
      j = i+1;
    }
  }

  //out
  cout << e.size() << endl;
  for (auto &&i : e)
  {
    cout << i.first << ' ' << i.second << endl;
  }
   
  
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string[] inputs = Console.ReadLine().Split(" ");
            int legsSum = int.Parse(inputs[1]);
            int animals = int.Parse(inputs[0]);
            bool possible = false;
            for (int i = 0; i <= animals; i++)
            {
                for (int j = 0; j <= animals; j++)
                {
                    if (i * 4 + j * 2 == legsSum && i + j == animals)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}


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

using namespace std; 
int main()
{
	double aux;
	long long int a,b,k;
	cin>>a>>b;
	aux=double(b*b-a*a)/double(2*b-2*a);

	k = aux;
	if(aux-double(k)!=0)
		cout<<"IMPOSSIBLE"<<endl;
	
	else	
		cout<<k<<endl;
	
	return 0;		
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


////フォード - ファルカーソン法 O(Flow|E|)

typedef int Weight;

const Weight INF = 1e9;
const Weight ZERO = 0;
struct Edge {
	int src, dst;
	Weight weight;
	int rev;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int rev_,const int id_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_),id(id_) { }
	Edge(int src_, int dst_, Weight weight_,const int rev_) :
		src(src_), dst(dst_), weight(weight_),rev(rev_) { }
	Edge() :src(0), dst(0), weight(0) {
	}
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph&g,int from, int to, int cap)
{
	g[from].push_back(Edge ( from,to, cap, (int)g[to].size() ));
	g[to].push_back(Edge ( to,from, 0, (int)g[from].size() - 1 ));
}
int dfs(vector<int>&used,Graph&g,int now, int t, int f)
{
	if (now == t) {
		return f;
	}
	used[now] = true;
	for (int i = 0; i<g[now].size(); ++i) {
		Edge &e = g[now][i];
		if (!used[e.dst] && e.weight>0) {
			int d = dfs(used,g,e.dst, t, min(f, e.weight));
			if (d > 0) {
				e.weight -= d;
				g[e.dst][e.rev].weight += d;
				return d;
			}
		}
	}
	return 0;
}
Weight fold_falc(Graph g,const int start,const int goal) {
	Weight ans = 0;
	while (1) {
		vector<int>used(g.size());
		int flow = dfs(used, g, start, goal, INF);
		if (!flow)return ans;
		else ans += flow;
	}
}

const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>field(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			field[i][j] = st[j] == 'X';
		}
	}
	bool ok = true;
	for (int i = 0; i < H; ++i) {
		if (field[i][0])ok = false;
		if (field[i][W - 1])ok = false;
	}
	for (int i = 0; i < W; ++i) {
		if (field[0][i])ok = false;
		if (field[H - 1][i])ok = false;
	}
	if (!ok)cout << -1 << endl;
	else {
		const int start = 0;
		const int nodein = start + 1;
		const int nodeout = nodein + H*W;
		const int goal = nodeout + H*W;
		Graph g(goal+1);
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (field[i][j] == 1) {
					add_edge(g, start, nodeout + i*W + j, 1e6);
				}
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					add_edge(g, nodeout + i*W + j,goal, 1e6);
				}
				add_edge(g, nodein + i*W + j, nodeout + i*W + j, 1);
				for (int way = 0; way < 4; ++way) {

					const int nx = j + dx[way];
					const int ny = i + dy[way];
					if (nx >= 0 && nx < W&&ny >= 0 && ny < H) {
						add_edge(g, nodeout + i*W + j, nodein + ny*W + nx,1e6);
					}
				}
			}
		}
		int ans = fold_falc(g, start, goal);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6784
use proconio::input;
use proconio::marker::Chars;

fn main(){
  input!{
    N:usize,
    W:[Chars;N]
  }
  let mut ans:bool=true;
  for i in 1..N{
    if W[i-1][W[i-1].len()-1]!=W[i][0]{
      ans=ans && false;
    }
    for j in 0..i-1{
      if W[i]==W[j]{
        ans = ans && false
      }
    }
  }
  if ans {
    print!("{}","Yes".to_string());
  }else{
    print!("{}","No".to_string());
  } 
}

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

typedef long long LL;

const int N = 1e5+7, RT = 400;
int a[N];
LL sum[N][RT];

LL query(int l, int r, int d) {
    assert((r-l)%d==0);
    if (d < RT) {
        if (l<=d)    return sum[r][d];
        return sum[r][d] - sum[l-d][d];
    }

    LL ans = 0;
    for (int i=l; i<=r; i+=d)   ans += a[i];
    return ans;
}

vector<int> divs[N];
int cnt[N];

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

    for (int i=1; i<N; i++)
        for (int j=i; j<N; j+=i)
            divs[j].push_back(i);

    int n;
    cin>>n;
    n--;

    for (int i=0; i<=n; i++)    cin>>a[i];
    for (int i=1; i<RT && i<=n; i++) {
        for (int j=1; j<=n; j++) {
            sum[j][i] = a[j];
            if (j>=i)  sum[j][i] += sum[j-i][i];
        }
    }

    LL ans = 0;
    for (int a=1; a<n; a++) {
        for (int d: divs[n-a]) {
            if (d >= a) break;
            int k = (n-a)/d;
            if (a%d==0 && k*d>=a)   continue;
            LL x = query(a, n, d) ;
            LL y = query(d, k*d, d);
            LL cur =  x + y;
            ans = max(ans, cur);
//            cout<<a<<" "<<a-d<<" = "<<cur<<" "<<x<<" "<<y<<endl;
        }
    }
    cout<<ans<<endl;
}


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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().run();
        return 0;
    }

    void run()
    {
        Scanner cin = new Scanner();
        while (true)
        {
            int n = cin.nextInt();
            int m = cin.nextInt();
            if (n == 0) break;
            int[] book = new int[m];
            for (int i = 0; i < m; i++)
            {
                book[i] = cin.nextInt();
            }

            int min = 0;
            int max = (int)1e9 + 10;
            while (max - min > 1)
            {
                //Console.WriteLine(max + " " + min);
                int mid = (min + max) / 2;
                bool ok = true;

                int need = 1;
                int nokori = mid;
                for (int i = 0; i < m; i++)
                {
                    nokori -= book[i];
                    if (nokori < 0) { need++; nokori = mid - book[i]; }
                    if (nokori < 0) { ok = false; }
                }
                if (need > n) ok = false;

                if (ok)
                {
                    max = mid;
                }
                else
                {
                    min = mid;
                }
            }
            Console.WriteLine(max);
        }

    }

}

class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

}

Measured memory_bytes: 5680
a, b, c, k = map(int, input().split())
s = 0
for i in [[a, 1], [b, 0], [c, -1]]:
    if k <= 0:
        break
    v = (i[0] if i[0] <= k else k)
    s += i[1] * v
    k -= v
print(s)



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

namespace ConsoleApp11 {
    class Program {
        static void Main(string[] args) {
            var A = new int[5];


            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            A[0] = a;
            A[1] = b;
            A[2] = c;
            A[3] = d;
            A[4] = e;


            if ((e - a) > k) {
                Console.WriteLine(":(");
            } else {
                Console.WriteLine("Yay!");
            }


        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
int x[100000];
int y[100000];
vector<E> edge;
struct UnionFind {
	int *par;
	int *rank;
	int size;
	UnionFind(int n) :size(n) {
		par = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
int main() {
	int N;
	cin >> N;
	vector<P> vx, vy;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		vx.emplace_back(x[i], i);
		vy.emplace_back(y[i], i);
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	for (int i = 0; i + 1 < N; i++) {
		edge.emplace_back(vx[i + 1].first - vx[i].first, P(vx[i].second, vx[i + 1].second));
		edge.emplace_back(vy[i + 1].first - vy[i].first, P(vy[i].second, vy[i + 1].second));
	}
	sort(edge.begin(), edge.end());
	UnionFind U(N);
	LL ans = 0;
	for (int i = 0; i < edge.size(); i++) {
		if (U.same(edge[i].second.first, edge[i].second.second)) continue;
		ans += edge[i].first;
		U.unite(edge[i].second.first, edge[i].second.second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7912
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}


int main() {
	string w; cin >> w;
	map<char, int> p;
	for (int i = 0; i < w.size(); i++) {
		p[w[i]]++;
	}
	for (int i = 0; i < w.size(); i++) {
		if (p[w[i]] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s1=sc.next();
    String s2=sc.next();
    String s3=sc.next();
    String S1=s1.toUpperCase();
    String S2=s2.toUpperCase();
    String S3=s3.toUpperCase();

    System.out.println(S1.charAt(0)+""+S2.charAt(0)+""+S3.charAt(0));



  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    int fact[1000005];
    bool ok=false;
 
    void f(int x){
        if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
    }
 
    void solve(){  
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        int gcd=a[0];
        // cout<<"in "<<ok<<"\n";
        f(a[0]);
        // cout<<"in "<<ok<<"\n";
        for(int i=1;i<n;i++){
            f(a[i]);
            gcd=__gcd(gcd,a[i]);
            // cout<<"in "<<ok<<"\n";
        }
        if(!ok){
            cout<<"pairwise coprime";
        }
        else if(gcd==1){
            cout<<"setwise coprime";
        }
        else{
            cout<<"not coprime";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int n,m;
vector<int> v;
vector<vector<P<int,int>>> graph;

bool Dfs(int x){
  for(auto&e:graph[x]){
    int to = e.first;
    int pos = v[x] + e.second;
    if(v[to] == -1001001001){
      v[to] = pos;
      if(!Dfs(to)) return false;
    } else if(v[to] != pos){
      return false;
    }    
  }
  return true;
}

int main(){
  cin >> n >> m;
  v.resize(n,-1001001001);
  graph.resize(n);
  for(int i = 0; i < m; ++i){
    int l, r, d; cin >> l >> r >> d;l--;r--;
    graph[l].push_back({r,d});
    graph[r].push_back({l,-d});
  }

  for(int i = 0; i < n; ++i){
    if(v[i] != -1001001001)continue;
    v[i] = 0;
    if(!Dfs(i)){
      cout << "No" << endl;
      return 0;
    }
    // for(int j = 0; j < n; ++j){
    //   cerr << v[j] << ' ';      
    // }cerr << endl;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 11008
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int a[] = new int[n];
  for(int i = 0;i < n;i++){
    a[i] = sc.nextInt();
  }
  Arrays.sort(a);
  int m = a[n-1];
    int min = 1000000000;;
    for(int i = 0;i < n-1;i++){
      if(Math.abs((double)m/2 - (double)a[i]) < Math.abs((double)m/2 - (double)min)){
        min = a[i];
      }
    }
    System.out.println(m + " " + min);
}}


Measured memory_bytes: 50512