akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }


void solve() {
    int n,m,k;
    cin >> n >> m >> k;
    VLL a(n), b(m);
    REP(i,0,n) cin >> a[i];
    REP(i,0,m) cin >> b[i];
    
    VLL rua(n+1), rub(m+1);
    REP(i,0,n) rua[i+1] = rua[i] + a[i];
    REP(i,0,m) rub[i+1] = rub[i] + b[i];
    int ans = 0;
    REP(i,0,n+1) {
        int rem = k - rua[i];
        if (rem < 0) break;
        auto it = upper_bound(all(rub), rem);
        --it;
        chmax(ans, i + (int)distance(rub.begin(), it));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 9528
import java.util.Scanner;
import static java.lang.Math.*;

import java.io.PrintWriter;
class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        while(true){
            int n = sc.nextInt();
            if(n == -1)return;
            double x = 0, y = 0, rad = 0;
            while(n-->0) {
                x += cos(rad);
                y += sin(rad);
                rad = atan2( y, x) + PI/2;
            }
            System.out.printf("%.2f\n%.2f\n", x, y);
        }
    }
}

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

#define DIV 998244353

long long N, S;
long long A[3005];
//           idx,  sum , state (0-> LR not fixed, 1-> L fixed, 2-> LR fixed)
long long dp[3005][3005][3];

int main(){
	cin >> N >> S;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	for(long long i = 0; i < N; i++) {
		//左端を決める
		if(A[i] <= S) {
			dp[i+1][A[i]][1] = (i + 1);
			dp[i+1][A[i]][1] %= DIV;
		}
		//左右端を同時に
		if(A[i] == S) {
			dp[i+1][S][2] += (i + 1) * (N-i);
			dp[i+1][S][2] %= DIV;
		}
		dp[i+1][S][2] += dp[i][S][2];
		dp[i+1][S][2] %= DIV;
		for(long long j = 0; j <= S; j++) {
			//A[i]を使う
			if(j + A[i] <= S) {
				dp[i+1][j + A[i]][1] += dp[i][j][1];
				dp[i+1][j + A[i]][1] %= DIV;
			}

			//A[i]を使わない
			dp[i+1][j][1] += dp[i][j][1];
			dp[i+1][j][1] %= DIV;

			//右端を決める
			if(j + A[i] == S) {
				dp[i+1][S][2] += dp[i][j][1] * (N-i);
				dp[i+1][S][2] %= DIV;
			}

		}
	}
	cout << dp[N][S][2] << endl;


	//long long ans = 0;
	////        start left, sum     , num
	//map<pair<long long, long long>, long long> memo;
	//map<pair<long long, long long>, long long> nextmemo;

	//for(long long i = 0; i < N; i++) {

	//	for(auto item: memo) {
	//		long long left = item.first.first;
	//		long long sumi = item.first.second;
	//		long long num = item.second;

	//		nextmemo[item.first] += num;
	//		

	//		//これを使う
	//		if(sumi + A[i] == S) {
	//			//cout << "left = " << left << " right = " << i << endl;
	//			//left - right
	//			ans += (left+1) * (N - i) * num;
	//			ans %= DIV;
	//		} else if(sumi + A[i] < S) {
	//			nextmemo[make_pair(left, sumi + A[i])] += num;
	//		}
	//	}


	//	//start from this
	//	if(A[i] == S) {
	//		//cout << "left = " << i << " right = " << i << endl;
	//		ans += (i+1) * (N - i);
	//		ans %= DIV;
	//	} else if (A[i] < S) {
	//		nextmemo[make_pair(i, A[i])] += 1;
	//	}
	//	swap(memo, nextmemo);
	//	nextmemo.clear();
	//}

	//cout << ans << endl;
}

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

  ll N , M , L;
  cin >> N >> M >> L ;
  if(L>=N){
    cout << 0 << endl;
    cout << max( M - ( L - N ) , (ll) 0 ) <<endl;
  }
  else{
    cout << N - L << endl;
    cout << M  <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll sum=0;
  ll i=1;
  while(n)
  {
    if(i%3==0 or i%5==0)
    {
      i++;
      n--;
      continue;
    }
    sum+=i;
    i++;
    n--;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3648
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=998244353;

class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    vector<ll> FR;
    
public:
    comb(ll mod=1000000007,ll mx=100000):mod(mod),mx(mx),F(mx+1,1),FR(mx+1,1){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        while(x>0){
            if(x&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
            x>>=1;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        for(ll i=1;i<=mx;i++){F[i]=F[i-1]*i%mod; FR[i]=R(F[i]);}
    }
    
    ll c(ll n,ll k){
        if(n<0 || k<0){return 0;}
        if(n<k){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*FR[n-k]%mod*FR[k]%mod;
    }
};

comb C(MOD,1000000);


int main(){
    ll n,x;
    cin>>n>>x;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ll cnt=0;
        for(ll t=i;t<x && t<=2*i;t++){
            cnt+=C.c(i,t-i);
        }
        cnt%=MOD;
        for(ll t=1;t*2<i && t*2<x-1;t++){
            cnt+=C.c(i-2*t,x-1-i);
            if(i-2*t==x-1-i){cnt--;}
        }
        if(2*i>=x && (x&1)){cnt++;}
        cnt%=MOD;
        ans+=cnt*C.c(n,i)%MOD;
    }
    ans%=MOD;
    ans+=MOD; ans%=MOD;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll x,b[100100],l[100100],u[100100],df=0ll;
vector<int> v;

ll comp(int i, int j){
	ll p,q;
	p = (x-b[i])*u[i]+b[i]*l[i];
	q = (x-b[j])*u[j]+b[j]*l[j];
	return p>q;
}

bool judge(ll p){
	int i;
	ll q,r,tmp=df,d=-INFLL,c,qv;
	q = p/x; r = p%x;
	for(i=0; i<q; ++i){
		tmp += (x-b[v[i]])*u[v[i]]+b[v[i]]*l[v[i]];
	}
	qv = (x-b[v[q]])*u[v[q]]+b[v[q]]*l[v[q]];
	for(i=0; i<n; ++i){
		c = min(r,b[v[i]])*l[v[i]]+max(r-b[v[i]],0ll)*u[v[i]];
		if(i<q){
			c -= (x-b[v[i]])*u[v[i]]+b[v[i]]*l[v[i]];
			d = max(d,tmp+qv+c);
		}else{
			d = max(d,tmp+c);
		}
	}
	return (d>=0ll);
}

int main(void){
	int i;
	ll ok=0ll,ng,mid;
	cin >> n >> x;
	for(i=0; i<n; ++i){
		v.push_back(i);
		cin >> b[i] >> l[i] >> u[i];
		df -= b[i]*l[i];
		ok += b[i];
	}
	if(!ok){
		cout << 0 << endl;
		return 0;
	}
	sort(v.begin(),v.end(),comp);
	ng = 0ll;
	while(ok-ng>1){
		mid = (ok+ng)>>1;
		if(judge(mid)){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 3064
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B;


  return (A == B) ? "Yes" : "No";
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
    int a, b, ans;
    char op;

    while (std::cin >> a >> op >> b) {
        if (op == '?') break;

        switch (op) {
            case '+':
                ans = a + b;
                break;
            case '-':
                ans = a - b;
                break;
            case '*':
                ans = a * b;
                break;
            case '/':
                ans = a / b;
                break;
            default:
                ans = -1;
                break;
        }
        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    static long[][] nCr = new long[51][51];

    public static void main(String[] args) {
        int N = in.i();
        int P = in.i();
        int even = 0;
        int odd = 0;
        for (int i = 0; i < N; i++) {
            if ((in.i() & 1) == 0) {
                even++;
            } else {
                odd++;
            }
        }

        long ans = 0;
        for (int i = P; i <= odd; i += 2) {
            ans += nCr(odd, i) * pow(2, even);
        }
        out.println(ans);
    }

    static long pow(long a, int b) {
        long c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }

    static long nCr(int n, int r) {
        if (n < r) return 0;
        if (nCr[n][r] > 0) return nCr[n][r];
        if (r == 0) return nCr[n][r] = 1;
        if (n - r < r) return nCr[n][r] = nCr(n, n - r);
        else return nCr[n][r] = nCr(n - 1, r - 1) + nCr(n - 1, r);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (c == ' ' || c == '\n') {
                break;
            }
            cbuf[i] = c;
        }
        if (i == cbuf.length) next();
        return i;
    }
}


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

class Stack{
private:
  int sp;
  int S[100];
public:
  Stack(){
    sp=0;
  }
  bool isFull() const {return (sp==100);}
  bool isEmpty() const {return (sp==0);}
  void push(int d);
  int top();
  void pop();
};

void Stack::push(int d){
  if(isFull())
  return;
  S[sp++]=d;
}

int Stack::top(){
  if(isEmpty())
  return -1;

  return S[sp-1];
}

void Stack::pop(){
  if(isEmpty())
  return;

  sp--;
}

int main(){

Stack s;

string expr;
getline(cin,expr);

istringstream is(expr);

while(!is.eof()){
  string op;
  is>>op;

  int tmp1,tmp2;

  switch(op[0]){
  case '+':
    tmp1=s.top(); s.pop();
    tmp2=s.top(); s.pop();
    s.push(tmp2+tmp1);
    break;

  case '-':
    tmp1=s.top(); s.pop();
    tmp2=s.top(); s.pop();
    s.push(tmp2-tmp1);
    break;

  case '*':
    tmp1=s.top(); s.pop();
    tmp2=s.top(); s.pop();
    s.push(tmp2*tmp1);
    break;

  default:
    istringstream is2(op);
    is2>>tmp1;
    s.push(tmp1);
    break;
  }
}

cout<<s.top()<<endl;

return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<vecint> t(n, vecint(m));
  REP(i,n)REP(j,m) {
    cin>>t[i][j];
    --t[i][j];
  }
  vecint cnt(m);
  REP(i,n) ++cnt[t[i][0]];
  int mn = n;
  vecint index(n, 0);
  set<int> del;
  REP(i,m) {
    int mx = 0;
    REP(j,m) {
      mx = max(mx, cnt[j]);
    }
    mn = min(mn, mx);
    REP(j,m) {
      if (cnt[j] == mx) del.insert(j);
      cnt[j] = 0;
    }
    if (del.size() == m) break;
    REP(j,n) {
      while (del.count(t[j][index[j]])) ++index[j];
      ++cnt[t[j][index[j]]];
    }
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
const int size=1000000;
int main(){
  int i,k,n;
  int data[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  while(scanf("%d",&n)!=EOF){
    int cnt=0;
    for(i=2;i<=n;i++){
      if(data[i])cnt++;
    }
    printf("%d\n",cnt);
  }
}

Measured memory_bytes: 6492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int s = sc.nextInt();
			int a[] = new int[4];
			for (int i = 0; i < 4; i++) {
				a[i] = s % 10;
				s /= 10;
			}
			boolean result = false;

			for (int i = 1; i < 4; i++) {
				if (a[i] == a[i - 1]) {
					result = true;
					break;
				}
			}

			if (result) {
				System.out.println("Bad");
			} else {
				System.out.println("Good");
			}
		}

	}

}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int Q; cin >> Q;
	while (Q--) {
		int c, a, n; cin >> c >> a >> n;
		int ans = 0;
		
		while(c&&a&&n) {
			c--; a--; n--; ans++;
		}
		while (c > 1 && a) {
			c -= 2; a--; ans++;
		}
		while (c > 2) {
			c -= 3; ans++;
		}
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>

int main(void){
  int x,y;

  while(1){
    scanf("%d%d",&x,&y);
    if(x==0 && y==0)  break;
    if(x<y)  printf("%d %d\n",x,y);
    else  printf("%d %d\n",y,x);
  }

  return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,v;
	while(cin>>N) {
		string ans = "APPROVED";
		REP(i, N) {
			cin>>v;
			if(!(v%2==1 || v%2==0 && (v%3==0 || v%5==0))) ans = "DENIED";
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int num[200010];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	vector<int> v;
	int l,n;
	cin>>l>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		if(i>1)
			v.push_back(num[i]-num[i-1]);
	}
	v.push_back(l-num[n]+num[1]);
	sort(v.begin(),v.end(),greater<int>());
	cout<<l-v[0];
	return 0;
}

Measured memory_bytes: 4468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		char []s = sc.next().toCharArray();
		
		for(int i = 0 ; i< s.length;i++) {
			if(s[i] == '?') {
				s[i] = 'D';
			}
		}
		String t = String.valueOf(s);
		System.out.println(t);
		
		
		}

	}



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

int main(){
	int n, temp;
	unordered_set<int> a;
	bool distinct = true;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> temp;
		if(a.find(temp) != a.end()){
			distinct = false;
		}
		a.insert(temp);
	}

	if(distinct){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 8520
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(const int n = getInt()){
    vector<int> a(n);
    vector<int> b(n);

    REP(i,n) a[i] = getInt();
    REP(i,n) b[i] = getInt();

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    vector<int> t(n);

    for(int i = 0; i < n - 1; i += 2){
      if(a[i] > b[i/2]){
        printf("%d\n", i + 1);
        goto end;
      }
    }
    puts("NA");
  end:;
  }
  return 0;
}

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

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h * 0.5 << endl;
}

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

int main(){
  int n;
  cin >> n;
  for (int i=0;i<n;++i){//i=商品を買う個数
    int rest=n-i*100;
    if (0<=rest&&rest<=i*5){
      puts("1");
      return 0;
    }
    if (rest<0)
      break;
  }
  puts("0");
  return 0;
}
//ナップザック問題だけど今回は大袈裟すぎ

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int N, D, X[50][50], i, j, k, count = 0;
	double ans = 0.0;
	scanf("%d %d", &N, &D);
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j++) {
			scanf("%d", &X[i][j]);
		}
	}
	//ここから本処理
	for (i = 0; i < N - 1; i++) {
		for (k = i + 1; k < N; k++) {
			for (j = 0; j < D; j++) {
				ans = ans + pow((X[i][j] - X[k][j]), 2);
			}
			ans = sqrt(ans);
			if (ceil(ans) == floor(ans)) {
				count++;
			}
			ans = 0;
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

class Segment_tree
{
    using data_type = int;

public:

    vector<data_type> dat;
    int N;
    data_type id;

    data_type func(data_type u, data_type v){
        return max(u, v);
    }

    Segment_tree(int n, data_type id): id(id) {
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, id);
    }

    Segment_tree(int n, data_type id, vector<data_type> v): id(id) {
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, id);
        REP(i, n) dat[i + N - 1] = v[i];
        IREP(i, N - 1) dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]); 
    }

    //k番目の値をaに更新
    void update(int k, data_type a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    data_type query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return id;
        if(a <= l && r <= b) return dat[k];
        else{
            data_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            data_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return func(vl, vr);
        }
    }

    //[a, b)の演算結果
    data_type query(int a, int b){
        return query(a, b, 0, 0, N);
    }

    data_type getdat(int k){
        return dat[k + N - 1];
    }
};

signed main(){

    int N; cin >> N;
    vec h(N), a(N);
    readv(h); readv(a);

    Segment_tree seg(N + 1, -1);
    seg.update(0, 0);
    REP(i, N){
        int v1 = seg.getdat(h[i]);
        int v2 = seg.query(0, h[i]) + a[i];
        seg.update(h[i], max(v1, v2)); 
    }
    int ans = 0;
    REP(i, N + 1) ans = max(ans, seg.getdat(i));
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 7424
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1; i <= 5; i++){
            int num = sc.nextInt();
            if(num == 0){
                System.out.print(i);
                System.exit(0);
            }
        }
    }
}


Measured memory_bytes: 35840
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]

from bisect import bisect_left
for i in range(len(x)):
    idx1 = bisect_left(s, x[i])
    idx2 = bisect_left(t, x[i])

    cands = [[], []]
    if idx1 != 0 and idx1 != len(s):
        cands[0].append(s[idx1 - 1])
        cands[0].append(s[idx1])
    elif idx1 == 0:
        cands[0].append(-float('inf'))
        cands[0].append(s[idx1])
    elif idx1 == len(s):
        cands[0].append(s[idx1 - 1])
        cands[0].append(float('inf'))
    if idx2 != 0 and idx2 != len(t):
        cands[1].append(t[idx2 - 1])
        cands[1].append(t[idx2])
    elif idx2 == 0:
        cands[1].append(-float('inf'))
        cands[1].append(t[idx2])
    elif idx2 == len(t):
        cands[1].append(t[idx2 - 1])
        cands[1].append(float('inf'))

    # print(cands, x[i])
    print(min(x[i] - min([cands[0][0], cands[1][0]]),
              max([cands[0][1], cands[1][1]]) - x[i],
              (x[i] - cands[1][0]) * 2 + (cands[0][1] - x[i]),
              (x[i] - cands[1][0]) + (cands[0][1] - x[i]) * 2,
              (x[i] - cands[0][0]) * 2 + (cands[1][1] - x[i]),
              (x[i] - cands[0][0]) + (cands[1][1] - x[i]) * 2))


Measured memory_bytes: 16168
#include <iostream>
#include <stack>
#include <string>
using namespace std;
stack<int> st;
int main(){
    string s;
    while(cin >> s){
        if(s == "+"){
            int x, y;
            x = st.top();
            st.pop();
            y = st.top();
            st.pop();
            st.push(x+y);
            //cout << st.top() << endl;
        } else if(s == "*"){
            int x, y;
            x = st.top();
            st.pop();
            y = st.top();
            st.pop();
            st.push(x*y);
            //cout << st.top() << endl;
        } else if(s == "-"){
            int x, y;
            x = st.top();
            st.pop();
            y = st.top();
            st.pop();
            st.push(y-x);
            //cout << st.top() << endl;
        } else{
            st.push(stoi(s));
        }
    }
    cout << st.top() << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  
  string red, green, down_str;
  while(cin >> red >> green >> down_str) {
    if(cin.eof()) break;
    int rsize = red.size();
    int gsize = green.size();
    int dsize = down_str.size();
    
    string ans;
    int rpos = 0, gpos = 0;
    char cent = green[gpos++];
    for(int dpos=0; rpos<rsize || gpos<gsize;) {
      if(dpos<dsize && down_str[dpos]==cent) {
        dpos ++;
        cent = red[rpos++];
      }
      else {
        ans += cent;
        cent = green[gpos++];
      }
    }
    cout << ans+cent << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll nums[2000000];

int main() {
    while (1) {
        int N, M;
        cin >> N >> M;
        fill(nums, nums + 2000000, 0);
        if (N == 0) {
            break;
        }
        ll h[N];
        for (int i = 0; i < N; i++) {
            cin >> h[i];
            ll num = 0;
            for (int j = 0; j <= i; j++) {
                num += h[i - j];
                nums[num]++;
            }
        }
        ll w[M];
        ll ans = 0;
        for (int i = 0; i < M; i++) {
            cin >> w[i];
            ll num = 0;
            for (int j = 0; j <= i; j++) {
                num += w[i - j];
                ans += nums[num];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 18716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=405,INF=1e18+7;
//did u check when n=1?
//is mxN correct?
int n,v[mxN],pref[mxN];
int dp[mxN][mxN];

int32_t main(){
    //memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
        pref[i+1]=pref[i]+v[i];
    }
    //cout<<solve(0,n-1)<<"\n";
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j)dp[i][j]=0;
            else{
                int ans=INF;
                for(int k=i;k<j;k++){
                    ans=min(ans,dp[i][k]+dp[k+1][j]+pref[j+1]-pref[i]);
                }
                dp[i][j]=ans;
            }
        }
    }
    cout<<dp[0][n-1];

}   
//dp[l][r]=menor custo pra transformar l->r em um slime
///z

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    string s;
    int a;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<"\n";
    }
    else{
        cout<<"red\n";
    }



    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
ans = 0
R = []
G = []
B = []


for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R) * len(G) * len(B)


for i in range(0,n-2):
    for j in range(i+1,n-1):
        k = j + ( j -i )
        if k < n:
            if s[i] != s[j] and s[k] != s[j] and s[i] != s[k]:
                ans -= 1


print(ans)

Measured memory_bytes: 9324
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define SZ(c) int(c.size())
#define pb push_back
#define loop(i,start,n)  for(int i=start;i<n;i++)
#define rloop(i,start,n)  for(int i=start;i>n;i--)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
const ll inf = 2e9+3;

void solve(){
    int tc=1 ;
    //cin >> tc;
    while(tc--) {
        ll n; cin >> n;
        string res = "";
        while (n){
            int c = n%26;

            if(c-1>=0)res+=char('a'+c-1);
            else res+='z';

            if(c==0) n--;
            n/=26;
        }
        reverse(res.begin(),res.end());
        cout << res << endl;
    }
}

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

Measured memory_bytes: 3660
import java.util.Scanner;

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

		int a=0;
		int b=0;


		try(Scanner scanner=new Scanner(System.in)){
			a=scanner.nextInt();
			b=scanner.nextInt();
		}

		if(a >= 1 && b<=100) {
		System.out.print(a*b + " ");
		System.out.println(2*a+2*b);
		}

	}

}

Measured memory_bytes: 26004
let () =
    let main () =
        let n, u, v = Scanf.scanf "%d %d %d" (fun n u v -> n, u - 1, v - 1) in
        let ab = Array.init (n - 1) (fun _ -> Scanf.scanf " %d %d" (fun a b -> a - 1, b - 1)) in
        let nei = Array.make n [] in
        Array.iter (fun (a, b) -> nei.(a) <- b :: nei.(a); nei.(b) <- a :: nei.(b)) ab;
        let dist_aoki = Array.make n (-1) in
        let rec loop dist next = function
            | [] -> if next = [] then dist else loop (dist + 1) [] next
            | hd :: tl ->
                    if dist_aoki.(hd) >= 0 then loop dist next tl else (
                        dist_aoki.(hd) <- dist;
                        let next = List.rev_append nei.(hd) next in
                        loop dist next tl
                    )
        in
        let _ = loop 0 [] [ v ] in
        let dist_takahashi = Array.make n (-1) in
        let rec loop dist next = function
            | [] -> if next = [] then dist else loop (dist + 1) [] next
            | hd :: tl ->
                    if dist_aoki.(hd) <= dist || dist_takahashi.(hd) >= 0 then loop dist next tl else (
                        dist_takahashi.(hd) <- dist;
                        let next = List.rev_append nei.(hd) next in
                        loop dist next tl
                    )
        in
        let _ = loop 0 [] [ u ] in
        let rec loop i acc =
            if i = n then acc else
                let acc = if dist_takahashi.(i) < dist_aoki.(i) && dist_takahashi.(i) <> (-1) then max acc dist_aoki.(i) else acc in
                loop (i + 1) acc
        in
        let r = loop 0 0 in
        Printf.printf "%d\n" (r - 1)
    in
    main ()

Measured memory_bytes: 15616
#include <iostream>
#include <algorithm>

using namespace std;

// Find Maximum Sub Square Matrix
int main() {
    int h, w;
    cin >> h >> w;

    int G[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            cin >> x;
            G[i][j] = x;
        }
    }

    int maxWidth = 0;
    int dp[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            dp[i][j] = G[i][j] == 0 ? 1 : 0;
            maxWidth |= dp[i][j];
        }
    }

    for (int i = 1; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if (dp[i][j]) {
                // ?????????????????????????´??????????????°??????????1????????????????????????(i,j)???????????????????????£?????§???????????§?????£?????¢???????????????
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                maxWidth = max(maxWidth, dp[i][j]);
            }
        }
    }
    cout << maxWidth * maxWidth << endl;

    return 0;
}

Measured memory_bytes: 18280
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll A[201010];

int main() {
  //
  cin >> N;
  rep(i, 0, N) { cin >> A[i]; }

  ll ans = 0;
  rep(i, 1, N) {
    ll diff = A[i - 1] - A[i];
    if (diff > 0) {
      ans += diff;
      A[i] += diff;
    }
  }

  cout << ans;
}


Measured memory_bytes: 5192
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string S[3];
	FOR(i, 0, 3) cin >> S[i];

	char ans;
	int t = 0;
	while (true) {
		if (S[t].size() == 0) {
			ans = static_cast<char>(t + 'A');
			break;
		}
		int nt = S[t][0] - 'a';
		S[t] = S[t].substr(1, S[t].size()-1);
		t = nt;
	}

	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int k;
    vector<vector<int>> s;
    s.resize(m);
    for(int i=0; i<m; i++){
        cin >> k;
        s[i].resize(k);
        for(int j=0; j<k; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    for(int i=0; i<m; i++) cin >> p[i];
    int cnt, ans = 0;
    bool flag;
    for(int bit=0; bit<(1<<n); bit++){
        flag = true;
        for(int i=0; i<m; i++){
            cnt = 0;
            for(int j : s[i]){
                if(bit & (1<<j)) cnt++;
            }
            if(cnt%2 != p[i]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Measured memory_bytes: 45064
module Main where
import Control.Applicative ((<$>))

main = do
  s <- (\x -> read x :: Int)  <$> getLine
  putStrLn $ solve s


solve :: Int -> String
solve n = (show h) ++ ":" ++ (show m) ++ ":" ++ (show s)
  where
    h  = div n (60 * 60 )
    m = div n (60 ) - h * 60
    s = n - m * 60  - h * 60 * 60

Measured memory_bytes: 3576
#include <iostream>
#include <vector>

using namespace std;

void recursive(int prev, int remain, vector<int> vec) {
    if(remain == 0) {
        int last = vec.back();
        vec.pop_back();
        for (int i : vec) {
            cout << i << " ";
        }
        cout << last << endl;
        return;
    }
    for(int i = 0; i < remain ; i++) {
        if(prev >= remain-i) {
            vec.push_back(remain - i);
            recursive(remain - i, i, vec);
            vec.pop_back();
        }
    }
}

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n==0) return 0;
        vector<int> vector;
        recursive(n, n, vector);
    }
}





Measured memory_bytes: 3052
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	int cou = 0;
	rep(i, 0, s.size()) {
		string a;
		a = s[i];
		cou += stoi(a);
	}
	if (n%cou == 0) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
package main

import "fmt"


func main() {
  var K, A, B int
  
  fmt.Scanf("%d\n", &K)
  fmt.Scanf("%d %d\n", &A, &B)
  
  if A%K == 0 {
    fmt.Println("OK")
    return
  }
  
  if A-(A%K)+K<= B {
    fmt.Println("OK")
  }else{
    fmt.Println("NG")
  }
}

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

int main() {
  string s;
  cin >> s;
  ll ans=0;
  ll a=0;
  bool b=false;
  for(ll i=0;i<s.size();i++) {
    if(s[i]=='A') {
      if(b) {
        a=0;
      }
      a++;
      b=false;
    }
    else if(s[i]=='B') {
      if(b) {
        a=0;
      }
      b=true;
    }
    else {
      if(b) {
        ans+=a;
      }
      else {
        a=0;
      }
      b=false;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >>  n;
  int mi = 1e9, mx = -1;
  for(int i=0, x; i<n; i++){
    cin >> x;
    mi = min(mi, x);
    mx = max(mx, x);
  }
  cout << mx - mi << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double omega_h = 2 * M_PI / (12 * 60);  //[rad/min]
    double omega_m = 2 * M_PI / (1 * 60);  //[rad/min]
    double theta_h = omega_h * (60 * H + M);
    while (theta_h >= 2 * M_PI){
        theta_h -= 2 * M_PI;
    }
    double theta_m = omega_m * (60 * H + M);
    while (theta_m >= 2 * M_PI){
        theta_m -= 2 * M_PI;
    }

    cout << setprecision(15) << sqrt(A * A + B * B - 2 * A * B * cos(theta_h - theta_m)) << endl;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int inf = 1 << 30;

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

    int n, m;
    cin >> n >> m;
    vt<string> v(n);
    for (auto &i : v) cin >> i;

    vt<vt<int>> dist(n, vt<int>(m, inf));
    dist[0][0] = v[0][0] == '#';
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i) dist[i][j] = min(dist[i][j], dist[i - 1][j] + 
                    (v[i][j] == '#' && v[i - 1][j] == '.'));
            if (j) dist[i][j] = min(dist[i][j], dist[i][j - 1] +
                    (v[i][j] == '#' && v[i][j - 1] == '.'));
        }
    }

    cout << dist.back().back();
}


Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  cin >> k;
  ll l=s.length();


  ll lin=0;
  ll rin=0;



  int stt=l,edd=-1;
  
  int si=s[0];
  for(int i=0;i<l;i++){
    if (s[i]==si){
      lin++;
    }else{
      stt=i;
      break;
    }
  }

  for(int i=l-1;i>=0;i--){
    if (s[i]==si){
      rin++;
    }else{
      edd=i;
      break;
    }
  }

  
  ll renzokou;
  if ((rin+lin)<l){
    renzokou=lin+rin;
    for(int i=stt+1;i<=edd;i++){
      if (s[i]==s[i-1]){
        ans++;
        i++;
      }
    }
    ans=ans*k+(renzokou/2)*(k-1)+lin/2+rin/2;
  }else{
    renzokou=l;
    ans=(l*k)/2;
  }
  



cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 256
nums = [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]
k = int(input()) - 1
print(nums[k])

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

using namespace std;

int main(){
  int n,k,x,ans=0;
  cin >> n >> k;
  for (int i=0;i<n;i++){
    cin >> x;
    if (k-x > x) ans+=2*x;
    else ans+=2*(k-x);
  }
  cout << ans << endl;
}


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


// ------------------------

void solve() {
    int A, B, C; cin >> A >> B >> C;

    int count = 0;

    if(A == B) ++count;
    if(A == C) ++count;
    if(B == C) ++count;

    if(count == 1){
        cout << "Yes" << "\n";
    }else
    {
        cout << "No" << "\n";
    }
}

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

Measured memory_bytes: 256