akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N, L;
	cin >> N >> L;
	vector<ll> v(N);
	ll max2 = 0, max2i = 0;
	cin >> v[0];
	reppp(i, 1, N-1){
	    cin >> v[i];
	    if(max2 < v[i-1] + v[i]){
	        max2 = v[i-1] + v[i];
	        max2i = i;
	    }
	}
	if(max2 < L){
	    cout << "Impossible";
	    return 0;
	}
	cout << "Possible" << endl;
	reppp(i, 1, max2i-1){
	    cout << i << endl;
	}
	for(int i = N-1; i >=max2i+1; i--){
	    cout << i << endl;
	}
	cout << max2i;
	return 0;
}

Measured memory_bytes: 1664
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

def func(n,c,d):
    a1 = n//c
    a2 = n//d
    a3 = n//lcm(c,d)
    return n - (a1+a2-a3)

a,b,c,d = map(int,input().split(' '))
ans = func(b,c,d)-func(a-1,c,d)
print(ans)

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

int dp[110][2][4];
int seen[110][2][4];
string digit;
int k;

int solve(int id, int can, int cnt)
{
    if(cnt > k) return 0;
    if(id == digit.size())
        return cnt == k;
    if(seen[id][can][cnt]) return dp[id][can][cnt];
    int num = digit[id] - '0';
    int ans = 0;
    for(int i = 0; i < 10; i++)
        if(can or i <= num)
            ans += solve(id + 1, can or i < num, cnt + (i > 0));
    seen[id][can][cnt] = true;
    return dp[id][can][cnt] = ans;
}

int32_t main()
{
    cin >> digit >> k;
    cout << solve(0, 0, 0) << '\n';
  
	return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

const int N = 1000;
char s[N+1], t[N+1];
int ls, lt;
int q;
int dp[N+1][N+1];
//dp[i][j] = s[0]...s[i-1]??¨t[0]...t[j-1]???LCS
//(1<=i<=ls, 1<=j<=lt)

int main() {
  int i, j, k;
  scanf("%d ", &q);
  for (k=0; k<q; k++) {
    ls = lt = 0;
    memset(s, 0, sizeof(s)), scanf("%s ", s);
    memset(t, 0, sizeof(t)), scanf("%s ", t);
    while (s[ls]) ls++;
    while (t[lt]) lt++;

    memset(dp, 0, sizeof(dp));
    for (i=1; i<=ls; i++)
      for (j=1; j<=lt; j++) {
        if (s[i-1]==t[j-1])
          dp[i][j] = dp[i-1][j-1] + 1;
        else
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }

    printf("%d\n", dp[ls][lt]);
  }

  return 0;
}

Measured memory_bytes: 5104
#define SORT(v) sort(begin(v), end(v))
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define LLINF (long long)1e18
#define NMAX 100000
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
// #define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;


ll N,M,K,T[NMAX],A,B,C,D,E;
int dp[NMAX][MMAX] = {};


static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 0;

void solve(){
    // 解答アルゴリズム
    int count = 0, lim = 0;
    sort(T, T+N);
    for (int i = 0; i < N; ++i)
    {
        if (count == C || T[i] > lim)
        {
            count = 1;
            ans++;
            lim = T[i] + K;
        }
        else
        {
            ++count;
        }
    }
}
void debug(){
    // デバッグ用出力
    for (int i = 0; i < N; ++i)
    {
        cout << T[i] << " ";
    }
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    // Fill(dp, -1);

    cin >> N >> C >> K;
    ll lim = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> T[i];
    }
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

int main(){
    using namespace std;
    int N;
    cin>>N;
    string S;
    cin>>S;
    vector<vector<int>> a(N,vector<int>(3));
    a[N-1][0]=0;
    a[N-1][1]=0;
    a[N-1][2]=0;
    if(S[N-1]=='R'){
        a[N-1][0]=1;
    }else if(S[N-1]=='G'){
        a[N-1][1]=1;
    }else{
        a[N-1][2]=1;
    }

    for(int i=N-2;i>=0;i--){
        a[i][0]=a[i+1][0];
        a[i][1]=a[i+1][1];
        a[i][2]=a[i+1][2];
        if(S[i]=='R'){
            a[i][0]++;
        }else if(S[i]=='G'){
            a[i][1]++;
        }else{
            a[i][2]++;
        }
    }

    //long long ans=N*(N-1)*(N-2);
    long long ans=0;
    for(int i=0;i<=N-3;i++){
        for(int j=i+1;j<=N-2;j++){
            //cout<<ans<<endl;
            //ans-=N-1-j;
            if(S[i]!=S[j]){
                int r=0;
                int g=0;
                int b=0;
                if(S[i]=='R'){
                    r=1;
                }else if(S[i]=='G'){
                    g=1;
                }else{
                    b=1;
                }
                if(S[j]=='R'){
                    r=1;
                }else if(S[j]=='G'){
                    g=1;
                }else{
                    b=1;
                }
                int k=0;
                if(r==0){
                    k=0;
                }else if(g==0){
                    k=1;
                }else{
                    k=2;
                }
                //cout<<k<<endl;

                ans+=a[j+1][k];
                if(2*j-i<N){
                    if(S[j+j-i]=='R'){
                        if(k==0){
                            ans--;
                        }
                    }else if(S[j+j-i]=='G'){
                        if(k==1){
                            ans--;
                        }

                    }else{
                        if(k==2){
                            ans--;
                        }
                    }
                }
            }
        }
    }

    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    string S;
    cin >> S;
    bool has_b = false;
    bool has_a = false;
    for(auto c:S){
        if(c == 'A'){
            has_a = true;
        }else if(c == 'B'){
            has_b = true;
        }
    }

    if(has_a && has_b){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }


}

int main(){
    Main();
}

Measured memory_bytes: 256
class String
  @@encode = {}
  @@decode = {}

  def encode
    res = split('').map{ |c| @@encode[c] }.join

    while res.size % 5 != 0
      res << '0'
    end

    res
  end

  def decode
    res = ""
    s = 0

    size.times do |t|
      c = @@decode[self[s..t]]
      if c then
        res += c
        s = t + 1
      end
    end

    res
  end


  @@encode[" "] = "101"
  @@encode["'"] = "000000"
  @@encode[","] = "000011"
  @@encode["-"] = "10010001"
  @@encode["."] = "010001"

  @@encode["?"] = "000001"
  @@encode["A"] = "100101"
  @@encode["B"] = "10011010"
  @@encode["C"] = "0101"
  @@encode["D"] = "0001"
  @@encode["E"] = "110"
  @@encode["F"] = "01001"
  @@encode["G"] = "10011011"

  @@encode["H"] = "010000"
  @@encode["I"] = "0111"
  @@encode["J"] = "10011000"
  @@encode["K"] = "0110"
  @@encode["L"] = "00100"
  @@encode["M"] = "10011001"
  @@encode["N"] = "10011110"

  @@encode["O"] = "00101"
  @@encode["P"] = "111"
  @@encode["Q"] = "10011111"
  @@encode["R"] = "1000"
  @@encode["S"] = "00110"
  @@encode["T"] = "00111"
  @@encode["U"] = "10011100"

  @@encode["V"] = "10011101"
  @@encode["W"] = "000010"
  @@encode["X"] = "10010010"
  @@encode["Y"] = "10010011"
  @@encode["Z"] = "10010000"

  @@decode["00000"] = "A"
  @@decode["00001"] = "B"
  @@decode["00010"] = "C"
  @@decode["00011"] = "D"
  @@decode["00100"] = "E"
  @@decode["00101"] = "F"
  @@decode["00110"] = "G"

  @@decode["00111"] = "H"
  @@decode["01000"] = "I"
  @@decode["01001"] = "J"
  @@decode["01010"] = "K"
  @@decode["01011"] = "L"
  @@decode["01100"] = "M"
  @@decode["01101"] = "N"

  @@decode["01110"] = "O"
  @@decode["01111"] = "P"
  @@decode["10000"] = "Q"
  @@decode["10001"] = "R"
  @@decode["10010"] = "S"
  @@decode["10011"] = "T"
  @@decode["10100"] = "U"

  @@decode["10101"] = "V"
  @@decode["10110"] = "W"
  @@decode["10111"] = "X"
  @@decode["11000"] = "Y"
  @@decode["11001"] = "Z"

  @@decode["11010"] = " "
  @@decode["11011"] = "."
  @@decode["11100"] = ","
  @@decode["11101"] = "-"
  @@decode["11110"] = "'"
  @@decode["11111"] = "?"
end


while line = gets
  puts line.encode.decode
end

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    if(n<=k){
      System.out.println(n*x);
    }else{
      System.out.println(k*x+(n-k)*y);
    }
  }
}

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

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  if (n==1 || n==2){
    cout << n << endl;
  }
  
  int dig = 0;
  int sum = 0;
  for (int i = 1; i < n; ++i) {
    sum += i;
    if(sum >= n) {
      dig = i;
      break;
    }
  }
  
  for (int i = 1; i <= dig; ++i) {
    if(i == sum - n) continue;
    else cout << i << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm> 
#include <math.h>
/*
   メモ
#inlucde <string>
memset(配列,初期化値,sizeof(配列));//配列初期化

#include <queue>
push(),back(),front()
pop()//最初の要素削除

#inclue <stack>
pop(),push(),top(),empty()

__builtin_popcount(unsigned int);

*/

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;
const int SIZE= 1000000;
bool prime[SIZE];
vector<int> primes;

int main() {
	rep (i, SIZE) prime[i] = true;
	prime[0] = prime[1] = false;
	//素数生成
	for (int i = 0; i * i <= SIZE; ++i) {
		if (!prime[i]) continue;
		for (int j = i * i; j <= SIZE; j += i) {
			prime[j] = false;
		}
	}
	rep (i, SIZE) if (prime[i]) primes.push_back(i);
	
	

	int n, p;
	while (true) {
		cin >> n >> p;
		if (n == -1 && p == -1) break;
		
		//イテレータから要素取り出し
		int pos = upper_bound(primes.begin(), primes.end(), n) - primes.begin();
		

		vector<int> res;
		rep (i, p) rep (j, p) {
			res.push_back(primes[pos + i] + primes[pos + i + j]);
		}
		sort(res.begin(), res.end());
		cout << res[p - 1] << endl;

	}
	return 0;
}

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


int main(){
  int N, M, a, b, i, j;
  cin >> N >> M;
  vector<int> t(N);
  
  for(i = 0; i < M; i++){
    cin >> a >> b;
    t.at(a-1)++;
    t.at(b-1)++;
  }
    
  for(i = 0; i < N; i++){
    cout << t.at(i) << endl;
  }

}


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

#define PI 3.14159265359

int main(void)
{
    int n, r; // ?????°, ?§????
    int temp_r;
    double x=0.0, y=0.0;

    scanf("%d,%d", &n, &r);
    y = n;
    temp_r = r;

    while(1) {
        scanf("%d,%d", &n, &r);
        if(n==0 && r==0) break;

        x += n * sin(PI / 180.000 * temp_r);
        y += n * cos(PI / 180.000 * temp_r);
        temp_r += r;
    }

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

    return 0;
}

Measured memory_bytes: 604
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    H1, M1, H2, M2, K = input_number_list()
    t1 = H1 * 60 + M1
    t2 = H2 * 60 + M2
    print(t2 - t1 - K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
use std::collections::BinaryHeap;

fn main() {
    let (_, m) = {
        let tmp: Vec<i32> = read_vec();
        (tmp[0], tmp[1])
    };
    let mut a = {
        let tmp: Vec<i64> = read_vec();
        BinaryHeap::from(tmp)
    };

    for _ in 0..m {
        let head = a.pop().unwrap();
        a.push(head / 2);
    }

    let ans: i64 = a.iter().sum();

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 8444
/*
�����ߣ�NJYZ_LHW
����ʱ�䣺
�㷨���ͣ�
��Ŀ��

*/
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm> 
#include <queue>
using namespace std;

int main()
{
	int n;
	vector <long long>a;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		a.push_back(t);
	}
	sort(a.begin(),a.end(),greater<long long>());
	
	
	int ct=0;
	vector <long long> vl;
	vector <long long> sum;
	for (int i=1;i<=a.size();i++)
	{
		ct++;
		if (i==n)
		{
			vl.push_back(a[i-1]);
			sum.push_back(ct);
			ct=0;
		}
		else if (a[i]!=a[i-1])
		{
			vl.push_back(a[i-1]);
			sum.push_back(ct);
			ct=0;
		}
	}
	////for (int i=1;i<a.size();i++)  //�߽����� 
//	{
//		ct++;
//		if (a[i]!=a[i-1] || i==n-1)
//		{
//			
//			if (i==n-1)
//			{
//				vl.push_back(a[i]);    //�߽����� 
//				sum.push_back(ct+1);
//			}
//			else
//			{
//				vl.push_back(a[i-1]);
//				sum.push_back(ct);
//			}
//			ct=0;
//		}
//	}
	
	long long rs;
	deque<long long> dq1;
	deque<long long> dq2;
	
	dq1.push_back(sum[0]);
	dq2.push_back(vl[0]);
	rs=(sum[0]-1) * vl[0];
	
	for (int i=1;i<sum.size();i++)
	{
		long long t1,t2;
		long long f=0;
		long long tsum=sum[i];
		t1=dq1.front();
		t2=dq2.front();
		dq1.pop_front();
		dq2.pop_front();
		while (tsum>=t1)
		{
			//if (i==3)
//			{
//				cout<<t1<<" "<<t2<<endl;
//			}
			rs+=t1*t2;
			tsum-=t1;
			if (!dq1.empty())
			{
				t1=dq1.front();
				t2=dq2.front();       //ѭ�������壬ϸ˼ 
				dq1.pop_front();
				dq2.pop_front();
			}
			else
			{
				f=1;
				break;
				
				//break; ���� ѭ����	
			}
				
		}
		
		if (f)
		{
			rs+=tsum*vl[i];
			dq1.push_back(tsum+(sum[i]-tsum)*2);
			dq2.push_back(vl[i]);
		}
		else
		{
			
			rs+=t2*tsum;
			dq1.push_front(t1-tsum);
			dq2.push_front(t2);
			dq1.push_back(sum[i]*2);
			dq2.push_back(vl[i]);
		}
	}
	cout<<rs;
	return 0;
}



Measured memory_bytes: 10048
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; 

char Map[53][53];
int M,N,Ans,Flag;

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
	for(int j=1;j<=M;j++)
	cin >>Map[i][j];
	
	for(int i=1;i<=N;i++)
	for(int j=1;j<=M;j++)
	if(Map[i][j]=='#')
	{
		if(Map[i-1][j]=='#') continue;
		if(Map[i+1][j]=='#') continue;
		if(Map[i][j-1]=='#') continue;
		if(Map[i][j+1]=='#') continue;
		printf("No");
		return 0;
	}
	printf("Yes");
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
   public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        String enzan = scan.next();
        int b = scan.nextInt();
        
        if (enzan.equals("+")) {
          System.out.println(a + b);
        } else {
          System.out.println(a - b);
        }
        scan.close();
   }
}


Measured memory_bytes: 21844
s=input()
l=len(s)
t="abcdefghijklmnopqrstuvwxyz"
d={}
for i in t:d[i]=0
for i in s:d[i]+=1
a=l*(l-1)//2
for i in t:a-=d[i]*(d[i]-1)//2
print(a+1)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;




#define rep(i, n) for(ll i=0; i<(n); ++i)
#define repp(i, a, b) for(ll i = (a); i <= (b); i++)

const ll MOD=pow(10, 9) + 7;


int main(void){
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    ll x;
    x = min(min(a, b), c);
    x = min(min(x, d), e);

    ll tmp = (n + x-1)/x;
    //n/xの切り上げ


    cout << tmp + 4 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <iostream>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	// int n ;
	// cin >> n ;
	bool ok = true ;
	string s , t ;
	cin >> s >> t ;
	if (s.length() + 1 != t.length()) ok = false ;
	for (int i = 0 ; i < s.length() ; i++) {
		if (s[i] != t[i]) ok = false ;
	}

	if (ok) cout << "Yes\n";
	else cout << "No\n";



	// cout << << "\n";




	return 0 ;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool isPalindrome(string s){
    string t = s;
    reverse(t.begin(),t.end());//sを反転させたｔがsと一致してたら返す．
    return s == t;
}
 
int main() {
  string s;
  cin >> s;
bool ans = true;
if(!isPalindrome(s)) ans = false;//もし返り値が一致していなかったらans=false
if(!isPalindrome(s.substr(0,s.size()/2))) ans = false;//もし返り値の１文字目から半分の一つ前の文字が一致していなかったらfalse

cout << (ans ? "Yes" : "No") << endl; //ans=trueならYes,falseならNoを出力
 return 0;

}

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

struct sig{
	long long a;
	long long b;
};

int compare_int(const void *a,const void *b){
	struct sig A=*(struct sig*)a,B=*(struct sig*)b;
	if(A.b>B.b)return 1;
	return -1;
}

int main(){
	int n,i;
	struct sig ab[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld%lld",&ab[i].a,&ab[i].b);
	qsort(ab,n,sizeof(struct sig),compare_int);
	long long tmp=0;
	for(i=0;i<n;i++){
		tmp+=ab[i].a;
		if(tmp>ab[i].b){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 6396
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)

c = 0

for i in range(n+1) :
  d = a[i] - b[i]
  if d >= 0 :
    c += b[i]
  else :
    c += a[i]
    if i < n :
      e = a[i+1] - (-d)
      if e >= 0 :
        c += -d
        a[i+1] = e
      else :
        c += a[i+1]
        a[i+1] = 0
      
print(c)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll m, n;
    cin >> n >> m;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++)
        cin >> a[i];   
    ll sum = accumulate(a.begin(), a.end(), 0);
    //db(sum);
    ll cutoff = (sum + (4 * m) - 1) / (4 * m), count = 0;
    FOR(i, n){
        if(a[i] >= cutoff) ++count;
    }
    if(count >= m) cout << "Yes\n";
    else cout << "No\n"; 
}

Measured memory_bytes: 256
n,a=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
sx=sum(x)
dp=[[0]*(n+1) for i in range(sx+1)]
dp[0][0]=1
for i in range(n):
    dp_sub=[[0]*(n+1) for j in range(sx+1)]
    for j in range(sx+1):
        for k in range(n+1):
            if (j==0 and k==0) or dp[j][k]!=0:
                dp_sub[j+x[i]][k+1]=dp[j][k]
    for j in range(sx+1):
        for k in range(n+1):
            dp[j][k]+=dp_sub[j][k]
cnt=0

for i in range(min(sx//a,n)):
    cnt+=dp[a*(i+1)][i+1]
#print(dp)
print(cnt)

Measured memory_bytes: 77788
// https://atcoder.jp/contests/abc060/tasks/arc073_a?lang=ja
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, t, now = 0, end = 0, sum = 0;
    cin >> n >> t;
    REP(i, n) {
        cin >> now;
        // 水が切れていた場合
        if (end < now) {
            sum += t;
        } else {
            sum += now - (end - t);
        }
        // 水が切れる時刻
        end = now + t;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
list_V = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_VC = [list_V[i] - list_C[i] for i in range(N)]
count = 0
for i in range(N):
    if list_VC[i] > 0:
        count += list_VC[i]
print(count)

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

int main ()
{
	int r, c;
	cin >> r >> c;
	int a[r+1][c+1];
	for (int i=0; i<=r; i++)
		for (int j=0; j<=c; j++)
			a[i][j] = 0;
		
	for (int i=0; i<r; i++)
		for (int j=0; j<c; j++) {
		
			cin >> a[i][j];
			a[r][c] += a[i][j]; }
	
	for (int i=0; i<r; i++)
		for (int j=0; j<c; j++)
			a[i][c] += a[i][j];		
	
	for (int i=0; i<c; i++)
		for (int j=0; j<r; j++)
			a[r][i] += a[j][i];	
	
	for(int i = 0;i <= r;i++){
        for(int j = 0;j <= c;j++){
            cout << a[i][j];
                if(j != c){
                        cout << " ";
                	}
                }
                cout << endl;	}
	return 0;							
}

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


ll n;
typedef pair<ll,ll> pll;
vector< pll > ans;
void makeit(ll X)
{
        for(ll i=2;i<=X;i++){
                ans.pb(make_pair(i,i-1));
        }
        ans.pb(make_pair(X, n+1));
        for(ll i=2;i<=X;i++){
                ans.pb(make_pair(n+i,n+i-1));
        }
}
void pints()
{
        cout << "Yes\n";
        for(auto &i:ans){
                cout << i.first << " " << i.second << "\n";
        }
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        ll pw = 1LL;
        set<ll> S;
        S.insert(pw);
        while(pw <= 100000){
                pw *= 2LL;
                S.insert(pw);
        }
        cin >> n;
        if(S.find(n) != S.end()){
                cout << "No\n"; return 0;
        }
        if(n%4 == 3){
                makeit(n);
                pints();
                return 0;
        }else if(n%4 == 1) {
                makeit(n-2);
                ans.pb(make_pair(1LL , n));
                ans.pb(make_pair(n, n-1));
                ans.pb(make_pair(1LL , n+n-1));
                ans.pb(make_pair(n+n-1, n+n));
                pints();
                return 0;
        }else if(n%4 == 2) {
                makeit(n-3);
                ans.pb(make_pair(1LL , n-1));
                ans.pb(make_pair(n-1, n-2));
                ans.pb(make_pair(1LL , n+n-2));
                ans.pb(make_pair(n+n-2, n+n-1));
                ans.pb(make_pair(n-1, n));
                ans.pb(make_pair(2LL , n+n));
                pints(); return 0;
        }else {
                makeit(n-1);
                ll yo = n-1;
                ll reqq = yo ^ n;
                ans.pb(make_pair(yo, n));
                ans.pb(make_pair(n+reqq-1, n+n));
                pints();
                return 0;
        }
        return 0;
}


Measured memory_bytes: 6504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S; cin >> S;
    if(S == "mew"){ cout << "Cat" << endl; return 0;}
    while(true){
        string T = S.substr(1,S.length()-2);
        size_t idx = T.find("mew");
        if(idx == string::npos){
            cout << "Rabbit" << endl;
            return 0;
        }
        T.erase(idx,3);
        S = S[0] + T + S[S.length()-1];
        if(S.length() <= 3){
            if(S == "mew"){
                cout << "Cat" << endl;
            }else{
                cout << "Rabbit" << endl;
            }
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N>>K;
  cout <<(N%K==0?0:1)<<endl;
  // print();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int P = sc.nextInt();
		int paiMax;
		P += A*3;
		paiMax = P/2;
		System.out.println(paiMax);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  lint n;
  cin >> n;
  lint ans = (1 + (n - 1)) * (n - 1) / 2;
  cout << ans << endl;
  return 0;
}

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

int main() {

	string s;
    cin >> s;
	bool ok = true;
	int n = s.size();

	for(int i=0;i<n/2;i++){
		if(s[i] != s[n-1-i]){
			ok = false;
		}
	}
	int nn = (n-1) / 2;
	for(int i=0;i<nn/2;i++){
		if(s[i] != s[nn-i-1]){
			ok = false;
		}
	}
	nn = (n+3) / 2 - 1;
	for(int i=0;i<(n-nn)/2;i++){
		if(s[i+nn] != s[n-1-i]){
			ok = false;
		}
	}
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
L = [int(input()) for i in range(5)]

LL = {}

for i in range(len(L)):
	I = str((L[i]-1))[-1]
	I = int(I)
	LL[i] = I

key = [k for k,v in LL.items() if v == min(LL.values())][0]

min = L[key]
L[key] = 0

for i in range(0,5):
	digit_one = str(L[i])[-1]
	if digit_one != "0":
		L[i] += 10 - int(digit_one)
	
print(sum(L) + min)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbd(a) cout << #a << ": " << a << endl
#define dbd2(a,b) cout << #a << ": " << a << ", " << #b << ": " << b << endl 
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto _i:a) cout << _i << " "; cout << endl
#define adbp(a) for(auto _i:a) cout << _i.first << " " << _i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 998244353
#define N 1000010
#define M 100010
using namespace std;

vector< vector<char> > mat;
vector< vector<bool> > vis;
vector< vector<int> > dist;
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};

bool chk(int x, int y, int n, int m) { return(x >= 0 && x < n && y >= 0 && y < m && mat[x][y] != '@');}

void bfs(int x, int y, int n, int m, int k)
{
    queue< pair<int,int> > q;
    q.push({x, y});
    dist[x][y] = 0;
    vis[x][y] = true;

    while(!q.empty())
    {
        int xx = q.front().first, yy = q.front().second;
        q.pop();

        for(int i=0; i<4; i++)
        {
            for(int j=1; j<=k; j++)
            {
                int nx = xx + dx[i]*j, ny = yy + dy[i]*j;

                if(!chk(nx, ny, n, m)) break;
                if(vis[nx][ny] && dist[nx][ny] < dist[xx][yy] + 1) break;
                if(vis[nx][ny]) continue;

                vis[nx][ny] = true;
                dist[nx][ny] = dist[xx][yy] + 1;
                q.push({nx, ny});
            }
        }
    }
}

int main()
{
    fastIO;
    int h, w, k;
    cin >> h >> w >> k;

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;

    mat = vector< vector<char> >(h, vector<char>(w));
    vis = vector< vector<bool> >(h, vector<bool>(w, false));
    dist = vector< vector<int> >(h, vector<int>(w, 0));

    int i, j;
    
    for(i=0;i<h;i++)
        for(j=0;j<w;j++)
            cin >> mat[i][j];

    bfs(x1, y1, h, w, k);

    if(!vis[x2][y2]) cout << "-1" << endl;
    else cout << dist[x2][y2] << endl;
}   

Measured memory_bytes: 12216
import java.util.Scanner;



public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll w, h;
  cin >> w >> h;
  ll x, y;
  cin >> x >> y;

  
  cout << w*h/2.0 << " ";


  if(w/2.0 == (double)x && h/2.0 == (double)y) cout << 1 << endl;  
  else cout << 0 << endl;
  


  return 0;
}


Measured memory_bytes: 256
// AOJ ALDS1_5_C Koch Curve
// 2018.4.30 bal4u

#include <stdio.h>
#include <math.h>

#define PI 3.1415926535897932384626433832795

double d; int a;
double vcos[6], vsin[6];
double x, y;

void koch_curve(int k)
{
	if (k == 0) {
		x += d*vcos[a % 6], y += d*vsin[a%6];
		printf("%.8lf %.8lf\n", x, y);
	} else {
		d /= 3;
		koch_curve(k-1), a++, koch_curve(k-1);
		a += 4;
		koch_curve(k-1), a++, koch_curve(k-1);
		d *= 3;
	}
}

int main()
{
	int n, i;
	
	for (i = 0; i < 6; i++) vcos[i] = cos(i*PI/3), vsin[i] = sin(i*PI/3);

	scanf("%d", &n);

	d = 100;		// (0,0) - (100,0);

	a = 0, x = 0, y = 0; puts("0.00000000 0.00000000");
	koch_curve(n);
	return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<limits.h>

int main(void){
    long N;
    long capa[5];
    scanf("%ld %ld %ld %ld %ld %ld", &N, &capa[0], &capa[1], &capa[2], &capa[3], &capa[4]);

    int i;
    long min = LONG_MAX;
    int idx;
    for(i = 0 ; i < 5; i++){if(min > capa[i]){min = capa[i]; idx = i;}}

    long first = idx + 1;
    long second = 5 - (idx+1);
   
    long group = 0;
    if(N <= min){group = 1;}
    //これ（直下の一行）が間違い。
    //N%minをする理由は、全部で何隊あるかを確かめるため。
    //仮にN%min=2であっても、それは2グループ余ったわけではなく、2人グループが1グループ分余ったということ。
    //else{group = (N/min) + (N%min);}
    else if(N % min == 0){group = N/min;}
    else{group = N/min + 1;}
    
    for(i = 0; i < group - 1; i++){second++;}

    printf("%ld\n", first + second);
    
    return 0;
}


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

const int INF = 1001001001;
int dp[1000005][2];

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j;
    if (x < 10) chmin(dp[i+1][0], dp[i][j]+x);
    if (x > 0) chmin(dp[i+1][1], dp[i][j]+(10-x));
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9220
#include <stdio.h>

#define maxN 100

void select(int N,int A[]){
	int i,j,tmp,min,swc=0;
	for(i=0;i<N-1;i++){
		min = i;
		for(j=i;j<N;j++){
			if(A[j] < A[min]){
				min = j;
			}
		}
		tmp = A[i];
		A[i] = A[min];
		A[min] = tmp;
		if(min != i)swc++;
	}
	for(i=0;i<N;i++){
		printf("%d",A[i]);
		if(i < N-1){
			printf(" ");
		}
	}
	printf("\n%d\n",swc);
}

int main(void){
	int c,n,a[maxN];
	scanf("%d",&n);
	for(c=0;c<n;c++){
		scanf("%d",&a[c]);
	}
	select(n,a);
}


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

#define ll long long 
#define int ll
#define endl "\n"

const int mx = 9;
vector <vector <char> >grid(mx, vector <char> (mx));
vector <vector <char> >temp(mx, vector <char> (mx));
set <int> rows;
set <int> cols;
int h, w, k;

int result(){
	temp.clear();
	temp = grid;
	for (int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			if (rows.count(i) or cols.count(j)){
				temp[i][j] = '.';
			}
		}
	}
	
	int cont = 0;
	for (int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			if (temp[i][j] == '#') cont++;
		}
	}
	
	return cont;
}

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.txt", "r", stdin); 
	//freopen("output.txt", "w", stdout);
		
	
	cin >> h >> w >> k;
	for (int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			cin >> grid[i][j];
		}
	}	
	
	int ans = 0;
	
	for (int row_mask = 0; row_mask < (1<<h); row_mask++){
		rows.clear();
		for (int row_bit = 0; row_bit < h; row_bit++){
			if (row_mask&(1<<row_bit)){
				rows.insert(row_bit);
			}
		}
		
		for (int col_mask = 0; col_mask < (1<<w); col_mask++){
			cols.clear();
			for (int col_bit = 0; col_bit < w; col_bit++){
				if (col_mask&(1<<col_bit)){
					cols.insert(col_bit);
				}
			}
//				cerr << "Rows ";
//				for (int i:rows) cerr << i << " ";
//				cerr << endl << "Columns ";
//				for (int i:cols) cerr << i << " ";
//				cerr << endl;
				int this_ = result();
//				cerr << "Number of black cells: " << this_ << endl;
				if (this_ == k) ans++;
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
	ll ans = 0;
	makel(N);
	makel(K);
	if (K == 0)ans = N * N;
	else FOR(b, K, N + 1) {
		ans += N / b * (b - K) + max(0ll, N%b - K + 1);
	}
	say(ans);
}

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        double lol = i * 1.08;
        if ((int) lol == n) {
            cout << i;
            return;
        }
    }
    cout << ":(";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2!=0)
  {cout<<"No";
   return 0;}
  for(int i=0;i<n/2;i++)
  {
  if(s[i]!=s[n/2+i])
  {cout<<"No";
   return 0;
  } }cout<<"Yes";}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    set<ll> dvs;
    for(int i=1; i<n; ++i){
        if(a[i] == a[i-1]){
            dvs.insert(a[i]);
        }
    }
    vector<bool> cnd(a[n-1]+1, false);
    for (auto it = dvs.begin(); it != dvs.end(); ++it){
        ll h = *it;
        ll mx = a[n-1] / h;
        if(cnd[h]) continue;
        for (int i=1; i < mx+1; ++i){
            cnd[i * h]  = true;
        }
    }
    ll score = 0;
    for (auto it = a.begin(); it != a.end(); ++it){
        ll h = *it;
        ll mx = a[n-1] / h;
        if(cnd[h]) continue;
        for (int i=1; i < mx+1; ++i){
            cnd[i * h]  = true;
        }
        score += 1;
    }
    cout << score << endl;
    return 0;
}

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

typedef long long lint;
typedef pair<int, int> ii;

int MOD = 1e9 + 7;
int INF = 0x3f3f3f3f;
// ll INF = 1e18;

int n, p, a[55];
lint dp[55][2]={};

int solve(){
	cin >> n >> p;
	for(int i=1;i<=n;i++) cin >> a[i];
	dp[0][0]++;
	for(int i=1;i<=n;i++){
		if(a[i] & 1){
			dp[i][0] += dp[i-1][1];
			dp[i][1] += dp[i-1][0];
		}else{
			dp[i][0] += dp[i-1][0];
			dp[i][1] += dp[i-1][1];
		}
		dp[i][0] += dp[i-1][0];
		dp[i][1] += dp[i-1][1];
	}
	cout << dp[n][p] << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


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

using namespace std;

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

	int n, tw;
	cin >> n >> tw;
	vector<int> v(n);
	vector<int> w(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	vector<long long> dp(sum + 1, 1e18);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = sum; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	long long res = 0;
	for (int i = 1; i <= sum; i++) {
		if (dp[i] <= tw) {
			res = max(res, (long long) i);
		}
	}
	cout << res << '\n';

	return 0;
}



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

int main() {
  ll n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i];

  ll b_sum = 0;
  rep(i, n) {
    c[i] = a[i] + b[i];
    b_sum += b[i];
  }
  sort(c.rbegin(), c.rend());

  ll ans = 0;
  for (int i = 0; i < n; i += 2) ans += c[i];
  ans -= b_sum;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4240
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

ll f(ll x, int i = 60) {
  if(x == -1) return 0;
  if(i == -1) return 0;
  ll j = 1ll << i;
  if(!(x & j)) return f(x, i-1);
  if(i == 0) {
    return 1;
  }
  ll res = 0;
  if(!(x & 1)) res ^= j;
  if(i == 1) {
    res ^= 1;
  }
  return res ^ f(x, i - 1);
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << (f(a-1)^f(b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math


def read():
    N =int(input().strip())
    TXY = []
    for i in range(N):
        t, x, y = map(int, input().strip().split())
        TXY.append((t, x, y))
    return N, TXY


def solve(N, TXY):
    t0 = 0
    x0, y0 = 0, 0
    for t1, x1, y1 in TXY:
        dt = t1 - t0
        du = abs(x1-x0) + abs(y1-y0)
        if du > dt:
            return "No"
        elif (du - dt) % 2 == 1:
            return "No"
        t0, x0, y0 = t1, x1, y1
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 17328
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5+7; /// change this

int tr[4*MAXN];

void update(int u, int l, int r, int idx, int v) {
    if (r < idx || idx < l) return;
    if (l == r) {
        tr[u] = max(tr[u], v);
        return;
    }
    int mid = (l+r)/2;
    update(u*2, l, mid, idx, v);
    update(u*2+1, mid+1, r, idx, v);
    tr[u] = max(tr[u*2], tr[u*2+1]);
}

int query(int u, int l, int r, int x, int y) {
    if (x <= l && r <= y) return tr[u];
    int mid = (l+r)/2;
    if (y <= mid) return query(u*2, l, mid, x, y);
    if (mid < x) return query(u*2+1, mid+1, r, x, y);
    return max(query(u*2, l, mid, x, y), query(u*2+1, mid+1, r, x, y));
}

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

    int n, k;
    cin >> n >> k;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        int z = query(1, 0, MAXN, x-k, x+k) + 1;
        ans = max(ans, z);

        update(1, 0, MAXN, x, z);
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 7752
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll l,r;
    cin >> l >> r;
    if(l+1==r){
        cout << ((l%2019)*(r%2019))%2019 << endl;
        return 0;
    }

    if(l==0){
        cout << 0 << endl;
        return 0;
    }

    if(r-l+1>=673){
        cout << 0 << endl;
    }else{
        int m=2018;
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                m = min(m,((i%2019)*(j%2019))%2019);
            }
        }
       
        cout << m << endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   char c; cin >> c;
   if (c < 'a'){
      cout << 'A' << endl;
   }
   else cout << 'a' << endl;
}

Measured memory_bytes: 3636
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;

void solve()
{

    string s, t;
    cin >> s >> t;
    int l = INT_MAX;

    loop1(i, 0, s.size()-t.size())
    {

        int c=0;
        loop(j,0,t.size())
        {
            if(t[j]!=s[i+j])
            c++;
            
        }

        l = min(l, c);
    }

    cout<<l<<"\n";
}

int main()
{
    io;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();

    return 0;
}


Measured memory_bytes: 3644
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    n, a, b = map(int, input().split())

    print(min(a, b), max(a+b-n, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ans;
  while(cin >> n){
    cout << (n*n+2+n)/2<< endl;
  }
  return 0;
}

Measured memory_bytes: 1188