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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }
  else{
    int a,b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}


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

int getCnt(int n) {
    int result = 0;
    while (n % 2 == 0) {
        result++;
        n /= 2;
    }
    return result;
}
int main(void) {
    int N;cin>>N;
    int ma = 0;
    int result = 0;
    for (int i = 1; i <= N; i++) {
        int gc = getCnt(i);
        if (getCnt(i) >= ma) {
            ma = gc;
            result = i;
        }
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int num,counter5=0,counter7=0;
  for(int i=0;i<3;i++){
    cin >> num;
  	if(num == 5) counter5++;
    if(num == 7) counter7++;
  }
  
  if(counter5==2&&counter7==1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
class P
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        
        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);
        
        while(h != 0)
        {
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            
            str = Console.ReadLine().Split(' ');
            h = int.Parse(str[0]);
            w = int.Parse(str[1]);
        }
    }
}


Measured memory_bytes: 15940
L, R = map(int, input().split())

if R - L + 1 >= 2019:
     print(0)
else:
    ans = float('Inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


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

int main() {
  while(true) {
    string num;
    cin >> num;
    if(num == "0") break;
    int sum = 0;
    for(int i = 0; i < num.size(); i++) {
      sum += num[i] - '0';
    }
  cout << sum << "\n";
  }
}


Measured memory_bytes: 3148
#include<stdio.h>
int main(void){
    int n,A[100000];
    int i,j;
    int x,tmp;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
	scanf("%d",&A[i]);
    }

    i=-1;
    x=A[n-1];
    for(j=0;j<n-1;j++){
	if(A[j]<=x){
	    i++;
	    tmp=A[i];A[i]=A[j];A[j]=tmp;
	}
    }
    tmp=A[i+1];
    A[i+1]=A[n-1];
    A[n-1]=tmp;

    for(j=0;j<n;j++){
	if(j) printf(" ");
	if(j==i+1) printf("[%d]",A[j]);
	else printf("%d",A[j]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 992
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX = 100 * 10000 + 47;





int main()
{
    string S;
    cin >> S;
    FOR(i, 0, SZ(S )- 8)
    cout << S[i];
    
}


Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    string A = input[0];
    string B = input[1];
    if (A == B) {
      Console.WriteLine("=");
    } else {
      Array.Sort(input);
      Console.WriteLine(input[0] == A ? "<" : ">");
    }
  }
}

Measured memory_bytes: 13404
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, w = list(map(int, input().rstrip('\n').split()))
    dp = [10 ** 10] * (1000 * n + 1)
    dp[0] = 0
    mw = 0
    for _ in range(n):
        wv, vv = list(map(int, input().rstrip('\n').split()))
        for i in range(1000 * n - vv, -1, -1):
            dp[i+vv] = min(dp[i+vv], dp[i] + wv)
    mt = 0
    for i in range(len(dp)):
        if dp[i] <= w:
            mt = max(mt, i)
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40176
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"

#define INF (int)1e9
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,dp[NMAX][MMAX] = {};
string s;

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

int ans = 0;

void solve(){
    // 解答アルゴリズム
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == ',')
        {
            s[i] = ' ';
        }
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    cout << s << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    Fill(dp, -1);

    cin >> s;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  int h, w;
  std::cin >> h >> w;
  std::vector<std::vector<bool> > michi(h+2, std::vector<bool>(w+2, false));
  for(int i=1; i<h+1; i++){
    for(int j=1; j<w+1; j++){
      char c;
      std::cin >> c;
      if(c == '.') michi[i][j] = true;
    }
  }

  int largest = 0;
  for(int st_i=1; st_i<h+1; st_i++){
    for(int st_j=1; st_j<w+1; st_j++){
      //std::cout << st_i << " " << st_j << std::endl;
      if(!michi[st_i][st_j]) continue;

      
      std::vector<std::vector<int> > dp(h+2, std::vector<int>(w+2, 10000));
      std::queue<std::pair<int, int> > q;
      dp[st_i][st_j] = 0;
      q.push(std::make_pair(st_i, st_j));      
      while(!q.empty()){
	std::pair<int, int> now = q.front();
	q.pop();
	if(dp[now.first][now.second] > largest) largest = dp[now.first][now.second];
	
	if(michi[now.first][now.second+1] && dp[now.first][now.second]+1 < dp[now.first][now.second+1]){
	  dp[now.first][now.second+1] = dp[now.first][now.second]+1;
	  q.push(std::make_pair(now.first, now.second+1));
	}
	if(michi[now.first][now.second-1] && dp[now.first][now.second]+1 < dp[now.first][now.second-1]){
	  dp[now.first][now.second-1] = dp[now.first][now.second]+1;
	  q.push(std::make_pair(now.first, now.second-1));
	}
	if(michi[now.first-1][now.second] && dp[now.first][now.second]+1 < dp[now.first-1][now.second]){
	  dp[now.first-1][now.second] = dp[now.first][now.second]+1;
	  q.push(std::make_pair(now.first-1, now.second));
	}
	if(michi[now.first+1][now.second] && dp[now.first][now.second]+1 < dp[now.first+1][now.second]){
	  dp[now.first+1][now.second] = dp[now.first][now.second]+1;
	  q.push(std::make_pair(now.first+1, now.second));
	}
	
      }

      /**
      for(int i=0; i<dp.size(); i++){
	for(int j=0; j<dp[i].size(); j++){
	  std::cout << dp[i][j] << " ";
	}
	std::cout << std::endl;
      }
      **/
    }
  }
  

  std::cout << largest << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int lastN=0;
		int a=sc.nextInt();


		for(int i=0; i<32; i++) {
			if(a%2==1) {
				lastN=i;
			}
			a/=2;
		}
		int res=1;
		for(int i=0; i<lastN; i++) {
			res*=2;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 21844
N, M = map(int,input().split())
like_foods = []
for i in range(N):
    ith_like_foods = list(map(int,input().split()))
    like_foods.append(ith_like_foods[1:])

set_prev = set(like_foods[0])

for i in like_foods:
    set_prev = set_prev & set(i)
    
print(len(set_prev))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while(x <= y){
    ans++;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
var n,k int
var s [][]rune
var dp [][]bool
var ok []bool
var ans []rune
func main() {
  fmt.Scan(&n,&k)
  s = make([][]rune,n)
  for i:=0;i<n;i++ {
    var tmp string
    fmt.Scan(&tmp)
    s[i] = []rune(tmp)
  }
  preprocess()
  process()
  fmt.Println(string(ans))
}
func preprocess() {
  dp = make([][]bool,n+1)
  for i:=0;i<n+1;i++ { dp[i] = make([]bool,k+1) }
  dp[n][0] = true
  for i:=n-1;i>=0;i-- {
    l := len(s[i])
    for j:=0;j<=k;j++ {
      dp[i][j] = dp[i+1][j]
      if j >= l { dp[i][j] = dp[i][j] || dp[i+1][j-l] }
    }
  }
}
func process() {
  ans = make([]rune,k)
  for i:=0;i<k;i++ { ans[i] = '{' }
  ok = make([]bool,k+1)
  ok[0] = true
  for i:=0;i<n;i++ {
    l := len(s[i])
    x,d := -1,-1
    z := z_algorithm(string(s[i])+"."+string(ans))
    z = z[l+1:]
    for j:=0;j<=k-l;j++ {
      if !(ok[j] && dp[i+1][k-l-j]) { continue }
      if z[j] < l && j+z[j] < k && s[i][z[j]] < ans[j+z[j]] {
        x = j
        break
      }
    }
    if x < 0 { continue }
    y := x+l
    for j:=0;j<l;j++ {
      if d < 0 && ans[x+j] != s[i][j] { d = x+j }
      ans[x+j] = s[i][j]
    }
    for j:=y;j<k;j++ { ans[j] = '{' }
    for j:=d+1;j<=k;j++ { ok[j] = false }
    ok[y] = true
  }
}
func z_algorithm(s string) []int {
  n := len(s)
  z := make([]int,n)
  z[0] = n
  for i,j:=1,0;i<n; {
    for i+j < n && s[j:j+1] == s[i+j:i+j+1] { j++ }
    z[i] = j
    if j == 0 { i++;continue }
    k := 1
    for ;i+k<n&&k+z[k]<j;k++ { z[i+k] = z[k] }
    i,j = i+k,j-k
  }
  return z
}

Measured memory_bytes: 54272
from collections import defaultdict
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

graph = defaultdict(list)
for _ in range(M):
    a, b = list(map(int, input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans = 0
for i in range(N):
    height = H[i]
    nx_nodes = graph[i]
    if len(nx_nodes) == 0:
        ans += 1
    else:
        if any([height <= H[nx] for nx in nx_nodes]):
            continue
        else:
            ans += 1
print(ans)
            





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

typedef long long LL;

const int N=100000;

LL n;
int mod,x;
int nxt[N+9];
int p[N+9],a[N+9];
LL sum[N+9],ans;

void work(){
  scanf("%lld%d%d",&n,&x,&mod);
  int now=x;
  for (int i=0;i<mod;++i) nxt[i]=1LL*i*i%mod;
  if (n==1) {printf("%d\n",x);return;}
  p[sum[1]=a[1]=x]=1;
  for (int i=2;i<=mod+2;++i){
	a[i]=nxt[a[i-1]];
	sum[i]=sum[i-1]+a[i];
	if (i==n) {printf("%lld\n",sum[i]);return;}
	if (p[a[i]]){
	  ans=sum[i];
	  int c=i-p[a[i]];
	  n-=i;
	  ans+=(sum[i]-sum[p[a[i]]])*(n/c);
	  //printf("%lld\n",sum[i]-sum[p[a[i]]-1]);
	  n%=c;
	  int now=a[i];
	  for (int j=1;j<=n;++j) ans+=now=nxt[now];
	  printf("%lld\n",ans);
	  return;
	}
	p[a[i]]=i;
  }
}

int main(){
  int T=1;
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 5164
#include<stdio.h>

int SimpleInterest(int, int, double, int);
int ComposedInterest(int, int, double, int);

int main(){
  int i, j, n, m, x, y, isInt, fee, max, _max;
  double rate;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d %d %d", &x, &y, &m);

    for(j=0, max=x; j<m; j++){
      scanf("%d %lf %d", &isInt, &rate, &fee);

      if(isInt == 0) _max = SimpleInterest(x, y, rate, fee);
      else _max = ComposedInterest(x, y, rate, fee);

      if(max < _max) max = _max;
    }

    printf("%d\n", max);
  }
  return 0;
}

int SimpleInterest(int x, int year, double rate, int fee){
  int i, _x;
  for(i=0, _x=0; i<year; i++){
    _x += (x * rate);
    x -= fee;
  }
  x += _x;
  return x;
}

int ComposedInterest(int x, int year, double rate, int fee){
  int i, _x;
  for(i=0; i<year; i++){
    _x = x * rate;
    x += (_x - fee);
  }
  return x;
}

Measured memory_bytes: 0
N=input()
if int(N[0])+int(N[1])+int(N[2])+int(N[3])==7:
    print (N[0]+'+'+N[1]+'+'+N[2]+'+'+N[3]+'=7')
elif int(N[0])+int(N[1])+int(N[2])-int(N[3])==7:
    print (N[0]+'+'+N[1]+'+'+N[2]+'-'+N[3]+'=7')
elif int(N[0])+int(N[1])-int(N[2])+int(N[3])==7:
    print (N[0]+'+'+N[1]+'-'+N[2]+'+'+N[3]+'=7')
elif int(N[0])+int(N[1])-int(N[2])-int(N[3])==7:
    print (N[0]+'+'+N[1]+'-'+N[2]+'-'+N[3]+'=7')
elif int(N[0])-int(N[1])+int(N[2])+int(N[3])==7:
    print (N[0]+'-'+N[1]+'+'+N[2]+'+'+N[3]+'=7')
elif int(N[0])-int(N[1])+int(N[2])-int(N[3])==7:
    print (N[0]+'-'+N[1]+'+'+N[2]+'-'+N[3]+'=7')
elif int(N[0])-int(N[1])-int(N[2])+int(N[3])==7:
    print (N[0]+'-'+N[1]+'-'+N[2]+'+'+N[3]+'=7')
elif int(N[0])-int(N[1])-int(N[2])-int(N[3])==7:
    print (N[0]+'-'+N[1]+'-'+N[2]+'-'+N[3]+'=7')

Measured memory_bytes: 3192
ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  break if h == 0 && w == 0
  1.upto(h) do |i|
    case i
    when 1, h
      puts '#' * w
    else
      print "#", ("." * (w - 2)), "#\n"
    end
  end
  puts
end

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
vector<pair<int,int> >v;
int ans[N],a[N];
int main()
{
    int n,m,i;
    cin>>n>>m;
    for(i=1;i<=n;i++)ans[i]=1;
    for(i=0;i<m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end());
    memset(a,0,sizeof a);
    for(auto x:v)
    {
        int y=x.second;
        ans[y]=ans[y+1]=ans[y]+ans[y+1]-a[y];
        a[y]=ans[y];
    }
    cout<<ans[1];
    for(i=2;i<=n;i++)printf(" %d",ans[i]);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main() {
  int a,b,k;
  cin>>a>>b>>k;
    cerr << a+k << b - k << endl;
  if (a+k<=b-k) {
    for (int i(a);i<a+k;i++) cout << i << endl;
    for (int i(b-k+1);i<=b;i++) cout << i << endl;
  }else{
    cerr << "aa" << endl;
    for (int i(a);i<=b;i++) cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;
}

int32_t main()
{
	Main();
	return 0;
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int n;
int cnt[N];

int main() {

	FAST;

	cin >> n;
	for (int i = 2; i <= n; i ++) {
		int tmp = i;
		for (int j = 2; j * j <= i; j ++) {
			while (tmp % j == 0) {
				tmp /= j;
				cnt[j] ++;
			}
		}
		if (tmp != 1) cnt[tmp] ++;
	}
	int ans = 0;
	for (int i = 2; i <= n; i ++) {
		if (cnt[i] >= 74) ans ++;
	}
	for (int i = 2; i <= n; i ++) {
		for (int j = 2; j <= n; j ++) {
			if (i != j && cnt[i] >= 2 && cnt[j] >= 24) ans ++;
		}
	}
	for (int i = 2; i <= n; i ++) {
		for (int j = 2; j <= n; j ++) {
			if (i != j && cnt[i] >= 4 && cnt[j] >= 14) ans ++;
		}
	}
	for (int i = 2; i <= n; i ++) {
		for (int j = 2; j < i; j ++) {
			for (int k = 2; k <= n; k ++) {
				if (k != i && k != j && cnt[k] >= 2 && cnt[i] >= 4 && cnt[j] >= 4) ans ++; 
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,w,a[10000],v,l,k=1;
	while(true){
		scanf("%d",&w);
		if(w==0)return 0;
		for(int i=0;i<=w;i++)a[i]=0;
		scanf("%d",&n);
		while(n--){
			scanf("%d,%d",&v,&l);
			for(int i=w;i>=l;i--)if(a[i]<a[i-l]+v)a[i]=a[i-l]+v;
		}
		l=w;
		while(a[l]==a[w])l--;
		printf("Case %d:\n%d\n%d\n",k,a[w],l+1);
		k++;
	}
}

Measured memory_bytes: 2600
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> matrix(H+2, vector<char>(W+2, '#'));

	REP(h, H+2) REP(w, W+2) {
		if (h==0 || h==H+1 || w==0 || w==W+1) continue;
		cin >> matrix[h][w];
	}

	REP(h, H+2) REP(w, W+2) {
		cout << matrix[h][w];
		if (w==W+1) cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> pair;
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする
 
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//dpTable
int dp[100050];

int main(){
    int N,D;
    cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
    return 0;
}


Measured memory_bytes: 3636
/*
 * 上皿天秤は、左の皿に乗っているおもりの重さの合計を L とし、右の皿に乗っているおもりの重さの合計を R としたとき、 L>R なら左に傾き、L=R なら釣り合い、L<R なら右に傾きます。
 * 
 * 高橋君は、上皿天秤の左の皿に重さ A のおもりと重さ B のおもりを、右の皿に重さ C のおもりと重さ D のおもりを置きました。
 * 
 * 上皿天秤が左に傾くなら Left を、釣り合うなら Balanced を、右に傾くなら Right を出力してください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int l = Integer.parseInt(sc.next()) + Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next()) + Integer.parseInt(sc.next());

            //出力
            if(l<r){
            	System.out.println("Right");
            }else if(l>r){
            	System.out.println("Left");
            }else{
            	System.out.println("Balanced");
            }

            sc.close();
        }
    }


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 2e5 + 7;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int a[N];
int nx[N];
int pr[N];
int en[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) pr[i] = -1;
    for (int i = n - 1; i >= 0; --i) {
        nx[i] = pr[a[i]];
        pr[a[i]] = i;
    }   
    int sum = 1;
    for (int i = 0; i < n; ++i) {
        sum = mod(sum + en[i]);
        if (nx[i] != -1 && nx[i] != i + 1) en[nx[i]] = mod(en[nx[i]] + sum);
    }   
    cout << sum << '\n';
}    

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int x;
	scanf("%d", &x);
	vector<int> a = {1800, 1600, 1400, 1200, 1000, 800, 600, 400};
	for (int i = 0; i < a.size(); ++i) {
		if (x >= a[i]) {
			printf("%d\n", i + 1);
			break;
		}
	}
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
  	cout << "A\n";
  }else {
  	cout << "B\n";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <tuple>
#include <cstring>
using namespace std;

static int dr[4] = {1, 0, -1, 0},
           dc[4] = {0, 1, 0, -1};

static int H, W, K;

bool inside(int r, int c) {
    return 0 <= r and r < H and 0 <= c and c < W;
}

int main() {
    const int MAXH = 810;
    const int MAXW = 810;

    cin >> H >> W >> K;

    int sr = -1, sc = -1;

    string A[MAXH];
    for (int r = 0; r < H; r++) {
        cin >> A[r];
        for (int c = 0; c < W; c++) {
            if (A[r][c] == 'S') {
                sr = r;
                sc = c;
            }
        }
    }

    static int dist[MAXH][MAXW];
    memset(dist, -1, sizeof(dist));

    queue<tuple<int, int, int>> Q;
    dist[sr][sc] = 0;
    Q.push({sr, sc, 0});

    int ans = W * H;
    while (!Q.empty()) {
        int r, c, d;
        tie(r, c, d) = Q.front(); Q.pop();

        int x = min({r, H - 1 - r, c, W - 1 - c});

        ans = min(ans, (x + K - 1) / K + 1);

        if (d == K) continue;
        for (int i = 0; i < 4; i++) {
            int nr = r + dr[i],
                nc = c + dc[i];
            if (inside(nr, nc) and dist[nr][nc] < 0 and A[nr][nc] != '#') {
                dist[nr][nc] = d + 1;
                Q.push({nr, nc, d + 1});
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4600
/*SorooshH*/
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
const int MAX = 1e6;
const int MV = 1e5;
const int INF = 2e9;
const int MOD = 1e9 + 7;
ll MA = -INF , MI = INF , ANS;

int n;
string s;
ll arr[10];
char c[] = {'M' , 'A' , 'R' , 'C' , 'H'};

int32_t main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n;

    for(int i=0 ; i<n ; i++)
    {
        cin >> s;
        for(int j=0 ; j<5 ; j++)
        {
            if( c[j] == s[0] )
                arr[j]++;
        }
    }

    for(int i=0 ; i<5 ; i++)
        for(int j=i+1 ; j<5 ; j++)
            for(int k=j+1 ; k<5 ; k++)
                ANS += arr[i] * arr[j] * arr[k];

    cout << ANS << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if ( b >= c ) ans = b + c;
    else if ( a + b >= c ) ans = b + c;
    else                   ans = b + ( a + b + 1 );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dilip
 */

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>

using namespace std;

class CDivideTheProblems {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        int n;
        in >> n;
        int d[n];
        for(int i=1;i<=n;i++)in >> d[i];

        sort(d+1,d+n+1);

        int mid = 0.5 * (1 + n);

        out << d[mid+1] - d[mid];


	}
};


int main() {
	CDivideTheProblems solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
from collections import Counter
from functools import reduce
import bisect
import copy
import fractions
import math
# import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]

n, a = II(), LI()
a_abs = list(map(abs,a))
print(sum(a_abs)) if sum(x < 0 for x in a) % 2 == 0 else print(sum(a_abs) - 2 * min(a_abs))


Measured memory_bytes: 16400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    bool ok = true;
    if(s[a]!='-') ok = false;
    rep(i, a+b+1) {
        if(i==a) continue;
        if((s[i]-'0')<0||9<(s[i]-'0')) ok = false; 
    }
    if(ok) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	
	map<int,int>fre;
	
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		
		fre[x]++;
	}
	
	int ans=0;
	
	for(auto it: fre)
	{
		if(it.first>it.second) ans+=it.second;
		else ans+=it.second-it.first;
	}
	
	cout<<ans;
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 8052
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int main()
{

	int N, ans =0;
	char x;
	bool flag = true;
	cin >> N;
	vector<vector<char>> a(2*N, vector<char>(2*N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> x;
			a[i][j] = a[i+N][j] = x;
		}
	}


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (a[j+i][k] != a[k+i][j]) {
					flag = false;
				}
			}
		}
		if (flag == true) {
			ans += N;
		}
		flag = true;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
	long n, r, k, d = LONG_MIN, max_r = LONG_MIN, min_r, i;
	cin >> n >> min_r;
	for(i = 1; i < n; ++i){
		cin >> r;
		k = r - min_r;
		if( k > d )
			d = k;
		if( r < min_r ) {
			min_r = r;			
		}
	}
	
	cout << d << "\n";

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec memo(3,0);
    rep(i,N){
        cin>>A;
        if(A%4 == 0){
            ++memo[2];
        }else if(A%2 == 0){
            ++memo[1];
        }else{
            ++memo[0];
        }
    }
    bool yes = false;
    if(memo[1] == 0){
        if(memo[2] + 1 >= memo[0]) yes = true;
    }else{
        if(memo[2] >= memo[0]) yes = true;
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]>=b[i]:
    ans+=b[i]
  else:
    c=b[i]-a[i]
    if a[i+1]>=c:
      a[i+1]-=c
      ans+=a[i]+c
    else:
      ans+=a[i]+a[i+1]
      a[i+1]=0

print(ans)

Measured memory_bytes: 24084
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int p[200005];
void solve()
{
   int n,sol=0;
   cin >> n;
   int mn = mod;
   for (int i = 0; i < n; i++)
   {
      cin >> p[i];
      mn = min(mn, p[i]);
      if (mn == p[i])
         sol++;
   }
   cout << sol;
}
int main()
{
	int t = 1;
//	cin >> t;
	while (t--)
	{
		solve();
	}
}


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

typedef long long Int;
typedef pair<Int,Int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define MAX (6 << 10)

Int R[MAX][MAX + MAX];

int main()
{
	int n, m;
	cin >> n >> m;

	CLEAR(R, 0);
	R[0][MAX] = 1;
	int i, j;
	FOR(i, 0, 3*n)
	FOR(j, 0, MAX + MAX)
	if(R[i][j] != 0)
	{
		R[i + 1][j + 1] = (R[i + 1][j + 1] + R[i][j]) % m;
		if(i + 2 <= 3*n) R[i + 2][j - 1] = (R[i + 2][j - 1] + R[i][j]*(i + 1)) % m;
		if(i + 3 <= 3*n) R[i + 3][j] = (R[i + 3][j] + R[i][j]*(i + 1)*(i + 2)) % m;
	}

	Int res = 0;
	FOR(i, MAX, MAX + MAX) res += R[3*n][i];
	res %= m;
	cout << res << endl;
	return 0;
}

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

#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

map<string, int> memo;
int main() {
	//sort(a.begin(),a.end());
	int k, n;
	cin >> n >> k;
	vector<int> a(n);
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	if (n <= k) {
		cout << 0;
	}
	else {
		for (int i = 0; i < n - k; i++) {
			ans += a[i];
		}
		cout << ans;
	}
	
	return 0;
}









Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
   int n, k; cin >> n >> k;
   vector<ll> c(n);
   bool pf = true;
   bool mf = true;
   int prd = 0;
   bool f = true;
   rep(i,n) {
      cin >>  c[i];

      if(c[i] >= 0) {
         mf = false;
      } else {
         pf = false;
      }

      if(c[i] >= 0 && f) {
         prd = i;
         f = false;
      }
   }

   ll ans = 0;
   if(pf) {
      ans = c[k-1];
   } else if(mf) {
      ans = abs(c[n - k]);
   } else {
      ll l = prd;
      ll r = l + k-1;
      /*cout << l << " " << r << endl;*/
      if(r >= n ) {
         ll diff = r - n;
         r -= diff + 1;
         l -= diff + 1;
         /*cout << diff + 1 << endl;*/
      }
      /*cout << l << " " << r << endl;*/
      ans = max(abs(c[r]), abs(c[l])) + 2*min(abs(c[r]), abs(c[l]));

      while(r >= prd && r >= 0 && l >= 0) {
         /*cout << l << " " << r << endl;*/
         ans = min(ans, max(abs(c[r]), abs(c[l])) + 2 * min(abs(c[r]), abs(c[l])));
         /*cout << max(abs(c[r]), abs(c[l])) + 2 * min(abs(c[r]), abs(c[l])) << endl;*/
         r--;
         l--;
      }
   }


   cout << ans << endl;
}

int main()
{
   solve1();
}

Measured memory_bytes: 3940
# CADDi 2018 for Beginners: B – AtCoder Alloy
N, H, W = [int(s) for s in input().split()]
R = [[int(s) for s in input().split()] for _ in range(N)]

count = 0

for i in range(N):
    if R[i][0] >= H and R[i][1] >= W:
        count += 1

print(count)

Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
#define INF 8108931145141919810
using namespace std;
int n, q, c, e, dir[111111]; long long t, x[111111], y[111111];
int main() {
	scanf("%d%lld%d", &n, &t, &q);
	for (int i = 0; i < n; i++) scanf("%lld%d", x + i, dir + i);
	for (int i = 1; i < n; i++) {
		if (dir[i - 1] == 1 && dir[i] == 2) y[c++] = (x[i - 1] + x[i]) / 2;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d", &e); e--;
		int ptr = lower_bound(y, y + c, x[e]) - y;
		long long ret;
		if (dir[e] == 1) {
			ret = x[e] + t;
			if (ptr != c) ret = min(ret, y[ptr]);
		}
		else {
			ret = x[e] - t; ptr--;
			if (ptr != -1) ret = max(ret, y[ptr]);
		}
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int b = 0, mb = 0;
    rep(i, 0, n) {
        if (s[i] == '(') {
            b++;
        } else {
            b--;
        }
        mb = min(b, mb);
    }
    rep(i, 0, -mb) {
        cout << '(';
    }
    cout << s;
    rep(i, 0, b - mb) {
        cout << ')';
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,a;
    t = 1;
    while(t--) {
     cin >> n >> a;
     if(a >= n % 500)
      cout << "Yes" << endl;
     else
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int n,m;
	int h[1501],w[1501];
	static int width[1000*1501];
	int i,j;
	h[0]=w[0]=0;
	while(scanf("%d%d",&n,&m),n|m){
		int ans=0;
		for(i=1;i<=n;i++){
			scanf("%d",h+i);
			h[i] += h[i-1];
		}
		for(i=1;i<=m;i++){
			scanf("%d",w+i);
			w[i] += w[i-1];
		}
		memset(width,0,sizeof(width));
		for(i=0;i<=m;i++)
			for(j=i+1;j<=m;j++)
				width[w[j]-w[i]]++;
		for(i=0;i<=n;i++)
			for(j=i+1;j<=n;j++)
				ans += width[h[j]-h[i]];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct Kruskal{
  
  struct edge{
    Int from,to;
    T cost;
    Int used;
    edge(){}
    edge(Int from,Int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<Int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int n):n(n){}

  void init(Int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(Int x,Int y){
    return find(x)==find(y);
  }

  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(Int u,Int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  Kruskal<Int> ks(n);

  using P = pair<Int, Int>;
  vector<P> vp;
  
  for(Int i=0;i<n;i++)
    vp.emplace_back(x[i],i);

  sort(vp.begin(),vp.end());
  for(Int i=1;i<n;i++){
    Int a=vp[i-1].second;
    Int b=vp[i].second;
    ks.add_edge(a,b,x[b]-x[a]);
  }

  vp.clear();
  
  for(Int i=0;i<n;i++)
    vp.emplace_back(y[i],i);
  
  sort(vp.begin(),vp.end());
  for(Int i=1;i<n;i++){
    Int a=vp[i-1].second;
    Int b=vp[i].second;
    ks.add_edge(a,b,y[b]-y[a]);
  }

  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 13804
n, m = map(int, raw_input().split())
v = []
for i in range(m):
    p, y = map(int, raw_input().split())
    v.append((i, p, y))
v = sorted(v, key=lambda _: _[2])
D = {p: 1 for p in range(1,n+1)}
w = []
for i, p, y in v:
    x = D[p]
    D[p] += 1
    w.append((i, "%06d%06d" % (p, x)))
for i, code in sorted(w):
    print code

Measured memory_bytes: 43432
#include <iostream>

using namespace std;

int R, G, B, N, r, g, b, ans;
int main()
{
    cin>>R>>G>>B>>N;

    r = N/R;
    g = N/G;
    b = N/B;

    for (int i=0; i<=r; i++)
        for(int j=0; j<=g; j++)
        {
            int k = (N-i*R-j*G);
            if (k>=0 && k%B==0) ans++;
        }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
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;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    string s; cin >> s;
    ll ans = 0;
    if(s[1] == 'R'){
        rep(i, 3){
            if(s[i] == 'R') ans++;
        }
    }
    else{
        if(s[0] == 'R' || s[2] == 'R') ans = 1;
        else ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3504
/****************************************************

@author: vichitr
Compiled On: 10th Jan 2020

*****************************************************/
#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>
#define F first
#define S second

#define loop(i,n) for(int i=0;i<n;i++)
#define loops(i,s,n) for(int i=s;i<=n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e6+7;
// const ll M = 2e5+7;

ll pwr(ll x, ll y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r;
}

int inv(int x)
{
    return pwr(x, MOD-2ll);
}

int fact[N], n;

int nCr(int x, int y){
    int ans= fact[x];
    ans *= inv(fact[y]);
    ans %= MOD;
    ans *= inv(fact[x-y]);
    ans %= MOD;
    return ans;
}


void solve()
{ 
    char c; cin>>c;
    c++;
    cout<<c;
    
}

signed main()
{
    fast;
    int t=1;
    // cin >>t;

    // fact[0] =1;
    // for(int i=1;i<N;i++){
    //     fact[i] = fact[i-1]*i;
    //     fact[i] %= MOD;
    // }

    while(t--){
        solve();
        
    }
    return 0;
}

/*****************************

3 595

43 2

300 4

554 10


***************************/

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

int main()
{
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }
else{
  int x,y;
  cin >> x >> y;
  cout << x + y << endl;
}
  return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<int, int>;

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n+1) { } 
  void add(int k, T a) { 
    for (++k; k < x.size(); k += k&-k) x[k] += a;
  }
  T sum(int k) {
    T s = 0;
    for (; k > 0; k &= k-1) s += x[k];
    return s;
  }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, Q;
  while (cin >> N >> Q) {
    vector<int> colors(N);
    for (auto& x : colors) cin >> x, --x;
    vector<P> queries(Q);
    for (auto& x : queries) cin >> x.fst >> x.snd, --x.fst;
    vector<int> index(Q);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&](auto i, auto j) {
      auto a = queries[i], b = queries[j];
      if (a.snd != b.snd) return a.snd < b.snd;
      return a.fst < b.fst;
    });
    fenwick_tree<int> bit(N);
    vector<int> pre(N, -1);
    int r = 0, cnt = 0;
    vector<int> res(Q, -1);
    for (auto qi : index) {
      auto q = queries[qi];
      while (r < q.snd) {
        int c = colors[r];
        int p = pre[c];
        if (p < 0) {
          ++cnt;
        } else {
          bit.add(p, -1);
        }
        bit.add(r, 1);
        pre[c] = r;
        ++r;
      }
      res[qi] = cnt - bit.sum(q.fst);
    }
    for (int x : res) cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 17372
#include <iostream>
#include <string>
using namespace std;
int main(){
      string s;
      while(getline(cin,s)||!cin.eof()){
            for(int i=0;i<25;i++){
                  if(s.find("the")!=-1||s.find("this")!=-1||s.find("that")!=-1)break;
                  else for(int j=0;j<s.size();j++)if(s[j]>='a'&&s[j]<='z')s[j]!='z'?s[j]++:s[j]='a';
            }
            cout<<s<<endl;
      }
}

Measured memory_bytes: 1176