akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int X;
  cin >> X;
  if (X<600) {
    cout << 8 << endl;
  }
  else {
    if (X<800) {
      cout << 7 << endl;
    }
    else {
      if (X<1000) {
        cout << 6 << endl;
      }
      else {
        if (X<1200) {
          cout << 5 << endl;
        }
        else {
          if (X<1400) {
            cout << 4 << endl;
          }
          else {
            if (X<1600) {
              cout << 3 << endl;
            }
            else {
              if (X<1800) {
                cout << 2 << endl;
              }
              else {
                cout << 1 << endl;
              }
            }
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {

	string s;
	cin >> s;
	string s1 = s.substr(0, 1);
	string s2 = s.substr(1, 1);
	string s3 = s.substr(2, 1);

	int sum = 700;
	if (s1 == "o") {
		sum += 100;
	}
	if (s2 == "o") {
		sum += 100;
	}
	if (s3 == "o") {
		sum += 100;
	}


	cout << sum;
	return 0;
}

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

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int>X(n), Y(m);
	for (int i = 0; i < n; i++)cin >> X[i];
	for (int i = 0; i < m; i++)cin >> Y[i];
	int xmax = x, ymin = y;
	for (int i = 0; i < n; i++) {
		xmax = max(xmax, X[i]);
	}
	for (int i = 0; i < m; i++) {
		ymin = min(ymin, Y[i]);
	}
	for (int i = -200; i < 200; i++) {
		if (xmax < i && ymin >= i) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}

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

int main() {
  string str;
  cin >> str;
  
  long S = 0;
  string k;
  int n;
  for (long i = 0; i < str.size(); i++) {
    k = str.at(i);
    n = atoi(k.c_str());
    S += n;
  }
  
  if (S % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#define int long long 
using namespace std;

int fib(int n);
signed main()
{
    int n, a;
    cin >> n >> a;
    vector<int> x(n + 5);
    int max = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
        if(x[i]>max){
            max = x[i];
        }
        x[i] -= a;
    }
    int ans = 0;
    vector<vector<int>> dp(n + 5, vector<int>(2 * n * max + 5));

    int t = 1;
    for (int i = 1; i <= n;i++){
        for (int j = 1; j < t; j++)
        {
            dp[i][j] = 0;
        }
    }
    dp[0][n * max] = 1;
    int flag = 0;
    //max = a;
    for (int i = 0; i <= n; i++)
    {
        for (int t = 0; t < 2 * n * max; t++){

            if (i >= 1 && t - x[i] >= 0 && t - x[i] <= 2 * n * max)
            {
                dp[i][t] = dp[i - 1][t] + dp[i - 1][t - x[i]];
            }
            else if ((i >= 1 && t - x[i] < 0) || (t - x[i] > 2 * n * max))
            {
                dp[i][t] = dp[i - 1][t];
                flag = 1;
            }
        }
    }
    cout << dp[n][n*max] - 1 << endl;
    //cout << flag << endl;
    return 0;
}


Measured memory_bytes: 2432
func sumDigits(_ num: Int) -> Int {
    var num = num
    var sum = 0
    while num > 0 {
        sum += num%10
        num /= 10
    }
    return sum
}


let rd = readLine()!.split(separator: " ").map({Int($0)!})
let N = rd[0]
var sum = 0

for i in 1 ... N {
    if rd[1] <= sumDigits(i) && sumDigits(i) <= rd[2] {
        sum += i
    }
}
print(sum)

Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main(){
   char aux;
   cin >> aux;
    if (isupper(aux))cout<<'A'<<endl;
    else cout << "a" << endl;
  }



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		while (n/2) {
			if (n % 2) break;
			cnt++;
			n /= 2;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3544
#!/usr/bin/env python3
import sys

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())

    for c in s:
        if c=='1':
            k -= 1
            if k==0:
                print(c)
                break
            else:
                continue
        else:
            print(c)
            break


if __name__=='__main__':
    main()

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

int main()
{
  string S;
  cin >> S;
  if (S == "zyxwvutsrqponmlkjihgfedcba")
  {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> A(26, false);
  int N = S.size();
  for (int i = 0; i < N; i++)
  {
    int a = S.at(i) - 'a';
    A.at(a) = true;
  }
  if (N < 26)
  {
    cout << S;
    for (int i = 0; i < 26; i++)
    {
      if (!A.at(i))
      {
        cout << (char)('a' + i) << endl;
        break;
      }
    }
  }
  else
  {
    priority_queue<int> pq;
    for (int i = N - 1; i >= 0; i--)
    {
      int d = S.at(i) - 'a';
      pq.push(d);
      if ((int)(S.at(i) - 'a') >= pq.top())
      {
        continue;
      }
      for (int j = 0; j < i; j++)
      {
        cout << S.at(j);
      }
      char c;
      while ((int)(S.at(i) - 'a') < pq.top())
      {
        c = (char)('a' + pq.top());
        pq.pop();
      }
      cout << c << endl;
      break;
    }
  }
}

Measured memory_bytes: 3620
n,m=map(int,input().split())
p=[0]*m
temp=['a']*m
s=["qw"]*m
judge=[0]*n
wa=[0]*n
  
for i in range(0,m):
  temp[i],s[i]=input().split()
  p[i]=int(temp[i])
  
ac=0
wasum=0
for i in range(0,m):
  if s[i][0]=='W' and s[i][1]=='A':
    wa[p[i]-1]+=1
  elif s[i][0]=='A' and s[i][1]=='C' and judge[p[i]-1]==0:
    ac+=1
    judge[p[i]-1]=1
    wasum+=wa[p[i]-1]
print("%d %d"% (ac,wasum))

Measured memory_bytes: 21236
# D
from collections import deque
N, M = map(int, input().split())

value_list = [0]*N
done_list = [-1]*N
# -1:any, 0:not_done, 1:done

res = 'Yes'

G = dict()
for i in range(N):
    G[i] = dict()
    
# input
for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1][R-1] = D
    G[R-1][L-1] = -D
    done_list[L-1] = 0
    done_list[R-1] = 0

# pick one node not resolved
pick = 0

while pick < N and res == 'Yes':
    
    queue = deque([pick])
    done_list[pick] = 1
    value_list[pick] = 0
    
    # BFS
    while len(queue) > 0:
        L = queue.popleft()
        for R in G[L].keys():
            if done_list[R] == 0:
                done_list[R] = 1
                value_list[R] = value_list[L] + G[L][R]
                queue.append(R)
            else:
                if value_list[R] != value_list[L] + G[L][R]:
                    res = 'No'

    # next seed
    while pick < N:
        if done_list[pick] == 0:
            break
        pick += 1
print(res)

Measured memory_bytes: 77080
n, h = gets.strip.split.map(&:to_i)
a = readlines.map {|line| line.strip.split.map(&:to_i) }.sort

all_a = a.map(&:first).sort
all_b = a.map(&:last).sort

usual = all_a.last

result = 0

all_b.select {|e| e>=usual }.sort.reverse.each do |thr|
  h -= thr
  result += 1

  if h<=0
    p result
    exit
  end
end

result += 1 if h%usual > 0

result += (h/usual)

p result


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

//var 
int a,b,c,k, ans = 0;

int main(){
	cin >> a >> b >> c >> k;
	if(a>=k){
		cout << k << endl;
		return 0;
	}
	ans += a; k -= a;
	if(b>=k){
		cout << ans << endl;
		return 0;
	} k -= b;

	ans -= k;
	cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    
    public static void easymod(int a, int b){
        if ((a*b)%2 == 0){
            System.out.println("Even");
        } else {
             System.out.println("Odd");
        }
    }
    public static void main(String[] args) {
        /* Enter your code here. Print output to STDOUT. Your class should be named Solution. */
         Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        easymod(a,b);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main() {
    int h=0,m=0,s=0,x=0;
    scanf("%d",&x);
    h=(x/60/60);
    m=((x/60)%60);
    s=(x%60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1852
// SeeAlso: https://atcoder.jp/contests/abc124/tasks/abc124_b

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <limits>

#define MAX 4

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

using namespace std;

int main() {
    int N;
    int H[100];

    cin >> N;

    REP(i, N) {
        cin >> H[i];
    }

    int ans = 0;
    int height = 0;

    REP(i, N) {
        if (height <= H[i]) {
            ans++;
        }

        CHMAX(height, H[i]);
    }

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


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	string S;
	cin >> S;

	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (i % 2 == 0) {
			if (S[i] == '0') {
				tmp++;
			}
		}
		else {
			if (S[i] == '1') {
				tmp++;
			}
		}
	}
	ans = tmp;
	tmp = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (i % 2 == 0) {
			if (S[i] == '1') {
				tmp++;
			}
		}
		else {
			if (S[i] == '0') {
				tmp++;
			}
		}
	}
	ans = min(ans, tmp);

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


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

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(B > C) swap(B, C);
  if(A > C) swap(A, C);
  if(A == 5 && B == 5 && C == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI 3.1415926

int main(void)
{
	double a, b, C;
	scanf("%lf %lf %lf", &a, &b, &C);

	C = C / 180 * PI;

	printf("%lf\n%lf\n%lf\n", (a * (b * sin(C))) / 2 , a + b + sqrt(a * a + b * b - 2 * a * b * cos(C)), b * sin(C));

	return 0;
}


Measured memory_bytes: 2028
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  lli a, b ,c;
  scanf("%lld %lld %lld", &a, &b, &c);

  if (a + b + 2.0 * sqrtl(a * b) < c) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
use std::io::*;

fn main() {
	let mut input = String::new();
	stdin().read_line(&mut input);
	input.pop();

	let n: u32 = input.parse().unwrap();

	input.clear();
	stdin().read_line(&mut input);
	input.pop();

	let mut t = 0u32;
	let mut max = 0;
	for s in input.split(' ').skip(1) {
		let b = s.parse::<u32>().unwrap();
		t |= 1 << b;
		if max < b {
			max = b;
		}
	}

	let out = stdout();
	let mut out = BufWriter::new(out.lock());
	if t == 0 {
		writeln!(out, "0:");
	}

	for p in max..n {
		for d in (1 << p)..(2 << p) {
			if d & t == t {
				write!(out, "{}:", d);

				for e in 0..p + 1 {
					if d & 1 << e != 0 {
						write!(out, " {}", e);
					}
				}
				writeln!(out);
			}
		}
	}
}



Measured memory_bytes: 5024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = 0; i < m; i++)
#define allprintu(i,n,m,a) for(int i = n; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
	
int main(void){
	int n,q;
	int mid,left,right;
	int s[100000],t[50000];
	int same = 0;

	scani(n);
	repu(i,0,n){
		scani(s[i]);
	}
	scani(q);
	repu(i,0,n){
		scani(t[i]);
	}
	repu(i,0,q){
		left = 0;
		right = n;
		while(left < right){
			mid = (left+right)/2;
			if(s[mid] == t[i]){
				same++;
				break;
			}else if(t[i] < s[mid]){
				right = mid;
			}else{
				left = mid + 1;
			}
		}
	}
	printin(same);
	return 0;
}


Measured memory_bytes: 2280
use std::io::stdin;

fn read_line() -> Vec<i64> {
    let mut a_str = String::new();
    stdin().read_line(&mut a_str).expect("read error");
    a_str.split_whitespace()
        .map(|x| x.parse::<i64>().expect("parse error"))
        .collect::<Vec<i64>>()
}

fn main() {
    let mut h = read_line()[0];
    let mut c = 0;
    while h > 0 {
        h /= 2;
        c += 1;
    }

    let x: i64 = 2;
    println!("{}", x.pow(c) - 1);
}

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

long long MOD = 1000000007;

int main(void) {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N), B(M);
  set<int> sa, sb;
  int a_min = 1e9, b_min = 1e9;
  // 最小値及び集合で管理
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    a_min = min(a_min, A[i]);
    sa.insert(A[i]);
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
    b_min = min(b_min, B[i]);
    sb.insert(B[i]);
  }
  int ab_min = min(a_min, b_min);

  const int nm = N * M;
  long long ret = 1;
  long long r = 0, c = 0;
  for (int i = nm; i >= 1; i--) {
    bool isa = (sa.find(i) != sa.end());
    bool isb = (sb.find(i) != sb.end());

    // cerr << i << " : " << ret << endl;
    // 両方になし
    if ((!isa) && (!isb)) {
      // まだそれより小さい行列が出てくる
      if (i > ab_min) {
        if ((r * c - (nm - i)) <= 0) {
          cout << 0 << endl;
          return 0;
        }
        ret *= (r * c - (nm - i));
        ret %= MOD;
      }
      // 終わり
      else {
        if ((r * c - (nm - i)) <= 0) {
          cout << 0 << endl;
          return 0;
        }
        ret *= r * c - (nm - i);
        ret %= MOD;
      }
    }
    // 両方にあり
    else if (isa && isb) {
      // 変化なし ret *= 1;
      r++;
      c++;
    }
    // Aのみにあり
    else if (isa) {
      // c通りある
      ret *= c;
      ret %= MOD;
      r++;
    }
    // Bのみにあり
    else if (isb) {
      // r通りある
      ret *= r;
      ret %= MOD;
      c++;
    }
  }
  if (ret < 0) cout << 0 << endl;
  else cout << ret << endl;
  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	int TC;
	cin >> TC;
	while (TC--) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B || D < B) {
			puts("No");
		} else if (C >= B) {
			puts("Yes");
		} else {
			A %= B;
			ll d = __gcd(B, D);
			ll m = (B - A) % d;
			if (m == 0) m = d;
			ll t = (B - m) % B;
			
			if (t > C) {
				puts("No");
			} else {
				puts("Yes");
			}
		}
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		int n = getInt(st);
		int[] a = new int[n];
		int[] b = getIntArry(st);
		int ans = 0;
		for(int i=0;i<n-1;i++) {
			a[i] = b[i];
			a[i+1] = b[i];
		}
		ans+=a[0];
		for(int i=0;i<n-1;i++) {
			if(a[i+1] > b[i]) {
				a[i+1] = b[i];
			}
			ans+=a[i+1];
		}
		anser(ans);
	}

	private static int getInt(BufferedReader st) throws Exception, IOException {
		int num = Integer.parseInt(st.readLine());
		return num;
	}

	private static int[] getIntArry(BufferedReader st) throws Exception, IOException {
		String line = st.readLine();
		String[] strData = line.split(" ");
		int[] intData = new int[strData.length];
		for (int i = 0; i < strData.length; i++) {
			intData[i] = Integer.parseInt(strData[i]);
		}
		return intData;
	}

	private static void anser(int num) {
		System.out.println(num);
	}
}

Measured memory_bytes: 23636
import math
  
def main():
  k=int(input())
  cur=0
  for a in range(1,k+1):
    for b in range(1,k+1):
      for c in range(1,k+1):
        cur+=math.gcd(math.gcd(a,b),c)
        
  return cur
print(main())


Measured memory_bytes: 9084
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int z=0;
  rep(i,k-1) if(a[i+1]==0) ++z;
  rep(l,n-k){
    int r = l+k;
    if(z==0&&a[l]<a[r]) cout << "Yes" << endl;
    else cout << "No" << endl;
    if(a[r]==0) ++z;
    if(a[l+1]==0) --z;
  }
}


Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;

int main(){
    ll a, v, b, w, t;
    int f = 0;
    cin>>a>>v>>b>>w>>t;
    
    if(abs(a-b) <= (v-w)*t){
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}


Measured memory_bytes: 3612
N = int(input())
A = list(map(int, input().split()))
abs_A = [abs(i) for i in A]
neg_A = [i for i in A if i < 0]

if len(neg_A) % 2 == 0:
	ans = sum(abs_A)
else:
	min = min(abs_A)
	ans = sum(abs_A) - 2 * min

print(ans)

Measured memory_bytes: 14412
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    bool flag=false;
    int money;
    scanf("%d",&money);
    for(int i=0;i<=25;++i)
    {
        for(int j=0;j<=16;++j)
        {
            if(4*i+7*j==money)
            {
                flag=true;
            }
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int counter;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		counter = 0;
		while (n != 1) {
			if (n % 2 == 0) {
				n /= 2;
			} else {
				n = n * 3 + 1;
			}
			counter++;
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll N,count = 0;
    cin >> N;
    ll a[N];
    bool same = false;
    cin >> a[0];
    for(int i = 1; i < N; i++){
        cin >> a[i];
        if(a[i] == a[i-1])
            if(!same){
                count++;
                same = true;
            }
            else same = false;
        else same = false;
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n')[0].split(' ')
	let cnt = 1
	if (args[1] !== args[0]) cnt++
	if (args[2] !== args[1] && args[2] !== args[0]) cnt++
	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

bool func() {
    int M, T, P, R;
    typedef struct{
        int m;
        int t;
        int p;
        int j;
    } Data;
    vector<Data> datas;

    typedef struct {
        int id;
        int solve;
        int time;
        vector<int> pena; 
    } Team;
    vector<Team> teams;

    cin >> M >> T >> P >> R;
    if(M==0 && T==0 && P==0 && R==0) return true;

    for(int i=0; i<T; i++) {
        vector<int> tmpvec(P, 0);
        Team t = {i+1, 0, 0, tmpvec};
        teams.push_back(t);
    }

    for(int i=0; i<R; i++) {
        int m, t, p, j;
        cin >> m >> t >> p >> j;
        Team team = teams[t-1];
        if(j==0) {
            team.solve += 1;
            team.time += team.pena[p-1] * 20 + m;
        } else {
            team.pena[p-1] += 1;
        }
        teams[t-1] = team;
    }
    sort(teams.begin(), teams.end(), [](const Team& a, const Team& b){
        if(a.solve == b.solve && a.time == b.time) return a.id > b.id;
        else if(a.solve == b.solve) return a.time < b.time;
        else return a.solve > b.solve;
    }); 

    vector<int> tmpvec;
    Team pre = {-1, -1, -1, tmpvec};
    char delimiter = ',';
    for(Team t: teams) {
        if(pre.solve!=-1) {
            if(pre.solve==t.solve && pre.time==t.time) delimiter = '=';
            else delimiter = ',';
            printf("%c", delimiter);
        }
        pre = t;
        printf("%d", t.id);
    }
    printf("\n");
    return false;
}

int main() {
    bool flag = false;
    while(!flag) {
        flag = func();
    }
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int dfs(Graph &G,vector<int> &visit, int n) {
	stack<int> s;
	s.push(n);
	int dist = 1;
	while(!s.empty()) {
		int u = s.top(); s.pop();
		visit[u] = 1;
		for(auto p: G[u]) {
			if(visit[p] == -1) {
				s.push(p);
				visit[p] = 1;
				dist++;
			}
		}
	}
	return dist;
}

int main() {
	int N, M; cin >> N >> M;
	Graph G(N);
	for(int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> visit(N, -1);
	int ans = 0;
	for(int i = 0; i < N; i++) {
		int len = dfs(G, visit, i);
		ans = max(ans, len);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15504
#include <bits/stdc++.h>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18

using namespace std;
int main(){
	int n,m; cin>>n;
	vector<string> s, t;
	s.resize(n);
	for(int i=0; i<n; i++) cin >> s[i];
	cin>>m;  t.resize(m);
	for(int i=0; i<m; i++) cin >> t[i];
	
	map<string, int> mp;
	std::map<string,int>::iterator itr;
	for(int i=0; i<n; i++){
		itr=mp.find(s[i]);
		if(itr!=mp.end()){
			mp[s[i]]+=1;
		}
		else{
			mp[s[i]]=1;
		}
	}
	for(int i=0; i<m; i++){
		itr=mp.find(t[i]);
		if(itr!=mp.end()){
			mp[t[i]]-=1;
		}
	}
	int ans=0;
	for(int i=0; i<n; i++){
		ans=max(ans,mp[s[i]]);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	rems := []int{}
	for {
		N--
		if N < 26 {
			rems = append(rems, N)
			break
		}
		v := N % 26
		N = (N - v) / 26
		rems = append(rems, v)
	}
	table := map[int]string{
		0:  "a",
		1:  "b",
		2:  "c",
		3:  "d",
		4:  "e",
		5:  "f",
		6:  "g",
		7:  "h",
		8:  "i",
		9:  "j",
		10: "k",
		11: "l",
		12: "m",
		13: "n",
		14: "o",
		15: "p",
		16: "q",
		17: "r",
		18: "s",
		19: "t",
		20: "u",
		21: "v",
		22: "w",
		23: "x",
		24: "y",
		25: "z",
	}
	out := ""
	for i := 0; i < len(rems); i++ {
		out += table[rems[len(rems)-i-1]]
	}
	io.PrintLn(out)
}


Measured memory_bytes: 1784
n = int(input())
s = input()

l_lack=0
l_cnt=0

for tmp in s:
    if tmp==")":
        if l_cnt==0:
            l_lack+=1
        else:
            l_cnt-=1
    if tmp=="(":
        l_cnt+=1

left="("*l_lack
right=")"*l_cnt
print(left+s+right)

Measured memory_bytes: 3060
/*
g++ -std=c++14 -o2 -Wall ABC122C.cpp -o .\out\ABC122C.out
.\out\ABC122C.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int a[100005];
int l[100005];
int r[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int n, q;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; ++i) {
    cin >> l[i] >> r[i];
  }
  for (int i = 0;i < n; ++i) {
    if (i == 0) a[1] = 0;
    else {
      if (s[i - 1] == 'A' && s[i] == 'C') {
        a[i + 1] = a[i] + 1;
      } else {
        a[i + 1] = a[i];
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    cout << (a[r[i]] - a[l[i]]) << "\n";
  }
  return 0;
}


Measured memory_bytes: 2256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s,t,temp;cin>>s>>t;
  string ans;
  bool flg=true;
  rep(i,s.size()-t.size()+1){
    ans=s;
    flg=true;
    rep(j,t.size()){
      temp=s.substr(s.size()-i-t.size(),t.size());
      if(temp[j]=='?'||temp[j]==t[j]){
        ans[s.size()-i-t.size()+j]=t[j];
      }else{
        flg=false;
      }
    }
    if(flg){
      rep(i,ans.size()){
        if(ans[i]=='?'){
          cout<<"a";
        }else{
          cout<<ans[i];
        }
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const int M = 1e7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

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

  int a = 0,b = 0,c = 0;
  rep(i,s.size()){
    if (s[i] == 'a') a++;
    if (s[i] == 'b') b++;
    if (s[i] == 'c') c++;
  }

  if (abs(a-b) <= 1 && abs(b-c) <= 1 && abs(c-a) <= 1){
    cout << "YES" << endl;
  } else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve(ll N, vl X);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N;
    cin >> N;
    vl X(N);
    for(int i = 0; i < N; ++i){
        cin >> X[i];
    }
    solve(N, move(X));
}

void solve(ll N, vl X){
    vl Y=X;
    sort(all(Y));

    rep(i,N){
        if(X[i]<Y[N/2])cout<<Y[N/2]<<endl;
        else cout<<Y[N/2-1]<<endl;
    }
}



Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

bool isPrime(ll n){
    if(n == 2)return true;
    if(n == 1 || n == 0)return false;
    ll sq = sqrt(n) + 1;
    ll tmp = n; 
    for(int i = 2; i <= sq; i++){
        sq = sqrt(tmp) + 1;
        while(tmp%i == 0)tmp/=i;
    }
    if(tmp == n)return  true;
    return false;
}
int main(){
    ll q;
    cin >> q;
    vector<ll> l(q);
    vector<ll> r(q);
    rep(i, q)cin >> l[i] >> r[i];
    ll left[100010];
    left[0] = left[1] = 0;
    for(ll i = 2; i < 100010; ++i){
        left[i] = left[i-1];
        if(isPrime(i) && isPrime((i+1)/2))left[i]++;
    }
    rep(i, q)cout << left[r[i]]  -  left[l[i]-1] << endl;
}

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

int main() {

  int r, c;
  cin >> r >> c;
  
  vector<vector<int>> X(r, vector<int>(c)); 
  
  for (int i = 0; i < r; i++) {
    int rsum = 0;
    for (int j = 0; j < c; j++) {
		cin >> X.at(i).at(j);
      	cout << X.at(i).at(j) << ' ';
      	rsum += X.at(i).at(j);
    }
    cout << rsum << endl;
  }
  
  int sum = 0;
  for (int j = 0; j < c; j++) {
	int csum = 0;
    for (int i = 0; i < r; i++) {
		csum += X.at(i).at(j);
    }
    cout << csum << ' ';
    sum += csum;
  }
  cout << sum << endl;
    
  
  return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y[ohara],sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
bool red[ohara];
ll ballnum[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
    red[0]=true;
    rep(i,n)ballnum[i]=1;
    rep(i,m){
        if(red[x[i]]){
            red[y[i]]=true;
        }
        ballnum[x[i]]--;
        if(ballnum[x[i]]==0)red[x[i]]=false;
        ballnum[y[i]]++;
    }
    rep(i,n){
        if(red[i])ans++;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 7168
#include "bits/stdc++.h"
using namespace std;

const int INF = 1 << 29;        // 十分大きい値にする

string S, T;

// DP テーブル
int dp[3010][3010];

int main() {
	cin >> S >> T;

	memset(dp, 0, sizeof(dp));    // 初期化
	for (int i = 0; i < S.size(); ++i) {
		for (int j = 0; j < T.size(); ++j) {
			if (S[i] == T[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
		}
	}

	string res = "";
	int i=(int)S.size(), j=(int)T.size();
	while (i > 0 && j > 0) {
		if(dp[i][j] == dp[i-1][j]) i--;
		else if(dp[i][j] == dp[i][j-1]) j--;
		else {
			res = S[i-1] + res;
			i--; j--;
		}
	}

	cout << res << endl;
}

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

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

	int N, L; cin >> N >> L;
	int m = 100000;
	int sum = 0;
	int ans;
	for (int i = 1; i <= N; i++) {
		int t = L + i - 1;
		if (m > abs(t)) {
			ans = t;
			m = abs(t);
		}
		sum += t;
	}
	cout << sum - ans;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using vec = vector<int>;


int main() {
    
    int a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    int x=a*60+b,y=c*60+d;
    int ans=y-x-k;
cout<<ans<<endl;

}

Measured memory_bytes: 3620
N = gets.to_i

def go(n, acc = "")
  return acc if n == 0
  b = (-2)**acc.length
  if n % ((-2) * b) == 0
    go(n, '0' + acc)
  else
    go(n - b, '1' + acc)
  end
end

puts N.zero? ? 0 : go(N)

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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define mp make_pair
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;

const double pi = acos(-1.0);

struct pt {
	ll x, y;
	int id;
	pt() {}
	pt(ll X, ll Y)
	{
		x = X;
		y  = Y;
	}
	
	inline double scalar(pt b)
	{
		return x * b.x + y * b.y;
	}
	inline double len()
	{
		return sqrt(x * x + y * y);
	}
};
pt a[N];
double ans[N];

bool cmp (pt a, pt b) {
	return a.x < b.x || a.x == b.x && a.y < b.y;
}

bool cw (pt a, pt b, pt c) {
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) < 0;
}

bool ccw (pt a, pt b, pt c) {
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) > 0;
}

void convex_hull (vector<pt> & a) {
	if (a.size() == 1)  return;
	sort (a.begin(), a.end(), &cmp);
	pt p1 = a[0],  p2 = a.back();
	vector<pt> up, down;
	up.push_back (p1);
	down.push_back (p1);
	for (size_t i=1; i<a.size(); ++i) {
		if (i==a.size()-1 || cw (p1, a[i], p2)) {
			while (up.size()>=2 && !cw (up[up.size()-2], up[up.size()-1], a[i]))
				up.pop_back();
			up.push_back (a[i]);
		}
		if (i==a.size()-1 || ccw (p1, a[i], p2)) {
			while (down.size()>=2 && !ccw (down[down.size()-2], down[down.size()-1], a[i]))
				down.pop_back();
			down.push_back (a[i]);
		}
	}
	a.clear();
	for (size_t i=0; i<up.size(); ++i)
		a.push_back (up[i]);
	for (size_t i=down.size()-2; i>0; --i)
		a.push_back (down[i]);
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

int n;
	cin >> n;
	vector<pt> a(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i].x >> a[i].y;
		a[i].id = i;
	}
	cout.precision(15);
	if(n == 2)
	{
		cout << fixed << 0.5 << '\n' << 0.5 << '\n';
		return 0;
	}
	convex_hull(a);
	if(a.size() == 2)
	{
		ans[a[0].id] = 0.5;
		ans[a[1].id] = 0.5;
		for(int i = 0; i < n; ++i)
			cout << fixed << ans[i] << '\n';
		return 0;
	}
	for(int i = 0; i < a.size(); ++i)
	{
		int pre = (i - 1 + a.size()) % a.size();
		int nxt = (i + 1) % a.size();
		pt fi = pt(a[pre].x - a[i].x, a[pre].y - a[i].y);
		pt se = pt(a[nxt].x - a[i].x, a[nxt].y - a[i].y);
		double res = fi.scalar(se);
		double alpha = acos(res / (fi.len() * se.len()));
		ans[a[i].id] = (pi-alpha)/pi / 2;
	}
	for(int i=0;i<n;++i)
		cout << fixed << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 256
#168 - F
import sys
import numpy as np
from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


@njit
def cal_area(A, B, C, D, E, F, X, Y):
    LenX = len(X)
    LenY = len(Y)

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    for x1, x2, y in zip(A, B, C):
        for x in range(x1, x2):
            LineY[x][y] = True

    for x, y1, y2 in zip(D, E, F):
        for y in range(y1, y2):
            LineX[x][y] = True
    
    visit = [[False] * LenY for _ in range(LenX)]
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    while queue:
        x, y = queue.pop()

        if x == 0 or x == LenX - 1 or y == 0 or y == LenY - 1:
            area = 0
            break
        
        area += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y])

        if not LineX[x][y] and not visit[x - 1][y]:
            visit[x - 1][y] = True
            queue.append((x - 1, y))
        if not LineY[x][y] and not visit[x][y - 1]:
            visit[x][y - 1] = True
            queue.append((x, y - 1))
        if not LineX[x + 1][y] and not visit[x + 1][y]:
            visit[x + 1][y] = True
            queue.append((x + 1, y))
        if not LineY[x][y + 1] and not visit[x][y + 1]:
            visit[x][y + 1] = True
            queue.append((x, y + 1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


Measured memory_bytes: 129800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long LL;
#define rep(i ,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define arycpy(ary1,ary2,N) memcpy(ary2,ary1,sizeof(int)*N) //ary1:???????????? ary2:????????????
typedef vector<int> vi;

int main(){
	double h;
	int sum[6] = {};	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> h;
		if (h < 165) sum[0]++;
		else if (h < 170) sum[1]++;
		else if (h < 175) sum[2]++;
		else if (h < 180) sum[3]++;
		else if (h < 185) sum[4]++;
		else sum[5]++;
	}

	for (int i = 0; i < 6; i++){
		cout << i + 1 << ":";
		for (int j = 0; j < sum[i]; j++){
			cout << "*";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

LL reflect(LL A, LL B){
    if(A > B) swap(A,B);

    if(B % A == 0){
        return A * (2 * (B / A) - 1);
    }
    else{
        return A * (2 * (B / A)) + reflect(A,B%A);
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,X; cin >> N >> X;
    cout << N + reflect(X,N-X) << endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    
	    String S = nextString();
	    
	    if(S.equals("AAA") || S.equals("BBB")) {
	        out.println("No");
	    }else{
	        out.println("Yes");	        
	    }
	    
	    
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21204
N, M = [int(_) for _ in input().split()]
xyz = []
for _ in range(N):
    xyz.append([int(_) for _ in input().split()])

ans = -1
for i in range(8):
    sx = -(i >> 2 & 1) or 1
    sy = -(i >> 1 & 1) or 1
    sz = -(i >> 0 & 1) or 1
    xyz.sort(key=lambda v: sx * v[0] + sy * v[1] + sz * v[2], reverse=True)
    x, y, z = 0, 0, 0
    for a in xyz[:M]:
        x += a[0]
        y += a[1]
        z += a[2]
    ans = max(ans, abs(x) + abs(y) + abs(z))
print(ans)


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+111;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>l>>r>>k;
        ll ans=0;
        for(i=l;i<=r;i++){
                if(i%k==0)ans++;
        }
        cout<<ans;
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N+1);
  vector<int> C(N);
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }
  for(int i=1; i<=N; i++){
    cin >> B[i];
  }
  for(int i=1; i<=N-1; i++){
    cin >> C[i];
  }
  
  int ans=0;
  for(int i=1; i<=N; i++){
    ans+=B[A[i]];
  }
  for(int i=1; i<=N-1; i++){
      if (A[i+1]-A[i]==1) ans+=C[A[i]];
  }
  cout << ans<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define forn(i,n) for(int i = 0; i< n;++i)
ll MOD = 1e9 + 7;
ll dp(int mask,int women_num,vector<vector<int>>& comp,int target,int n,vector<vector<int>>& save){
		if (save[mask][women_num] != -1){
			return save[mask][women_num];
		}
		if (mask == target){
			save[mask][women_num] = 1;
			return 1;
		}
		if(women_num == n){
			return 0;
		}


		ll ans = 0;
		for(int men =  0;men < n; ++men){
			if(((mask >> men) & 1 )== 0 && comp[men][women_num] == 1){
					ans += dp(mask | (1 << men), women_num+1,comp,target,n,save);
					ans %= MOD;
				}
			}
		save[mask][women_num] = ans%MOD;
		return ans%MOD;
	}

int main() {
	int n;
	cin >> n;
	vector<vector<int>> comp;
	vector<int> app;
	for(int men =0 ;men < n; ++men){
		for(int women = 0; women < n; ++women){
			int temp;
			cin >> temp;
			app.push_back(temp);
		 }
		 comp.push_back(app);
		 app.clear();
	 }
	 //cout << "done";
	vector<vector<int>> save((1<<n),vector<int>(n+1,-1));
	int target = (1 << n) - 1; 
	cout << dp(0,0,comp,target,n,save)%MOD << endl;
}

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

int main() {

  int N;
  cin >> N;

  int f=0;
  int tmp=N;
  while(tmp>0){
    f += tmp%10;
    tmp /= 10;
  }

  if(N%f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      Arrays.sort(arr);
      int minHeigth = Integer.MAX_VALUE;
      for(int i = k - 1; i < arr.length; i++) {
        minHeigth = Math.min(minHeigth, arr[i] - arr[i - k + 1]);
      }
      System.out.println(minHeigth);
  }
}

Measured memory_bytes: 50424
import Data.Int
import Data.Bits
import Data.List

naiveSolution :: Int64 -> Int64 -> Int64
naiveSolution a b = foldl' xor 0 [a..b]

-- g n == scanl xor 0 [0..] !! n == naiveSolution 0 (n - 1)
g :: Int64 -> Int64
g 0 = 0
g x | odd x = x `xor` (((x + 1) `shiftR` 1) .&. 1)
    | even x = (x `shiftR` 1) .&. 1

solve :: Int64 -> Int64 -> Int64
solve a b = g (b + 1) `xor` g a

main = do
  [a,b] <- map read . words <$> getLine
  print $ solve a b


Measured memory_bytes: 508