akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = inputLongArray[0];
            var a = inputLongArray[1];
            var b = inputLongArray[2];
            string str = Console.ReadLine();
            string[] strArray = new string[str.Length];
            for (var i = 0; i < str.Length; i++)
            {
                strArray[i] = str.Substring(i, 1);
            }
            var countA = 0;
            var countB = 0;
            for (var i = 0; i < n; i++)
            {
                if (strArray[i] == "a" && countA + countB < a + b)
                {
                    Console.WriteLine("Yes");
                    countA++;
                }
                else if (strArray[i] == "b" && countA + countB < a + b && countB < b)
                {
                    Console.WriteLine("Yes");
                    countB++;
                }
                else Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 31700
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
const double E=exp(1);
const int maxn=1e6+10;
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	int flag=0;
	cin>>n;
	while(n>=4)
	{
		if(n%4==0||n%7==0)
		{
			flag++;
			break;
		}
		n-=7;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int L;
  cin >> L;
  cout << fixed << setprecision(10);
  cout << (double) L * L * L / 27 << endl;
}


Measured memory_bytes: 3768
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    for(int i=1;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    int cnt[n] = {0};
    for(int i=1;i<n;i++){
        cnt[a[i]]++;
    }
    for(int i=0;i<n;i++)
        cout<<cnt[i]<<endl;
    return 0;
}



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

const int MAX = 1000100;
const int INF = 1<<29;

int main() {
    vector<int> dp(MAX, INF), odddp(MAX, INF);
    dp[0] = odddp[0] = 0;
    for (int i = 1;; ++i) {
        int num = i * (i+1) * (i+2) / 6;
        if (num >= MAX) break;
        for (int j = num; j < MAX; ++j) {
            dp[j] = min(dp[j], dp[j-num]+1);
            if (num & 1) odddp[j] = min(odddp[j], odddp[j-num]+1);
        }
    }
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << dp[n] << " " << odddp[n] << endl;
    }
}


Measured memory_bytes: 10580
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n);
  fill(cnt.begin(), cnt.end(), 0);
  rep(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  bool enable = true;
  if(cnt[0] > 1) enable = false;
  rep1(i, n) {
    if(cnt[i] > 2) enable = false;
  }
  if(!enable) {
    cout << 0 << endl;
    return 0;
  }

  int cnt2 = 0;
  rep(i, n) {
    if(cnt[i] == 2) cnt2++;
  }
  int ans = 1;
  rep(i, cnt2) {
    ans = (ans * 2) % MOD;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1024
import math
n=int(input())

def make_divisors(n):
  divisors=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      divisors.append(i)
      if i!=n//i:
        divisors.append(n//i)
  divisors.sort()
  return divisors
a=make_divisors(n)
if len(a)%2==1:
  print(2*int(math.sqrt(n))-2)
if len(a)%2==0:
  b=a[len(a)//2-1]
  c=a[len(a)//2]
  print(b+c-2)

Measured memory_bytes: 3288
#include "stdio.h"

int main(void){
    int sec;
    int min;
    int hrs;
    scanf("%d", &sec);
    
    hrs = sec/3600;
    sec -= hrs * 3600;
    
    min = sec/60;
    sec -= min*60;
    
    printf("%d:%d:%d\n", hrs, min,sec);
    return 0;
}

Measured memory_bytes: 592
N=int(input())
L=list(map(int, input().split()))
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                if max(L[i],L[j],L[k])<L[i]+L[j]+L[k]-max(L[i],L[j],L[k]):
                    count += 1
                else:
                    pass

print(count)



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, s0, s1;
    cin >> s;
    
    int x = 0;
    for (int i = 0; i < s.length(); i++){
        s0 += '0' + x;
        s1 += '0' + (x^1);   
        x ^= 1;
    }

    int c0 = 0, c1 = 0;
    for (int i = 0; i < s.length(); i++){
        if (s[i] != s0[i])
            c0 += 1;
        
        if (s[i] != s1[i])
            c1 += 1;
    }

    cout << min(c0, c1) << '\n';
    
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int N;
long long A[200000];
long long res;

void load(void);
void calc(void);
void output(void);

int main(){
	load();
	calc();
	output();
	return 0;
}

void load(void){
	int i;
	cin >> N;
	for(i = 0;i < N;i++){
		cin >> A[i];
	}
}

void calc(void){
	int i;
	sort(A, A + N, greater<>());
	for(i = 0;i < N - 1;i++){
		res += A[(int)((i + 1)/2)];
	}
}

void output(void){
	cout << res << endl;
}

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

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

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

  string s,t;
  cin >> s >> t;

  rep(i,n){
    int same=n-i;

    bool check=true;
    rep(j,same){
      if(s.at(n-same+j)!=t.at(j)){check=false; break;}
    }

    if(check){cout<<n*2-same; return 0;}
  }

  cout << n*2;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();
		int  ans = A1 + A2 + A3;
		
		if(ans >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}



   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		
		if (n % k != 0) {
			ans = 1;
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = sum(w)
    for i in range(n):
        w1 = []
        w2 = []
        for j in range(n):
            if j <= i:
                w1.append(w[j])
            else:
                w2.append(w[j])
        tmp = abs(sum(w1) - sum(w2))
        if tmp < ans:
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()


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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, M, K;

int main(void)
{
    cin >> N >> M >> K;

    bool flag = false;
    for (int i = 0; i <= N; ++i) {
        for (int k = 0; k <= M; ++k) {
            // 横
            int ans = i * M;

            // 縦
            ans += k * (N - i);
            ans -= k * (i);

            if (ans == K) {
                flag = true;
                break;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

void solve(){
	int n; scanf("%d", &n);
	int c = 0;
	while(n--){
		int x; scanf("%d", &x);
		c += (x&1);
	}
	printf("%s\n", (c&1) ? "NO" : "YES");
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

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

int main(){
	int w,n,wnum[31];
	for(int i = 0; i <= 30; i++){
		wnum[i] = i;
	}
	cin >> w >> n;
	for(int i = 0; i < n; i++){
		int a,b;
		char comma;
		cin >> a >> comma >> b;
		swap(wnum[a],wnum[b]);
	}
	for(int i = 1; i <= w; i++){
		cout << wnum[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  ll sum=0;
  for(ll i=1;i<=N;i++){
    if(i%3==0||i%5==0){
      continue;
    }
    sum+=i;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
	int n;
	string s;
	while (cin >> n, n) {
		cin >> s;
		int i, j, k;
		for (i = 0; i < n; ++i) {
			string tmp = "";
			for (j = 0; j < (int)s.size(); j = k) {
				int cnt = 0;
				for (k = j; s[j] == s[k]; ++k) cnt++;
				char sub[100];
				sprintf(sub, "%d", cnt);
				tmp += sub;
				tmp += s[j];
			}
			s = tmp;
		}
		cout << s << endl;
	}
}

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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n,m,c;
    cin>>n>>m>>c;
   // vector<vector<int>> A(n, vector<int> (m));
    vector<int> B(m);

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

    int count = 0;
    for(int i = 0; i < n; i++) {
    	long long sum = 0;
    	for(int j = 0; j < m; j++) {
    		int x;
    		cin>>x;
    		//A[i][j] = x;
    		sum += x * B[j];
    	}

    	//cout<<sum<<endl;
    	sum += c;
    	//cout<<sum<<endl;
    	if(sum > 0)
    		count++;
    }

    cout << count;



	return 0;		
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int x;
  cin>>x;
  if(x==7 || x==5 || x==3){
    cout<<"YES"<<endl;
  }else cout<<"NO"<<endl;
}


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

const ll INF = 1LL << 60;
vector<ll> dp(100010,INF);
vector<ll> h(100010);

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 rec(int i) {
    if(dp[i] != INF) return dp[i];
    if(i == 0) return 0;
    ll res = INF;
    chmin(res,rec(i-1)+abs(h[i-1]-h[i]));
    if(i > 1)
    chmin(res,rec(i-2)+abs(h[i-2]-h[i]));
    return dp[i] = res;
}

int main() {
    int N; cin >> N;
    rep(i,N) cin >> h.at(i);

    cout << rec(N-1) << endl;

}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int k;
    string s;
    cin >> k >> s;
    if(s.length()<=k){
        c(s);
    }else{
        string str = s.substr(0, k );
        str += "...";
        c(str);
    }
}


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

int main(){
   int r;
   cin >> r;
   cout << setprecision(20) << 2 * 3.1415926 * r << endl;
}

Measured memory_bytes: 3784
def listcut(array):
    res = []
    kar = []
    for i in range(len(array)):
        if array[i] == 0:
            if len(kar) != 0:
                res.append(kar)
            kar = []
        else:
            kar.append(array[i])
    if len(kar) != 0:
        res.append(kar)
    return res


n = int(input())
h = list(map(int, input().split()))
kai = 0
wak = [h]
while wak != []:
    t = []
    for i in range(len(wak)):
        m = min(wak[i])
        kai += m
        k = list(map(lambda x: x - m, wak[i]))
        s = listcut(k)
        if s != []:
            t += s
    wak = t
print(kai)

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

int main(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      int N;
      cin >> N;
      vector<int> P(pow(N,2));
      for (int i = 0; i < pow(N, 2); i ++){
            cin >> P[i];
            P[i] -= 1;
      }
      vector<int> move = {-1, 0, 1, 0};

      vector<vector<int>> fin(N, vector<int>(N));
      vector<vector<int>> dist(N, vector<int>(N));
      for (int i = 0; i < N; i++){
            for (int j = 0; j < N; j++){
                  dist[i][j] = min(min(i, N-i-1), min(j, N-j-1));
                  fin[i][j] = 1;
            }
      }
      int x, y, dx, dy, nx, ny;
      queue<pair<int, int>> q;
      int count = 0;
      for (int i = 0; i < pow(N, 2); i++){
           x = P[i] / N;
           y = P[i] % N;
           count += dist[x][y];
           fin[x][y] = 0;
           for (int m = 0; m < 4; m++){
                 dx = move[m];
                 dy = move[(m+1) % 4];
                 if (0<=x+dx and x+dx<N and 0<=y+dy and y+dy<N){
                       if (dist[x][y] < dist[x+dx][y+dy]){
                             dist[x+dx][y+dy] = dist[x][y];
                             pair<int, int> xy = {x+dx, y+dy};
                             q.push(xy);
                        }  
                  }
            }
      
           while (!q.empty()){
                 pair<int, int> np = q.front();
                 nx = np.first;
                 ny = np.second;
                 q.pop();
                 for (int m = 0; m < 4; m++){
                        dx = move[m];
                        dy = move[(m+1) % 4];
                        if (0<=nx+dx<N && 0<=ny+dy<N){
                              if (dist[nx][ny]+fin[nx][ny] < dist[nx+dx][ny+dy]){
                                   dist[nx+dx][ny+dy] = dist[nx][ny]+fin[nx][ny];
                                   pair<int, int> xy = {nx+dx, ny+dy};
                                   q.push(xy);
                              }
                        }
                  }
            }
      }
      cout << count << '\n';
      return 0;
}

Measured memory_bytes: 6024
a = [int(i) for i in input().split()]

b1 = abs(a[0] - a[1]) + abs(a[1] - a[2])
b2 = abs(a[1] - a[2]) + abs(a[2] - a[0])
b3 = abs(a[2] - a[0]) + abs(a[0] - a[1])
b4 = abs(a[0] - a[2]) + abs(a[2] - a[1])
b5 = abs(a[1] - a[0]) + abs(a[0] - a[2])
b6 = abs(a[2] - a[1]) + abs(a[1] - a[0])

print(min([b1, b2, b3, b4, b5, b6]))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  ll n;
  cin >> n;
  vector<ll> vec;
  for (ll i = 1; i <= (ll)(sqrt(n)); i++) {
    if (n % i == 0) {
      ll j = n / i;
      ll tmp = max(i, j);
      vec.push_back((to_string(tmp)).size());
    }
  }
  vector<ll>::iterator iter = min_element(all(vec));
  cout << *iter << endl;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    let mut primes: Vec<i64> = vec![];
    let mut sieve = vec![true; 31623];

    for i in 2..sieve.len() {
        if sieve[i] {
            primes.push(i as i64);
            let mut j = i + i;
            while j < sieve.len() {
                sieve[j] = false;
                j += i;
            }
        }
    }

    input! {
        n: usize,
        a: [i64; n],
    }

    let mut m = HashMap::new();

    for a in a {
        let mut a = a;
        let mut fs = vec![];

        for &p in primes.iter() {
            if p * p > a {
                break;
            }

            let mut cnt = 0;
            while a % p == 0 {
                a /= p;
                cnt += 1;
            }
            if cnt > 0 {
                fs.push((p, cnt));
            }
        }

        if a > 1 {
            fs.push((a, 1));
        }

        // println!("{}: {:?}", a, fs);

        rec(0, 1, &fs, &mut m);
    }

    // println!("{:?}", m);

    let mut ans = 1;

    for (k, cnt) in m {
        if cnt >= n - 1 {
            ans = std::cmp::max(ans, k);
        }
    }

    println!("{}", ans);
}

fn rec(i: usize, acc: i64, fs: &[(i64, usize)], m: &mut HashMap<i64, usize>) {
    if i >= fs.len() {
        *m.entry(acc).or_insert(0) += 1;
        return;
    }

    let mut t = acc;
    for _ in 0..fs[i].1 + 1 {
        rec(i + 1, t, fs, m);
        t *= fs[i].0;
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
 
int main(void) {
	int a,b,c,d,L,R;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	L = a+b;
	R = c+d;
 
	if(L>R) printf("Left");
	else if(L==R) printf("Balanced");
	else if(L<R) printf("Right");
 
	return 0;
}

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

int main() {
    int m, d, M, D;
    cin >> m >> d >> M >> D;

   if (m < M) cout << "1" << endl;
   else cout << "0" << endl;
}

Measured memory_bytes: 256
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: usize = input.next().unwrap().parse().unwrap();
    let mut in_h: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    let mut ans = 0;
    while in_h.iter().max().unwrap() > &0 {
        let mut i = 0usize;
        while i < in_n {
            if in_h[i] > 0 {
                ans += 1;
                while i < in_n && in_h[i] > 0 {
                    in_h[i] -= 1;
                    i += 1;
                }
            }
            i += 1;
        }
    }
    writeln!(out, "{}", ans).ok();
}


Measured memory_bytes: 8572
#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 int MAX = 2 * 100000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

int A[MAX];
void sim(string& s)
{
	int p = 0;
	int d = 1;
	while (1)
	{
		if (p == -1 || p == SZ(s)) break;
		if (s[p] == 'A')
		{
			s[p] = 'B';
			d *= -1;
			p += d;
			continue;
		}
		else
		{
			s[p] = 'A';
			p += d;
		}
	}
}

void sim(string& s, int k)
{
	FOR(i, 0, k)
	{
		sim(s);
	}
}

void calc(string& s, int k)
{
	int rev = 0;
	int p = 0;
	int n = SZ(s);
	if (n == 1)
	{
		s[0] = ((s[0] - 'A') ^ (k & 1)) + 'A';
		return;
	}

	FOR(i, 0, n) A[i] = s[i] == 'B';

	FOR(i, 0, min(k, 4 * n + k % 2))
	{
		if (A[p] ^ rev == 0)
		{
			A[p] ^= 1;
			continue;
		}

		rev ^= 1;
		A[p] = rev;
		p++;
		if (p == n) p = 0;
	}

	FOR(k, 0, n)
	{
		int i = p + k;
		if (i >= n) i -= n;

		s[k] = (A[i] ^ rev) + 'A';
	}
}

string s;
int k, n;
void gen()
{
	n = rand() % 10 + 1;
	s.clear();
	FOR(i, 0, n)
	{
		s.push_back(rand() % 2 + 'A');
	}

	k = rand() % 10 + 1;
}

//#define TEST

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

#ifdef TEST
	while (1)
	{
		gen();
		cout << s << " " << k << endl;
		string s1 = s;
		calc(s, k);
		sim(s1, k);
		if (s1 != s)
		{
			cout << "fail" << endl;
			cout << s << endl;
			cout << s1 << endl;
			return 0;
		}
	}
#else
	cin >> n >> k >> s;
	calc(s, k);
	cout << s << endl;
#endif

}

Measured memory_bytes: 1532
N , K = map(int,input().split())

def afterdiceprob(x):
    flag = True
    y = 0
    while(flag):
        if x*2**y >= K:
            break
        y += 1
    return y

sum = 0
kmax = 0
for k in range(1,N+1):
    sum += (1/N)*(1/2)**afterdiceprob(k)
print(sum)

Measured memory_bytes: 3060
#include <stdio.h>

const int month_day[10] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
int get_day_index(int y, int m, int d)
{
    int i, ans = 0;

    for (i = 1; i < y; ++i) {
        if (i % 3 == 0)
            ans += 20 * 10;
        else
            ans += 20 * 5 + 19 * 5;
    }

    for (i = 1; i < m; ++i) {
        if (y % 3 == 0)
            ans += 20;
        else
            ans += month_day[i - 1];
    }

    ans += d;

    return ans;
}

int main(void)
{
    int n, i;

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

        scanf("%d %d %d", &y, &m, &d);

        printf("%d\n", get_day_index(1000, 1, 1) - get_day_index(y, m, d));
    }

    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int a,b,c;

/*
 *関数
 */
int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

/*
 *解 
 */
void solve(){
    if(b/a>c)printf("%d",c);
    else printf("%d",b/a);
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>a>>b>>c;
       solve();
       return 0;
}

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

using namespace std;

void solve()
{
	vector<string> s(3);
	for (int i = 0; i < 3; ++i)
	{
		cin >> s[i];
	}
	vector<int> pos(3);
	int pos_index = 0;
	while (true)
	{
		if (pos[pos_index] == s[pos_index].size())
		{
			break;
		}
		if (s[pos_index][pos[pos_index]] == 'a')
		{
			++pos[pos_index];
			pos_index = 0;
		}
		else if (s[pos_index][pos[pos_index]] == 'b')
		{
			++pos[pos_index];
			pos_index = 1;
		}
		else if (s[pos_index][pos[pos_index]] == 'c')
		{
			++pos[pos_index];
			pos_index = 2;
		}
	}
	if (pos_index == 0)
	{
		cout << "A" << endl;
	}
	else if (pos_index == 1)
	{
		cout << "B" << endl;
	}
	else
	{
		cout << "C" << endl;
	}
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[13][100021] = {};
int main() {
	string s;
	cin >> s;
	dp[0][0] = 1;
	long long int keta = 1;
	long long int sum = 0;
	for (int i = s.size()-1; i >=0; i--) {
		if (s[i] == '?') {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 13; k++) {
					dp[(j * keta + k) % 13][sum + 1] = (dp[(j * keta + k) % 13][sum + 1] + dp[k][sum]) % MOD;
				}
			}
		}
		else {
			int number = s[i] - '0';
			for (int k = 0; k < 13; k++) {
				dp[(number * keta + k) % 13][sum + 1] = dp[k][sum] % MOD;
			}
		}

		keta = keta * 10 % 13;
		sum = sum + 1;
	}
	cout << dp[5][s.size()];
}

Measured memory_bytes: 6656
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
if n==1:
	if m==1:
		print(1)
		exit()
	print(m-2)
	exit()
if m==1:
	print(n-2)
	exit()

print(n*m-(2*n+2*m-4))

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int n, r;
    in2(n, r);
    if (n <= 10)
    {
        r += 100 * (10 - n);
    }
    out(r);
}

Measured memory_bytes: 256
from collections import Counter
mod = 998244353
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
    print(0)
    exit()

C = Counter(d)
C = dict(sorted(C.items()))

memo1 = C[1]
memo2 = 1
ans = 1

for i in range(1,n):
    if d[i] == 0:
        print(0)
        exit()

for key in C:
    if key >= 2:
        if memo2 + 1 != key: #道が途切れている場合はダメ
            print(0)
            exit()
        ans = (ans * memo1 ** C[key]) % mod #modは和について閉じているため先にわる
        memo1 = C[key]
        memo2 = key
print(ans)
    

Measured memory_bytes: 35368
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int K, A, B;
    cin >> K >> A >> B;

    cout << (A % K == 0 || (B - A >= K) || A % K > B % K ? "OK" : "NG") << endl;
    
    
    return 0;
}

Measured memory_bytes: 3608
N = gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
grouped = array.group_by {|i| i%4}
n4=(grouped[0] || []).length
n2=(grouped[2] || []).length
n1=N-n4-n2
puts (n4>=n1 || n4+1==n1 && n2==0) ? 'Yes' : 'No'


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long a, b, c, d;
  cin >> a >> b >> c >>d;
  cout << max({a * d, a * c, b * d, b * c}) <<endl;
}


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

int main(){
	int i,j,n,A,B,C,D,num[4],ans;
	string s[3];
	cin >> n;
	A = n/1000;
	B = (n - 1000*A)/100;
	C = (n - 1000*A - 100*B)/10;
	D = n%10;
	num[0] = A;
	num[1] = B;
	num[2] = C;
	num[3] = D;
	ans = num[0];
	for(i=0;i<(1<<3);i++){
		for(j=0;j<3;j++){
			if(i&(1<<j)){
				ans += num[j+1];
				s[j] = "+";
			}else{
				ans -= num[j+1];
				s[j] = "-";
			}
		}
		if(ans == 7){
			cout << num[0] << s[0] << num[1] << s[1] << num[2] << s[2] << num[3] <<"=7"<< endl;
		break;
		}
	ans = num[0];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

vvc<pair<ll,ll>> yen(1e5+7,vc<pair<ll,ll>>()); // pair<行先,コスト>
vvc<pair<ll,ll>> snu(1e5+7,vc<pair<ll,ll>>());

ll dij(int start, int goal, vvc<pair<ll,ll>> to, vc<ll> &dist){
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> q; //pair<距離,点>
    q.push(make_pair(0, start));
    dist[start] = 0;
    
    while (q.size()) {
        ll pos = q.top().second; q.pop();
        for (pair<ll,ll> p: to[pos]){
            ll des = p.first, cost = p.second;
            if (dist[des] > dist[pos] + cost){
                //すでに最小値でない場合はqueueに入れない
                dist[des] = dist[pos] + cost;
                q.push(make_pair(dist[des], des));
            }
        }
    }
    if (dist[goal] == INF) return -1;
    return dist[goal];
}

int main(){
    cout << fixed << setprecision(20);
    int n,m,s,t; cin >> n >> m >> s >> t;
    s--; t--;
    ll max = 1e15;
    rep(i,m){
        int a,b,c,d; cin >>a>>b>>c>>d;
        a--; b--;
        yen[a].eb(make_pair(b,c));
        yen[b].eb(make_pair(a,c));
        snu[a].eb(make_pair(b,d));
        snu[b].eb(make_pair(a,d));
    }
    vc<ll> ans(n);
    ll min = INF;
    vc<ll> dist1(1e5+7,INF);
    vc<ll> dist2(1e5+7,INF);
    dij(s,t,yen,dist1); dij(t,s,snu,dist2); //s->i , i<-t
    per(i,n){
        chmin(min,dist1[i]+dist2[i]);
        ans[i] = min;
    }
    rep(i,n) cout << max-ans[i] << endl;
    
    return 0;
}


Measured memory_bytes: 26004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll sum[101010];
int N;
ll M;
vector<int> A;

bool solve(int x){
  ll cnt=0;
  for(int i=0;i<N;i++){
    int j=lower_bound(A.begin(),A.end(),x-A[i])-A.begin();
    cnt+=N-j;
  }
  if(cnt>=M) return 1;
  else return 0;
}

int main(){
  cin>>N>>M;
  A.resize(N);
  rep(i,N){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  A.push_back(INT_MAX/2);
  for(int i=0;i<N;i++){
    sum[i+1]=sum[i]+A[i];
  }
  
  int ok=0,ng=1e9;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  ll ans=0,cnt=0;
  for(int i=0;i<N;i++){
    int j=upper_bound(A.begin(),A.end(),ok-A[i])-A.begin();
    cnt+=N-j;
    ans+=sum[N]-sum[j]+1LL*A[i]*(N-j);
  }
  ans+=(M-cnt)*ok;
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k,s;
    cin >> n >> k >> s;
    ll INF = 1e9;
    if(s < INF){
        for(i = 0;i < k;++i){
            cout << s << endl;
        }
        for(i = k;i < n;++i){
            cout << INF << endl;
        }
    }else{
        for(i = 0;i < k;++i){
            cout << s << endl;
        }
        for(i = k;i < n;++i){
            cout << 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
bool visited[200009];
int dis[200009];
vector<int>g[200009];
void DFS(int v,int dep)
{
    visited[v]=true;
    dis[v]=dep;
    for(int i=0;i<g[v].size();i++)
    {
        if(!visited[g[v][i]])
            DFS(g[v][i],dep+1);
    }
    return;
}

int main()
{
    int n,e,u,v,source;
    scanf("%d%d",&n,&e);
    while(e--)
    {
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }

    DFS(1,0);
        dis[n]==2?puts("POSSIBLE"):puts("IMPOSSIBLE");
    return 0;

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    b.push_back(100100);
    int ans = 0;

    ans += b[0];
    rep(i,n-1){
        ans += min(b[i], b[i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int n;

    cin >> n;

    if(n%2 == 0)cout << n;
    else cout << n * 2;

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, t;

int main() {
    cin >> n;
    int N = 1;
    int a = 2;
    int b = n;
    while (b) {
        if (b & 1) {
            N *= a;
        }
        a = a * a;
        b >>= 1;
    }
    int mx = 0;
    multiset<int> st;
    for (int i = 0; i < N; ++i) {
        cin >> t;
        st.insert(t);
        mx = max(mx, t);
    }
    vector<int> v(N);
    v[0] = mx;
    int len = 1;
    st.erase(st.find(mx));
    while (len < N) {
        int j = len;
        for (int i = 0; i < len; ++i) {
            auto it = st.lower_bound(v[i]);
            if (it == st.begin()) {
                cout << "No" << endl;
                exit(0);
            }
            --it;
            v[j++] = *it;
            st.erase(it);
        }
        len *= 2;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 16968
#include<stdio.h>
#define N 10000
#define Q 500




int main(){
  int i, j, n, q, ans=0, S[N], T[Q];

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
  scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
  scanf("%d",&T[i]);
  }

    for(j=0 ; j<q ; j++){
      i=0;
      S[n] = T[j];
      while(S[i] != T[j] ){
	i++;
      }
    if(i != n){
     
      ans++;
    }
    }

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






Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=100005;
ll ans[N];
void solve()
{
	ll n,dp[N],dp2[N],i;
	string s;
	cin>>s;
	n=s.length();
	dp[n-1]=n-1;
	for(i=n-2;i>=0;i--)
		if(s[i]=='L')
			dp[i]=i;
		else
			dp[i]=dp[i+1];
	dp2[0]=0;
	for(i=1;i<n;i++)
		if(s[i]=='R')
			dp2[i]=i;
		else
			dp2[i]=dp2[i-1];
	for(i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			if((dp[i]-i)&1)
				ans[dp[i]-1]++;
			else
				ans[dp[i]]++;
		}
		else
		{
			if((i-dp2[i])&1)
				ans[dp2[i]+1]++;
			else
				ans[dp2[i]]++;
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i]<<" ";
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 3024
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"os"
	"strings"
	"unicode"
)

type Input struct {
	lines [][]string // Input は複数行からなる文字列から値をいい感じに取り出すためのメソッドを提供します.

}

func (i *Input) GetFirstValue(rowIndex int) (string, error) {
	return i.GetValue(rowIndex, 0)
}
func (i *Input) GetLine(index int) ([]string, error) {
	if err := i.validateRowIndex(index); err != nil {
		return nil, err
	}
	return i.lines[index], nil
}
func (i *Input) GetValue(rowIndex, colIndex int) (string, error) {
	line, err := i.GetLine(rowIndex)
	if err != nil {
		return "", err
	}
	if colIndex < 0 || colIndex >= len(line) {
		return "", fmt.Errorf("Invalid col index: %v ", colIndex)
	}
	return line[colIndex], nil
}
func (i *Input) MustGetFirstValue(rowIndex int) string {
	_v0, _err := i.GetFirstValue(rowIndex)
	if _err != nil {
		panic(_err)
	}
	return _v0
}
func (i *Input) validateRowIndex(index int) error {
	if index >= len(i.lines) {
		return errors.New(fmt.Sprintf("index(%d) is larger than lines(%d)", index, len(i.lines)))
	}
	if index < 0 {
		return errors.New(fmt.Sprintf("index is under zero: %d", index))
	}
	return nil
}
func lib_MustNewInputFromReader(reader *bufio.Reader) *Input {
	_v0, _err := lib_NewInputFromReader(reader)
	if _err != nil {
		panic(_err)
	}
	return _v0
}
func lib_NewInputFromReader(reader *bufio.Reader) (*Input, error) {
	lines, err := lib_toLinesFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("failed to create new Input from reader: %v", err)
	}
	return &Input{lines: lines}, nil
}
func lib_TrimSpaceAndNewLineCodeAndTab(s string) string {
	return strings.TrimFunc(s, func(r rune) bool {
		return r == ' ' || r == '\r' || r == '\n' || r == '\t'
	})
}
func lib_readLineAsChunks(reader *bufio.Reader) (chunks []string, err error) {
	for {
		chunk, isPrefix, err := reader.ReadLine()
		if err != nil {
			return nil, err
		}
		chunks = append(chunks, string(chunk))
		if !isPrefix {
			return chunks, nil
		}
	}
}
func lib_toLinesFromReader(reader *bufio.Reader) (lines [][]string, err error) {
	for {
		chunks, err := lib_readLineAsChunks(reader)
		if err == io.EOF {
			return lines, nil
		}
		if err != nil {
			return nil, fmt.Errorf("failed to read line from reader: %v", err)
		}
		lineStr := lib_TrimSpaceAndNewLineCodeAndTab(strings.Join(chunks, ""))
		line := strings.Split(lineStr, " ")
		lines = append(lines, line)
	}
}
func main() {
	input := lib_MustNewInputFromReader(bufio.NewReader(io.Reader(os.Stdin)))
	fmt.Println(solve(input))
}
func solve(input *Input) string {
	a := []rune(input.MustGetFirstValue(0))[0]
	if unicode.IsUpper(a) {
		return "A"
	} else {
		return "a"
	}
}


Measured memory_bytes: 1740
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in [0]*D]
    ans = [int(input()) for _ in [0]*D]

    def calc_score(ans):
        score = 0
        last = [-1]*26
        for d in range(D):
            ct = ans[d]-1  # 開くコンテスト
            score += s[d][ct]
            last[ct] = d
            for j in range(26):
                score -= c[j]*(d-last[j])
            print(score)
        score = max(0, 10**6+score)
    calc_score(ans)


main()

Measured memory_bytes: 9256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,K; cin >> N >> K;
    vector<ll> p(N); for(auto& in:p) cin >> in;
    sort(p.begin(),p.end());
    res = accumulate(p.begin(),p.begin()+K,0LL);
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3664
x, y = gets.chomp.split(" ").map(&:to_i)

# 鶴の数:a  亀の数:b
#  a +  b =  x
# 2a + 4b =  y
    #   a = ( 4x - y) / 2
    #   b = (-2x + y) / 2

# a, b が0以上の正の整数でなければ不正？
# c, d が 0 ならば a, b は整数
#       c = ( 4x - y) % 2
#       d = (-2x + y) % 2
c = (4 * x - y) % 2
d = (-2 * x + y) % 2

a = (4 * x - y) / 2
b = (-2 * x + y) / 2

if c == 0 && d == 0 && a >= 0 && b >= 0
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 14284
n, m= map(int, input().split())

a =[]

for i in range(n):
  a.append(list(map(int, input().split())))
  a[i] += [sum(a[i])]
  print(*a[i])
  
a=list(zip(*a[::-1]))

for i in range(m):print(sum(a[i]),end=' ')

print(sum(a[m]))


Measured memory_bytes: 5768
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  f=False
  for x in l:
    if x%2==0:
      if x%3!=0 and x%5!=0:
        f=True

  if f:
    return 'DENIED'
  return 'APPROVED'

# main()
print(main())


Measured memory_bytes: 3436