akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  int a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll odd[100005] = {0};
    ll even[100005] = {0};
    REP(i,n){
      if(i%2) odd[input()]++;
      else {even[input()]++;}
    }

    ll maxO=0,maxE=0;
    REP(i,100005){
      if(odd[maxO]<odd[i]) maxO=i;
      if(even[maxE]<even[i]) maxE=i;
    }

    sort(odd,odd+100005);
    reverse(odd,odd+100005);

    sort(even,even+100005);
    reverse(even,even+100005);

    ll ans = n;
    if(maxE==maxO) ans -= max(odd[0]+even[1],odd[1]+even[0]);
    else ans -= odd[0]+even[0];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <string>
#include <stack>
using namespace std;
 

int main() {
    stack<int>S; int a, b; string s;
    while(cin>>s){
      if(s[0]=='+'){
        b=S.top(); S.pop();
        a=S.top(); S.pop();
        S.push(a+b);
      }
      else if(s[0]=='-'){
        b=S.top(); S.pop();
        a=S.top(); S.pop();
        S.push(a-b);
      }
      else if(s[0]=='*'){
        b=S.top(); S.pop();
        a=S.top(); S.pop();
        S.push(a*b);
      }
      else{
        S.push(stoi(s));
      }
    }
    cout << S.top() << endl;
    return 0;
}

Measured memory_bytes: 3128
import sys
from queue import deque
input = sys.stdin.readline

def main():
    N, Q = list(map(int, input().split()))
    graph = [[] for i in range(N)]
    # 最初にroot pointを定めて:
    # graph構造に大して点を与える...
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    
    points = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        points[p-1] += x
    
    visited = [False] * N
    
    nodes = deque([0])

    while nodes:
        node = nodes.pop()
        visited[node] = True
        for _node in graph[node]:
            if visited[_node]:
                continue
            points[_node] += points[node]
            nodes.append(_node)
    
    print(*points)
    
main()

Measured memory_bytes: 95888
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int Left = a + b;
    int Right = c + d;
    if(Left == Right) cout << "Balanced" << endl;
    else cout << (Left < Right ? "Right" : "Left") << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
import copy

N,K=map(int,input().split())
A=list(map(int,input().split()))

A=[0]+list(accumulate(A))
data=[]
for i in range(0,N):
    for j in range(i+1,N+1):
        data.append(A[j]-A[i])

digit=40
q=copy.copy(data)
ans=0
while digit>=0:
    test=[[] for i in range(0,digit+1)]
    for i in range(0,len(q)):
        for j in range(0,digit+1):
            if q[i]>>j & 1==1:
                test[j].append(q[i])

    for i in range(0,digit+1):
        if len(test[digit-i])>=K:
            ans+=2**(digit-i)
            q=copy.copy(test[digit-i])
            digit=digit-i-1
            break
    else:
        break

print(ans)


Measured memory_bytes: 192744
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //char in[120];
  int a,b; cin>>a>>b;
  int ans = 0;
  rep(i,2) {
    if (a<b) {
      ans += b;
      b--;
    } else {
      ans += a;
      a--;
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
int main(){

	string s;
	cin >>s ;
	int n=s.size();
	int i;
	for(i=1;i<=n;i++){
		s[5]= 32;
		s[13]= 32;
		
	}
	cout<<s;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N; cin >> N;
  int a[110];
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  int alice, bob; alice=0; bob=0;
  
  //降順にソート
  sort(a, a+N, greater<int>());
  
  for (int i=0; i<N; i++){
    if (i%2==0){
      alice = alice + a[i];
    }
    else{
      bob = bob + a[i];
    }
  }
  
  cout << alice - bob << endl;
  
}

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

int main(){
  string s;
  cin >> s;  
  if(s[0]=='a'||s[1]=='a'||s[2]=='a'){
    if(s[0]=='b'||s[1]=='b'||s[2]=='b'){
      if(s[0]=='c'||s[1]=='c'||s[2]=='c'){
	cout << "Yes" << endl;
      }else{cout << "No" << endl;}
    }else{cout << "No" << endl;}
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<functional>
#include<set>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  while(true){
    int n,x;
    cin>>n>>x;
    if(!n&&!x)break;
    vector<int> menu(n);
    for(int i=0;i<n;i++){
      cin>>menu[i];
    }
    int p = -1;
    bool money[x+1];
    money[0] = true;
    for(int i=1;i<x+1;i++){
      money[i] = false;
      for(int j=0;j<n;j++){
	if(i>=menu[j]&&money[i-menu[j]])
	  money[i] = true;
      }
      if(money[i]&&prime[i])p=i;
    }
    if(p==-1)cout<<"NA"<<endl;
    else cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 2860
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto ans = "";
    while (N != 0)
    {
        ans = cast(char)('a' + (N - 1) % 26) ~ ans;
        N--;
        N /= 26;
    }
    writeln(ans);
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b;
	cin >> a >> b;

	int ans = a * b - (a + b - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from collections import defaultdict

def main():
  n, m = map(int, input().split())
  db2a = defaultdict(list)
  for _ in range(m):
    a, b = map(int, input().split())
    db2a[b-1].append(a-1)
    
  cnt = 0
  end = 0
  for b in sorted(db2a.keys()):
    if end <= max(db2a[b]):
      cnt += 1
      end = b
  print(cnt)

if __name__=='__main__':
  main()



Measured memory_bytes: 28572
#include <bits/stdc++.h>
using namespace std;
double t,a[3001],f[3001][3001],s;
int main()
{
        int n,i,j;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
                scanf("%lf",&a[i]);
        }
        f[0][0]=1;
        for(i=1;i<=n;i++)
                f[i][0]=f[i-1][0]*(1-a[i]);
        for(i=1;i<=n;i++)
        {
                for(j=1;j<=i;j++)
                {
                        f[i][j]=f[i-1][j-1]*a[i]+f[i-1][j]*(1-a[i]);
                }
        }
        s=0;
        for(i=n/2+1;i<=n;i++)
        {
                s+=f[n][i];
        }
        printf("%.10lf",s);
        return 0;
}


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

int x, y;
int main()
{
	cin >> x >> y;
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
		{
			cout << "Yes" << endl;
		} else
		{
			cout << "No" << endl;
		}
	} else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		if (y == 4 || y == 6 || y == 9 || y == 11)
		{
			cout << "Yes" << endl;
		} else
		{
			cout << "No" << endl;
		}
	} else
	{
		if (y == 2)
		{
			cout << "Yes" << endl;
		} else
		{
			cout << "No" << endl;
		}
	}

	cin.get();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define fori(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define p pair<int,int>
#define vi vector<int>
#define space " "
#define endl "\n"
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
void buildsegment(vi &arr, vi &tree, int node, int start, int end) {
	if (start == end) {
		tree[node] = arr[start];
		return;
	}
	int mid = (start + end) / 2;
	buildsegment(arr, tree, 2 * node + 1, start, mid);
	buildsegment(arr, tree, 2 * node + 2, mid + 1, end);
	tree[node] = min(tree[2 * node + 1] , tree[2 * node + 2]);
}
void updatesegment(vi &arr, vi &tree, int node, int start, int end, int idx, int val) {
	if (start == end) {
		arr[idx] = val;
		tree[node] = val;
	}
	else {
		int mid = (start + end) / 2;
		if (start <= idx && idx <= mid) {
			updatesegment(arr, tree, 2 * node + 1, start, mid, idx, val);
		}
		else {
			updatesegment(arr, tree, 2 * node + 2, mid + 1, end, idx, val);
		}
		tree[node] = min(tree[2 * node + 1] , tree[2 * node + 2]);
	}
}
int rmquery(vi &tree, int node, int start, int end, int l, int r) {
	if (l > end || start > r) {
		return INT_MAX;
	}
	if (l <= start && r >= end) {
		return tree[node];
	}
	int mid = (start + end) / 2;
	int p1 = rmquery(tree, 2 * node + 1, start, mid, l, r);
	int p2 = rmquery(tree, 2 * node + 2, mid + 1, end, l, r);
	// cout << min(p1, p2) << endl;
	return (min(p1, p2));
}
void solve() {
	int n;
	cin >> n;
	int a = 0, w = 0, tl = 0, r = 0;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC") {
			a++;
		}
		else if (s == "WA") {
			w++;
		}
		else if (s == "TLE") {
			tl++;
		}
		else {
			r++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << tl << endl;
	cout << "RE x " << r << endl;
}
int32_t main() {
#ifndef ONLINE_JUDGE
	//read input into input.txt
	freopen("input.txt", "r", stdin);
	//write output into output.txt
	freopen("output.txt", "w", stdout);
#endif
	fastio;
	// w(t) {
	// 	solve();
	// }
	solve();
	return 0;
}

Measured memory_bytes: 3616
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N, M, K, res = 0;
	vector<long long int> A, B;

	cin >> N >> M >> K;
 
	rep(i, N){
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
 
	rep(i, M){
		int tmp;
		cin >> tmp;
		B.push_back(tmp);
	}
 
	long long int Asum = 0, Anum = 0;
	rep(i, N){
		if(Asum+A[i] > K){
			break;
		}else{
			Asum += A[i];
			Anum++;
		}
	}
	long long int Bsum = 0, Bnum = 0;
	rep(i, M){
		Bsum += B[i];
		Bnum++;
		while(1){
			if(Asum + Bsum > K){
				if(Anum == 0){
					break;
				}
				Asum -= A[Anum-1];
				Anum--;
			}else{
				break;
			}
		}
		if(Asum + Bsum > K){
				break;
		}

		if(res < Anum+Bnum){
			res = Anum+Bnum;
		}
	}


	Bsum = 0, Bnum = 0;
	rep(i, M){
		if(Bsum+B[i] > K){
			break;
		}else{
			Bsum += B[i];
			Bnum++;
		}
	}
	Asum = 0, Anum = 0;
	rep(i, N){
		Asum += A[i];
		Anum++;
		while(1){
			if(Asum + Bsum > K){
				if(Bnum == 0){
					break;
				}
				Bsum -= B[Bnum-1];
				Bnum--;
			}else{
				break;
			}
		}
		if(Asum + Bsum > K){
				break;
		}

		if(res < Anum+Bnum){
			res = Anum+Bnum;
		}
	}
 
 
	cout << res;
 
	return 0;
}

Measured memory_bytes: 7920
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int count = 0;

    for (int i = 0; i < 4; i++) {
        int tmp = n % 10;
        if (tmp == 2) {
            count++;
        }
        n /= 10;
    }

    cout << count << endl;

    return 0;
}


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

int main(){
    int a[31], n;
    fill(a, a+31, 0);
    for(int i = 0; i < 28; i++){
        cin >> n;
        a[n] = 1;
    }
    for(int i = 1; i <= 30; i++){
        if( !a[i] ) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	X := make([]int, N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		X[i] = x
	}

	sort.Ints(X)

	distinct := false
	for i := 0; i < N-1; i++ {
		if X[i] == X[i+1] {
			distinct = true
		}
	}
	if distinct {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


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

using vi = std::vector<int>;

constexpr int nil = 0;

class BinaryHeap
{
public:

    BinaryHeap(int n)
        : nodes(n + 1)
    {}

    virtual ~BinaryHeap() = default;

    int parent(int id) const
    {
        return modifiedIndex(id / 2);
    }

    int left(int id) const
    {
        return modifiedIndex(id * 2);
    }

    int right(int id) const
    {
        return modifiedIndex(id * 2 + 1);
    }

    int size() const
    {
        return nodes.size();
    }

    void show(int id) const
    {
        using namespace std;
        cout << "node " << id << ": key = " << nodes[id] << ", ";
        if (parent(id) != nil)
            cout << "parent key = " << nodes[parent(id)] << ", ";
        if (left(id) != nil)
            cout << "left key = " << nodes[left(id)] << ", ";
        if (right(id) != nil)
            cout << "right key = " << nodes[right(id)] << ", ";
        cout << endl;
    }

    void show() const
    {
        for (int i = 1; i < nodes.size(); ++i)
        {
            show(i);
        }
    }

    const int& operator[](int i) const
    {
        return nodes[i];
    }

    int& operator[](int i)
    {
        return nodes[i];
    }

protected:

    vi nodes;

    int modifiedIndex(int i) const
    {
        if (i <= 0 || i >= nodes.size())
            i = nil;
        return i;
    }
};

class MaximumHeap : public BinaryHeap
{
public:

    using BinaryHeap::BinaryHeap;

    virtual ~MaximumHeap() = default;

    void maxHeapify(int i)
    {
        auto l = left(i);
        auto r = right(i);
        int largest;

        if (l < nodes.size() && l > nil && nodes[l] > nodes[i])
            largest = l;
        else
            largest = i;
        if (r < nodes.size() && r > nil && nodes[r] > nodes[largest])
            largest = r;

        if (largest != i)
        {
            std::swap(nodes[i], nodes[largest]);
            maxHeapify(largest);
        }
    }

    void buildMaxHeap()
    {
        for (int i = (nodes.size() - 1) / 2; i >= 1; --i)
            maxHeapify(i);
    }
};

void solve()
{
    using namespace std;
    int n;
    cin >> n;

    MaximumHeap mh {n};

    for (int i = 1; i <= n; ++i)
    {
        cin >> mh[i];
    }

    mh.buildMaxHeap();
    for (int i = 1; i <= n; ++i)
    {
        cout << " " << mh[i];
    }

    cout << endl;
}

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


Measured memory_bytes: 4560
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static final void solve() {
		try (Scanner cin = new Scanner(System.in)) {

			int N = cin.nextInt();
			int M = cin.nextInt();
			int[] b = new int[M];

			int[] a2 = new int[M];

			int a_;
			int b_;
			int index = 0;
			int index2 = 0;

			for (int i = 0; i < M; i++) {
				a_ = cin.nextInt();
				b_ = cin.nextInt();
				if (a_ == 1) {
					b[index] = b_;
					index++;
				} else if (b_ == N) {
					a2[index2] = a_;
					index2++;
				}
			}

			Arrays.sort(a2);

			for (int i = 0; i < index; i++) {
				b_ = b[i];
				if (Arrays.binarySearch(a2, b_) > 0) {
					System.out.println("POSSIBLE");
					return;
				}
				;

			}
			System.out.println("IMPOSSIBLE");
		} finally {
		}
	}
}


Measured memory_bytes: 95744
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <typename T> using V = vector<T>;

ll S, T, D;
V<ll> W;

ll solve() {
    cin >> S >> T >> D;
    W.resize(D);
    for(auto &e : W) cin >> e;
    V<ll> sum(D + 1);
    for(ll i = 0; i < D; i++) sum[i + 1] = sum[i] + W[i];
    auto min_v = min_element(sum.begin(), sum.end());
    if(*min_v == 0) return -1;
    if(S + *min_v > T && sum.back() >= 0) return -1;
    ll diff = T - S;
    ll init_ok = T - *min_v;
    ll x = max<ll>(0, S - init_ok);
    ll y = abs(sum.back());
    ll ret = 0;
    if(y) ret += x / y + !!(x % y);
    ll now = S - abs(sum.back()) * ret;
    ret *= D;
    for(ll i = 0; i < D; i++) {
        now += W[i];
        if(now <= T) return ret + i + 1;
    }
    assert(false);
}

int main() {
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 4404
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int x, y;
	while (true) {
	    String[] line = sc.nextLine().split(" ");
	    x = Integer.parseInt(line[0]);
	    y = Integer.parseInt(line[1]);
	    if (x == 0 && y == 0) break;

	    if (x > y) {
		System.out.println(y + " " + x);
	    } else {
		System.out.println(x + " " + y);
	    }
	}
    }
}

Measured memory_bytes: 29972
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9+7;

typedef tuple<int,int,int> State; // operator< defined
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef double ld;

/*---------------Matrix Multiplication-------------------
struct matrix {
  // N is the size of the matrix
  int m[N][N];
  matrix()
  {
     memset(m,0,sizeof(m));
  }
  matrix operator * (matrix b)
  {
     matrix c = matrix();
     for (int i = 0; i < N; ++i)
       for (int j = 0; j < N; ++j)
         for (int k = 0; k < N; ++k) 
           c.m[i][j] = (c.m[i][j] + 1LL * m[i][k] * b.m[k][j]) % M;
     return c;
  }
};
// Note that this multiplication method can be used to multiplying numbers,matrixes,etc....
matrix modPow(matrix m,int n)
{
  if ( n == 0 )
    return unit; // the unit matrix - that is 1 for principal diagonal , otherwise 0
  matrix half = modPow(m,n/2);
  matrix out = half * half;
  if ( n % 2 )
    out = out * m;
  return out; 
}
-----------------END-----------------------------------*/
int sum() { return 0; }

template<typename T, typename... Args>
auto sum(T a, Args... args) { return a + sum(args...); }
template<class T> bool uin(T &a,T b) {return a > b ? (a == b, true) : false; }
template<class T> bool uax(T &a,T b) {return a < b ? (a == b, true) : false; }

int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#endif

	int t,i;
	string n;
	cin>>t;
	set<string> ans;
	while(t--) {
	    cin>>n;
	    ans.insert(n);
	}
	cout<<ans.size()<<"\n";


    
#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}

Measured memory_bytes: 19392
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;


int main (){
     int x;
     cin >> x;
     if(x == 0)cout << 1 << endl;
     else cout << 0 << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, L;
	cin >> N >> L;
	vector<int> a(N+10);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < N; i++) {
		if (a[i] + a[i+1] >= L) {
			puts("Possible");
			for (int k = 1; k < i; k++) {
				cout << k << endl;
			}
			for (int k = N-1; k >= i+1; k--) {
				cout << k << endl;
			}
			cout << i << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void erase(vector<int> &v, int m) { // erase mth
    m = m % v.size();
    v.erase(v.begin() + m);
    vector<int> w;
    FOR(i,m,v.size()) {
        w.push_back(v[i]);
    }
    REP(i,m) {
        w.push_back(v[i]);
    }
    swap(v,w);
}

int Joseph(vector<int> v, int m) {
    while(v.size()-1) {
        erase(v,m-1);
    }
    return v[0];
}

int main() {
    int n, m;
    while(cin >> n >> m, n + m) {
        vector<int> v;
        REP(i,n) {
            v.push_back(i+1);
        }
        cout << Joseph(v,m) << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;




int main()
{
    idfc;

    char e;
    cin>>e;
    int i=e;

    if(i>=65&&i<96)cout<<"A";
    else cout<<"a";


    return 0;
}

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

int main() {
    long long x;
    cin >> x;
    long long ans = x / 11;
    ans *= 2;
    x %= 11;
    if(x > 0 && x < 7) ans += 1;
    else if(x > 6) ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

b = []
for i in range(N):
    b.extend([i + 1] * a[i])

for i in range(H):
    row = b[i * W:(i + 1) * W]
    if i % 2 == 1:
        row.reverse()
    print(' '.join([str(c) for c in row]))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
long long h;
int main() {
    cin >> h;
    long long cnt = 0;
    long long sum = 0;
    while (h != 0) {
        h /= 2;
        cnt++;
    }

    for(int i = 0; i < cnt; ++i) {
        sum += pow(2, i);
    }

    cout << sum << endl;
    
}

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

int main() {
  ll h, w; cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (h * w + 1) / 2 << endl;
}

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

int main()
{
	char s[4];
	cin >> s;

	rep(i, 3){
		if(s[i] == '7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int a, b, cnt = 0;
	cin >> a >> b;
	if (b >= 0) {
		for (int i = 0; i < a; ++i) {
			cnt = cnt + i + b;
		}
		cnt = cnt - b;
	}
	else if (a > -b) {
		for (int i = 0; i < a; ++i) {
			cnt = cnt + i + b;
		}
	}
	else {
		for (int i = 0; i < a-1; ++i) {
			cnt = cnt + i + b;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define beg(i ,n) for(int i=0;i<n;i++)
#define beg1(i ,n) for(int i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 998244353 ;
const ll MAX = 1e5 + 7;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------

void solve(){
	vector<ll> dp(100001 , 0) ;
	ll n , w;
	cin >> n >> w ;
	vector<vector<ll> > ar(n) ;
	beg(i , n) ar[i] = vector<ll> (2) ;
	beg(i , n) cin >> ar[i][0] >> ar[i][1] ;
	beg(i , n){
		for(int j=w ; j>=ar[i][0] ; j--){
			dp[j] = max(dp[j] , ar[i][1]+dp[j-ar[i][0]]) ;
		}
	}
	//beg1(i , w+1) cout << dp[i] << " " ;
	//cout << nl ;
	cout << dp[w] ;
}
 
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

Measured memory_bytes: 1024
//jackさんのコードを参考にしました
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<math.h>

using namespace std;

int main(){

	int A[26];
	for(int i = 0; i < 26; i++){
		A[i] = 0;
	}
	string s;
	cin >> s;

	for(int i = 0; i < s.size(); i++){
		A[int(s[i]) - 97]++;
	}

	for(int i = 0; i < 26; i++){
		if(A[i]%2 != 0){
			cout << "No" <<endl;
			return 0;
		}
	}
	cout << "Yes" <<endl;

	return 0;
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

double f(double x){
  return 4*x*(1-x);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  vector<pair<ll, string>> v(0);

  sin(s);
  rep(i, 3){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 3632
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - y2 + y1
y3 = y2 + x2 - x1
x4 = x1 - y2 + y1
y4 = y1 - x1 + x2
print(x3,y3,x4,y4)


Measured memory_bytes: 9104
from collections import Counter

N = int(input())
S = [list((map(str,input().split()))) for _ in range(N)]

A = []
for i in S:
    ew_str = ''.join(sorted(i[-1]))
    A.append(ew_str)

cnt = Counter(A)
cnt = list(cnt.values())
#print(cou)

ans = 0
for i in cnt:
    ans +=i*(i-1)//2
print(ans)

Measured memory_bytes: 44196
import java.util.*;

class Main {
	Scanner sc;
	long N, X, D;
	Map<Integer, List<long[]>> f;
	Comparator<long[]> c;
	{
		c = Comparator.comparingLong(a -> a[0]);
		c = c.thenComparingLong(a -> a[1]);
	}
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		X = sc.nextLong();
		D = sc.nextLong();
		
		if (D == 0) {
			if (X == 0) System.out.println(1);
			else System.out.println(N+1);
			return;
		}
		if (D < 0) { X = -X; D = -D; }
		
		f = new HashMap<>();
		for (int k = 0; k <= N; k++) {
			long s = X*k+D*(k-1)*k/2;
			long e = X*k+D*(2L*N-k-1)*k/2;
			int m = (int)((k*X)%D);
			List<long[]> segs = f.get(m);
			if (segs == null) segs = new ArrayList<>();
			segs.add(new long[] {s, e});
			f.put(m, segs);
		}
		long cnt = 0;
		for (List<long[]> segs : f.values()) {
			segs.sort(c);
			long doneE = Long.MIN_VALUE;
			for (long[] seg : segs) {
				long s = Math.max(doneE+D, seg[0]);
				long e = seg[1];
				if (s > e) continue;
				cnt += (e-s)/D+1;
				doneE = e;
			}
		}
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

using namespace std;

string s[1000];
int arr[300];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i<3; i++)cin >> s[i];
    int ans = 0;
    for(int i = 0; i<n; i++){
        for(int j = 0; j<300; j++)arr[j] = 0;
        int mx = 0;
        for(int k = 0; k<3; k++){
            arr[s[k][i]]++;
            mx = max(mx,arr[s[k][i]]);
        }
        ans += mx;
    }
    cout << 3*n-ans << endl;
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

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

	int x, a, b;
	cin >> x >> a >> b;
	a = -a;
	a += b;
	if (a <= 0) cout << "delicious" << endl;
	else if (a > 0 && a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        N: usize,
    }

    if N == 1 {
        println!("1");
    } else if N % 2 == 0 {
        println!("0.5");
    } else {
        println!("{}", ((N / 2) + 1) as f64 / (N as f64));
    }

}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = input()
    
    if S.startswith('keyence'):
        print("YES")
        sys.exit()
        
    if S.endswith('keyence'):
        print("YES")
        sys.exit()
        
    key = "keyence"
    for i in range(1, len(key)):
        key_s = key[:i]
        key_e = key[i:]
        
        if S.startswith(key_s) and S.endswith(key_e):
            print("YES")
            sys.exit()
            
    print("NO")
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 39280
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int n,a,b;
  cin>>n;
  if(n==1){
	   cout<<"Hello World"<<endl; 
	 }
   else{
	   cin>>a>>b;
	   cout<<a+b<<endl;
	  }	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  auto f=
    MFP([&](auto dfs,int a,int b,int c,int k)->bool{
      if(a<b and b<c) return true;
      if(k==0) return false;
      bool res=0;
      res|=dfs(a*2,b*1,c*1,k-1);
      res|=dfs(a*1,b*2,c*1,k-1);
      res|=dfs(a*1,b*1,c*2,k-1);
      return res;
    });

  int a,b,c,k;
  cin>>a>>b>>c>>k;

  cout<<(f(a,b,c,k)?"Yes":"No")<<newl;
  return 0;
}


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

#define all(x) 		 (x).begin(),(x).end()
#define mp     		 make_pair
#define pb 				 push_back
#define fi 				 first
#define se 				 second
#define sz(x) 		 ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x)  for(auto& y:x)
#define pii 			 pair<int,int>
#define vi 				 vector<int>

int dbg = 0;
#define cri   		 if(0)
#define shame 		 cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;


void solve() {
  int n, m;
  cin >> n >> m;
  int ee = (n * (n - 1)) >> 1;
  int eo = (m * (m - 1)) >> 1;
  cout << (ee + eo) << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        List<Integer> A = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) { A.add(sc.nextInt()); }

        solver(N, A);
    }

    public static void solver(int N, List<Integer> A) {

        while(true) {
            Collections.sort(A);
            int min = A.get(0);

            List<Integer> tmp = new ArrayList<Integer>();
            tmp.add(min);

            for (int i = 1; i < A.size(); i++) {
                if (A.get(i) % min != 0) {
                    tmp.add(A.get(i) % min);
                }
            }

            A = tmp;

            if(tmp.size() == 1){
                out.println(tmp.get(0));
                break;
            }

            //for(int i : tmp){
            //    out.print(i + ",");
            //}
            //out.println();
        }
    }
}

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

using namespace std;

int l[2000+5];

int main(){
    int n,memo,memo1,memo2;
    long long ans=0;

    cin >> n;
    for(int i=0; i<n;i++) cin >> l[i];
    sort(l, l+n);

    for (int a=0; a<n-2; a++){
        for (int b=a+1; b<n-1; b++){
            memo = max(l[a]-l[b],l[b]-l[a]);
            auto lft = upper_bound(l,l+n,memo);
            auto rgt = lower_bound(l,l+n,l[a]+l[b]);
            memo1 = rgt-lft;
            
            if (*rgt == n || memo1<=0 || rgt <= &l[b]) {
            continue; }
            if (lft<=&l[b]) memo1 = rgt-&l[b];
            
    
            /*
            memo1 = lft - &l[0]+1;
            memo2 = rgt - &l[0]+1;
            cout << a << " " << b << " "<<  l[*lft]<< memo1 <<" "<<memo2-memo1<< endl;
            if (memo2 == n || memo2-memo1<=0) {continue; 
            cout<<1111;}
            */
            ans += memo1-1; 
            
        }  
    }

    cout << ans << endl;

 


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

const ll MAX = 510000;
const ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

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

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);
    auto unit_r = 180.0 / M_PI;

    int64_t x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    auto d = (x + y) / 3;
    if (x - d < 0 || y - d < 0) {
        cout << 0 << endl;
        return 0;
    }
    auto a = x - d;
    auto b = y - d;


    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<1000000; i++){
        fac[i+1] = fac[i]*(i+1) % M;
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M;
    }
    ll ans=0;
    ans = comb(a+b, a)%M;
    cout << ans << endl;
}


Measured memory_bytes: 15872