akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll ME = 5050;
const ll MV = 5050;
vector<vp> g(2600);
ll n, m;
vll a(ME), b(ME), c(ME), score(ME);
ll ans = -INF;
vi finfv(MV, 0);

void bf(){
    score[1] = 0;
    repr(i, 2, n+1){
        score[i] = INF;
    }
    rep(i, n-1){
        bool finf = 0;
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(score[v] > score[u] + c[j]){
                score[v] = score[u] + c[j];
                finf = 1;
            }
        }
        if(!finf){
            ans = score[n];
            return;
        }
        dump(score);
    }
    rep(i, n){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(score[u] >= INF/2) continue;
            if(score[v] > score[u] + c[j]){
                score[v] = score[u] + c[j];
                finfv[v] = 1;
            }
            if(finfv[u]){
                finfv[v] = 1;
            }
        }
        dump(score);
        dump(finfv);
    }
    ans = (finfv[n] ? INF : score[n]);
    return;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll p;
    cin >> n >> m >> p;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] -= p;
        c[i] = -c[i];
        g[a[i]].emplace_back(b[i], c[i]);
    }
    bf();
    if(finfv[n]){
        cout << -1 << endl;
    }else{
        cout << max(-score[n], 0LL) << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int a[3][7]={{1,3,5,7,8,10,12},
	    {4,6,9,11,0,0,0},
	    {2,0,0,0,0,0,0}};
  int p,q;
  for(int i=0;i<3;i++){
    for(int j=0;j<7;j++){
      if(a[i][j]==x)p=i;
      if(a[i][j]==y)q=i;
    }
  }
  cout<<(p==q?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll N = 40005;

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

ll get_num (const set<ll>& s, ll i, ll j, ll t, map<ll,ll>& v) {
	ll sel = *s.lower_bound(j);
	return (sel != N ? t - v[sel] : 0) - (s.count(2*j-i) > 0 ? 1 : 0);
}

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0);
	// cout.precision(6);
	
	ll n; string s;
	cin >> n >> s;

	set<ll> r, g, b;
	ll rt, gt, bt;
	map<ll,ll> rv, gv, bv;
	r.insert(N);
	g.insert(N);
	b.insert(N);
	rt = gt = bt = 1;
	for (ll i = 0; i < s.size(); ++i) {
		if (s[i] == 'R') {
			rv[i] = rt++;
			r.insert(i);
		} else if (s[i] == 'G') {
			gv[i] = gt++;
			g.insert(i);
		} else {
			bv[i] = bt++;
			b.insert(i);
		}
	}

	ll ans = 0;
	for (ll i = 0; i < n; ++i) {
		for (ll j = i+1; j < n; ++j) {
			if (s[i] == s[j]) {
				continue;
			} else if (s[i] == 'R' and s[j] == 'G') {
				ans += get_num(b,i,j,bt,bv);
			} else if (s[i] == 'R' and s[j] == 'B') {
				ans += get_num(g,i,j,gt,gv);
			} else if (s[i] == 'G' and s[j] == 'R') {
				ans += get_num(b,i,j,bt,bv);
			} else if (s[i] == 'G' and s[j] == 'B') {
				ans += get_num(r,i,j,rt,rv);
			} else if (s[i] == 'B' and s[j] == 'R') {
				ans += get_num(g,i,j,gt,gv);
			} else if (s[i] == 'B' and s[j] == 'G') {
				ans += get_num(r,i,j,rt,rv);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

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

using namespace std;

long long gcd(long long a, long long b){
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int count = 0;
    while (true) {
        if (isPrime(X + count))break;
        count++;
    }
    cout << X + count;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        Set<Integer> checkHash = new HashSet<>();
        checkHash.add(a);
        checkHash.add(b);
        checkHash.add(c);

        if (checkHash.size()==2){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main(){
long x,y;
cin >> x >> y;
if( x == y){
cout << -1 << endl;
return 0;
}
long N = x*y;
long max_N = 1000000000000000000;
for(long i = x; i<=N; i+=x){
        if(i > max_N){
                cout << -1 << endl;
                return 0;
        }
        if(i%y !=0){
                cout << i << endl;
                return 0;
        }
}
cout << -1 << endl;
return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


a, b, k = LI()
cds = []
ans = 1
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
        cds.append(i)
print(cds[-k])


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

const int INF = 1e9;

typedef pair<int,int> P;
typedef pair<P,P> P1;

int dp[101][101][101];
int a, b, c;

void bfs(){
  
  dp[a][b][c] = 0;
  queue<P1> q;

  q.push(P1(P(a,b),P(c,0)));

  while(!q.empty()){
    
    P1 t = q.front(); q.pop();

    int A = t.first.first;
    int B = t.first.second;
    int C = t.second.first;
    int cost = t.second.second;
    
    int nA = A + 1;
    int nB = B + 1;
    int nC = C;
    
    if( nA <= 100 && nB <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }
    
    nA = A + 1;
    nB = B;
    nC = C + 1;
    
    if( nA <= 100 && nC <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }
    
    nA = A;
    nB = B + 1;
    nC = C + 1;
    
    if( nB <= 100 && nC <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }

    nA = A + 2;
    nB = B;
    nC = C;
    
    if( nA <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }

    nA = A;
    nB = B + 2;
    nC = C;
    
    if( nB <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }


    nA = A;
    nB = B;
    nC = C + 2;
    
    if( nC <= 100 ){
      if( dp[nA][nB][nC] > cost + 1 ){
	dp[nA][nB][nC] = cost + 1;
	q.push(P1(P(nA,nB),P(nC,cost+1)));
      }
    }    
    
  }
  
  
}

signed main(){
  
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      for(int k=0;k<101;k++){
	dp[i][j][k] = INF;
      }
    }
  }
  
  cin>>a>>b>>c;
    
  bfs();

  int ans = INF;
  
  for(int i=0;i<101;i++){
    ans = min( ans, dp[i][i][i] );
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 8576
url = "https://atcoder.jp//contests/abc155/tasks/abc155_b"

def main():
    input()
    t = list(map(int, input().split()))

    for val in t:
        if val % 2 == 0:
            flg = False
            if val % 3  == 0:
                flg = True
            elif val % 5  == 0:
                flg = True

            if not flg:
                print('DENIED')
                exit()
    print('APPROVED')
    exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * 60
c = [0] * 60
ans = 0
for i in range(n):
    for j in range(60):
        c[j] += i - b[j] if a[i] >> j & 1 else b[j]
        b[j] += a[i] >> j & 1
for j in range(60):
    ans += c[j] << j
print(ans % (10**9 + 7))


Measured memory_bytes: 136428
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

string S;
long long cnt = 0;

int main()
{
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == '+') {
			cnt++;
		}
		else {
			cnt--;
		}
	}

	printf("%lld\n", cnt);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for (int i=0; i<=K; ++i) {
    for (int j=0; j<=K; ++j) {
      int z = S - i - j;
      if (0 <= z && z <= K)  ++count;
    }
  }
  
  cout << count << endl;
}
        

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
  int a, b, N;
  scanf("%d",&N);
  a=N%1000;
  
  if (a==0)
  {
    a=1000;
  }
  
  b=1000-a;
  printf("%d",b);

  return 0;
}

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

using namespace std;

int pow(int a, int b) {
  return b == 0 ? 1 : a * pow(a, b-1);
}

int main(void) {
  int D, N; cin >> D >> N;
  cout << (N == 100 ? N+1 : N) * pow(100, D) << endl;

  return 0;
}

Measured memory_bytes: 384
use std::io;

fn main() {
    // let input = input_number();
    // let n = input[0] as usize;
    // let m = input[1] as usize;
    // let l = input[2] as usize;
    // let nm: Vec<Vec<i64>> = (0..n).map(|_| input_number()).collect();
    // let ml: Vec<Vec<i64>> = (0..m).map(|_| input_number()).collect();

    // for i in 0..n {
    //     for j in 0..l {
    //         let sum = (0..m).fold(0, |sum, k| sum + nm[i][k] * ml[k][j]);
    //         print!("{}{}", sum, if j == l - 1 { '\n' } else { ' ' });
    //     }
    // }
    let input = input_number();
    let r = input[0];

    println!("{}", r * r);
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] a = new Integer[N];
		for (int i=0; i<N; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		int alice = 0; int bob = 0;
		for (int i=0; i<N; i++) {
			if (i%2 == 0) alice+=a[i];
			else bob+=a[i];
		}
		System.out.println(alice -bob);
	}
}


Measured memory_bytes: 20692
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli n, i, j, c = 0, s = 0;
	cin >> n;
	lli arr[n], brr[n];
	for (i = 0; i < n; i++)
	{
		cin >> arr[i] >> brr[i];
	}
	for (i = 2; i < n; i++)
	{
		if ((arr[i] == brr[i]) && (arr[i - 1] == brr[i - 1]) && (arr[i - 2] == brr[i - 2]))
		{
			c++;
		}
	}
	//cout << c << endl;
	if (c > 0)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  std::vector<int> a(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int m = n / 2;
  int ret = a[m] - a[m - 1];
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli N;
	cin >> N;
	vector<lli> v(5);
	lli vm = LIMIT;
	for (int i = 0; i < 5; i++) {
		cin >> v[i];
		vm = min(vm, v[i]);
	}
	lli ans = N / vm;
	ans += (N%vm != 0 ? 1 : 0);
	cout << ans + 4<< endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, a, b, c, d, e, f, ansa, ansb = 0;
  double now = 0.0;
  scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
  ansa = a * 100;
  bool bo[31];
  for(i = 0; i < 31; ++i) bo[i] = false;
  bo[0] = true;
  for(i = 0; i * a < 31; ++i) bo[a * i] = true;
  for(i = 0; i < 31; ++i) if(bo[i]) {
    for(j = 1; i + j * b < 31; ++j) bo[i + b * j] = true;
  }
  for(j = 1; j < f / 100; ++j) if(bo[j]) {
    bool dp[e * j + 1];
    for(i = 0; i <= e * j; ++i) dp[i] = false;
    dp[0] = true;
    for(i = 0; i * c <= e * j; ++i) dp[c * i] = true;
    for(i = 0; i <= j * e; ++i) if(dp[i]) {
      for(k = 1; i + k * d <= j * e; ++k) dp[i + d * k] = true;
    }
    int tmp = 0;
    for(i = 0; i <= e * j; ++i) if(j * 100 + i <= f && dp[i]) tmp = i;
    if(now < (double)tmp / (double)j) now = (double)tmp / (double)j, ansa = j * 100 + tmp, ansb = tmp;
  }
  printf("%d %d", ansa, ansb);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  if (A[0]) {
    cout << -1 << '\n';
    return 0;
  }

  ll ans = 0;
  rep(i, N - 1) {
    if (A[i] < A[i + 1]) {
      if (A[i + 1] - A[i] != 1) {
        cout << -1 << '\n';
        return 0;
      }

      ans++;
    } else {
      ans += A[i + 1];
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
   int h, m, s;

   scanf("%d", &s);

   h = s/3600;
   m = (s-h*3600)/60;
   s = s-(h*3600+m*60);

   printf("%d:%d:%d\n", h, m, s);

   return 0;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	qsort(a,3,sizeof(int),compare_int);
	int ans = 0;
	ans += a[1] - a[0];
	ans += a[2] - a[1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
seq = [int(input()) for _ in range(N)]
from collections import deque
import bisect
LIS = deque([seq[0]])
for i in range(1,len(seq)):
    if seq[i] <= LIS[0]:
        LIS.appendleft(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])-1] = seq[i]

print(len(LIS))


Measured memory_bytes: 81788
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N,X,x=0,y=0,L;
	cin >> N >> X;
	rep(i, N) {
		if (x <= X)
			y++;
		cin >> L;
		x += L;
	}
	if (x <= X)
		y++;
	cout << y;
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll Q;
    cin >> Q;
    
    while(Q--){
        ll b, e, k;
        cin >> b >> e >> k;

        ll count = 0;
        FOR(i, b, e){
            if(A[i]==k) count++;
        }
        p(count);
    }
    
    return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,m;
	cin >> n >> m;
	if(abs(n-m) >= 2){
		cout << 0 << "\n";
		return 0;
	}else if(abs(n-m) == 1){
		ll ans = 1;
		FOR(i,1,n+1){
			ans = (ans * i) % MOD;
		}
		FOR(i,1,m+1){
			ans = (ans * i) % MOD;
		}
		ANS(ans);
	}else{
		ll ans = 2;
		FOR(i,1,n+1){
			ans = (ans * i) % MOD;
		}
		FOR(i,1,m+1){
			ans = (ans * i) % MOD;
		}
		ANS(ans);
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var h=new int[s[0]][];
		for(int i = 0;i<s[0];i++) {h[i]=sc.Ia;}
		Array.Sort(h,(u,v)=>u[0]-v[0]);
		var dp=Enumerable.Repeat(-1,6002).ToArray();
		dp[0]=0;
		int p=0;
		for(int i = 0;i<s[0];i++) {
			for(int j = p;j>=0;j--) {
				if(dp[j]>=0){
					dp[j+h[i][0]]=Max(dp[j]+h[i][1],dp[j+h[i][0]]);
					p=Max(p,j+h[i][0]);
					p=Min(p,s[1]-1);
				}
			}
		}
		Console.WriteLine("{0}",dp.Max());
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13532
#include <iostream>
using namespace std;
#define ll long long
int main()
{
    ll n, k;
    scanf("%lld%lld", &n, &k);
    if(n % k == 0)
        printf("0\n");
    else {
        printf("%lld\n", min(n % k, abs(n % k - k)));
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

  unordered_map<string, int> counts(n);

  int maxCount = 0;

  // create map
  rep(i, n) {
    string s;
    cin >> s;
    counts[s]++;
    maxCount = max(counts[s], maxCount);
  }

  // filter
  vector<string> strs;
  for(auto x : counts) {
    if (x.second == maxCount) {
      strs.push_back(x.first);
    }
  }

  sort(strs.begin(), strs.end());

  rep(i, strs.size()) {
    cout << strs[i] << endl;
  }
}


Measured memory_bytes: 25332
use proconio::input;
use superslice::Ext;

fn solve(g : &Vec<Vec<usize>>, a : &Vec<u32>,
         pos : usize, prev : usize, best : usize,
         res : &mut Vec<usize>, inc : &mut Vec<u32>)
{
    let idx = inc.lower_bound(&a[pos]);
    let cur_value = inc[idx];
    inc[idx] = a[pos];
    res[pos] = best.max(idx+1);
    for &next in &g[pos] {
        if next == prev { continue; }
        solve(g, a, next, pos, res[pos], res, inc);
    }
    inc[idx] = cur_value;
}

fn main() {
    input! {
        n : usize,
        a : [u32; n]
    };
    let mut g = vec![Vec::new(); n];
    for _ in 0..n-1 {
        input! {
            (u, v) : (usize, usize)
        };
        g[u-1].push(v-1);
        g[v-1].push(u-1);
    }
    let mut res = vec![1; n];
    let mut inc = vec![1_000_000_007; n];
    solve(&g, &a, 0, n, 1, &mut res, &mut inc);
    for r in res { println!("{}", r); }
}


Measured memory_bytes: 36504
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {};
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], a[1] = __gcd(a[i], a[1]);
    cout << a[1];
}


Measured memory_bytes: 640
n = gets.to_i
ary = []
n.times do
  ary << gets.chomp.to_i
end
 
i = 0
cnt = 1
 
n.times do
  if ary[i] == 2
    puts cnt
    exit
  else
    i = ary[i] - 1
    cnt += 1
  end
end
 
puts -1

Measured memory_bytes: 2684
#include <iostream>

using namespace std;

class A {
	int N, a, b;
public:
	void solve()
	{
		if (N == 1)
			cout << "Hello World" << endl;
		else
			cout << (a + b) << endl;
	}

	A()
	{
		cin >> N >> a >> b;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
l = sorted(l, key=itemgetter(1), reverse=True)
a = sorted(a)
idx = 0
cont_flag = 1
for b, c in l:
    cnt = 1
    while(cnt <= b and cont_flag):
        if a[idx] < c:
            a[idx] = c
            idx += 1
            cnt += 1
            if idx == n:
                cont_flag = 0
        else:
            break
    if not cont_flag:
        break
print(sum(a))

Measured memory_bytes: 33696
#include<stdio.h>

int fibonacci(int);
int F[45];
int main(){
  int i,n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}

int fibonacci(int n){
  int i;
  F[0]=1;
  F[1]=1;
  if(n==0 ||n==1) return 1;
  for(i=2;i<=n;i++){
  F[i]=F[i-2]+F[i-1];
  }
  return F[n];
}

Measured memory_bytes: 596
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
   char str[20];
   scanf("%s",str);
   int k=0;
   while(str[k]!='\0')
   {
   	 int p=k%2;
   	 if(p==1&&str[k]!='i')
   	 break;
   	 if(p==0&&str[k]!='h')
   	 break;
   	 k++;
   }
   
   if(k==strlen(str)&&k%2!=1)
   printf("Yes");
   else
   printf("No");
   
   return 0;
}

Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split()))
count = 0
for x in ls:
    if x < 0:
        count += 1
ls2 = list(map(abs, ls))
if count % 2 == 0:
    print(sum(ls2))
else:
    print(sum(ls2) - 2 * min(ls2))

Measured memory_bytes: 14412
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (x, y) = read!(i64, i64);

    if x == y {
        println!("0");
        return;
    }

    if x * y > 0 {
        // x, yの符号が同じ場合
        if x < y {
            println!("{}", y - x);
            return;
        } else {
            println!("{}", x - y + 2);
            return;
        }
    } else if x * y < 0 {
        // x, yの符号が違う場合
        if x > 0 {
            // xが正、yが負
            // |x| と |y| の大小で場合分けが生じる
            if x.abs() >= y.abs() {
                println!("{}", 1 + x + y);
                return;
            } else {
                println!("{}", 1 - x - y);
                return;
            }
        } else {
            // xが負、yが正
            if x.abs() >= y.abs() {
                println!("{}", 1 - x - y);
                return;
            } else {
                println!("{}", 1 + x + y);
                return;
            }
        }
    } else {
        // x, y のどちらかが0の場合
        if x == 0 {
            if y > 0 {
                println!("{}", y - x);
                return;
            } else {
                println!("{}", 1 - y);
                return;
            }
        } else {
            if x > 0 {
                println!("{}", 1 + x);
                return;
            } else {
                println!("{}", -x);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    string s;
    while ((s = readln.chomp) != null) {
        auto ab = s.split.map!(to!int).array;
        int a = ab[0], b = ab[1];

        writeln(gcd(a, b));
    }
}

Measured memory_bytes: 2392
//09-1 IOIOI
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)

int main(){
	ROOP(){
		int n,m;
		cin >> n;
		if(n==0) break;
		cin >> m;
		string s;
		cin >> s;
		s = s+"OO";
		vector<int> sn;
		for(int i=0; i<m+2; i++){
			if(s[i]=='I') sn.push_back(1);
			else sn.push_back(0);
		}

		vector<int> num;
		for(int i=0; i<(m+2)/2; i++){
			num.push_back(0);
		}

		int before = 0;//1:I 0:O
		int tmp = 0;
		for(int i=0; i<m+2; i++){
			if(before+sn.at(i) == 1) tmp++;
			else{
				if(tmp%2 == 0) tmp -= 2;
				else tmp--;
				if(tmp>1) num.at(tmp/2)++;
				
				tmp = sn.at(i);
			}
			before = sn.at(i);
		}

		LL ans = 0;
		for(int i=n; i<(m+2)/2; i++){//i:Oの数
			ans += num.at(i)*(i-n+1);
		}

		cout << ans << endl;

		sn.clear();
		num.clear();
	}
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad\n";
    else cout << "Good\n";
}


Measured memory_bytes: 256
//Create Time: 2018-04-27 16:36:54
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
int an[(int)1e5+9];
int main(){
    int n;cin>>n;
    an[0]=0;
    rep(i,0,n)scanf("%d",an+i+1);
    an[n+1]=0;
    n+=2;
    ll s=0;
    rep(i,1,n)s+=abs(an[i]-an[i-1]);
    rep(i,1,n-1){
        printf("%lld\n",s+abs(an[i+1]-an[i-1])-abs(an[i+1]-an[i])-abs(an[i-1]-an[i]));
    }
    return 0;
}


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

int G[110][110] ={0};

int main(){
  int n;
  cin >> n;
  int u, k;
  int v[100000];
  for(int i=0; i<n; i++){
    cin >> u >> k;
    for(int j=0; j<k; j++){
      cin >> v[j];
      G[i][v[j]] = 1;
    }
  }
  for(int i=0; i<n; i++){
    for(int j=1; j<n; j++){
      cout << G[i][j] << " ";
    }
    cout << G[i][n] << endl;
  }
    
    
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

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

    if(X >= 30)
    {
        print("Yes");
    }

    else
    {
        print("No")
    }
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
 int n,d,x[11][11],a,cnt=0,b;
  scanf("%d%d",&n,&d);
  for(int i=1;i<=n;i++){
  	for(int j=1;j<=d;j++){
    	scanf("%d",&x[i][j]);
    }
  }
  for(int i=1;i<=n-1;i++){
  	for(int k=i+1;k<=n;k++){
    	a=0;
    	for(int j=1;j<=d;j++){
        	a+=(x[k][j]-x[i][j])*(x[k][j]-x[i][j]);
        }
     	b=sqrt(a);
      	if(b*b==a){
        	cnt++;
        }
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
sunuke_list=[]
for i in range(n):
    sunuke_list.append(0)
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        sunuke=a[j]
        sunuke_list[sunuke-1]=+1
print(sunuke_list.count(0))

Measured memory_bytes: 67368
W = input()
T = []
sum = 0

while True:
    a = input().split()
    if a[0] == "END_OF_TEXT":
        break
    else:
        for i in range(len(a)):
            a[i] = a[i].lower()
        T.append(a)

for i in range(len(T)):
    sum += T[i].count(W)


print(sum)



Measured memory_bytes: 5564
#include <iostream>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    long long sum = 0;

    for (int i = y + 1; i <= x; ++i) {
        sum = sum + (i - y) * (x / i);
        if (x % i - y >= 0) {
            sum = sum + 1 + x % i - y;
        }
    }

    if (y == 0) {
        sum = sum - x;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define int long long
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 505;

int a[N], b[N], l[N], r[N];
int n, k, sum, ans;

void solve(int x) {
    if(x < ans) return;
    for(register int i = 1; i <= n; i++) b[i] = a[i] % x;
    sort(b + 1, b + n + 1);
    for(register int i = 1; i <= n; i++) l[i] = l[i - 1] + b[i];
    for(register int i = n; i >= 1; i--) r[i] = r[i + 1] + (b[i] == 0 ? 0 : (x - b[i]));
    if(l[n] == 0) { ans = x; return; }
    for(register int i = 1; i < n; i++) {
        if(l[i] >= r[i + 1] && l[i] <= k) {
            ans = x; return;
        }
    }
}

signed main() {
    read(n); read(k);
    for(register int i = 1; i <= n; i++) read(a[i]), sum += a[i];
    for(register int i = 1; i * i <= sum; i++) {
        if(sum % i == 0) {
            solve(i);
            solve(sum / i);
        }
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = N

for i in range(1,N):
  j = N-i
  ist = str(i)
  jst = str(j)
  iarray = list(map(int ,ist))
  jarray = list(map(int ,jst))
  isum = sum(iarray)
  jsum = sum(jarray)
  if isum + jsum < ans:
    ans = isum + jsum
print(ans)
    
    
  


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#endif

const int INF = 1e5;
int dp[41][401][401];

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

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;

    int A[41], B[41], C[41];
    for (int i=0; i<N; ++i) {
        cin >> A[i] >> B[i] >> C[i];
    }
    
    for (int i=0; i<41; ++i) {
        for (int a=0; a<401; ++a) {
            for (int b=0; b<401; ++b) {
                dp[i][a][b] = INF;
            }
        }
    }
    dp[0][0][0] = 0;

    for (int i=0; i<N; ++i) {
        for (int a=0; a<401; ++a) {
            for (int b=0; b<401; ++b) {
                dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b]);
                if (a+A[i] <= 400 && b+B[i] <= 400) {
                    dp[i+1][a+A[i]][b+B[i]] = min(dp[i+1][a+A[i]][b+B[i]], dp[i][a][b]+C[i]);
                }
            }
        }
    }
    
    int ans = INF;
    for (int a=1; a<401; ++a) {
        for (int b=1; b<401; ++b) {
            if (a * Mb == b * Ma) {
                ans = min(ans, dp[N][a][b]);
            }
        }
    }

    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 25984
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"math"
)
 
func run() {

	var P int;
    P = nextInt();
    var Q int;
    Q = nextInt();
    var R int;
    R = nextInt();
	solve(P, Q, R);

}

func solve(P int, Q int, R int){
	Println(float64(P+Q+R) - math.Max(math.Max(float64(P),float64(Q)),float64(R)))
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



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

int main(){
    int N;cin>>N;
    int a[N+1],b[N];
    for(int i=0;i<=N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    ll monster=0;

    for(int i=0;i<N;i++){
        int ans1=min(a[i],b[i]);
        int ans2=min(a[i+1],b[i]-ans1);
        monster+=ans1;
        monster+=ans2;
        a[i]-=ans1;
        a[i+1]-=ans2;
    }
    cout <<monster;


}

Measured memory_bytes: 4384
/*_BELIEVE_*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
 int l,r;

 cin>>l>>r;

 if(r-l+1>=2019)
 cout<<0;
 else
 {
  vector<int> v;

  for(int i=l;i<=r;++i)
  v.pb(i%2019);

  int n=v.size(),ans=inf;
  for(int i=0;i<n;++i)
  {
   for(int j=i+1;j<n;++j)
   ans=min(ans,(v[i]*v[j])%2019);
  }

  cout<<ans;
 }
}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



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

int main(void){

	int A[100][100], b[100], n, m;

	cin >> n >> m;

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

	for (int i = 0; i < m; i++){
		cin >> b[i];
	}

	for (int i = 0; i < n; i++){
		int ans = 0;
		for (int j = 0; j < m; j++){
			ans += A[i][j] * b[j];
		}
		cout << ans << endl;
	}

	return 0;
}

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

const int N=99;
int n;
char a[N+5];

bool pal(int l,int r)
{
	while(l<=r)
	{
		if(a[l]!=a[r])return false;
		l++;r--;
	}
	return true;
}
int main()
{
	cin>>a+1;
	n=strlen(a+1);
	puts(pal(1,n)&&pal(1,n-1>>1)&&pal(n+3>>1,n)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    int i,j,k;
    char ch[1010];
    scanf("%s",ch);
    k = strlen(ch);
    for(i=0;i<k;i++){
        if(ch[i] == 'A'){
            ch[i]+=23;
        }
        else if(ch[i] == 'B'){
            ch[i]+=23;
        }
        else if(ch[i] == 'C'){
            ch[i]+=23;
        }
        else {
            ch[i]-=3;
        }
    }

    printf("%s",ch);

    printf("\n");


    return 0;
}

Measured memory_bytes: 1820
import scala.io.StdIn.readLine

object Main extends App {

  val n = readLine.toInt

  val ps: List[Int] = (0 until n).map(_ => readLine.toInt).toList

  val sorted = ps.sorted.reverse
  val biggest = sorted.head
  val smalls = sorted.tail

  val result = biggest / 2 + smalls.sum

  println(result)


}

Measured memory_bytes: 27332
#include <iostream>
using namespace std;
int main()
{
  int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int a;cin>>a;
  cout<<arr[a-1]<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
memo = {}

def doit(k):
    if not k in memo:
        if k == 0:
            memo[k] = sum(a)
        else:
            b = 1
            while k >= b:
                b *= 2
            b = b // 2
            d = 0
            for ai in a:
                d += b if ai & b == 0 else -b
            memo[k] = max(d + doit(k - b), doit(b - 1))
    return memo[k]

print(doit(k))


Measured memory_bytes: 14176
#include <bits//stdc++.h>
using namespace std;
int main() {
    int A,N,Max=0;
    cin >> N;
    long long goukei=0;
    for(int i=0;i<N;i++){
        cin >> A;
        goukei+=max(Max-A,0);
        Max=max(A,Max);
    }
    cout << goukei << endl;
    
}



Measured memory_bytes: 3608