akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
int K,A,B;
scanf("%d", &K);
scanf("%d %d", &A, &B);

int C = A/K;
int D = B/K;

if(A % K == 0 || B % K == 0 ){
  printf("OK\n");
}else if( D-C >0){
  printf("OK\n");
}else {
  printf("NG\n");
}
  return 0;
}

Measured memory_bytes: 1624
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 524287;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 524287;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';

	ll dekai[10];
	int d = 0;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			dekai[d++] = (ll(n) << 30) + s[i] - C;
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				if (tmp) {
					rep(j, 26) if ((tmp >> j & 1)) {
						k[j]++;
					}
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	sort(dekai, dekai + d);
	rep(p, d) {
		auto S = C + (dekai[p] & (1 << 21) - 1);
		int k[26] = {};
		ll are = 0;
		for (int i = (dekai[p] >> 30) - 1; i >= 1; i--) {
			int tmp = query(are);
			if (tmp) {
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 11064
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int k, x;
  cin >> k >> x;
  if (500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int N;
vector<int> A;

void solve(){
    long sum = 0;
    int abs_min = INT_MAX;
    int m_count = 0;
    for(auto i = 0; i < N; ++i){
        sum += abs(A[i]);
        int absx = abs(A[i]);
        if(absx < abs_min) abs_min = absx;
        if(A[i] < 0) m_count++;
    }
    if(m_count % 2 == 1) sum -= abs_min*2;

    cout << sum;
}

int main(){
    cin >> N;
    A.resize(N);
    for(auto &x : A){
        cin >> x;
    }

    solve();
}

Measured memory_bytes: 640
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e6+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
vll v[MAXN];
void sol(void)
{
cin>>n;
for(ll i=1;i*i<=n;i++)
for(ll j=i*i;j<=n;j+=i) 
v[j].pb(i);  
ll ans=0;
for(int c=1;c<=n-1;c++)
{
  int num=n-c;
  ans+=2*v[num].size();
  if(v[num].back()*v[num].back()==num)
  ans--;
}
cout<<ans;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


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

using ll = long long;
const int INF = 1e9+7;

void solve()
{
	int n,k;cin >> n >> k;
	vector<int> hash(n);
	for(int &x:hash) cin >> x;
	sort(hash.begin(),hash.end());
	int sum = 0;
	for(int i=0;i<k;++i)
		sum += hash[i];
	cout << sum;
}

int main()
{
	int t=1;
	while(t--) solve();
}	


Measured memory_bytes: 3556
n, m = map(int, input().split())
gyoretu = [[0 for i in range (m)] for j in range(n)]
vector = [] #?¨?????????????
vector2 = [0 for i in range(n)] #?¨?????????????

for i in range(n):
	#for j in range(m):
	gyoretu[i] = input().split()
	#print(gyoretu[i][1])

for j in range(m):
    vector.append(int(input()))

#calculate
for i in range(n):
	for j in range(m):
		vector2[i] += int(gyoretu[i][j])*int(vector[j])

for i in range(n): 
	print(vector2[i])

Measured memory_bytes: 8200
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b,t;
    cin >> a >> b >> t;
    int x = 0;
    for(int i = a; i <= t; i += a){
        x += b;
    }
    cout << x << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {
    // 入力
    ll A;
    string B;
    cin >> A >> B;
    B = B.substr(0,1)+B.substr(2,2);
    if(B[0]=='0'){
        B = B.substr(1,2);
        if(B[0]=='0') B = B.substr(1,1);
    }
    ll b = stoi(B);
    ll out = (A*b)/100;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3632
bi =[list(map(int,input().split())) for i in range(3)]
n=int(input())
isok = [[0 for i in range(3)]for j in range(3)]
for i in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if bi[j][k] == x:
                isok[j][k] = 1

clear = 0
for i in range(3):
    if isok[i][0] and isok[i][1] and isok[i][2]:
        clear = 1
    if isok[0][i] and isok[1][i] and isok[2][i]:
        clear = 1
if isok[0][0] and isok[1][1] and isok[2][2]:
    clear = 1
if isok[2][0] and isok[1][1] and isok[0][2]:
    clear = 1
print("Yes" if clear else "No")

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define PR pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define int ll

// baton relay game
#define MAX 2000005

int remain[MAX];
int l[MAX],r[MAX];

signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0; i<n; i++){
    remain[i]=true;
    l[i]=(n+i-1)%n;
    r[i]=(i+1)%n;
  }
  
  int now=0;
  for(int i=0; i<m; i++){
    int a;
    cin>>a;
    if(a%2){
      for(int j=0; j<a; j++) now=l[now];
      remain[now]=false;
      l[r[now]]=l[now];
      r[l[now]]=r[now];
      now=r[now];
    }else{
      for(int j=0; j<a; j++) now=r[now];
      remain[now]=false;
      l[r[now]]=l[now];
      r[l[now]]=r[now];
      now=r[now];
    }
  }
  for(int i=0; i<q; i++){
    int Q;
    cin>>Q;
    if(remain[Q]) cout<<1<<en
    else cout<<0<<en
  }
  
  RE
}


Measured memory_bytes: 7796
def cal_primes(N):
    candidate = [*range(2, N+1)]
    primes = []

    while candidate[0]**2 <= N:
        primes.append(candidate[0])
        candidate = [*filter(lambda x: x % candidate[0] != 0, candidate)]
    
    primes.extend(candidate)
    return primes

Q = int(input())
primes = set(cal_primes(10**5))
# print(primes)
res = [0] * (10**5+1)
for i in range(1,10**5+1):
    #print(i)
    if i%2==1 and i in primes and (i+1)//2 in primes:
        res[i] = res[i-1] + 1
    else:
        res[i] = res[i-1]
#print(res)
for i in range(Q):
    l, r = map(int, input().split())
    print(res[r]-res[l-1])

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

const int maxw = 100100;
const ll inf = 1e18;

int main(){
  IO; int N, W; cin >> N >> W;
  vll dp(maxw+1, inf); dp[0] = 0;
  int w, v;
  while(N --){
    cin >> w >> v;
    for(int i = maxw; i >= v; i --) MIN(dp[i], dp[i-v] + w);
  }
  int ans = 0;
  REPN(i, maxw) if(dp[i] <= W) ans = i;
  cout << ans << endl;
}


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

template <class T> T gcd(T x, T y) {
    // 最小公倍数を求める
    if (y == 0)
        return x;
    gcd(y, x % y);
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &&i : A) {
        cin >> i;
    }

    // 前計算
    vector<int> l(N), r(N);
    l[0]     = A[0];
    r[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) {
        l[i] = gcd(l[i - 1], A[i]);
    }
    for (int i = N - 2; i >= 0; i--) {
        r[i] = gcd(r[i + 1], A[i]);
    }

    int ans = max(l[N - 2], r[1]);

    for (int i = 1; i < N - 1; i++) {
        ans = max(ans, gcd(l[i - 1], r[i + 1]));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream> 

using namespace std; 
  
int main() {
    int n;
    cin>>n;
    long long a[200010];
    for(int i=0;i<n;i++) cin>>a[i];
    long long ss=a[0];
    long long r;
    for(int i=1;i<n;i++) ss=ss^a[i];
    for(int i=0;i<n;i++) {
    	r=ss^a[i];
    	cout<<r<<" ";
	}
}

Measured memory_bytes: 5092
_MULTITEST = False
##
def solve():
    MOD = int(1e9) + 7

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()

    neg = sum(1 for x in a if x < 0)
    pos = sum(1 for x in a if x > 0)
    zero = a.count(0)
    
    ### Set lower bound for answer
    ans_is_neg = False
    if n == k:
        if zero == 0 and neg % 2 == 1:
            ans_is_neg = True
    else:
        if pos == 0:
            if zero == 0:
                if k % 2 == 1:
                    ans_is_neg = True
    
    ### Solve by window-sliding
    # set some initial vars

    #print(ans_is_neg)
    if ans_is_neg:
        prod = 1
        for i in a[n-k:n]:
            prod = (prod * i) % MOD
        print(prod)
    else:
        prod = 1
        p1 = 0; p2 = n-1;
        while k > 0:
            if k > 1 and p1 + 1 < n and 0 < p2 and a[p1] * a[p1+1] > a[p2] * a[p2-1]:
                prod = (prod * a[p1] * a[p1 + 1]) % MOD
                p1 += 2; k -= 2;
            else:
                prod = (prod * a[p2]) % MOD
                p2 -= 1; k -= 1;
        print(prod)

##
if __name__ == "__main__":
    t = (int(input()) if _MULTITEST else 1)
    for tt in range(t):
        solve()

Measured memory_bytes: 104948
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
long double pi=3.141592653589793238;
ll r;
cin>>r;
long double ans=2.0*pi*r;
cout<<fixed<<setprecision(10)<<ans<<endl;


return 0;
}


Measured memory_bytes: 3808
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    Hs= list(map(int, input().split()))
    hs = [0]
    ans = ""
    for i in range(N):
        hs.append(0)
        #print(Hs)
        h_tmp = Hs[i]
        if i < N - 1:
            h_next = Hs[i + 1]
            if h_tmp < h_next:
                hs[i + 1] = 1
                Hs[i + 1] -= 1
                pass
            elif h_tmp == h_next:
                pass
            elif h_tmp - 1 == h_next and hs[i] == 0:
                if i > 0:
                    h_before = Hs[i - 1]
                    if h_before <= h_tmp - 1:
                        pass
                    else:
                        ans = "No"
                        break
                elif i == 0:
                    pass
            else:
                ans = "No"
                break
    if ans == "":
        ans = "Yes"
 
    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 60044
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
    int z;
    if(b==0){
        z=1;
        z%=c;
        return z;
    }
    if(b==1){
        z=a;
        z%=c;
        return z;
    }
    else{
        return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
    }
}

int main(){
  string a;
  cin>>a;
  if(a.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<a.size()/2;i++){
    if(a.at(2*i)!='h'||a.at(2*i+1)!='i'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		if(n<=1&&m<=1)
		    System.out.println(0);
		else if(n<=1)
		    System.out.println(binomialCoeff(m,2));
		else if(m<=1)
		    System.out.println(binomialCoeff(n,2));
		else
    		System.out.println(binomialCoeff(n,2)+binomialCoeff(m,2));
		
	}
	static int binomialCoeff(int n, int k) 
    { 
        int res = 1;  
        if ( k > n - k ) 
            k = n - k;  
        for (int i = 0; i < k; ++i) 
        { 
            res *= (n - i); 
            res /= (i + 1); 
        } 
      
        return res; 
    } 
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a;
  cin >> a;
  long long ans = 0;
if(a % 2 == 0){
  a /= 2;
  while(a >= 5){
    a /= 5;
    ans += a;}
    }
  cout << ans << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,n,ans[100010]={0};
    cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		ans[a]=i+1;
	}
	for(int i=1;i<=n;i++){
	    cout<<ans[i]<<" ";    	
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <set>
#include <vector>

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

    std::vector<int> p(n, 0);
    std::vector<int> id(n, 0);

    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
        id[p[i]] = i;
    }

    std::set<int> s;

    long long ans = 0;
    for (int elem = n - 1; elem >= 0; elem--) {
        int idx = id[elem];

        s.insert(idx);

        auto center = s.find(idx);

        std::vector<int> l(2, -1);
        for (int i = 0; i < 2; i++) {
            if (center == s.begin()) {
                break;
            }

            center--;
            l[i] = *center;
        }

        center = s.find(idx);
        std::vector<int> r(2, n);
        for (int i = 0; i < 2; i++) {
            center++;
            if (center == s.end()) {
                break;
            }

            r[i] = *center;
        }

        std::vector<int> ls(2), rs(2);
        ls[0] = idx - l[0];
        ls[1] = l[0] - l[1];
        rs[0] = r[0] - idx;
        rs[1] = r[1] - r[0];

        long long c = (long long)(ls[0] * rs[1]) + (long long)(ls[1] * rs[0]);

        ans += c * (elem + 1);
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;

long long int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int ma=0;
  int mi=1e9;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ma=max(a,ma);
    mi=min(a,mi);
  }
  cout<<ma-mi<<endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;
    vector<ll> a(N),b(N),c(N);
    REP(i, N)
        cin >> a.at(i) >> b.at(i) >> c.at(i);

        ll dp[3][N];

        dp[0][0] = a.at(0);
        dp[1][0] = b.at(0);
        dp[2][0] = c.at(0);

    REPS(i,N-1){
        
            dp[0][i] = max(dp[1][i - 1] , dp[2][i - 1])+a.at(i);
            dp[1][i] = max(dp[0][i - 1] , dp[2][i - 1]) + b.at(i);
            dp[2][i] = max(dp[0][i - 1] , dp[1][i - 1]) + c.at(i);
    }

    cout << max({dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]}) << endl;
}


Measured memory_bytes: 4992
n=int(input())
a=[int(input()) for _ in range(n)]

if a.count(0)==0:
    print(sum(a)//2)
else:
    tmp_sum=0
    ans=0
    for i in range(n):
        if a[i]==0:
            ans+=tmp_sum//2
            tmp_sum=0
        else:
            tmp_sum+=a[i]
    ans+=tmp_sum//2

    print(ans)



Measured memory_bytes: 7072
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(b, n * a) << endl;
}

Measured memory_bytes: 764
X,Y,A,B,C = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)


taberu = p[0:X] + q[0:Y] + r
taberu.sort(reverse=True)

print(sum(taberu[0:X+Y]))


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int a,b; cin>>a>>b;
	if(a==b) cout<<a+b<<endl;
	else cout<<2*max(a,b)-1<<endl;

	return 0;
}


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

using namespace std;

#define ll long long

void solve(){
    int s,w;
    cin>>s>>w;
    if(w >= s){
        cout<<"unsafe";
    }else{
        cout<<"safe";
    }
    
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
import sys
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
read = sys.stdin.read
readline = sys.stdin.readline

N, M, R = map(int, readline().split())
r = list(map(int, readline().split()))

INF = float('inf')
graph = [[INF] * (N + 1) for _ in range(N + 1)]
ABC = map(int, read().split())

for i in range(N + 1):
    graph[i][i] = 0

for A, B, C in zip(*[iter(ABC)] * 3):
    graph[A][B] = C
    graph[B][A] = C

distance = floyd_warshall(graph, directed=False)
answer = 10 ** 9
for tour in permutations(r):
    tmp = 0
    for i in range(R - 1):
        tmp += distance[tour[i]][tour[i + 1]]

    if tmp < answer:
        answer = tmp

print(int(answer))

Measured memory_bytes: 22252
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}

lli fac(int n )
{
    lli ans = 1;
    for(int i = 1;i<=n;i++)
        ans = mul(ans,i);
    return ans;
}

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;
    while(t--)
    {
        lli a;
        int n,m;
        cin>>n>>m;
        if(abs(n-m)>1)
        {
            cout<<0;
            return 0;
        }
        else
            a = mul(fac(n),fac(m));
        if(abs(n-m) == 0)
            a = add(a,a);
        cout<<a;
    }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


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

int main()
{
  int n;
  cin>>n;
  vector<long long int> a(5,0);

  string s;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    if(s.at(0)=='M') a.at(0)++;
    else if(s.at(0)=='A') a.at(1)++;
    else if(s.at(0)=='R') a.at(2)++;
    else if(s.at(0)=='C') a.at(3)++;
    else if(s.at(0)=='H') a.at(4)++;
  }

  long long int ans=0;
  for(int i=0;i<5;i++)
  for(int j=i+1;j<5;j++)
  for(int k=j+1;k<5;k++) ans+=a.at(i)*a.at(j)*a.at(k);

  cout<<ans<<endl;
}

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

int main()
{
  uint64_t n;
  cin >> n;
  if (n % 2 == 0)
  {
    n /= 2;
    uint64_t r = 0;
    for (uint64_t i = 0; i <= 100; i++)
    {
      r += (n /= 5);
    }
    cout << r << endl;
  }
  else
  {
    cout << 0 << endl;
  }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
ll n,k;
ll c[2001][2001];

void init(){
  for(int i = 0; i < 2001; i++)c[i][0] = 1;

  for(int i = 1; i < 2001; i++){
    for(int j = 1; j < i+1; j++){
      c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
    }
  }
  // cout << c[5][2] << endl;
}
int main(){
  cin >> n >> k;
  init();

  for(int i=1;i<k+1;i++){
    ll ans = c[n-k+1][i] * c[k-1][i-1];
    cout <<  ans % mod << endl;
  }
}

Measured memory_bytes: 30080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Nikkei_C solver = new Nikkei_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class Nikkei_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            long[] a = new long[n];
            long[] b = new long[n];

            long point = 0;


            ArrayList<dish> dishList = new ArrayList<dish>();

            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();

                b[i] = in.nextLong();

                point -= b[i];

                dish dish = new dish(a[i], b[i]);
                dishList.add(dish);
            }

            Collections.sort(dishList, new Comparator<dish>() {

                public int compare(dish o1, dish o2) {
                    if ((o1.a + o1.b) == (o2.a + o2.b)) {
                        return (int) (o2.a - o1.a);
                    }
                    return (int) ((o2.a + o2.b) - (o1.a + o1.b));
                }
            });

            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    point += dishList.get(i).a + dishList.get(i).b;
                }
            }

            out.print(point);
        }

    }

    static class dish {
        long a;
        long b;

        dish(long a, long b) {
            this.a = a;
            this.b = b;
        }

    }
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	Long n, W;
	cin >> n >> W;
	Long w[n], v[n];
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	Long dp[W + 1];
	memset(dp, 0LL, sizeof(dp));
	for (int i = 0; i < n; i++) {
		for (int j = W - w[i]; j >= 0; j--) {
			dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
		}
	}
	Long answer = 0LL;
	for (int i = 0; i <= W; i++) answer = max(answer, dp[i]);
	cout << answer << endl;
	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;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N, 0);
  for(auto &i : A) cin >> i;
  vector<int> cnt(1e5+1, 0);
  REP(i, N){
    cnt[A[i]]++;
  }
  int even = 0, odd = 0;
  REP(i, 1e5+1){
    if(cnt[i] != 0){
      if(cnt[i] % 2 == 1) odd++;
      if(cnt[i] % 2 == 0) even++;
    }
  }
  if(even == 0 || even % 2 == 0){
    cout << odd + even << endl;
  }else{
    cout << odd + even - 1 << endl;
  }

}

Measured memory_bytes: 1024
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846
#define IOS ios::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
const int p1 = 31;

int main() { IOS
   
    //Use long long
    ll n , m, k;
    cin>>n>>m>>k;

    ll row[n];
    ll col[m];
    ll total =0 ;
    char a[n][m];
    for(int i=0;i<n;i++)
    {	int cnt = 0;
    	for(int j=0;j<m;j++)
    	{
    		cin>>a[i][j];
    		if(a[i][j] == '#'){
    			cnt++;
    			total++;
    		}
    	}
    	row[i] = cnt;
    }
    for(int j =0 ;j < m;j++)
    {	int cnt =0;
    	for(int i=0;i<n;i++)
    	{
    		if(a[i][j] == '#')
    			cnt++;
    	}
    	col[j] = cnt;
    }
    ll tot1 = (1<<n);
    ll tot2 = (1<<m);
    ll ans =0;
    for(int i=0; i <tot1 ;i++)
    {
    	for(int j =0 ;j < tot2 ;j++){
    		ll tot = 0;
    		for(int p =0 ;p<n;p++)
    		{
    			for(int q=0;q<m;q++)
    			{
    				if(((i>>p)&(1)^1)&& ((j>>q)&(1)^1 ) && a[p][q] == '#')
    					tot++;
    			}
    		}
    		if(tot == k)
    			ans++;
    	}
    }
    cout<<ans<<endl;

	
    return 0;
  	
  	
   
            
}

Measured memory_bytes: 3616
#include <stdio.h>
     
int main(void){

	int i;
	char bt[4];
	int cnt[4] = {};

	while( scanf("%d,%s",&i, bt) != EOF ) {
		if( bt[1] == 'B' ) {
			cnt[3] ++;
		} else if( bt[0] == 'A' ) {
			cnt[0] ++;
		} else if( bt[0] == 'B' ) {
			cnt[1] ++;
		} else {
			cnt[2] ++;
		}
		
	}
	printf("%d\n%d\n%d\n%d\n", cnt[0], cnt[1], cnt[3], cnt[2] );
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void)
{
    int N,M,i;
    int A[100000];
    long long sum=0;

    scanf("%d %d",&N,&M);

    for(i=0; i<M; i++){
        scanf("%d",&A[i]);
        sum += A[i];
    }

    if(sum > N){
        printf("-1\n");
    } else {
        printf("%lld\n",N-sum);
    }


    
    return 0;
}

Measured memory_bytes: 1720
//
//  main.c
//  AtCoderProblems
//
//  Created by Gaska Wojtek on 2020/05/21.
//  Copyright © 2020 Gaska Wojtek. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int CheckFirstDigit(int *inputNumber)
{
    return *inputNumber = *inputNumber % 10;
}

char * CheckType(int firstDigit)
{
    if(firstDigit == 3)
    {
        return "bon";
    }
    else if (firstDigit == 2 || firstDigit == 4 || firstDigit == 5 || firstDigit == 7 || firstDigit == 9)
    {
        return "hon";
    }
    else
    {
        return "pon";
    }
}

void ReadInput(int * inputNumber)
{
    scanf("%d", inputNumber);
    
    while (*inputNumber > 999)
    {
        printf("Wrong input \n");
        ReadInput(inputNumber);
        if(*inputNumber < 999)
        {
          break;
        }
    }
}

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

    int *inputNumber = malloc(sizeof(int));
    char *counterType;
    
    ReadInput(inputNumber);
    CheckFirstDigit(inputNumber);

    counterType = CheckType(*inputNumber);
    
    printf("%s \n", counterType);
    
    return 0;
}

Measured memory_bytes: 1696
from collections import deque
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

Ch += 1
Cw += 1
Dh += 1
Dw += 1

lim = 10**6

S = ['#'*(W+4)]
S.append('#'*(W+4))
for k in range(H):
  S.append('##' + input() + '##')
S.append('#'*(W+4))
S.append('#'*(W+4))

foo = [[-1 for _ in range(W+4)] for _ in range(H+4)]
rev = [[-1 for _ in range(W+4)] for _ in range(H+4)]
for k in range(2, H+2):
  for j in range(2, W+2):
    if S[k][j] == '.':
      foo[k][j] = lim
      rev[k][j] = lim



foo[Ch][Cw] = 0
rev[Dh][Dw] = 0
jump = [(2,2),(2,1),(2,0),(2,-1),(2,-2),(1,2),(1,1),(1,-1),(1,-2),(0,2),(0,-2),(-1,2),(-1,1),(-1,-1),(-1,-2),(-2,2),(-2,1),(-2,0),(-2,-1),(-2,-2)]
mv = [(1,0),(-1,0),(0,1),(0,-1)]
now = deque([])
new = deque([(Ch, Cw)])
while len(new) > 0:
  item = new.pop()
  now.append(item)
  x = item[0]
  y = item[1]
  for m in mv:
    mx = x + m[0]
    my = y + m[1]
    if rev[mx][my] == 0:
      print(0)
      exit()
    else:
      if foo[mx][my] == lim:
        foo[mx][my] = 0
        new.append((mx, my))

now_rev = deque([])
new_rev = deque([(Dh,Dw)])
while len(new_rev) > 0:
  item = new_rev.pop()
  now_rev.append(item)
  x = item[0]
  y = item[1]
  for m in mv:
    mx = x + m[0]
    my = y + m[1]
    if rev[mx][my] == lim:
      rev[mx][my] = 0
      new_rev.append((mx, my))


start = 0
while True:
  if len(now) == 0:
    print(-1)
    exit() 
  start += 1
  while len(now) > 0:
    item = now.pop()
    x = item[0]
    y = item[1]
    for j in jump:
      jx = x + j[0]
      jy = y + j[1]
      if 0 <= rev[jx][jy] < lim:
        print(foo[x][y]+rev[jx][jy]+1)
        exit()
      else:
        if foo[jx][jy] > start:
          foo[jx][jy] = start
          new.append((jx,jy))
  while len(new) > 0:
    item = new.pop()
    now.append(item)
    x = item[0]
    y = item[1]
    for m in mv:
      mx = x + m[0]
      my = y + m[1]
      if 0 <= rev[mx][my] < lim:
        print(foo[x][y] + rev[mx][my])
        exit()
      else:
        if foo[mx][my] == lim:
          foo[mx][my] = start
          new.append((mx, my))

  if len(now_rev) == 0:
    print(-1)
    exit() 
  while len(now_rev) > 0:
    item = now_rev.pop()
    x = item[0]
    y = item[1]
    for j in jump:
      jx = x + j[0]
      jy = y + j[1]
      if 0 <= foo[jx][jy] < lim:
        print(rev[x][y]+foo[jx][jy]+1)
        exit()
      else:
        if rev[jx][jy] > start:
          rev[jx][jy] = start
          new_rev.append((jx,jy))

  while len(new_rev) > 0:
    item = new_rev.pop()
    now_rev.append(item)
    x = item[0]
    y = item[1]
    for m in mv:
      mx = x + m[0]
      my = y + m[1]
      if 0 <= foo[mx][my] < lim:
        print(rev[x][y] + foo[mx][my])
        exit()
      else:
        if rev[mx][my] == lim:
          rev[mx][my] = start
          new_rev.append((mx, my))
    

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m a 
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  ll tot = 0;
  rep(i, N) tot ^= a[i];

  rep(i, N) {
    ll ans = tot^a[i];
    cout << ans << endl;
  }
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4792
Scanf.scanf "%d %s" (fun n s ->
    let assume c1 c2 =
        let r = Array.make n '.' in
        r.(0) <- c1;
        r.(1) <- c2;
        let rev k = if k = 'S' then 'W' else 'S' in
        for i = 2 to n - 1 do
            r.(i) <- match r.(i - 1), s.[i - 1] with
            | 'S', 'o' 
            | 'W', 'x' -> r.(i - 2)
            | _        -> rev r.(i - 2)
        done;

        let check p =
            let pp = r.((p - 1 + n) mod n) in
            let pn = r.((p + 1 + n) mod n) in
            match r.(p), s.[p] with
            | 'S', 'o'
            | 'W', 'x' -> pp = pn
            | _        -> pp = rev pn
        in

        if check (n - 1) && check 0 then  (
            Array.iter print_char r;
            print_newline ();
            true
        ) else false
    in
    if assume 'S' 'S' || assume 'S' 'W' || assume 'W' 'S' || assume 'W' 'W' then () else
        print_endline "-1"
)

Measured memory_bytes: 7368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,q;
  string s;
  cin >> n >> s >> q;

  vector<set<int>> cs(26);
  rep(i,n) {
    cs[s[i]-'a'].insert(i);
  }

  vector<int> ans;
  rep(xxx,q){
    int t;
    cin >> t;
    if (t==1) {
      int i; char c;
      cin >> i >> c;
      --i;
      cs[s[i]-'a'].erase(i);
      s[i] = c;
      cs[s[i]-'a'].insert(i);
    }
    else {
      int r,l;
      cin >> r >> l;
      --r;
      int cnt = 0;
      rep(ci,26){
        auto itr = cs[ci].lower_bound(r);
        if (itr != cs[ci].end() && *itr < l) {
          ++cnt;
        }
      }
      ans.push_back(cnt);
    }
  }
  rep(i,ans.size()) cout << ans[i] << endl;
}


Measured memory_bytes: 24440
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = (n-2)/(k-1)+1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

mul = 1
while a.index{|v| v.odd?}.nil?
  a.map!{|v| v/2}
  mul *= 2
end

if mul > 1 && a.all?{|v| v.odd?}
  minX = mul / 2
  a.each do |v|
    minX = minX.lcm(v)
    if minX > m
      p 0 
      exit
    end
  end
  ans = (m / minX + 1) / 2
  p ans
else
  p 0
end


Measured memory_bytes: 8588
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  string S;
  cin >> S;
  string T[S.size()] = {};
  T[0] = S[0];
  int j = 0;
  int ans = 1;
  for(int i=1;i<S.size();i++){
    j++;
    for(j;j<S.size();j++){
      T[i] += S[j];
      if(T[i] != T[i-1]){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 11012
import java.util.*;

public class Main {
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    ArrayList arrayList=new ArrayList();
    for (int i = 0; i <3; i++) {
        arrayList.add(scanner.nextInt());
    }
    Collections.sort(arrayList);
    int sum=0;
    for (int i = 0; i <2; i++) {
        int arr= (int) arrayList.get(i);
        sum+=arr;
    }
    System.out.println(sum);
}
}

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

bool bb(pair<string,int> a,pair<string,int> b){
    if(a.first!=b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}
  
int main(){
    int n;
    cin>>n;
    vector<pair<string,int>> v(n);
    vector<pair<string,int>> vc(n);
    rep(i,n){
        string s;
        int p;
        cin>>s>>p;
        v[i]=make_pair(s,p);
    }

    vc=v;
    sort(vc.begin(),vc.end(),bb);

    for(auto i:vc){
        rep(j,n){
            if(i.first==v[j].first && i.second==v[j].second)cout<<j+1<<endl;
        }
    }
        
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N, M;
    cin >> N >> M;
  	//cout << N;
  	//cout << M;
  
    // スペース区切りの整数の入力
    int l, i=0, A[10000];
  	while(cin>>l){
      A[i]=l;
      //cout << A[i];
      i++;     
    }
  
  int zan = N;
    
  for (int i = 0; i < M; i++){
   	// 宿題にかかる日数
    int temp = A[i];
    zan = zan - temp;
  }
  
  int ret = zan;
  if (zan < 0){
    ret =  -1;
  }
  
	cout<<ret;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,m;
    map<string,int>a,b;
    cin>>n;
    string s[105];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
         a[s[i]]++;
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        string s;
        cin>>s;
        a[s]--;
    }
    int maxe=0;
    for(int i=0;i<n;i++)
    {
        if(a[s[i]]>=maxe) maxe=a[s[i]];
    }
     cout<<maxe;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main {
  static String[][] field;
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int K = sc.nextInt();
    field = new String[H][W];
    sc.nextLine();
    for (int i = 0; i < H; i++) {
      field[i] = sc.nextLine().split("");
    }
    int ans = 0;
    for (int i = 0; i < (1<<H); i++) {
      for (int j = 0; j < (1<<W); j++) {
        int count = 0;
        for (int h = 0; h < H; h++) {
          for (int w = 0; w < W; w++) {
            if ((1&i >> h) == 1 && (1&j >> w) == 1) {
              if (field[h][w].equals("#")) count++;
            }
          }
        }
        if (count == K) ans++;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;


int main()
{


/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

 const int INF = 1e9 + 5;
 const int maxm = 1e5;

  string s1;
  string s2;
  int cnt=0;

  cin>>s1>>s2;

  for(int i=0; i<3;i++)
  {
  	if(s1[i] == s2[i])
  	{
  		cnt++;
  	}
  }

  cout<<cnt;

}







Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	rdr := NewReader(n)
	h := ReadInt64s(rdr)

	m := make([]int64, n)
	for i := range m[1:] {
		m[i+1] = HalfInt64
	}

	for i := 0; i < n; i++ {
		for j := 1; j <= k && i+j < len(h); j++ {
			t := i + j
			abs := AbsInt64(h[i] - h[t])
			m[t] = MinInt64(m[t], m[i]+abs)
		}
	}

	fmt.Println(m[n-1])
}

// generated by https://github.com/murosan/gollect

const (
	HalfInt64 int64 = 4611686018427387903
)

func MinInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func AbsInt64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}

type Reader struct {
	rdr  *bufio.Reader
	size int
	sep  string
}

func NewReader(size int) *Reader {
	return &Reader{
		rdr:  bufio.NewReaderSize(os.Stdin, size),
		size: size,
		sep:  " ",
	}
}

func ReadLine(rdr *Reader) string {
	buf := make([]byte, 0, rdr.size)
	for {
		line, isPrefix, err := rdr.rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func ReadStrs(rdr *Reader) []string {
	return strings.Split(ReadLine(rdr), rdr.sep)
}

func ReadInt64s(rdr *Reader) (n []int64) {
	for _, v := range ReadStrs(rdr) {
		if i, e := strconv.ParseInt(v, 10, 64); e == nil {
			n = append(n, i)
		}
	}
	return n
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define des greater<ll>()
#define fi first
#define se second
#define PI 3.1415926535
#define FP(n) fixed<<setprecision(n)
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i++)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};

ll n,w;
ll c[105],v[105],dp[105][100005];

ll solve(ll i,ll wt)
{
    if(i>=n || wt>w)
    return 0;
    ll a=0,b=0;
    if(dp[i][wt]!=-1)
    return dp[i][wt];
    if((wt+c[i])<=w)
    a=v[i]+solve(i+1,wt+c[i]);
    b=solve(i+1,wt);
    dp[i][wt]=max(a,b);
    return dp[i][wt];
}














int main()
{
    fio;
    cin>>n>>w;
    fr(i,0,n)
    {
        cin>>c[i]>>v[i];
    }
    fr(i,0,105)
    fr(j,0,100005)
    dp[i][j]=-1;
    ll ans=solve(0,0);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 82304