akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, a[110000], b[110000], ans;
int main() {
	cin >> n;
	REP(i, n + 1)cin >> a[i];
	REP(i, n)cin >> b[i];
	REP(i, n) {
		ans += min(a[i], b[i]);
		b[i] = max(b[i] - a[i], 0ll);
		ans += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);
	}
	cout << ans << endl;
}
	


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
    ll A,B,a[3],i;
    scanf("%lld %lld",&A,&B);
    A--;
    for(i=B-A;i<=B+A;i++)

    printf("%lld ",i);
    return 0;
}


Measured memory_bytes: 256
#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 int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5 + 5)


void solve()
{
    ll n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    ll sum[n] = {0};
    sum[n-1] = arr[n-1];
    for(int i=n-2;i>=0;i--)
        sum[i] = (sum[i+1] + arr[i])%mod;

    ll ans = 0;
    for(int i=0;i<n-1;i++)
    {
        ll cur = (arr[i] * sum[i+1])%mod;
        ans = (ans + cur)%mod;
    }

    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define rep(i, a, b) for(int i = a; i < b; i++)

const double EPS = 1e-10;

double add(double a, double b){
    if( abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
    return a + b;
}

// 二次元ベクトル構造体
struct P{
    double x, y;
    P(){}
    P(double x, double y) : x(x), y(y){
    }
    P operator + (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator - (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator * (double d){
        return P(x * d, y * d);
    }
    P operator / (double d){
        return P(x / d, y / d);
    }
    double dot(P p){ // 内積
        return add(x * p.x, y * p.y);
    }
    double det(P p){ // 外積
        return add(x * p.y, -y * p.x);
    }
};
vector<P> p;

// 2点間の長さ
double dist(P a, P b){
    return sqrt((b-a).dot(b-a));
}
double dist2(P a, P b){
    return (b-a).dot(b-a);
}

//　線分p1-p2上に点qがあるか判定
bool on_seg(P p1, P p2, P q){
    return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

// 直線p1-p2と直線q1-q2の交点
P intersection(P p1, P p2, P q1, P q2){
    return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

double calc_r(P tmp){
    double r = 0;
    for(auto to: p) r = max(r, dist(tmp, to));
    return r;
}

double calc_y(double x){
    double low_y = 0;
    double high_y = 1000;
    int cnt = 500;
    while(cnt--){
        double c1 = (low_y * 2 + high_y) / 3.0;
        double c2 = (low_y + high_y * 2) / 3.0;
        if(calc_r(P(x, c1)) < calc_r(P(x, c2))) high_y = c2;
        else low_y = c1;
    }
    return low_y;
}

int main(){
    int N; cin >> N;
    
    p.resize(N);
    rep(i, 0, N) cin >> p[i].x >> p[i].y;

    double low_x = 0, high_x = 1000;
    int cnt = 500;
    while(cnt--){
        double c1 = (low_x * 2 + high_x) / 3.0;
        double c2 = (low_x + high_x * 2) / 3.0;
        if(calc_r(P(c1, calc_y(c1))) < calc_r(P(c2, calc_y(c2)))) high_x = c2;
        else low_x = c1;
    }

    cout << fixed << setprecision(10) << calc_r(P(low_x, calc_y(low_x))) << endl;

}


Measured memory_bytes: 256
N, K = map(int, input().split(' '))
d_list = input().split(' ')
for h in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    number = h * 10000 + i * 1000 + j * 100 + k * 10 + l
                    result = set(list(str(number)))
                    if set(d_list) & result != set():
                        continue
                    if number >= N:
                        print(number)
                        break
                else:
                    continue
                break
            else:
                continue
            break
        else:
            continue
        break
    else:
        continue
    break





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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int t[2]={-1,0};
    if(a==b&&b==c){
        cout << t[a%2] << endl;
    }
    else {
        int count = 0;
        while(a%2==0&&b%2==0&&c%2==0){
            int num1 = b/2 + c/2;
            int num2 = a/2 + c/2;
            int num3 = a/2 + b/2;
            a = num1;b = num2;c = num3;
            count++;
        }
        cout << count << endl;
    }
    return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
using namespace std;
struct node{int l;ll s;} f[2010][2010];
char ans[4010],a[2010];
int n,t;
ll k;

void print()
{
  for (int i=t;i;i--)
    printf("%c",ans[i]);
  cout <<endl;
}
void work(int l,int r,ll k)
{
  if (l==r) {printf("%s%c",ans+1,a[l]); print();return ;}
  if (l==r-1&&a[l]==a[r]) {ans[++t]=a[l]; printf("%s",ans+1); print(); return;}
  if (a[l]==a[r]) {ans[++t]=a[l]; work(l+1,r-1,k);}
  else {
      if (f[l+1][r].l>f[l][r-1].l) {ans[++t]=a[r];work(l,r-1,k);}
      else if (f[l+1][r].l<f[l][r-1].l) {ans[++t]=a[l];work(l+1,r,k);}
      else {
          if (a[l]>a[r])
          {
            if (f[l][r-1].s>=k) {ans[++t]=a[r];work(l,r-1,k);}
            else {ans[++t]=a[l];work(l+1,r,k-f[l][r-1].s);}
          }
          else {
            if (f[l+1][r].s>=k) {ans[++t]=a[l];work(l+1,r,k);}
            else {ans[++t]=a[r];work(l,r-1,k-f[l+1][r].s);}
          }
      }
  }
}

int main()
{
  //freopen("1.in","r",stdin);
  scanf("%s",a+1);
  cin>>k;
  n=strlen(a+1);
  for (int i=1; i<=n; i++) f[i][i]=(node){0,1};
  for (int i=1;i<=n-1;i++)
    if (a[i]==a[i+1]) f[i][i+1]=(node){0,1};
    else f[i][i+1]=(node){1,2};
  for (int l=3; l<=n; l++)
    for (int i=1; i<=n-l+1;i++)
    {
      int j=i+l-1;
      if (a[i]==a[j]) f[i][j]=f[i+1][j-1];
      else {
        if (f[i+1][j].l>f[i][j-1].l) f[i][j]=(node){f[i][j-1].l+1,f[i][j-1].s};
        else if (f[i+1][j].l<f[i][j-1].l) f[i][j]=(node){f[i+1][j].l+1,f[i+1][j].s};
        else f[i][j]=(node){f[i][j-1].l+1,f[i+1][j].s+f[i][j-1].s};
      }
      if (f[i][j].s>k) f[i][j].s=k+1;
    }
  if (f[1][n].s<k) puts("NONE");
    else work(1,n,k);
  return 0;
}

Measured memory_bytes: 62820
import bisect
N=int(input())

L=[]
for i in range(N):
    n=int(input())
    L.append(n)
    
dp=[10**20 for i in range(N)]
dp[0]=L[0]
for i in range(1,len(L)):
    dp[bisect.bisect_left(dp,L[i])]=L[i]
#print(dp)
cnt=0
for i in range(len(L)):
    if dp[i]<10**20:
        cnt+=1
    else:
        break
print(cnt)


Measured memory_bytes: 10352
#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;
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);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-INF;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

            for(int i=0;i<l;i++){
                sum+=v[i];
                if(v[i]<0) {
                    te.push_back(v[i]);
                }
            }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
           // if(min(a,b)!=0) {
                for (int tt = 0; tt <= min(a, b); tt++) {
                    /*if (te[tt] < 0) {
                        sum -= te[tt];
                        if (ans < sum) {
                            ans = sum;
                        }

                    } else { break; }*/
                   if(tt!=0){ sum -= te[tt-1];}
                    if (ans < sum) {
                        ans = sum;
                    }
                    //cout<<l<<" "<<r<<" "<<sum<<endl;

                }
          /*  }else {
                if (ans < sum) {
                    ans = sum;
                }
            }*/




        }
    }

    cout<<ans<<endl;



    return 0;
}


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

int main(){
  int n;
 EXIT:
  while(cin>>n,n){
    string s[55];
    for(int i=0;i<n;i++){
      string t;
      cin>>t;
      s[i]+=t[0];
      for(int j=1;j<t.size();j++){
	char c=t[j-1];
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')s[i]+=t[j];
      }
    }
    for(int k=1;k<=50;k++){
      set<string> st;
      int f=1;
      for(int i=0;i<n;i++){
	string t;
	for(int j=0;j<k&&j<s[i].size();j++)t+=s[i][j];
	if(st.count(t))f=0;
	else st.insert(t);
      }
      if(f){
	cout<<k<<endl;
	goto EXIT;
      }
    }
    cout<<-1<<endl;
  }
  return 0;
}



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

int a[200001];

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int res = a[0];
  for(int i = 1; i < N; i++){
    res ^= a[i];
  }
  for(int i = 0; i < N; i++){
    int r = res ^ a[i];
    cout << r << " ";
  }
 
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    vector<int> p(M);
    vector<int> k(M);

    rep(i, M)
    {
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j, k[i])
        {
            cin >> s[i][j];
        }
    }

    rep(i, M) cin >> p[i];
    ll pattern = pow(2, N);
    vector<int> tmp_s(N, 0);
    int ans = 0;
    rep(i, pattern)
    {
        bool ok = true;
        rep(j, N)
        {
            if (i & 1 << j)
            {
                tmp_s[j] = 1;
            }
            else
            {
                tmp_s[j] = 0;
            }
        }
        rep(j, M)
        {
            int cnt = 0;
            rep(l, k[j])
            {
                if (tmp_s[s[j][l] - 1])
                {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j])
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            ans++;
        }
    }
    cout << ans << endl;
 //   system("pause");
    return 0;
}

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

int asdfdsa(char str[]);

int main(void)
{
	int cnt=0;
	char str[200];

	while(scanf("%s",str)!=EOF)
		if(asdfdsa(str))
			cnt++;
	printf("%d\n",cnt);

	return 0;
}

int asdfdsa(char str[])
{
	int i,size;

	size=strlen(str);
	for(i=0; i<=size/2; i++)
		if(str[i]!=str[size-1-i])
			return 0;

	return 1;
}

Measured memory_bytes: 548
#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;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N; cin >> N;
  vector<LL> xs(N);
  REP(i,N) cin >> xs[i];

  LL ans = 0, mn = 1;
  for(int i=0;i<N;++i){
	if(mn < xs[i]){
	  if(xs[i] % mn == 0){
		ans += xs[i] / mn - 1;
		if(mn == 1){
		  ++mn;
		}
		/*
		LL mn_;
		for(mn_=mn+1;;++mn_){
		  if(xs[i]/mn-1 != xs[i]/mn_){
			mn_ = -1;
			break;
		  }
		  if(xs[i]%mn_ != 0 && xs[i]%mn_ != mn) break;
		}
		ans += xs[i]/mn-1;
		if(mn_ < 0){
		  ++mn;
		}
		*/
	  }
	  else
		ans += xs[i]/mn;
	}
	else if(mn == xs[i]){
	  ++mn;
	}
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
signed main() {
    ll n, m;
    cin >> n >> m;
    vl data(m);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            data[a - 1]++;
        }
    }
    ll count = 0;
    for (int i = 0; i < m; i++) {
        if (data[i] == n) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,a[MN+5],mx,Ans[MN+5],ans,c[5],num;
inline void Add(int x){if(x)Ans[++ans]=x;}
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;++i) a[i]=read(),mx+=a[i]>>1;
    if(mx+(n>>1)<n-1) return 0*puts("Impossible");
    if(m==1) Add(1),Add(a[1]-1);
    else if(m==2) Add(a[1]-1),Add(a[2]+1);
    else
    {
        for(int i=1;i<=m;++i) if(a[i]&1)
        {
            if(a[1]&1) swap(a[i],a[m]);
            else swap(a[i],a[1]);
        }
        Add(a[1]-1);
        for(int i=2;i<m;++i) Add(a[i]);
        Add(a[m]+1);
    }
    for(int i=1;i<=m;++i) printf("%d%c",a[i],i==m?'\n':' ');
    printf("%d\n",ans);
    for(int i=1;i<=ans;++i) printf("%d ",Ans[i]);
    return 0;
}


Measured memory_bytes: 256
import math

def cal(x):
    y = []
    for i in xrange(1,11):
        d= pow(2,(10-i))

        if x>=d:
            x -= d
            y.append(d)
    return y

if __name__ == "__main__":
    while True:
        try:

            b = cal(int(raw_input()))
            b.reverse()

            for i in b:
                print i,

            print

        except EOFError:
            break

Measured memory_bytes: 4348
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < (n);++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  int n;cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  ll dp[3][100100];
  
  rep(i,n+1){
    dp[0][i+1] = max(dp[1][i],dp[2][i]) + a[i];
    dp[1][i+1] = max(dp[0][i],dp[2][i]) + b[i];
    dp[2][i+1] = max(dp[0][i],dp[1][i]) + c[i];
  }
  ll ans = max(dp[0][n],max(dp[1][n],dp[2][n]));
  print(ans);
  
  return 0;
}

Measured memory_bytes: 3712
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    private static int[] OddPrimes = new int[] { 3, 5, 7, 11, 13 };

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var k = Products(3, new int[3], new Queue<int>(OddPrimes)).Count(x => x <= n);
        Console.WriteLine(k);
    }

    private static IEnumerable<int> Products(int k, int[] factors, Queue<int> candidates)
    {
        if (k == 0)
        {
            yield return factors.Aggregate((x, y) => x * y);
            yield break;
        }
        
        if (!candidates.Any())
        {
            if (k == 1)
            {
                yield return (int)Math.Pow(factors[0], 3) * factors[1];
                yield return (int)Math.Pow(factors[1], 3) * factors[0];
            }
            else if (k == 2)
            {
                yield return (int)Math.Pow(factors[0], 7);
            }

            yield break;
        }

        var t = candidates.Dequeue();
        foreach (var x in Products(k, factors, new Queue<int>(candidates)))
        {
            yield return x;
        }
        factors[3 - k] = t;
        foreach (var x in Products(k - 1, factors, new Queue<int>(candidates)))
        {
            yield return x;
        }
    }
}

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

long long cnt;
vector<int> G;

// 間隔gで行う挿入ソート
void insertionSort(vector<int> &a, int n, int g)
{
    for (int i = g; i < n; i++)
    {
        int v = a.at(i);
        int j = i - g;

        while (j >= 0 && a.at(j) > v)
        {
            a.at(j + g) = a.at(j);
            j -= g;
            cnt++;
        }
        a.at(j + g) = v;
    }
}

void shellSort(vector<int> &a, int n)
{
    // 数列G= {1,4,13,40,121,364,1093,..., 3G+1}を生成
    for (int h = 1;;)
    {
        if (h > n)
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }

    // 逆順にG.at(i) = gを指定
    for (int i = G.size() - 1; i >= 0; i--)
    {
        insertionSort(a, n, G.at(i));
    }
}

int main()
{
    int l;
    vector<int> A(1000000);
    int n;
    cin >> n;
    rep(i, n)
    {
        cin >> A.at(i);
    }
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--)
    {
        cout << G.at(i);
        if (i)
            cout << " ";
    }
    cout << endl;
    cout << cnt << endl;

    rep(i, n)
    {
        cout << A.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 6628
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
signed main(){
    string N;
    cin >> N;
    int ans = 0;
    bool kuriage = false;
    for(int i = N.size()-1; i >= 0; i--) {
        int keta = (int)(N[i]-'0');
        if (kuriage) {
            keta++;
        }
        kuriage = false;
        if (keta > 5 || (keta == 5 && i > 0 && (int)(N[i-1]-'0') > 4) ) {
            ans+=10-keta;
            kuriage = true;
        }
        else {
            ans+=keta;
        }
    }
    if (kuriage) {
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1412
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
   
    int l[15];
    int i,a,b;
   
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)!=EOF){
   
        double sum=0;
        for(i=0;i<10;i++){
            sum+=(double)l[i];
        }
   
    double c=0,d=0;
    for(i=0;i<10;i++){
        c+=l[i];
        d+=(double)l[i]/a*b;
        if(c+d>=sum)break;
    }
    cout<<i+1<<endl;
   
    }
    return 0;
}
 

Measured memory_bytes: 1208
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n = ii()
    print(ceil(n/2))


main()



Measured memory_bytes: 5628
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int fi=0,fj=0,fk=0;
    int count=0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                fi = s.find(to_string(i),0);
                if(fi != string::npos){
                    fj = s.find(to_string(j),fi+1);
                    if(fj != string::npos){
                        fk = s.find(to_string(k),fj+1);
                        if(fk != string::npos){
                            count++;
                         }
                    }
                }
            }   
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3216
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long V = sc.nextLong();
		long B = sc.nextLong();
		long W = sc.nextLong();
		long T = sc.nextLong();
		
		long D = Math.abs(B-A);
		long S = V-W;
		
        if(S*T < D) {System.out.println("NO");}
		else {System.out.println("YES");}
	}
}

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




int main(){
  map<string,int> m;
  int num;
  string str;
  cin>>num;

  for(int i;i<num;i++){
    cin>>str;
      if( str=="insert" ){
	cin >> str;
	m[str]=1;
	//	m.insert(std::make_pair(str,1));
      }else{
	cin >> str;
	if(m[str]==1) cout <<"yes"<<endl;
	else cout <<"no"<<endl;

      }

  }

  return 0;
}



Measured memory_bytes: 52616
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K):
    N = int(N)
    @lru_cache(maxsize=None)
    def f(n, k):
        if k == 0:
            return 1
        m = n % 10
        l = n // 10
        if l == 0 and k == 1:
            return m
        elif l == 0:
            return 0
        return f(l, k-1)*m + f(l-1, k-1)*(9-m) + f(l, k)


    return f(N, K)


def f(N, K):
    M = len(N)
    N = int(N)
    ans = 0
    for i in range(N+1):
        n = str(i).count('0')
        if len(str(i)) - n == K:
            ans += 1
            # print(i)
    return ans

def main():
    N = read_str()
    K = read_int()
    print(slv(N, K))

    # print(f(N, K))

    # for _ in range(1000):
    #     N = str(random.randint(1, 100))
    #     K = random.randint(1, 3)
    #     # print(N)
    #     # print(K)
    #     a = slv(N, K)
    #     b = f(N, K)
    #     if a != b:
    #         print(N)
    #         print(K)
    #         print(a, b)
    #         assert a == b



if __name__ == '__main__':
    main()


Measured memory_bytes: 5708
program ABC115B
    implicit none
    integer(8)::i
    integer(8)::N,p
    integer(8)::p_max=0
    integer(8)::pay=0

    read(5,*)N
    
    do i=1,N
        read(5,*)p
        if(p>p_max)then
            p_max=p
        end if
        pay=pay+p
    end do
    
    pay=pay-p_max/2

    print'(i0)',pay
end program ABC115B

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int n=sc.nextInt();
		int x=sc.nextInt();
		Integer[] candies = new Integer[n];
		for (int i=0;i<n;i++) {
			candies[i] =sc.nextInt();
		}
		Arrays.sort(candies);
		int ans =0;
		for (int i=0;i<n-1;i++) {
			if(x>=candies[i]) {
				x -= candies[i];
				ans ++;
			}
		}
		if (x ==candies[n-1]) {
			ans ++;
		}
		System.out.println(ans);

//------------------------------------------------------------
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll x;
    cin>>x;
    ll val=(x-400)/200;
    cout<<8-val<<"\n";
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll siguma(int a){
    ll ans = 0;
    for(int i = 1; i < a; i++){
        ans += i;
    }
    return ans;
}
int main() {
    int n; cin >> n;
    map<string, int> m;
    ll ans = 0;
    rep(i,n){
        string s; cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(auto a: m){
        ans += siguma(a.second);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int a[101];

int main()
{
    int n;
    while(cin>>n) a[n]++;
    int ma = 0;
    for (int i = 1; i <= 100; ++i) ma = max(ma, a[i]);
    for (int i = 1; i <= 100; ++i) if (a[i]==ma) cout<<i<<endl;
}

Measured memory_bytes: 1160
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DEBUG
#undef DEBUG

using ll = long long;

int N, A, B;
int H[100005];

// 敵iをタゲった回数
ll cnt[100005];

// m回の攻撃でいけるかどうか
bool check(ll m)
{
    // A*cnt[i] + B*(m-cnt[i]) >= H[i] なる最小の cnt[i] を求める
    // ただし cnt[i] が負になるなら 0 とする
    // cnt[] の総和は m 以下でなければならない
    REP(i, N) {
        ll numer = H[i] - B*m;
        ll denom = A - B;
        if(numer <= 0) // 剰余演算のイザコザを避けるため分子の符号で判定(分母は常に正)
            cnt[i] = 0;
        else
            cnt[i] = numer/denom + (numer%denom ? 1 : 0);
    }
#ifdef DEBUG
    cout << "[cnt] ";
    REP(i, N) {
        cout << cnt[i] << " ";
    }
    cout << "\n";
#endif
    return accumulate(cnt, cnt+N, 0LL) <= m;
}

void solve()
{
    // 解の下限(最良効率)と上限(最悪効率)を求める
    // 下限はHP最大の敵のみをタゲるケース
    // 上限はHP最大の敵を一切タゲらないケース
    //   下限: (最大HP) / A
    //   //下限: (HP総和) / (A+(N-1)*B)
    //   上限: (最大HP) / B + 1
    ll hmax = *max_element(H, H+N);
    //ll m_min = accumulate(H, H+N, 0LL) / (A + (N-1)*B);
    ll m_min = hmax / A;
    ll m_max = hmax / B + 1; // +1 は余りが出た場合を考慮したもの

    // 実際に解を構成できるかどうかで二分探索
    ll m = -1;
    for(;;) {
#ifdef DEBUG
        cout << "m_min: " << m_min << "\n";
        cout << "m_max: " << m_max << "\n";
#endif

        m = (m_max + m_min) / 2;
        if(check(m)) {
            if(m == m_min) break;
            m_max = m;
        }
        else {
            if(m_min == m_max) { // 起こらないと思うけど…
                cout << "NOTFOUND\n";
                break;
            }
            m_min = m+1;
        }
    }

    cout << m << "\n";
}

int main()
{
    cin >> N >> A >> B;
    REP(i, N) {
        cin >> H[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

if N == 2:
    ans = A[0]
elif N == 3:
    ans = sum(A[:2])
elif N == 4:
    ans = sum(A[:2])+A[1]
elif N == 5:
    ans = sum(A[:2])+A[1]+A[2]
elif N == 6:
    ans = sum(A[:2])+A[1]+A[2]*2
else:
    ans = sum(A[:2])+A[1]+A[2]*2
    # print(ans)
    ind = N-6
    if ind%2 == 0:
        ans += sum(A[3:3+ind//2])*2
    else:
        ans += sum(A[3:3+ind//2])*2+A[3+ind//2]


print(ans)

Measured memory_bytes: 31596
#include <stdio.h>

#define MOD 1000000007

int main()
{
    int n,i,j,alf[26] = {0};
    char s[100001];
    scanf("%d %s",&n,s);
    for (i = 0; i < n; i++)
    {
        alf[s[i] - 'a']++;
    }
    long long ans = 1;
    for (i = 0; i < 26; i++)
    {
        ans = (ans * (alf[i] + 1)) % MOD;
    }
    if(ans == 0)
    {
        printf("%lld", MOD - 1);
    }
    else
    {
        printf("%lld",ans - 1);
    }
    
}

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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

const auto mx = 100111 * 2;
int table[30][mx];

int main () {
    const int n = getint();
    const int C = getint();
    for (auto i = 0; i < n; ++i) {
        auto s = getint() * 2 - 1;
        auto t = getint() * 2;
        auto c = getint() - 1;
        table[c][s] += 1;
        table[c][t] -= 1;
    }
    for (auto c = 0; c < C; ++c) {
        for (auto i = 0; i < mx - 1; ++i) {
            table[c][i + 1] += table[c][i];
        }
    }
    int res = 0;
    for (auto i = 0; i < mx; ++i) {
        int cnt = 0;
        for (auto c = 0; c < C; ++c) {
            if (table[c][i] > 0) cnt++;
        }
        chmax(res, cnt);
    }
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 23680
n, k = map(int, input().split()) 

if 2 * k > (n-1) * (n-2):
  print(-1)
else:
  ans = [(1, i) for i in range(2, n+1)]
  p =  (n-1) * (n-2) // 2
  i = 2
  j = 3
  while p > k:
    ans.append((i, j))
    p -= 1
    j += 1
    if j == n + 1:
      i += 1
      j = i + 1
  print(len(ans))
  for a in ans:
    print(" ".join(map(str, a)))

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

int main() {
  int n, max = -1, nextmax = -1;

  cin >> n;

  vector<int> a(n);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max)
      max = a[i];
    else if (a[i] > nextmax)
      nextmax = a[i];
  }

  for (int i = 0; i < n; i++) {
    if (a[i] == max)
      cout << nextmax << endl;
    else
      cout << max << endl;
  }

  return 0;
}

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

int main()
{
  int n, x, t ;
  cin >> n >> x >> t ;

  int m, ans ;
  m = ( n / x ) ;

  if ( n%x != 0 ) {
    m++ ;
  }

  ans = m * t ;

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

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

int main() {
  int a,b,ans=0;
  cin >> a >> b;
  for (int i=a; i>=1; i--) {
    for (int j=b; j>=1; j--) {
      if (i == j) {
//cout << i << ':' << j << endl;
        ans++;
      }
    }
    if (i-1==1) b=31;
    else if (i-1==2) b=28;
    else if (i-1==3) b=31;
    else if (i-1==4) b=30;
    else if (i-1==5) b=31;
    else if (i-1==6) b=30;
    else if (i-1==7) b=31;
    else if (i-1==8) b=31;
    else if (i-1==9) b=30;
    else if (i-1==10) b=31;
    else if (i-1==11) b=30;
  }
  cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<long long> L(N + 1, 0);
  L[0] = 2;
  L[1] = 1;
  rep(i, N - 1)
  {
    L[i + 2] = L[i + 1] + L[i];
  }
  long long ans = L.back();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

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

	for ( int n; cin >> n, n; )
	{
		VI xs( n ), ys( n );
		REP( i, 1, n )
		{
			int ni, d;
			cin >> ni >> d;

			ys[i] = ys[ ni ] + dy[d];
			xs[i] = xs[ ni ] + dx[d];
		}
		
		cout << *max_element( ALL( xs ) ) - *min_element( ALL( xs ) ) + 1 << ' ';
		cout << *max_element( ALL( ys ) ) - *min_element( ALL( ys ) ) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
signed main()
{
    int N,flag=0;
    char c;
    cin >> N;
    for(int i=1;i<=N;i++)
    {
        cin >> c;
        if(c=='Y')
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  rep(i, 0, M) {
    cin >> A[i];
  }

  vector<int> MASS(N+1, 0);
  rep(i, 0, M) {
    MASS[A[i]] = 1;
  }

  int l_cost = 0;

  rep(i, 0, X) {
    l_cost += MASS[i];
  }

  int r_cost = 0;
  rep(i, X, N+1) {
    r_cost += MASS[i];
  }

  int ans = min(l_cost, r_cost);

  cout << ans << endl;
};


Measured memory_bytes: 256
playing_cards = {
    "S"=>[],
    "H"=>[],
    "C"=>[],
    "D"=>[]
}

num_of_cards = gets.to_i
num_of_cards.times do
    card_info = gets.split
    playing_cards[card_info[0]].push(card_info[1].to_i)
end
["S","H","C","D"].each do |mark|
    (1..13).each do |number|
        if !playing_cards[mark].include?(number)
            puts "#{mark} #{number}"
        end
    end
end


Measured memory_bytes: 6876
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int dy[] = {0, 1};
const int dx[] = {1, 0};
int N, M, D;
int solve(vector<string> &table)
{
    int res = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                int cnt = D;
                int ny = i, nx = j;
                while(ny < N && nx < M)
                {
                    if(table[ny][nx] == '#') break;
                    ny += dy[k];
                    nx += dx[k];
                    cnt--;
                    if(cnt == 0)
                    {
                        res++;
                        break;
                    }
                }
            }
        }
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> D;
    vector<string> table;
    for(int i = 0; i < N; i++)
    {
        string s; cin >> s;
        table.push_back(s);
    }
    cout << solve(table) << endl;
    return 0;
}




Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,vector<int>> friends,block;
void dfs(int i,unordered_map<int,int> &blocked,vector<int> &visited,vector<int> &component)
{
    visited[i]=1;
    component.push_back(i);
    for(auto it:block[i])
    {
        blocked[it]++;
    }
    for(auto it:friends[i])
    {
        if(!visited[it])
        dfs(it,blocked,visited,component);
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m,k;
  cin>>n>>m>>k;
  for(int i=0;i<m;i++)
  {
      int x,y;
      cin>>x>>y;
      friends[x].push_back(y);
      friends[y].push_back(x);
  }
  for(int i=0;i<k;i++)
  {
      int x,y;
      cin>>x>>y;
      block[x].push_back(y);
      block[y].push_back(x);
  }
  vector<int> visited(n+1,0);
  vector<int> ans(n+1);
  for(int i=1;i<=n;i++)
  {
      if(visited[i])
      continue;
      vector<int> component;
      unordered_map<int,int> blocked;
      dfs(i,blocked,visited,component);
      for(auto it:component)
      {
        ans[it]=(component.size()-friends[it].size()-blocked[it]-1);
      }
  }
  for(int i=1;i<=n;i++)
  cout<<ans[i]<<" ";
  return 0;
}


Measured memory_bytes: 23972
#include<stdio.h>
#define max 10000
#define NUL -1

struct Node{
  int h, l, e;
};

struct Node T[max];
int n;
void preParse(int ne){
  if (ne==NUL) return;
  printf(" %d", ne);
  preParse(T[ne].l);
  preParse(T[ne].e);
}
void inParse(int ne){
  if (ne==NUL) return;
  inParse(T[ne].l);
  printf(" %d",ne);
  inParse(T[ne].e);
}
void postParse(int ne){
  if (ne==NUL) return;
  postParse(T[ne].l);
  postParse(T[ne].e);
  printf(" %d", ne);
}

int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for (i=0;i<n;i++ ) {
    T[i].h=NUL;
  }

  for (i=0;i<n;i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l=l;
    T[v].e=r;
    if (l!=NUL){
      T[l].h=v;}
    if (r!=NUL){
      T[r].h=v;}
  }

  for ( i=0;i<n;i++ ) {
    if(T[i].h== NUL) {
      root = i;}
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<"x";
    }
    cout<<endl;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;


typedef unsigned long long int ll; 


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

int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll lcm=a[0];
    for(int i=1;i<n;i++){
        lcm= ( (lcm/findGCD(lcm,a[i])*a[i]));
    }
    cout<<lcm;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 1 5 2 4");
            //YES
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 7 6 4 5");
            //NO
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("48792 105960835 681218449 90629745 90632170");
            //NO
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("491995 412925347 825318103 59999126 59999339");
            //YES
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long N = wkArr[0];
        long A = wkArr[1];
        long B = wkArr[2];
        long C = wkArr[3];
        long D = wkArr[4];

        bool IsOK = false;

        //+の数でループ
        for (int I = 0; I <= N - 2; I++) {
            long MinusCnt = N - 1 - I;

            long MinVal = A + C * I - D * MinusCnt;
            long MaxVal = A + D * I - C * MinusCnt;

            //Console.WriteLine("+が{0}個で、-が{1}個での最小値={2}", I, MinusCnt, MinVal);
            //Console.WriteLine("+が{0}個で、-が{1}個での最大値={2}", I, MinusCnt, MaxVal);

            if (MinVal <= B && B <= MaxVal) {
                IsOK = true;
                break;
            }
        }
        Console.WriteLine(IsOK ? "YES" : "NO");
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(){
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);
        if(A<6){
                printf("0\n");
            }else if(A<13){
                    printf("%d\n",(B/2));
                }else{
                        printf("%d\n",B);
                    }
                    return 0;
    }


Measured memory_bytes: 128
N,M=map(int,input().split())
G=[0]*(N+2)
for i in range(M):
    L,R=map(int,input().split())
    G[L]+=1
    G[R+1]-=1
GG=[0]*(N+2)
tmp=0
for i in range(N+2):
    tmp+=G[i]
    GG[i]=tmp
ans=GG.count(M)
print(ans)

Measured memory_bytes: 7920
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e3+5, P = 1e9+7;
int n, m, nxt[N<<1], to[N<<1], h[N], tot, s[N]; i64 f[N][N], g[N];
void add(int x, int y) { nxt[++tot] = h[x], to[tot] = y, h[x] = tot; }
void dfs(int x, int fa)
{
    f[x][s[x]=1] = 1;
    for(int i = h[x], y; i; i = nxt[i]) if((y = to[i]) != fa)
    {
        dfs(y, x); static i64 g[N];
        for(int i = 1; i <= s[x]; ++i) g[i] = f[x][i], f[x][i] = 0;
        for(int i = 1; i <= s[x]; ++i) for(int j = 0; j <= s[y]; ++j)
            f[x][i+j] = (f[x][i+j]+g[i]*f[y][j]%P)%P;
        s[x] += s[y];
    }
    for(int i = 1; i <= s[x]; ++i) (f[x][0] += P-f[x][i]*g[i]%P) %= P;
}
int main()
{
    n = read(); g[0] = 1; for(int i = 2; i <= n; i += 2) g[i] = g[i-2]*(i-1)%P;
    for(int i = 1, x, y; i < n; ++i) x = read(), y = read(), add(x, y), add(y, x);
    dfs(1, 0), printf("%lld\n", (P-f[1][0])%P);
    return 0;
}

Measured memory_bytes: 194944