akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast()    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll knapsack(int wt[],int val[],int w,int n)
{
	ll K[n+1][w+1];
	
	 for (int i = 0; i <= n; i++) 
   { 
       for (int j = 0; j <= w; j++) 
       { 
           if (i==0 || j==0) 
               K[i][j] = 0; 
           else if (wt[i-1] <= j) 
                 K[i][j] = max(val[i-1] + K[i-1][j-wt[i-1]],  K[i-1][j]); 
           else
                 K[i][j] = K[i-1][j]; 
       } 
   } 
  
   return K[n][w]; 
} 

 
 int main()
 {
 	int n,w;
 	cin>>n>>w;
 	int wt[n],val[n];
 	for(int i=0;i<n;i++)
 	cin>>wt[i]>>val[i];
 	
 	cout<<knapsack(wt,val,w,n);
 	
	 }

Measured memory_bytes: 79104
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize, t: usize,
        a: [usize; t],
    }
    let max_ = a.iter().max().unwrap();
    let other = k - max_;

    println!("{}", if max_ > &(k / 2) { max_ - other - 1 } else { 0 });
}


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


/**
 * AIZU ONLINE JUDGE
 * 1041
 *  2020/5/10
 */
public class Main {

    PrintStream log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    PrintStream result = System.out;
    Scanner sc = new Scanner(System.in);

    void main() throws IOException {

        for(;;) {
            int N = sc.nextInt();
            if (N == 0)
                break;
            int sum = 0;
            for(int i = 0; i < N / 4; i++) {
                sum += sc.nextInt();
            }
            result.println(sum);
        }
    }

    public static void main(String[] args) throws IOException {
        new Main().main();
    }


}




Measured memory_bytes: 26316
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class bit : public vector<T> {
private:
    lli n;
public:
    bit():vector<T>(){}
    bit(lli n):vector<T>(n+1,0){
        this->n = n;
    }
    T sum(lli i){
        T s = 0;
        for(;i > 0;i -= i & -i) s += this->at(i);
        return s;
    }
    void add(lli i,T x){
        for(;i <= n;i += i & -i) this->at(i) += x;
    }
};

bit<lli> b;

lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    b = bit<lli> (n+1);
    for(lli i = 0;i < q;i++){
        scanf("%lld",&c);
        if(c == 0){
            scanf("%lld%lld%lld",&s,&t,&x);
            b.add(s,x);
            b.add(t+1,-x);
        }else if(c == 1){
            scanf("%lld",&x);
            printf("%lld\n",b.sum(x));
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

int counter = 0;

void count(vector<int> p, int a, int b){
    if (p.size() < 3) return;

    int id1, id2, id3;
    id1 = id2 = id3 = 101;
    for (int i = 0; i < p.size(); i++){
        if (p[i] <= a) id1 = i;
        else if (p[i] > a && p[i] <= b) id2 = i;
        else if (p[i] > b) id3 = i;
    }

    if (id1 == 101 || id2 == 101 || id3 == 101) return;
    else counter++;

    vector<int> new_p;
    for (int i = 0; i < p.size(); i++){
        if (i == id1 || i == id2 || i == id3) continue;
        else new_p.push_back(p[i]);
    }

    count(new_p, a, b);

}

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }

    count(p, a, b);

    cout << counter << endl;

    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int n,m,v,p;
vector<LL> A;

bool P(const int i, int v)
{
    if (n-i <= p)
        return true;
    /* everyone pick i */
    const LL x = A[i]+m;
    /*
     * We need i to be in the top p, so everyone can pick any of the
     * top p-1 w/o effecting i.
     */
    int j = n - min(p,v);
    if (x < A[n-p])
        return false;
    v -= n-(j+1)+1;             /* the top ones can't effect i */
    v -= i;                     /* anyone before i can't catch i */
    if (v > 0) {
        /*
         * m people, each select v number of problems. We need to
         * distribute the selection in a box such that max in the
         * box not exceed x.
         */
        while (A[j] > x)
            j--;
        const int y = j-i;      /* box width */
        LL vol = x*y;           /* box volume */
        FOR(k,i+1,j+1)
            vol -= A[k];
        return vol >= 1LL * v*m;
    }
    return true;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> m >> v >> p) {
        A.resize(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A));
        int lo = 0, hi = n-1;
        while (lo < hi) {
            const int mid = (lo+hi)/2;
            if (P(mid,v))
                hi = mid;
            else
                lo = mid+1;
        }
        cout << n-lo << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#import numpy as np
import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    def check(x):
        if x <= 0:
            return False
        else:
            return N+K >= sum(map(lambda a: math.ceil(a/x), A))

    s = max(A)//2
    h = s//2
    c = check(s)
    last = c
    while True:
        if c:
            s -= max(1,h)
        else:
            s += max(1,h)
        h //= 2
        last = c
        c = check(s)
        if h <= 0 and last != c:
            if last:
                s += 1
            break
    print(s)

main()


Measured memory_bytes: 30872
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define pb push_back
using namespace std;
ll ans , n , cnt ,a  , b;

string s , s1;
int type = 0;
int main(){
    ios_base::sync_with_stdio( false );
        ll T;
        cin >> a >> b;
        if( a !=b )
            cout << "No";
        else
            cout << "Yes";
}


Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long int LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
    LL x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    d = abs(d);
    LL diva = min(x / d, k);
    LL mina = x - d * diva;
    if(diva == k)
        cout << mina << endl;
    else{
        LL minb = abs(mina - d);
        diva++;
        if((k - diva) % 2 == 0){
            cout << minb << endl;
        }else
            cout << mina << endl;
    }
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 3660
#include<stdio.h>

int main(void)
{
	int n,i,x;
	int sum1=0;
	int sum2=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x);
		sum1+=x;
		sum2+=x*x;
	}
	
	printf("%d",(sum1*sum1-sum2)/2);
	return 0;
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
 
 
int main ()
{
  prep();
  int n, m;
  cin >> n >> m;
  int arr[n];
  int freq[100001] = {0};
  for (int i=0; i<n; i++){
      cin >> arr[i];
      freq[arr[i]]++;
  }
  
  set<int> modded[100001];
  for (int i=0; i<n; i++){
      modded[arr[i]%m].insert(arr[i]);
  }
  int pairs = 0;
  set<int> zeros = modded[0]; 
  int summ = 0;
  for (int i : zeros){
      summ += freq[i];
  }
  pairs += summ/2;
 
  int cur;
  set<int> mids = modded[m/2];
  if (m%2 == 0){
      summ = 0;
      for (int i : mids){
          summ += freq[i];
      }
      pairs += summ/2;
  }
  
  // for rest, for least similar ones pair w/ other num
  for (int i=1; i<m/2+m%2; i++){
      set<int> one = modded[i];
      set<int> two = modded[m-i];
      vector<int> freq11;
      vector<int> freq22;
      int sum1 = 0;
      int sum2 = 0;
      for (int j : one){
          freq11.push_back(freq[j]);
          sum1 += freq[j];
      }
      for (int j : two){
          freq22.push_back(freq[j]);
          sum2 += freq[j];
      }
      int left = abs(sum1-sum2)-abs(sum1-sum2)%2;
      pairs += min(sum1, sum2);

      if (sum1 > sum2){
          for (int i=0; i<freq11.size() && left > 0; i++){
              if (freq11[i]-freq11[i]%2 >= left){
                  pairs += left/2;
                  break;
              }else{
                  pairs += freq11[i]/2;
                  left -= freq11[i]-freq11[i]%2;
              }
          }
      }else{
          for (int i=0; i<freq22.size() && left > 0; i++){
              if (freq22[i]-freq22[i]%2 >= left){
                  pairs += left/2;
                  break;
              }else{
                  pairs += freq22[i]/2;
                  left -= freq22[i]-freq22[i]%2;
              }
          }
      }
  }
  cout << pairs;
  return 0; 
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int T = read(), X = read();
  cout << (double)T / (double)X << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input().strip())
i=0
S=""
if N==0:
    print(0)
else:
    while N!=0:
        if N%(2**(i+1))==0:
            sp="0"
        else:
            sp="1"
        S=sp+S
        N=N-(int(sp)*((-2)**i))
    #    print(N)
        i=i+1
#        print(sp)
    print(int(S))

Measured memory_bytes: 3060
import sys

x = list( map(int, input().split()) )
h = x[0]
w = x[1]

if h == 1 or w == 1:
    print(1)
    sys.exit()


menseki = h*w//2
if h*w % 2 == 0:
    print(menseki)
else:
    print(int(menseki)+1)


Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BKleeneInversion {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, K;
	    in >> N >> K;
	    vector<int> A(N);
	    REP(i,0,N) in >> A[i];
	    ll answer = 0;
	    REP(i,0,N) {
	        REP(j,i+1,N) {
//	            out << i << j << "\n";
//	            out << A[i] << A[j] << "\n";
	            if (A[i] > A[j]) {
                    answer += (ll)K*(K+1)/2;
                    answer %= MOD;
	            } else if (A[i] < A[j]) {
                    answer += ((ll)K*(K-1)/2)%MOD;
                    answer %= MOD;
	            }
	        }
	    }
	    out << answer << "\n";
	}
};


signed main() {
	BKleeneInversion solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
/*
    https://atcoder.jp/contests/abc164/tasks/abc164_d
    https://www.youtube.com/watch?v=83yW2Pp6HMk
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define set_vect(a,n); vector<int>a(n); for(auto &z : a)cin>>z;
const int mod = 2019;
string s;
void solve(){
    cin >> s;
    int n = s.length();
    map <int,int> cnt;
    ll ans = 0;
    int tmp = 0 , poww = 1;
    cnt[tmp]++;
    for(int i = n - 1 ; i >= 0 ; i--){
        int x = s[i] - '0';
        tmp = (tmp + poww * x) % mod;
        poww = 10 * poww % mod;
        ans += cnt[tmp];
        cnt[tmp]++;
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    
    int t = 1; //cin >> t;
    while(t--){solve();}
    return 0;
}

// Code By CodeWar :3 (Bao Trung)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題

int main() {
string s,t;
cin>>s>>t;
int count=0;
rep(i,s.size()){
  if(s[i]!=t[i]) count++;
}
cout<<count<<endl;


  return 0;
}


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

typedef long long ll;
ll N, X, Y, Z;
ll dp[50][1 << 18];

const ll M = 1e9+7;

int main() {
	cin >> N >> X >> Y >> Z;
	dp[0][1] = 1;
	ll res = 0;
	int mdx, mdy, mdz;
	mdx = ((1 << (X+1)) -1);
	mdy = ((1 << (X+Y+1)) -1) & ~mdx;
	mdz = ((1 << (X+Y+Z+1)) -1) & ~(mdx | mdy);
	int msx, msy, msz;
	msx = (1 << X) - 1;
	msy = ((1 << (X+Y)) - 1) & ~msx;
	msz = ((1 << (X+Y+Z)) - 1) & ~(msx | msy);

//	cout << hex << msx << " " << msy << " " << msz << endl;
//	cout << hex << mdx << " " << mdy << " " << mdz << endl;

	for(int i = 1; i <= N; i++) {
		res = (res * 10) % M;
		for(int j = 0; j < (1 << (X+Y+Z+1)); j++) {
			for(int k = 1; k <= 10; k++) {
				int x, y, z, t;
				x = ((j & msx) << k) & mdx;
				y = ((j & msy) << k) & mdy;
				z = ((j & msz) << k) & mdz;
				t = x | y | z | 1;
				
				if(t & (1 << (X+Y+Z))) {
					res = (res + dp[i-1][j]) % M;
				}
				else {
					dp[i][t] = (dp[i][t] + dp[i-1][j]) % M;
				}
			}
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 41344
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k , s , c = 0;
    cin >> k >> s;
    for ( int i = 0 ; i <= k ; i++ ) {
        for ( int j = 0 ; j <= k ; j++ ) {
            if( 0 <= s - i - j && s - i - j <= k ) c++;
        }
    }
    cout << c;
}

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


int main() {
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World";
    }
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a+b;
    }
    
    cout << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

vint ans;

int N;


void calc(vint &a,int k){
    ans.pb(k);
    if(k==0){
        a=vint(a.begin()+1,a.end());
    }
    else if(k+1==a.size()){
        a.pop_back();
    }
    else{
        a[k-1]+=a[k+1];
        a.erase(a.begin()+k,a.begin()+k+2);
    }
}

signed main(){
    cin>>N;
    vint A(N);rep(i,N)cin>>A[i];

    if(*max_element(all(A))<0){
        int k=max_element(all(A))-A.begin();
        cout<<A[k]<<endl;
        cout<<N-1<<endl;
        for(int i=N-1;i>k;i--){
            cout<<i+1<<endl;
        }
        rep(i,k)cout<<1<<endl;
        return 0;
    }

    int sumA=0,sumB=0;
    rep(i,N){
        if(i&1){
            sumB+=max(0ll,A[i]);
        }
        else{
            sumA+=max(0ll,A[i]);
        }
    }

    if(sumA>=sumB){
        if(N%2==0){
            calc(A,N-1);
        }
        else{

        }
    }
    else{
        if(N%2==0){
            calc(A,0);
        }
        else{
            calc(A,N-1);
            calc(A,0);
        }
    }




    while(true){
        bool flag=false;
        for(int i=0;i<A.size();i+=2){
            if(A[i]>=0)continue;
            if(i==0){
                calc(A,0);
                calc(A,0);
            }
            else if(i+1==A.size()){
                calc(A,A.size()-1);
                calc(A,A.size()-1);
            }
            else{
                calc(A,i);
            }
            flag=true;
            break;
        }
        if(!flag)break;
    }
    while(A.size()>1){
        calc(A,1);
    }
    cout<<A[0]<<endl;
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i]+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (char)((arr[i] - 'A' - 3 + 26) % 26 + 'A');
        }
        System.out.println(arr);
    }
}



Measured memory_bytes: 26032
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int ans = 0;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];
    rep(i, n) ans += max(0LL, x[i] - y[i]);
    cout << ans << endl;
}

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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

const int MAXN = 200005;

int N, M, K;
int A[MAXN], B[MAXN];
long long sumA[MAXN], sumB[MAXN];

int main(void) {
    cin >> N >> M >> K;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        sumA[i] = sumA[i - 1] + A[i];
    }
    for (int i = 1; i <= M; i++) {
        cin >> B[i];

        sumB[i] = sumB[i - 1] + B[i];
    }

    int ans = 0;

    for (int i = 0; i <= N; i++) {
        int l = 0, h = M;

        while (l <= h) {
            int m = (l + h) / 2;

            if (sumA[i] + sumB[m] <= K) {
                ans = max(ans, i + m);
                l = m + 1;
            } else {
                h = m - 1;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 8296
#include <iostream>
using namespace std;
const long MOD = 1000000007;
int main(){
	int N;
	cin >> N;
	int A[N], possible[N];
	for (int i=0; i<N; i++) {
		possible[i] = 0;
	}
	for (int i=0; i<N; i++) {
		cin >> A[i];
		int left1 = (A[i] + N-1)/2;
		int left2 = (-A[i] + N-1)/2;
		if (left1 == left2) {
			possible[left1]++;
			if (possible[left1] == 2) {
				cout << 0 << endl;
				return 0;
			}
		} else {
			possible[left1]++;
			possible[left2]++;
			if (possible[left1] == 3 || possible[left2] == 3) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	long ans = 1;
	for (int i=0; i<N/2; ++i) {
		ans *= possible[i];
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

void insertionsort(int *A,int n){
		int i,j,k,v;
		
		for(i=1;i<n;i++){

			for(k=0;k<n-1;k++){
			printf("%d ",A[k]);
			}
			
			printf("%d\n",A[n-1]);
			v = A[i];
			j = i-1;
			while(j>=0&&A[j]>v){
				A[j+1]=A[j];
				j--;
				A[j+1]=v;
				
			}
			
		}
		
			for(k=0;k<n-1;k++){
			printf("%d ",A[k]);
			}
			printf("%d\n",A[n-1]);
}
	
	





int main(){
  int n,i,A[1000];
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  insertionsort(A,n);

  return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

template<typename T>
struct Bit {
  int N; // 2のべき乗でなくてもOK
  vector<T> node;
  Bit(int N) : N(N), node(N + 1, 0) {}
  void add(int i, T w) // node[i] += w
  {
    for (int x = ++i; x <= N; x += x & -x) node[x] += w;
  }
  T sum(int i) // return sum [0, i)
  {
    T ans = 0;
    for (int x = i; x > 0; x -= x & -x) ans += node[x];
    return ans;
  }
  T sum(int i, int j) // return sum [i, j)
  {
    return sum(j) - sum(i);
  }
};

void solve() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];
  rep(i, N) a[i] -= K;
  dump(a);

  // vector<ll> b(N + 1);
  // b[0] = 0;
  // for (int i = 0; i < N; i++) {
  //   b[i + 1] = b[i] + a[i];
  // }
  vector<ll> b(N);
  b[0] = a[0];
  for (int i = 1; i < N; i++) {
    b[i] = b[i - 1] + a[i];
  }
  dump(b);

  ll ans = 0;
  rep(i, N) if (b[i] >= 0) ans++;

  // 座標圧縮
  map<ll, int> mp;
  rep(i, b.size()) mp[b[i]] = 0;
  int j = 0;
  for (auto& x : mp) x.second = j++;
  rep(i, b.size()) b[i] = mp[b[i]];
  dump(b);

  // Bit<ll> bit(N + 1);
  // bit.add(b[0], 1);
  // for (int i = 1; i <= N; i++) {
  //   ans += bit.sum(b[i] + 1); // 以下なので+1
  //   bit.add(b[i], 1);
  // }
  Bit<ll> bit(N);
  for (int i = 0; i < N; i++) {
    ll s = bit.sum(b[i] + 1); // 以下なので+1
    bit.add(b[i], 1);
    ans += s;
    dump(i, s, ans);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 17408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CSumOfProductOfPairs solver = new CSumOfProductOfPairs();
    solver.solve(1, in, out);
    out.close();
  }

  static class CSumOfProductOfPairs {

    final static long MOD = (long) (1e9 + 7);

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      long[] arr = new long[n];
      for (int i = n - 1; i >= 0; --i) {
        arr[i] = in.nextLong();
      }
      long[] pre = new long[n + 1];
      for (int i = 0; i < n; ++i) {
        pre[i + 1] = pre[i] + arr[i];
        pre[i + 1] %= MOD;
      }
      long ans = 0;
      for (int i = n - 1; i > 0; --i) {
        ans += arr[i] * (pre[i]);
        ans %= MOD;
      }
      out.println(ans);
    }

  }

  static class InputReader {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public long nextLong() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      long res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10L;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }
      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

  }
}



Measured memory_bytes: 37004
<?php
$fst = true;
while($line = trim(fgets(STDIN)))
{
    $years = explode(' ', $line);
    if ($years[0] == 0 && $years[1] == 0) {
        return;
    }
    if ($years[0] > $years[1]) {
        return;
    }
    if ($years[0] <= 0) {
        return;
    }
    if ($years[1] >= 3000) {
        return;
    }

    if ($fst) {
        $fst = false;
    } else {
        echo PHP_EOL;
    }
    $naFlag = true;
    for ($i = $years[0]; $i <= $years[1]; $i++){
        $retLeap = leap($i);
        if ($retLeap) {
            echo $i . PHP_EOL;
            $naFlag = false;
        }
    }
    if ($naFlag) {
        echo 'NA' . PHP_EOL;
    }
    
}

function leap ($year) {
    if ($year % 4 == 0) {
        if ($year % 100 == 0) {
            if ($year % 400 == 0) {
                $leap = true;
            } else {
                $leap = false;
            }
        } else {
            $leap = true;
        }
    } else {
        $leap = false;
    }
    return $leap;
}

Measured memory_bytes: 15328
N=int(input())
#ダムに溜まった水
A=list(map(int, input().split()))

"""
+ A[0]=B[0]//2+B[1]//2
- A[1]=B[1]//2+B[2]//2
+ A[2]=B[2]//2+B[3]//2
  ...
+ A[N-1]=B[N-1]//2+B[0]//2 #奇数番目

A[0]-A[1]+A[2]+....+A[N-1]=B[0]
"""
b_0=0
for i in range(N):
  if i%2==0:
    b_0+=A[i]
  else:
    b_0-=A[i]
    
for i in range(N):
  if i==0:
    print(b_0, end=" ")
    b=b_0
  else:
    b_n=(A[i-1]-b//2)*2
    print(b_n, end=" ")
    b=b_n





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

int main() {
  int n, m;
  cin >> n >> m;
  int c[n];
  fill(c, c + n, 0);
  for (int i = 0; i < 2 * m; i++) {
    int a;
    cin >> a;
    c[a - 1]++;
  }
  for (int x: c) {
    cout << x << endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
// template for atcoder beginners
// when you create a *.cpp file, this template is loaded

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

int main() {
  int N, tmp;
  double sum=0.0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
     sum += 1.0 / tmp;
  }
  cout << 1.0 / sum << endl;
}




Measured memory_bytes: 256
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(list(input()))

res = True

for j in range(1, W-1):
    for i in range(1, H-1):
        if graph[i][j] == '#' and graph[i + 1][j] == '.' and graph[i - 1][j] == '.' and graph[i][j + 1] == '.' and graph[i][j - 1] == '.':
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Measured memory_bytes: 94080
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 3e3+3;
double pd[MAX][MAX];
double a[MAX];
int N;

double solve() {
	REP(i, 0, N) REP(j, 0, N/2) pd[i][j] = 1.0;
	REP(i, 1, N) REP(j, 0, N/2) {
		pd[i][j] = pd[i-1][j] * a[i];
		if(j > 0) pd[i][j] += pd[i-1][j-1] * (1-a[i]);
	}
	return pd[N][N/2];
}

int main(int argc, char ** argv) {
	scanf("%d", &N);
	REP(i, 1, N) scanf("%lf", &a[i]);
	printf("%.10lf\n", solve());
	return 0;
}


Measured memory_bytes: 69760
#include<iostream>
using namespace std;
int main () {
  int H, N;
  cin >> H >> N;
  int a = 0;
  for (int i = 0; i < N; i ++) {
    int k;
    cin >> k;
    a += k;
  }
    cout << (a >= H ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c=0,d=0,n=0;

  while(scanf("%d,%d",&a,&b)!=EOF){
    c+=a*b;
    d+=b;
    n++;
  }
  printf("%d\n%d\n",c,(d*10/n+5)/10);
  return 0;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n);
    rep(i, m) {
        int _a;
        cin >> _a;
        a[_a] = 1;
    }

    int costToN = 0;
    for(int i = x + 1; i < n; i++) {
        costToN += a[i];
    }

    int costToZero = 0;
    for(int i = x - 1; i != 0; i--) {
        costToZero += a[i];
    }
    cout << min(costToN, costToZero) << endl;
}

Measured memory_bytes: 3632
n = int(input())
s = list(input())

e = [0]


for i in range(n):
    if s[i]=="E":
        e.append(e[i]+1)
    else:
        e.append(e[i])

w = [0]

for i in range(n):
    if s[(n-1)-i]=="W":
        w.append(w[i]+1)
    else:
        w.append(w[i])



ans = 10**9
for i in range(n):
    ans = min(ans,(n-1)-e[i]-w[(n-1)-i])
print(ans)

Measured memory_bytes: 81344
#include<stdio.h>
int main(){
  long long n,l,i,c=0,x,y;
  scanf("%lld %lld",&n,&l);
  for(i=0;i<n;i++){
    scanf("%lld %lld",&x,&y);
    if(x*x+y*y<=l*l)c++;
  }
  printf("%lld\n",c);
  return 0;
}
  


Measured memory_bytes: 1736
package main

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

func main() {
	s := bufio.NewScanner(bufio.NewReader(os.Stdin))
	s.Split(bufio.ScanWords)

	n := nextInt(s)
	m := nextInt(s)
	c := nextInt(s)

	var b []int
	for i := 0; i < m; i++ {
		b = append(b, nextInt(s))
	}

	var a [][]int
	for i := 0; i < n; i++ {
		a = append(a, make([]int, m))
		for j := 0; j < m; j++ {
			a[i][j] = nextInt(s)
		}
	}

	fmt.Println(solve(n, m, c, a, b))
}

func solve(n int, m int, c int, a [][]int, b []int) int {
	r := 0

	for i := 0; i < n; i++ {
		s := c
		for j := 0; j < m; j++ {
			s += a[i][j] * b[j]
		}
		if s > 0 {
			r++
		}
	}

	return r
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x;
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  deque<char> deq;
  for(char c : s) deq.push_back(c);
  int q;
  cin >> q;
  VI t(q, 0), f(q, 0);
  vector<char> c(q, '#');
  int revc = 0;
  rep(i, q) {
    cin >> t[i];
    if(t[i] == 1) {
      revc++;
      revc %= 2;
      continue;
    }
    else {
      cin >> f[i] >> c[i];
    }
  }
  if(revc) reverse(all(deq));
  int qrevc = 0;
  rep(i, q) {
    if(t[i] == 1) {
      qrevc++;
      qrevc %= 2;
    }
    else {
      if(revc == qrevc) {
        if(f[i] == 1) deq.push_front(c[i]);
        else deq.push_back(c[i]);
      }
      else {
        if(f[i] == 1) deq.push_back(c[i]);
        else deq.push_front(c[i]);
      }
    }
  }
  print(deq);

  return 0;
}


Measured memory_bytes: 2768
function main(input) {
  // 入力値（文字列）を改行で区切る
  const inputList = input.split(/\s/);
  const numOfN = formatNum(inputList[0]);
  const numOfA = formatNum(inputList[1]);
  
  var result = 0;
  if (numOfN >= numOfA) {
    result = 10
  }
  console.log(result);
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21956
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=1;i<=n;i++){
        	int ans=0;
        	for(int x=1;x<=(-1+(int)Math.pow(i-2, 0.5));x++){
        		for(int y=x;y<=(-x-1+(int)Math.pow(-3*x*x-2*x-3+4*i,0.5))/2;y++){
        			double z=(-x-y)+Math.pow(-3*x*x-3*y*y-2*x*y+4*i, 0.5);
        			if(z%2==0&&z>=y*2){
        				int b=(int)z/2;
        					if(x==y&&y==b){ans++;}
        					else if(x==y||y==b||b==x){ans=ans+3;}
        					else{ans=ans+6;}
        			}
        		}
        	}
        	System.out.println(""+ans);
        }
}
}

Measured memory_bytes: 40928
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define endl "\n"
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k,a,b;
	cin>>k>>a>>b;
	int cnt=0;
	for(int i=a;i<=b;i++){
		if(i%k==0)cnt++;
	}
	if(cnt!=0){
		cout<<"OK\n";
	}
	else{
		cout<<"NG\n";
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
void printVec(vector<int>& vec)
{
    for(int i = 0; i < vec.size(); i++)
    {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, n;
    cin >> k >> n;
    vector<int> q;
    vector<int> dis;
    for(int i = 0; i < n; i++)
    {
        int get;
        cin >> get;
        q.push_back(get);
        if(i > 0)
        {
            dis.push_back(get - q.at(i - 1));
            //cout << get - q.at(i - 1) << " ";
        }
    }
    dis.push_back(k - q.at(q.size() - 1) + q.at(0));
    //cout << dis.at(dis.size() - 1) << endl;
    sort(dis.begin(), dis.end());
    //dis.pop_back();
    //printVec(dis);
    int ans = 0;
    ans = k - dis.at(dis.size() - 1);
    //for(int i = 0; i < dis.size(); i++)
        //ans += dis.at(i);
    cout << ans << endl;
}



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

using namespace std;

typedef long long int ll;

const int MAXN = 100 + 7;
const int MAXV = 1000 + 7;

const ll LINF = 1001002003004005006LL;

int N, W;
int v[MAXN], w[MAXN];
ll dp[MAXV * MAXN];

int main() {
  //init to inf because we are looking for minimum weight
  for(int i = 0; i < MAXV * MAXN; ++i) dp[i] = LINF;
  dp[0] = 0ll; //never forget

  cin >> N >> W;

  for(int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  for(int i = 0; i < N; ++i) {
    for(int j = MAXV * MAXN - 1; j >= v[i]; --j) {
      //for every possible value, pick the minimum weight to get that value
      //if the loop is increasing, the same item i can be picked multiple times
      /*
      3 8
      3 30
      4 50
      5 60
      ->100 (4 and 4)
      */
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
  }

  int ans = 0;
  for(int i = 0; i < MAXN * MAXV; ++i) {
    //only check bags with weight <= maximum capacity
    if(dp[i] <= W) {
      ans = i;
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1024
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS
    int h, a; cin>>h>>a;

    if(h%a==0)
    cout<<h/a;
    else
    {
        cout<<h/a+1;
    }
    




   
   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int ans1 = 0;
		int ans2 = 0;
		String[] s = saori.nextHayami().split("");
		boolean flg = false;
		for(int i = 0;i < s.length-2;i++){
			if(s[i].equals(s[i+1])){
				flg = true;
				ans1 = i+1;
				ans2 = i+3;
				break;
			} else if(s[i].equals(s[i+2])){
				flg = true;
				ans1 = i+1;
				ans2 = i+3;
				break;
			} else if(s[i+1].equals(s[i+2])){
				flg = true;
				ans1 = i+1;
				ans2 = i+3;
			}
		}

		if(s.length == 2 && s[0].equals(s[1])){
			flg = true;
			ans1 = 1;
			ans2 = 2;
		}
		if(flg){
			System.out.println(ans1 + " " + ans2);
		} else {
			System.out.println(-1 + " " + -1);
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 29012
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;

int main(){
    string S; int K;
    cin >> S >> K;
    int L = S.size();
    reverse(ALL(S));

    vector<vector<ll>> f(L+1, vector<ll>(K+1)), g(L+1, vector<ll>(K+1));
    rep(i, L) f[i][0] = g[i][0] = 1;

    rep2(i, 1, L+1) rep2(j, 1, K+1){
        int x = S[i-1] - '0';
        if(x > 0){
            f[i][j] += f[i-1][j-1];
            f[i][j] += (x-1) * g[i-1][j-1];
            f[i][j] += g[i-1][j];
        }
        else{
            f[i][j] += f[i-1][j];
        }
        g[i][j] += 9 * g[i-1][j-1];
        g[i][j] += g[i-1][j];
    }
    cout << f[L][K] << endl;
}

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

int main() {
  string S;
  cin>>S;
  if(S.at(S.size()-1)=='s'){
    cout<<S<<"es"<<endl;
  }
  else{
    cout<<S<<"s"<<endl;
  }
}

Measured memory_bytes: 3640