akhauriyash/Code-Regression huggingface dataset:
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0

L = min(B, W)
r2 = "%d\n" % rev2
for i in range(L):
    sys.stdout.write(r2)
base = pow(rev2, L-1, MOD)

rB = rfact[B-1]; rW = rfact[W-1]
for i in range(L, B+W):
    base = rev2 * base % MOD
    if i >= B:
        p = (p + (fact[i-1]*rfact[i-B] % MOD) * (rB * base % MOD) % MOD) % MOD
    if i >= W:
        q = (q + (fact[i-1]*rfact[i-W] % MOD) * (rW * base % MOD) % MOD) % MOD
    sys.stdout.write("%d\n" % ((1-p+q)*rev2 % MOD))

Measured memory_bytes: 47836
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

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

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    int n , k;
    cin >> n >> k;
    vi a(n);
    fo(i , n) cin >> a[i];
    vector<int> dp(k + 2 , 0);
    
    int mi = *min_element(all(a));

    fo(i , mi)
        dp[i] = 0;
    
    for(int i = mi ; i <= k ; i++){
        for(int j : a)
            if(i - j >= 0)
                dp[i] |= (!dp[i - j]);
    }
    

    if(dp[k])
        cout << "First\n";
    else
        cout << "Second\n";

    return 0;
}



Measured memory_bytes: 3700
N, A, B, C = map(int,input().split())
L = [int(input()) for _ in range(N)]

def dfs(idx, a, b, c):
    if idx == N:
        if a == 0 or b == 0 or c == 0:
            return 1e9
        return abs(A-a) + abs(B-b) + abs(C-c)
    
    x = dfs(idx+1,a,b,c)
    y = dfs(idx+1,a+L[idx],b,c) + 10*(a!=0)
    z = dfs(idx+1,a,b+L[idx],c) + 10*(b!=0)
    w = dfs(idx+1,a,b,c+L[idx]) + 10*(c!=0)

    return min(x,y,z,w)

ans = dfs(0,0,0,0)

print(ans)

Measured memory_bytes: 3064
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

const p = 1000000007

func main() {
  NABCD := NextIntVec()
  N, A, B, C, D := NABCD[0], NABCD[1], NABCD[2], NABCD[3], NABCD[4]
  F, Finv, _ := Factorial(N)
  DP := make([][]int, B - A + 2)
  for i := range DP {
    DP[i] = make([]int, N + 1)
  }
  DP[0][0] = 1
  for i := range DP[1:] {
    x := A + i
    for j, dp := range DP[i] {
      if dp < 1 { continue }
      DP[i + 1][j] += dp
      DP[i + 1][j] %= p
      for k := C; k <= D ; k++ {
        y := j + x * k
        if N < y { break }
        z := (dp * F[y] % p) * Finv[j] % p
        for l := 0; l < k; l++ {
          z = z * Finv[x] % p
        }
        z = z * Finv[k] % p
        DP[i + 1][y] += z
        DP[i + 1][y] %= p
      }
    }
  }
  Write(DP[B - A + 1][N])
  Output()
}

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;


int main()
{
    string s;
    int flag = 1;
    cin>>s;
    while(flag)
    {
        flag = 0;
        int len = s.length();
        if(len < 5)break;
        if(!s.compare(len-5,len,"dream")||!s.compare(len-5,len,"erase"))
        {
            flag = 1;
            s.erase(len-5,len);
            continue;
        }
        if(!s.compare(len-6,len,"eraser"))
        {
            flag = 1;
            s.erase(len-6,len);
            continue;
        } 
               if(!s.compare(len-7,len,"dreamer"))
        {
            flag = 1;
            s.erase(len-7,len);
            continue;
        }
    }
    printf(s.length()?"NO\n":"YES\n");
}

Measured memory_bytes: 512
// atcoder/abc171/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli n;
  while (cin >> n) {
    --n;
    if (n == 0) {
      cout << 'a' << endl;
      continue;
    }

    vec<lli> v({1});
    while (v.size() < 13) {
      v.push_back(v.back() * 26);
    }
    int len = 1;
    for (int i = 1; i < v.size(); ++i) {
      if (n < v[i]) {
        len = i;
        break;
      }
      n -= v[i];
    }

    str s(len, 'a');
    for (int i = 0; n; ++i) {
      s[i] = 'a' + (n % 26);
      n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
ll a[301][301];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  ll res = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      bool eq = false;
      for(int k = 0; k < n; k++){
        if(k == i || k == j)continue;
        if(a[i][k] + a[k][j] == a[i][j])eq = true;
        else if(a[i][k] + a[k][j] < a[i][j]){
          cout << - 1 << endl;
          return 0;
        }
      }
      if(!eq){
        res += a[i][j];
      }
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 896
n = int(input())
cardslist = []

for i in range(n):
    input_cards = input()
    cardslist.append(input_cards)

for mark in "SHCD":
    for i in range(1, 14):
        if mark + ' ' + str(i) not in cardslist:
            print(mark + ' ' + str(i))



Measured memory_bytes: 5592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0 0 0")) {
			String[] partstr = str.split(" ", 3);
			int numofparts = Integer.parseInt(partstr[0])
					+ Integer.parseInt(partstr[1])
					+ Integer.parseInt(partstr[2]);
			int[] state = new int[numofparts];
			for (int i = 0; i < numofparts; i++) {
				state[i] = 2;
			}
			str = br.readLine();
			int n = Integer.parseInt(str);
			String[][] resultstr = new String[n][4];
			for (int i = 0; i < n; i++) {
				str = br.readLine();
				resultstr[i] = str.split(" ", 4);
			}
			for (int m = 0; m < n; m++) {
				for (int l = 0; l < n; l++) {
					int i = Integer.parseInt(resultstr[l][0]) - 1;
					int j = Integer.parseInt(resultstr[l][1]) - 1;
					int k = Integer.parseInt(resultstr[l][2]) - 1;
					int r = Integer.parseInt(resultstr[l][3]);
					if (r == 1) {
						state[i] = 1;
						state[j] = 1;
						state[k] = 1;
					} else {
						if (state[i] == 1 && state[j] == 1)
							state[k] = 0;
						if (state[i] == 1 && state[k] == 1)
							state[j] = 0;
						if (state[k] == 1 && state[j] == 1)
							state[i] = 0;
					}
				}
			}
			for (int states : state) {
				System.out.println(states);
			}
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 29760
#include<iostream>
int main() 
{
	int x,i=0;
	while (1)
	{
		
		std::cin >> x;
		if (x == 0)
		{
			break;
		}
		i += 1;
		std::cout << "Case" <<" "<<i<<":"<<" "<< x << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3016
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>

using Coord = std::pair<int32_t, int32_t>;

double dist(const Coord& pos1, const Coord& pos2) {
  return std::sqrt((pos1.first - pos2.first) * (pos1.first - pos2.first) +
                   (pos1.second - pos2.second) * (pos1.second - pos2.second));
}

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<std::pair<int32_t, int32_t>> pos(N);
  for (size_t i = 0; i < N; i++) std::cin >> pos[i].first >> pos[i].second;

  uint32_t fact = 1;
  std::vector<uint32_t> path(N);
  for (size_t i = 0; i < N; i++) {
    path[i] = i;
    fact *= i + 1;
  }

  double sum = 0.0;
  do {
    for (size_t i = 0; i < path.size() - 1; i++)
      sum += dist(pos[path[i]], pos[path[i + 1]]) / fact;
  } while (std::next_permutation(path.begin(), path.end()));

  std::cout << std::fixed << std::setprecision(10) << sum << std::endl;

  return 0;
}

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



int main(){
  int A,B,C;
  int D,E,F;
  int G,H,I;
  cin>>A>>B>>E;
  for(int i=0;i<1000;i++){
    C=i;
    int sum=A+B+C;
    G=sum-E-C;
    D=sum-A-G;
    F=sum-D-E;
    H=sum-B-E;
    I=sum-G-H;
    if(A+B+C==D+E+F&&
       A+B+C==G+H+I&&
       A+B+C==A+D+G&&
       A+B+C==B+E+H&&
       A+B+C==C+F+I&&
       A+B+C==A+E+I&&
       A+B+C==C+E+G){
      cout<<A<<' '<<B<<' '<<C<<endl;
      cout<<D<<' '<<E<<' '<<F<<endl;
      cout<<G<<' '<<H<<' '<<I<<endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 15 != 0 && i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
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 powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n+1);
    rep(i, n+1){
        cin >> a[i];
    }
    vll b(n);
    rep(i, n){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = n-1; i >= 0; i--){
        ll f = min(b[i], a[i+1]);
        b[i] -= f;
        a[i+1] -= f;
        ans += f;
        ll g = min(b[i], a[i]);
        b[i] -= g;
        a[i] -= g;
        ans += g;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
from sys import stdin

n, k, q = map(int, stdin.readline().rstrip().split())
a = [0] * q
for i in range(q):
    a[i] = int(stdin.readline().rstrip())

l = [0] * (n+1)

for ai in a:
    l[ai] += 1

for i in range(n):
    j = i+1
    point = k - (q-l[j])
    if point <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 13744
#include <iostream>

using namespace std;

int main() {
	int r, g, b;
	cin >> r;
	cin >> g;
	cin >> b;
	int n = 100 * r + 10 * g + b;
	if(n % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define CHMAX(a,b) (a)=max((a),(b))
#define CHMIN(a,b) (a)=min((a),(b))
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n],t[n],u[n];
    for(int i=0;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        s[i]=a;
        t[i]=b;
        u[i]=c;
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int hmax=1<<30;
            int hmin=-1;
            for(int k=0;k<n;k++){
                int aa=abs(s[k]-i)+abs(t[k]-j);
                if(u[k]==0){
                    hmax=min(hmax,aa);
                }
                else{
                    hmax=min(hmax,aa+u[k]);
                    hmin=max(hmin,aa+u[k]);
                }
                
            }
            if(hmax==hmin){
                cout<<i<<" "<<j<<" "<<hmax<<endl;return 0;
                }
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int sum=0;
    int max=0;
    for(int i=0;i<n;i++){
      int p=sc.nextInt();
      if(p>max){
        max=p;
      }
      sum+=p;
    }
    System.out.println(sum-max/2);
  }
}

Measured memory_bytes: 24020
#include <stdio.h>
#include <stdlib.h>

long long int changeCount(long long int*, int, int);

int main(void){
	/*
	サイズnの入力
	*/
	int n;
	if(scanf("%d\n", &n) < 1){
		exit(1);
	}

	/*
	a_1,a_2, ... a_nの入力
	*/
	long long int *a;
	a = (long long  int*) malloc ( n * sizeof(long long int));
	int i;
	for(i=0; i<n-1; i++){
		if(scanf("%lld ", &a[i]) < 1){ //scanfの戻り値は、成功した変数の数、もしくは-1である
			//printf(stderr, "error: ill-formed fraction.\n");
			exit(1);
		}
	}
	if(scanf("%lld", &a[n-1]) < 1){
		//printf(stderr, "error: ill-formed fraction.\n");
		exit(1);
	}

	long long int evenchangeCount = changeCount(a, n, 0); //何回変更するのかのカウント
	long long int oddchangeCount = changeCount(a, n, 1); //何回変更するのかのカウント
	
	if(evenchangeCount <= oddchangeCount){
		printf("%lld", evenchangeCount);
	}else{
		printf("%lld", oddchangeCount);
	}
	free(a);
	return 0;
}



long long int changeCount(long long int *a, int n, int oddPositive){
	/*
	temp_1はa[0]〜a[i-1]までの和
	temp_2はa[0]〜a[i]までの和
	*/
	long long int temp_1=0;
	long long int temp_2=0;
	long long int changeCount = 0; //何回変更するのかのカウント

	int i;
	for(i=0; i < n; i++){
		temp_2 = temp_1 + a[i];

		if(i%2 == 1){ /*iが奇数の時*/
			if(oddPositive == 1){//合計が正でなければいけないとき
				if(temp_2 <= 0){//正でないなら
					changeCount += -temp_2 + 1;
					temp_2 = 1;
				}
			}else{//合計が負でなければいけないとき
				if(temp_2 >= 0){//負でないなら
					changeCount += temp_2 + 1;
					temp_2 = -1;
				}
			}

		}else{/*iが偶数の時*/
			if(oddPositive == 0){//合計が正でなければいけないとき
				if(temp_2 <= 0){//正でないなら
					changeCount += -temp_2 + 1;
					temp_2 = 1;
				}
			}else{//負でなければいけないとき
				if(temp_2 >= 0){//負でないなら
					changeCount += temp_2 + 1;
					temp_2 = -1;
				}
			}
		}
		temp_1 = temp_2;
	}
	return changeCount;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-26 20:42:26 +0900
# LastModified: 2020-07-20 04:38:38 +0900
#


import os
import sys
import numpy as np
# import pandas as pd


def main():
    h, w = map(int, input().split())
    a = np.zeros((h,w), dtype = np.int32)
    for i in range(h):
        s = input()
        for j in range(w):
            if s[j] == '.':
                a[i, j] = 1
    stack = []
    delete_colums = 0
    delete_index = 0
    for i in range(h):
        if np.sum(a[i, :]) == w:
            stack.append(i)
            delete_index += 1
    while stack:
        p = stack.pop()
        a = np.delete(a, obj=p, axis=0)

    for i in range(w):
        if np.sum(a[:, i]) == h-delete_index:
            stack.append(i)
            delete_colums += 1
    while stack:
        p = stack.pop()
        a = np.delete(a, obj=p, axis=1)
    
    for i in range(h-delete_index):
        for j in range(w-delete_colums):
            if a[i, j] == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
            



if __name__ == "__main__":
    main()


Measured memory_bytes: 27376
#include <bits/stdc++.h>
using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(ii, aa, bb) for (int ii = aa; ii >= bb; ii--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back
vector<vector<int>> dp;
vector<int> A, B, C;
int rec(int curr, int a)
{
    if (curr == A.size())
    {
        return 0;
    }
    if ( a > 0 && dp[curr][a] != -1)
    {
        return dp[curr][a];
    }
    int ans = 0;
    if (a != 1)
    {
        ans = max(ans, A[curr] + rec(curr + 1, 1));
    }
    if (a != 2)
    {
        ans = max(ans, B[curr] + rec(curr + 1, 2));
    }
    if (a != 3)
    {
        ans = max(ans, C[curr] + rec(curr + 1, 3));
    }
    dp[curr][a] = ans;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    dp.assign(n, vector<int>(4, -1));
    A.resize(n);
    B.resize(n);
    C.resize(n);
    rep(i, 0, n)
    {
        cin >> A[i] >> B[i] >> C[i];
    }
    cout << rec(0, 0);
}

Measured memory_bytes: 14720
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
using namespace std;
const int maxN=1e7;
struct student{
    int n;
    int all;
}S[maxN];
bool cmp(student s1,student s2){
    return s1.all<s2.all;
}
int main(){
    int m;
    cin>>m;
    for(int i=1;i<=m;i++){
        cin>>S[i].all;
        S[i].n=i;
    }
    sort(S+1,S+m+1,cmp);
    for(int i=1;i<=m;i++){
        if(i==m){
            cout<<S[i].n<<endl;
        }else
        {
        cout<<S[i].n<<" ";
        }
        
        
    }
    
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    int bt = 0;
    int bx=0,by = 0;
    rep(i,n){
        int t,x,y;cin>>t>>x>>y;
        int dist = abs(bx-x)+abs(by-y);
        if(((t-bt)>=dist)&&((t-bt)%2==dist%2)){bx=x;by=y;bt=t;continue;}
        else{co("No");return 0;}
    }
    co("Yes");
}

Measured memory_bytes: 256
using System;

namespace abc160_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = (Console.ReadLine().Trim());            
            var l = n.ToCharArray();
            Console.WriteLine(l[2]==l[3] && l[4] == l[5] ? "Yes":"No");
        }
    }
}


Measured memory_bytes: 11092
program TST01;
var s:string;
begin
 read(s);
 if s = '25' then
 	writeln('Christmas');
     if s = '24' then
 	writeln('Christmas Eve');
     if s = '23' then
 	writeln('Christmas Eve Eve');
     if s = '22' then
 	writeln('Christmas Eve Eve Eve');
end.

Measured memory_bytes: 128
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var k = int.Parse(line[2]);
            if (n == 0 && m == 0 && k == 0) break;
            var amax = n * m;
            var dp = new long[n, amax + 1];
            for (int i = 1; i <= m; i++) dp[0, i] = 1L;
            for (int i = 1; i < n; i++)
                for (int j = 1; j <= m; j++)
                    for (int L = 1; L <= amax; L++)
                    {
                        var ww = dp[i - 1, L];
                        if (ww != 0) dp[i, j + L] += ww;
                    }
            var res = getAns(dp, n, m, k);
            Console.WriteLine(res);
        }
    }
    public static double getAns(long[,] dp, int n, int m, int k)
    {
        var a0 = n * m + 1;
        var minus = 0L;
        var sum = 0L;
        for (int i = 0; i < a0; i++)
        {
            var te = (long)(i - k);
            if (te <= 0) minus += dp[n - 1, i];
            else if (te == 1) sum += dp[n - 1, i] + minus;
            else sum += te * dp[n - 1, i];
        }
        return (double)sum / Math.Pow(m, n);
    }
}


Measured memory_bytes: 7984
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F_d first
#define S_d second
#define LARGE 100000000
#define MOD 100000
#define LL long long

string s;
int I = 0, O = 0, J = 0, k = 0;

int main() {
	cin >> s;

	if (s[0] == 'J')J++;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == 'J') {
			if (s[i - 1] != 'J') J = O = I = 0;
			J++;
		}
		else if (s[i] == 'O') {
			if (s[i - 1] == 'J' || (s[i - 1] == 'O' && J > O)) { O++; I = 0; }
			else J = O = I = 0;
		}
		else {
			if ((s[i - 1] == 'O' && J != 0) || (s[i - 1] == 'I' && J != 0 && O != 0)) {
				I++;
				if (I == O)k = max(k, O);
			}
			else J = O = I = 0;
		}
	}

	cout << k << endl;

	return 0;
}




Measured memory_bytes: 3984
#include <iostream>
#include <vector>

using namespace std;


int main(){
  long long N;
  long long t = 1000000007;
  cin >> N;
  int a[N+1];

  for (int i = 2; i < N+1; i++){
    a[i] = 0;
  }

  for (int i = 2; i < N+1; i++){
    int n = i;
    for (int j = 2; j * j <= n; j++){
      if(n%j != 0) continue;
      int ex = 0;
      while (n%j == 0){
        ex++;
        n /= j;
      }
      a[j] += ex;
    }
    a[n] += 1;
  }
  
  long long ans = 1;
  for (int i = 2; i < N+1; i++){
    ans %= t;
    ans *= (a[i]+1);
  }
  printf("%llu\n",ans%t);
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double X = 0;
  for ( int i = 0; i < N; i++) {
    double A = 0;
    string M;
    cin >> A >> M;
    if ( M == "JPY") {
      X += A;
    }
    else {
      X += (A*380000);
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 256
# include <iostream> # include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -100000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll n, x;
vector<ll> a;

int ok(int v) {
  if (v > n) return 0;
  int aa = (v + 1) / 2;
  int re = n - aa;
  int y = lower_bound(a.begin(), a.end(), x - (a[re] - x)) - a.begin();
  return y + v <= n;
}

int main() {
  ll q;
  cin >> n >> q;
  vector<ll> s(n + 1, 0), t(n + 1, 0);
  a.resize(n);
  rep(i, n) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
    t[i + 1] = (i >= 1 ? t[i - 1] : 0) + a[i];
  }
  while (q--) {
    cin >> x;
    int turn = 0;
    repr(i, 20) {
      if (ok(turn + (1 << i))) turn += 1 << i;
    }
    int a = (turn + 1) / 2;
    if (turn % 2 == 1) turn++;
    ll ret = s[n] - s[n - turn / 2];
    if (turn < n) ret += t[n - turn];
    cout << ret << endl;
  }


  
  return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main(void){
    int n;
    int a = 0;

    while ((n = getchar()) != '\n')
    {
        n -= '0';
        a += n;
    }
    if(a % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 1528
import java.util.Stack;
import java.io.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Stack<Integer> S = new Stack<Integer>();
        int a, b;


        try{
            String input[] = br.readLine().split("\\s+");

            for(int i = 0; i < input.length; i++){
                if(!input[i].equals("+") && !input[i].equals("-") && !input[i].equals("*")) {
                     S.push(Integer.parseInt(input[i])); //intに変換
                    continue;
                }

                b = S.peek();
                S.pop();
                a = S.peek();
                S.pop();

                if(input[i].equals("+")) {
                    S.push(a+b);
                } else if(input[i].equals("-")) {
                    S.push(a-b);
                } else if(input[i].equals("*")) {
                    S.push(a*b);
                }
            }
            System.out.println(S.peek());

        } catch (IOException e) {
            e.printStackTrace();
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }

}



Measured memory_bytes: 24492
# -*- coding: utf-8 -*-

import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        a, b, c, d = map(int, input().split())
        one = a * b
        another = c * d
        print(max(one, another))
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n,k,a;
    cin>>n>>k;
    set<ll> s;
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        s.insert(a);
    }
    for(ll i=n;;i++)
    {
        ll num=i;
        bool boo=true;
        while(num>0)
        {
            if(s.find(num%10)!=s.end())
            {
                boo=false;
                break;
            }
            num/=10;
        }
        if(boo)
        {
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	double D,T,S;
	cin>>D>>T>>S;
	double k=D/S;
	if(k<=T)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

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

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int L;
	stack<int> rec; rec.push(0);
	bool in[1005] = {};
	cin >> L;
	rep(i, L) {
		int c;
		cin >> c;
		if (c > 0) {
			if (in[c]) {
				cout << i+1 << endl;
				return 0;
			}
			in[c] = true;
			rec.push(c);
		}
		else {
			c = -c;
			int f = rec.top();
			if (f != c) {
				cout << i + 1 << endl;
				return 0;
			}
			rec.pop();
			in[c] = false;
		}
	}
	cout << "OK" << endl;

	return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
long long int n;
double prob[3000];
double dp[3000][3000];
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() 
{    
	boost
    scanf("%lld",&n);
    long long int i,j,k;
    for(i=1;i<=n;i++)
    scanf("%lf",&prob[i]);
    dp[1][0]=1-prob[1];
    dp[1][1]=prob[1];
    for(i=2;i<=n;i++)
    	for(j=0;j<=i;j++)
    	{
            if(j==0)
            	dp[i][j]=dp[i-1][j]*(1-prob[i]);
            else
            	dp[i][j]=dp[i-1][j]*(1-prob[i])+dp[i-1][j-1]*prob[i];
    	}
        double ans=0;
    	for(j=(n+1)/2;j<=n;j++)
    		ans+=dp[n][j];
    cout<<fixed<<setprecision(9);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 68992
#include<iostream>

using namespace std;


int isPrim(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}

int main() {
	int n;
	cin >> n;
	int pre = 2;
	for (int i = 0; i < n; i++) {
		for (int j = pre; j <= 55555; j++) {
			if (j % 10 == 1 && isPrim(j)) {
				cout << j;
				if (i == n - 1) {
					cout << endl;
				}
				else {
					cout << " ";
				}
				pre = j + 1;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N*A, B) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		
		int[] as = new int[n];
		BigInteger exact = BigInteger.valueOf(1000);
		BigInteger holds = BigInteger.ZERO;
		for (int i = 0; i < n; i++) {
			as[i] = sc.nextInt();
			if (i == 0) continue;
			if (as[i] > as[i-1]) {
				// 今 > 前	→前の値段で買って今売る
				holds = exact.divide(BigInteger.valueOf(as[i-1]));
				exact = exact.subtract(holds.multiply(BigInteger.valueOf(as[i-1]))).add(holds.multiply(BigInteger.valueOf(as[i])));
			}
		}
		System.out.println(exact);
	}
}


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

using namespace std;

int N, K;
int DpLen[2][100002];
bool Used[100001];

int solve() {
	int maxLen;

	for (int i = 1; i <= N; ++i) {
		if (!Used[i]) {
			continue;
		}
		DpLen[0][i] = DpLen[0][i - 1] + 1;
	}
	for (int i = N; i >= 1; --i) {
		if (!Used[i]) {
			continue;
		}
		DpLen[1][i] = DpLen[1][i + 1] + 1;
	}

	maxLen = 1;


	for (int i = 1; i <= N; ++i) {
		maxLen = max(maxLen, max(DpLen[0][i], DpLen[1][i]));
		if (!Used[0] || Used[i]) {
			continue;
		}
		maxLen = max(maxLen, DpLen[0][i - 1] + 1 + DpLen[1][i + 1]);
	}

	return maxLen;
}

int main() {
	int a;

	while (cin >> N >> K, N) {
		memset(DpLen, 0, sizeof(DpLen));
		memset(Used, false, sizeof(Used));
		for (int i = 0; i < K; ++i) {
			cin >> a;
			Used[a] = true;
		}
		cout << solve() << endl;
	}

	return 0;
}


Measured memory_bytes: 3964
n=int(input())

kp=-10
km=10
k=0
while not(km<=n and n<=kp):
    k=k+1
    km=-int(2*(4**k-1)/(4-1))
    kp=int((4**k-1)/(4-1))
#    print("n=",n,"k=",k,"km=",km,"kp=",kp)        
#print("n=",n,"n-km=",n-km)

n=n-km

v=""
for kk in range(k):
    np=n//4**(k-kk-1)
    n=n-np*4**(k-kk-1)
    if np==0:
        v=v+"10"
    elif np==1:
        v=v+"11"
    elif np==2:
        v=v+"00"
    elif np==3:
        v=v+"01"
#print("v=",v)

if len(v)>0 and v[0]=="0":
    v=v[1:]
if len(v)>0:
    print(v)
else:
    print(0)


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
a.sort()

i = 0
while i < n-1:
    x = a[i+1] % a[i]
    a[i+1] = a[i]
    a[i] = x
    if a[i] == 0:
        i += 1
print(a[i])


Measured memory_bytes: 20076
import scala.io.StdIn

object Main extends App {

  def dec(n: String) = n.foldLeft(0)((acc, c) => acc + Integer.parseInt(c.toString))

  val n = StdIn.readLine()

  val x = dec(n)

  // 10000000000
  println(if (x != 0 && n.toLong % x == 0) "Yes" else "No")

}


Measured memory_bytes: 25412
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    //querySolve();
    solve();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }

                var oneLine = Console.ReadLine().Split().Select(double.Parse).ToList();

                var average = oneLine.Average();
                var variance = oneLine.Select(x => (x - average) * (x - average)).Sum() / n;
                var standardDeviation = Math.Sqrt(variance);

                Console.WriteLine(standardDeviation.ToString("F5"));
            }
        }
    }
}



Measured memory_bytes: 18304
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u8,
        a: [u64; n],
    }

    let mut money: u64 = 1000;
    for i in 1..n {
        if a[i as usize] > a[(i - 1) as usize] {
            let num_stocks = money / a[(i - 1) as usize];
            money += num_stocks * (a[i as usize] - a[(i - 1) as usize])
        }
    }
    println!("{}", money);
}


Measured memory_bytes: 2172
#include<iostream>

using namespace std;

int main(){
  string x;
  int sum;
  while(1){
      cin >> x;
      if(x[0] == '0')break;
      sum = 0;
      for(int i = 0; x[i] != '\0'; i++){
          sum += (x[i] - '0');
      }
      cout << sum << endl;
  }return 0;
}


Measured memory_bytes: 3164
# AOJ 0143 Altair and Vega
# Python3 2018.6.18 bal4u

# a, b, はラインの同一側にあるか
def is_atSameSide(a, b, line):
	sa = (line[1].real-line[0].real)*(a.imag-line[0].imag) \
		 + (line[1].imag-line[0].imag)*(line[0].real-a.real);
	sb = (line[1].real-line[0].real)*(b.imag-line[0].imag) \
		 + (line[1].imag-line[0].imag)*(line[0].real-b.real);
	return (sa > 0 and sb > 0) or (sa < 0 and sb < 0)    # a, b at same side

for i in range(int(input())):
	buf = list(map(int, input().split()))
	p1 = complex(buf[0], buf[1])
	p2 = complex(buf[2], buf[3])
	p3 = complex(buf[4], buf[5])
	pk = complex(buf[6], buf[7])
	ps = complex(buf[8], buf[9])

	kin = is_atSameSide(p3, pk, [p1, p2]) & \
		  is_atSameSide(p1, pk, [p2, p3]) & \
		  is_atSameSide(p2, pk, [p3, p1])
	sin = is_atSameSide(p3, ps, [p1, p2]) & \
		  is_atSameSide(p1, ps, [p2, p3]) & \
		  is_atSameSide(p2, ps, [p3, p1])
	print("OK" if kin ^ sin else "NG")


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,n,k,a,b,c,d,o,m,r,n1,n2,l,j,n3;
    cin>>n;
    r=n%10;
    if(r==2||r==4||r==5||r==7||r==9)
        cout<<"hon\n";
    else if(r==0||r==1||r==6||r==8)
         cout<<"pon\n";
    else cout<<"bon\n";
}




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

int main() {
  string s;
  cin >> s;
  int b = 0;
  ll ans = 0;
  rep(i, s.size()) {
    if (s[i] == 'B') ++b;
    else ans += b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
int main() {
	int a[4][3][10], n, b, f, r, v,a1,a2,a3;
	for (a1 = 0; a1 < 4; a1 = a1 + 1) {
		for (a2 = 0; a2 < 3; a2 = a2 + 1) {
			for (a3 = 0; a3 < 10; a3 = a3 + 1) {
				a[a1][a2][a3] = 0;
			}
		}
	}
	cin >> n;
	for (; n > 0; n = n - 1) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] = a[b-1][f-1][r-1] + v;
	}
	for (a1 = 0; a1 < 4; a1 = a1 + 1) {
		for (a2 = 0; a2 < 3; a2 = a2 + 1) {
			for (a3 = 0; a3 < 10; a3 = a3 + 1) {
				if (a[a1][a2][a3] < 0) {
					a[a1][a2][a3] = 0;
				}
				if (a[a1][a2][a3] > 9) {
					a[a1][a2][a3] = 9;
				}
				cout << ' ' << a[a1][a2][a3];
			}
			cout << endl;
		}
		if (a1 == 3) {
			return 0;
		}
		cout << "####################" << endl;
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 100005
int n,Cnt[1000];
int cnt;
char S[10];
int main() {
	scanf("%s",S);
	for(int i='A'; i<='Z'; i++)Cnt[i]=2;
	for(int i=0; i<4; i++)if(--Cnt[S[i]]==0)cnt++;
	puts(cnt==2?"Yes":"No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int N, M, C;
  int a[21][21];
  int b[21];
  int res=0;
  cin >> N >> M >> C;

  rep(i,M) cin >> b[i];
  rep(i,N){
    rep(j,M){
      cin >> a[i][j];
    }
  }

  rep(i,N){
    int score = 0;
    rep(j,M){
      score += a[i][j]*b[j];
    }
    score += C;
    if(score>0) res++;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
N,K = map(int, input().strip().split())
S=input().strip()

point=0
gap=0
for i in range(N-1):
    if S[i+1] == S[i]:
        point+=1
    else:
        gap+=1

if gap % 2 ==0:
    if K >= gap/2:
        point+=gap
    else:
        point+=K*2
else:
    if K >= gap//2+1:
        point+=gap
    else:
        point+=K*2
print(point)

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

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int a = x2 - x1;
  int b = y2 - y1;

  int x3, y3, x4, y4;


  x3 = x2 + -1  * b;
  y3 = y2 + a;

  int tmp;
  tmp = -1 * b;
  b = a;
  a = tmp;

  x4 = x3 + (- 1 * b);
  y4 = y3 + a;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 3564
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;

int main() {
	int32_t n;
	cin >> n;
	vector<int32_t> a(n);
	for (int32_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	std::sort(a.begin(), a.end());
	auto half = std::lower_bound(a.begin(), a.end(), a[n - 1] / 2);
	int32_t ans = 0;
	if (half != a.begin()) {
		int32_t l, r;
		r = *half;
		--half;
		l = *half;
		if (r == a[n - 1])ans = l;
		else {
			if (l <  a[n - 1] - r) {
				ans = r;
			}
			else {
				ans = l;
			}
		}
	}
	else {
		ans = *half;
	}
	
	cout << a[n - 1] << " " << ans;

	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline

n = int(input())
a = list(map(int, input().split()))

ans = [0 for _ in range(n)]
for a_i in a:
    ans[a_i - 1] += 1

for i in range(n):
    print(ans[i])


Measured memory_bytes: 100500
<?php
fscanf(STDIN, '%d', $N);
fscanf(STDIN, '%s', $S);
$mmin = 0;
$tmp = 0;
$a = str_split($S);
for ($i = 0; $i < $N; $i++) {
    if ($a[$i] === ')') {
        $tmp--;
        $mmin = min($tmp, $mmin);
    }
    if ($a[$i] === '(') {
        $tmp++;
    }
}
$ans = '';
$ans .= str_repeat('(', -$mmin);
$tmp -= $mmin;
$ans .= $S;
if ($tmp > 0) {
    $ans .= str_repeat(')', $tmp);
}
echo $ans;


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long A,B,N;
cin>>A>>B>>N;
long long x;
if(B-1>N){
    x=N;
}
else{
    x=B-1;
}
long long ans1=(A*x)/B;
long long ans2=x/B;
ans2*=A;
long long ans=ans1-ans2;
cout<<ans<<"\n";
return 0;
}


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

void sort(string s[], int a[], int n) {
  for (int i = 0; i < n; i++) {
    for (int j = i; j > 0; j--) {
      if (a[j - 1] < a[j]) {
	int t = a[j - 1];
	a[j - 1] = a[j];
	a[j] = t;
	string u = s[j - 1];
	s[j - 1] = s[j];
	s[j] = u;
      }
    }
  }
}

int main() {
  bool flag = false;
  for ( ; ; ) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    if (flag) cout << endl;
    else flag = true;
    string s[n];
    int w[n], l[n], d[n], score[n];
    for (int j = 0; j < n; j++)
      cin >> s[j] >> w[j] >> l[j] >> d[j];
    for (int j = 0; j < n; j++)
      score[j] = w[j] * 3 + d[j];
    
    sort(s, score, n);
    for (int j = 0; j < n; j++)
      cout << s[j] << ',' << score[j] << endl;
  }
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,j,k;
   string s;
   cin>>n;
   cin>>s;
   for(i=0;i<s.size();i++)
   {

    s[i]=s[i]+n;
    if(s[i]>=91)
    {
        s[i]=s[i]-26;
    }
   }
   cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
  int ar[1000000];
bool check(int x )
{
  int sum =0;
  for(int i=0;i<n;i++)
  {
sum+=(ar[i]-1)/x;
  }
  if(sum<=k)
    return true;
  return false;
}
int main()
{
  
  cin>>n>>k;

  int longest=-1;//save length of longets log
  for(int i=0;i<n;i++)
  {//finding longest log
    cin>>ar[i];
    longest=max(longest, ar[i]);
    }
  //now we know longest log and our ans depends on it
  // we  find now how to cut the longest log to cut ans 
  // obvious max we can get if we divide it in 2 halfves 
  // but taking care of thye total cuts to make its length is tend 
  // decrease or increase to satisfy the given condition
  
   int l=1,r=longest;
    //cout<<"start l val : "<<l<<",  r value : "<<r;
    while(l<r) {
        int mid=(l+r)/2;
        if(check(mid))
        {r=mid;
       // cout<<"l value :  "<<l<<", r value  : "<<r<<endl;
        }
 
        else 
        {l=mid+1;
     //   cout<<" check mid false l value : "<<l<<", r value  : "<<r<<endl;
        }
    }
  cout<<l;
  
  
  
}


Measured memory_bytes: 4420
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = get_tuple!(u64, u64);
    let m = n % k;
    let mm = k - m;
    // dbg!(&m);
    let ans = if m > mm {mm} else {m};
    println!("{}", ans)
}


Measured memory_bytes: 2160
s = input()
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
b = a.index(s)
b += 1
print(a[int(b)])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long INF = 100000000;


int main(){
  long long n;
  cin >> n;
  long long dp[n];
  for(int i = 0; i < n; i++){
    dp[i] = INF;
  }
  int c[n];
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  int i = 2;
  dp[0] = 0;
  dp[1] = abs(c[0] - c[1]);
  while(i!=n){
    dp[i] = min(dp[i-1] + abs(c[i]-c[i-1]),dp[i-2] + abs(c[i]-c[i-2]));
    i++;
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
vector<int>vec2;
vector<int>vec3;

int main(){
  int n,a;
  cin>>n>>a;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    vec.push_back(x);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<vec.size();i++){
    if(i==0&&vec[i]>a){
      vec2.push_back(a);
    }
    else if(i!=0&&vec[i-1]<a&&a<vec[i]){
      vec2.push_back(a);
    }
    vec2.push_back(vec[i]);
    if(i+1==n&&vec[i]<a){
      vec2.push_back(a);
    }
  }
  //for(int i=0;i<vec2.size();i++)cout<<vec2[i]<<endl;
  for(int i=1;i<vec2.size();i++){
    vec3.push_back(vec2[i]-vec2[i-1]);
  }
  int x,y;
  x=vec3[0];
  //for(int i=0;i<vec3.size();i++)cout<<vec3[i]<<' ';
  //cout<<endl;
  int temp;
  for(int i=1;i<vec3.size();i++){
    y=vec3[i];
    if(x<y)swap(x,y);
    while(y!=0){
      temp=y;
      y=x%y;
      x=temp;
    }
  }
  cout<<x<<endl;
  return(0);
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a [n];
  int min = INT_MAX;
  for(int i = 0 ; i < n; i++)cin>>a[i];
  sort(a, a+n);
  for(int i = 0;  i<=n-k; i++)
    (a[i+k-1] - a[i])<min?min =(a[i+k-1] - a[i]):min = min;
  cout<<min<<endl;  
  return 0;
}

Measured memory_bytes: 640