akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
keys = [None] * M
for i in range(M):
  cost,b = map(int,readline().split())
  bit = 0
  target = list(map(int,readline().split()))
  for t in target:
    bit += (1 << (t - 1))
  keys[i] = (cost, bit)
    
# 全ての鍵の組み合わせでDP
INF = 10 ** 8 + 1
dp = [INF for i in range(2 ** N)]
dp[0] = 0
for key in keys:
  cost, bit = key
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == -1:
      continue
    if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1])

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

int main(){
  int n;
  cin >> n;
  char c;
  bool yellow = false;
  
  rep(i,n){
    cin >> c;
    if(c=='Y') yellow=true;
  }
  
  if(yellow) cout << "Four" << endl;
  else cout << "Three" << endl;  
  
  return 0;
}

Measured memory_bytes: 256
mod=10**9+7
s=input()
n=len(s)
R=[[[0]*13 for _ in range(10)] for __ in range(13)]
for i in range(13):
  for j in range(10):
    for k in range(13):
      R[i][j][k]=(k-i*j)%13

P=[0]*(n+1)
P[0]=1
for i in range(n):
  P[i+1]=(P[i]*10)%13

DP=[[0]*13 for _ in range(n+1)]
DP[0][0]=1
for i in range(n):
  r=P[n-1-i]
  if s[i]=="?":
    for k in range(13):
      DP[i+1][k]=sum(DP[i][R[r][j][k]] for j in range(10))
      DP[i+1][k]%=mod
  else:
    for k in range(13):
      DP[i+1][k]=DP[i][R[r][int(s[i])][k]]
      DP[i+1][k]%=mod
print(DP[n][5]%mod)

Measured memory_bytes: 63580
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll dis = abs(a-b), e = v-w;
    if(e <= 0)cout << "NO" << endl;
    else if((dis+e-1)/e <= t)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3636
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;
void main()
{
    immutable buf = readln.chomp.split.to!(size_t[]);
    bool[][] chocolate;
    foreach (i; 0..buf[0])
        chocolate ~= readln.chomp.map!(_=>_=='1').array;
    auto ps = chocolate.partialSum;
    auto answer = ulong.max;
    foreach (p; 0..1<<(chocolate.length - 1))
        answer = answer.min(solve(ps, p.toUpperLower(buf[0]), buf[2]));
    answer.writeln;
}

size_t[][] partialSum(in bool[][] chocolate)
{
    auto ret = new size_t[][](chocolate.length + 1, chocolate[0].length + 1);
    foreach (i, row; chocolate)
        foreach (j, e; row)
            ret[i+1][j+1] += ret[i][j+1] + ret[i+1][j] + chocolate[i][j] - ret[i][j];
    return ret;
}
size_t rectSum(in size_t[][] ps, size_t lower, size_t upper, size_t left, size_t right)
{
    return ps[upper][right] + ps[lower][left] - ps[upper][left] - ps[lower][right];
}

size_t[] toUpperLower(size_t p, size_t h)
{
    auto ret = [size_t(0)];
    foreach (i; 1..h)
    {
        if (p & 1) ret ~= i;
        p >>= 1;
    }
    return ret ~ h;
}

ulong solve(in size_t[][] ps, size_t[] pattern, size_t k)
{
    stderr.writefln("pattern: %(%d..%)", pattern);
    size_t left;
    int cut;
    foreach (right; 1..ps[0].length)
    {
        if (ps.ng(pattern, left, right, k))
        {
            if (left == right - 1)
                return int.max;
            cut += 1;
            stderr.writefln("cut: %d..%d", left, right-1);
            left = right - 1;
        }
    }
    return cut + pattern.length - 2;
}

bool ng(in size_t[][] ps, size_t[] pattern, size_t left, size_t right, size_t k)
{
    foreach (i; 0..pattern.length-1)
        if (k < ps.rectSum(pattern[i], pattern[i+1], left, right))
            return true;
    return false;
}


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define MOD 1000000007LL

typedef long long int llint;

int N;

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

	llint ans = 1;
	llint cap[3] = { 0, 0, 0 };
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < 3; j++) {
			if (cap[j] == A[i]) {
				if (sum == 0) { cap[j]++; }
				sum++;
			}
		}
		ans *= sum;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	VI p(n);
	REP(i, n)cin >> p[i];

	int c, d, e;
	c = d = e = 0;

	REP(i, n) {
		if (p[i] <= a)c++;
		else if (b < p[i])e++;
		else d++;
	}
	cout << min({ c,d,e }) << endl;


	return 0;
}

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

int main()
{
	long long int n, k, p;
	scanf("%lld %lld", &n, &k);
	
	p = n%k;
	
	if(p <= k - p) printf("%lld", p);
	else printf("%lld", k - p);
	
}

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

int main() {

  // 配列
  string S; // int型の配列変数vecを宣言
// vector<int> T(N); // int型の配列変数vecを宣言
  cin >> S;

  string ANS;
  ANS = "Yes";
  if(S.at(0)==S.at(1)){
	if(S.at(0)==S.at(2)){
		ANS = "No";
    }
  }
  
  cout << ANS << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  int x = 1;
  while (x * x + x < 2 * N) {
    x++;
  }
  if (x * x + x != 2 * N) {
    print("No");
  } else {
    print("Yes");
    print(x + 1);
    FOR(i, x + 1) {
      cout << x << " ";
      FOR(j, x) {
        if (i <= j) {
          cout << i * (2 * x - i + 1) / 2 + j + 1 - i << " ";
        } else {
          cout << j * (2 * x - j + 1) / 2 + i - j << " ";
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std; 
typedef long long int ll; 
int main()
{
    ll A, V; 
    cin >> A >> V; 
    ll B,W; 
    cin >> B >> W; 
    ll T; 
    cin >> T; 
    ll D=abs(A-B); 
    ll D2=(V-W)*T; 
    puts(D<=D2?"YES":"NO"); 
    }


Measured memory_bytes: 3664
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = long.Parse(_[0]);
            var b = long.Parse(_[1]);

            if((a + b) % 2 == 0){
                Console.WriteLine((a + b) / 2);
            }else{
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  char a,b,c,gomi;
  cin>>a>>gomi>>gomi>>gomi>>b>>gomi>>gomi>>gomi>>c;
  cout<<a<<b<<c;
  }


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);

	int t = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 != 0) {
			cout << 0 << endl;
			return 0;
		}
		else a[i] /= 2;
	} 
	t++;

	
	int c = 1;
	while (1) {
		for (int i = 0; i < n;i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
			}
			else c = 0;
		}
		if (!c)break;
		t++;
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int D;
  cin>>D;
  if(D==25){
    cout<<"Christmas"<<endl;
  }else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }else if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
    }
  else{
    cout<<"Christmas Eve Eve Eve"<<endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int chara[5]={0};
  string tmp;
  string cmp="MARCH";
  for(int i=0;i<N;i++){
    cin>>tmp;
    for(int i=0;i<5;i++){
      if(tmp[0]==cmp[i]){
        chara[i]++;
        break;
      }
    }
  }
  ll ans=0;

  int type[5][10]={
    {1,1,1,1,1,1,0,0,0,0},
    {1,1,1,0,0,0,1,1,1,0},
    {1,0,0,1,1,0,1,1,0,1},
    {0,1,0,1,0,1,1,0,1,1},
    {0,0,1,0,1,1,0,1,1,1}
  };

  for(int i=0;i<10;i++){
    ll part=1;
    for(int j=0;j<5;j++){
      if(type[j][i]==1){
        part*=ll(chara[j]);
      }
    }
    ans+=part;
  }

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

Measured memory_bytes: 256
import collections
N = int(input())
s_list = []
for i in range(N):
  s_list.append(''.join(sorted(input())))
s_list = collections.Counter(s_list)
def f(n):
  return int(n*(n+1)/2)
result = sum([f(n-1) for n in s_list.values()])
print(result)

Measured memory_bytes: 19764
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<sstream> //istringstream stm(string); stm >> x;
#include<map>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
map<ll,int> ma;
map<ll,int>::iterator it;
int main() {
	int n,i;
	scanf("%d",&n);
	for(i = 0; i < n; i++) {
		ll x;
		scanf("%lld",&x);
		ma[x]++;
	}
	ll ans = 0;
	ll last = -1;
	for(it = ma.begin(); it != ma.end(); it++) {
		if(last != -1) {
			if(it->second >= 2) {
				ans = max(ans,last * it->first);
			}
		}
		if(it->second >= 2) {
			last = it->first;
		}
	}
	for(it = ma.begin(); it != ma.end(); it++) {
		if(it->second >= 4) {
			ans = max(ans,it->first * it->first);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> pic(H+2,vector<char>(W+2,'#'));
  for(int i=1;i <= H;i++){
    for(int j =1;j<=W;j++){
      cin >> pic.at(i).at(j);
    }
  }
  for(int i=0;i < H+2;i++){
    for(int j =0;j<W+2;j++){
      cout << pic.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 2*1e5 + 10;
// make sure N size is correctttt!!!!!!!!!

int n, h[N], a[N], seg[4*N];
void update(int node, int l, int r, int pos, int vals){
   if(l > r)
      return;
   if(l == r){
      smax(seg[node], vals);
      return;
   }
   int mid = (l + r) >> 1;
   if(pos <= mid){
      update(2*node, l, mid, pos, vals);
   }
   else{
      update(2*node+1, mid+1, r, pos, vals);
   }
   seg[node] = max(seg[2*node], seg[2*node+1]);
}

int query(int node, int l, int r, int ql, int qr){
   if(qr < l or ql > r)
      return 0;
   if(ql <= l and r <= qr)
      return seg[node];
   int mid = (l+r)>>1;
   return max(query(2*node, l, mid, ql, qr), query(2*node+1, mid+1, r,  ql, qr));
}

template <typename T>
struct fenwick_tree {
private:
   int n;
   vector <T> a;
public:
   void initialize(int k) {
      n=k;
      a.assign(n+1,0);
   }
   void update(int pos, T val) {
      for(;pos<=n;pos+=pos&(-pos)) smax(a[pos], val);
   }
   T query(int pos) {
      T ans=0;
      for(;pos>=1;pos-=pos&(-pos)) smax(ans, a[pos]);
      return ans;
   }
};

fenwick_tree <int> bit;
int32_t main(){_

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

   bit.initialize(n);

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      int tt = bit.query(h[i]);//query(1,1,n,1,which);
      a[i] += tt;
      smax(ans, a[i]);
      bit.update(h[i],a[i]); // update(1,1,n,which,a[i]);
   }

   cout<<ans;
   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 5120
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

int sx,sy,tx,ty;
string paths = "";

void solve(){
	int dx = tx - sx;
	int dy = ty - sy;
	//行って
	paths = paths + string(dy,'U');
	paths = paths + string(dx,'R');
	//戻る
	paths = paths + string(dy,'D');
	paths = paths + string(dx,'L');
	//もう一度行って
	paths = paths + 'L';
	paths = paths + string(dy+1,'U');
	paths = paths + string(dx+1,'R');
	paths = paths + 'D';
	//戻る
	paths = paths + 'R';
	paths = paths + string(dy+1,'D');
	paths = paths + string(dx+1,'L');
	paths = paths + 'U';
}

int main(){
	cin >> sx >> sy >> tx >> ty;

	solve();

	cout << paths;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     // freopen("input1.txt","r",stdin);
     // freopen("output1.txt","w",stdout); 
    string S; 
    cin>> S;
    int ans=0;
    for(auto it:S){
        ans=(ans+ it-'0') %9;
    }
    
    if(ans==0)
        cout<<"Yes";
    else
        cout<<"No";;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

const int N = int(5e5) + 500;
const int u[2] = {+1, 0};
const int d[2] = {-1, 0};

int n, q;
int ps[N], ans[N], c[N], fen[N];
vector <int> g[N];
vector <pair <pair <int, int>, int> > qu;

void upd(int x, int vl) {
    while (x < n) {
        fen[x] += vl;
        x = (x | (x + 1));
    }
}

int sum(int x) {
    int res = 0;
    while (x >= 0) {
        res += fen[x];
        x = (x & (x + 1)) - 1;
    }
    return res;
}

int main() {
    fast_io;

    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        ps[c[i]] = 0;
        g[c[i]].push_back(i);
    }

    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        qu.push_back(make_pair(make_pair(l, r), i));
    }
    sort(qu.begin(), qu.end());

    for (int i = 1; i <= n; ++i) {
        for (int j = ps[i]; j < min(ps[i] + 2, int(g[i].size())); ++j)
            upd(g[i][j], u[j - ps[i]]);
    }

    //for (int i = 0; i < n; ++i)
        //cerr << sum(i) - sum(i - 1) << " ";
    //cerr << "\n";

    int L = 0, p = 0;
    while (L < n && p < q) {
        int l = qu[p].first.first, r = qu[p].first.second;
        while (L < l) {
            int x = c[L];
            for (int i = ps[x]; i < min(ps[x] + 2, int(g[x].size())); ++i)
                upd(g[x][i], d[i - ps[x]]);
            ++ps[x];
            for (int i = ps[x]; i < min(ps[x] + 2, int(g[x].size())); ++i)
                upd(g[x][i], u[i - ps[x]]);
            ++L;
        }

        //for (int i = 0; i < n; ++i)
            //cerr << sum(i) - sum(i - 1) << " ";
        //cerr << "\n";

        ans[qu[p].second] = sum(r);
        ++p;
    }

    for (int i = 0; i < q; ++i)
        cout << ans[i] << "\n";
}


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

int main(){
    int a[9];
    rep(i,9){
        cin>>a[i];
    }
    int n;
    cin>>n;
    vector<int>b(n);
    bool c[9];
    rep(i,9)c[i]=false;
    rep(i,n){
        cin>>b[i];
        rep(j,9){
        if(a[j]==b[i]){
            c[j]=true;
        }
        }
    }
    for(int j=0;j<7;j+=3){
        if(c[j]==true&&c[j+1]==true&&c[j+2]==true){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    for(int j=0;j<3;j++){
        if(c[j]==true&&c[j+3]==true&&c[j+6]==true){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(c[0]==true&&c[4]==true&&c[8]==true){
        cout<<"Yes"<<endl;
         return 0;
    }
    if(c[2]==true&&c[4]==true&&c[6]==true){
        cout<<"Yes"<<endl;
         return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int n, a, min, max, i;
    long long sum = 0;
    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> a;
        sum += a;
        if (i == 0) {
            max = a;
            min = a;
        }
        
        if (a > max) {
            max = a;
        }
        
        if (a < min) {
            min = a;
        }
    }
    
    cout << min <<" "<< max <<" "<< sum << endl;
    
    return 0;
}


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

#define sz(x) ((int)x.size())
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll; 

vector<vector<int>> adj; 
vector<int> vis; 


void dfs(int u, int p){
  vis[u]=1; 
  for(int v:adj[u]){
    if(!vis[v]){
      dfs(v,u); 
    }
  }
}

int main(){
  int n; cin>>n; 
  adj=vector<vector<int>> (n+1); 
  int m; cin>>m; 
  for(int i=1;i<=m;i++){
    int x,y,z; cin>>x>>y>>z; 
    adj[x].push_back(y); 
    adj[y].push_back(x); 
  }
  int c=0; 
  vis=vector<int> (n+1,0); 
  for(int i=1;i<=n;i++){
    if(!vis[i]){
      c++; 
      dfs(i,0); 
    }
  }
  cout<<c<<endl; 
}

Measured memory_bytes: 9216
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<isize> = s.trim().chars().map(|x| x.to_string().parse().unwrap()).collect();

    for o in 0..2_usize.pow(4) {
        let mut i = 0;
        let x = v.iter().fold(0, |a, b| if i==0||o&(1<<i)!=0 {i+=1; a+b} else {i+=1; a-b});
        if x==7 {
            print!("{}", v[0]);
            for i in 1..v.len() {
                print!("{}{}", if o&(1<<i)!=0 {"+"} else {"-"}, v[i]);
            }
            println!("=7");
            return;
        }

    }

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j;
	cin >> n;
	int arr[n][3];
	
	for(i=0;i<n;i++)
	for(j=0;j<3;j++)
	cin >> arr[i][j];
	
	int dp[n][3];
	
	for(j=0;j<3;j++)
	dp[0][j]=arr[0][j];
	
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			if(j==0)
			dp[i][j]=max(dp[i-1][1],dp[i-1][2])+arr[i][j];
			else if(j==1)
			dp[i][j]=max(dp[i-1][0],dp[i-1][2])+arr[i][j];
			if(j==2)
			dp[i][j]=max(dp[i-1][0],dp[i-1][1])+arr[i][j];
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n,m; cin >> n >> m;
  vector<int> H(n);
  rep(i, n) cin >> H[i];
  vector<vector<int>> h(n);

  rep(i, m) {
    int a,b; cin >> a >> b;
    --a; --b;
    h[a].push_back(b);
    h[b].push_back(a);
  }
  int cnt = 0;
  rep(i, n) {
    bool good = true;
    rep(j, h[i].size()) {
      if(H[h[i][j]] >= H[i]) {
        good = false;
        break;
      }
    }
    if(good) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 8744
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        j=3
        while j <= b:
            if a%j==0:
                c+=1
                break
            j+=2
        if c==0:
            s+=1
print(s)

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

int main() {
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)){
    cout<<"Bad"<<endl;
  }
  else if(s.at(1)==s.at(2)){
    cout<<"Bad"<<endl;
  }
  else if(s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2017年12月29日 星期五 14时53分54秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)
 
const int N=1e5+10;
char s[N];
int a[N];
 
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
 
	scanf("%s",s);
	int len=strlen(s),ans=len;
 
	for(int i=1;i<len;i++){
		if(s[i]!=s[i-1]){
			ans=min(ans,max(i,len-i));
		}
	}

	printf("%d\n",ans);
    
    return 0;
}


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

signed main(){
  int N;
  cin >> N;
  int A;
  vector<int> B(200020);
  for(int i = 2;i <= N;i++){
    cin >> A;
    B[A]++;
  }
  for(int i =1;i <= N;i++){
    cout << B[i] << "\n";
  }
}



Measured memory_bytes: 4812
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    cnt = 0
    while A >= B:
        B *= 2
        cnt += 1

    while B >= C:
        C *= 2
        cnt += 1

    if cnt <= K:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9108
S=input()
i=0
while i<=len(S):
    if i==len(S):
        print("YES")
        exit()
    if S[i:i+11] == "dreameraser":
        i+=11
    elif S[i:i+10] == "dreamerase":
        i+=10
    elif S[i:i+7] == "dreamer":
        i+=7
    elif S[i:i+6] == "eraser":
        i+=6
    elif S[i:i+5] in ["dream","erase"]:
        i+=5
    else:
        print("NO")
        exit()


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

int N,Y;

int main()
{
    cin>>N>>Y;

    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N-i; j++)
        {
            int k = N-i-j;
            if(10000*i + 5000*j + 1000*k == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
        
    }
    
    cout << "-1 -1 -1 "<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string S;
int N;
int K;
int memo[345][345][345];
int dp(int i, int j, int k) {
	if (i == 0 || j == 0)return 0;
	if (memo[i][j][k] >= 0)return memo[i][j][k];
	int res = max(dp(i - 1, j, k), dp(i, j - 1, k));
	if (S[i - 1] == S[N - j])res = max(res, dp(i - 1, j - 1, k) + 1);
	if (k > 0)res = max(res, dp(i - 1, j - 1, k - 1) + 1);
	return memo[i][j][k] = res;
}

int main(void)
{
	cin >> S;
	cin >> K;
	N = S.size();
	memset(memo, 0xff, sizeof(memo));
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int can = dp(i, N - i - 1, K);
		ans = max(ans, can * 2 + 1);
	}
	for (int i = 0; i <= N; ++i) {
		int can = dp(i, N - i, K);
		ans = max(ans, can * 2);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int num ;
	cin >> num ; 
	int flag =0 ;
	for(int i=1;  i<=9 ; i++)
	{
		for(int j=1;j<=9 ; j++)
		{
			if((i*j)==num)
			{
				flag = 1 ;
				break;
			}
		}
	}
	if(flag==1)
		cout << "Yes" ;
	else
		cout << "No" ; 
}

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

const int N=800005;
const long long MOD=1e9+7;
int n;
long long k,ans;
struct node{long long x[60][60];}now;

node mult(node a,node b)
{
	node res;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			res.x[i][j]=0;
			for(int k=1;k<=n;k++)
			{
				res.x[i][j]+=a.x[i][k]*b.x[k][j]%MOD;
				res.x[i][j]%=MOD;
			}
		}
	}
	return res;
}

void ksm(node a,long long b)
{
	node res;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			res.x[i][j]=0;
		}
		res.x[i][i]=1;
	}
	while(b)
	{
		if(b%2) res=mult(res,a);
		a=mult(a,a),b/=2;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			ans=(ans+res.x[i][j])%MOD;
		}
	}
}

int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&now.x[i][j]);
		}
	}
	ksm(now,k);
	printf("%lld\n",ans);
}

Measured memory_bytes: 512
package main
import "fmt"

const MaxInt = 1<<31
var k int
var n int
var A []int
func min(a, b int) int {
	if a < b { return a }
	return b
}
func abs(a int) int {
	if a < 0 { return -a }
	return a
}
func main() {
	_,e := fmt.Scanf("%d%d", &n, &k)
	if e!= nil { return }
	if n<=1 {
		fmt.Println(0)
		return
	}
	A = make([]int, n+1)
  	dp := make([]int, n+1)
	for i:=1; i<=n; i++ {
		_,e := fmt.Scanf("%d", &A[i])
		if e != nil { return }
     	dp[i] = MaxInt
	}
	if n == 2 {
		fmt.Println(abs(A[2]-A[1]))
		return
	}
	dp[1] = 0
	for i:=2; i<=n; i++ {
		for j:=1; j<=k; j++ {
			if i-j >= 1 {
				dp[i] = min(dp[i], dp[i-j]+abs(A[i] - A[i-j]))
			}
		}

	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll x, y, z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
#define rrp(i, n)   for(int i = ((int)(n)); i >=0; i--)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > ppp;
typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;

int main(){
vvi d(3001,vi(3001,0));
int a[3001];
int n,s;
cin>>n>>s;
rep(i,n)cin>>a[i];
long long ans=0;
long long mod=998244353;
rep(i,n)d[i][0]=1;
rep(i,n)for(int j=s;j>=0;j--){
d[i+1][j]+=d[i][j];
d[i+1][j]%=mod;
if((j+a[i])<=s){
    
    d[i][j+a[i]]+=d[i][j];
    d[i][j+a[i]]%=mod;
    d[i+1][j+a[i]]=d[i][j+a[i]];
}
}
rep(i,n)ans+=d[i][s],ans%=mod;
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N;
char S[100005];

int main(void) {
    scanf("%d", &N);
    scanf("%s", S);

    ans = 1;
    REP(i, 1, N) {
    	if (S[i-1]==S[i])continue;
    	ans++;
    }
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

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

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;

int main() {
    IOS;
    int n, m, x;
    cin >> n >> m >> x;
    int data[n] = {0};
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        a--;
        data[a] = 1;
    }
    int c1 = 0, c2 = 0;
    for (int i = x - 1; i < n; ++i) {
        c1 += data[i];
    }
    for (int i = 0; i <= x - 1; ++i) {
        c2 += data[i];
    }
    cout << min(c1, c2);


    cout << endl;

    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).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;}

const char EOL = '\n';
const int MOD = 1000000007;
const int INF = 1000000001;

void solve();

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

void solve() {
    int n;
    cin >> n;
    vector<int> c(n);
    REP(i, n) cin >> c[i];

    vector<ll> dp(n + 1, 0);
    vector<ll> dp2(200200, 0);
    dp[0] = 1;

    REP(i, n) {
        if (c[i - 1] == c[i]) {
            dp[i + 1] = dp[i];
        } else {
            dp[i + 1] = dp[i] + dp2[c[i]];
            dp[i + 1] %= MOD;
            dp2[c[i]] += dp[i];
            dp2[c[i]] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

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

typedef long long LL;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int N = 100000;
const int oo = 0x3f3f3f3f;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
string solve(int a, int b, int c) {
    bool flag = false;

    if(!a) {
        flag = true;
        a = b;
        b = c;
        c = 0;
    }

    string res;
    if(!a) {
        res = string(b, 'b');
    }else {
        if(!b && !c) {
            res = string(a, 'a');
        }else {
            vector<string> ans(a, "a");
            for(int i = 0; i < c; ++i) ans[i % a] += 'c';

            int pos = c % a;
            for(int i = 0; i < b; ++i) {
                ans[pos] += 'b';
                if(++ pos == a) pos = c % a; 
            }

            map<string, int> mp;
            vector< pair<string, int> > sub;

            for(const auto& x : ans) { ++ mp[x]; }
            for(const auto& x : mp) { sub.pb(x); }
            while(sub.size() < 3) sub.pb(make_pair("", 0));

            string tmp = solve(sub[0].snd, sub[1].snd, sub[2].snd);

            for(const auto& x : tmp) {
                res += sub[x - 'a'].fst;
            }
        }
    }

    if(flag) {
        for(auto& ch : res) ++ ch;
    }
    return res;
}

int a, b, c;
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
    
    cin >> a >> b >> c;
    cout << solve(a, b, c) << endl;

    return 0;
}


Measured memory_bytes: 256
a = input()
a = int(a)
 
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
 
print(l[a-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N=2e5+5;
int n,m;
ll ans;
ll choose(int x,int t=2){
	return x*(x-1)/2;
}
int main(){
	scanf("%d%d",&n,&m);
	if(n>1)ans+=choose(n);
	if(m>1)ans+=choose(m);
	cout<<ans<<endl;
}	

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0576().doIt();
	}
	
	class AOJ0576{
		String kan;
		void doIt(){
			int n = in.nextInt();
			kan = in.next();
			int cnt = 0;
			for(int i=0;i<n;i++){
				cnt+=get_Kanban(in.next());
//				System.out.println(cnt);
			}
			System.out.println(cnt);
		}
		
		int get_Kanban(String input){
			//何文字目から始めるか
			int n = input.length();
			for(int i=0;i<n;i++){// start
				for(int s=1;s<n;s++){// 間隔
					String a = "";
					for(int k=i;k<n;k+=s){// 文字場所
						if(a.length()==kan.length())break;
						a+=input.charAt(k);
					}
					if(a.equals(kan))return 1;
				}
			}
			return 0;
		}
		
	}
	
}

Measured memory_bytes: 90688
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    a=ST()
    b=ST()+" "
    ans = ""
    for i,s in enumerate(a):
        ans += s+b[i]
    ans.replace(" ","")
    print(ans)
if __name__ == '__main__':
    main()

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; ++i) {
		dp[i] = min(abs(a[i] - a[i - 2]) + dp[i - 2],abs(a[i] - a[i - 1]) + dp[i - 1]);
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int n, m, head[N], ver[M], nex[M], tot;
int vis[N], ans[N], sum;

void add(int a, int b) {
   ver[++tot]=b;
   nex[tot]=head[a];
   head[a]=tot;
}

int main() {
   cin>>n>>m;
   for1(i, m) {
      int x, y;
      scanf("%d%d", &x, &y);
      add(x, y);
      add(y, x);
   }
   queue<int>q;
   q.push(1);
   while(!q.empty()) {
      int x=q.front(); q.pop();
      for(int i=head[x]; i; i=nex[i]) {
         int y=ver[i];
         if(!vis[y]) {
            ans[y]=x;
            sum++, vis[y]=1;
            q.push(y);
         }
      }
   }
   if(sum != n) puts("No");
   else {
      puts("Yes");
      for(int i=2; i<=n; ++i) printf("%d\n", ans[i]);
   }
   return 0;
}

Measured memory_bytes: 8200
using System;
using static System.Console;

class Program
{
	static void Main(string[] args)
	{
		int[] list = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

		int K = int.Parse(ReadLine());
		WriteLine(list[K - 1]);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[105];

int main()
{
	int i, j;
	scanf("%s", str + 1);
	N = 1;
	while (str[N] != 0) ++N;
	--N;
	for (i = 1; i <= N; ++i) {
		int l = i;
		int r = N - i + 1;
		if (str[l] == str[r]) continue;
		break;
	}
	if (i < N + 1) {
		printf("No\n");
		return 0;
	}
	for (i = 1; i <= (N - 1) / 2; ++i) {
		int l = i;
		int r = (N - 1) / 2 -i + 1;
		if (str[l] == str[r]) continue;
		break;
	}
	if (i < (N - 1)/2 + 1) {
		printf("No\n");
		return 0;
	}
	for (i = (N +3)/2; i <= N; ++i) {
		int l = i;
		int r = N - i + 1;
		if (str[l] == str[r]) continue;
		break;
	}
	if (i < N + 1) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, r,card[50],cut[50],p,c;
	while (cin >> n >> r && n&&r) {
		for (int i = 0; i < n; ++i) card[i] = i + 1;
		for (int i = 0; i < r; ++i) {
			cin >> p >> c;
			for (int j = 0; j < c; ++j) cut[j] = card[n - p - j];
			for (int j = 1; j < p; ++j) card[n - p -c+ j] = card[n - p + j];
			for (int j = 0; j < c; ++j) card[n-j-1] = cut[j];
		}
		cout << card[n-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 2988
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var n = toInt(input[0]);
	var as = toIntArr(input[1].split(' '));
	var sum = 0;
	for(var i = 0; i < n; i++){
		sum += as[i];
	}
	var bs = as.map((el,ind,arr)=>abs(sum - n*el));
	var ans = 0;
	var min = bs[0];
	for(var i = 1; i < n; i++){
		if(bs[i] < min){
			min = bs[i];
			ans = i;
		}
	}
	console.log(ans);
}

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int a = 0;
	if (A < 10) {
		if (B < 10) {
			a = A * B;
		}
		else {
			a = -1;
		}
	}
	else {
		a = -1;
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
const int maxn = 1000000000;
map<int,int> peo;
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        int temp;
        cin>>temp;
        if(peo.find(temp) == peo.end()){
            peo[temp] = 1;
        }else{
            if(peo[temp] == 1){
                peo[temp] = 0;
            }else if(peo[temp] == 0){
                peo[temp] = 1;
            }
        }
    }
    int ans = 0;
    for(map<int,int>::iterator it = peo.begin();it != peo.end();it++){
        if(it->second == 1) ans++;
    }
    cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> ai(n);
  vector<int> bi(n);
  vector<int> ci(n-1);
  for (int i = 0; i < n; i++) {
    cin >> ai.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> bi.at(i);
  }
  for (int i = 0; i < n-1; i++) {
    cin >> ci.at(i);
  }
  
  int manzoku = 0;
  int before_num = -1;
  for (int i = 0; i < n; i++) {
    int select_num = ai.at(i);
    manzoku += bi.at(select_num-1);
    if (before_num+1 == select_num) {
      manzoku += ci.at(before_num-1);
    }
    before_num = select_num;
  }
  cout << manzoku << endl;
}

Measured memory_bytes: 256
room1=[[0 for i in range(10)]for j in range(3)]
room2=[[0 for i in range(10)]for j in range(3)]
room3=[[0 for i in range(10)]for j in range(3)]
room4=[[0 for i in range(10)]for j in range(3)]

n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    if b==1:
        room1[f-1][r-1]+=v
    elif b==2:
        room2[f-1][r-1]+=v
    elif b==3:
        room3[f-1][r-1]+=v
    elif b==4:
        room4[f-1][r-1]+=v

for i in range(3):
    print(" ",end='')
    print(*room1[i])
print("#"*20)
for i in range(3):
    print(" ",end='')
    print(*room2[i])
print("#"*20)
for i in range(3):
    print(" ",end='')
    print(*room3[i])
print("#"*20)
for i in range(3):
    print(" ",end='')
    print(*room4[i])


Measured memory_bytes: 5628
x = int(input())
max_cand = 120
for a in range(max_cand+1):
    for b in range(max_cand+1):
        if (a**5 - b**5) == x:
            print(a, b)
            break
        elif (a**5 + b**5) == x:
            print(a, -b)
            break
    else:
        continue
    break


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll n, k; cin >> n >> k;
    vector<ll> Avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> Avec[i];

    ll pre = 0;
    for(int i = k; i < n; ++i) {
        if(Avec[pre] < Avec[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
        pre++;
    }
}

Measured memory_bytes: 4844