akhauriyash/Code-Regression huggingface dataset:
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
//ここから始めよう
signed main(){
    int n;cin>>n;
    string  s;cin>>s;
    int a[40]={};
    rep(i,0,n*2){
        a[s[i]-'a']++;
    }
    rep(i,0,26){
        if(a[i]%2==1){
            cout<<0<<endl;
            return 0;
        }
    }
    vector<pair<string,string>>p,q;
    rep(i,0,1<<n){
        bitset<18>b(i);
        string st={},sn={},sa={},sb={};
        rep(j,0,n){
            if(b[j]==1){
                st+=s[j];sn+=s[j+n];
            }
            else{
                sa+=s[j];sb+=s[j+n];
            }
        }
        reverse(sn.begin(),sn.end());
        reverse(sb.begin(),sb.end());
        p.push_back(make_pair(st,sa));
        q.push_back(make_pair(sn,sb));
    }
    sort(p.begin(),p.end());sort(q.begin(),q.end());
    int ans=0;
    rep(i,0,p.size()){
        int h=upper_bound(q.begin(),q.end(),p[i])-lower_bound(q.begin(),q.end(),p[i]);
        ans+=h;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 64472
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)*}
    };
}
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)*}
    };
}
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        v: [isize; n],
        c: [isize; n],
    };
    let mut p = 0;
    for i in 0..n {
        let pro = v[i] - c[i];
        p += if pro>0 { pro } else {0};
    }

    println!("{}", p);

}



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


int solve(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans=0;
  if(a==b)  ans++;
  if(b==c)  ans++;
  if(c==a)  ans++;
  if(ans==1)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 1;
}

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


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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if ((i % 3 != 0) && (i % 5 != 0))
        {
            sum += 1LL * i;
        }
    }
    cout << sum << "\n";
    return 0;
}

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

int count(string x, string y) {
  map<char, bool> mpx;
  map<char, bool> mpy;
  for(char c : x) mpx[c] = true;
  for(char c : y) mpy[c] = true;
  
  int ans = 0;
  rep(i, 26) {
    char c = i + 'a';
    if(mpx[c] && mpy[c]) ++ans;
  }
  
  return ans;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 1; i < n; ++i) {
    string x = s.substr(0, i);
    string y = s.substr(i, n-i);
    
    ans = max(ans, count(x, y));
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n,k,r,s,p; cin>>n>>k>>r>>s>>p;
  string t; cin>>t;
  int res=0;
  vector<bool> ok(n, false);
  rep(i, n) {
    if (i-k>=0&&ok[i-k]&&t[i]==t[i-k]) continue;
    if (t[i]=='r') res+=p;
    if (t[i]=='s') res+=r;
    if (t[i]=='p') res+=s;
    ok[i]=true;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)

	ans := 0
	for i := 0; i <= n; i++ {
		for j := 0; i+j <= n; j++ {
			tmp := n - r*i - g*j
			if tmp >= 0 && tmp%b == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
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 = 1;
		for (int i = 0; i < n; i++) {
			ans = ans * 2 - ans < k ? ans * 2 : ans + k;
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
<?php 
$num = fgets(STDIN);
$array = explode(" ",fgets(STDIN));
$a = [];

foreach($array as $v){
    $a[] = intval($v);
}

$n = count($a);
print implode(' ', $a)."\n";
for($i=1;$i<$n;$i++){
  $tmp = $a[$i];
  for($j=$i-1;$j>=0&&$a[$j]>$tmp;$j--){
    $a[$j+1] = $a[$j];
  }
  $a[$j+1] = $tmp;
  print implode(' ', $a) . "\n";
}

?>


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
lli a[maxN];

lli memo[maxN][3];
lli solve(int i = 0, int jumps = n & 1 ? 2 : 1)
{
  if (i >= n) return 0;
  if (memo[i][jumps] != -1) return memo[i][jumps];

  lli ans = a[i] + solve(i + 2, jumps);
  if (jumps) ans = max(ans, solve(i + 1, jumps - 1));
  return memo[i][jumps] = ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class BPalace {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n,t,a;
	    in>>n>>t>>a;
	    vector<double> h(n);
	    rep(i,n) {
            int tmp;
	        in>>tmp;

	        h.at(i)=t-tmp*0.006;
	    }
	    pair<double ,int > ans;
	    ans.first=pow(10,5);
	    rep(i,n){
	        if(abs(ans.first-a)>abs(h.at(i)-a)){
	            ans.first=h.at(i);
	            ans.second=i+1;
	        }
	    }
	    out<<ans.second<<endl;

	}
};


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


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

int main() {
  int cell[3][3];
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      cin >> cell[i][j];
    }
  }
  int N;
  cin >> N;
  int number[N];
  for(int i=0; i<N; i++) {
    cin >> number[i];
  }
  
  int hole[3][3];
  
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      hole[i][j] =0;
    }
  }
  
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      for(int k=0; k<N; k++) {
        if(cell[i][j]==number[k]) {
          hole[i][j] =1;
        }
      }
    }
  }
  if (hole[0][0] + hole[1][0] + hole[2][0] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[0][1] + hole[1][1] + hole[2][1] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[0][2] + hole[1][2] + hole[2][2] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[0][0] + hole[0][1] + hole[0][2] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[1][0] + hole[1][1] + hole[1][2] ==3) {
    cout << "Yes" <<endl; 
  }
  else if (hole[2][0] + hole[2][1] + hole[2][2] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[0][0] + hole[1][1] + hole[2][2] ==3) {
    cout << "Yes" <<endl;
  }
  else if (hole[0][2] + hole[1][1] + hole[2][0] ==3) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    string s, t; cin >> s >> t;
    int sl, tl;
    sl = s.size();
    tl = t.size();

    for(int i=sl - tl; i>=0; i--){
        bool flg = false;
        FOR(j, 0, tl){
            if(!(s[i+j]=='?' || s[i+j]==t[j])){
                flg = true;
                break;
            }
        }

        if(flg) continue;

        rep(j, tl){
            s[i+j] = t[j];
        }
        rep(j, sl){
            if(s[j]=='?') s[j] = 'a';
        }
        pr(s);
        return 0;
    }
    pr("UNRESTORABLE");
    return 0;}

Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	vector<int> perm(N);
	for (int i = 0; i < N; ++i) {
		perm[i] = i;
	}
	sort(perm.begin(), perm.end(), [&](int i, int j) { return A[i] + B[i] > A[j] + B[j]; });
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0) ans += A[perm[i]];
		else ans -= B[perm[i]];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int x,y,r,tmp;

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

  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n", y);

  return 0;
}


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

using namespace std;

int main(){
  int N, X;
  cin >> X >> N;
  
  vector<int> p(N);
  set<int> s;
  for(int i = 0; i <= 10000; i++) s.insert(i);
  int diff = 10000;
  for(int i = 0; i < N; i++){
    cin >> p[i];
    s.erase(p[i]);
  }
  
  for(auto x : s){
    diff = min(abs(x - X), diff);
  }
  
  int min_p = 10000;
  for(auto x : s){
    if(abs(x - X) == diff){
      min_p = min(x, min_p);
    }
  }
  
  cout << min_p << endl;
  
  return 0;
}

Measured memory_bytes: 4068
'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const N = Number(input.shift());
  const heights = input[0].split(' ').map(v => parseInt(v, 10));
  let ans = true;

  for (let i = 0; i < N - 1; ++i) {
    const n1 = heights[i];
    const n2 = heights[i + 1];

    if (n1 < n2) heights[i + 1] -= 1;

    if (n2 - n1 < 0) {
      ans = false;
      break;
    }
  }

  answer(ans);
}

function answer(bool) {
  if (bool) console.log('Yes');
  else console.log('No');
}

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

Measured memory_bytes: 19404
function Main(input) {
  const lines = input.split('\n');
  const number = lines[0].split('').map(i => parseInt(i));
  const sum = number.reduce((a, b) => a + b);
  const flag = sum % 9 === 0;
  console.log(flag? 'Yes': 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main() {
  int n; cin >> n;
  string t; t="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  string s; cin >> s;
  
  for(int i=0; i < s.size(); i++){
    for(int j=0; j < 26; j++){
      if(s.at(i)==t.at(j)){
        s.at(i) = t.at(j+n);
        break;
      }
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] abc = new int[n][3];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				abc[i][j] = sc.nextInt();
			}
		}

		int[][] dp = new int[n][3];
		for (int i = 0; i < 3; i++) {
			dp[0][i] = abc[0][i];
		}

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				dp[i][j] = abc[i][j] + Math.max(
						dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
			}
		}
		System.out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
	}

}


Measured memory_bytes: 99572
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;



int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int i, j;
	LL N, K, s[60]={0}, dp[60][2]={0};

	cin >> N >> K;

	for (i = 0; i < N; i++) {
		LL a;
		cin >> a;

		for (j = 0; j < 50; j++) {
			if (a & (1ll << j)) {
				s[j]++;
			}
		}
	}
	reverse(s, s + 50);

	for (i = 0; i < 50; i++) {
		if (K & (1ll << (50 - i - 1))) {
			dp[i + 1][0] = dp[i][0] * 2 + N - s[i];
			dp[i + 1][1] = dp[i][0] * 2 + s[i];
		}
		else {
			dp[i + 1][0] = dp[i][0] * 2 + s[i];
		}
		if (dp[i][1] > 0) {
			dp[i + 1][1] =
				max(dp[i + 1][1], dp[i][1] * 2 + max(N - s[i], s[i]));
		}
	}
	cout << max(dp[50][0], dp[50][1]) << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n;
	cin >> n;
	int l[201];
	int k[101] = {};
	rep(i,2*n){
		cin >> l[i];
		k[l[i]]++;
	}
	ll ans = 0; bool flag = true;
	rep(i,101) {
		ans += (k[i]/2) * i;
		if(k[i]%2) {
			if(flag){
				ans += i;
			}
			flag = !flag;
		}
	}

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


Measured memory_bytes: 256
oList = list(input())
eList = list(input())
passList = [oList[0]]

for i in range(len(oList)-1):
    passList.append(eList[i])
    passList.append(oList[i+1])

if len(oList) == len(eList):
    passList.append(eList[-1])

print(''.join(passList))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

double expt(double n) {
  double tmp = 0;
  rep(i, n+1) tmp+=(double)i;
  return tmp/n;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<double> p(N+1,0);
  vector<int> sum(N+1,0);
  for(int i=1; i<=N; ++i) {
    cin >> p[i];
    sum[i] = sum[i-1]+p[i];
  }
  int max=0, maxIdx=0;
  for(int i=K; i<=N; ++i) {
    int tmp = sum[i]-sum[i-K];
    if(tmp > max) {
      max = tmp;
      maxIdx = i;
    }
  }
  double ans = 0;
  rep(i,K) {
    ans += expt(p[maxIdx-i]);
  }
  printf("%.10f", ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <utility>
#include <vector>
#include <stdint.h>
#include <set>

using namespace std;

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

  vector<uint64_t> X(N+1);
  set<uint32_t> A;

  for (unsigned m=0; m<M; ++m) {
    uint32_t a;
    cin >> a;
    A.insert(a);
  }

  X[0] = 1;
  X[1] = A.count(1) ? 0 : 1;
  for (unsigned n=2; n<=N; ++n) {
    if (A.count(n) == 1)
      X[n] = 0;
    else
      X[n] = X[n-1] + X[n-2];
    X[n] %= 1000000007;
  }
  
  cout << X[N] << endl;

  return 0;
}


Measured memory_bytes: 5760
from collections import defaultdict
N = int(input())
S = list(map(int, input().split()))
ans = 0
d = defaultdict(int)
for c in range(1, N):
    tmp = 0
    k = 0
    while (k + 1) * c < N - 1:
        if k * c == N - 1 - k * c:
            break
        if d[k * c] == c or d[N - 1 - k * c] == c:
            break
        d[k * c] = c
        d[N - 1 - k * c] = c
        tmp += S[k * c] + S[N - 1 - k * c]
        ans = max(ans, tmp)
        k += 1

print(ans)


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

const int m = 2019;

int main(){
    string s;
    cin >> s;
    size_t n = s.size();      
    reverse(s.begin(), s.end()); 
    vector<int> cnt(m);
    int x = 1, tot = 0;
    int ans = 0;
    rep(i,n){
        cnt[tot]++;
        tot += (s[i] - '0')*x;
        tot %= m;
        ans += cnt[tot];
        x = x*10 % m;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(b==1){
            System.out.println(0);
            return;
        }

        for(int i=1;i<100;i++){
            if(a*i - (i-1) >=b){
                System.out.println(i);
                return;
            }
        }




    }
    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }

}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define INF             1e9
#define INFL            8e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define READ            freopen("D:\\moidda CPP\\alu.txt", "r", stdin)
#define WRITE           freopen("D:\\moidda CPP\\vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

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

const int MAX = 1e3 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAX_VALUE = 200 + 2;
const int MOD = 1e9 + 7;
const double PY = acos(-1.0);
const double EPS = 1E-9;

int32_t main()
{
//#ifndef ONLINE_JUDGE
//    READ;
//    WRITE;
//#endif

    FASTIO;

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    ll sum = 0;
    for(int i = n-1; i >= 0; i--){
        a[i] += sum;
        ll x = ceil((double)a[i]/b[i])*b[i];
        sum += x-a[i];
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
using namespace std;
typedef long long ll;
 

 
int main(){
    string tap,ans="Yes";
    cin>>tap;
   for(int i=0;i<tap.size();i++){
       if(i%2==0){
           if(tap.at(i)=='L')ans="No";
       }else{
           if(tap.at(i)=='R')ans="No";
       }
       
       }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc015/tasks/agc015_a
# 最小と最大は必ず一つは存在するのか
n, a, b = map(int, input().split())
if b < a or (n == 1 and a != b):  # コーナーケース
    print(0)
    exit()
ma = b * (n - 1) + a
mi = a * (n - 1) + b
print((ma - mi + 1))


Measured memory_bytes: 61756
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
const int M = 200005 ;
using namespace std ;
inline int read(){
	char c = getchar() ; int x = 0 , w = 1 ;
	while(c>'9'||c<'0') { if(c=='-') w = -1; c= getchar() ;}
	while(c>='0'&&c<='9'){ x = x*10+c-'0' ; c = getchar() ;}
	return x*w ;
}
int A,B ;
int main(){
	A = read() ; B = read() ;
	if(A<=8&&B<=8) cout<<"Yay!\n" ;
	else cout<<":(\n" ;
	return 0 ;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b;

    if(a+b<24) cout <<  a+b;
    else cout << a+b-24;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

macro_rules !min {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::min ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::min ($a ,min !($($rest ) ,+) ) } } ;}
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}

#[fastout]
fn main() {
   input! {
      h: i64,
      w: i64
   }

   if h % 3 == 0 || w % 3 == 0 {
      println!("0");
      return;
   }

   let mut ans = min(h, w);
   let w1 = w / 2;
   let w2 = w - w / 2;
   for h1 in 1..h {
      let h2 = h - h1;
      let s1 = max! {h1*w, h2*w1, h2*w2};
      let s2 = min! {h1*w, h2*w1, h2*w2};
      ans = std::cmp::min(ans, (s1 - s2).abs());
   }
   let h1 = h / 2;
   let h2 = h - h / 2;
   for w1 in 1..w {
      let w2 = w - w1;
      let s1 = max! {h*w1, h1*w2, h2*w2};
      let s2 = min! {h*w1, h1*w2, h2*w2};
      ans = std::cmp::min(ans, (s1 - s2).abs());
   }
   println!("{}", ans);
}


Measured memory_bytes: 2184
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let n = read!(usize);
	let a = read!([i64]);
	let mut ans = 1;
	if a.iter().filter(|&x| *x==0).count()>0 {
		println!("0");
		return;
	}
	let ma = 1000000000000000000_i64;
	for i in 0..n {
		if a[i]>ma/ans {
			println!("-1");
			return;
		}
		ans *= a[i];
	}
	println!("{}",ans);
}

fn run() {
    solve();
}


Measured memory_bytes: 3796
#include<iostream>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;

  int a=0;
  int b=0;
  if(A == 5){
    a+=1;
  }else if(A == 7){
    b+=1;
  }
  if(B == 5){
    a+=1;
  }else if(B == 7){
    b+=1;
  }
  if(C == 5){
    a+=1;
  }else if(C == 7){
    b+=1;
  }
  if(a==2 && b==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		cout << ((a[i] == b[n - 1]) ? b[n - 2] : b[n - 1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 1034567
#define offset 1000000000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
ll B[tam],A[tam];
int n,c;
ll dp[420][420],dp2[420][420];
const ll MOD=1e9+7;
ll pot(ll base,ll exp)
{
    ll resp=1;
    base%=MOD;
    while(exp>0)
    {
        if (exp&1)
            resp*=base,resp%=MOD;
        base*=base;base%=MOD;
        exp/=2;
    }
    return resp;
}
ll go(int pos,int cuanto)
{
    if (dp2[pos][cuanto]!=-1)
        return dp2[pos][cuanto];
    ll tot=0;
    forr(i,A[pos],B[pos]+1)
    {
        tot+=pot(i,cuanto);tot%=MOD;
    }
    return dp2[pos][cuanto]=tot;
}
ll f(int pos,int c)
{
    ll tot=0;
    if (pos==n){
        if (c==0)
        return 1;
        return 0;
    }
    if (dp[pos][c]!=-1)
        return dp[pos][c];
    for(int x=c;x>=0;x--)
    {
        tot+=go(pos,x)*f(pos+1,c-x);tot%=MOD;
    }
    //cout<<pos<<" "<<c<<" "<<tot<<endl;
    return dp[pos][c]=tot;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>n>>c;
    forr(i,0,n)
    {
        cin>>A[i];
    }   
    forr(i,0,n)
    {
        cin>>B[i];
    }
    memset(dp,-1,sizeof dp);
    memset(dp2,-1,sizeof dp2);
    //cout<<go(0,3)<<endl;
    //cout<<go(0,2)<<endl;
    //cout<<go(1,1)<<endl;
    //return 0;
    cout<<f(0,c)<<endl;
}


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

using namespace std;
const int INF = 1e9+5;
int main(){ 
	int n;
	cin>>n;
	vector<int> v(n);
	for(int& x : v)
		scanf("%d", &x);
	vector<int> dp(n, INF);
	dp[0]=0;
	for(int i =0; i<n; i++){
		for(int j : {i+1, i+2}){
			if(j<n){
				dp[j]=min(dp[j], dp[i]+abs(v[i] - v	[j]));
			}
		}
	}
	printf("%d\n", dp[n-1]);
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  char A=a.at(0);
  char B=b.at(0);
  char C=c.at(0);
  printf( "%c", toupper(A) );
  printf( "%c", toupper(B) );
  printf( "%c", toupper(C) );
  return 0;
}

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

#define pii pair<int,int>
#define maxn 51
#define m_p make_pair

int main(){
	int n;
	cin>>n;
	int x[maxn],y[maxn];
	map<pii,int> mp;
	for (int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		mp[m_p(x[i],y[i])]=1;
	}
	int res=n;
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (i==j) continue;
			int dx=x[i]-x[j];
			int dy=y[i]-y[j];
			int cnt=0;
			for (int k=0;k<n;k++)
				if (mp.count(pii(x[k]+dx,y[k]+dy))) cnt++;
			res=min(res,n-cnt);
		}
	}
	printf("%d\n",res);
	return 0;
} 

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int s[100],i,j,n,k,l,temp,sum=0;
    while((scanf("%d %d",&n,&k))!=EOF){
    for(i=0;i<n;i++){
        l=i;
        scanf("%d",&s[i]);

    }
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(s[i]<s[j])
            {
                temp=s[i];
                s[i]=s[j];
                s[j]=temp;
            }
        }

    }

    for(i=0; i<k; i++)
    {
        sum=sum+s[i];

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

}


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

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9;
#define INFL 1e18;
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class CGoToSchool {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        pair<ll, ll> A[N];
        REP(i, N) {
            in >> A[i].first;
            A[i].second = i+1;
        }
        sort(A,A+N);
        REP(i, N) {
            out << A[i].second << (i < N - 1 ? ' ':'\n');
        }
	}
};


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


Measured memory_bytes: 2432
import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7


class CumSum(val A: List<Long>) {
    private var csum: LongArray = LongArray(A.size + 1)
    init {
        for (i in 1..A.size) {
            this.csum[i] = this.csum[i-1] + A[i-1]
        }
    }
    fun sum(L: Int, R: Int): Long {
        val r = min(R, A.size);
        val l = max(L, 0)
        if (l >= r) return 0
        return this.csum[r] - this.csum[l];
    }
}


fun solveB(N: Int, K: Int, A: List<Long>): Long {
    val plus = LongArray(N)
    val minus = LongArray(N)
    A.forEachIndexed{ i, v ->
        if (v >= 0) {
            plus[i] = v
        } else {
            minus[i] = v
        }
    }

    val pcs = CumSum(plus.toList())
    val mcs = CumSum(minus.toList())
    var Max = pcs.sum(0, N)
    var res = Long.MIN_VALUE
    for (l in 0 until N-K+1) {
        val white = pcs.sum(l, l+K)
        res = max(res, Max-white)
        val black = mcs.sum(l, l+K)
        res = max(res, Max+black)
    }

    return res
}


fun main(args: Array<String>) {
    val (N,K) = readListInt()
    val A = readListLong()
    val ans = solveB(N, K, A)

    println(ans)
}


Measured memory_bytes: 73792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n,l,k;
	cin >> n >> l >> k;
	ll a[n], b[l];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<l; i++){
		cin >> b[i];
	}

	ll m=0,mm=0;
	ll s=0;
	int i,j;
	for(i=0; i<n; i++){
		if(s+a[i]>k)
			break;
		s += a[i];
		m++;
	}
	for(j=0; j<l; j++){
		if(s + b[j] >k)
			break;
		s += b[j];
		m++;
	}
	mm = m;

	for(i--; i>=0; i--){
		s -= a[i];
		m--;
		while(j<l && s+b[j]<=k){
			s+=b[j];
			m++;
			j++;
		}
		mm = max(m,mm);
		if(j==l)
			break;
	}

	cout << mm;




	
	

	return 0;
}

Measured memory_bytes: 6752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 32968
#include <iostream>
#define ll long long

using namespace std;

const int MOD = 1e9+7;
int dp[3007][3007];

int main()
{
    int n;
    string s;
    cin >> n >> s;
    dp[0][1] = 1;
    //cout << dp[0][1] << endl;
    for(int i = 1; i < n; i++){
        int ps[3007][2] = {0};
        ps[1][0] = dp[i-1][1];
        for(int j = 2; j <= i; j++){
            ps[j][0] = (ps[j-1][0] + dp[i-1][j]) % MOD;
        }
        ps[i][1] = dp[i-1][i];
        for(int j = i-1; j >= 1; j--){
            ps[j][1] = (ps[j+1][1] + dp[i-1][j]) % MOD;
        }
        for(int j = 1; j <= i+1; j++){
            if(s[i-1] == '>'){
                dp[i][j] = ps[j][1];
            }
            else{
                dp[i][j] = ps[j-1][0];
            }
            //cout << dp[i][j] << ' ';
        }
        //cout << endl;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans = (ans + dp[n-1][i]) % MOD;
    }
    cout << ans;
}


Measured memory_bytes: 34304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = m;
  rep(i, n-1) ans *= m-1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n, x, t;
  while (scanf("%d %d %d", &n, &x, &t) != EOF)
  {
    printf("%d\n", t * (n / x + (n % x != 0)));
  }
  return 0;
}

Measured memory_bytes: 3756
import sys

N=int(input())

if N%2!=0:
    print(0)
    sys.exit()

ans1=0
ans2=0
a=2
b=5

while N//a!=0:
    ans1=ans1+N//a
    a=a*2
while N//b!=0:
    ans2=ans2+N//b//2
    b=b*5

print(min(ans1,ans2))

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

void main_()
{
    ll N, M;
    cin >> N >> M;

    // ボールの数、赤いボールの可能性があるかどうか
    // 初期値: 各箱にボール1個ずつ、1番目の箱は赤いボール
    vector<pair<ll, bool>> dp(N, { 1, false });
    dp[0].second = true;

    for (ll i = 0; i < M; ++i) {
        ll x, y;
        cin >> x >> y;
        x--; // zero-index
        y--; // zero-index

        // xからyへボールを移す
        dp[x].first--;
        dp[y].first++;

        // xに赤いボールがある場合yに赤いボールを移すことができる
        dp[y].second |= dp[x].second;

        // xからボールがなくなった場合は赤いボールが入っている可能性もなくなる
        if (dp[x].first == 0) {
            dp[x].second = false;
        }
    }

    auto ans = count_if(begin(dp), end(dp), [](auto&& p) { return p.second; });
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1792
import sys
d=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
for n in iter(d,'0\n'):
 a=[1];s=[1,2,3,4,5,6]
 for _ in[0]*int(n):
  s=[s[e]for e in p[d()[0]]]
  a+=[s[0]]
 print(sum(a))


Measured memory_bytes: 5720
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1e5+7;
int n,m;
vector <int> adj[N];
int visited[N];
int dp[N];
int dfs(int s)
{
	visited[s] = 1;
	for(auto u : adj[s])
	{
		if(!visited[u])
		dfs(u);
		dp[s] = max(dp[s],1+dp[u]);
	}
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	#define int long long
	int n,m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int u,v;
		cin >> u >> v;
		adj[u].pb(v);
	}
	for(int i = 1; i <= n; i++)
	{
		if(!visited[i])
		{
			dfs(i);
		}
	}
	int mx = 0;
	for(int i = 1; i <= n; i++)
	{
		if(dp[i] > mx) mx = dp[i];
	}
	cout << mx << "\n";
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <tuple>

int main()
{
	int N;
	std::cin >> N;
	std::vector<int64_t> A(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	int64_t sum = 0;
	for (int i = 1; i < N; ++i) {
		const int64_t diff = A[i - 1] - A[i];
		if (diff > 0) {
			sum += diff;
			A[i] += diff;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
int main() {
  ll n;
  cin>>n;
  vec l(n);
  loop(i,n){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  ll count=0;
  ll ans=0;
  loop(i,n-2){
    Loop(j,i+1,n-1){
      Loop(k,j+1,n){
        if((l[k]<(l[i]+l[j]))&&(l[k]>(l[j]-l[i]))){
          count++;
        }
        else{
          ans+=count;
          count=0;
          break;
        }
      }
    }
  }
  ans+=count;
  cout<<ans;
  
}

Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>x>>n; set<int>st;

    for(i=1; i<=n; i++){
        cin>>p; st.insert(p);
    }

    p = x;
    while(true)
    {
        if(st.find(p)==st.end()) break; p++;
    }

    q = x;
    while(true)
    {
        if(st.find(q)==st.end()) break; q--;
    }

    if(abs(x-p)<abs(x-q)) cout<<p<<endl;
    else if(abs(x-p)>abs(x-q)) cout<<q<<endl;
    else cout<<min(p,q)<<endl;

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 3584
#include <cstdio>

using namespace std;

int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  if (a > b) {
    printf("%s\n", "a > b");
  } else if (a < b) {
    printf("%s\n", "a < b");
  } else {
    printf("%s\n", "a == b");
  }
  return 0;
}



Measured memory_bytes: 2564
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    for i in range(1,10):
        for j in range(1,10):
            if i*j == n:
                print("Yes")
                return
    print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double x = m / 60.0 * 2 * pi, y = (h + m/60.0) / 12 * 2 * pi;
    printf("%.12lf\n", sqrt(a*a + b*b - 2 * a * b * cos(x-y))); 
    return 0;
}



Measured memory_bytes: 4192
#include<iostream>
using namespace std;
int main(){
	int n,i,j,k,H,S,D,C,y;
	char x,ch;
	cin>>n;
	bool cards[4][13]={false};
	for(i=0;i<n;i++){
	cin>>x>>y;
	if(x=='S'){
	cards[0][y-1]=true;
	}
	else if(x=='H'){
	cards[1][y-1]=true;
	}
	
	else if(x=='C'){
	cards[2][y-1]=true;
	}
	else if(x=='D'){
	cards[3][y-1]=true;
	}
	}
	for(j=0;j<4;j++){
		for(k=0;k<13;k++){
			if(cards[j][k]==false){
		switch(j){
		case 0:ch='S';break;
		case 1:ch='H';break;
		case 2:ch='C';break;
		case 3:ch='D';break;
		}
		cout<<ch<<" "<<k+1<<endl;
			}
		}
	}
return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    string s,t;
    cin>>s>>t;
    int ans=INF;
    for(int i=0;i<s.size();i++){
        int cnt=0;
        for(int j=0;j<t.size();j++){
            if(j+i>=s.size()){
                cnt=INF;
                break;
            }
            if(s[i+j]!=t[j])cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int dp[110000];
vector<int>g[110000];
int dfs(int a,int b){
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		dfs(g[a][i],a);
	}
	int t=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		t^=(dp[g[a][i]]+1);
	}
	return dp[a]=t;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	int ret=dfs(0,-1);
	if(ret)printf("Alice\n");
	else printf("Bob\n");
}

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

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

Measured memory_bytes: 3640
sx, sy, tx, ty = map(int, input().split())

ans = ''
ans += 'U' * (ty - sy) + 'R' * (tx - sx)
ans += 'D' * (ty - sy) + 'L' * (tx - sx)
ans += 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D'
ans += 'R' + 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1) + 'U'

print(ans)


Measured memory_bytes: 3060