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

int main()
{
    int len;
    int num;

    cin >> len >> num;

    vector<int> list(num + 1, 0);
    vector<int> spaceList(num + 1, 0);

    //家の位置のリストを作る
    for (int i = 1; i <= num; i++)
    {
        cin >> list[i];
    }

    //次の家までの距離のリストを作る(まずN-1番目の家まで)
    for (int i = 1; i < num; i++)
    {
        spaceList[i] = list[i + 1] - list[i];
    }
    //N番目の家について
    spaceList[num] = len - list[num] + list[1];

    //一番大きい数値を探す
    vector<int>::iterator iter = max_element(spaceList.begin(), spaceList.end());
    int maxIndex = distance(spaceList.begin(), iter);

    // cout << maxIndex << endl;

    int ans = 0;

    //spaceListの値を足していけば答え。ただし一番距離が大きいところは足さない
    for (int i = 1; i <= num; i++)
    {
        // cout << spaceList[i] << "--";
        if (i == maxIndex)
        {
            continue;
        }
        ans = ans + spaceList[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string s; cin >> s;
    set<char> alphabet{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
                       'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                       'w', 'x', 'y', 'z'};

    for (const char &c: s) {
        if (alphabet.find(c) != alphabet.end()) alphabet.erase(c);
    }
    if (alphabet.empty()) {
        cout << "None" << endl;
    } else
        cout << *alphabet.begin() << endl;
}


Measured memory_bytes: 888
//#define _XCODE_DEBUG

#include <iostream>
#include <vector>
#include <queue>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

using graph = std::vector<std::vector<char>>;
using matrix = std::vector<std::vector<int>>;

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    
    // input data
    int H, W;
    std::cin >> H >> W;
    char maze[H][W];
    int c[H][W];
    int black = 0;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            std::cin >> maze[i][j];
            c[i][j] = 0;
            if (maze[i][j]=='#') ++black;
        }
    }
    
    // bfs
    int di[4] = {1,-1,0,0};
    int dj[4] = {0,0,1,-1};
    std::queue<int> qi;
    std::queue<int> qj;
    qi.push(0);
    qj.push(0);
    while (!qi.empty()) {
        int i = qi.front(); qi.pop();
        int j = qj.front(); qj.pop();
        for (int k=0; k<4; ++k) {
            int mi = i + di[k];
            int mj = j + dj[k];
            if (maze[mi][mj]=='#' || c[mi][mj]!=0) continue;
            if (mi<0 || mi>=H || mj<0 || mj>=W) continue;
            c[mi][mj] = c[i][j] + 1;
            qi.push(mi);
            qj.push(mj);
        }
    }
    
    if (c[H-1][W-1]) std::cout << H*W-(black+c[H-1][W-1]+1) << "\n";
    else std::cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<map>
#include <bits/stdc++.h>
#include<cmath>
#define mod 1000000007
#define ll long long 
using namespace std;

int main() {


  ll a,b;
  cin>>a>>b;
  if(a==1 && b==2)
  {
  	cout<<3<<endl;
  }
  else if(a==2 && b==1)
  {
  	cout<<3<<endl;
  }
  else if(a==3 && b==2)
  {
  	cout<<1<<endl;
  }
  else if(a==2 && b==3)
  {
  	cout<<1<<endl;
  }
  else if(a==3 && b==1)
  {
  	cout<<2<<endl;
  }else if(a==1 && b==3)
  {
  	cout<<2<<endl;
  }
	return 0;
}

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

struct interval {
  int s, f;
  interval(int s, int f) : s(s), f(f) { }
};
bool compare_f(const interval &x, const interval &y) {
  return x.f < y.f;
}
vector<interval> interval_scheduling(vector<interval> J) {
  vector<interval> A;
  sort(J.begin(), J.end(), compare_f);
  int f = -1e18;
  for (int i = 0; i < J.size(); ++i) {
    if (J[i].s >= f) {
      A.push_back(J[i]);
      f = J[i].f;
    }
  }
  return A;
}

void solve(long long N, std::vector<long long> X, std::vector<long long> L){
    vector<interval> vec;
    for(int i = 0;i < N;i++){
        vec.push_back(interval(X[i]-L[i], X[i]+L[i]));
    }
    cout<<interval_scheduling(vec).size()<<endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


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

using namespace std;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;



void solve() {
    ll r, d, x; cin >> r >> d >> x;
    ll tmp = x;
    for (int i = 1; i <= 10; i++) {
        tmp = r * tmp - d;
        cout << tmp << "\n";
    }
}

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

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}


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

static const auto NMAX = 100;

static int N, C[NMAX];

static bool solve() {
	int D;
	for(D = N; C[--D] == 0;);
	for(auto i = 0; i <= D; i++) {
		auto j = max(i, D - i);
		if(--C[j] < 0) return false;
	}
	auto b = (D + 1) / 2;
	for(auto i = 0; i <= b; i++) if(C[i] != 0) return false;
	return true;
}

static void input() {
	scanf("%d", &N);
	for(auto i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		C[x]++;
	}
}

int main() {
	input();
	puts(solve() ? "Possible" : "Impossible");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int X, A;
    read(X, A);
    int ans = 0;
    if(X >= A) ans = 10;
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

int main(void){
	int n, k;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout << d[n/2] - d[n/2-1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int a[102], b[102], c[102], ans, num, x, n;
int main(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + (n + 1));
    for(int i = 1; i <= n + 1; i++) {
        if(a[i] != a[i - 1] && a[i - 1] != 0) b[x] = a[i - 1], c[x] = num, num = 0, x++;
        num++;
    }
    if(x > 2){
    for(int i = 0; i < x; i++){
        for(int j = i + 1; j < x; j++){
            for(int k = j + 1; k < x; k++){
                if(b[i] + b[j] > b[k]) ans += (c[i] * c[j] * c[k]);
            }
        }
    }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	int[][] map;
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine() == true) {
			map = new int[12][12];
			for (int i = 0; i < map.length; i++) {
				String line = sc.nextLine();
				if (line.equals("")) line = sc.nextLine();
				for (int j = 0; j < map.length; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}
			
			int cnt = 0;
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map.length; j++) {
					if (map[i][j] != 0) {
						dfs(i, j);
						cnt++;
					}
				}
			}
			
			System.out.println(cnt);
		}
	}
	
	private void dfs(int x, int y) {
		if ((x < 0) || (x >= map.length) || (y < 0) || (y >= map.length)) return;
		if (map[x][y] == 0) return;
		map[x][y] = 0;

		dfs(x - 1, y);
		dfs(x + 1, y);
		dfs(x, y - 1);
		dfs(x, y + 1);
	}
}

Measured memory_bytes: 26032
#include <cassert>
#include <cstddef>
#include <functional>
#include <vector>

template <class T, class Operate = std::plus<T>, class Invert = std::negate<T>>
class cumulative_sum {
public:
  using value_type = T;

private:
  using size_t = std::size_t;

  Operate oper;
  Invert inve;
  std::vector<T> prefix;

public:
  cumulative_sum() = default;
  explicit cumulative_sum(const std::vector<T>& c, Operate oper = Operate(),
    T iden = T(), Invert inve = Invert())
    : oper(std::move(oper)), inve(std::move(inve)), prefix() {
    prefix.reserve(c.size() + 1);
    prefix.push_back(iden);
    for (const T& e : c) {
      prefix.push_back(oper(prefix.back(), e));
    }
  }

  T fold(const size_t first, const size_t last) const {
    assert(first <= last);
    assert(last < prefix.size());
    return oper(inve(prefix[first]), prefix[last]);
  }
  T operator[](const size_t index) const { return fold(index, index + 1); }
};

bool is_prime(int p) {
  if (p < 2) {
    return false;
  }
  for (int i = 2; i * i <= p; i += 1) {
    if (p % i == 0) {
      return false;
    }
  }
  return true;
}

#include<iostream>

int main() {
  int q;
  std::cin >> q;
  const int n = 100001;
  std::vector<int> a(n);
  for (int i = 0; i < n; i += 1) {
    if (i % 2 == 1 && is_prime(i) && is_prime((i + 1) / 2)) {
      a[i] = 1;
    }
    else {
      a[i] = 0;
    }
  }
  const cumulative_sum<int> s(a);
  while (q--) {
    int l, r;
    std::cin >> l >> r;
    std::cout << s.fold(l, r + 1) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1408
n,k = map(int,input().split())
v = list(map(int,input().split()))
a = 0 #左からaことる
b = 0 #右からbことる

ans = -10**10
while a <= min(k,n):
    while b <= min(k-a,n-a):
        plus = []
        minus = []
        for i in range(a):
            if v[i] >= 0:
                plus.append(v[i])
            else:
                minus.append(v[i])
        for i in range(b):
            if v[-1-i] >= 0:
                plus.append(v[-1-i])
            else:
                minus.append(v[-1-i])
        plus.sort()
        minus.sort()
        temp = sum(plus) + sum(minus)
        m = k-a-b #取り出した後に残った操作回数
        for i in range(min(m,len(minus))):
            temp += -minus[i]
        m = m - min(m,len(minus)) #負の数を戻した後に残った操作回数
        if temp > ans:
            ans = temp
        b += 1
    a += 1
    b = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#define TYPE_N 4

using namespace std;

int main () {
  bool first = true;
  while ( 1 ){
    int price, total = 0, result;
    int p;
    int m[ TYPE_N ] = { 10, 50, 100, 500 };
    int mn[ TYPE_N ];
    int rmn[ TYPE_N ];

    cin >> price;
    if( !price ){ return EXIT_SUCCESS; }
    if( first ){
      first = false;
    }else{
      cout << endl;
    }
    for( int i = 0; i < TYPE_N; i++ ) {
      cin >> mn[ i ];
      total += mn[ i ] * m[ i ];
    }

    result = total - price;

    for( int i = TYPE_N - 1; i >= 0; i-- ) {
      rmn[ i ] = result / m[ i ];
      result -= rmn[ i ] * m[ i ];
    }

    for( int i = 0; i < TYPE_N; i++ ) {
      int *minmp = &( rmn[ i ] > mn[ i ] ? mn[ i ] : rmn[ i ] );
      if( minmp == &mn[ i ] ){
        rmn[ i ] -= mn[ i ];
        mn[ i ] = 0;
      }else{
        mn[ i ] -= rmn[ i ];
        rmn[ i ] = 0;
      }
    }

    for( int i = 0; i < TYPE_N; i++ ){
      if( mn[ i ] ){
        cout << m[ i ] << " " << mn[ i ] << endl; 
      }
    }
  }
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;

public class Main extends Template{
	public void solve() throws IOException{
		String str = nextToken();
		if( str.charAt(0) != str.charAt(str.length()-1) ){
			System.out.println("o");
		} else {
			System.out.println(Character.toString(str.charAt(0)));
		}
		
	}
	
	public static void main(String[] args){
		new Main().run();
	}
}

abstract class Template implements Runnable{
	public abstract void solve() throws IOException;
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
		

Measured memory_bytes: 9200
#include<stdio.h>
#include<math.h>

int main(){
	double a,b,c,s,t;
	while(~scanf("%lf%lf%lf",&a,&b,&c)){
		s = sqrt(b*b-a*a/4)*a/2;
		t = sqrt(c*c + 2*b*c)*b/2;
		printf("%lf\n",s+t);
	}
	return 0;
}

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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size()-1; i += 2) {
        cout << s[i];
    }
    if (s.size() % 2) cout << s[s.size()-1];
    cout << endl;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n, a, b, c, d, e int
	fmt.Scan(&n, &a, &b, &c, &d, &e)

	x := []int{a, b, c, d, e}
	sort.Ints(x)
	min := x[0]

	count := int(math.Ceil(float64(n) / float64(min)))
	fmt.Println(count + 4)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define N 1000

int n;
long long T[N],lcm;

long long get_gcd(long long a,long long b)
{
	long long r = 1;
	if (a < b) swap(a,b);
	while (r != 0)
	{
		r = a%b;
		a = b;
		b = r;
	}
	return a;
}

void solve()
{
	lcm = 1;
	for (int i = 1; i <= n; i++)
		lcm = lcm/get_gcd(lcm,T[i])*T[i];
	printf("%lld\n", lcm);
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &T[i]);
	solve();
	return 0;
}

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

using namespace std;

int n,m,x,y;
int vis[100010];
vector<pair<int,int> > v;

int main() {
    scanf("%d %d", &n, &m);

    int l = 1, r = n;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &x, &y);
        l = max(l, x);
        r = min(r, y);
    }
    
    printf("%d\n", max(0,r - l + 1));
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n,wmax=map(int, input().split( ))
U=[]
for _ in range(n):
    v,w =map(int,input().split( ))
    u = v/w
    U.append([-u,v,w])
U.sort()

remains = wmax
i=0
ans = 0
while True:
    try:
        if remains > U[i][2]:
            remains-=U[i][2]
            ans+=U[i][1]
            i+=1
        else:
            ans += U[i][1]*remains/U[i][2]
            break
    except:
        break
print(ans)


Measured memory_bytes: 23788
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var T = ReadLine();
            var N = S.Length;
            var dctS = new Dictionary<char, List<long>>();
            var dctT = new Dictionary<char, List<long>>();
            for (var i = 0; i < N; ++i)
            {
                var s = S[i];
                if (!dctS.ContainsKey(s)) dctS[s] = new List<long>();
                dctS[s].Add(i);
                var t = T[i];
                if (!dctT.ContainsKey(t)) dctT[t] = new List<long>();
                dctT[t].Add(i);
                if (dctS[s].Count != dctT[t].Count)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


using P = pair<i64, i64>;

int main() {
    i64 N; cin >> N;
    vector<i64> X(N);
    REP(i, N) cin >> X[i];
    vector<i64> sX = X;
    sort(sX.begin(), sX.end());

    i64 medi = N / 2 - 1;
    i64 med = sX[medi];
    REP(i, N) {
        if (X[i] <= med) {
            cout << sX[medi + 1] << endl;
        } else {
            cout << sX[medi] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int S[n];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  int q;
  cin >> q;
  int T[q];
  for(int i=0;i<q;i++){
    cin >> T[i];
  }

  int cnt = 0;
  for(int ti=0;ti<q;ti++){
    for(int si=0;si<n;si++){
      if(T[ti] == S[si]){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3108
n = int(input())
a = list(map(int,input().split()))

#必要な4の倍数の数
need = n//2

#２の倍数、4の倍数の数
two = 0
four = 0
for num in a:
  if num%2 == 0:
    two += 1
  if num%4 == 0:
    four += 1
    
two -= four

if four + (two//2) >= need:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

a, b, x = nm()
d_min = x - (a % x)
if d_min == x: 
    d_min = 0
d_max = b % x
min = a + d_min
max = b - d_max
if min > max: 
    ans = 0
else:
    ans = ((max - min) // x + 1)
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

/////////////         qsortのラッピング

int qsort_int_compare_ascend(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int *array) {//昇順
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int *array) {//降順
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

int main() {
	long a, b, c, d, e, f, g;

	// a b d e だけ

	cin >> a >> b >> c >> d >> e >> f >> g;

	long sum = a + b + d + e;

	long _a = a % 2, _d = d % 2, _e = e % 2;

	long s = _a + _d + _e;
	if (s == 0 || s == 3) {
		cout << sum << endl;
	}
	else if (s == 1) {
		cout << sum - 1 << endl;
	}
	else {
		if (_a == 0 && a >= 2) {
			cout << sum - 1 << endl;
		}
		else if (_d == 0 && d >= 2) {
			cout << sum - 1 << endl;
		}
		else if (_e == 0 && e >= 2) {
			cout << sum - 1 << endl;
		}
		else {
			cout << sum - 2 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r>= 0 && x+r <= w && y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int []arr =new int[n];
		int max=1;
		for(int i=0;i<n;i++){
			arr[i]=scn.nextInt();
			max=Math.max(arr[i], max);
		}
		  res(arr,max);

	}
	public static void res(int []arr ,int max){
		int [] spf =new int[max+1];
		spf[1]=1;
	  for(int i=0;i<=max;i++){
		  spf[i]=i;
	  }
		for(int i=2;i<=max;i+=2){
			spf[i]=2;
		}
		for(int i=3;i*i<=max;i++){
			if(spf[i]==i){
			for(int j=i*i;j<=max;j+=i){
				if(spf[j]==j){
					spf[j]=i;
				}
			}
			
			}
		}
//		for(int i=0;i<spf.length;i++){
//			System.out.println(spf[i]);
//		}
		
		HashSet<Integer>hs2 =new HashSet<>();
		int ans=0;
		boolean f=false;
	  for(int i=0;i<arr.length;i++){
		  
		  HashSet<Integer> hs =pf(arr[i],spf);
		  ans+=hs.size();
		  for(int val :hs){
			  hs2.add(val);
		  }
		 // System.out.println(hs2.size()+" "+ans);
		  if(hs2.size()!=ans){
			  f=true;
			  break;
		  }
		  
	  }
	 
	  if(f==false){
		  System.out.println("pairwise coprime");
		  return ;
	  }else{
		  int gcd=arr[0];
		for(int i=1;i<arr.length;i++){
			gcd=gcd(gcd,arr[i]);
			if(gcd==1){
				System.out.println("setwise coprime");
				return ;
			}
		}
	  }
	  System.out.println("not coprime");
		
	}
	public static int gcd(int a ,int b){
		if(b==0){
			return a;
		}
		
		return gcd(b,a%b);
	}
	public static HashSet<Integer>  pf(int val,int [] spf){
		HashSet<Integer> hs =new HashSet<>();
		while(val!=1){
			hs.add(spf[val]);
			val/=spf[val];
		}
		return hs;
	}

}

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

constexpr int MAX = 3030;

int n;
vector<vector<int>> g;
vector<int> dp;

int dfs (int v) {
    if (dp[v] != -1) return dp[v];
    if (g[v].size() == 0) return dp[v] = 0;
    for (const int &u : g[v]) {
        dp[v] = max(dp[v], dfs(u) + 1);
    }
    return dp[v];
}

int main() {
    int m;
    cin >> n >> m;
    g.resize(n);
    dp.resize(n, -1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dfs(i));
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define endl "\n"
    #define MOD 1000000007
    #define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
    #define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
    //    for(auto& it : m)
    void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
    ll int power(ll int x, ll int y, ll int p)  
    {  
       ll int res = 1;     // Initialize result  
     
        x = x % p; // Update x if it is more than or  
                    // equal to p
       
        if (x == 0) return 0; // In case x is divisible by p;
     
        while (y > 0)  
        {  
            // If y is odd, multiply x with result  
            if (y & 1)  
                res = (res*x) % p;  
     
            // y must be even now  
            y = y>>1; // y = y/2  
            x = (x*x) % p;  
        }  
        return res;  
    }  
     
    ll int modInverse(ll int a,ll int m)
    {
        ll int g = __gcd(a, m);
       
            // If a and m are relatively prime, then modulo inverse
            // is a^(m-2) mode m
           
           return      power(a, m-2, m);
       
    }
     ll int maxProfit(ll int price[], ll int start,ll int end) 
{ 
  
   
    if (end <= start) 
        return 0; 
 ll   int profit = 0; 
  
    for (ll int i = start; i < end; i++) { 
  
        for (ll int j = i + 1; j <= end; j++) { 
  
            if (price[j] > price[i]) { 
  
           
                ll int curr_profit = price[j] - price[i] 
                                  + maxProfit(price, start, i - 1) ;
                profit = max(profit, curr_profit); 
            } 
        } 
    } 
    return profit; 
} 
    int main()
    {
     
      fastio();
     
    ll int T=1;
   // cin>>T;
     
    for(ll int test=1;test<=T;test++)
    {
         ll int n;
         cin>>n;
         ll int a[n];
         ll int i;
         for(i=0;i<n;i++)
            cin>>a[i];
        ll int amt=1000,cnt=0;
        i=0;
       while(i<n-1)
        {
            while(i<n-1&&a[i+1]<=a[i])
              {  i++;}
          if(i==n-1)break;
          cnt=amt/a[i];
          amt-=cnt*a[i];

            while(i<n-1&&a[i+1]>=a[i])
                i++;
            amt+=a[i]*cnt;
            cnt=0;

        }
     //   ll int ans= maxProfit(a,0,n-1);
        cout<<amt<<endl;
    
    }
     
     
     
    return 0;}

Measured memory_bytes: 3624
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
const int M = 59;
LL a[N];
LL b[M + 10];
int cnt[M + 10];
void setzero(LL& b, int o)
{
	b |= 1LL << o;
	b ^= 1LL << o;
}
void add(LL x)
{
	for (int j = M; j >= 0; j--)
	{
		if (x >> j & 1)
		{
			if (b[j] == 0)
			{
				b[j] = x;
				break;
			}
			x ^= b[j];
		}
	}
}
void refrain()
{
	vector<LL> v;
	for (int i = 0; i <= M; i++) v.push_back(b[i]);
	MEM(b, 0);
	for (auto& x : v)
		add(x);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	LL sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum ^= a[i];
		LL x = a[i];
		for (int j = M; j >= 0; j--)
		{
			cnt[j] += (a[i] >> j & 1);
		}
		add(a[i]);
	}
	LL ans = 0;
	LL o = 0;
	for (int i = M; i >= 0; i--)
	{
		if (cnt[i] == 0)
		{
			continue;
		}
		if (sum >> i & 1)
		{
			ans += 1LL << i;
			for (int j = 0; j <= M; j++)
			{
				setzero(b[j], i);
			}
			refrain();
			continue;
		}
		o |= 1LL << i;
		LL x = o;
		for (int j = M; j >= 0; j--)
		{
			if (x >> j & 1)
			{
				x ^= b[j];
			}
		}
		if (x & o)
		{
			o ^= 1LL << i;
			for (int j = 0; j <= M; j++)
			{
				setzero(b[j], i);
			}
			refrain();
		}
	}
	cout << ans + o * 2 << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  ll sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  ll s = 0;
  ll m = llINF;
  REP(i, N) {
    s += A[i];
    if (m > abs(sum - (2 * s)))
      m = abs(sum - (2 * s));
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}


int main(){
    int64_t n,k;
    cin >> n >> k;
    int64_t  ans=k;
    for(int i=1;i<n;++i) ans *= (k-1);

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

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,p = map(int, input().split())
ns = [[] for _ in range(n)]
rns = [[] for _ in range(n)]

mc = -1
for _ in range(m):
    u,v,c = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].append((p-c,v))
    rns[v].append(u)
q = [n-1]
seen = [False]*n
seen[n-1] = True
while q:
    u = q.pop()
    for v in rns[u]:
        if seen[v]:
            continue
        seen[v] = True
        q.append(v)
def bf(start):
    dist = [float("inf")]*n
    dist[start] = 0
    for i in range(n):
        for u in range(n):
            if dist[u]==float("inf"):
                continue
            for c,v in ns[u]:
                if dist[v] > dist[u] + c:
                    dist[v] = dist[u] + c
                    if i>=n-1 and seen[v]:
                        return -1
    return dist

dist = bf(0)
if dist==-1:
    ans = -1
else:
    ans = max(0, dist[n-1]*-1)
print(ans)

Measured memory_bytes: 75504
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <pair<ll,int> > v;
ll a[100004];
ll tat[100004];
int main(){
	int n,m;
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i]; 
	sort (a,a+n);
	for (int i=1;i<n;i++) a[i]+=a[i-1];
	int l=0;
	for (int i=0;i<m;i++){
		int x;ll y;
		cin>>x>>y;
		v.push_back(make_pair(y,x)); 
	}
	ll ans=a[n-1];
	int kil=0,t=m-1;
	sort (v.begin(),v.end());
	while (t>=0 && kil<n){
		int ola=0;
		while (kil<n && ola<v[t].second) tat[kil]=(kil==0)?v[t].first:tat[kil-1]+v[t].first,kil++,ola++;
		t--;		
	}
	for (int i=0;i<n;i++) if (kil>=i){
		ans=max(ans,a[n-1]-a[i]+tat[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 3440
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	string S;
	long long K;
	cin >> S;
	cin >> K;

	long long jdg = 1;
	for (long long i = 0; i < S.length() - 1; i++) {
		if (S[i + 1] == S[i]) {
			jdg += 1;
		}
	}

	long long jdg1 = S.length();

	long long cnt = 0;
	for (long long i = 0; i < S.length() - 1; i++) {
		if (S[i + 1] == S[i]) {
			cnt += 1;
			i++;
		}
	}

	long long dcnt = 0;
	S += S;
	for (long long i = 0; i < S.length() - 1; i++) {
		if (S[i + 1] == S[i]) {
			dcnt += 1;
			i++;
		}
	}

	dcnt = dcnt - 2 * cnt;

	long long ans = K * cnt + (K - 1) * dcnt;


	// ������̑S�Ă����������̂Ƃ������A��O����
	if (jdg == jdg1) {
		ans = K * jdg1 / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n, m;
	cin >> n >> m;
	int mini = 1;
	int maxa = n;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		mini = max(a, mini);
		maxa = min(b, maxa);
	}
	if (mini > maxa) {
		cout << 0 << endl;
		return 0;
	}
	cout << maxa - mini + 1 << endl;
}

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

int N,L;

int main() {
    cin>>N>>L;
    int taste=N*(2*(L-1)+1+N)/2;
    if (0<L) taste-=L;
    else if (L+N-1<0) taste-=L+N-1;
    cout<<taste<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) cout<<0<<endl;
    else{
        ll aa=a-a/2,bb=b-b/2,cc=c-c/2;
        cout<<min({abs(a/2-aa)*b*c,a*abs(b/2-bb)*c,a*b*abs(c/2-cc)})<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n, m;

	cin >> n >> m;

	int k[n], a[n][30];

	for(int i = 0; i < n; i++){
		cin >> k[i];
		for(int j = 0; j < k[i]; j++){
			cin >> a[i][j];
		}
	}

	int ans = 0, temp;

	for(int fav = 1; fav <= m; fav++){
		temp = 0;
		for(int i=0; i< n; i++){
			for(int j=0;j<k[i];j++){
				if(fav == a[i][j]){
					temp++;
					break;
				}
			}
		}
		if(temp==n){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
#define ci const int&
#define cl const long long&
#define cul const unsigned long long&
#define io_f std::ios::sync_with_stdio(false)
using namespace std;

const int mod = 1e9 + 7;
int h, w ;
int A, B ;
ull le[200010];

inline ull ksm (int x, int y) {
    ull bs = x, ans = 1;
    while (y) {
        if (y & 1) ans *= bs;
        if (ans >= mod) ans %= mod;
        bs *= bs;
        if (bs >= mod) bs %= mod;
        y >>= 1;
    }
    return ans;
}

inline ull C (int x, int y) {
    ull a1 = le[x];
    ull b1 = (le[y] * le[x-y]) % mod;
    b1 = ksm(b1, mod-2);
    return (a1*b1) % mod;
}

int main() {
    scanf("%d %d %d %d", &h, &w, &A, &B);
    ull ans = 0;
    le[0] = 1; le[0] = 1;
    for (int i = 1; i <= h+w; i++) {
        le[i] = le[i-1] * i;
        if (le[i] >= mod) le[i] %= mod;
    }
    for (int i = B; i <= w - 1; i++) {
        ans += (C(i+h-A-1,i)*C(A-1+w-i-1,A-1));
        ans %= mod;
    }
    printf("%llu",ans);
    return 0;
}

Measured memory_bytes: 1792
"""
author : halo2halo
date : 13,Nov,2019
"""

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N, D = map(int, readline().split())

print((N+2*D)//(2*D+1))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr <<"\e[91m"<<__func__<<": "<< #x << " = " << x <<"\e[39m"<< "\n"
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;


int main()
{
#ifndef ONLINE_JUDGE
    freopen("../io/in.txt", "r", stdin);
    //freopen("../io/out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int n;
    cin >> n;
    int ac = 0, tle = 0, wa = 0, re = 0;
    string s;
    while(n--) {
        cin >> s;
        if(s[0] == 'A') ac++;
        else if(s[0] == 'T') tle++;
        else if(s[0] == 'W') wa++;
        else if(s[0] == 'R') re++;
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	public static void main(String[] args) {
		while (read()) {
			solve();
		}
	}
	
	static Scanner sc = new Scanner(System.in);
	static int A, B;
	static boolean read() {
		A = sc.nextInt();
		B = sc.nextInt();
		return (A != 0 && B != 0) ? true : false; 
	}

	static int[] coin = {1000, 500, 100};
	static void solve() {
		int cur = B - A;
		int[] ret = new int[3];
		for (int i = 0; i < 3; i++) {
			ret[i] = cur / coin[i];
			cur -= ret[i] * coin[i];
		}
		System.out.println(ret[2] + " " + ret[1] + " " + ret[0]);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	char C;
	cin >> C;

	if ('A' <= C && C <= 'Z') {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}

}






Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();
		int n1,n2,n3;
		if(a<=b && a<=c) {
			n1=a;
			n2=(b<=c)?b:c;
			n3=(b>=c)?b:c;
			}
		else if (b<=c) {
			n1=b;
			n2=(a<=c)?a:c;
			n3=(a>=c)?a:c;
		}
		else{
			n1=c;
			n2=(a<=b)?a:b;
			n3=(a>=b)?a:b;
		}
		
		System.out.print(n1+" "+n2+" "+n3+"\n");

	}

}

Measured memory_bytes: 17328
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a <= 8 && b <= 8){
            System.out.println("Yay!");
            return;
        }
        System.out.println(":(");
    }
}


Measured memory_bytes: 21716
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b,x ) FOR(i, a, b){ printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) REP(i, n){ printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int i, j;
    int n, count;

    while (1){
        scanf("%d", &n);

        if (n == 0){
            break;
        }

        int S[n];
        int P[n];
        bool flag[n];

        memset(flag, false, sizeof(flag));
        count = 0;
        
        for (i = 0; i < n; ++i){
            scanf("%d", &S[i]);
        }

        memset(P, 0, sizeof(P));

        while (1){
            for (i = 0; i < n; ++i){
                for (j = 0; j < n; ++j){
                    if (S[i] == S[j]){
                        P[i]++;
                    }
                }
            }
            
            if(memcmp(P, S, sizeof(S)) == 0){
                break;
            }

            memcpy(S, P, sizeof(P));
            memset(P, 0, sizeof(P));
            
            count++;

        }
        
        printf("%d\n", count);

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

    return 0;
        
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main()
{
	int i=-1;
	char str[1024];
	gets(str);
	while(i++!=strlen(str))if('`'<str[i]&&str[i]<'{')str[i]-=32;
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 524
while True:
    try:
        a1,b1,c1,a2,b2,c2 = map(float,raw_input().split(' '))
        det = a1*b2-b1*a2
        x = (c1*b2-b1*c2)/det
        if not x:
            x = 0.
        y = (a1*c2-c1*a2)/det
        if not y:
            y = 0.
        print '{0:.3f} {1:.3f}'.format(x,y)
    except:
        break

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define f first
#define sec second
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	vector<ll>r,w;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]=='W')
		w.pb(i);
		else
		r.pb(i);
	}
	ll ri=r.size()-1,wi=0;
	ll ans=0;
	while(wi<w.size()&&ri>=0&&w[wi]<r[ri])
	{
		ans++;
		wi++;
		ri--;
	}
	cout<<ans<<endl;
	

}


Measured memory_bytes: 5764