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

int64_t MOD = 1000003;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

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

    create_mod_tables(MOD-1);

    while(Q--){
        int64_t x, d, n, ans;
        cin >> x >> d >> n;
        if(d == 0){
            ans = power_mod(x, n) % MOD;
        }else{
            int64_t start = x * inv_mod(d) % MOD;
            int64_t end = (start + n - 1) % MOD;
            if(n >= MOD || start == 0 || start > end){
                ans = 0;
            }else{
                ans = fact[end] * fact_inv[start-1] % MOD;
            }
            mul(ans, power_mod(d, n));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 25856
using System;
class distance{
    public static void Main(){
        String[] str = Console.ReadLine().Split(' ');
        double x1 = double.Parse(str[0]);
        double y1 = double.Parse(str[1]);
        double x2 = double.Parse(str[2]);
        double y2 = double.Parse(str[3]);
        Console.WriteLine(Math.Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    }
}


Measured memory_bytes: 17912
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll K = 4e5+10;
const ll maxn = 420;
const ll mod = 1e9+7;

ll n , m , w;
ll c[maxn], v[maxn], dp[maxn][K];

int main()
{
    cin>> n >> w;
    for(ll i = 1; i <= n; i++)
        cin>> c[i] >> v[i];

    ll ans = 0;
    for(ll i = 0; i <= n; i++)
    {
        for(ll j = 1; j <= 1e5; j++)
        {
            if(i == 0){
                dp[i][j] = INF;
                continue;
            }
            if(j <= v[i])
                dp[i][j] = min(dp[i-1][j], c[i]);
            else
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + c[i]);
            if(dp[i][j] <= w)
                ans = max(ans, j);
        }
    }
    cout<< ans;
}










Measured memory_bytes: 281600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  sort(all(s));
  rep(i,n){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


struct Realedge {
  vector<set<int>>tos;
};

int main() {
  
  int N, M, A, B, C; cin >> N >> M >> A >> B >> C;
  vector<int>memo(N, -1);
  memo[N - 1] = 0;
  vector<int>nums = { A,B,C };
  vector<vector<int>>edges(N);
  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    edges[u].push_back(v);
  }
  vector<Realedge>res(N);
  for (int i = 0; i < 3; ++i) {
    for (int start = 0; start < N; ++start) {
      const int time = nums[i];
      set<int>froms;
      froms.emplace(start);
      for (int t = 0; t < time; ++t) {
        set<int>tos;
        for (auto f : froms) {
          for (auto e : edges[f]) {
            tos.emplace(e);
          }
        }
        froms = tos;
      }
      res[start].tos.push_back(froms);
    }
  }
  queue<int> que;
  que.push(N - 1);
  int ans = -1;
  while (!que.empty()) {
    if (que.front() == 0) {
      ans = memo[0];
      break;
    }
    que.pop();
    for (int i = 0; i < res.size(); ++i) {
      int maxtime = -1;
      for (int j = 0; j < 3; ++j) {
        set<int>aset(res[i].tos[j]);
        int mintime = 1e9;
        for (auto n : aset) {
          if (memo[n]!=-1&&memo[n] < mintime) {
            mintime = memo[n];
          }
        }
        maxtime = max(maxtime, mintime+1);
      }
      if (maxtime >= 1e9) {

      }
      else {
        if (memo[i]==-1||maxtime < memo[i]) {

          memo[i] = maxtime;
          que.push(i);
        }
      }
    }
  }
  if (ans == -1) {

    cout << "IMPOSSIBLE" << endl;
  }
  else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3500
n = gets.chomp.split("")
s = n.size
ans = 0
combi = []
for i in 0..2**(s-1)-1
  (s-1).times do |j|
    combi[j] = i%2
    i /= 2
  end
  tmp = 0
  for j in 0..s-1
    if combi[j] == 0
      n[tmp,2] = n[tmp,2].join
    else
      tmp += 1
    end
  end
  ans += n.map(&:to_i).inject(:+)
  n = n.join.to_s.split("")
end
puts ans

Measured memory_bytes: 1916
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;

int main(){
        int N;
        scanf("%d\n",&N);
        int flag = 0;
        string s;
        getline(cin,s);
        int result  = (int)s.find("Y");
        if (result >= 0) cout << "Four" << endl;
        else cout << "Three" << endl;
        return 0;
}

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

using namespace std;

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

    if(n < 1200) cout << "ABC\n";
    else if(n >= 1200 and n < 2800 ) cout << "ARC\n";
    else if(n >= 2800) cout << "AGC\n";
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let s: String = sc.read();
    let s: Vec<char> = s.chars().collect();
    let mut set: HashSet<char> = HashSet::new();
    for c in &s {
        set.insert(*c);
    }
    match set.len() == s.len() {
        true  => println!("yes"),
        false => println!("no"),
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
vector<int> R,G,B;

bool isInBlue(int val){
	int idx = lower_bound(B.begin(),B.end(),val) - B.begin();	
	return (idx != B.size() && B[idx] == val);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; string str; cin>>n>>str;
	for(int i=0;i<n;i++){
		if(str[i] == 'R') R.push_back(i);
		else if(str[i] == 'G') G.push_back(i);
		else B.push_back(i);
	}
	ll ans = 0;
	for(int i=0;i<R.size();i++){
		for(int j=0;j<G.size();j++){
			int high = max(R[i],G[j]), low = min(R[i],G[j]);
			ll k = B.size();
			if(isInBlue(high+(high-low)))k--;
			if(isInBlue(low-(high-low)))k--;
			if(!((high+low)&1)){
				if(isInBlue((high+low)/2)) k--;
			}
			ans += k;
		}
	}
	cout<<ans; return 0;
}


Measured memory_bytes: 3648
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
c = [list(map(int,input().split())) for j in range(M)]
ans=[]
for i in a:
    temp=4*10**8
    temp2=50
    for j in range(M):
        if abs(i[0]-c[j][0])+abs(i[1]-c[j][1])<temp:
            temp=abs(i[0]-c[j][0])+abs(i[1]-c[j][1])
            temp2=j+1
    ans.append(temp2)
for i in ans:
    print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k)
  {
    cout << a - k << " " << b << endl;
  }
  else if (a + b < k)
  {
    cout << "0 0" << endl;
  }
  else
  {
    cout << "0 " << b - (k - a) << endl;
  }
}


Measured memory_bytes: 3632
import math
from functools import reduce

def gcd_get(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            ans += gcd_get(i, j, l)
print(ans)


Measured memory_bytes: 69400
H, W = gets.chomp.split(" ").map(&:to_i)
S = [Array.new(W+2, '.')]
H.times{
  S << '.' + gets.chomp + '.'
}
S << Array.new(W+2, '.')

(1..H).each{|i|
  (1..W).each{|j|
    if S[i][j] == '.' then
      wk = S[i-1][j-1, 3].count('#')
      wk += S[i+1][j-1, 3].count('#')
      wk += 1 if S[i][j-1] == '#'
      wk += 1 if S[i][j+1] == '#'
      S[i][j] = wk.to_s
    end
  }
}

S[1, H].each{|s|
  puts s[1, W]
}


Measured memory_bytes: 1788
a, b, c, d = map(int, input().split())

alice = list(range(a, b+1))
bob = list(range(c, d+1))

ans = 0
for a in alice:
    if a in bob:
        ans += 1
if ans != 0:
    print(ans - 1)
else:
    print(0)

Measured memory_bytes: 38256
L, R = list(map(int, input().split(' ')))
#print(L, R)

min = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        mod_ij = (i * j) % 2019
        if min > mod_ij:
            min = mod_ij
            if min == 0:
                break
    if min == 0:
        break

print(min)


Measured memory_bytes: 2940
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
    ans = 0
else:
    points = X[:]
    points.sort()

    diff_p = []
    for i in range(1, len(points)):
        diff_p.append(points[i] - points[i-1])

    diff_p.sort()
    #print(diff_p)

    ans = sum(diff_p[:M-N])
print(ans)


Measured memory_bytes: 13960
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B; cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);

     	if(a%2 == 0 || b%2 == 0)
        {
          Console.WriteLine("Even");
        }
     	else
      	{
          Console.WriteLine("Odd");
        }	
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string s;
  cin >> s;

  auto func = [&](string ss){
    char c = ss.at(0), cc = ss.at(N-1);
    for(int i = 1; i < N; i++){
      int next;
      if(i != N-1) next = i+1;
      else next = 0;
      if(ss.at(i) == 'S'){
        if(ss.at(i-1) == 'S' && s.at(i) == 'o') ss.at(next) = 'S';
        else if(ss.at(i-1) == 'S' && s.at(i) == 'x') ss.at(next) = 'W';
        else if(ss.at(i-1) == 'W' && s.at(i) == 'o') ss.at(next) = 'W';
        else if(ss.at(i-1) == 'W' && s.at(i) == 'x') ss.at(next) = 'S';
      }
      else{
        if(ss.at(i-1) == 'S' && s.at(i) == 'o') ss.at(next) = 'W';
        else if(ss.at(i-1) == 'S' && s.at(i) == 'x') ss.at(next) = 'S';
        else if(ss.at(i-1) == 'W' && s.at(i) == 'o') ss.at(next) = 'S';
        else if(ss.at(i-1) == 'W' && s.at(i) == 'x') ss.at(next) = 'W';
      }
    }
    if(ss.at(0) == c && ss.at(N-1) == cc){
      if(s.at(0) == 'o'){
        if(ss.at(1) == ss.at(N-1)) ss.at(0) = 'S';
        else ss.at(0) = 'W';
      }
      else{
        if(ss.at(1) == ss.at(N-1)) ss.at(0) = 'W';
        else ss.at(0) = 'S';
      }
      cout << ss << endl;
      return true;
    }
    return false;
  };

  string ss;
  map<int, char> ma;
  ma[0] = 'S'; ma[1] = 'W';
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      ss = s;
      if(s.at(0) == 'o'){
        if(i == j) ss.at(0) = 'S';
        else ss.at(0) = 'W';
      }
      else{
        if(i == j) ss.at(0) = 'W';
        else ss.at(0) = 'S';
      }
      ss.at(1) =ma[i]; ss.at(N-1) = ma[j];
      if(func(ss)) return 0;
    }
  }

  cout << -1 << endl;

}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n, k;
ll a[505];
set<ll> factors;
bool check(int num)
{
    ll work[505];
    int i, j;
    FOR0(i, n) work[i] = a[i]%num;
    sort(work, work+n);
    ll ans = 0;
    FOR0(i, n)
    {
        ll cur = work[i];
        FORD(j, n-1, i+1)
        {
            if(cur == 0) break;
            ll res = MIN2(cur, (num - work[j])%num);
            work[j] += res;
            work[j] %= num;
            cur -= res;
            ans += res;
        }
        work[i] = 0;
    }
    if(ans <= k) return true;
    return false;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>k;
    ll i;
    ll sum = 0;
    FOR0(i, n)
    {
        cin>>a[i];
        sum += a[i];
    }
    //cout<<sum<<endl;
    ll bnd = sqrt(sum) + 1;
    FOR(i, 1, bnd)
    {
        if(sum%i==0)
        {
            factors.insert(i);
            factors.insert(sum/i);
        }
    }
    set< ll >::iterator it = factors.begin();
    ll ans = 1;
    while(it!=factors.end())
    {
        if(check(*it)) ans = *it;
        it++;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin>>A>>B>>C;

    int K;
    cin>>K;

    int ans=0;
    while(B<=A){
        B*=2;
        ans++;
    }
    while(C<=B){
        C*=2;
        ans++;
    }
    if(ans<=K)cout << "Yes" << endl;
    else cout <<"No" << endl;

    



}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

int min_distance_counts[2000];

int dist(int pos1, int pos2);

int main(void)
{
    int nodes_count;
    int x, y;

    cin >> nodes_count >> x >> y;
    x -= 1;
    y -= 1;

    for(int i = 0; i < 2000; i++){
        min_distance_counts[i] = 0;
    }

    for(int i = 0; i < nodes_count - 1; i++){
        for(int j = i + 1; j < nodes_count; j++){
            int pure_dist = dist(i, j);
            int xtoy_dist = dist(i, x) + 1 + dist(y, j);
            /*
            int ytox_dist = dist(i, y) + 1 + dist(x, j);

            min_distance_counts[min(min(pure_dist, xtoy_dist), ytox_dist)] += 1;
            */
            min_distance_counts[min(pure_dist, xtoy_dist)] += 1;
        }
    }

    for(int i = 1; i < nodes_count; i++){
        cout << min_distance_counts[i] << endl;
    }

    return 0;
}

int dist(int pos1, int pos2)
{
    if(pos1 >= pos2){
        return pos1 - pos2;
    }else{
        return pos2 - pos1;
    }
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string i;
    cin >> i;
    
    if(i[0]==i[1]){
        if(i[1]==i[2]) cout << "Yes";
        else cout << "No";
    }
    else if(i[1]==i[2]){
        if(i[2]==i[3]) cout << "Yes";
        else cout << "No";
    }
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <lli> arr(n+1);
	vector <lli> ar(n);
	for(lli &x: arr) cin >> x;
	for(lli &x: ar) cin >> x;

	lli res = 0;
	for(int i=0; i<n; i++){
		int loc = min(ar[i], arr[i]+arr[i+1]);
		if(loc > arr[i]) arr[i+1] -= (loc - arr[i]);
		res += loc;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
char a,b;
scanf("%c  %c",&a,&b);
if(a=='D')
{if(b=='D')
printf("H");
else
printf("D");}
if(a=='H')
{if(b=='D')
printf("D");
else
printf("H");}
return 0;
}

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

int main() {
  string x;
  cin >> x;
  if (x.at(0) == x.at(1) && x.at(1) == x.at(2) && x.at(0) == x.at(1)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

long long inv(int a, int p) { return a==1 ? 1 : (1-p*inv(p%a,a))/a+p; }
static const int MODVAL = 998244353;
struct mint {
  int val;
  mint():val(0){}
  mint(int x):val(x%MODVAL) {}
  mint(size_t x):val(x%MODVAL) {}
  mint(long long x):val(x%MODVAL) {}
  mint& operator+=(mint y) { val+=y.val; if(val>=MODVAL) val-=MODVAL; return *this; }
  mint& operator-=(mint y) { val-=y.val; if(val<0) val+= MODVAL; return *this; }
  mint& operator*=(mint y) { val=(val*(long long)y.val)%MODVAL; return *this; }
  mint& operator/=(mint y) { val=(val*inv(y.val,MODVAL))%MODVAL; return *this; }
};
inline mint operator+(mint x, mint y) { return x+=y; }
inline mint operator-(mint x, mint y) { return x-=y; }
inline mint operator*(mint x, mint y) { return x*=y; }
inline mint operator/(mint x, mint y) { return x/=y; }
mint POW(mint x, long long n) { mint r(1); for(;n;x*=x,n>>=1) if(n&1) r*=x; return r; }
mint FAC(int n) { static vector<mint> FAC_(1,1);
  while(int(FAC_.size())<=n) FAC_.push_back(FAC_.back()*FAC_.size()); return FAC_[n]; }
inline mint CMB(int n, int k) { return k<0||n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
inline ostream& operator<<(ostream& os, mint a) { return os << a.val; }

// n箇所にm個を配るが、k個より大きいところを作ってはならない
mint solve(int n, int m, int k) {
  if(n == 0) {
    return m == 0 ? 1 : 0;
  }
  mint res = CMB(m+n-1, n-1);
  for(int x = k+1; x <= m; ++x) {
    res -= CMB(m-x + n-2, n-2) * n;
  }
  return res;
}

int main(void) {
  int n, m;
  cin >> n >> m;
  mint res = solve(n, 3*m, 2*m);
  int last = min(n, 3*m);
  for(int x = last; x > m; --x) { // 奇数の箇所が多すぎるパターン
    if((3*m-x) % 2 == 1) {
      continue;
    }
    // cerr << ">" << res << endl;
    mint cur = CMB(n, x) * CMB((3*m-x)/2 + n-1, n-1);
    res -= cur;
  }
  cout << res << endl;
  
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>num(n);
  int yon=0,ni=0;
  for(int i=0;i<n;i++){
    cin>>num[i];
    if(num[i]%4==0)yon++;
    else if(num[i]%2==0)ni++;
  }
  if(yon>=(n)/2-(ni/2))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
#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++)
typedef long long ll;
typedef pair<int,int> pii;


const int MOD=998244353;

vector<ll> fac(300001);
vector<ll> ifac(300001);

ll modpow(ll x,ll n){
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1; 
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a==0&&b==0) return 1;
    if(a<b||a<0) return 0;
    ll tmp = ifac[a-b]*ifac[b] % MOD;
    return tmp*fac[a]%MOD;
}

void prepare(){
    fac[0]=1;ifac[0]=1;
    for(ll i=0;i<300000;i++){
        fac[i+1]=fac[i]*(i+1)%MOD;
        ifac[i+1]=ifac[i]*modpow(i+1,MOD-2)%MOD;
    }
}


int main(){
    prepare();
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;

    for(int i=0;i<=k;i++){
        ans += (comb(n-1,i)*modpow(m-1,n-1-i))%MOD;
        ans =ans%MOD;
    }
    cout<<(m*ans)%MOD<<endl;
    return 0;
}

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

struct Line {
    int64_t h;
    int64_t l;
    int64_t r;
    Line(int64_t _h=0, int64_t _l=0, int64_t _r=0):h(_h),l(_l),r(_r){}
};

unordered_map<int64_t, int> compress(const set<int64_t> &s) {
    int v = 0;
    unordered_map<int64_t, int> m;

    for (auto i : s) {
        m[i] = 2 * (v++);
    }
    
    return m;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<Line> vLine(N);
    vector<Line> hLine(M);
    set<int64_t> xs;
    set<int64_t> ys;
    xs.insert(0);
    ys.insert(0);
    int64_t a, b, c;
    for (int i = 0; i < N; ++i) {
        cin >> a >> b >> c;
        vLine[i] = Line(c, a, b);
        xs.insert(a);
        xs.insert(b);
        ys.insert(c);
    }
    for (int i = 0; i < M; ++i) {
        cin >> a >> b >> c;
        hLine[i] = Line(a, b, c);
        xs.insert(a);
        ys.insert(b);
        ys.insert(c);
    }

    auto x2i = compress(xs);
    auto y2i = compress(ys);
    vector<int64_t> i2x(begin(xs), end(xs));
    vector<int64_t> i2y(begin(ys), end(ys));

    const auto width = size(i2x) * 2 - 1;
    const auto height = size(i2y) * 2 - 1;
    vector<vector<bool>> grid(width, vector<bool>(height, true));

    for (const auto &line : vLine) {
        int y = y2i[line.h];
        int x1 = x2i[line.l];
        int x2 = x2i[line.r];
        for (int x = x1; x <= x2; ++x) {
            grid[x][y] = false;
        }
    }

    for (const auto &line : hLine) {
        int x = x2i[line.h];
        int y1 = y2i[line.l];
        int y2 = y2i[line.r];
        for (int y = y1; y <= y2; ++y) {
            grid[x][y] = false;
        }
    }

    uint64_t ans = 0;
    queue<pair<int,int>> q;
    q.emplace(x2i[0], y2i[0]);

    const int dx[] = {0, 0, 1, -1};
    const int dy[] = {1, -1, 0, 0};
    auto isValid = [&](int x, int y) {
        return 0 <= x && 0 <= y && x < (int)size(grid) && y < (int)size(grid[0]);
    };

    while (!empty(q)) {
        auto front = q.front();
        q.pop();
        int x = front.first;
        int y = front.second;
        if (x % 2 && y % 2) {
            int xx = x / 2;
            int yy = y / 2;
            auto dy = i2y[yy+1] - i2y[yy];
            auto dx = i2x[xx+1] - i2x[xx];
            ans += dy * dx;
        }
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (!isValid(nx, ny)) {
                cout << "INF" << endl;
                return 0;
            }
            if (grid[nx][ny]) {
                q.emplace(nx, ny);
                grid[nx][ny] = false;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    ll lb = 1, ub = 9;
    int foo = -1;
    bool flag = true;
    while(flag && lb < 1e+10){
        char c1, c2;
        cout << "? " << lb << "\n" << flush;
        cin >> c1;
        cout << "? " << ub << "\n" << flush;
        cin >> c2;
        if(foo == -1 && c1 == 'Y' && c2 == 'Y') foo = lb;
        if(c1 == 'N' && c2 == 'Y'){
            flag = false;
            lb -= 1;
        }
        else{
            lb *= 10;
            ub *= 10;
            ub += 9;
        }
    }
    if(flag){
        cout << "! " << foo << "\n";
        return 0;
    }

    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        cout << "? " << mid << "\n" << flush;
        char c;
        cin >> c;
        if(c == 'Y')    ub = mid;
        else    lb = mid;
    }
    cout << "! " << ub / 10 << "\n";
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vi s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};	
	int k;
	cin >> k;
	k--;
	cout << s[k] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long MOD = 1000000007;
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N;cin >> N;
    vector<long long> V(N);
    REP(i,N) cin >> V[i];
    sort ALL(V);reverse ALL(V);
    vector<long long> W(2,0);
    REP(i,N){
        if(V[i] == V[i+1]){
            W.pb(V[i]);
            i++;
        }
    }
    sort ALL(W);reverse ALL(W);
    cout << W[0]*W[1] << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

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;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll A,B,C,D;
    cin >> A>>B>>C>>D;
    if(abs(A - C) <= D || (abs(A-B) <= D && abs(B-C) <= D))cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
	int n;
	scanf("%d",&n);
	double t=0.0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		t=t+1.0/a[i];
	}
	printf("%.5lf",1.0/t);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
        double h=sc.nextInt();
        double a=sc.nextInt();
        double hits=0;
        if((h/a)%1==0)
        	hits=h/a;
        else
          hits=(h/a)+1;
        int hit= (int)hits;
        pw.print(hit);
		pw.close();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

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

int main()
{
   int r;
   scanf("%d",&r);
   double area1,area2;
   area1=1*3.14;
   area2=3.14*r*r;
   int z;
   z=ceil(area2/area1);
   printf("%d",z);

    return 0;
}


Measured memory_bytes: 128
//21
#include<iostream>

using namespace std;

int n,m,s,d;
char l[30][10];

bool dl(){
  int x=m-1;
  for(int y=0;y<d;y++){
    for(int i=0;i<2;i++){
      int d[]={-1,0};
      int nx=x+d[i];
      if(0<=nx&&nx<n-1&&l[y][nx]=='1'){
	int dd[]={-1,1};
	x+=dd[i];
	break;
      }
    }
  }
  return x+1==s;
}

int main(){
  while(cin>>n>>m>>s>>d,n){
    for(int y=0;y<d;y++){
      cin>>l[y];
    }
    if(dl()){
      cout<<0<<endl;
    }else{
      for(int y=0;y<d;y++){
	for(int x=0;x<n-1;x++){
	  if(l[y][x]=='0'&&(x==0||l[y][x-1]=='0')&&(x==n-2||l[y][x+1]=='0')){
	    l[y][x]='1';
	    if(dl()){
	      cout<<y+1<<' '<<x+1<<endl;
	      goto next;
	    }
	    l[y][x]='0';
	  }
	}
      }
      cout<<1<<endl;
    }
  next:
    ;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
	int w,h,x,y,r,x1,x2,y1,y2;
	scanf("%d",&w);
	scanf("%d",&h);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	x1=x-r;
	x2=x+r;
	y1=y-r;
	y2=y+r;
	
	if(x1>=0 && x2<=w && y1>=0 && y2<=h){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}



Measured memory_bytes: 2696
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define M 200010
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
ll a[M], b[M], n, ans, tm, now, tp, an[M], bn[M], sta[M], tot, now2;
multiset<ll> st;
multiset<ll>:: iterator it;
ll bude = 0;
map<ll, int> mp;
ll tmp;
int father[M];
int find(int x) {
	return father[x] == x ? x : father[x] = find(father[x]);
}
int main() {
//	freopen("replace.in", "r", stdin);
	//freopen("replace.out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i++) a[i] = read(), now ^= a[i];
	for(int i = 1; i <= n; i++) b[i] = read(), st.insert(b[i]), now2 ^= b[i];
	for(int i = 1; i <= n; i++) {
		it = st.find(a[i]);
		if(it == st.end()) tm++, bude = a[i];
		else st.erase(it);
		if(a[i] == b[i]) continue;
		ans++;
	}
	for(int i = 1; i <= n; i++) {
		if(a[i] != b[i]) break;
		if(i == n) {
			cout << "0\n";
			return 0;
		}
	}
	if(st.find(now) == st.end()) tm++;
	else st.erase(st.find(now));
	if(tm >= 2 || st.size()) {
		cout << "-1" << "\n";
		return 0;
	}
	tp = 0, tot = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i] == b[i]) continue;
		sta[++tot] = a[i];
		an[++tp] = a[i];
		bn[tp] = b[i];
	}
	sta[0] = -1;
	sta[++tot] = now;
	sta[++tot] = now2;
	sort(sta + 1, sta + tot + 1);
	int cnt = 0;
	for(int i = 1; i <= tot; i++) {
		if(sta[i] == sta[i - 1]) continue;
		mp[sta[i]] = ++cnt;
	}
	for(int i = 1; i <= cnt; i++) father[i] = i;
	for(int i = 1; i <= tp; i++) {
		int vi = mp[an[i]], vj = mp[bn[i]];
		vi = find(vi), vj = find(vj);
		if(vi == vj) continue;
		father[vi] = vj;
	}
	int vi = mp[now], vj = mp[now2];
	vi = find(vi), vj = find(vj);
	if(vi != vj)
		father[vi] = vj;
	for(int i = 1; i <= cnt; i++) if(father[i] == i) ans++;
	cout << ans - 1<< "\n";
	return 0;
}
/*
5
1 2 3 0 5
1 2 3 5 5

1
2
2
*/

Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
long long a[100005],n;
int check(long long p){
	for(int i=0;i<n;++i) p-=p%a[i];
	return p==2;
}
int main(){
	long long x,y;
	cin>>n;
	for(int i=0;i<n;cin>>a[i++]);
	long long low,high;
	for (low=2,high=1e15;low<high;){
		long long mid = low+high>>1;
		long long p = mid;
		for(int i=0;i<n;++i) p-=p%a[i];
		if(p>=2) high = mid;
		else low = mid+1;
	}
	x=low; 
	for (low=2,high=1e15;low<high;){
		long long mid = low+high+1>>1;
		long long p = mid;
		for(int i=0;i<n;++i) p-=p%a[i];
		if(p>2) high = mid-1;
		else low = mid;
	}
	y=low;
	if(!check(x)|| !check(y)) return cout<<-1,0;
	cout<<x<<' '<<y;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
 
  int n=0, x=0, cnt=0;
  int y=0;
  cin >> n >> x;
  vector<int> d(n);
 
  d[0]=0;
  for (int i=0; i<n; ++i){
    cin >> y;
    d[i+1]=d[i]+y;
  }
 
  for(int j=0; j<=n; ++j){
    if( x >= d[j] ){
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; ll a[N+1]; ll sum = 0;
  rep(i, N){
    cin >> a[i]; sum+=a[i];
  }
  a[N] = a[0];
  ll K = (ll)N*(N+1)/2;
  if(sum%K){
    cout << "NO" << endl; return 0;
  }
  K = sum/K;
  ll sa[N];
  rep(i, N){
    sa[i] = a[i+1] - a[i];
  }
  ll cnt = 0;
  rep(i, N){
    if(-(N-1)*K>sa[i] || sa[i]>K){
      cout << "NO" << endl; return 0;
    }
    if((K-sa[i])%N){
      cout << "NO" << endl; return 0;
    }
    cnt+=((K-sa[i])/N);
  }
  if(cnt!=K){
    cout << "NO" << endl; return 0;
  }
  cout << "YES" << endl;
}

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

int position;
vector<int> pre, in, post;

void reconstruction(int left, int right)
{
    if(left >= right)
        return;
    int root = pre[position++];
    int mid = distance(in.begin(), find(in.begin(), in.end(), root));
    reconstruction(left, mid);
    reconstruction(mid + 1, right);
    post.push_back(root);
}

void solve(int n)
{
    position = 0;
    reconstruction(0, pre.size());
    for(int i = 0; i < n; i++)
    {
        if (i != 0) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    int input;
    for(int i = 0; i < n; i++)
    {
        cin >> input;
        pre.push_back(input);
    }
    for(int i = 0; i < n; i++)
    {
        cin >> input;
        in.push_back(input);
    }
    solve(n);
}


Measured memory_bytes: 3152
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for x in arr:
  d[x] = d.get(x,0)+1

mxN = 10**6 + 1
rp = [True]*mxN

if 1 in d:
  if d[1] > 1:
    print(0)
    exit()
  else:
    print(1)
    exit()
for i in range(2,len(rp)):
  if i not in d or not rp[i]:continue
  for j in range(i+i,mxN,i):
    if j in d: rp[j] = False

#reason for tle



for k,v in d.items():
  if v > 1:rp[k] = False

ans = sum([(1 if rp[x] else 0) for x in arr])
print(ans)





Measured memory_bytes: 38208
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define PI acos(-1)

int n,f[N];

struct node{int x,y;}a[N],s,t;
bool cmp_x(node a,node b){return a.x<b.x;}
bool cmp_y(node a,node b){return a.y<b.y;}

int query(int x){
	if (!x) return 0;
	return max(f[x],query(x-(x&-x)));
}

void modify(int x,int t){
	if (x>n) return;
	f[x]=max(f[x],t);modify(x+(x&-x),t);
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	s.x=read();s.y=read();t.x=read();t.y=read();
	n=read();
	for (int i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();
		if (1ll*(a[i].x-s.x)*(a[i].x-t.x)>0||1ll*(a[i].y-s.y)*(a[i].y-t.y)>0) i--,n--;
	}
	if (s.x>t.x){
		for (int i=1;i<=n;i++) a[i].x*=-1;
		swap(s.x,t.x);
	}
	if (s.y>t.y){
		for (int i=1;i<=n;i++) a[i].y*=-1;
		swap(s.y,t.y);
	}
	sort(a+1,a+n+1,cmp_y);
	for (int i=1;i<=n;i++) a[i].y=i;
	sort(a+1,a+n+1,cmp_x);
	for (int i=1;i<=n;i++)
		modify(a[i].y,query(a[i].y-1)+1);
	int k=query(n);
	printf("%.15lf\n",100.0*(t.x-s.x+t.y-s.y)+(5*PI-20)*k+(k==min(t.x-s.x,t.y-s.y)+1?5*PI:0));
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    
    int trial;
    int sum=0;
    
    trial = K;
    
    if(trial > A){
        for(int i=0;i<A;i++) sum += 1;
        trial = K - A;
        if(trial > B){
            trial = K - A - B;
            if(trial > C){
                for(int i=0;i<C;i++) sum -= 1;    
            }
            else if(trial <= C){
                for(int i=0;i<trial;i++) sum -= 1;
            }
        }
        else if(trial <= B){
        }
    }
    else if(trial <= A){
        for(int i=0;i<trial;i++) sum += 1;
    }
    
    cout << sum;
    
}

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

int main(){
	int h, w, a;
	string in;
	cin >> h >> w;
	for(int i = 0; i<h;i++){
		a = -1;
		cin >> in;
		for(int j = 0;j<w;j++){
			if(in[j] == 'c') a = 0;
			else if(a == -1) a = -1;
			else a = a + 1;
			
			if(j == 0) cout << a;
			else cout << ' ' << a;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var nums = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            Console.WriteLine(nums[k - 1]);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> tree(N+1);
    for (int i = 0; i < N; i++) {
        int u, v, w;
        scanf("%d", &u);
        scanf("%d", &v);
        scanf("%d", &w);
        tree[u].push_back(make_pair(v, w));
        tree[v].push_back(make_pair(u, w));
    }
    vector<int> color(N+1, -1);
    color[1] = 0;
    queue<pair<int, int>> q;
    q.push({1, -1});
    while (!q.empty()) {
        int now = q.front().first;
        int pre = q.front().second;
        q.pop();
        for (pair<int, int> p : tree[now]) {
            if (pre == p.first) continue;
            if (p.second % 2 == 0) color[p.first] = color[now];
            else color[p.first] = 1 - color[now];
            q.push({p.first, now});
        }
    }
    for (int i = 1; i <= N; i++) {
        printf("%d\n", color[i]);
    }
    return 0;
}

Measured memory_bytes: 6784
import java.io.*;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int i = 1;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a,b;
		
		while(i<=n){
			a = i/10;
			b = a/10;
			if(i%3==0){
				System.out.print(" "+i);
			}else if(i%10==3){
				System.out.print(" "+i);
			}else if(a%10==3){
				System.out.print(" "+i);
			}else if(b%10==3){
				System.out.print(" "+i);
			}else if(b/10==3){
				System.out.print(" "+i);
			}
			i++;
		}
		System.out.println();		
	}
}

Measured memory_bytes: 24144
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u) {
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u) {
	if ( u == NIL ) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void postParse(int u) {
	if ( u == NIL ) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

int main() {
	int i, v, l, r, root;

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

	for (i=0; i<n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}

	for (i=0; i<n; i++) if (T[i].p == NIL) root = i;

	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}



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

int main() {
  int a = 0;
  cin >> a;
  int m = a % 1000;
  if (m == 0){
    cout << 0;
  }else{
  int v = 1000 - m;
  cout << v;
    }
	return 0;
}


Measured memory_bytes: 3580
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;
#define mod 1000000007

int main(){
    int n,d;cin >> n >> d;
    int cnt=0;
    int f=d*2+1;
    while(n>0){
        n-=f;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
int main()
{
  long long N; cin >> N;
  vector<char> result;
  while (N) {
    N -= 1;
    long long dig = N % 26L;
    result.push_back(dig+97);
    N /= 26L;
  }
 
  for (auto i = result.rbegin(); i != result.rend(); i++) {
    cout << *i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
#include<cmath>
#include<ctime>
using namespace std;
int main()
{
	int i,j;
	for(i=1;i<10;i++)
		for(j=1;j<10;j++)
		{
		  cout<<i<<"x"<<j<<"="<<i*j<<endl;
		
		
		}

		return 0;
}

Measured memory_bytes: 1116