akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    cin >> N;
    vector<int> a(3 * N);
    rep(i, 3 * N) cin >> a[i];
    
    priority_queue<int, vector<int>, greater<int>> p;
    lint sum = 0;
    rep(i, N) {
        sum += a[i];
        p.push(a[i]);
    }
    vector<lint> S(N + 1, 0);
    S[0] = sum;
    rep(i, N) {
        int x = p.top();
        p.pop();
        if (x < a[N + i]) {
            sum -= x;
            sum += a[N + i];
            p.push(a[N + i]);
        } else {
            p.push(x);
        }
        S[i + 1] = sum;
    }
    reverse(a.begin(), a.end());
    priority_queue<int> q;
    sum = 0;
    rep(i, N) {
        sum += a[i];
        q.push(a[i]);
    }
    vector<lint> T(N + 1, 0);
    T[0] = sum;
    rep(i, N) {
        int x = q.top();
        q.pop();
        if (x > a[N + i]) {
            sum -= x;
            sum += a[N + i];
            q.push(a[N + i]);
        } else {
            q.push(x);
        }
        T[i + 1] = sum;
    }
    reverse(T.begin(), T.end());
    lint ans = -1000000000000000;
    rep(i, N + 1) ans = max(ans, S[i] - T[i]);
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef tuple<ll,ll,ll> point;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  bool visited[H][W];
  rep(h, H) rep(w, W) visited[h][w] = false;
  priority_queue<point> que;

  que.emplace(-(S[0][0] == '#'), 0, 0);
  visited[0][0] = true;
  ll ans;
  while(!que.empty()){
    ll cost, h, w;
    tie(cost, h, w) = que.top();
    que.pop();
    visited[h][w] = true;
    if(h == H-1 && w == W-1){
      ans = -cost;
      break;
    }
    if(h+1 < H && !visited[h+1][w]){
      que.emplace(cost - (S[h][w] == '.' && S[h+1][w] == '#'), h+1, w);
      // printf("%lld %lld %lld\n", cost - (S[h][w] == '.' && S[h][w] == '#'), h+1, w);
    }
    if(w+1 < W && !visited[h][w+1]){
      que.emplace(cost - (S[h][w] == '.' && S[h][w+1] == '#'), h, w+1);
      // printf("%lld %lld %lld\n", cost - !(S[h][w] == S[h][w+1]), h, w+1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define p_b push_back
#define e_b emplace_back
#define m_p make_pair
#define m_t make_tuple

using namespace std;

int main() {
	ll md = 1000000007, ans = 0, sum=0;
	int n;
	cin >> n;
	vector<ll> vec(n);

	rep(i, n) {
		cin >> vec[i];
		sum += vec[i];
		sum %= md;
	}

	rep(i, n) {
		sum -= vec[i];
		if (sum < 0) sum += md;
		ans += vec[i] * sum;
		ans %= md;
	}

	cout << ans << endl;

}

Measured memory_bytes: 4764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {

    int N; cin >> N;
    ll a[N];
    rep(i,N) cin >> a[i];
    ll sum[N];
    rep(i,N) sum[i] = 0;
    sum[0] = a[0];
    for (int i = 1; i < N; ++i) {
        sum[i] = sum[i-1] + a[i];
    }
    ll ans = INF;
    rep(i,N-1) {
        ans = min(ans, abs(2 * sum[i] - sum[N-1]));
    }
    out(ans);



    return 0;
}



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


const int N = 1e5 + 5;

int n, t, x, y, tt, xx, yy;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t >> x >> y;
        int tim = t - tt, cur = abs(x - xx) + abs(y - yy);
        if(cur == 0){
            if(tim % 2){
                return cout << "No", 0;
            }
        }
        else
        if(tim % cur){
            return cout << "No", 0;
        }
        tt = t, xx = x, yy = y;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    ll n;
    cin>>n;
    ll nn = n;
    if(n%2){
        cout<<0<<endl;
        return 0;
    }else{ll ans = 0;
        ll k=10;
        while(true){
            if(nn/k!=0){
                ans+=nn/k;
                k*=5;
            }else{
                break;
            }
        }
        cout<<ans<<endl;



    }
    
return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<string> OUTPUT;

//ASCIIで左>右niならないようにdfsする
void dfs(string now,char maxi,int N){
    if(now.size() == N){
        OUTPUT.push_back(now);
    }
    else{
        //1文字目からどんどん分岐させていく
        for(char C = 'a';C <= maxi;C++){
            //現時点でのASCIImaxiと同じなら次にそれより+1の文字が使えるようにする
            if(C == maxi) dfs(now+C,maxi+1,N);
            else dfs(now+C,maxi,N);
        }
    }
    
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;

    dfs("",'a',N);

    sort(OUTPUT.begin(),OUTPUT.end());

    for(string V : OUTPUT) cout << V << endl;

}


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

typedef long long int ll;
typedef long double ld;         
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int ans_of_chars = 256; 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    ll A, B, K, i;
 
    cin >> A >> B >> K;
 
    if (K > A) {
        K = K - A;
        A = 0;
        
        if (K > B) {
            B = 0; 
        }
        else {
            B = B - K;
        }
    }
    else {
        A = A - K;
    }
 
    cout << A << " " << B << '\n';
    
    return 0;
}

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

int main(){
  int a,b;
  int n = 0;
  int k = 1;
  int i = 0;
  int x[200]={};
   
    
    
  while(i < 200 && cin >> a >> b){
      
      if(a < 0 || a > 1000000 || b < 0 || b > 1000000){
          cout << "データを入力し直してください!!" << endl;
          break;
      }
      
      else{
          i++;
          n = a+b;
          
    while(n/10 !=0){
        k++;
        n = n/10;
    }
          x[i-1] = k;
          k = 1;
      }
  }
    
    for(int j = 0;j < i;j++)
        cout << x[j] << endl;
    
  return 0;
}



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

int main() {
  int n, orignum;
  int x = 0;
  cin >> n;
  orignum = n;
  while (n != 0) {
    x += n % 10;
    n /= 10;
  }
  if (orignum % x == 0) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}


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

int main(void){
	char *a0= "SUN";
  	char *a1= "MON";
	char *a2= "TUE";
	char *a3= "WED";
	char *a4= "THU";
	char *a5= "FRI";
	char *a6= "SAT";

  char b[4];
  scanf("%s", b);
  
    if(strcmp(a0,b)==0) printf("7");
    else if(strcmp(a1,b)==0) printf("6");
    else if(strcmp(a2,b)==0) printf("5");
    else if(strcmp(a3,b)==0) printf("4");
    else if(strcmp(a4,b)==0) printf("3");
    else if(strcmp(a5,b)==0) printf("2");
    else if(strcmp(a6,b)==0) printf("1");

  return 0;
}


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

int main()
{
  while(true){
    int n;
    cin >> n;

    if(n==0)
      break;

    int len[40];
    for(int i=0; i<n; i++){
      string w;
      cin >> w;

      len[i] = w.size();
    }

    for(int i=0; i<n; i++){
      bool flg = false;
      int sta = 0;
      int sum = 0;

      for(int j=i; j<n; j++){
	sum += len[j];

	if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
	  sta++;
	}

	if(sta==5){
	  flg = true;
	  // cout << "OK" << endl;
	  break;
	}
	else if(sum>=31){
	  break;
	}
      }

      if(flg){
	cout << i+1 << endl;
	break;
      }
    }
    // cout << "Not OK" << endl;
  }

  return 0;
}



Measured memory_bytes: 3152
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 10007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const ll MAXN=110;
char a[MAXN];
ll f[MAXN][4];//f[i][j]表示到了第i位此时出现了非0数位的方案数
ll n,k;
ll c[MAXN];
inline ll dfs(ll x,ll w,ll limit,ll s)//表示到了第x位出现了w位非0
//是否有最高位的限制是否存在前导0
{
	if(w<0)return 0;
	if(!limit&&f[x][w]!=-1)return f[x][w];
	if(!x)
	{
		if(!w)return f[x][w]=1;
		return f[x][w]=0;
	}
	ll maxx=limit?c[x]:9;
	ll cnt=0;
	for(ll i=0;i<=maxx;++i)
	{
		if(s&&i==0){cnt+=dfs(x-1,w,0,s);continue;}
		if(i==0)cnt+=dfs(x-1,w,limit&&i==maxx,0);
		else cnt+=dfs(x-1,w-1,limit&&i==maxx,0);
	}
	if(!limit&&!s)f[x][w]=cnt;
	return cnt;
}
int main()
{
	//freopen("1.in","r",stdin);
	memset(f,-1,sizeof(f));
	scanf("%s",a+1);
	n=strlen(a+1);k=read();
	for(ll i=1;i<=n;++i)c[i]=a[i]-'0';
	reverse(c+1,c+1+n);
	printf("%lld\n",dfs(n,k,1,1));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  ll a[n][n];
  bool b[n][n];
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) b[i][j] = true;
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) scanf("%lld", &a[i][j]);
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) for(k = 0; k < n; ++k) if(i != j && j != k && k != i) {
    if(a[i][j] + a[j][k] < a[i][k]) {
      printf("-1");
      return 0;
    } else if(a[i][j] + a[j][k] == a[i][k]) b[i][k] = false;
  }
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(b[i][j]) ans += a[i][j];
  printf("%lld", ans);
  return 0;
}

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

int main()
{
    int n;
    std::cin>>n;
    std::vector<int> a(n+1);
    std::vector<int> ans;
    std::vector<bool> ball(n+1);
    for(int i=1;i<=n;i++)std::cin>>a[i];
    int ans_cnt = 0;    
    for(int i = n; i > 0; i--){
        int cnt = 0;
        for(int j = i; j <= n; j += i){
            if(ball[j])cnt++;
        }
        if(cnt %2 != a[i]){
            ball[i] = true;
            ans.push_back(i);
            ans_cnt++;
        }
    }
    std::cout<<ans_cnt<<std::endl;
    for(auto i : ans){
        std::cout<<i<<" ";
    }
}

Measured memory_bytes: 2428
//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<map>
//#include<unordered_map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll; 
typedef unsigned int ull; 
//typedef pair<int, int> P; 
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
struct ed{
	int to, nxt, w;
}e[N << 1];
int head[N], tot = 1;
void add(int u, int v, int w){
	e[tot].to = v, e[tot].w = w, e[tot].nxt = head[u], head[u] = tot++;
}

int a[N], n, op = 1, x, y;
int  main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, greater<int>());
	for (int i = 1; i <= n + 1; i++)
	{
		if (i > a[i])
		{
			x = a[i - 1] - i + 1;
			int j = 0;
			for (; a[i + j] == i - 1; j++)
				y++;
			if ((x & 1) || (y & 1))
				printf("First\n");
			else
				printf("Second\n");
			break;
		}
	}
	
}

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

int main() {
  int n;
  cin >> n;
  vector<tuple<string,int,int>> a;
  for(int i =1;i<=n;i++){
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  for(int i = 0;i<n;i++){
    string s;
    int p;
    int id;
    tie(s,p,id) = a.at(i);
    cout << id << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int64_t sum=0;
  int i;
  for(i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0){
      sum+=i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/

int N, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    set<int> cand;
    rep(i, 0, N) {
        cand.insert(A[i]);
        cand.insert(A[i] + 1);
        if(A[i]) cand.insert(A[i] - 1);
    }

    map<int, int> m;
    rep(i, 0, N) m[A[i]]++;

    int ans = 0;
    fore(c, cand) {
        int cnt = 0;
        cnt += m[c];
        cnt += m[c + 1];
        if (c) cnt += m[c - 1];
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

int n;
int dist[101][101];
int atk[101][101];
int memo[101][101]; //memo[i][j] : ??????j??§?????????i???????????¨??????????°??\???\?????°
bool used[101][101];
const int INF = 1000000000;

struct V{
  int p,m;
  V(int p,int m):p(p),m(m){}
};

bool operator < (const V& a,const V& b){
  return memo[a.p][a.m] > memo[b.p][b.m];
}

int solve(int s,int l){
  for(int i=0;i<=100;++i)
    for(int j=0;j<=100;++j){
      used[i][j]=false;
      memo[i][j]=INF;
    }
  
  memo[s][l] = 0;
  priority_queue<V> Q;
  Q.push(V(s,l));

  while(!Q.empty()){
    V x=Q.top(); Q.pop();
    int cur = x.p, mon = x.m, cst=memo[cur][mon];
    //    if(used[cur][mon]) continue;
    //    used[cur][mon] = true;
    for(int i=0;i<n;++i){
      if(dist[cur][i]){
	if(cst+atk[cur][i] < memo[i][mon]){
	  memo[i][mon] = cst+atk[cur][i];
	  Q.push(V(i,mon));
	}
	if(mon-dist[cur][i]>=0){
	  if(memo[i][mon-dist[cur][i]] > cst){
	    memo[i][mon-dist[cur][i]] = cst;
	    Q.push(V(i,mon-dist[cur][i]));
	  }
	}
      }
    }
  }

  int ret = INF;
  for(int i=0;i<=l;++i) ret = min(ret, memo[n-1][i]);
  return ret;
}
int main(){
  int m,l;
  while(cin>>n>>m>>l,n||m||l){
    memset(dist,0,sizeof(dist));
    memset(atk,0,sizeof(atk));
    while(m--){
      int a,b,d,e;
      cin >> a >> b >> d >> e;
      a--;b--;
      dist[a][b] = dist[b][a] = d;
      atk[a][b] = atk[b][a] = e;
    }
    cout<<solve(0,l)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1460
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int N;
long C;
long[] H;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      C = readLong();
      H = new long[N];
      foreach (i; 0 .. N) {
        H[i] = readLong();
      }
      // Tuple!(long, long)[] q;
      Tuple!(long, long)[] q = new Tuple!(long, long)[N];
      int qHead, qTail;
      auto dp = new long[N];
      foreach (i; 0 .. N) {
        if (i == 0) {
          dp[i] = 0;
        } else {
          debug {
            writefln("i = %s, q = %s", i, q);
          }
          // for (; q.length >= 2; q.popFront) {
          for (; qTail - qHead >= 2; ++qHead) {
            // if (q[0][0] + q[0][1] * H[i] < q[1][0] + q[1][1] * H[i]) {
            if (q[qHead][0] + q[qHead][1] * H[i] < q[qHead + 1][0] + q[qHead + 1][1] * H[i]) {
              break;
            }
          }
          debug {
            writefln("i = %s, q = %s", i, q);
          }
          // dp[i] = q[0][0] + q[0][1] * H[i];
          dp[i] = q[qHead][0] + q[qHead][1] * H[i];
          dp[i] += H[i] * H[i] + C;
        }
        const a = tuple(dp[i] + H[i] * H[i], -2 * H[i]);
        // for (; q.length >= 2; q.popBack) {
        for (; qTail - qHead >= 2; --qTail) {
          // -(q[$ - 2][0] - q[$ - 1][0]) / (q[$ - 2][1] - q[$ - 1][1]) < -(q[$ - 1][0] - a[0]) / (q[$ - 1][1] - a[1])
          // if (-(q[$ - 2][0] - q[$ - 1][0]) * (q[$ - 1][1] - a[1]) < -(q[$ - 1][0] - a[0]) * (q[$ - 2][1] - q[$ - 1][1])) {
          if (-(q[qTail - 2][0] - q[qTail - 1][0]) * (q[qTail - 1][1] - a[1]) < -(q[qTail - 1][0] - a[0]) * (q[qTail - 2][1] - q[qTail - 1][1])) {
            break;
          }
        }
        // q ~= a;
        q[qTail++] = a;
      }
      debug {
        writefln("dp = %s", dp);
      }
      writeln(dp[N - 1]);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 15108
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int,int> P;
struct St{
	int x, y, c;
	St(int cst, P p): c(cst), y(p.first), x(p.second) {}
	bool operator>(const St &s) const{
		return c > s.c;
	}
};

const int inf = 999999;
int xdir[4] = {0, -1, 0, 1}, ydir[4] = {1, 0, -1, 0};
int bfs(char a[101][101], int w, int h, P p)
{
	int r = -1, vis[101][101];
	priority_queue<St, vector<St>, greater<St> > que;
	fill(&vis[0][0], &vis[h][w], inf);
	vis[p.first][p.second] = 0;
	que.push(St(0, p));
	while(!que.empty()){
		St s = que.top();
		que.pop();
		if(s.x < 0 || s.x >= w || s.y < 0 || s.y >= h){
			r = s.c;
			break;
		}
		
		for(int i = 0; i < 4; i++){
			int dy = s.y+ydir[i], dx = s.x+xdir[i];
			if(dy < 0 || dy >= h || dx < 0 || dx >= w){
				St t = (a[s.y][s.x] == '#')? St((s.c+1), P(dy, dx)): St(s.c, P(dy, dx));
				que.push(t);
			} else if(vis[dy][dx] > s.c){
				int u = inf;
				if(a[s.y][s.x] == '#' && a[dy][dx] == '.'){
					u = s.c+1;
				} else {
					u = s.c;
				}
				if(u < vis[dy][dx]){
					vis[dy][dx] = u;
					que.push(St(u, P(dy, dx)));
				}
			}
		}
	}
	
	return r;
}

int main()
{
	int w, h;
	char a[101][101];
	P p;
	
	while(cin>>w>>h && (w+h)){
		for(int i =0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> a[i][j];
				if(a[i][j] == '&'){
					p = P(i, j);
					a[i][j] = '.';
				}
			}
		}
		
		cout << bfs(a, w, h, p) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

struct Edge {
  int src, dst;
  long long weight;
  Edge(int src, int dst, long long weight)
      : src(src), dst(dst), weight(weight) {}

  bool operator<(const Edge &e) const { return weight > e.weight; }
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;

std::pair<long long, Edges> Prim(const Graph &g, int s) {
  int n = g.size();
  Edges tree;
  long long total = 0;
  std::vector<int> visited(n, 0);
  std::priority_queue<Edge> q;
  q.emplace(-1, s, 0);
  while (!q.empty()) {
    Edge e = q.top();
    q.pop();
    if (visited[e.dst])
      continue;
    if (e.src != -1)
      tree.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for (auto f : g[e.dst]) {
      if (!visited[f.dst])
        q.push(f);
    }
  }
  return std::pair<long long, Edges>(total, tree);
}

constexpr long long INF64 = 1e18;

using Weight = long long;

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
//経路復元可能
Weight Dijkstra(const Graph &g, int s, int t) {
  const int V = g.size();
  std::vector<Weight> dist(V, INF64);
  std::vector<int> prev(V, -1);
  std::priority_queue<Edge> q;
  dist[s] = 0;
  for (q.emplace(-2, s, 0); !q.empty();) {
    Edge e = q.top();
    q.pop();
    if (prev[e.dst] != -1)
      continue;
    prev[e.dst] = e.src;
    if (prev[t] != -1)
      return dist[t];
    for (auto ge : g[e.dst]) {
      if (dist[ge.dst] > e.weight + ge.weight) {
        dist[ge.dst] = e.weight + ge.weight;
        q.emplace(ge.src, ge.dst, e.weight + ge.weight);
      }
    }
  }
  return dist[t];
}

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for (int i = 0; i < m; ++i) {
    int s, t;
    long long c;
    cin >> s >> t >> c;
    s--;
    t--;
    g[s].push_back({s, t, c});
    g[t].push_back({t, s, c});
  }
  Graph tree(n);
  auto prim = Prim(g, 0);
  auto edges = prim.second;
  for (const auto &e : edges) {
    tree[e.src].push_back({e.src, e.dst, e.weight});
  }
  long long ans = 0;
  int count = 0;
  {
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      int p = q.front();
      q.pop();
      for (const auto &e : tree[p]) {
        Graph gg(n);
        for (const auto &ges : g) {
          for (const auto &gee : ges) {
            if (gee.src == e.dst and gee.dst == e.src)
              continue;
            gg[gee.src].push_back(gee);
          }
        }
        if (prim.first != Prim(gg, e.dst).first) {
          ans += e.weight;
          count++;
        }
        q.push(e.dst);
      }
    }
  }
  cout << count << " " << ans << endl;
}


Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

void solve(long long N, std::vector<long long> a)
{
    vector<bool> visit(N, false);
    int push = 0;
    int light = (int)a[push];
    int ans = 1;
    while (!visit[push])
    {
        if (light == 1)
        {
            cout << ans << endl;
            return;
        }
        else
        {
            ans++;
            visit[push] = true;
            push = light;
            light = (int)a[push];
        }
    }
    cout << -1 << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        ll x;
        cin >> x;
        a[i] = (x - 1);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll x,a;
       cin>>x>>a;
       if(x<a)
       {
           cout<<"0";
       }
       else
       {
           cout<<"10";
       }
    } 
    return 0;
}


Measured memory_bytes: 3640
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =3e3+5;
int n,a[maxn],re;
bool ok[maxn];
vector<int> ad[maxn];
void dfs(int u,int pa)
{
	for(int v:ad[u])if(v!=pa)
	{
		dfs(v,u);
		if(!ok[v]&&a[v]<a[u])ok[u]=1;
	}
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    rep(i,1,n)
    {
	    int x,y;
	    cin>>x>>y;
	    ad[x].pb(y);
	    ad[y].pb(x);
    }
    rep(i,1,n+1)
    {
	    memset(ok,0,sizeof ok);
	    dfs(i,0);
	    if(ok[i])cout<<i<<' ';
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n,k;
    scanf("%lld%lld",&n,&k);
    int dp[2][k+1]; memset(dp,0,sizeof(dp));
    for (int i = 0; i < n; i++){
        int w,v;
        scanf("%lld%lld",&w,&v);
        for (int j = 1; j <= k; j++){
            dp[i%2][j] = dp[1-i%2][j];
            if (w <= j) dp[i%2][j] = max(v+dp[1-i%2][j-w],dp[i%2][j]);
        }
    }
    printf("%lld",dp[1-n%2][k]);
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int a, b, d;
    while (cin >> a >> b >> d, a) {
        int opt_x = -1, opt_y = -1;
        int ma_xy = inf, ma_axby = inf;
        rep(x, 50001) {
            for (int sgn = -1; sgn <= 1; sgn += 2) {
                if ((a * x + sgn * d) % b == 0) {
                    int y = abs(a * x + sgn * d) / b;
                    if (x + y < ma_xy || (x + y == ma_xy && a * x + b * y < ma_axby)) {
                        opt_x = x, opt_y = y;
                        ma_xy = x + y;
                        ma_axby = a * x + b * y;
                    }
                }
            }
        }
        cout << opt_x << " " << opt_y << endl;
    }
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;




int main(){
    int n;
    string s;
    string cir="";
    for(int i=0;i<='z'-'a';i++)
        cir+='a'+i;
    for(int i=0;i<='Z'-'A';i++)
        cir+='A'+i;
    while(cin>>n,n){
        vi k(n);
        REP(i,n)
            cin>>k[i];
        cin>>s;
        REP(i,s.size()){
            int j;
            for(j=0;j<52;j++)
                if(cir[j]==s[i])
                    break;
            s[i]=cir[(j-k[i%n]+2*52)%52];


        }
        cout<<s<<endl;


    }



}

Measured memory_bytes: 3152
s = input()

cnt = 0
# サイズnの連結成分は必ず作れない
# サイズ1の連結成分は必ず作れる
if s[-1] == "1" or s[0] == "0":
    print(-1)
    exit()
    
li = []
for i in range(1, len(s) // 2):
    if s[i] != s[-i-2]:
        print(-1)
        exit()
    if s[i] == "1":
        li.append(i + 1)
        
tree = []
j = 1
for _ in range(len(li)):
    tree.append((j, j + 1))
    j += 1
li.append(len(s))

cnt = 0
for i in range(len(li)):
    cnt += 1
    while cnt < li[i]:
        tree.append((i + 1, j + 1))
        j += 1
        cnt += 1

for edge in tree:
    print(*edge)

Measured memory_bytes: 20060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  LL r;
  cin >> r;
  cout << 3*r*r << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, tmp, c=0;
    scanf("%d", &n);
    int a[n];
    for(int i=0 ; i<n ; i++) scanf("%d",&a[i]);
    
    for(int i=0 ; i<n ; i++){
        for(int j=n-1 ; j>i ; j--){
            if(a[j]<a[j-1]){
                tmp = a[j], a[j] = a[j-1], 
                a[j-1] = tmp, c++;
            }
        }
    }
    for(int i=0 ; i<n ; i++){
        if(i==n-1)  printf("%d\n", a[i]);
        else        printf("%d ", a[i]);
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 2092
#coding: utf-8
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
l = []
for i in range(N):
    A = list(map(int, input().split()))
    l.append(sum(A[j] * B[j] for j in range(M)) + C > 0)
print(sum(l))

Measured memory_bytes: 3060
use std::collections::{HashMap, BinaryHeap};

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (n, m) = (input[0], input[1]);
    let mut hm = HashMap::new();

    for _ in 0..n {
        let input = read_vec::<usize>();
        let v = hm.entry(input[0]).or_insert_with(|| vec![]);
        (*v).push(input[1]);
    }

    let mut ans = 0;
    let mut heap = BinaryHeap::new();
    for i in 1..m+1 {
        if let Some(v) = hm.remove(&i) {
            for i in v.into_iter() {
                heap.push(i);
            }
        }
        if let Some(b) = heap.pop() {
            ans += b;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 15804
#include<iostream>
using namespace std;
 int USCLN(int a, int b)
        {                       
            if (a==0 ||b==0)
                return a+b;
            while (a!=b)
            {
                if(a>b)
                    a=a-b;
                else
                    b=b-a;
            }
            return a;
        }
int main()
{
   int a, b;
   cin >> a >> b;
   cout << USCLN(a,b) << endl;

}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/
/*void build_tree(ll tree[],ll a[],ll start,ll end,ll node)
{
    if(start==end)
    {
        tree[node]=a[start];
        return;
    }
    int mid=(start+end)/2;
    build_tree(tree,a,start,mid,2*node);
    build_tree(tree,a,mid+1,end,2*node+1);
    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll query_tree(ll tree[],ll a[],ll qs,ll qe,ll start,ll end,ll node)
{
    if(start>=qs && end<=qe)
    {
        return tree[node];
    }
    if(start>qe || end<qs)
        return INT_MAX;
    int mid=(start+end)/2;
    int left_tree=query_tree(tree,a,qs,qe,start,mid,2*node);
    int right_tree=query_tree(tree,a,qs,qe,mid+1,end,2*node+1);

    return min(left_tree,right_tree);
}*/
vector<vector<int>> adj(100005);
std::vector<bool> vis(100005);
int temp=0;
void dfs(int u)
{
    temp++;
    vis[u]=true;
    for(int i:adj[u])
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
}
int main()
{

 #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif  
  IOS;
 ll n,m;
 cin>>n>>m;
 vector<int> x;
 adj.clear();
 adj.resize(n+1);
 vis.clear();
 vis.resize(n+1);
 for (int i = 0; i < m; ++i)
 {
     ll u,v;
     cin>>u>>v;
     adj[u].push_back(v);
     adj[v].push_back(u);
 }
 for(int i=1;i<=n;i++)
 {
    if(!vis[i])
    {
        temp=0;
        dfs(i);
        x.push_back(temp);
    }
 }
 sort(x.begin(),x.end());
 ll ans=x[x.size()-1];
cout<<ans<<endl;

 
}
                                  
   

  

Measured memory_bytes: 20424
#include<bits/stdc++.h>
#define cs const
using namespace std;
cs int N = 200;
int ct[N], len, nd, ic[N];
string oc, fin; char v[N];
int query(string S){
	cout << "? " << S << '\n';
	fflush(stdout);
	int x; scanf("%d",&x); return x;
}
string cope(string a, string b){
	int n = a.length(), m = b.length();
	if(!n) return b; if(!m) return a;
	string c = "";
//	cout << "cope "<<a<<" "<<b<<" "<<n<<' '<<m<<endl;
	int pt = 0, j = 0;
	while(j < m){
		string pr = c; 
//		cout << c <<" "<<j<<" "<<pt<<endl;
		c += b[j]; 
		if(pt == n){ ++j; continue; }
		oc = c; 
		for(int i=pt; i<n; i++) oc += a[i];
		int k = oc.length();
//		cout << k << " " << c << endl;
		if(query(oc) != len - k)
		c = pr, c += a[pt], ++pt;
		else ++j;
//		cout << c <<" "<<j<<" "<<pt<<endl;
	} while(pt < n) c += a[pt++];
	return c;
}
string work(int l, int r){
	if(l==r){
		string nx = "";
//		cout << l << " " << ct[l]<<endl;
		for(int i=1; i<=ct[l]; i++) nx += v[l];
		return nx;
	} int mid = (l+r)>>1;
	return cope(work(l,mid),work(mid+1,r));
}
int main(){
	for(int i=0; i<26; i++) v[ic[i + 'a'] = ++nd] = i + 'a';
	for(int i=0; i<26; i++) v[ic[i + 'A'] = ++nd] = i + 'A';
	for(int i=0; i<10; i++) v[ic[i + '0'] = ++nd] = i + '0';
	for(int i=1; i<=nd; i++){
		oc.clear();
		for(int j=0; j<128; j++) oc+=v[i];
		ct[i] = 128 - query(oc); len += ct[i]; 
	} fin = work(1,nd); 
	cout << "! " << fin;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3788
n, k = map(int, input().split())
s = [0 for i in range(n)]
for z in range(k):
	hoge = input()
	l = list(map(int, input().split()))
	for i in l:
		s[i-1] += 1

def fuga(x): return x==0

print(len(list((filter(fuga, s)))))


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  int i = 0;
  while(i <= n && i < 10){
  	if(a<=i && i<=b){
    	ans += i;
    }
    i++;
  }
  while(i <= n && i < 100){
  	int j = i/10 + i%10;
  	if(a<=j && j<=b){
    	ans +=i;
    }
    i++;
  }
  while(i <= n && i < 1000){
  	int j = i/100 + (i-i/100*100)/10 + i%10;
  	if(a<=j && j<=b){
    	ans += i;
    }
    i++;
  }
  while(i <= n && i < 10000){
  	int j = i/1000 + (i-i/1000*1000)/100 + (i-i/100*100)/10 + i%10;
  	if(a<=j && j<=b){
    	ans += i;
    }
    i++;
  }
  if(n == 10000 && a == 1 && 1 <= b){
  	ans += 10000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef ONLINE_JUDGE
#define debug(x) {}
#else
#define debug(x) { cerr << #x << " = " << x << endl; }
#endif
int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int m1, m2, d1, d2;

  cin >> m1 >> d1;
  cin >> m2 >> d2;

  if(m1 == m2){
  	cout<<0<<'\n';
  }else{
  	cout<<1<<'\n';
  }
  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;

// 一行取って、一番初めのTを習得
template <class T> int streamvar(std::istream& in, T& var)
{
    string s;
    if (!in) {
        return 1;
    }
    getline(in, s);
    istringstream is(s);
    is >> var;
    if (is.fail()) 
        return 1;
    return 0;
}
// 一行取って、T vectorに格納する
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) 
        return 1;
    getline(in, s);
    if (in.fail()) 
        return 1;
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

#define EPS 1e-6
int main(void)
{
    int n;
    while (cin >> n) {
        long long m = 100000;
        for (int i = 0; i < n; i++) {
            m = (double)m * 1.05;
            if (m % 1000) {
                m -= m % 1000;
                m += 1000;
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N, M; cin >> N >> M;

  rep(i, (M+1)/2)
    cout << N - i << " " << N - (M-i) << endl;
  rep(i, M/2)
    cout << i+1 << " " << M-i << endl;
  return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

vector<pair<int,int>> p;
set<pair<int,int>> q;

/*----------------------------------------------------------------*/
signed main(){

    int n,q;
    int a[21];
    int m[201];
    cin >> n;
    rep(i,n)cin >> a[i];
    cin >> q;
    rep(i,q)cin >> m[i];

    set<int> num;
    for(int bit = 0;bit < (1LL<<n);bit++){
        int d = 0;
        rep(i,n)if(bit&(1LL<<i))d += a[i];
        num.insert(d);
    }

    rep(i,q){
        if(num.find(m[i]) != num.end())cout << "yes" << endl;
        else cout << "no" << endl;
    }

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://sumitrust2019.contest.atcoder.jp/tasks/sumitb2019_d


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int a,b,n;
  cin >> n >> a >> b;
  int x=n/(a+b);
  int y=n%(a+b);
  if(y<=a){cout<<x*a+y;}
  else{cout<<(x+1)*a;}
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

constexpr int kMOD = 1000000007;
constexpr uint64_t kINF = 0xFFFFFFFFFFFFFFFF;

int main() {
    uint64_t N, M;
    cin >> N >> M;

    vector<uint64_t> dp(N+4, 0);
    rep(i, M) {
        uint64_t tmp;
        cin >> tmp;
        dp[tmp] = kINF;
    }

    dp[0] = 1;
    rep(i, N) {
        if(dp[i] == kINF)
            continue;

        if(dp[i+1] != kINF) {
            dp[i+1] += dp[i];
            dp[i+1] %= kMOD;
        }

        if(dp[i+2] != kINF) {
            dp[i+2] += dp[i];
            dp[i+2] %= kMOD;
        }
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 3676
x = int(input())

if 400 <= x <= 599:
    print(8)

elif 600 <= x <= 799:
    print(7)

elif 800 <= x <= 999:
    print(6)

elif 1000 <= x <= 1199:
    print(5)

elif 1200 <= x <= 1399:
    print(4)

elif 1400 <= x <= 1599:
    print(3)

elif 1600 <= x <= 1799:
    print(2)

elif 1800 <= x <= 1999:
    print(1)


Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
main()
{
    string s;
    cin>>s;
    int n=s.size();
    vector<int> ans(n,1);
    for(int i=0;i<n;i++)if(s[i]=='R'&&s[i+1]=='R')
    {
        ans[i+2]+=ans[i];
        ans[i]=0;
    }
    for(int i=n-1;i>=0;i--)if(s[i]=='L'&&s[i-1]=='L')
    {
        ans[i-2]+=ans[i];
        ans[i]=0;
    }
    for(int i=0;i<n;i++)printf(i==0?"%d":" %d",ans[i]);
    puts("");
}

Measured memory_bytes: 1024