akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

const long long INF = 1LL << 60;

struct Node {
    explicit Node(int idx, int pos, long long cost) : idx(idx), pos(pos), cost(cost) {}
    int idx, pos;
    long long cost;
    bool operator > (const Node& nd) const { return cost > nd.cost; }
};

int main(){
    int N; cin >> N;
    vector<string> S(2*N);
    vector<long long> C(2*N);
    for(int i=0;i<N;i++){
        cin >> S[2*i];
        S[2*i+1] = S[2*i];
        reverse(S[2*i+1].begin(), S[2*i+1].end());
        cin >> C[2*i];
        C[2*i+1] = C[2*i];
    }
    vector dist(2*N, vector(21, INF));
    priority_queue<Node, vector<Node>, greater<Node>> qu;
    for(int i=0;i<2*N;i++){
        qu.emplace(i, 0, C[i]);
        dist[i][0] = C[i];
    }
    long long res = INF;
    while(!qu.empty()){
        Node nd = qu.top(); qu.pop();
        const string& s = S[nd.idx];
        bool end = true;
        for(int i=0;i+nd.pos<s.size()-i-1;i++){
            if(s[i+nd.pos] != s[s.size()-i-1]) end = false;
        }
        if(end){
            res = min(res, nd.cost);
        }
        for(int i=1-nd.idx%2;i<2*N;i+=2){
            int l = min<int>(s.size() - nd.pos, S[i].size());
            bool ok = true;
            for(int j=0;j<l;j++){
                if(s[nd.pos+j] != S[i][j]) ok = false;
            }
            if(!ok) continue;
            int nidx = (nd.pos + l == s.size() ? i : nd.idx);
            int npos = (nd.pos + l == s.size() ? l : nd.pos + l);
            long long ncost = dist[nd.idx][nd.pos] + C[i];
            if(ncost < dist[nidx][npos]){
                dist[nidx][npos] = ncost;
                qu.emplace(nidx, npos, ncost);
            }
        }
    }
    cout << (res < INF ? res : -1) << endl;
}

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

int main()
{
	string x;
	int i, sum;

	while (1)
	{
		sum = 0;
		cin >> x;
		if (x == "0")
		{
			break;
		}
		for (i = 0; i < (int)x.size(); i++)
		{
			sum += (int)x[i] - '0';
		}
		cout << sum << endl;
	}

}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define pll pair<ll, ll>
#define M (1ll << 60)
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 300;
const int mod = 1000000007;
int Q, k, s[N];
ll X, Y, ans, f[N];
pair<ll, ll> p[N][N];
void prework() {
	f[0] = 1, f[1] = 1, f[2] = 2, f[3] = 3;
	p[1][1] = pll(1, 2);
	p[1][2] = pll(1, 3);
	s[1] = 2;
	k = 1;
	while (f[k + 1] <= M) {
		k ++;
		f[k + 2] = f[k] + f[k + 1];
		Rep(i, 1, s[k - 1]) {
			ll x = p[k - 1][i].fr, y = p[k - 1][i].sd;
			for (x += y; x <= f[k + 2]; x += y) {
				p[k][++ s[k]] = pll(y, x);
			}
		}
		// cout << s[k]<<endl;
	}
}
void calc(ll x, ll y) {
	if (x <= X && y <= Y && x * 2 > y) (ans += (Y - y) / x + 1) %= mod;
}
int main()
{
	prework();
	scanf ("%d", &Q);
	while(Q --) {
		scanf ("%lld%lld", &X, &Y);
		if (X > Y) swap(X, Y);
		int i = k;
		while (i && p[i][1].fr > X || p[i][1].sd > Y) i --;
		if (!i) i ++;
		if (i == 1) {
			printf("%d %lld\n", i, X % mod * Y % mod);
			continue ;
		}
		ans = 0;
		Rep(j, 1, s[i]) {
			ll x = p[i][j].fr, y = p[i][j].sd;
			calc(x, y);
			calc(y, x);
		}
		printf("%d %lld\n", i, ans);
	}

	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    ll mx1 = 0, mx2 = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] >= mx1) {
            mx2 = mx1;
            mx1 = A[i];
        }
        else if (A[i] > mx2) {
            mx2 = A[i];
        }
    }

    for (ll i = 0; i < N; i++) {
        if (mx1 == A[i]) {
            cout << mx2 << "\n";
        }
        else {
            cout << mx1 << "\n";
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

using ll = long long;

long long rc(long long, int);

int main()
{
    int n;
    long long x;
    scanf("%d%lld", &n, &x);
    printf("%lld\n", rc(x, n));

    return 0;
}

// levelN
long long rc(long long x, int n)
{
    if (n == 1)
    {
        if (x == 5) return 3;
        else return x - 1;
    }
    long long burger_n{((ll)1 << (n + 2)) - 3}, burger_minus{((ll)1 << (n + 1)) - 3};
    long long ban_n{(((ll)1 << (n + 1)) - 1)}, ban_minus{((ll)1 << n) - 1};
    if (x == burger_n) return ban_n;
    if (x > burger_minus + 2) return ban_minus + 1 + rc(x - (burger_minus + 2), n - 1);
    if (x == burger_minus + 2) return ban_minus + 1;
    if (x > 1) return rc(x - 1, n - 1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[200010];
int main(){
	int n,k;
	cin>>k>>n;
	int mx=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i!=0){
			mx=max(mx,a[i]-a[i-1]);
		}
	}
	mx=max(mx,a[0]+k-a[n-1]);
	cout<<k-mx<<endl;
	return 0;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
    n = int(input())
    d = {}
    for i in range(n):
        s,p = input().split()
        p = int(p)
        if( s not in d ):
            d[s] = []
        temp = d[s]
        temp.append([p,i])
    
    k = d.keys()
    k = sorted(k)
    for i in k:
        d[i].sort(key=lambda x: -x[0])
        for j in d[i]:
            print(j[1] + 1)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,T;
     cin >> N >> T;
     int ans = 1001;
     for(int i = 0; i < N; i++){
          int c,t; cin >> c >> t;
          if(t <= T){
               ans = min(ans,c);
          }
     }

     if(ans == 1001) cout << "TLE" << endl;
     else cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = map(int, input().split())
A = sorted(A) # ascending

B_C = []
for _ in range(M):
    b, c = map(int, input().split())
    B_C.append((b, c))
B_C = sorted(B_C, key=lambda x: x[1], reverse=True)

cur_a_ix = 0
ans = 0

for b, c in B_C:
    while b and cur_a_ix < len(A):
        if A[cur_a_ix] < c:
            ans += c
        else:
            break
        b -= 1
        cur_a_ix += 1
ans += sum(A[cur_a_ix:])
print(ans)
    


Measured memory_bytes: 23276
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(ALL(a));

  vector<ll> b(n, 0);
  int base = n / 2;
  b[base] = a[0];
  for (int i = 1; i <= n / 2; i++) {
    if (i%2 == 0) {
      b[base - i] = a[i-1];
      if (base +i >= n) break;
      b[base + i] = a[i];
    } else {
      b[base - i] = a[n-i];
      if (base +i >= n) break;
      b[base + i] = a[n-i-1];
    }
  }
/*
  rep(i, n) {
    cerr << b[i] << " ";
  }
  cerr << endl;
*/
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += abs(b[i] - b[i-1]);
  }

  // 逆から
  b[base] = a[n-1];
  for (int i = 1; i <= n / 2; i++) {
    if (i%2 == 0) {
      b[base - i] = a[n-i];
      if (base +i >= n) break;
      b[base + i] = a[n-i-1];
    } else {
      b[base - i] = a[i-1];
      if (base +i >= n) break;
      b[base + i] = a[i];
    }
  }
/*
  rep(i, n) {
    cerr << b[i] << " ";
  }
  cerr << endl;
*/
  ll ans2 = 0;
  for (int i = 1; i < n; i++) {
    ans2 += abs(b[i] - b[i-1]);
  }

  cout << max(ans, ans2) << endl;

  return 0;
}


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

int main() {
  
  string N;
  cin >> N;
  
  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x, y, s;
    while (cin >> x >> y >> s && x){
        int ans = 0;
        FOR(i,1,s-1) FOR(j,1,s-1){
            int t = i*(100+x)/100 + j*(100+x)/100;
            if (t != s) continue;
            ans = max(ans, i*(100+y)/100 + j*(100+y)/100);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3004
H, W = gets.to_s.split.map{|t|t.to_i}

# p '.'.ord #=> 46
# p '#'.ord #=> 35
S = Array.new(H){ gets.to_s.chomp.bytes } 

def bfs(sx, sy)
  
  dx = [1, 0, -1, 0]
  dy = [0, 1, 0, -1]
  
  q = [[sx,sy,1]]
  
  used = Array.new(H){ Array.new(W+1){ false } }
  while q.any?
    q.uniq!
    x, y, d = q.shift
    used[x][y] = true
    d += 1
    4.times do |i|
      nx = x + dx[i]
      ny = y + dy[i]
      return d if nx == H - 1 && ny == W - 1
      if 0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] == 46 && !used[nx][ny]
        q.push( [nx, ny, d] )
      end
    end
  end
  
  puts -1
  exit
end

p S.flatten.count(46) - bfs(0,0)


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[22];
ll work(int l,int r,ll xl,ll xr){
	if (l>r) return 0;
	ll ans=1e18;
	for (int x=l;x<=r;x++)ans=min(ans,work(l,x-1,xl,xl+xr)+work(x+1,r,xl+xr,xr)+a[x]*(xl+xr));
	return ans;
}
int main(){
	cin>>n;
	for (int i=0;i<n;i++)cin>>a[i];
	cout<<a[0]+a[n-1]+work(1,n-2,1,1);
	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

vll f(ll n) {
	vll res;

	for (ll i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		
		ll cnt = 0;
		while (n % i == 0) cnt++, n /= i;
		res.push_back({ i, cnt });
	}

	if (n != 1) res.push_back({ n, 1 });

	return res;
}

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

	ll ans = 0;
	auto fac = f(n);

	for (auto p : fac) {
		ll e = p.second;
		ll tmp = 0, cur = 1;
		while (e >= cur) e -= cur++, tmp++;
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int p[4000][4000];
int main(void){
    int n,k,ans=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a,b;
        char c;
        cin>>a>>b>>c;
        if(c=='W'){
            a+=k;
            a%=2*k,b%=2*k;
        }
        else a%=2*k,b%=2*k;
        p[a][b]++;p[a+k*2][b]++;p[a][b+k*2]++;p[a+2*k][b+2*k]++;
    }
    for(int i=0;i<4000;i++){
        for(int j=1;j<4000;j++){
            p[i][j]+=p[i][j-1];
        }
    }
    for(int i=1;i<4000;i++){
        for(int j=0;j<4000;j++){
            p[i][j]+=p[i-1][j];
        }
    }
    /*
    for(int i=0;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            cout<<p[i][j];
        }
        cout<<endl;
    }
    */
    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k;j++){
            int p1=p[i][j]+p[i+k][j+k]-p[i+k][j]-p[i][j+k];
            int p2=p[i+k][j+k]+p[i+2*k][j+2*k]-p[i+2*k][j+k]-p[i+k][j+2*k];
            ans=max(ans,p1+p2);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 62720
s = input()
t = input()
len_s, len_t = len(s), len(t)
dp = [[0] * (len_t + 1) for _ in range(len_s + 1)]
for index_s in range(len_s):
  char_s = s[index_s]
  dp_s = dp[index_s]
  dp_ss = dp[index_s + 1]
  for index_t in range(len_t):
    if char_s == t[index_t]:
      dp_ss[index_t + 1] = dp_s[index_t] + 1
    else:
      dp_ss[index_t + 1] = max(dp_s[index_t + 1], dp_ss[index_t])
index_s, index_t = len_s - 1, len_t - 1
lcs_reverse = []
len_lcs = dp_ss[-1]
while len_lcs > 0:
  if s[index_s] == t[index_t]:
    lcs_reverse.append(s[index_s])
    index_s -= 1
    index_t -= 1
    len_lcs -= 1
  elif dp[index_s][index_t + 1] == len_lcs:
    index_s -= 1
  else:
    index_t -= 1
print(''.join(lcs_reverse[::-1]))

Measured memory_bytes: 112092
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int s = Integer.parseInt(st.nextToken());
    int w = Integer.parseInt(st.nextToken());
    if(s>w)
    	System.out.println("safe");
    else
    	System.out.println("unsafe");
    	}
    	}
    

Measured memory_bytes: 32604
from collections import Counter
N,M=map(int,input().split())
A=list(map(int,input().split()))

B=[0]*(N+1)
for i in range(1,N+1):
  B[i]=(B[i-1]+A[i-1])%M
  
B=Counter(B).values()
ans=0
for b in B:
  ans+=b*(b-1)//2
  
print(ans)

Measured memory_bytes: 16548
//file_name:ABC58_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int a[256];
    rep(i,256){
        a[i] = 999;
    }
    rep(i,n){
        string s;
        cin >> s;
        int temp[256] = {};
        rep(j,s.size()){
            temp[(int)s[j]]++;
        }
        rep(j,256){
            a[j] = min(a[j],temp[j]);
        }
    }

    rep(i,256){
        rep(j,a[i]){
            cout << (char)i;
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=[int(i) for i in input().split()]
q=[int(j) for j in input().split()]
r=[int(k) for k in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
s=p+q+r
s.sort(reverse=True)
s=s[:x+y]
print(sum(s))

Measured memory_bytes: 23644
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(n-2):
  dp[i+2] = min( (dp[i] + abs(h[i]-h[i+2])), (dp[i+1] + abs(h[i+1]-h[i+2])) )
print(dp[n-1])

Measured memory_bytes: 13980
import java.util.*;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mochiCount = sc.nextInt();
        Set<Integer> mochiSet = new HashSet<>();
        for (int i = 0; i < mochiCount; i++) {
            mochiSet.add(sc.nextInt());
        }
        
        int result = mochiSet.size();
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		a, b int
		s    string
	)
	fmt.Scan(&a, &b, &s)

	l := strings.Split(s, "-")
	if len(l[0]) == a && len(l[1]) == b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include<string>

using namespace std;

int main()
{
  int n;
  int x;
  int i;
  int j;
  int k;
  int count=0;
  
  while(1)
  {
    cin >> n >>x;
    
    if(n==0 && x==0)
      break;
    for(i=1;i<=n;i++)
    {
      for(j=i+1;j<=n;j++)
      {
        for(k=j+1;k<=n;k++)
        {
          if(i+j+k==x)
            count++;
        }
      }
    }
  cout << count <<"\n";
  count=0;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int gcd(int a, int b) {
  if(a<b) swap(a,b);
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  int mi = INF,ma = -INF;
  rep(i,N) {
    cin >> A[i];
    mi = min(mi,A[i]);
    ma = max(ma,A[i]);
  }
  rep(i,N) {
    if(A[i] == K) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  int g = A[0];
  rep(i,N) {
    g = gcd(g,A[i]);
  }
  if(ma < K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  if(K%g != 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << "POSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = 0;

    if(h == 1){
        ans = 1;
    }else if(w == 1){
        ans = 1;
    }else{
        ans += (h / 2) * w;
        if(h % 2 == 1){
            ans += (w + 1) / 2;
        }
    }

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


Measured memory_bytes: 256
def main():

    n = int(input())

    if n ==1:
        print(0)
        return
    if n ==2:
        print(2)
        return
    m = (10 ** 9) + 7
    ans = (10 ** n) % m
    ans -= (8**n) %m
    ans -= ((9**n-8**n)*2)%m
    print(ans%m)
if __name__=='__main__':
    main()


Measured memory_bytes: 10876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=1e7;

ll a[200005],b[200005];

int main()
{
  ll n, m, k, i, j, ans=0, p, mx=0, r, x;

  cin>>n>>m>>k;

  for(i=1; i<=n; i++)
  {
    cin>>x;
    a[i]=a[i-1]+x;
  }

  for(i=1; i<=m; i++)
  {
    cin>>x;
    b[i]=b[i-1]+x;
  }

  for(i=0; i<=n; i++)
  {
   // cout<<a[i]<<" ";
    r=k-a[i];
    //cout<<r<<endl;

    if(r>=0)
    {
        ll low=0,high=m, mid, ans=0;

        while(low<=high)
        {
            mid=(low+high)/2;
            if(b[mid]<=r)
            {
                low=mid+1;
                ans=mid;
            }
            else
                high=mid-1;
        }
        mx=max(i+ans,mx);
    }
  }
  cout<<mx<<endl;

}

Measured memory_bytes: 6748
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>

int main(void) {

  char s[20];
  int i = 0;

  scanf("%s", s);

  if (strlen(s)<3) {
    printf("error\n");
    return -1;
  }
  while (i<strlen(s)) {
    if (islower(s[i])==0) {
      printf("error\n");
      return -1;
    }
    i++;
  }

  printf("%c%c%c\n", s[0], s[1], s[2]);
  return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  map<string, set<P>> mp;
  rep(i, n) {
    string s;
    int p;
    cin >> s >> p;
    mp[s].insert(P(p, i+1));
  }
  for(auto x : mp) {
    for(auto it = x.second.rbegin(); it != x.second.rend(); ++it) cout << it->second << endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n && n!=0){
		vi d(n);
		rep(i,0,n) cin>>d[i];

		bool f[100000];
		memset(f,0,sizeof(f));

		rep(i,0,n){
			f[i]=d[i];
			if(i%2 && f[i-1]!=d[i]){
				repb(j,i-1,0){
					if(f[j]==d[i]) break;
					f[j]=d[i];
				}
			}
		}

		int ans=0;
		rep(i,0,n) if(!f[i]) ans++;
		o(ans);
	}
}

Measured memory_bytes: 2060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]
ll check[1000];

int main(){
    ll n, k;
    ll d;
    ll a;
    ll ans = 0;

    scanf("%lld%lld", &n, &k);

    for (int i = 0; i < k; i++)
    {
        scanf("%lld", &d);
        for (int j = 0; j < d; j++)
        {
            scanf("%lld", &a);
            check[a]++;
        }
    }
    
    for (int i = 1; i <= n; i++)
    {
        if(check[i] == 0) ans++;
    }
    
    
    
    printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const ll inf = 2e9 + 7;

ll n, W, v[maxn], w[maxn], dp[110][100010], ans;

ll max(ll x, ll y)
{
	return x > y ? x : y;
}

ll read()
{
	ll x;
	scanf("%lld", &x);
	return x;
}

int main()
{
	n = read(), W = read();
	for(int i = 0; i <= 1e5 + 10; i ++)
	{
		dp[0][i] = inf;
	}
	dp[0][0] = 0;
	for(int i = 0; i < n; i ++)
	{
		w[i] = read(), v[i] = read();
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j <= 1e5; j ++)
		{
			if(j < v[i])dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}
	for(int i = 0; i <= 1e5; i ++)
	{
		 
//		printf("i:%d dp[%d][%d] = %d \n ", i,  n, i, dp[n][i]);
		if(dp[n][i] <= W)ans = i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 82304
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    int N, K; cin >> N >> K;
    cout << N - K + 1 << endl;
}



Measured memory_bytes: 888
n=int(input())
s=input()
e=[int("E"==i) for i in s]
for i in range(1,n):
  e[i]+=e[i-1]

  
ans=[]
for j in range(n):
  left=j-0
  right=n-j-1
  
# leftにWは何個？
# leftのEは、
  if j-1>=0:
    etmp=e[j-1]
  else:
    etmp=0
  leftw=left-etmp
# rightにEは何個？
# rightのEは、
  eee=e[n-1]-e[j]
  ans+=(leftw+eee),
print(min(ans))


Measured memory_bytes: 33140
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])

  let zorome = 0
  for (let i = 0; i < N; i++) {
    const [one, two] = input[i + 1].split(' ').map(x => parseInt(x))
    if (one === two) {
      zorome++
    }
    if (zorome === 3) {
      console.log('Yes')
      return
    }
    if (zorome > 0 && one !== two) {
      zorome = 0
    }
  }
  console.log('No')

}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29700
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, p;
int main() {
    cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 1001

int getLCS(char*,char*);
int Z[N][N];

int main(){
  char X[N],Y[N];
  int q,i;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s%s",X,Y);
    printf("%d\n", getLCS(X,Y));
  }
  return 0;
}

int getLCS(char *x,char *y){
  int i,j,a,b;
  a = strlen(x);
  b = strlen(y);

  for(i=0;i<a;i++){
    for(j=0;j<b;j++){
      if(x[i]==y[j])  Z[i+1][j+1] = Z[i][j]+1;
      else Z[i+1][j+1] = ((Z[i][j+1] > Z[i+1][j]) ? Z[i][j+1]:Z[i+1][j]);
    }
  }
  return Z[a][b];
}

Measured memory_bytes: 4520
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a-b>c) {
        System.out.println("0");
        }
        else {
        System.out.println(c-(a-b));

        }
    }
}

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

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    ll ans = A[0];
    rep(i, N) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
const int INF=1000000000;
int z(int a){
	if(a<0)a=-a;
	return a;
}

int main(){
while(1){
	int n,m,k[153],x[153][10],d[153][10],dp[153][10][77],ans=INF;
	scanf("%d%d",&n,&m);
if(n==0&&m==0)break;
	for(int i=1;i<=n;i++){
		scanf("%d",&k[i]);
		for(int j=0;j<k[i];j++){
			scanf("%d%d",&x[i][j],&d[i][j]);
		}
	}
	k[n+1]=0; k[n+2]=0;
	for(int i=0;i<153;i++)for(int j=0;j<10;j++)for(int h=0;h<77;h++)dp[i][j][h]=INF;
	for(int j=0;j<10;j++)dp[1][j][0]=0;
	for(int j=0;j<10;j++)dp[2][j][1]=0;
	for(int i=1;i<=n;i++)for(int j=0;j<k[i];j++)for(int h=0;h<=m;h++){
		for(int g=0;g<k[i+1];g++){
			int c=dp[i][j][h]+z(x[i][j]-x[i+1][g])*(d[i][j]+d[i+1][g]);
			if(c<dp[i+1][g][h])dp[i+1][g][h]=c;
		}
		for(int g=0;g<k[i+2];g++){
			int c=dp[i][j][h]+z(x[i][j]-x[i+2][g])*(d[i][j]+d[i+2][g]);
			if(c<dp[i+2][g][h+1])dp[i+2][g][h+1]=c;
		}
		if(i==n&&dp[i][j][h]<ans)ans=dp[i][j][h];
		if(i==n-1&&h<=m-1&&dp[i][j][h]<ans)ans=dp[i][j][h];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1656
n = int(input())
a = []
for _ in range(n):
    b = list(map(int, input().split()))
    a.append(b)

dp = [[0]*3 for _ in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            else:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k])

ans = 0
for i in range(3):
    ans = max(ans, dp[n][i])
print(ans)


Measured memory_bytes: 74328
#include<stdio.h>
int main()
{
  int a,b,c;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')
      break;
    else if(op=='+')
      c=a+b;
    else if(op=='/')
      c=a/b;
    else if(op=='*')
      c=a*b;
    else if(op=='-')
      c=a-b;
    printf("%d\n",c);
  }
   return 0;
 }

Measured memory_bytes: 1028
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int len;
    cin >> len;
    cin.get();

    string str;
    getline(cin, str);

    auto res = 0;
    auto val = 0;

    for (const auto &ch : str) {
        val += (ch == 'I' ? 1 : -1);
        res = max(res, val);
    }

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


Measured memory_bytes: 256
///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
using namespace std;
typedef bool                   boo;
typedef int                    li;
typedef long                   il;
typedef unsigned long          ul;
typedef long long int          ll;
typedef unsigned long long     ull;
typedef double                 dd;
typedef string                 str;
#define vli                    vector<li>
#define vll                    vector<ll>
#define sli                    set<li>
#define sll                    set<ll>
#define pli                    pair<li>
#define pll                    pair<ll>
#define vpi                    vector<pair<li, li>>
#define vpl                    vector<pair<ll, ll>>
#define mpl                    map<ll, ll>
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];
#define lp(a, i, b)            for(ll i=a; i<b; i++)
#define rlp(a, i, b)           for(ll i=a; i>=b; i--)
#define sz(x)                  x.size()
#define len(z)                 z.begin(), z.end()
#define co(x)                  cout<<x nl
#define mem(z, l)              memset(z, l, sizeof(z))
#define MP                     make_pair
#define pb                     push_back
#define F                      first
#define S                      second
#define nl                     <<endl
#define nll                    cout<<endl
#define sp                     <<" "<<
#define sl                     <<" "
#define cy                     cout<<"YES"
#define cn                     cout<<"NO"
#define rn                     return
#define good_bye               return 0
#define PI                     3.1415926536
#define gcd(a,b)               __gcd(a,b)
#define lcm(a,b)               (a*(b/gcd(a,b)))
#define faster                 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define input_txt()            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double eps=              1e-9;
const int inf=                 2000000000;
const ll infLL=                9000000000000000000;
//ll Pow(ll P, ll Q)           { ll R=1; for(ll I=1; I<=Q; I++) R*=P; rn R; }
//void dfs(ll K)               { vis[K]=true; for(auto J: v[K]) { if(!vis[J]) dfs(J); } }
//void seive(ll MX)            { S.pb(2); for(ll I=3; i<=MX; i+=2) { if(!vis[I]) { S.pb(I); for(ll J=I*I; j<=MX; J+=(2*I)) vis[J]=false; } } }
//bool isPrime(ll n)           { if(n%2==0) rn false; for(ll i=3; i*i<=n; i+=2) { if(n%i==0) rn false; } rn true; }
//----------------------------------------LET'S BEGIN-----------------------------------------------------------------------
const int mX = 2e5+123;
ll n, a[mX], dp[mX], s;

ll soln(ll m)
{
    if(dp[m]!=-1) rn dp[m];
    if(m==n) rn 0;
    s = abs(a[m]-a[m+1]) + soln(m+1);

    if(m+1==n) rn dp[m] = s + soln(m+1);
    else rn dp[m] = min(s, abs(a[m]-a[m+2]) + soln(m+2));
}

void case_i()
{
    cin>>n;
    lp(1, i, n+1) cin>>a[i];
    mem(dp, -1);
    cout<<soln(1) nl;
}

int main()
{
    faster;
//    input_txt();
//    wt
      case_i();
    good_bye;
}
///           _5_4_8_8_1_9_                ///



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


int main(){
    int x,y;
    int c = 2;
    int t = 4;
    cin >> x>>y;
    rep(i,x+1){
        int j = x-i;
        if(i*c+j*t==y){ 
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#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 N;
   cin >> N;
   string b = "No";
   rep(i,26){
     rep(j,15){
       if( N == i*4 + j*7){
         b = "Yes";
         break;
       }
     }
   }
   cout << b << endl;
   return 0;
}


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

ll solve(vector<ll> v,ll k)
{
  ll n=v.size();
  ll ans[n];
  ans[0]=0;
  ans[1]=abs(v[1]-v[0]);
  for(ll i=2;i<n;i++)
  {
    ll min_ans=INT_MAX;
   for(ll j=0;j<k;j++)
   {
     if((i-j-1)>=0)
     {
      	ll x=abs(v[i]-v[i-j-1])+ans[i-j-1];
     	if(x<min_ans)
     	{
      		min_ans=x; 
     	} 
     }
     else
     {
       break;
     }
   }
    ans[i]=min_ans;
  }
  return ans[n-1];
}

int main()
{
 ll n,k;
  cin>>n>>k;
  vector<ll> v;
  for(ll i=0;i<n;i++)
  {
   ll x;
    cin>>x;
    v.push_back(x);
  }
  cout<<solve(v,k)<<endl;
}

Measured memory_bytes: 5536
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;
P Q[LEN];
int head=0, tail, n;
void enqueue(P x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  tail++;
  if(tail == LEN){
    tail = 0;
  }
}
int main(){
  int elaps = 0;
  int i, q;
  scanf("%d %d", &n, &q);
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = n;
  while(tail!=head){
    if(Q[head].t > q){
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
    }
    else{
      elaps+=Q[head].t;
      printf("%s %d\n",Q[head].name,elaps);
    }
    head++;
    if(head == LEN){
      head = 0;
    }
  }
  return 0;
}

Measured memory_bytes: 10768
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;

int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> value;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		value.push_back(temp);
	}
	ll sum_value =accumulate(value.begin(),value.end(),0LL);
	ll ans=0;
	for(ll l=0;l<=min(k,n);l++){
		for(ll r=0;r<=min(k-l,n-l);r++){
			int64_t last_value=0;
			for(ll i1=l;i1<n-r;i1++){
				last_value += value[i1];
			}
			vector<ll> pickup;
			for(ll i1=0;i1<l;i1++){
				pickup.push_back(value[i1]);
			}
			for(ll i1=n-r;i1<n;i1++){
				pickup.push_back(value[i1]);
			}
			sort(pickup.begin(),pickup.end());
			for(ll i1=0;i1<min(k-l-r,(ll)pickup.size());i1++){
				if(pickup[i1]<0){
					last_value+=pickup[i1];
				}
			}
			if(sum_value-last_value > ans){
				ans=sum_value-last_value;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
const main = (input) => {
  const [a, b, c] = input.trim().split(" ");
  const A = a.slice(0, 1).toUpperCase();
  const B = b.slice(0, 1).toUpperCase();
  const C = c.slice(0, 1).toUpperCase();
  return A + B + C;
};
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long num,solve;
    while(cin>>num)
    {
        int count=0;
        solve=100;
        while(num>solve)
        {
            solve=solve+(solve/100);
            count++;
        }
        cout<<count<<endl;
        break;
    }
}


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

using namespace std;

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

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

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

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

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

const int maxn = 1e5+5;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A));
        int ans = 0;
        for (int i = 0; i < n; i++) {
            while (i+1 < n && A[i] == A[i+1])
                i++;
            const int a = i+1;
            const int b = n-(i+1);
            if (a == b) {
                ans += A[i+1]-A[i];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  int M = max(x,y);
  int m = min(x,y);
  if (m==0){
    return M;
  }else{
    return gcd(m,M%m);
  }
}
      
int main() {
  int N,X;
  cin >> N >> X;
  int ans = 0;
  int a;
  for (int i = 0;i< N;i++){
    cin >> a;
    if(a >X){
      ans = gcd(ans,a-X);
    }else{
      ans = gcd(ans,X-a);
    }
  }
  cout << ans << endl;
}
      
      
    

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    printf ("%d\n", N*N*N );

    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

struct node {
  int l, r;
  node() {}
  node(int ll, int rr) : l(ll), r(rr) {}
  bool operator <(const node& o) const {
    return r == o.r ? l > o.l : r < o.r;
  }
} a[1000000];

int n, m;

int main() {
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    if(x > y) swap(x, y);
    a[i] = node(x, y);
  }
  sort(a + 1, a + m + 1);
  int need = 1, r = a[1].r;
  for(int i = 2; i <= m; i++) {
    if(a[i].l >= r) {
      need++;
      r = a[i].r;
    }
  }
  printf("%d\n", need);
  return 0;
}


Measured memory_bytes: 1024