akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 998244353
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  ll K,N;
  cin>>S>>K;
  N=S.size();
  
  ll now=0,n1=0;
  vector<ll> S_1(300,0);
  
  for(int i=0; i<N; i++){
    if(S[i]=='0') now++;
    else{
      S_1[now]++;
      n1++;
    }
  }
  if(S[N-1]=='1') now++;
  K=min(n1,K);
  
  vector<vector<vector<long long>>> dp(now+1,vector<vector<long long>> (K+1,vector<long long> (K+1,0)));
  dp[now][K][0]=1;
  
  n1=0;
  for(int i=now-1; i>=0; i--){
    n1+=S_1[i];
    for(int j=max(0ll,K-n1); j<=K; j++){
      for(int l=0; l<=n1; l++){
        if(j+l>K) break;
        for(int m=l; j+m<=K; m++){
          dp[i][j][l]+=dp[i+1][j][m];
          dp[i][j][l]%=MOD;
        }
        for(int m=1; m<=S_1[i]; m++){
          if(j+m>K) break;
          if(l<m) break;
          dp[i][j][l]+=dp[i+1][j+m][l-m];
          dp[i][j][l]%=MOD;
        }
      }
    }
  }
  
  ll ans=0;
  for(int i=0; i<=K; i++){
    ans+=dp[0][i][0];
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 30980
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
pair<pair<string,ll>,ll>data[n];
string s;
ll p;
for(int i=0;i<n;i++){
    cin>>s>>p;
    p*=-1;
    data[i]=make_pair(make_pair(s,p),i);
}
sort(data,data+n);
for(int i=0;i<n;i++){
    cout<<data[i].second+1<<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[] num = new int[5];
      int tmp = 0;
      for(int i=0;i<5;i++){
        num[i] = sc.nextInt();
        if( num[i] != i + 1 ){
          tmp = i+1;
        }
      }
      System.out.println(tmp);
      
	}
}
  /*
        if( (int)s.charAt(0)-48 >= 0 && (int)s.charAt(0)-48 <=48 ){
*/

Measured memory_bytes: 27072
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N, K;
	cin >> N >> K;

	cout << (N - 1) / (K - 1) + (((N - 1) % (K - 1)) != 0);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() { 
  long long start, end, div_num;
  long long cnt = 0;

  std::cin >> start >> end >> div_num;

  cnt = end / div_num + 1;

  if (start == 1) {
    cnt--;
  } else if (start > 1) {
    cnt -= ((start - 1) / div_num + 1);
  }

  std::cout << cnt << "\n";

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
S = input()
ans = np.zeros(len(S), np.int64)
pos = 0
last_R = 0
while pos < (len(S)):
    if S[pos] == 'R':
        move_count = 0
        while S[pos] == 'R':  # Lを探す
            last_R = pos
            move_count += 1
            pos += 1
        # 'L'発見 S[pos] == L
        ans[pos] += (move_count)//2
        ans[pos-1] += (move_count - (move_count)//2)
    else:  # S[pos] == 'L':
        move_count = 0
        # print('found L')
        while pos < len(S):
            # print(pos, len(S))
            if S[pos] == 'L':  # 'R'を探す
                pos += 1
            else:
                break
        # R発見
        move_count = pos-1 - last_R
        # print(move_count, '=', pos, '-', last_R)
        ans[last_R] += (move_count)//2
        ans[last_R+1] += (move_count - (move_count)//2)


print(*list(ans))


Measured memory_bytes: 19824
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		String op = scan.next();
		int b = Integer.parseInt(scan.next());
		while(!op.equals("?")){
			if(op.equals("+")){
				System.out.println(a+b);
			}
			else if(op.equals("-")){
				System.out.println(a-b);
			}
			else if(op.equals("*")){
				System.out.println(a*b);
			}
			else if(op.equals("/")){
				System.out.println(a/b);
			}
			a = Integer.parseInt(scan.next());
			op = scan.next();
			b = Integer.parseInt(scan.next());
		}
		scan.close();
	}

}

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

void maxHeapify( int* , int , int );
void buildMaxHeap( int* , int );

int main(){

  int *a;
  int n,i,j;

  scanf("%d",&n);
  a = malloc(sizeof(int)*(n+1));

  for( i=1 ; i<n+1 ; i++ ){
    scanf("%d",&a[i]);
  }

  buildMaxHeap( a, n );

  for( i=1 ; i<n+1 ; i++ ){
    printf(" %d",a[i]);
  }

  printf("\n");

  free(a);

  return 0;
}

void maxHeapify( int *a , int i , int n ){
  int l,r,max,tmp;

  max = i;
  l = 2*i;
  r = 2*i+1;

  if( l <= n && a[l] > a[i] ) max = l;

  if( r <= n && a[r] > a[max] ) max = r;
  

  if( max != i ){
    tmp = a[i];
    a[i] = a[max];
    a[max] = tmp;
    return maxHeapify( a, max, n );
  }

}


void buildMaxHeap( int *a , int n ){
  int i;

  for( i=n/2 ; i>=1 ; i-- ){
    maxHeapify(a, i, n);
  }
}

Measured memory_bytes: 2472
n = int(input())
v = list(map(int,input().split()))

cnt1 = {}
cnt2 = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] in cnt1:
            cnt1[v[i]] += 1
        else:
            cnt1[v[i]] = 1
    else:
        if v[i] in cnt2:
            cnt2[v[i]] += 1
        else:
            cnt2[v[i]] = 1

sorted_cnt1 = sorted(cnt1.items(), key = lambda x: x[1], reverse = True)
sorted_cnt2 = sorted(cnt2.items(), key = lambda x: x[1], reverse = True)

sorted_cnt1.append((-1,0))
sorted_cnt2.append((-1,0))

if sorted_cnt1[0][0] != sorted_cnt2[0][0]:
    print(n - sorted_cnt1[0][1] - sorted_cnt2[0][1])
else:
    print(n - max(sorted_cnt1[0][1] + sorted_cnt2[1][1], sorted_cnt1[1][1]+sorted_cnt2[0][1]))


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

int main(){
    string o,e;
    cin >> o >> e;
    string s="";
    for(int i=0; i<(int)e.length(); i++){
        s += o[i];
        s += e[i];
    }
    if(o.length() > e.length()){
        s += o.back();
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

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

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    ll ans=0;
    rep(i,n-1){
        sum-=a[i];
        if(sum<0)sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    cout<<ans<<endl;

}













































































Measured memory_bytes: 4844
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	

	vector<ll> a(n);
	
	
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] =a[i]- i - 1;
	}
	sort(a.begin(), a.end());
	vector<ll> cs(n);
  cs[0]=a[0];
	for(int i=1;i<n;i++){
      cs[i]=cs[i-1]+a[i];
    }

	ll ans = 1e18;
	for (int i = 0; i < n; ++i) {
		ll res = 0;
		res += a[i] * (i + 1) - cs[i];
		res += (cs.back() - cs[i]) - a[i] * (n - i - 1);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d_one = 0
d_two = 0
d_three = 0
d_inf = [0]*n


for i in range(n):
    d_one += abs(x[i]-y[i])
    d_two += abs(x[i] - y[i]) ** 2
    d_three += abs(x[i] - y[i]) ** 3
    d_inf[i] = abs(x[i] - y[i]) 
    
print(d_one)
print(math.sqrt(d_two))
print(math.pow(d_three, 1.0 / 3.0))
print(max(d_inf))


Measured memory_bytes: 5700
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll dp[110][5][2];

int main() {
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    if(s[0]-'0' == 0) {
        dp[0][0][0] = 1;
    } else {
        dp[0][0][1] = 1;
        dp[0][1][0] = 1;
        dp[0][1][1] = s[0]-'0'-1;
    }
    rep(i,n-1) rep(j,K+1) rep(k,2) {
        int now = s[i+1]-'0';
        if(k == 0) {
            if(now != 0) {
                dp[i+1][j+1][k] += dp[i][j][k];
                dp[i+1][j+1][1] += dp[i][j][k]*(now-1);
                dp[i+1][j][1] += dp[i][j][k];
            } else {
                dp[i+1][j][k] += dp[i][j][k];
            }
        } else {
            dp[i+1][j+1][k] += dp[i][j][k]*9;
            dp[i+1][j][k] += dp[i][j][k];
        }
    }
    cout << dp[n-1][K][0]+dp[n-1][K][1] << endl;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

len_B = M+1
res = []
for i, a_ in enumerate(a):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a_ + b[j] <= K:
            res.append(i+j)
            break
    len_B = j+1

print(0 if len(res) < 1 else max(res))

Measured memory_bytes: 48496
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		int a[] = new int[5];
		int x;
		for(int i = 0;i<5;i++){
			a[i] = scn.nextInt();
		}
		for(int i = 0;i<4;i++){
			for(int j = 0;j<4;j++){
				if(a[j] < a[j+1]){
					x = a[j];
					a[j] = a[j+1];
					a[j + 1] = x;
				}
			}
		}
		for(int i = 0;i<5;i++){
			if(i == 4){
				System.out.println(a[i]);
				break;
			}
			System.out.print(a[i] + " ");
		}
	}
}

Measured memory_bytes: 26204
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Min(a, b) (a < b ? a : b)

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  printf("%d\n", Min(n*a, b));
  return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

lli Set(lli N,lli pos)
{
    return N=N | (1LL<<pos);
}
lli reset(lli N,lli pos)
{
    return N = N & ~(1LL<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}

int LEN(lli n){
    int cnt = 0;
    while(n){
        n/=2;
        cnt++;
    }
    return cnt;
}

int bit[60];

lli fun(lli a, lli ret = 0){

    if(!a) return 0;
    if(a == 1) return ret^1LL;

    lli d = a+1;

    if((d/2)%2) ret ^= 1LL;

    for(int i=1; i<LEN(a); i++){

        lli t = 1LL<<i;

        if((d/t)%2 && (d%t)%2) ret ^= t;
    }

    return ret;
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;


    lli a,b;

    scn2ll(a,b);

    lli ans = fun(a-1 , fun(b));

    cout<<ans;

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 256
"""
Problem A: Starship Hakodate-maru
https://onlinejudge.u-aizu.ac.jp/problems/1224
cannot be greater than 151200

Sample Input
100
64
50
20
151200
0
Output for the Sample Input
99
64
47
20
151200

maximum: 151200 = 39 × 39 × 39 + 81 × 82 × 83/6
n = 54  n^3 = 157464

n = 96 tetrahedral = 152096

"""

#cube and tetrahedral
cube = []
tetrahedral = []

def solve(n):
    min = 0
    diff_min = pow(10, 6)
    for i in cube:
        for j in tetrahedral:
            sum_value = i+j
            now_diff = n - sum_value
            if now_diff < diff_min and now_diff >= 0:
                diff_min = now_diff
                min = sum_value
                #print(n,i,j,sum_value,diff_min)

    return min

if __name__ == '__main__':

    for i in range(0, 55):
        cube.append(i**3)
    for i in range(0, 97):
        tetrahedral.append(i*(i+1)*(i+2)//6)

    ans = []
    while(True):
        n = int(input())
        if n == 0:
            break
        ans.append(solve(n))
    print(*ans, sep='\n')



Measured memory_bytes: 5772
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = list(input())
T = list(input())

LS = len(S)
LT = len(T)

ans = LT
for i in range(LS - LT + 1):
    t = 0
    for j in range(LT):
        if S[i + j] != T[j]:
            t += 1

    ans = min(ans, t)

print(ans)


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

using namespace std;

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

    int o = 2;
    int e = 1;
    vector<int> v;

    for(int i=0;i<n;i++){
        v.push_back(o);
        o += 2;
    }

    for(int i=0;i<m;i++){
        v.push_back(e);
        e += 2;
    }

    int x = 0;
    int c = 0;
    for(int i=0;i<n+m;i++){
        for(int j=i+1;j<n+m;j++){
            x = v[i] + v[j];
            if((x % 2) == 0)
                c++;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if(M1!=M2){
        cout << '1' << endl;
    }else{
        cout << '0' << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

readline = stdin.buffer.readline
read = stdin.buffer.read
def i_input(): return int(input().rstrip())
def i_map(): return map(int, input().rstrip().split())
def i_list(): return list(i_map())

MOD = 10 ** 9 + 7
def main():
    N = i_input()
    print((pow(10, N, MOD) - pow(9, N, MOD) * 2 + pow(8, N, MOD)) % MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 61852
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
       int w,a,b;
       cin>>w>>a>>b;
       if(abs(a-b)<=w) cout<<0<<endl;
       else cout<<abs(a-b)-w<<endl;
    }

Measured memory_bytes: 256
<?php
# 入力部
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%d %d", $n, $m);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
if ($n % 2 == 0) {
  $r = $n / 2;
} else {
  $r = ($n + 1) / 2;
}

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
echo $r . "\n";


Measured memory_bytes: 16076
using System;
using System.IO;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');

            for (int i = x - 1; i >= 0; i--)
            {
                Console.Write(a[i]);
                if (i != 0)
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

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

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

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

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int M, D;

int main(){
    cin >> M >> D;

    int ans = 0;
    for(int i = 1; i <=M; ++i){
        for(int j = 1; j <= D; ++j){
            int a = j % 10, b = j / 10;
            if(a >= 2 && b >= 2 && i == a * b) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b;
  
  scanf("%d",&a);
  b=a%10;
  
 if(b==3) printf("bon");
 else if(b==0 || b==1 || b==6 || b==8) printf("pon");
  else printf("hon");
  
  

return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;
    int ans=INT_MIN;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='I')
        {
            c++;
            ans=max(ans, c);
        }
        else
        {
            c--;
            ans=max(ans, c);
        }
    }
    cout<<max(0, ans);
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;
const int nmax=100005;
long long sum,a[nmax],d[nmax];
int n,i;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%(1LL*n*(n+1)/2))
    {
        cout<<"NO";
        return 0;
    }
    long long k=(sum/((1LL*n*(n+1)/2)));
    a[n+1]=a[1];
    for(i=1;i<=n;i++)
    {
        d[i]=a[i+1]-a[i];
        if(k-d[i]<0||(k-d[i])%n)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t=100;
	ll x;
	cin>>x;
	int ans=0;
	while(t<x){
		t=t*1.01;
		ans++;
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 3652
#include<stdio.h>
int main(){
	int a,b,i,j;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==b && a==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2072
fun main(args:Array<String>) {
    val (h,n) = readLine()!!.split(" ").map { it.toInt() }
    val move = readLine()!!.split(" ").map { it.toInt() }
    val sum = move.sum()
    if(sum >= h) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 48380
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,a[25][25],dp[25][3003000],cnt[3003000];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();
	rep(i,1,n) rep(j,1,n) a[i][j]=read();
	dp[0][0]=1;int lim=(1<<n)-1;
	rep(i,1,lim) cnt[i]=cnt[i>>1]+(i&1);
	rep(i,1,n)
		rep(j,1,lim)
			if (cnt[j]==i)
				rep(k,1,n)
					if ((j&(1<<(k-1))) && (a[i][k]))
						dp[i][j]=(dp[i][j]+dp[i-1][j^(1<<(k-1))])%maxd;
	printf("%d",dp[n][lim]);
	return 0;
}

Measured memory_bytes: 205056
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <map>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

// 18分

signed main(){
  int a[3],b[3];
  int route[5]={};
  bool ans = true;
  LOOP(i,3){
    cin >> a[i] >> b[i];
    route[a[i]]++;
    route[b[i]]++;
  }
  if(route[1]!=1)ans = false;
  FOR(i,2,3){
    if(route[i]!=2){
      ans = false;
    }
  }
  if(route[4]!=1){
    ans = false;
  }
  if(ans == false){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}
// ;;


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr double DINF = 100000000000000000.0;
constexpr long long INF = 100000000000000000;
const double PI = acos(-1);

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	if (a == c)cout << b << endl;
	if (b == c)cout << a << endl;
}

Measured memory_bytes: 768
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var map = new char[n, n];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Trim();
                for (int j = 0; j < n; j++) map[i, j] = line[j];
            }
            var dp = new int[n, n];
            for (int i = 0; i < n; i++)
            {
                if (map[0, i] == '.') dp[0, i] = 1;
                if (map[i, 0] == '.') dp[i, 0] = 1;
            }
            for (int i = 1; i < n; i++)
                for (int j = 1; j < n; j++)
                    if (map[i, j] == '*') dp[i, j] = 0;
                    else dp[i, j] = Math.Min(Math.Min(dp[i - 1, j], dp[i - 1, j - 1]), dp[i, j - 1]) + 1;
            var maxn = 0;
            foreach (var x in dp) maxn = Math.Max(maxn, x);
            Console.WriteLine(maxn);
        }
    }
}

Measured memory_bytes: 25284
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	int n;
	cin >> n;
	map<ll, int> mpd, mpt;
	rep(i, n) {
		ll k;
		cin >> k;
		mpd[k]++;
	}
	int m;
	cin >> m;
	rep(i, m) {
		ll k;
		cin >> k;
		mpt[k]++;
	}
	for (auto i = mpt.begin(); i != mpt.end(); i++) {
		if (i->second > mpd[i->first]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
int cnt[100005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
    cin >> N;
    vector<int> a(N);
    int mx = 0;
    int mn = inf;
    rep(i,N){
        cin >> a[i];
        mx = max(mx,a[i]);
        mn = min(mn,a[i]);
    }
    if(mx-mn>=2){
        cout << "No" << endl;
        return 0;
    }
    if(mx==mn){
        if(a[0]!=N-1 && 2*a[0]>N){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }else{
        int A = mx;
        int x = 0;
        int y= 0;
        rep(i,N){
            if(a[i]==A-1)x++;
            else y++;
        }
        if(x<A && 2*(A-x)<=y)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int x;
    cin >> x;
    x /= 200;
    cout << 10 - x << "\n";
}

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

numbers = list(map(int, input().split(" ")))

cnt = 0

flag = 1

si = 0

while flag:
    flag = 0
    for j in range(n - 1, si, -1):
        if numbers[j] < numbers[j - 1]:
            tmp = numbers[j]
            numbers[j] = numbers[j - 1]
            numbers[j - 1] = tmp
            cnt += 1
            flag = 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)

Measured memory_bytes: 7644
#[allow(dead_code)]
fn main() {
    let mut nn = i::u();
    let mut vec1=i::iv(nn);

    let mut sum1=0;
    let mut max1=0;

    for xx1 in vec1 {
        sum1+=xx1;
        if (xx1>max1){
            max1=xx1;
        }
    }
    if (max1<(sum1-max1)){
        println!("Yes");
    }else{
        println!("No");
    }
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int partition(vector<int>& v, int p, int r){
    int x = v[r];
    int i = p-1;
    for(int j=p; j<r; j++){
        if(v[j] <= x){
            i++;
            swap(v[i], v[j]);
        }
    }
    swap(v[i+1], v[r]);

    return i+1;
}

int main(){
    int n; cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    int index = partition(v, 0, n-1);
    for(int i=0; i<n; i++) {
        if(i==index) cout << "[" << v[i] << "]";
        else cout << v[i];
        cout << " \n"[i==n-1];
    }
    
    return 0;
}


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

long long N, K, A[1 << 18];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> A[i];
    
    for (int i = K + 1; i <= N; i++) {
        if (A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string s;
	cin >> n >> s;
	
	int cntr = 0, cntb = 0;
	rep(i, n) {
		if (s[i] == 'R') cntr++;
		else cntb++;
	}
	
	if (cntr > cntb) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
readlines.each do |l|
  xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = l.split.map(&:to_f)
  puts (xb1<=xa1 && xa1<=xb2 || xa1<=xb1 && xb1<=xa2) &&
       (yb1<=ya2 && ya2<=yb2 || ya1<=yb2 && yb2<=ya2) ? "YES" : "NO"
end

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

int main() {
  int input;
  cin>>input;
  if(input>9){
    int i=input%10;
  if(i==2||i==4||i==5||i==7||i==9){
    cout<<"hon";
  }
  else if(i==0||i==1||i==6||i==8){
    cout<<"pon";
  }
  else if(i==3){
    cout<<"bon";
  }
  }
  else{
    if(input==2||input==4||input==5||input==7||input==9){
    cout<<"hon";
  }
  else if(input==0||input==1||input==6||input==8){
    cout<<"pon";
  }
  else if(input==3){
    cout<<"bon";
  }
  }
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

    priority_queue<ll> div;
    for (ll ii = 1; ii*ii <= N; ++ii){
        if (N % ii == 0){
            div.push(ii);
            if (N / ii != ii){
                div.push(N / ii);   //重複しないなら相方も追加
            }
        }
    }

    ll ans = 0;
    while (!div.empty()) {
    	ll tmp = div.top();
    	div.pop();

    	ll val = tmp - 1;
    	ll val2 = N / tmp;
    	if (val > val2){
    		ans += val;
    	} else {
    		break;
    	}
    }

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include "iostream"

int main()
{
	int S,h,m,s;
	std::cin >> S;
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S - h * 3600 - m * 60;

	std::cout << h << ":" << m << ":" << s << std::endl;

    return 0;
}



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

using namespace std;

int main()
{
    long long X,K,D,num,m,n,num1;
    cin>>X>>K>>D;
    num=X/D;
    m=X-num*D;
    if(K<=abs(num))
    {
        if(X<=0)
            K=-K;
        cout<<abs(X-K*D)<<endl;
    }
    else
    {
        if(X<=0)
            n=m+D;
        else
            n=m-D;
        num1=K-abs(num);
        if(num1%2==0)
            cout<<abs(m)<<endl;
        else
            cout<<abs(n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var d string
	fmt.Scan(&d)
	switch d {
	case "25":
		fmt.Println("Christmas")
	case "24":
		fmt.Println("Christmas Eve")
	case "23":
		fmt.Println("Christmas Eve Eve")
	case "22":
		fmt.Println("Christmas Eve Eve Eve")
	}
}


Measured memory_bytes: 1768
# https://atcoder.jp/contests/abc108/tasks/abc108_b

x1, y1, x2, y2 = map(int, input().split())

x = x2 - x1
y = y2 - y1

print("{} {} {} {}".format(x2 - y, y2 + x, x1 - y, y1 + x))


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    char a;

    scanf("%c", &a);

    if( ( a >= 'A' ) && ( a <= 'Z' ) ) {
        printf("A\n");
        return 0;
    }

    printf("a\n");
    return 0;
}


Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    vector<int> testcases(m);
    rep(i,m) scanf("%d", &testcases.at(i));
    int ans = 0;
    rep(i,n) {
        int score = 0;
        rep(j,m) {
            int particularity;
            scanf("%d", &particularity);
            score += testcases.at(j)*particularity;
        }
        score += c;
        if (score > 0) ans++;
    }
    printf("%d\n", ans);
}

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

int main() {
  int k,n;
  cin >> k >> n;
  vector<int> a(n);

  int max_n = 0;
  for (int i=0;i<n;i++){
    cin >> a[i];
    if(i>0){
      max_n = max(max_n,a[i]-a[i-1]);
      // cout << max_n << endl;
    }
  }
  max_n = max(max_n,k-a[n-1]+a[0]);
  // cout << max_n << endl;

  cout << k - max_n << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A, B;
  long E;
  long ans;
  cin >> A >> B;
  for(long i = min(A,B); i > 0; i--){
    if(A % i == 0 && B % i == 0){
      E = i;
      break;
    }
    E = 1;
  }
  ans = (A/E) * (B/E) * E;
  cout << ans << endl;
}

Measured memory_bytes: 3656
from collections import deque 

h,w = map(int,input().split())
maze = [list(input()) for _ in range(h)]

# print(maze)

max_step = 0
moves = [[1,0], [0,1], [-1,0], [0,-1]]

# i,j をスタート地点に幅優先探索
for i in range(h):
    for j in range(w):
        if maze[i][j] == '#':
            continue

        visited = [[-1]*w for _ in range(h)]
        visited[i][j] = 0
        next_step = deque([[i,j]])

        while next_step:
            now_step = next_step.popleft()
            for move in moves:
                nh = now_step[0]+move[0]
                nw = now_step[1]+move[1]
                if 0<=nh<h and 0<=nw<w and maze[nh][nw] == '.' and visited[nh][nw] == -1:
                    visited[nh][nw] = visited[now_step[0]][now_step[1]] + 1
                    next_step.append([nh,nw])

        for tmp in visited:
            max_step = max(max_step, max(tmp))

print(max_step)


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

int main() {
  // int A, H;
  // cin >> H >> A;
  // int ans = H / A;
  // if (H % A != 0) {
  //   cout << ans + 1 << endl;
  // } else {
  //   cout << ans << endl;
  // }

  int H, N;
  cin >> H >> N;
  vector<int> A(N, 0);
  for (int i; i < N; i++) {
    int val;
    cin >> val;
    A.at(i) = val;
    H = H - val;
  }
  if (H <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 640
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
a4,b4=map(int,input().split())
a5,b5=map(int,input().split())
a6,b6=map(int,input().split())
a7,b7=map(int,input().split())

print(a1-b1)
print(a2-b2)
print(a3-b3)
print(a4-b4)
print(a5-b5)
print(a6-b6)
print(a7-b7)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	string s, t, u;
	ll a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
}


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

int main() {
   int h,n;
   cin >> h >> n;
   int cnt = 0;
   rep(i,n) {
       int k;
       cin >> k;
       cnt+=k;
   }
   string ans = "No";
   if (cnt >= h) ans="Yes";
   cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 0614: Railroad Trip
// 2017.10.29 bal4u@uu

#include <stdio.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))

int p[100005], a[100005], b[100005], c[100005];
int f[100005];

char buf[700105], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, m, i;
	long long ans, cash, ic;

	fgets(bp=buf, 32, stdin), n = getint(), bp++, m = getint();
	fgets(bp=buf, 700100, stdin);
	for (i = 0; i < m; i++) p[i] = getint(), bp++;
	for (i = 0; i < n-1; i++){
		fgets(bp=buf, 128, stdin);
		a[i] = getint(), bp++, b[i] = getint(), bp++, c[i] = getint();
	}
	for (i = 0; i < m-1; i++) {
		int t, u = p[i]-1, v = p[i+1]-1;
		if (u > v) t = u, u = v, v = t;
		f[u]++, f[v]--;
	}
	for (i = 1; i < n; i++) f[i] += f[i-1];

	for (ans = 0, i = 0; i < n-1; i++) {
		cash = (long long)a[i] * f[i];
		ic = (long long)b[i] * f[i] + c[i];
		ans += MIN(cash, ic);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4356
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
import std.numeric;
bool area(double[2] p1, double[2] p2, double[2] p3){
	double[2] px1 = [p2[0]-p1[0],p2[1]-p1[1]];
	double[2] px2 = [p3[0]-p1[0],p3[1]-p1[1]];
	return (px1[1]*px2[0]-px1[0]*px2[1]) < 0;
}
void main() {
	string s;
	while( (s=readln().strip()).length != 0 ){
		auto i = s.split(',').map!(to!double)().array();
		bool f0=area([i[0],i[1]],[i[2],i[3]],[i[4],i[5]]);
		bool f1=area([i[0],i[1]],[i[4],i[5]],[i[6],i[7]]);
		bool f2=area([i[2],i[3]],[i[4],i[5]],[i[6],i[7]]);
		bool f3=area([i[2],i[3]],[i[6],i[7]],[i[0],i[1]]);
		bool f4=area([i[4],i[5]],[i[6],i[7]],[i[0],i[1]]);
		bool f5=area([i[4],i[5]],[i[0],i[1]],[i[2],i[3]]);
		bool f6=area([i[6],i[7]],[i[0],i[1]],[i[2],i[3]]);
		bool f7=area([i[6],i[7]],[i[2],i[3]],[i[4],i[5]]);
		if(f0==f1&&f1==f2&&f2==f3&&f3==f4&&f4==f5&&f5==f6&&f6==f7) writeln("YES");
		else writeln("NO");
	}
}

Measured memory_bytes: 2496
//30分
import java.util.Arrays;
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] n = new int[N];
		int[] x = new int[N];
		int[] y = new int[N];

		for(int i=0; i<N; i++) {
			n[i] = i;
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		double sum = 0;
		//順列全探索
		for(int i=0; i<factorial(N); i++) {
			for(int j=0; j<N-1; j++) {
				sum += Math.sqrt((x[n[j]] - x[n[j+1]])*(x[n[j]] - x[n[j+1]]) + (y[n[j]] - y[n[j+1]])*(y[n[j]] - y[n[j+1]]));
			}
			next_permutation(n, 0, n.length);
		}

		double ans = sum / factorial(N);

		System.out.println(ans);
	}

	//階乗
	static int factorial(int n) {
		if(n == 1)
			return 1;

		return n * factorial(n-1);
	}

	//次の順列を生成する
	static boolean next_permutation(int[] array, int start, int end) {

		if(array == null || start > end || start < 0 || end > array.length) {
			System.out.println("Error: 引数が正しくありません。");
			return false;
		}

		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}

}


Measured memory_bytes: 23764