akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   ll n;
   cin>>n;
   ll a[n],s=0;
   for(int i=0;i<n;i++){
   cin>>a[i];
   s=s+a[i];}
   ll t;
   cin>>t;
   while(t--)
   {
       ll x,y;
       cin>>x>>y;
       cout<<s-a[x-1]+y<<"\n";
   }}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,a2,a3,sum;
	cin>>a1;
	cin>>a2;
	cin>>a3;
	sum=a1+a2+a3;
	if(sum>=22)
	cout<<"bust";
	else
	cout<<"win";
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
#define INF 1e18
#define vec vector<int>
#define REP(i,a,b) for(i=a;i<b;i++)
using namespace std;
int32_t main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
        cin>>a[i];
    int x=a[0],ans=0;
    for(i=1;i<n;i++)
    {
      if(a[i]<x)
            ans+=x-a[i];
      else 
        x=a[i];
    }
    cout<<ans<<"\n";
  }
}


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

typedef pair<string,int> state;

int main(){

  int n,q;
  cin >> n >> q;
  queue<state> que;


  for(int i=0; i<n; i++){
    string s;
    int t;
    cin >> s >> t;
    que.push( state(s,t) );
  }

  int time = 0;
  while(que.size()){

    state front = que.front();
    front.second -= q;
    que.pop();
    if(front.second > 0){
      que.push( front );
      time += q;
    }
    else{
      time += front.second + q;
      cout << front.first << " "<< time << endl;
    }

  }

  


}

Measured memory_bytes: 6328
L, R = map(int, input().split())

min1 = 10000
border = 4039
ancker = 99999

'''
for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min1 :
        min1 = i % 2019
        ancker = i

min2 = 100000

for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min2 and i != ancker:
        min2 = i % 2019
'''

min1 = 100000

for i in range(L,  min(R+1, L + border)) :
    for j in range(i + 1, min(R+1, L + border)) :
        if (i * j) % 2019 < min1 :
            min1 = (i * j) % 2019

#ans = (min1 * min2) % 2019

print(min1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  ll ans=inf;
  for(ll i=0;i<2;i++) {
    ll tmp=0;
    for(ll j=0;j<n;j++) {
      if(j%2) {
        tmp+=i!=(s[j]-'0');
      }
      else {
        tmp+=i==(s[j]-'0');
      }
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
flag=True
for i in range(N):
  if A[i]%2==0:
    if A[i]%3 == 0 or A[i]%5 == 0:
      continue
    else:
      flag=False

if flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int a[3];

	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);

	cout << a[2]*10+a[1]+a[0] << endl;

	return 0;
	
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};

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

  int64_t N;
  Mint S = 0;
  Mint SS = 0;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    S += A[i];
    SS += A[i] * A[i];
  }
  Mint result = (S * S - SS) / 2;
  cout << result.value << endl;
  return 0;
}


Measured memory_bytes: 4768
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll n;
    cin >> n;
    ll ans = 1LL<<60;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll j = n / i;
            ans = min(ans, abs(i - 1) + abs(j -1));
        }
    }
    cout << ans << endl;
}


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

int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   int s;
   while (cin >> s)
   {
      int sum{}, mi = 12345678;
      for (int i = 0; i < s; i++)
      {
         int x; cin >> x;
         sum += x;
         if (x % 10)
         {
            mi = min(mi, x);
         }
      }
      if (0 == (sum % 10))
      {
         if (mi == 12345678)
            sum = 0;
         else
         {
            sum -= mi;
         }
      }
      cout << sum << "\n";
   }
   return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import sys


def solve(ls, v1, v2):
    lsum = sum(ls)
    d1 = v1 * lsum / (v1 + v2)
    d = 0.0
    for i in range(len(ls)):
        d += ls[i]
        if d >= d1:
            break
        else:
            continue
    return i + 1


if __name__ == "__main__":
    for line in sys.stdin:
        vals = array.array("d", map(float, line.split(",")))
        ls = vals[:10]
        v1, v2 = vals[-2:]
        print(solve(ls, v1, v2))

Measured memory_bytes: 7496
#!/usr/bin/env python3

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
from itertools import count, cycle, repeat     # count(start[,step]), cycle(iter), repeat(elm[,n])
from itertools import groupby                  # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
from itertools import starmap                  # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    from fractions import gcd
    a, b = mi()
    # g = math.gcd(a, b)
    g = gcd(a, b)
    print(a * b // g)

if __name__ == "__main__":
    main()

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

const int INF=999999999;

int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	vector<int>vW(N+1,0),vE(N+1,0);
	for(int i=0;i<N;i++){
		vW[i+1]+=vW[i];
		if(S[i]=='W')vW[i+1]++;
		vE[i+1]+=vE[i];
		if(S[i]=='E')vE[i+1]++;
	}
	int ans=INF;
	for(int i=0;i<N;i++){
		int now=vW[i]+(vE[N]-vE[i+1]);
		if(ans>now)ans=now;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include<cstdio>
#include<queue>
using namespace std;
queue<int> q;
int beg[100100],nex[200100],tto[200100],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int dis[100100];
int color[100100];
struct ask{
	int d,v,c;
}qury[100100];
void insert(int u,int d){
	if(d>dis[u]){
		dis[u]=d;
		q.push(u);
	}
}
void solve(int u,int d,int c){
	insert(u,d);
	while(!q.empty()){
		u=q.front();
		q.pop();
		if(!color[u]) color[u]=c;
		for(int i=beg[u];i;i=nex[i])
			insert(tto[i],dis[u]-1);
	}
}
int main(){
//	freopen("B.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	int s,t;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&s,&t);
		putin(s,t);
		putin(t,s);
	}
	for(int i=1;i<=n;i++) dis[i]=-1;
	int Q;
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++)
		scanf("%d%d%d",&qury[i].v,&qury[i].d,&qury[i].c);

	for(int i=Q;i>=1;i--)
		solve(qury[i].v,qury[i].d,qury[i].c);
	for(int i=1;i<=n;i++)
		printf("%d\n",color[i]);
	return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
int ct[2][MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x; cin >> x;
        ct[i%2][x]++;
    }

    int amax = 0;
    for (int i = 0; i < MAXN; i++)
        amax = max (amax, ct[0][i] + ct[1][i]);

    sort (ct[0], ct[0] + MAXN);
    reverse (ct[0], ct[0] + MAXN);
    sort (ct[1], ct[1] + MAXN);
    reverse (ct[1], ct[1] + MAXN);

    int ans = ct[0][0] + ct[1][0];
    if (amax == ans)
        ans = max (ct[0][0] + ct[1][1], ct[1][0] + ct[0][1]);
    cout << N - ans << "\n";
}

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

int d[1000][1000],ans[1000][1000];
int dx[]{1,-1,0,0},dy[]{0,0,1,-1};
int main(){
	int r,c,x1,y1,x2,y2;cin>>r>>c>>x1>>y1>>x2>>y2;
	queue<P>que;
	memset(d,-1,sizeof(d));
	ans[x1][y1]=1;d[x1][y1]=0;que.push(P(x1,y1));
	while(!que.empty()){
		P p=que.front();que.pop();
		rep(i,4){
			int nx=p.first+dx[i],ny=p.second+dy[i];
			int a=0;
			if(nx<0||nx>=r){
				nx=(nx+r)%r;a++;
			}
			if(ny<0||ny>=c){
				ny=(ny+c)%c;a++;
			}
			if(a==2)continue;
			if(d[nx][ny]==-1){
				d[nx][ny]=d[p.first][p.second]+1;
				que.push(P(nx,ny));
			}
			if(d[nx][ny]==d[p.first][p.second]+1)
				(ans[nx][ny]+=ans[p.first][p.second])%=MOD;
		}
	}
	printf("%d\n",ans[x2][y2]);
}

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

using namespace std;

typedef long long ll;

int main()
{
    int a, b, c, k;

    cin >> a >> b >> c;
    cin >> k;

    while(b <= a && k > 0)
    {
        b *= 2;
        k--;
    }

    while(c <= b && k > 0)
    {
        c *= 2;
        k--;
    }

    if(a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

	return 0;
}



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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll cnt[1000010];

int main(){
  int a,b;
  cin >> a >> b;
  set<pair<ll,int>> st;
  REP(i,b) {
    int x,y;
    cin >> x >> y;
    st.erase({cnt[x],a-x});
    cnt[x] += y;
    st.insert({cnt[x],a-x});
    set<pair<ll,int>>::iterator it = st.end();
    it--;
    cout << a - (*it).se << " " << (*it).fi << endl;
  }

  return 0;
}



Measured memory_bytes: 16816
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * 100100 for _ in range(N + 10)] 
for i in range(N):
    for j in range(W + 1):
        if j - vw[i][1] >= 0:
            dp[i + 1][j] =  max(dp[i][j - vw[i][1]] + vw[i][0], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 120300
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}


const double eps=1e-9;
const double pi=acos(-1);

struct point{
	double x,y;
	inline void read(){
		scanf("%lf%lf",&x,&y);
	}
	inline bool operator < (const point &nt) const {
		if(y==nt.y) return x<nt.x;
		return y<nt.y;
	}
	inline point operator + (const point &nt) const {
		return (point){x+nt.x,y+nt.y};
	}
	inline point operator - (const point &nt) const {
		return (point){x-nt.x,y-nt.y};
	}
	inline point operator * (const double &nt) const {
		return (point){x*nt,y*nt};
	}
	inline double length(){
		return sqrt(x*x+y*y);
	}
};

double distance(point x,point y){ //距离 
	return sqrt((y.x-x.x)*(y.x-x.x)+(y.y-x.y)*(y.y-x.y));
}

struct segment{
	point x,y;
	inline void read(){
		x.read();y.read();
	}
	inline double length(){ //线段长度 
		return distance(x,y);
	}
};

struct line{
	point x,y;
	inline void read(){
		x.read();y.read();
	}
};

segment linetoseg(line x){
	return (segment){x.x,x.y};
}

line segtoline(segment x){
	return (line){x.x,x.y};
}

double DJ(point x,point y){ //点积 
	return x.x*y.x+x.y*y.y;
}

double CJ(point x,point y){ //叉积 
	return x.x*y.y-x.y*y.x;
}

point trpoint(segment x){ //将有向线段转成向量点 
	return x.y-x.x;
}

point trpoint(line x){ //将直线转成向量点 
	return x.y-x.x;
}

double prolen(point x,segment a){ //点在有向线段上的投影长度 
	return DJ(trpoint((segment){a.x,x}),trpoint(a))/a.length();
}

point propoint(point x,segment a){ //点在直线(线段)上的投影点 
	return a.x+trpoint(a)*(prolen(x,a)/a.length());
}

point refpoint(point x,segment a){ //点对于直线(线段)的对称点 
	return x+(propoint(x,a)-x)*2;
}

bool orthline(line x,line y){ //两条直线是否垂直 
	return DJ(trpoint(x),trpoint(y))==0;
}

bool paraline(line x,line y){ //两条直线是否平行 
	return CJ(trpoint(x),trpoint(y))==0;
}

bool interseg(segment x,segment y){ //两条线段是否相交 
	return min(x.x.x,x.y.x)<=max(y.x.x,y.y.x)&&min(y.x.x,y.y.x)<=max(x.x.x,x.y.x)&&min(x.x.y,x.y.y)<=max(y.x.y,y.y.y)&&min(y.x.y,y.y.y)<=max(x.x.y,x.y.y)&&CJ(y.x-x.x,y.y-x.x)*CJ(y.x-x.y,y.y-x.y)<=0&&CJ(x.x-y.x,x.y-y.x)*CJ(x.x-y.y,x.y-y.y)<=0;
}

double dispointline(point x,line y){ //点到直线的距离 
	return distance(x,propoint(x,linetoseg(y)));
}

point crossline(line x,line y){ //两条直线的交点 
	double a=dispointline(x.x,y),b=dispointline(x.y,y);
	return x.x+(x.y-x.x)*(a/(a+b));
}

bool onseg(point x,segment y){
	return abs(distance(x,y.x)+distance(x,y.y)-y.length())<=eps;
}

double dispointseg(point x,segment y){
	if(onseg(propoint(x,y),y)) return dispointline(x,segtoline(y));
	return min(distance(x,y.x),distance(x,y.y));
}

void doit(){
	segment a,b;
	a.read();
	b.read();
	double res;
	if(interseg(a,b)) res=0;
	else res=min(min(dispointseg(a.x,b),dispointseg(a.y,b)),min(dispointseg(b.x,a),dispointseg(b.y,a)));
	printf("%.10lf\n",res);
}

signed main(){
	int t;
	read(t);
	while(t--) doit();
}


Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int r = reader.nextInt();
		int g = reader.nextInt();
		int b = reader.nextInt();
		int num = r * 100 + g * 10 + b;
		String ans = "NO";
		if (num % 4 == 0) {
			ans = "YES";
		}
		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 21716
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19;

char a[100], b[100];

void solve()
{
	scanf ("%s %s", a, b);
	printf("%s", b);
	printf("%s\n", a);
}			
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}
 





Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  string s,t; cin>>s>>t;
  int ans=0;
  for (int i=0;i<3;i++){
    if(s[i]==t[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> l(2*n);
  for(int i=0;i<2*n;++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int su = 0;
  for(int i=0;i<n;++i) {
    su += l[i*2];
  }
  cout << su << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>

using namespace std;


int main()
{
	int i, N;
	string tmp;
	map<string, int> S;

	cin >> N;

	for (i = 0; i < N; i++)
	{
		cin >> tmp;
		S[tmp] = 1;
	}
	
	cout << S.size() << endl;


	return 0; 
}

Measured memory_bytes: 19216
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef pair<int,int> pint;
typedef pair<tint,tint> ptint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele(a*a, b/2);
	}else{
		return a*ele(a*a, b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

void solve(){
	int a, b, n;
	vector<tint> v;
	cin>>n;
	int ar[n];
	set<int> s;
	int cant[n+2];
	forn(i,n+2)cant[i]=0;
	forn(i,n){
		cin>>ar[i];
		cant[ar[i]]++;
		s.insert(ar[i]);
	}
	sort(ar,ar+n);
	if(s.size()>2){
		cout<<"No"<<endl;
	}else if(s.size()==2){
		if(ar[0]==ar[n-1]-1){
			int grupos = ar[0] + 1;
			if ( (grupos>cant[ar[0]]) && (grupos-cant[ar[0]])*2<=cant[ar[n-1]]) {
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(n>=2*ar[0] || ar[0]==n-1){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}




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


Measured memory_bytes: 5760
import sys
 
n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1 - r0
mn = min(r1, r0)
 
for i in map(int, sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
    if mn > i:
        mn = i
 
print(mx)

Measured memory_bytes: 23608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, d;
  cin >> n >> d;

  vector<vector<int>> v;
  for (int i = 0; i < n; i++)
  {
    vector<int> tmp;
    for (int j = 0; j < d; j++)
    {
      int x;
      cin >> x;

      tmp.push_back(x);
    }

    v.push_back(tmp);
  }

  int res = 0;
  for (int i = 0; i < n - 1; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      float dist = 0;
      for (int k = 0; k < d; k++)
      {
        dist += pow(v[i][k] - v[j][k], 2);
      }

      dist = sqrt(dist);
      if (dist == int(dist))
      {
        res++;
      }
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
/*
    _________             ____    __   __    __      __       __       __   __  
   |___   ___|           /  __)  |  | |  |  |  \    /  |     /  \     |  \ |  | 
       | |     __       (  {__   |  | |  |  |   \  /   |    / /\ \    |   \|  | 
       | |    /__\       \__  \  |  |_|  |  |    \/    |   / ____ \   |       | 
       | |                __)  ) {       }  |  |\__/|  |  / /    \ \  |  |\   | 
       |_|               (____/   \_____/   |__|    |__| /_/      \_\ |__| \__| 
*/
#include<bits/stdc++.h>
#define t_suman ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define pll pair<ll,ll>
#define VP vector< pll >
#define VLL vector< ll >
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rrep(i,a,b) for(int (i) = (a); (i) > (b); (i)--)
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
#define in insert
#define out erase
#define MOD 1000000007
#define MAX 1000005
using namespace std;


int main(void)
{
	t_suman;

	string s;
	cin>>s;
	bool flag=0;
	if(s.length()==6){
		if(s[2]==s[3]&&s[4]==s[5])flag=1;
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <cmath>
#include <stdio.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll A, B;
    cin >> A >> B;

    if( ( (A+B) % 2) == 0 ) cout << (A+B) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		int[] P = new int[N];
		Arrays.setAll(P, $ -> Integer.parseInt(sc.get()));

		Arrays.sort(P);

		int sum = 0;
		for (int i = 0; i < K; i++) {
			sum += P[i];
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 33676
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string day[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	for(int i=0;i<7;i++)
		if(day[i]==s)
		    cout<<(7-i);
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int n, c[10], f[100][10], p[100][11];
long long int max=-1000000000;
void check(int o){
  if(o==0) return;
  int i;
  long long int sum=0;
  for(i=0;i<n;i++) sum+=p[i][c[i]];
  if(max<sum) max=sum;
}

void func(int j, int o){
  if(j==10){check(o); return;}
  int i;
  for(i=0;i<n;i++) if(f[i][j]==1) c[i]++;
  func(j+1, o+1);
  for(i=0;i<n;i++) if(f[i][j]==1) c[i]--;
  func(j+1, o);
}

int main(void){
  int i, j;
  scanf("%d",&n);
  for(i=0;i<n;i++) for(j=0;j<10;j++) scanf("%d",&f[i][j]);
  for(i=0;i<n;i++) for(j=0;j<11;j++) scanf("%d",&p[i][j]);
  for(i=0;i<10;i++) c[i]=0;
  func(0, 0);
  printf("%lld\n",max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    set<string> st;
    string Sm;
    cin >> Sm;

    int len = (int)Sm.size();
    vector<ll> S(len + 1, 0);
    map<int, int> mp;
    mp[0]++;
    ll ct = 1;
    ll ans = 0;
    for (int i = 0; i <= len - 1; i++) {
        S[i + 1] = (S[i] + (Sm[len - i - 1] - '0') * ct) % 2019;
        ans += mp[S[i + 1]];
        mp[S[i + 1]]++;
        ct *= 10;
        ct %= 2019;
    }

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

Measured memory_bytes: 5156
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	bool seven = false;
	bool one = false;
	bool nine = false;
	bool four = false;
	int nums[4];

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

	for (int i = 0; i < 4; i++)
	{
		if (nums[i] == 1)
			one = true;
		else if (nums[i] == 7)
			seven = true;

		else if (nums[i] == 4)
			four = true;

		else if (nums[i] == 9)
			nine = true;

		
	}

	if (one && seven && four && nine)
		cout << "YES";
	else
		cout << "NO";
}

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

void Main() {
	string in;
	cin >> in;
	bitset<3> b(in);
	cout << b.count() << endl;
}

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


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

int main() {
  int N; cin >> N;
  vector<int> X1(N);
  vector<int> X2(N);
  
  for(int i = 0; i < N; ++i){
    cin >> X1.at(i);
    X2.at(i) = X1.at(i);
  }
  
  sort(X1.begin(), X1.end());
  int mf = X1.at(N/2-1);
  int ml = X1.at(N/2);
  
  for(int i = 0; i < N; ++i){
    if(X2.at(i) <= mf) cout << ml << endl;
    else cout << mf << endl;
  }
}

Measured memory_bytes: 3712
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		int[][] result = new int[100][2];
		int index = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			int m = stdIn.nextInt();
			while( m != 0 ){
				int[][] search = new int[m][2];
				for(int i = 0; i < m; i++){
					search[i][0] = stdIn.nextInt();
					search[i][1] = stdIn.nextInt();
				}
				int n = stdIn.nextInt();
				int[][] map = new int[n][2];
				for(int i = 0; i < n; i++){
					map[i][0] = stdIn.nextInt();
					map[i][1] = stdIn.nextInt();
				}
				int i = 0;
				int count = 0;
				for(; i < n; i++){
					for(int j = 1; j < m; j++){
						int x = map[i][0]-search[0][0]+search[j][0];
						int y = map[i][1]-search[0][1]+search[j][1];
						for(int k = 0; k < n; k++){
							if( x == map[k][0] && y == map[k][1] ){
								count++;
								break;
							}
						}
					}
					if( count == m-1 ){
						result[index][0] = map[i][0]-search[0][0];
						result[index][1] = map[i][1]-search[0][1];
						break;
					} else {
						count = 0;
					}
				}
				index++;
				m = stdIn.nextInt();
			}
			
			for(int j = 0; j < index; j++){
				System.out.println(result[j][0] + " " + result[j][1]);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int binary_search_p(int first_w, int last_w, int k, const vector<int>&w, int max_w)
{
	auto get_minimum_k = [&w](int p_candidate)
	{
		int result = 1, temp = 0;
		REPC(i, w)
		{
			if (temp + i <= p_candidate)temp += i;
			else
			{
				result++;
				temp = i;
			}
		}
		return result;
	};
	int p_candidate = first_w + (last_w - first_w) / 2;
	if (first_w <= last_w)return get_minimum_k(p_candidate) <= k ? binary_search_p(first_w, p_candidate - 1, k, w, max_w) : binary_search_p(p_candidate + 1, last_w, k, w, max_w);
	else for (int i = max(p_candidate, max_w);; i++)if (get_minimum_k(i) <= k)return i;
}
signed main()
{
	int n = in(), k = in();
	vector<int>w(n);
	int min_w = 10001, max_w = -1, sum_w = 0;
	REPC(&i, w)
	{
		i = in();
		if (min_w > i)min_w = i;
		if (max_w < i)max_w = i;
		sum_w += i;
	}
	cout << binary_search_p(min_w, sum_w, k, w, max_w) << endl;
}


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

using namespace std;

int N, R, T;
int Pace[100], CurPos[100], EmptyCup[1000], FullCup[1000];

void solve() {
	int sum;

	sum = 0;
	for (int t = 1; t <= T; ++t) {
		for (int id = 0; id < N; ++id) {
			CurPos[id] += Pace[id];
			CurPos[id] %= R;
			if (t!=1) {
				++EmptyCup[CurPos[id]];
			}
			if (FullCup[CurPos[id]] != 0) {
				--FullCup[CurPos[id]];
			}
			else {
				++sum;
			}
		}
		for (int id = 0; id < N; ++id) {
			FullCup[CurPos[id]] += EmptyCup[CurPos[id]];
			EmptyCup[CurPos[id]] = 0;
		}
	}

	cout << sum << endl;
}

int main() {

	cin >> N >> R >> T;
	for (int i = 0; i < N; ++i) {
		cin >> Pace[i];
	}
	memset(CurPos, 0, sizeof(CurPos));
	memset(EmptyCup, 0, sizeof(EmptyCup));
	memset(FullCup, 0, sizeof(FullCup));
	solve();

	return 0;
}



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

int main() {
 int a, b;
 char op;
 while(cin >> a >> op >> b, op != '?') {
 switch(op) {
   case '?':
    return 0;
   case '+':
    cout << a + b << endl;
    break;
   case '-':
    cout << a - b << endl;
    break;
   case '*':
    cout << a * b << endl;
    break;
   case '/':
    cout << a / b << endl;
    break;
 }
}

}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String p = sc.next();
        
        s += s;
        if(s.indexOf(p)!=-1){
        	System.out.println("Yes");
        }
        else{
        	System.out.println("No");
        }
    }
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        if(a + b >= c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 23380
#include <stdio.h>

int A[1000000], n;


int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1; 
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2116
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y;
}a[100010];
bool cmp(node a,node b){return max(a.x,a.y)<max(b.x,b.y);}
int n;
long long sum,s[100010];
inline int erfen(int pos)
{
	int l=1,r=n,p=0,d=max(a[pos].x,a[pos].y);
	while(l<=r)
	{
		int mid=l+r>>1;
		long long uf=s[mid];if(mid>=pos)uf-=d;
		if(uf<=sum)p=mid,l=mid+1;
		else r=mid-1;
	}return p;
}
inline long long gcd(long long x,long long y)
{
	if(x==0)return y;
	else return gcd(y%x,x);
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)a[i].x=read(),a[i].y=read();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		s[i]=s[i-1]+max(a[i].x,a[i].y);
		if(a[i].y>a[i].x)sum+=a[i].y-a[i].x;
	}
	long long ax=0,ay=1,x,y,ul;
	for(int i=1;i<=n;i++)
	{
		x=erfen(i);long long uf=sum-s[x];if(x>=i)x--,uf+=max(a[i].x,a[i].y);
		if(a[i].y>a[i].x)uf-=a[i].y-a[i].x;
		x=x*a[i].y+min(uf+a[i].y-a[i].x,1LL*a[i].y),y=1LL*n*a[i].y;ul=gcd(x,y);
		if(x<=0)continue;
		x/=ul,y/=ul;
		long long he=gcd(ay,y);
		if(1.0*ay/he*x>1.0*y/he*ax)ax=x,ay=y;
	}
	printf("%lld %lld\n",ax,ay);
	return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int fee1, fee2;
  fee1 = N *A;
  fee2 = B;
  if(fee1 <= fee2){
    cout << fee1 << endl;
  }else{
    cout << fee2 << endl;
  }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a, b; cin >> a >> b;
  cout << (a < 10 && b < 10 ? a * b : -1) << endl;
}

Measured memory_bytes: 896
def op(a:int, b:int): return max(a, b)#セグ木で使う関数
class Segtree():#親のノードを１とするスタート
    def __init__(self, n, segfunc=max, init=0):
        self.n  = n
        self.segfunc = segfunc
        self.init = init
        self.num = 1 << (self.n-1).bit_length() #最下層の数:2**n個
        self.tree = [self.init]*2*self.num #最も頂点の親ノードが1スタートなのでn個必要


    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:#^排他的論理和
            #tree[1]まで操作する
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k^1])
            k>>=1

    def query(self, l, r):#[l, r)の区間であることに注意
        if r<=l: return self.init
        l += self.num
        r += self.num
        res = self.init
        while(r>l):#rがlより大きい間
            if l&1:#ノードが右側なら評価
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r&1:#ノードが右側なら左側の値を入れる。
                r -= 1
                res = self.segfunc(res, self.tree[r])
            l = l//2
            r = r//2
        return res

n, k = map(int, input().split())
max_a = 3*10**5+7
st = Segtree(max_a)
for i in range(n):
    a = int(input())
    temp = st.query(max(0, a-k), min(a+k+1, max_a+1))+1
    st.update(a, temp)

print(st.tree[1])

Measured memory_bytes: 85660
def main():
    S = input()
    N = len(S)
    for i in range(1, N+1):
        t = S[:-i]
        if len(t) % 2 == 1:
            continue
        M = len(t)
        if t[:M//2] == t[M//2:]:
            return print(M)


if __name__ == '__main__':
    main()


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

int main(){
    int n,m,min,tmp;
    int coin[20],*list;
    int i,j;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)scanf("%d",&coin[i]);
    list = (int *)calloc(n+1,sizeof(int));
    list[0] = 0;
    for(j=1;j<=n;j++){
        min = j;
        for(i=0;i<m;i++){
            if(coin[i]<=j){
                tmp = list[j-coin[i]]+1;
                if(min>tmp)min = tmp;
            }
        }
        list[j] = min;
    }
    printf("%d\n",list[n]);
}

Measured memory_bytes: 1224
#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()

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

const int mod = 1e9 + 7;

signed main() {
  int n, tmp, ans = 0;
  std::cin >> n;
  tmp = n;
  while (tmp != 0) {
    ans += tmp % 10;
    tmp /= 10;
  }
  if (n % ans)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

ans = 0

(n - 1).times do |i|
  l = s.chars[0, i + 1]
  r = s.chars[i + 1, n - 1]
  i = (l & r).uniq

  ans = i.size if i.size >= ans
end

puts ans


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define LL long long
#define il inline
#define rg register
using namespace std;
int s, t, n, m;
il void chkmax(int &a, int b) {a = a > b ? a : b;}
il void chkmin(int &a, int b) {a = a < b ? a : b;}
il int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) {
		if(c == '-') f = -f;
		c = getchar();
	}
	while(isdigit(c)) {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * f;
}
il void write(int x) {
	char c[33] = {0}, tot = 0;
	if(x == 0) {puts("0"); return;}
	while(x) {c[++ tot] = x % 10 + '0'; x /= 10;}
	while(tot) {putchar(c[tot --]);}
	return ;
}
int a; 
int main() {
	a = read();
	cout << a + a * a + a * a * a;
	return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll dp[200015][5][2];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	dp[5][0][0] = dp[5][1][0] = dp[5][3][0] = dp[5][0][1] = dp[5][1][1] = dp[5][2][1] = dp[5][3][1] = -1000000000000000000;
	rep1(i, n) {
		int v; gi(v);
		int k = i+5;
		if(i % 2) {
			dp[k][0][0] = max(dp[k-1][0][0], dp[k-1][0][1]);
			dp[k][1][0] = max(dp[k-1][1][0], dp[k-1][1][1]);
			dp[k][2][0] = max(dp[k-1][2][0], dp[k-1][2][1]);
			dp[k][3][0] = max(dp[k-1][3][0], dp[k-1][3][1]);
			dp[k][0][1] = -1000000000000000000;
			dp[k][1][1] = dp[k-1][0][0] + v;
			dp[k][2][1] = dp[k-1][1][0] + v;
			dp[k][3][1] = dp[k-1][2][0] + v;
		} else {
			dp[k][0][0] = max(dp[k-1][1][0], dp[k-1][1][1]);
			dp[k][1][0] = max(dp[k-1][2][0], dp[k-1][2][1]);
			dp[k][2][0] = max(dp[k-1][3][0], dp[k-1][3][1]);
			dp[k][3][0] = -1000000000000000000;
			dp[k][0][1] = dp[k-1][0][0] + v;
			dp[k][1][1] = dp[k-1][1][0] + v;
			dp[k][2][1] = dp[k-1][2][0] + v;
			dp[k][3][1] = dp[k-1][3][0] + v;
		}
	}
	print(max(dp[n+5][2][0], dp[n+5][2][1]));
}


Measured memory_bytes: 21344
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	X, Y := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = scanInt()
		Y[i] = X[i]
	}
	sort.Ints(Y)

	for _, x := range X {
		if x >= Y[N/2] {
			fmt.Println(Y[N/2-1])
		} else {
			fmt.Println(Y[N/2])
		}
	}
}


Measured memory_bytes: 9224
<?php
fscanf(STDIN, "%d %d",$n,$m);
$magic=pow(10,9)+7;

$result=1;
for ($i=1; $i <= $n; $i++)
{ 
	$result*=$i;
	$result%=$magic;
}
for ($i=1; $i <= $m; $i++)
{ 
	$result*=$i;
	$result%=$magic;
}

if(abs($n-$m)>=2)
	printf("0");
elseif(abs($n-$m)==1)
	printf("%d",$result);
else
{
	$result*=2;
	$result%=$magic;
	printf("%d",$result);
}

Measured memory_bytes: 4604
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  cout << S[0] << S.size()-2 << S[S.size()-1] << endl;
}


Measured memory_bytes: 256