akhauriyash/Code-Regression huggingface dataset:
using System;
using System.CodeDom;
using System.Linq;
using System.Text;

namespace paizaTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var line = string.Empty;
            while ((line = Console.ReadLine()) != "0 0")
            {
                var result = line.Split(' ').Select(int.Parse).OrderBy(x => x).Select(x => x.ToString()).ToArray();

                Console.WriteLine(string.Join(" ", result));
            }
        }
    }
}

Measured memory_bytes: 10292
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        // assume that n > 0 && n <= N
        map<int, int> factors(int n) {
            // assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (is_prime(i)) {
                    p.push_back(i);
                }
            }
        }

        // assume that n > 0 && n <= N
        bool is_prime(const int n) {
            // assert(n > 0 && n <= N);
            return numbers[n] == n;
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

const int MAX_N = 1000;

// {number, count}
map<int, int> m;

vector<int> acc;

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

    EratosthenesSieve *sieve = new EratosthenesSieve(MAX_N);
    for (int i = 2; i <= N; i++) {
        auto facts = sieve->factors(i);
        for (auto &p : facts) {
            m[p.first] += p.second;
        }
    }
    // for (auto &p : m) {
    //     printf("%d: %d\n", p.first, p.second);
    // }
    // printf("\n");

    // preapre acc
    acc.resize(100 + 1, 0);
    for (auto &p : m) {
        acc[p.second]++;
    }
    for (int i = 100; i > 0; i--) {
        acc[i - 1] += acc[i];
    }
    // for (int i = 0; i < (int) acc.size(); i++) {
    //     printf("%d: %d\n", i, acc[i]);
    // }
    // printf("\n");

    int ans = 0;
    // ans += max(0, (acc[1 - 1] - 1) * acc[75 - 1]);
    ans += acc[75 - 1];
    ans += max(0, (acc[3 - 1] - 1) * acc[25 - 1]);
    ans += max(0, (acc[5 - 1] - 1) * acc[15 - 1]);
    ans += max(0, (acc[3 - 1] - 2) * acc[5 - 1] * (acc[5 - 1] - 1) / 2);

    cout << ans << endl;

    delete sieve;
    return 0;
}


Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[100005]={},b[100005]={},c[100005]={},ans=0,x,y;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    cin >> c[i];
  }
  sort(a,a+n);
  sort(c,c+n);
  for(int i=0; i<n; i++) {
    x=lower_bound(a,a+n,b[i])-a;
    y=c+n-upper_bound(c,c+n,b[i]);
    ans+=x*y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
import itertools
N,x = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
ans = 0
for i in range(0,N-1):
    l = As[i]
    r = As[i+1]
    diff = max((r+l) - x,0)
    if diff >= r:
        ans += r

        diff -= r
        As[i + 1] = r = 0
        ans += diff

    else:
        r -= diff
        As[i + 1] = r
        ans += diff

print(ans)






Measured memory_bytes: 14428
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          #define pb push_back
          #define ll long long
          #define ld long double
          bool mysort(pair<int,int> &a,pair<int,int> &b)
          {
               return a.ss < b.ss;
          }
          int main()
          {
               tani_nachi_ke  

               int n;
               cin >> n;
               vector<pair<int,int>> bin;
               for(int i = 0; i < n; i++)
               {
                    int x,l;
                    cin >> x >> l;

                    bin.push_back({x-l,x+l});
               }
               sort(bin.begin(),bin.end(),mysort);

               int k = 0;
               int r = -1e9 - 7;
               for(auto u:bin)
               {
                    // cout << u.ff << " " << u.ss << endl;
                    if(u.ff >= r)
                    {
                         k++;
                         r = max(r,u.ss);
                    }

               }
               cout << k << endl;



         
               return 0;
          }

Measured memory_bytes: 1400
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    vector<int>a(N);
    rep(i,N)cin>>a[i];
    sort(a.begin(),a.end());
    int first=a[0],last=a[N-1];
    ll mn=1e+9+7;
    ll ans;
    for(int i=a[0];i<=a[N-1];i++){
        ans=0;
        for(int j=0;j<N;j++){
            ans+=(i-a[j])*(i-a[j]);
        }
        mn=min(mn,ans);
    }
    cout<<mn<<endl;
}

Measured memory_bytes: 256
class Node:
    def __init__(self, val=None):
        self.l = None
        self.r = None
        self.p = None
        self.v = val

    def insert(self, val):
        if self.v is None:
            self.v = val
            return
        n = Node(val)
        cur_node = self
        prev_node = None
        while cur_node:
            prev_node = cur_node
            if val < prev_node.v:
                cur_node = prev_node.l
            else:
                cur_node = prev_node.r
        if prev_node is None:
            self.v = n.v
        else:
            if val < prev_node.v:
                prev_node.l = n
            else:
                prev_node.r = n

    def __str__(self):
        return str(self.v)

    def preorder(self):
        if self.v:
            print(' {0}'.format(self.v), end='')
        if self.l:
            self.l.preorder()
        if self.r:
            self.r.preorder()

    def inorder(self):
        if self.l:
            self.l.inorder()
        if self.v:
            print(' {0}'.format(self.v), end='')
        if self.r:
            self.r.inorder()


M = int(input())
tree = Node()
for _ in range(M):
    line = input().strip()
    if line == 'print':
        tree.inorder()
        print('')
        tree.preorder()
        print('')
    else:
        inst, k = line.split()
        k = int(k)
        if inst == 'insert':
            tree.insert(k)
        elif inst == 'find':
            pass
        elif inst == 'delete':
            pass

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


#define file "file"
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef complex<double> point;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define DEBUG 0
#define dout if(DEBUG) cout

const int MAXN = 300 + 5;

int a[MAXN][MAXN];
bool bad[MAXN];
int cnt[MAXN];
int n, m;

bool good(int lim){
    for(int i = 1; i <= m; i++){
        bad[i] = 0;
        cnt[i] = 0;
    }
    for(int ii = 1; ii < m; ii++){
        bool fl = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(bad[a[i][j]]) continue;
                cnt[a[i][j]]++;
                if(cnt[a[i][j]] > lim){
                    bad[a[i][j]] = 1;
                    fl = 1;
                }
                break;
            }
            if(fl) break;
        }
        if(fl){
            for(int i = 1; i <= m; i++) cnt[i] = 0;
        }
        else return true;
    }
    return false;
}

void solve(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }

    int lf = 1, rg = n;
    while(lf + 1 < rg){
        int md = (lf + rg) >> 1;
        if(good(md)) rg = md;
        else lf = md;
    }
    int ans = lf;
    if(!good(ans)) ans = rg;
    cout << ans;
}

int main() {
    #ifdef NASTYA
        assert(freopen("input.txt", "r", stdin)); assert(freopen("output.txt", "w", stdout));
    #else
    // assert(freopen(file".in", "r", stdin)); assert(freopen(file".out", "w", stdout));
    #endif
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;//DFS

const int nmax = 8;
bool graph[nmax][nmax];//globalで持つ　→　関数内で使える

int dfs (int now, int n, vector<bool> visited) {
    bool all_visited = true;
    for (int i=0; i<n; i++) {
        if (visited[i] == false) all_visited = false;
    }
    if (all_visited) return 1;
    int sum = 0;
    for (int i=0; i<n; i++) {
        if (graph[now][i] == false) continue;
        if (visited[i]) continue;
        visited[i] = true;
        sum += dfs(i, n, visited);
        visited[i] = false;
    }
    return sum;
}

int main() {
    int n, m; cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a][b] = graph[b][a] = true;
    }
    vector<bool> visited(n, false);
    visited[0] = true;
    cout << dfs(0, n, visited) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 100100100;

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

  ll ans = 0;
  if(n <= m/2){
    ans += n;
    m -= n*2;
    ans += m/4;  
  }else if(n > m/2){
    ans += m/2;
  }
  cout << ans << endl;
}


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

int main() {
  
  int x[5];
  
  for(int i = 0; i < 5; i++){
    cin >> x[i];
  }
  
  for(int i = 0; i < 5; i++){
    if(x[i] == 0){
      cout << i + 1 << endl;
    }
  }

}


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

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int arr[n];
	double total = 0;
	int i;
	for(i = 0 ; i < n ; i ++){
		scanf("%d",&arr[i]);
		total += arr[i];
	}
	total = (double)total / (4*m);
	int flag = 0;
	for(i = 0 ; i < n ; i ++){
		if(arr[i]>=total)
			flag ++;
		if(flag == m)
			break;
	}
	if(flag  == m)
		printf("Yes");
	else
		printf("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
		
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n + 2);
	a[0] = a[n + 1] = 0;
	long long sum = 0;
	for(int i = 1; i < n + 1; i++) {
		cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
		if(i == n) {
			sum += abs(a[i + 1] - a[n]);
		}
	}
	for(int i = 1; i < n + 1; i++) {
		long long tmp = sum;
		tmp -= abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1]);
		tmp += abs(a[i + 1] - a[i - 1]);
		cout << tmp << '\n';
	}
	return 0;
}	


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

int main(){
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    S += S;
    static int nxt[200001][26], now[26];
    for(int k=0; k<26; k++) now[k] = -1;
    for(int i=2*N; i>=0; i--){
        for(int k=0; k<26; k++) nxt[i][k] = now[k];
        if(i) now[S[i-1]-'a'] = i;
    }
    int64_t num = 0;
    for(char c : T){
        int i = num%N;
        c -= 'a';
        if(nxt[i][c] == -1){
            cout << -1 << endl;
            return 0;
        }else{
            num += nxt[i][c] - i;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 21120
X[]={1,0,-1,0},Y[]={0,1,0,-1},s[11][11];char *D="RDLU";
main(x,y,i,j,z){
	x=y=5;
	for(j=0;j<2*y;j++)for(i=0;i<2*x;i++)s[i][j]=0;
	for(j=1;j<2*y;getchar(),j++)for(i=(j&1)?2:1;i<2*x;i+=2)s[i][j]=getchar()-'0';
	putchar('R');
	for(z=0,x=3,y=1;x!=1||y!=1;){
		z=(z+3)%4;
		for(;!s[x+X[z]][y+Y[z]];z=(z+1)%4);
		x+=X[z]*2,y+=Y[z]*2;
		putchar(D[z]);
	}
	puts("");exit(0);
}

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

int main(){// N個の要素を含む0-オリジンの配列A
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i]; 
    for(int i=0;i<N;i++){
        int v = A[i];
        int j = i;
        while(j>=1&&A[j-1]>v){
            A[j] = A[j-1];
            j--;
            A[j] = v;
        }
        for(int k=0;k<N-1;k++) cout << A[k] << " ";
        cout << A[N-1] << endl;
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct Fordfulkerson{
#define MAX_V 55
  int INF = 1 << 28;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };
  
  vector<vector<edge> > G;
  vector<int> used;
  
  Fordfulkerson(){}
  Fordfulkerson(int V){init(V);}
  
  void init(int V){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    used.clear();
    G.resize(V);
    used.resize(V);
  }
  
  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
 
  int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0 ){
	int d=dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap-=d;
	  G[e.to][e.rev].cap+=d;
	  return d;
	}
      } 
    }
    return 0;
  }
 
  int max_flow(int s,int t){
    int flow=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,INF);
      if(f==0) return flow;
      flow+=f;
    }
  }
};
signed main(){
  int V,E;
  cin>>V>>E;
  Fordfulkerson ford(V);
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    ford.add_edge(u,v,c);
  }
  cout<<ford.max_flow(0,V-1)<<endl;
  return 0;
}

/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/

Measured memory_bytes: 3180
#include <cmath>
#include <random>
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

const int maxn = 65;
const double pi = acos(-1.0);

double x[maxn], y[maxn], c[maxn];
int n, k;

double t[maxn];

inline double sqr(double x){
    return x * x;
}

inline double dist(double x1,double y1,double x2, double y2){
    return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

double calc_time(double c_x,double c_y){
    for (int i = 1;i <= n;i++){
        t[i] = dist(c_x,c_y,x[i],y[i]) * c[i];
    }
    nth_element(t+1,t + k, t+n+1);
    return t[k];
}

double global_ans = 1e15;

void workout(){
    random_device rd;
    mt19937_64 gen(rd());
    uniform_real_distribution<> dis2(-1000, 1000);
    double init_x = dis2(gen);
    double init_y = dis2(gen);

    double radius = 1500;
    double ans = calc_time(init_x,init_y);
       

    //hyperparemeters
    double alpha = 0.965;
    int rounds = 750;
    int randoms = 900;
       
    while (rounds--){
        double best_x = 0;
        double best_y = 0;
        double cur_best = 1e15;
        uniform_real_distribution<> dis(-radius, radius);
        for (int i = 1;i <= randoms;i++){
            double nx = init_x + dis(gen);
            double ny = init_y + dis(gen);
            double score = calc_time(nx, ny);
            if (score < cur_best){
                cur_best = score;
                best_x = nx;
                best_y = ny;
            }
        }
        if (cur_best < ans){
            init_x = best_x;
            init_y = best_y;
            ans = min(ans, cur_best);
        }

        radius *= alpha;
    }
    global_ans = min(global_ans, ans);
}

int main(int argc, const char * argv[]) {
    cin >> n >> k;
    for (int i = 1;i <= n;i++){
        cin >> x[i] >> y[i] >> c[i];
    }
    for (int i=  1;i <= 5;i++){
        workout();
    }
    cout << fixed << setprecision(8);
    cout << global_ans << endl;
    return 0;
}




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

int main(){
  int n; cin >> n;
  vector<int> a;
  long long sum = 0;
  rep(i,n){
    int x; cin >> x;
    a.push_back(x);
    sum += x;
  }

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

  cout << a[0] << " " << a[n-1] << " " << sum << endl;

  return 0;
}



Measured memory_bytes: 3276
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        sc.close();

        long sum = 0;
        for (int a = 1; a <= K; a++) {
            for (int b = 1; b <= K; b++) {
                long tmp = getDualGcb(a, b);
                for (int c = 1; c <= K; c++) {
                    long tmp2 = getDualGcb(tmp, c);
                    sum += tmp2;
                }
            }
        }
        System.out.println(sum);
    }

    public static long getDualGcb(long m, long n) {
        long ret = 0;
        for (long i = m; i >= 1; i--) {
            if (m % i != 0) {
                continue;
            }
            if (n >= i && n % i == 0) {
                ret = i;
                break;
            }
        }
        return ret;
    }
}


Measured memory_bytes: 35592
N,K = map(int,input().split())
S = [tuple(map(int,input().split())) for _ in range(K)]
MOD=998244353
dp=[0]*N
dp[0]=1
for i in range(N-1):
    x = dp[i]
    dp[0]=0
    for k in range(K):
        l,r = S[k]
        if i+l < N:
            dp[i+l]+=x
            dp[i+l]%=MOD
        if i+r+1 < N:
            dp[i+r+1]-=x
            dp[i+r+1]%=MOD
    dp[i+1]+=dp[i]
    dp[i+1]%=MOD
print(dp[-1]%MOD)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll n; cin >> n;
  ll ans = 1;

  ll div = 1000000007;
  for(ll i = 1;i<=n;i++){
    ans *= i;
    ans %= div;
  }

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


Measured memory_bytes: 3596
n,cap=map(int,input().split())
weigh=[]
profit=[]
temp=n
while temp!=0:
    w,p=map(int,input().split())
    weigh.append(w)
    profit.append(p)
    temp-=1

mat=[[0 for i in range(cap+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(1,cap+1):
        if j<weigh[i-1]:
            mat[i][j]=mat[i-1][j]
        else:
            mat[i][j]=max(profit[i-1]+mat[i-1][j-weigh[i-1]],mat[i-1][j])
print(mat[n][cap])


Measured memory_bytes: 171656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
using namespace std;
#define int long long
#define inf 1e9+7
typedef pair<int, int> P;

int pm[114514];
bool lk[114514];
int lk17[114514];

void sosu(int n) {
	for (int i = 0; i <= n; i++)lk[i] = true;
	lk[0] = lk[1] = false;
	for (int i = 2; i <= n; i++) {
		if (lk[i]) {
			for (int j = 2 * i; j <= n; j += i)lk[j] = false;
		}
	}
	return;
}

signed main() {
	int q;
	cin >> q;
	sosu(100005);

	for (int i = 0; i < 100005; i++) {
		if (lk[i])pm[i]++;
		if (i * 2 < 100005 && lk[i])pm[i * 2]++;
	}

	for (int i = 1; i < 100005; i++) {
		if (pm[i] && pm[i + 1]&&(i&1))lk17[i]++;
	}
	for (int i = 0; i < 100005; i++) {
		lk17[i + 1] += lk17[i];
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << lk17[r] - lk17[l - 1] << endl;
	}
}

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

public class App
{
    public static void Main(string[] args)
    {
        int n,m;
        {
            var r = Console.ReadLine().Split();
            n=int.Parse(r[0]);
            m=int.Parse(r[1]);  
        }
            ToggleSwitch[] Switches = new ToggleSwitch[n];
            LightBulb[] LightBulbs = new LightBulb[m];
            for(int i = 0;i < n;i++)
            {
                Switches[i] = new ToggleSwitch(false);
            }
            for(int i = 0;i < m;i++)
            {
                LightBulbs[i] = new LightBulb(Console.ReadLine().Split().Skip(1).Select(v=>Switches[int.Parse(v)-1]).ToArray(),0);
            }
            {
                var r = Console.ReadLine().Split();
                for(int i = 0;i < m;i++)
                {
                    LightBulbs[i].LitConditionModulo = int.Parse(r[i]);
                }
            }
        int PatternCount = 0;
        for(int i = 0;i < 1<<n;i++)
        {
            for(int j = 0;j < n;j++)
            {
                Switches[j].IsON = (i>>j)%2==1;
            }
            if(LightBulbs.All(v=>v.GetLit()))
                PatternCount++;
        }
        Console.WriteLine(PatternCount);
    }
    public class ToggleSwitch
    {
        public ToggleSwitch(bool InitSwitchCondition)
        {
            IsON = InitSwitchCondition;
        }
        public bool IsON;
        public void Invert()
        {
            IsON = !IsON;
        }
    }
    public class LightBulb
    {
        public readonly ToggleSwitch[] DependingSwitch;
        public int LitConditionModulo;
        public LightBulb(ToggleSwitch[] DependingSwitch,int LitConditionModulo)
        {
            if(LitConditionModulo != 0 && LitConditionModulo != 1)
                throw new InvalidOperationException("LitConditionModulo must be 0 or 1");
            this.DependingSwitch = DependingSwitch;
            this.LitConditionModulo = LitConditionModulo;
        }
        public bool GetLit()
        {
            return DependingSwitch.Count(v=>v.IsON)%2==LitConditionModulo;
        }
    }
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    string s[210];
    for (int i = 0;i < n;++i) cin >> s[i];
    vector<vector<int>> G(n,vector<int>(n,1000000));
    vector<int> used(n,-1);
    for (int i = 0;i < n;++i) G[i][i] = 0;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (s[i][j] == '1') G[i][j] = 1;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) for (int k = 0;k < n;++k) G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
    deque<int> que;
    bool ok = true;
    used[0] = 0;
    que.push_back(0);
    while (!que.empty()) {
        int t = que.front();
        que.pop_front();
        for (int i = 0;i < n;++i) if (s[t][i] == '1') {
            if (used[i] < 0) {
                used[i] = used[t]^1;
                que.push_back(i);
            } else if (used[i] == used[t]) ok = false;
        }
    }
    if (ok) {
        int ans = 0;
        for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (G[i][j] < 1000000) ans = max(ans,G[i][j]);
        cout << ans+1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    ll ans = k;
    printf("%lld\n", (ll)(ans*pow(k-1, n-1)));
    return 0;
}


Measured memory_bytes: 4076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(rbegin(h), rend(h));
    for(int i = k; i < n; i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int inf=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > p;

int n,r;
void solve() {
    vector<int> hana;
    for(int i=n;i>=1;i--) hana.pb(i);
    rep(i,r) {
        int p,c;
        cin>>p>>c;
        vector<int> tmp;
        for(int i=0;i<p-1;i++) tmp.pb(hana[i]);
        for(int i=0;i<c;i++) hana[i] = hana[i+p-1];
        for(int i=c;i<c+p-1;i++) hana[i]=tmp[i-c];
        //rep(i,hana.size()) cout<<hana[i]<<" ";
        //cout<<endl;
    }
    cout<<hana[0]<<endl;
}
int main() {
    while(cin>>n>>r) {
        if(n+r==0) break;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(){
    string first, str1;
    int m, h;
    while (1){
        cin >> first;
        if (first == "-") break;
        else{
            cin >> m;
            for (int i=0; i<m; i++){
                cin >> h;
                str1 = first.substr(0,h);
                first.erase(0,h);
                first.insert(first.size(), str1);
            }
        }
        cout << first << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>

using namespace std;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if(a+b >= x)
    {
        if(a > x)
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
    }
    else
    {
        cout << "NO";
    }
    return 0;
}


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

using namespace std;

int a[10010];
int pic[110][110];

int main()
{
    int H,W,N;
    int i,j,k=0;
    memset(a,0,sizeof(a));
    scanf("%d%d%d",&H,&W,&N);
    for(i=0;i<N;++i)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<H;++i)
    {
        if(i%2==0)
        {
            for(j=0;j<W;++j)
            {
                pic[i][j]=k+1;
                --a[k];
                if(a[k]==0)++k;
            }
        }
        if(i%2==1)
        {
            for(j=W-1;j>=0;--j)
            {
                pic[i][j]=k+1;
                --a[k];
                if(a[k]==0)++k;
            }
        }
    }
    for(i=0;i<H;++i)
    {
        for(j=0;j<W;++j)
        {
            printf("%d",pic[i][j]);
            if(j==W-1)printf("\n");
            else printf(" ");
        }
    }
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int n;
	scanf("%d", &n);
	vector <int> a(n), b(n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n) scanf("%d", &b[i]);
	ll tot = 0;
	rep(i, n) tot += b[i] - a[i];
	ll req = 0;
	rep(i, n) if (a[i] < b[i])
		req += (b[i] - a[i] + 1) >> 1;
	puts(tot >= req ? "Yes" : "No");
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<long> v(m);
  unordered_map<int, int> prefectures;
  rep(i, m) {
    long p, y;
    cin >> p >> y;
    v[i] = (p << 32) | y;
    prefectures[p]++;
  }

  vector<long> sorted_v(v);
  sort(sorted_v.begin(), sorted_v.end());

  rep(i, m) {
    const long p = v[i] >> 32;
    if (prefectures[p] == 1) {
      printf("%06ld000001\n", p); 
      continue;
    }
    auto it1 = lower_bound(sorted_v.begin(), sorted_v.end(), p << 32);
    auto it2 = lower_bound(sorted_v.begin(), sorted_v.end(), v[i]);
    auto d = distance(it1, it2);
    printf("%06ld%06ld\n", p, d + 1); 
  }
  return 0;
}


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

int main(){
    unsigned n,q,*S,*T;
    unsigned count=0;

    cin >> n;
    S = new unsigned[n+1];
    for(int i=0;i<n;i++)
        cin >> S[i];

    cin >> q;
    T = new unsigned[q];
    for(int i=0;i<q;i++)
        cin >> T[i];

    for(int i=0;i<q;i++){
        S[n] = T[i];
        for(int j=0;;j++){
            if(T[i]==S[j]){
                if(j!=n)
                    count++;
                break;
            }
        }
    }

    cout << count << endl;

    delete[] S;
    delete[] T;
    return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <functional>
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N, a[110], i, j, S1, S2;
  	S1=0;
  	S2=0;
  	cin >> N;
  	for(i=0;i<=N;i++) cin >> a[i];
  	
  	sort(a,a+N,greater<int>());
	
  	for(j=0;j<N;j++){
      if(j%2==1){
    	S1+=a[j];
      }else{
      	S2+=a[j];
      }
    }
  
  	cout << S2-S1<< endl;
 
}

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

using namespace std;
int main(void)
{
   string s;

   cin >> s;

   int a_index = 0;
   for (int i = 0; i < s.size(); i++) {
       if (s[i] == 'A') {
           a_index = i;
           break;
       }
   }

   int z_index = 0;
   for (int i = s.size() - 1; i >= 0; i--) {
       if (s[i] == 'Z') {
           z_index = i;
           break;
       }
   }

   cout << z_index - a_index + 1 << endl;

   return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int S; cin>>S;
  int a=S/100, b=S-a*100;
  bool yymm=1, mmyy=1;
  if(a<1 || a>12 ){
    mmyy=0;
  }
  if(b<1 || b>12){
    yymm=0;
  }
  string ans;
  if(mmyy && yymm){
    ans="AMBIGUOUS";
  }
  else if(mmyy){
    ans="MMYY";
  }
  else if(yymm){
    ans="YYMM";
  }
  else{
    ans="NA";
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, x;
int b[100005], lo[100005], hi[100005];
LL gain[100005];
pair<LL, int> ord[100005];
LL need;

LL getPart(int ind, int part) {
    if (part <= b[ind]) {
        return (LL)lo[ind] * part;
    }
    return (LL)lo[ind] * b[ind] + (LL)hi[ind] * (part - b[ind]);
}

int main() {
    scanf("%d%d", &n, &x);
    forn(i, n) {
        scanf("%d%d%d", b + i, lo + i, hi + i);
    }
    need = 0;
    forn(i, n) {
        need += (LL)lo[i] * b[i];
        gain[i] = (LL)lo[i] * b[i] + (LL)hi[i] * (x - b[i]);
    }
    forn(i, n) {
        ord[i] = mp(gain[i], i);
    }
    sort(ord, ord + n);
    reverse(ord, ord + n);
    LL lo = 0;
    LL hi = (LL)x * n;
    while (lo < hi) {
        LL mid = (lo + hi) / 2;
        int whole = mid / x;
        int part = mid % x;
        LL got = 0;
        forn(i, whole) {
            got += ord[i].first;
        }
        LL mx = got;
        if (part > 0) {
            forn(i, whole) {
                mx = max(mx, getPart(ord[i].second, part) + got - ord[i].first + ord[whole].first);
            }
            for (int i = whole; i < n; ++i) {
                mx = max(mx, getPart(ord[i].second, part) + got);
            }
        }
        if (mx >= need) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    cout << lo << endl;
    return 0;
}


Measured memory_bytes: 3712
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

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


int main() {
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for(int i = 0; i < H; i++)
		cin >> a[i];
	vector<string> ans[2];

	for(int i = 0; i < H; i++) {
		string s[2];
		s[0] = s[1] = "";
		for(int j = 0; j < W; j++) {
			s[i%2] += "#";
			s[!(i%2)] += ".";
		}
		s[0][0] = '#';
		s[1][0] = '.';
		s[1][W-1] = '#';
		s[0][W-1] = '.';
		ans[0].push_back(s[0]);
		ans[1].push_back(s[1]);
	}

	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(a[i][j] == '#') {
				if(ans[0][i][j] == '.')
					ans[0][i][j] = '#';
				if(ans[1][i][j] == '.')
					ans[1][i][j] = '#';
			}
		}
	}

	for(int i = 0; i < 2; i++) {
		if(i) cout << endl;
		for(int j = 0; j < H; j++) {
			cout << ans[i][j] << endl;
		}
	}
}


Measured memory_bytes: 1536
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 200001
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
LL ans,sum;
int top,num[N],val[N];
int n,a[N];
int main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	for(int i=1;i<=n;++i)
	{
		int now=1;
		while(a[i]<=val[top])
			sum-=1ll*num[top]*val[top],now+=num[top--];
		sum+=1ll*now*a[i];
		num[++top]=now;
		val[top]=a[i];
		ans+=sum; 
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N, K = imn()
A = iln()

la = len(A)
cnt = 0

# 1個のブロック内の転倒数を求める
cnt1 = 0
for i in range(la):
    for j in range(i+1, la):
        if A[i] > A[j]:
            cnt1 += 1

# ブロック間の転倒数を求める
cnt2 = 0
for i in range(la):
    for j in range(la):
        if A[i] > A[j]:
            cnt2 += 1
ans = cnt1*K
ans += cnt2*(K-1)*K//2
    
print(ans%MOD)

Measured memory_bytes: 5552
#include <iostream>
#include <vector>
#include <bitset>
#define N 1005
using namespace std;
int n, s, x[N], y[N];
vector<int> a[N];
bitset<1<<20> bs;

int main() {
	int i, j, t;
	cin>>n;
	for(i=2; i<=n; i++) cin>>t, a[t].push_back(i);
	for(i=1; i<=n; i++) cin>>x[i];
	for(i=n; i>=1; i--) {
		bs = 1;
		s = 0;
		for(j=0; j<a[i].size(); j++) {
			t = a[i][j];
			bs = bs<<x[t] | bs<<y[t];
			s += x[t] + y[t];
		}
		for(j=x[i]; j>=0 && !bs[j]; j--);
		if(j<0) {cout<<"IMPOSSIBLE"; return 0;}
		else y[i] = s - j;
	}
	cout<<"POSSIBLE";
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 3000+1;
ll memo[maxn][maxn][2];
int seen[maxn][maxn][2];
int N,A[maxn];

ll dp(int i,int j,int cnt){
	if(i == j){
		if(!cnt)return A[i];
		else return -A[i];
	}
	ll &res = memo[i][j][cnt];
	if(seen[i][j][cnt])return res;
	seen[i][j][cnt] = 1;
	if(cnt == 0){
		res = max(A[i]+dp(i+1,j,!cnt),A[j]+dp(i,j-1,!cnt));
	}else{
		res = min(-A[i]+dp(i+1,j,!cnt),-A[j]+dp(i,j-1,!cnt));
	}
	return res;
}


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,maxn)forn(k,0,2){
		memo[i][j][k] = 0;
		seen[i][j][k] = 0;
	}
	cin >> N;
	forn(i,0,N)cin >> A[i];
	cout << dp(0,N-1,0) << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 211584
#include <iostream>
#include <list>

using namespace std;
int main()
{
    long N;
    long K;
    list<long> H;
    cin >> N >> K;
    
    for(long i=0;i<N;i++){
        long tmp;
        cin >> tmp;
        H.push_back(tmp);
    }
    H.sort();
    long result=0;
    list<long>::iterator it = H.begin();

    if(N>K){
    for(long i=0;i<(N-K);i++){
        result +=(*it);
        ++it;
        
    }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	Yn(a<b&&b<c);
}




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

int main(){
	int a[4][13];
	for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
			a[i][j] = 0;
		}
	}
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		char c;
		int num;
		cin >> c >> num;
		if(c=='S') a[0][num-1] = 1;
		if(c=='H') a[1][num-1] = 1;
		if(c=='C') a[2][num-1] = 1;
		if(c=='D') a[3][num-1] = 1;
	}
	for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
			if(a[i][j]==0){
				if(i==0) cout << "S " << j+1 << endl;
				if(i==1) cout << "H " << j+1 << endl;
				if(i==2) cout << "C " << j+1 << endl;
				if(i==3) cout << "D " << j+1 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
   	int N;
    ll H;
    cin >> N >> H;
    ll bmax = 0;
    vector<ll> a(N);
    ll b;
    for(int i = 0; i < N; i++){
        cin >> b >> a[i];
        bmax = max(bmax, b);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll cnt = 0;
    int s = 0;
    while(H > 0){
        if(a[s] >= bmax){
            H -= a[s++];
            cnt++;
        }else{
            break;
        }
    }
    while(H > 0){
        H -= bmax;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,x; cin >> N >> x;
  v<int> a(N);
  rep(i,N) cin >> a[i];
  int ans=0;
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  }
  for(int i=1;i<N;i++){
    int num=a[i-1]+a[i];
    if(num>x){
      if(a[i]>=num-x){
        ans+=num-x;
        a[i]-=num-x;
      }
      else{
        ans+=num-x;
        a[i]=0;
        a[i-1]-=num-x-a[i];
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/*	AtCoder 2171 Shik and Game
    1st Edition:2017.11.25 Saturday
    Algorithm:DP,╣╔╣В╤сап
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cctype>
using namespace std;

#define For(a,b,c) for(int (a)=(b);(a)<=(c);++a)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define shl(x,y) ((x)<<(y))
#define shr(x,y) ((x)>>(y))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;
const ll inf=2000000007LL;
const double EPS=1e-10;
const ll inf_ll=(ll)1e18;
const ll maxn=100005LL;
const ll mod=1000000007LL;

//input
int n;
ll T,E;
ll x[maxn];

void input(){
	scanf("%d%lld%lld",&n,&E,&T);
	For(i,1,n) scanf("%lld",x+i);
}

//DP
ll f[maxn];

void dp_init(){
	f[0]=0;
	For(i,1,n) f[i]=inf_ll;
}

void dp_test(){
	puts("\ndp tests begin");
	For(i,1,n) printf("%d ",f[i]);
	puts("");
	puts("dp tests end\n");
}

void dp_main(){
	dp_init();
	int divl=0;
	ll min2=inf_ll;
	if(x[1]*2>T) min2=0;
	For(i,1,n){
		min2+=2*(x[i]-x[i-1]);
		while(divl<i && 2*(x[i]-x[divl+1])>T){
			min2=min(min2,f[divl]+(x[i]-x[divl+1])*2);
			++divl;
		}
//		printf("%d %lld %lld\n",divl,f[divl]+T,min2);
		f[i]=min(min2,f[divl]+T);
	}
	printf("%lld\n",E+f[n]);
//	dp_test();
}

//main
int main(){
	input();
	dp_main();
	return 0;
}

/*
3 9 1
1 3 8

3 9 3
1 3 8

2 1000000000 1000000000
1 999999999

*/


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
# abc149/abc149_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S, T = i2s().split(' ')
    print(T+S)
    return

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,SUM=0;cin>>K;
  for(int a=1;a<=K;a++)
    for(int b=1;b<=K;b++)
      for(int c=1;c<=K;c++)
        SUM+=__gcd(a,__gcd(b,c));
  cout<<SUM<<endl;     
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	void solve(){



		ins(morty);
		FOR(i,0,morty.size()){
			if(morty[i] == '?'){
				morty[i] = 'D';
			}
		}
		out(morty);







	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3696