akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >>n;
  vector<string> s(n);
  rep(i,n) cin >>s[i];
  sort(s.begin(), s.end());
  int ans = 1;
  for(int i  = 1; i<n; i++){
    if(s[i-1]!=s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int N;
  cin>>N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin>>s[i];
  bool ok = true;
  for (int i = 1; i < N; i++) {
    bool flag = false;
    string prev = s[i - 1];
    int sizep = prev.size();
    string cur = s[i];
    if (prev[sizep - 1] != cur[0]) {
      ok = false;
      break;
    }
    for (int j = 0; j < i - 1; j++) {
      if (s[j] == cur) {
        flag = true;
        break;
      }
    }
    if (flag) {
      ok = false;
      break;
    }
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    loop {
        let s = read::<String>();
        if s.chars().nth(0) == Some('0') {
            break;
        }
        let sum = s.chars().map(|c| c as u32 - 48).sum::<u32>();
        println!("{}", sum);
    }
}



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

int main(){
    int n;
    cin >> n;
    ll a[n], b[n];
    ll asum = 0, bsum = 0;
    rep(i, n){
        cin >> a[i];
        asum+= a[i];
    }
    rep(i, n){
        cin >> b[i];
        bsum += b[i];
    }

    if (asum < bsum){
        cout << -1 << endl;
        return 0;
    }

    ll diff = asum - bsum;

    vector<ll> d;
    rep(i, n){
        if (a[i] >= b[i]) d.push_back(a[i] - b[i]);
    }
    sort(d.begin(), d.end());

    int i = 0;
    while (diff - d[i] >= 0 && i < d.size()){
        diff -= d[i];
        i ++;
    }

    cout << n - i << endl;

    return 0;
}

Measured memory_bytes: 2808
n, k, q = map(int, input().split())
alist = list(map(int, input().split()))
ans = None
if q == 1:
  print(0)
else:
  for i, a in enumerate(alist):
    spla = []
    preva = -1
    ailist = alist[:i] + alist[i+1:]
    for j, _a in enumerate(ailist):
      if _a < a:
        spla.append(ailist[preva+1:j])
        preva = j
    if not preva == len(ailist)-1:
      spla.append(ailist[preva+1:])
    conda = []
    for sa in spla:
      if len(sa) >= k:
        conda.extend(list(sorted(sa))[:len(sa)-k+1])
    if len(conda) < q-1:
      continue
    else:
      y = list(sorted(conda))[q-2]
      if ans is None or ans > y - a:
        ans = y - a

  print(ans)


Measured memory_bytes: 3316
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n+ss)%2==0 and (e+w)%2==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)


int n,a,b,c;
vector<int> l;
int INF = 1000000000;

int rec(int num, int p, int q, int r){
  if (n==num) {
    int t1,t2,t3;
    t1 = p-a;
    t2 = q-b;
    t3 = r-c;
    if(min(p,min(q,r)) > 0){
    //cout << p << " " << q << " " << r << endl; 
    return abs(t1) + abs(t2) + abs(t3) -30; 
    } else return INF;
  }  
  else{
    int r0 = rec(num+1, p, q, r);
    int r1 = rec(num+1, p+l[num], q, r)+10;
    int r2 = rec(num+1, p, q+l[num], r)+10;
    int r3 = rec(num+1, p, q, r+l[num])+10;
    return min(min(r0,r1), min(r2,r3));
  }
}

void solve(){
  cin >> n >> a >> b >> c;
  rep(i,n){
    int j;
    cin >> j;
    l.emplace_back(j);
  }
  cout << rec(0,0,0,0) << endl;
  
}

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


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

using namespace std;

const int INF = 2e9;
const int MAX_N = 1e5 + 5;

int n, k;

int h[MAX_N];

int dp[MAX_N];

int main() {
  // dp[i] = the minimum cost to get a stone i
  // I can here to stone i from stone i - 1, i - 2 ... i - k so i gonna chose from those k
  // So, dp[i] = min(dp[i - 1] + query(i, i - 1) ... dp[i - k] + query(i, i - k))
  // I am at stone 1, so dp[1] = 0, no cost to get here
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
    dp[i] = INF;
  }
  dp[1] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i + j <= n) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
  }
  cout << dp[n] << "\n";
  return 0;
}


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

int H,W,C;
const int dx[] = {+1, 0,-1, 0};
const int dy[] = { 0,+1, 0,-1};

void dfs(int data[8][8], int x, int y, int c)
{
	int tc = data[x][y];
	data[x][y] = c;
	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(0<=nx && nx<W && 0<=ny && ny<H)
		{
			if(data[nx][ny]==tc) dfs(data, nx, ny, c);
		}
	}
}

int cnt(int data[8][8], int x, int y)
{
	int res=1;
	int tc = data[x][y];
	data[x][y] = 0;
	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(0<=nx && nx<W && 0<=ny && ny<H)
		{
			if(data[nx][ny]==tc) res+=cnt(data, nx, ny);
		}
	}
	return res;
}

int func(int data[8][8], int t)
{
	if(t==4)
	{
		if(data[0][0]!=C) dfs(data, 0, 0, C);
		return cnt(data, 0, 0);
	}

	int res=0;
	for(int i=1; i<=6; i++)
	{
		int tmp[8][8];
		memcpy(tmp, data, sizeof(tmp));
		if(tmp[0][0]!=i) dfs(tmp, 0, 0, i);
		res = max(res, func(tmp, t+1));
	}
	return res;
}

int main()
{
	while(cin>>H>>W>>C, H||W||C)
	{
		int data[8][8];
		for(int y=0; y<H; y++)
		for(int x=0; x<W; x++)
		{
			cin>>data[x][y];
		}

		cout << func(data, 0) << endl;		
	}
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 200001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pb push_back
#define db double
#define pu puts(" ")
using namespace std;
const int p=998244353;
int read()
{
	int x=0,f=1;
	char ch=gc;
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%p;a=(ll)a*a%p;
		
		b>>=1;
	}
	return ans%p;
}
ull n,ans=1;
int main()
{
    cin>>n;
    while(n>=ans)
    {
    	ans<<=1;
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 256
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll num = 0;
  ll tmp = 1;
  k = k - 1;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!='1'){
      num = i;
      tmp = s.at(i)-'0';
      break;
    }
  }
//  cout << num << endl;
//  cout << tmp << endl;
 	     if(k==0) 	cout<<s.at(0)<<endl;
    else if(k<num) 	cout<<s.at(0)<<endl;
    else			cout << tmp << endl;
}    

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(), Y = sc.nextInt();
		int y = (4 * X - Y) / 2;
		if (y < 0 || y > X || Y % 2 != 0)
			System.out.println("No");
		else {
			int x = X - y;
			if (4 * x + 2 * y == Y)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  int ans = 1;
  int p = 0;
  for (int i = 0; i < n; ++i) {
    p += l[i];
    if (p <= x) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring> 

using namespace std;

const int N = 2e5 + 10;

int n, T, p[N];
char s[N];
long long L, R, num[N][30];

long long fib(long long len, int c) {
    if (len <= n) return num[len][c];
    if (len <= n * 2) return num[n][c] + num[len - n][c];
    long long f1 = num[n][c], f2 = num[n][c] + num[T][c], l1 = n, l2 = n + T;
    while (len > l1 + l2) {
        long long t = f2;
        f2 += f1, f1 = t;
        t = l2, l2 += l1, l1 = t;
    }
    return f2 + fib(len - l2, c);
}

long long calc(long long len, int c) {
    if (len <= n) return num[len][c];
    if (n % T == 0) {
        long long re = 1ll * (len - n) / T * num[T][c] + num[n][c];
        len -= n, len %= T;
        return re + num[len][c];
    }
    else return fib(len, c);
}

int main() {
    scanf("%s%lld%lld",s+1,&L,&R);
    n=strlen(s+1)/2;p[1]=0;
    for(int j=0,i=2;i<=n;i++) {
        for(;j&&s[j+1]!=s[i];)j=p[j];
        if(s[j+1]==s[i])j++;
        p[i]=j;
    }
    for(int i=1;i<=n;i++) {
        for (int j=0;j<26;j++)num[i][j]=num[i-1][j];
        num[i][s[i]-'a']++;
    }T=n-p[n];
    for(int i=0;i<26;i++)
		printf("%lld%c",calc(R,i)-calc(L-1,i),i==25?10:32);
    return 0;
}


Measured memory_bytes: 27136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, d, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> n >> d >> x;
    vector<ll> list;
    while(cin >> a){
        list.push_back(a);
    }
    rep(i, list.size()){
        cnt = 1;
        while(cnt <= d){
            ans++;
            cnt += list[i];
        }
    }
    cout << ans + x << endl;
}



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

mod = pow(10, 9) + 7
l = []
for i in range(2001):
    if i < 3:
        l.append(0)
    elif 3 <= i <= 5:
        l.append(1)
    else:

        sum_ = 1
        for j in range(i-5):
            sum_ += l[i-(3+j)]
            sum_ = sum_ % mod
        l.append(sum_)

print(l[n])

Measured memory_bytes: 9236
#include <iostream>
#include <cmath>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;

int main() {
	int N, M, A[10000];
	cin >> N >> M;
	rep(i, M) cin >> A[i];
	int play = N;
	rep(i, M) {
		play -= A[i];
	}
	if (play < 0) {
		cout << -1 << endl;
	}
	else {
		cout << play << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b;
  cin>>a>>b;
  vector<bool>vec(a,false);
  vector<bool>veco(b,false);
  vector<vector<char>>vec1(a,vector<char>(b));
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>vec1.at(i).at(j);
      if(vec1.at(i).at(j)=='#'){
        vec.at(i)=true;
        veco.at(j)=true;
      }
    }
  }
  for(int i=0;i<a;i++){
    if(vec.at(i)){
      for(int j=0;j<b;j++){
        if(veco.at(j)){
          cout<<vec1.at(i).at(j);
        }
      }
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3604
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    MOD = 10 ** 9 + 7
    two_factor = 1
    ans = 0
    for i in range(60):
        bit_count = 0
        for a in A:
            if (a>>i) & 1:
                bit_count += 1
        ans += bit_count*(N-bit_count)*two_factor
        ans %= MOD
        two_factor *= 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 50816
/*
	Code written by Talant I.D.
*/
 
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define mt make_tuple
#define mod ll(1e9+7)
#define eps double(1e-9)
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353
 
inline bool isvowel(char ch){
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}
 
inline bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i == 0) return false;
	return true;
}

int main(){
	do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, i, cnt = 0;
	string s;
	cin >> n >> s;
	for(i = 0; i < s.size()-2; i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			cnt++;
		}
	}
	
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	H := make([]int, N)
	for i := 0; i < N; i++ {
		var k int
		fmt.Scan(&k)
		H[i] = k
	}

	m := make(map[int]int)
	for i := 0; i < len(H); i++ {
		m[i] = 1
	}
	
	for i := 0; i < M; i++ {
		var A, B int
		fmt.Scan(&A, &B)
		A = A - 1
		B = B - 1
		if H[A] > H[B] {
			m[B] = 0
		} else if H[B] > H[A] {
			m[A] = 0
		} else {
			m[B] = 0
			m[A] = 0
		}
	}
	total := 0
	//イテレーション1
	for _, v := range m {
		if v == 1 {
			total++
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 10228
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

char a[110][110];
int main()
{
    int n, m;
    cin >> n>> m;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i <= n+1; ++i)a[i][0] = a[i][m + 1] = '#';
    for(int i = 0; i <= m+1; ++i)a[0][i] = a[n + 1][i] = '#';
    for(int i = 0; i <= n+1; ++i){
        for(int j = 0; j <= m+1; ++j){
            cout << a[i][j];
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	int n,k;
	cin>>n>>k;
	bool dp[k+1];
	int a[n+1];
	rep(i,1,n+1)
	cin>>a[i];
	memset(dp,false,sizeof(dp));
	rep(i,1,k+1)
	{
		
		for(int j=1;j<=n;j++)
		{
			if(a[j]>i)
			break;
			
			if(!dp[i-a[j]])
			dp[i]=true;
			//else
			
		}
		
	}
	if(dp[k])
	cout<<"First";
	else
	cout<<"Second";
}



Measured memory_bytes: 384
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(H, W, K, C):
    ans = 0
    for ph in range(2 ** H):
        sh = format(ph, '0{0}b'.format(H))
        for pw in range(2 ** W):
            sw = format(pw, '0{0}b'.format(W))
            n = 0
            for i in range(H):
                if sh[i] == '1':
                    for j in range(W):
                        if sw[j] == '1':
                            n += (1 if C[i][j] == '#' else 0)
            if n == K:
                ans += 1
    return ans


(H, W, K) = tuple([int(s) for s in input().split()])
C = [list(input()) for _ in range(H)]
print(calc(H, W, K, C))


Measured memory_bytes: 68448
N,M,K=map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]

def root(x,P):
    l = []
    n = x
    p = P[n]
    while p >= 0:
        l.append(n)
        n = p
        p = P[p]
    for a in l: P[a] = n
    return n

def same(a, b, P): return root(a,P) == root(b,P)

def count(x,P): return -P[root(x,P)]

def unite(a, b, P):
    if count(a,P) < count(b,P): a, b = b, a
    ar = root(a,P)
    br = root(b,P)
    if ar == br: return
    P[ar] += P[br]
    P[br] = ar

Fu = [-1] * N
F = [set() for _ in range(N)]
B = [set() for _ in range(N)]

for a,b in AB:
    a, b = a-1, b-1
    unite(a,b,Fu)
    F[a].add(b)
    F[b].add(a)
for c,d in CD:
    c, d = c-1, d-1
    B[c].add(d)
    B[d].add(c)

for i in range(N):
    block = 0
    for b in B[i]:
        if same(i,b,Fu): block += 1
    print(count(i,Fu) - len(F[i]) - block - 1, end=' ')

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a <= 0 and b >= 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(a > 0){
        cout << "Positive" << endl;
        return 0;
    } 
    int len = (b - a + 1);
    if(len & 1){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }
    return 0;
}


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

using namespace std;

int main () {
  int a, b, c, d;

  cin >> a;

  b = a / 100 ;//100->1
  c = (a - b * 100) / 10 ;//10->1
  d = a - b * 100 - c * 10;

  cout << b + c + d << endl;
  /*cout << b << endl;
  cout << c << endl;
  cout << d << endl;*/
}

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;

  string sr = s;

  bool ok = false;
  do {
    if (sr == t) {
      ok = true;
      break;
    }
    rotate(sr.begin(), sr.begin()+1, sr.end());
  } while (s != sr);

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

#include <iomanip>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	double ans = 0;
	if (n >= k)
		ans = n-k+1;

	vector<int> cnt(33);
	for (int i = min(k-1, n); i > 0; --i) {
		int j = 1;
		while ((i << j) < k)
			++j;

		cnt[j]++;
		// ans += 1.0 / (1 << j);
	}

	for (int j = 1; j < cnt.size(); ++j)
		if (cnt[j]) {
			// printf("%d %d %lf\n", j, cnt[j], 1.0 * cnt[j] / (1 << j));
			ans += 1.0 * cnt[j] / (1 << j);
		}

	// cout << ans << endl;
	ans /= n;
	cout << setiosflags(ios::fixed) << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int main() {
	int c[3][3];

	for (int i = 0; i <= 2; i++) {
		for (int j = 0; j <= 2; j++) {
			cin >> c[i][j];
		}
	}

	bool A = true;
	

	for (int i = 0; i <= 1; i++) {
		int a[3];
		for (int j = 0; j <= 2; j++) {
			a[j] = c[i + 1][j] - c[i][j];
		}

		A = A && (a[0] == a[1] && a[1] == a[2]);
	}

	for (int i = 0; i <= 1; i++) {
		int a[3];
		for (int j = 0; j <= 2; j++) {
			a[j] = c[j][i + 1] - c[j][i];
		}

		A = A && (a[0] == a[1] && a[1] == a[2]);
	}

	if (A) cout << "Yes";
	else cout << "No";
}

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

typedef long long LL;

const int mod = 1e9 + 7;
const int inv2 = (mod + 1) >> 1;

template<int mod>
inline int qpow(int x, int y) {
	int ret = 1;
	for (; y; y >>= 1, x = (LL)x * x % mod)
		if (y & 1) ret = (LL)ret * x % mod;
	return ret;
}

int n, a[200005], b[200005], f[4005][4005], fac[8005], inv[8005];

inline int C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0;
	return (LL)fac[n] * inv[n - m] % mod * inv[m] % mod;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", a + i, b + i);
		++f[2001 - a[i]][2001 - b[i]];
	}
	for (int i = 1; i < 4002; ++i)
		for (int j = 1; j < 4002; ++j)
			(f[i][j] += (f[i - 1][j] + f[i][j - 1]) % mod) %= mod;
	fac[0] = 1;
	for (int i = 1; i <= 8002; ++i)
		fac[i] = (LL)fac[i - 1] * i % mod;
	inv[8002] = qpow<mod>(fac[8002], mod - 2);
	for (int i = 8001; i >= 0; --i)
		inv[i] = (LL)inv[i + 1] * (i + 1) % mod;
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		(ans += f[2001 + a[i]][2001 + b[i]]) %= mod;
	for (int i = 1; i <= n; ++i)
		(ans += mod - C((a[i] + b[i]) << 1, a[i] << 1)) %= mod;
	ans = (LL)ans * inv2 % mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 64512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	long long n,a,b;
	cin>>n>>a>>b;
	if (a > b){
		cout<<0<<endl;
		return 0;
	}
	if ((n == 1) && (a<b)){
		cout<<0<<endl;
		return 0;
	}
	cout<< a + (n-1)*b - ( b + (n-1)*a ) + 1<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int) 2e5 + 7;

struct tree
{
    int t[N];
    tree()
    {
        for (int i = 0; i < N; i++)
        {
            t[i] = 0;
        }
    }
    void upd(int i, int x)
    {
        while (i < N)
        {
            t[i] = max(t[i], x);
            i += i & (-i);
        }
    }
    int get(int i)
    {
        int sol = 0;
        while (i)
        {
            sol = max(sol, t[i]);
            i -= i & (-i);
        }
        return sol;
    }
};

tree a;
tree b;
int n;
int q;
ll cnt;

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

    cin >> n >> q;
    for (int i = 1; i <= q; i++)
    {
        int tp, x, lo = 1, hi = n, sol = 0;
        cin >> tp >> x;
        if (tp == 1)
        {
            while (lo <= hi)
            {
                int mid = (lo + hi) / 2;
                if (b.get(mid) < x)
                {
                    sol = mid;
                    lo = mid + 1;
                }
                else
                {
                    hi = mid - 1;
                }
            }
            cnt += min(n - 1, sol);
            a.upd(x, sol);
        }
        else
        {
            while (lo <= hi)
            {
                int mid = (lo + hi) / 2;
                if (a.get(mid) < x)
                {
                    sol = mid;
                    lo = mid + 1;
                }
                else
                {
                    hi = mid - 1;
                }
            }
            cnt += min(n - 1, sol);
            b.upd(x, sol);
        }
    }
    cnt += 2 * n - 1;
    ll white = cnt;
    ll green = 2 * n - 3 - q;
    ll black = (ll) n * n - white - green;
    cout << black << "\n";
}


Measured memory_bytes: 5216
s = list(input())
t = list(input())
ns = len(s)
nt = len(t)

flag = False
if ns < nt:
    print('UNRESTORABLE')
    exit()
for i in reversed(range(ns-nt+1)):
    for j in range(nt):
        if s[i:i+nt][j] != '?' and s[i:i+nt][j] != t[j]:
            break
    else:
        s[i:i+nt] = t
        flag = True
        break
if flag:
    ans = ''.join(s).replace('?', 'a')
    print(ans)
else:
    print('UNRESTORABLE')


Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
int x[6];
int main(){
    for(int i = 1;i <= 5;i++){
        cin >> x[i];
    }
    for(int i = 1;i <= 5;i++){
        if(x[i] == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const function<P(P, P)> minQ = [](P l, P r) { return min(l, r); };

template <typename T>
class LazySegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id1, id2;
	func_t merge;
	func_t change;
	vector<T> data, lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void propa(int node) {
		if (lazy[node] == id2) return;
		if (node < n) {
			lazy[node * 2] = change(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = change(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = change(data[node], lazy[node]);
		lazy[node] = id2;
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		propa(node);
		if (l <= lb && ub <= r) {
			lazy[node] = val;
			return;
		}
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = merge(change(data[node * 2], lazy[node * 2]), change(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id1;
		propa(node);
		if (l <= lb && ub <= r) {
			return data[node];
		}
		int c = (lb + ub) / 2;
		return merge(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_, T id1_, T id2_, func_t merge_, func_t change_)
		: n(size(n_)), id1(id1_), id2(id2_), merge(merge_), change(change_), data(n * 2, id1), lazy(n * 2, id2) {}
	void update(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T find(int l) {
		sub(l, l + 1, 1, 0, n);
		return data[l + n];
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int N, K, T;
	cin >> N >> K >> T;
	LazySegmentTree<P> lst(N, P(0, 0), P(-1, -1), minQ, [](P l, P r) {
		if (l == P(-1, -1)) return r;
		if (r == P(-1, -1)) return l;
		if (l == P(-2, -2) || r == P(-2, -2)) return P(-2, -2);
		return l.second == r.first ? P(l.first, r.second) : P(-2, -2);
	});
	for (int i = 0, l, r, x; i < T; i++) {
		cin >> l >> r >> x; l--; r--;
		lst.update(l, r, P(x - 1, x));
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (lst.find(i) == P(0, K)) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10972
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,A,B = inpl()

MAX = min(A,B)
MIN = max(0,A+B-N)
print(MAX,MIN)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;

signed main()
{
  int N, P;

  while(cin >> N >> P, N || P) {
    
    int w = P;
    int have[55] = {0};
    int i = 0;
    while(true) {
      if(w) have[i]++, w--;
      else w += have[i], have[i] = 0;
      if(have[i] == P) { cout << i << endl; break; }
      i++; if(i == N) i = 0;
    }

  }

  return 0;
}

Measured memory_bytes: 2968
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]
for l in range(n):
  c=0
  for j in range(m):
    c+=a[l][j]*b[j]
  print(c)


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////
ll n;


int main(){
	ll q,h,s,d;
	cin >> q >> h >> s >> d;//0.25 0.5 1 2

	cin >> n;

	if(q*2 < h)h = q*2;

	if(h*2 < s)s = h*2;

	if(s*2 < d)d = s*2;

	if(n%2 == 0)P(d * (n/2));
	else{
        P(d * (n/2) + s);
	}
	

	

	return  0;
}

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

int main() {

    while(1){

        int m,nmin,nmax;

        cin >> m >> nmin >> nmax;

        if(m == 0 && nmin == 0 && nmax == 0) break;

        int p[m];

        for(int i=0; i<m; i++){
            cin >> p[i];
        }

        sort(p,p+m,greater<int>());

        pair<int,int> ans = make_pair(0,0);

        for(int i=nmin; i<=nmax; i++) {
            if(ans.second <= p[i-1] - p[i]){
                ans = make_pair(i,p[i-1] - p[i]);
            }
        }

        cout << ans.first << endl;

    }

    return 0;
}

Measured memory_bytes: 3036
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = s()
L = []
for i in range(0,len(S),2):
    L.append(S[i])
print(''.join(L))

Measured memory_bytes: 10136
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)

	if a+w < b || a > b+w {
		fmt.Println(min(abs(b-a-w), abs(a-b-w)))
	} else {
		fmt.Println(0)
	}
}


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

int main(){
  int th,tw;
  int vals[1000000]={};
  int uv[1000]={};
  int db=0;
  for (int i=0;i<6;i++){
    cin >> th>>tw;
    if (th>tw)swap(th,tw);
    vals[(th-1)*1000+(tw-1)]++;
    uv[th]++;
    uv[tw]++;
    if (th==tw){
      if (db==0)db=th;
      else if (db!=th){
	cout << "no"<<endl;
	return 0;
      }
    }
  }
  for (int i=0;i<1000;i++){
    for (int j=0;j<1000;j++){
      if (vals[i*1000+j]%2){
	cout <<"no"<<endl;
	return 0;
      }
    }
    if (uv[i]%4){
      cout <<"no"<<endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 7016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define REP(i, a) for (int i = 0; i < (a); i++)
#define REPR(i, a) for (int i = (int)(a) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (int)(b) - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &a) { cout << a << ' '; }
void br() { putchar('\n'); }

int main() {
  int N = si();
  vector<int> A(N);
  REP(i, N) A[i] = si() - 1;
  for (int i = 0; i < N; i++) {
    if (A[i] > i) {
      cout << "-1" << '\n';
      return 0;
    }
  }
  vector<int> ans;
  REP(i, N) {
    REPR(j, A.size()) {
      if (A[j] == j) {
        ans.push_back(j);
        A.erase(A.begin() + j);
        break;
      }
    }
  }
  REPR(i, ans.size()) { pi(ans[i] + 1); br(); }
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,m,sum=0,tmp,i,j,ans=0;
    scanf("%d%d",&n,&m);
    int a[n];
    /*入力*/
    for(i=0;n>i;++i){
        scanf("%d",&a[i]);
    }
    /*総投票数*/
    for(i=0;n>i;++i){
        sum+=a[i];
    }
    /*降順ソート*/
    for (i=0; i<n; ++i) {
        for (j=i+1; j<n; ++j) {
            if (a[i] < a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  /*判定*/
  for(i=0;m>i;++i){
      if(a[i]>=(double)sum/(4*m))
      ++ans;
  }
  if(ans==m)
  printf("Yes");
  else
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
using namespace std;
int atl[2][2019];
//      pos kur beidzas un atl
int main()
{
    int ans=0;
    int p=1;
    string s;
    cin>>s;
    s="0"+s;
    for(int i=1; i<s.size(); i++){
        for(int j=0; j<2019; j++) atl[p][j]=0;
        atl[p][s[i]-'0']++;
        for(int j=0; j<2019; j++){
            int n=(j*10+s[i]-'0')%2019;
            atl[p][n]+=atl[!p][j];
        }
        ans+=atl[p][0];
        p=!p;
    }
    cout<<ans;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m,i,j,k,l,cnt,c1,c2,c3,mi;
	char a[50][51];
	cin>>n>>m;
	mi=n*m;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(i=0;i<n-2;i++){
		//cout<<'i'<<i<<'|';
		for(j=0;j<m;j++){
			if(a[i][j]!='W') c1=c1+1;
		}
		for(j=i+1;j<n-1;j++){
			//cout<<'j'<<j<<'|';
			for(k=0;k<m;k++){
				if(a[j][k]!='B') c2=c2+1;
			}
			for(k=j+1;k<n;k++){
				//cout<<'k'<<k<<'|';
				for(l=0;l<m;l++){
					if(a[k][l]!='R') c3=c3+1;
				}
			}
			cnt=c1+c2+c3;
			//cout<<"cnt"<<cnt<<'|';
			if(mi>cnt) mi=cnt;
			c3=0;
		}
		c2=0;
	}
	//cout<<'|'<<mi<<endl;
	cout<<mi<<endl;
	return 0;
}
	


Measured memory_bytes: 3092
//
//  main.cpp
//  programs
//
//  Created by Arunesh Sarker on 18/11/19.
//  Copyright © 2019 Arunesh Sarker. All rights reserved.
//

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
using namespace std;
vector<string> st;
typedef unsigned long long ll;
#define mod 1000000007
     
  // Function to return LCM of two numbers
int fact(int n)
{
    // single line to find factorial
    return (n==1 || n==0) ? 1: n * fact(n - 1);
}
 ll gcd(ll a, ll b)
 {
     if (a == 0)
         return b;
     return gcd(b % a, a);
 }
   
 // Function to find gcd of array of
 // numbers
 ll findGCD(ll arr[], ll n)
 {
     ll result = arr[0];
     for (ll i = 1; i < n; i++)
     {
         result = gcd(arr[i], result);
   
         if(result == 1)
         {
            return 1;
         }
     }
     return result;
 }
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0];
  
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (ll i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));
  
    return ans;
}
bool check(ll n)
{
    while(n>0)
    {
        ll t=n%10;
        if(t!=9)
            return false;
        n/=10;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a, a+n);
    ll sum=0;
    for(int i=k;i<n;i++)
        sum+=a[i];
    cout<<sum<<"\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
tmp = int(input())
d = tmp % 10
tmp //= 10
c = tmp % 10
tmp //= 10
b = tmp % 10
tmp //= 10
a = tmp


if a + b + c + d == 7:
    print('%d+%d+%d+%d=7' % (a, b, c, d))
elif a + b + c - d == 7:
    print('%d+%d+%d-%d=7' % (a, b, c, d))
elif a + b - c + d == 7:
    print('%d+%d-%d+%d=7' % (a, b, c, d))
elif a + b - c - d == 7:
    print('%d+%d-%d-%d=7' % (a, b, c, d))
elif a - b + c + d == 7:
    print('%d-%d+%d+%d=7' % (a, b, c, d))
elif a - b + c - d == 7:
    print('%d-%d+%d-%d=7' % (a, b, c, d))
elif a - b - c + d == 7:
    print('%d-%d-%d+%d=7' % (a, b, c, d))
elif a - b - c - d == 7:
    print('%d-%d-%d-%d=7' % (a, b, c, d))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)


int main() {
  int a,b;
  cin>>a>>b;
  cout<<6-a-b;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;cin >> s;
    if(s.size()&1){cout << "No";}
    else
    {
        string t;
        for (int i = 0; i < s.size()/2; ++i)
        {
            t+="hi";
        }
        if(s==t)cout << "Yes";else cout << "No";
    }
    }

Measured memory_bytes: 256
/* 有名なHello world プログラム */

#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>;

const int INF = 100100100;

int a[12][12];

int main(void)
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> c(N);
    rep(i, N) {
        cin >> c[i];
        rep(j, M) cin >> a[i][j];
    }

    int ans = INF;
    rep(s, 1<<N){
        int cost = 0;
        vector <int> d(M);
        rep(i,N){
            if(s>>i & 1){
                cost += c[i];
                rep(j,M) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep (j, M) if(d[j] < X) ok = false;
        if(ok) ans = min(ans, cost);
    }
    if ( ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY puts("Yes")
#define NN puts("No")
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll tmpa;
  if(a == 0) tmpa = 0;
  else tmpa = (a - 1) / x + 1;
  ll tmpb = b / x + 1;
  cout << tmpb - tmpa << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, M, X, t, k;
	int counta = 0, countb = 0;
	scanf("%d%d%d", &N, &M, &X);
	int A[M];
	for(t=0;t<M;t++)
	scanf("%d", &A[t]);
	for(t=1;t<X;t++)
	{
		for(k=0;k<M;k++)
		{
			if(t==A[k])
			counta++;
		}
	}
	for(t=X;t<N;t++)
	{
		for(k=0;k<M;k++)
		{
			if(t==A[k])
			countb++;
		}
	}
	if(counta>countb)
	printf("%d", countb);
	else
	printf("%d", counta);
	return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if a == b && b == c {
		fmt.Println("No")
	} else if a == b || b == c || c == a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   ll a;
   double b;
   cin>>a>>b;
   ll c=b*100+0.01;
   cout<<a*c/100;
   return 0;
}


Measured memory_bytes: 3704
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val nums = sc.nextLine.split(" ").map(_.toInt)

    val costA = Math.abs(nums.head - nums(1))
    val costB = Math.abs(nums.head - nums.last)
    val costC = Math.abs(nums(1) - nums.last)
    println(Array(costA, costB, costC).sorted.slice(0, 2).sum)
  }

}


Measured memory_bytes: 25644
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}

int main()
{

 int a,b;
 cin>>a>>b;
 int p=a-2*b;
 cout<<max(p,0);



}


Measured memory_bytes: 256