akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
int main(){
  int N,K,i,d,j,t;
  std::cin>>N>>K;
  std::vector<int> S(N,0);
  for(i=0;i<K;i++){
    for(j=d=0,std::cin>>d;j<d;j++){
      std::cin>>t;
      S[t-1]++;
    }
  }
  t=0;
  for(i=0;i<N;i++){
    if(S[i]==0){
      t++;
    }
  }
  std::cout<<t<<std::endl;
}

Measured memory_bytes: 3584
/* 
 * Author: aps
 * Time: 19-06-2019 00:54:25
**/
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll inf = 1e18;
const ll mod = 1e9+7;

inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

const int N = 1e5+5;

ld x[N],y[N];
char dir[N];
int n;

ld f(ld t){
    ld xmin = INT_MAX, xmax = INT_MIN, ymin = INT_MAX, ymax = INT_MIN;
    for(int i=0;i<n;i++){
        ld cx = x[i], cy = y[i];
        if(dir[i] == 'U') cy += t;
        if(dir[i] == 'D') cy -= t;
        if(dir[i] == 'R') cx += t;
        if(dir[i] == 'L') cx -= t;
        
        xmin = min(xmin,cx);
        xmax = max(xmax,cx);

        ymin = min(ymin,cy);
        ymax = max(ymax,cy);
    }
   return (ymax-ymin)*(xmax-xmin); 
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i] >> dir[i];
    }

    ld l = 0.0, r = 1e9;
    for(int i=0;i<300;i++){
        ld m1 = l + (r-l)/3.0;
        ld m2 = r - (r-l)/3.0;
        
        if(f(m1) < f(m2)){
            r = m2;
        } else {
            l = m1;
        }
    }

    cout << fixed << setprecision(9) <<  f(l) << endl;


    return 0;
}


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

int A[1000000], n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}

	int q, k, sum = 0;
	cin >> q;
	for (int i = 0; i < q; i++) {
		scanf("%d", &k);
		if (*lower_bound(A, A + n, k) == k) sum++;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3652
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,d,l;
	while(cin>>n>>d>>l,n){
		vi in(n+d+1);
		rep(i,n){
			int a;cin>>a;
			if(a>=l){
				in[i]++;
				in[i+d]--;
			}
		}
		rep(i,n+d)in[i+1]+=in[i];
		int out=0;
		rep(i,n-1)if(in[i])out++;
		cout<<out<<endl;
	}
}







Measured memory_bytes: 4284
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))

qw=0
for i in range(n):
    ans=c
    for j in range(m):
        ans+=(b[j]*a[i][j])
    if ans>0:
        qw+=1

print(qw)


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

using namespace std;

int main(){
    int64_t n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    vector<int> visited(n, -1);
    int cur = 0;
    int cnt = 0;
    while (true){
        cur = A[cur] - 1;
        cnt++;
        if (visited[cur] != -1)
            break;
        if (cnt == k)
            break;
        visited[cur] = cnt;
    }

    k -= visited[cur];
    k %= (cnt - visited[cur]);

    for (int i = 0; i < k; i++){
        cur = A[cur] - 1;
    }

    cout << cur + 1 << endl;
}


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

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n, X, x[100005];
    int dist[100005];

    scanf("%d %d", &n, &X);
    for(int i = 0; i < n; ++i){
        scanf("%d", &x[i]);
        dist[i] = abs_val(x[i], X);
    }

    int ans = ngcd(n, dist);

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2460
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

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

const int MAX_N=1e5+10;

vector <int> G[MAX_N],Main,now;
int col[MAX_N],N;

inline void dfs(int at,int p){
	now.push_back(at);
	if(at==N-1) Main=now;
	for(int i=0;i<G[at].size();i++){
		int to=G[at][i];
		if(to!=p) dfs(to,at);
	}
	now.resize(now.size()-1);
}

inline void color(int at,int p){
	int c=col[at];
	for(int i=0;i<G[at].size();i++){
		int to=G[at][i];
		if(col[to]==-1) col[to]=c;
		if(to!=p) color(to,at);
	}
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for(int i=0;i<MAX_N;i++) col[i]=-1;
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b; cin>>a>>b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}	
	dfs(0,-1);
	for(int i=0;i<(Main.size()+1)/2;i++) col[Main[i]]=1;
	for(int i=(Main.size()+1)/2;i<Main.size();i++) col[Main[i]]=0;
	color(0,-1);
	int sum1=0,sum2=0;
	for(int i=0;i<N;i++) if(col[i]==1) sum1++;
	for(int i=0;i<N;i++) if(col[i]==0) sum2++;
	if(sum1>sum2) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 10488
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, L, Q, x[100100], p[20][100100], r[20][100100];

int main () {
        cin >> N;
        fo(i, 0, N) cin >> x[i];
        cin >> L >> Q;
        fo(i, 0, N) {
                p[0][i] = int(upper_bound(x, x+N, x[i] + L) - x) - 1;
                r[0][i] = int(lower_bound(x, x+N, x[i] - L) - x);
        }
        fo(i, 1, 20) fo(j, 0, N) p[i][j] = p[i-1][p[i-1][j]], r[i][j] = r[i-1][r[i-1][j]];
        fo(z, 0, Q) {
                int a, b, n = 0; cin >> a >> b, a--, b--;
                if (a < b) {
                        for (int i = 20; i--; ) if (p[i][a] < b) {
                                a = p[i][a], n += (1<<i);
                        }
                } else {
                        for (int i = 20; i--; ) if (r[i][a] > b) {
                                a = r[i][a], n += (1<<i);
                        }
                }
                cout << n+1 << endl;
        }
        return 0;
}


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

#define MAXN 200005

using namespace std;
string info[MAXN];
bool comp(string a, string b) {
	return a.length() > b.length();
}
int child[1000010][26];
int cnt[1000010][26];
int main() {
#ifdef orange
    freopen("input.txt", "r", stdin);
#endif

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> info[i];
	int set = 1;
	long long ans = 0;
	sort(info, info + n, comp);
	for (int i = 0; i < n; i++) {
		int curr = 0;
		for (int j = info[i].length() - 1; j >= 1; j--) {
			int next = info[i][j] - 'a';
			if (child[curr][next] == 0)
				child[curr][next] = set++;
			curr = child[curr][next];
		}
		ans += cnt[curr][info[i][0] - 'a'];
		int first[26];
		fill(first, first + 26, info[i].length());
		for (int z = 0; z < info[i].length(); z++) {
			char a = info[i][z];
			if (first[a - 'a'] == info[i].length())
				first[a - 'a'] = z;
		}
		curr = 0;
		for (int j = info[i].length() - 1; j >= 0; j--) {
			for (int z = 0; z < 26; z++) {
				if (first[z] <= j) {
					cnt[curr][z]++;
				}
			}
			int next = info[i][j] - 'a';
			if (child[curr][next] == 0)
				child[curr][next] = set++;
			curr = child[curr][next];
		}
	}
	cout << ans << "\n";
}


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

const long long MOD = 1000000007;
const long long MAX = 1000000;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



void solve(long long X, long long Y){
    if((X+Y)%3 != 0){
        cout << 0 << endl;
        return;
    }
    long long n = (X+Y)/3;
    long long k = X-n;
    cout << COM(n,k) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);

     // 前処理
    COMinit();

    solve(X, Y);
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define fast_cin() ios_base::sync_with_stdio(0); cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = n-1; i>=0 ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define sz(a) int(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(container,it) for(auto it=container.begin();it!=container.end();it++)
#define present(container, element) (container.find(element) != container.end())
#define vpresent(container, element) (find(all(container),element) != container.end()) //for vectors
 
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif*/
    fast_cin();
    int n;cin>>n;
    int x;
    map<int,int>m;
    rep(i,n)
    {cin>>x;
     m[x]=i+1;
    }
   for(int i=1;i<=n;i++)
    cout<<m[i]<<" ";
    return 0;
}

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

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


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int NMAX = 100000 + 5;

vector <int> graph[NMAX];

int queryD[NMAX];
int queryV[NMAX];
int queryC[NMAX];

int color[NMAX];
bool vis[NMAX][11];

queue <pair <int, int> > q;
void bfs(int node, int cl, int maxD) {
    q.push(make_pair(node, maxD));
    vis[node][maxD] = true;

    if (color[node] == 0)
        color[node] = cl;

    while (!q.empty()) {
        pair <int, int> aux = q.front();
        q.pop();

        if (aux.second == 0)
            continue;

        for (auto it: graph[aux.first])
            if (!vis[it][aux.second - 1]) {
                vis[it][aux.second - 1] = true;
                q.push(make_pair(it, aux.second - 1));

                if (color[it] == 0)
                    color[it] = cl;
            }
    }
}

int main()
{
    ios_base :: sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    for (int i = 1; i <= M; ++ i) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int Q = 0;
    cin >> Q;
    for (int i = 1; i <= Q; ++ i)
        cin >> queryV[i] >> queryD[i] >> queryC[i];

    for (int i = Q; i; -- i)
        bfs(queryV[i], queryC[i], queryD[i]);

    for (int i = 1; i <= N; ++ i)
        cout << color[i] << '\n';
    return 0;
}


Measured memory_bytes: 9640
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
pair<ll,pll> dp[3001][3001];
int main()
{
  fast_io
  string s1,s2;
  cin >> s1 >> s2;
  rep(i,0,s1.size())
  {
    rep(j,0,s2.size())
    {
      if(s1[i] == s2[j])
      {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1],mp(1 + dp[i][j].first,mp(i,j)));
      }
      dp[i][j + 1] = max(dp[i][j + 1],mp(dp[i][j].first,mp(i,j)));
      dp[i + 1][j] = max(dp[i + 1][j],mp(dp[i][j].first,mp(i,j)));
    }
  }
  pair<ll,pll> ans = mp(0,mp(0,0));
  rep(i,0,s1.size() + 1)
  {
    rep(j,0,s2.size() + 1)
    {
      ans = max(ans,mp(dp[i][j].first,mp(i,j)));
    }
  }
  string res = "";
  if(ans.first == 0)
  {
    return 0;
  }
  pll cur = ans.second;
  while(cur.F != 0 || cur.S != 0)
  {
    pll prev = dp[cur.F][cur.S].second;
    if(prev == mp(cur.F - 1,cur.S - 1))
    {
      res += s1[cur.F - 1];
    }
    cur = prev;
  }
  reverse(res.begin(),res.end());
  cout << res;
  return 0;
}



Measured memory_bytes: 211328
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    cout << s[i] << t[i];
  }
  cout << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int c = h % a, d = w % b;
	cout << c * w + d * h - c * d << endl;
}


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

using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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 (b<a) { a=b; return true; } return false; }

vector<ll> dp(200000);

int main(){
	int n;cin>>n;
	dp.assign(200000,INF);
	vector<ll>v(0);
	int i=0,j=1;
	while(pow(6,i)<100000){
		v.pb(pow(6,i));
		i++;
	}
	while(pow(9,j)<100000){
		v.pb(pow(9,j));
		j++;
	}
	i=0;
	dp[0]=0;
	while(i<100000){
		for(auto&x:v){
			if(i+x>100000)continue;
			chmin(dp[i+x],dp[i]+1);
		}
		i++;
	}
	cout<<dp[n]<<endl;
}


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

int main() {
    struct card{
        string mark;
        int number;
    };
    string mark_type[4]= {
        "S","H","C","D"
    };
    int i,j,k,flag=0;
    int n;
    cin >> n;
    card deck[n];
    for(i=0;i<n;i++){
        cin >> deck[i].mark >> deck[i].number;
    }
    for(i=0;i<4;i++){
        for(j=1;j<=13;j++){
            card search = {mark_type[i],j};
            for(k=0;k<n;k++){
                if(search.mark.compare(deck[k].mark)==0&&search.number==deck[k].number) flag =1;
            }
            if(flag==0) {
                cout << search.mark << " " << search.number << endl;
            }
            flag = 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3156
N, M, Q = map(int, input().split())

BCD = [[] for _ in range(N)]
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    BCD[a - 1].append((b - a, c, d))

def search(mi, A):
    if len(A) > N:
        return 0

    ret = 0
    for i in range(1, A[-1] + 1):
        ret = max(ret, search(i, A + (i,)))

    d = len(A)
    for b, c, d in BCD[N - d]:
        if A[-(b + 1)] - A[-1] == c:
            ret += d
    return ret

ans = 0
for i in range(1, M + 1):
    ans = max(ans, search(i, (i,)))
print(ans)


Measured memory_bytes: 9184
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  unsigned long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=105;
const ll mod=1e9+7;

int main(){
	fast;
	ll n,i,j,k,ans=0;
	cin>>n;
	vector<ll> a(n+1),p(n+1);
	for(i=1;i<=n;++i){
		cin>>a[i];
		if(i>1){
			p[i]=p[i-1]+a[i];
		}
		else
		p[1]=a[1];
	}
	ll term;
	p[n]%=mod;
	for(i=1;i<=n;i++){
		p[i]%=mod;
		term=((a[i]*p[n])%mod-(a[i]*p[i])%mod+mod)%mod;
		ans=(ans+term+mod)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 6376
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;
typedef long double ll;

#define PI 3.14159265358979
int main(){
    ll n = 0;
    cin >> n;
    cout << setprecision(10) <<  (ll)2.0*PI*n << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 1010;

int lena,lenb,tr;
string A,B;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	tr=-1;
	cin>>A;
	cin>>B;
	
	lena=A.size(),lenb=B.size();
	
	if(lena > lenb){
		tr = 1;
	}else if(lena < lenb){
		tr = 0;
	}else{
		int t=-1;
		for(int i=0;i<lena;i++){
			if(A[i] < B[i]){
				t = 0;
				break;
			}else if(A[i] > B[i]) {
				t = 1;	
				break;
			}else{
				continue;
			}
		}
		if(t==1) {
			tr = 1;
		}else if(t==0){
			tr = 0;
		}
	}
	if(tr==0){
		printf("LESS\n");
	}else if(tr==1){
		printf("GREATER\n");
	}else{
		printf("EQUAL\n");
	}

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll n;
    cin >> n;
    ll i=26;ll j=1;
    ll c=26;
    while(true){
        if(n<=i)break;
        c*=26;
        i+=c;
        j++;
    }
    i-=c;
    n-=i+1;
    vector<char> ans(j);
    rep(k,j){
        ans[k]=(char)('a'+n%26);
        n/=26;
    }
    reverse(all(ans));
    rep(k,j) cout<<ans[k];
    cout<<endl;
}

Measured memory_bytes: 3616
program bbb
implicit none

integer :: n, i, m, res
integer,allocatable,dimension(:) :: h

read*, n
allocate(h(0:n))
read*, h(1:n)
h(0)=0

res=0
m=h(0)

do i=1,n
if(h(i)>=m) then
res=res+1
m=h(i)
end if
end do

write(*,'(i0)') res

end program

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ull binpowmod(ull x,ull y,ull p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
const ll maxe=1e18+7;
ll dp[401][401];

void solve()
{   
    int n;
    cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];
    for(int i=0;i<=400;++i)
        for(int j=0;j<=400;++j)
            dp[i][j]=maxe;
    for(int l=n-1;l>=0;--l){
        for(int r=l;r<n;++r){
            if(l==r)
                dp[l][r]=0;
            else
            {
                ll cost=0;
                for(int i=l;i<=r;++i)
                    cost+=v[i];
                for(int mid=l;mid<r;++mid){
                    dp[l][r]=min(dp[l][r],dp[l][mid]+dp[mid+1][r]+cost);
                }
            }
        }
    }
    cout<<dp[0][n-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        solve();
}   


Measured memory_bytes: 1536
r,c = map(int,input().split())
box = []
final = 0

for _ in range(r):
    box.append(list(map(int, input().split())))

for i in range(len(box)):
    box[i].append(sum(box[i]))
    count = len(box[i])
    for a in box[i]:
        if count == 1:
            print(a)
        else:
            print(a, end = ' ')
        count -= 1
            

for x in range(c):
    result = 0
    for y in range(r):
        result += box[y][x]
    final += result
    print(result, end = ' ')

print(final)




Measured memory_bytes: 6216
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

#define rep(i, N) for (int i = 0; i < N; i++)

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()



int main() {
	int N;
	cin >> N;
	vector<ll> A(N), B(N),C(N);
	rep(i, N) cin >> A.at(i);
	rep(i, N) B.at(i) = A.at(i) - i - 1;
	sort(all(B));

	int low=0;
	int high = N-1;
	
	auto f = [&](int k) {
		ll sum = 0;
		rep(i, N) sum += abs(B.at(i) - B.at(k));
		return sum;
	};

	C.at(0) = f(0);

	for(int i=1;i<N;i++) {
		C.at(i) =C.at(i-1)+ (i)*(B.at(i) - B.at(i-1))-(N-i)*(B.at(i) - B.at(i - 1));
	}
	cout << *min_element(all(C));

	return 0;
}


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

int main() {
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if((tail+1) == LEN){
    tail = 0;
  } else tail++;
}

P dequeue(){
  P x;
  x = Q[head];
  if((head+1) == LEN){
    head = 0;
  }
  else head++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  c = 0;
  head = 1;
  tail = n+1;
  
  while(1){
    u = dequeue();
    if((u.t-q) > 0){
      u.t -= q;
      enqueue(u);
      elaps+=q;
    }
    else {
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
      c++;
    }
    if(c == n)
      break;
  }
  
  return 0;
}



Measured memory_bytes: 12712
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector< vs32 > t;
int ans = 0;

int num(int x)
{
    int ret = 0;
    while (x)
    {
        ret += x & 1;
        x >>= 1;
    }
    return ret;
}

int ooru(int x, int i)
{
    return (x >> i) & 1;
}

void solve(int m, int N)
{
    rep (i, N)
    {
        if (ooru(m, i) == 1)
        {
            rep (j, N)
            {
                if (j != i && ((ooru(m, j) == 1 && t[i][j] == 0) || (ooru(m, j) == 0 && t[i][j] == 1)))
                {
                    if (num(m) == N) return;
                    solve(m + 1, N);
                    return;
                }
            }
        }
    }

    int tt = num(m);
    ans = MAX(tt, ans);
    if (num(m) == N) return;
    solve(m + 1, N);
}

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

    int N;
    cin >> N;

    t.resize(N, vector<int>(N, -1));

    int A, x, y;
    rep (i, N)
    {
        cin >> A;
        rep (j, A)
        {
            cin >> x >> y;
            --x;
            t[i][x] = y;
        }
    }

    /*rep (i, N)
    {
        rep (j, N)
        {
            if (t[i][j] == -1)
            {
                cout << "x ";
            }
            else
            {
                cout << t[i][j] << " ";
            }
        }
        cout << "\n";
    }*/

    solve(1, N);
    cout << ans << "\n";
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  char s;
  cin >> s;
  if (s - 'a' < 0) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

void mul_matrix_2x2(
  long long int const (&m0)[4],
  long long int const (&m1)[4],
  long long int (&m_out)[4])
{
  m_out[0] = (m0[0] * m1[0]% 1000000007 + m0[1] * m1[2]% 1000000007)% 1000000007;
  m_out[1] = (m0[0] * m1[1]% 1000000007 + m0[1] * m1[3]% 1000000007)% 1000000007;
  m_out[2] = (m0[2] * m1[0]% 1000000007 + m0[3] * m1[2]% 1000000007)% 1000000007;
  m_out[3] = (m0[2] * m1[1]% 1000000007 + m0[3] * m1[3]% 1000000007)% 1000000007;
}

void power_matrix_2x2(
  long long int const (&m0)[4],
  unsigned long long int const n,
  long long int (&m_out)[4])
{
  if (n == 0) {
    m_out[0] = 1;
    m_out[1] = 0;
    m_out[2] = 0;
    m_out[3] = 1;
  } else if (n == 1) {
    m_out[0] = m0[0];
    m_out[1] = m0[1];
    m_out[2] = m0[2];
    m_out[3] = m0[3];
  } else if (n % 2 == 0) {
    long long int tmp_m[4];
    mul_matrix_2x2(m0, m0, tmp_m);
    power_matrix_2x2(tmp_m, n / 2, m_out);
  } else {
    long long int tmp_m_a[4];
    long long int tmp_m_b[4];
    mul_matrix_2x2(m0, m0, tmp_m_a);
    power_matrix_2x2(tmp_m_a, n / 2, tmp_m_b);
    mul_matrix_2x2(m0, tmp_m_b, m_out);
  }
}

unsigned long long int calculate_fibonacci(unsigned long long int n)
{
  long long int const matrix_2x2[4] = {1, 1, 1, 0};
  long long int result_matrix_2x2[4];
  power_matrix_2x2(matrix_2x2, n, result_matrix_2x2);
  return (result_matrix_2x2[2] + result_matrix_2x2[3])% 1000000007;
}


int main() {
  int n, m;
  long long int answer = 1;
  cin >> n >> m;
  int bef = -1;
  for (int i = 0; i < m; ++i) {
    int cur;
    cin >> cur;
    int time = cur - bef;
    bef = cur;
    if (time == 1) {
      cout << 0 << endl;
      return 0;
    }
    answer *= calculate_fibonacci(time-2) % 1000000007;
    answer %= 1000000007;
  }
  int time = n+1 - bef;
  answer *= calculate_fibonacci(time-2) % 1000000007;
  answer %= 1000000007;
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();

        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
            System.out.println(0);
        } else {
            long[] array = {a, b, c};
            Arrays.sort(array);
            System.out.println(array[0] * array[1]);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <set>

int main() {
	int n;
	std::cin >> n;
	std::string command, str;
	std::set<std::string> dic;
	for (int i = 0; i < n; i++) {
		std::cin >> command >> str;
		if (command == "insert") {
			dic.insert(str);
		} else if (command == "find") {
			if (dic.count(str) == 0) {
				std::cout << "no\n";
			} else {
				std::cout << "yes\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 32624
#include<stdio.h>


int main(){
   int i,j;
   int R,L;
   int mod;
  int min_mod = 2018;

  scanf("%d %d", &L, &R);
   
  for(i=L; i<R; i++){
    for(j=i+1; j<=R; j++){
       mod = ((i%2019)*(j%2019)) %2019;
       if(mod < min_mod){
        min_mod = mod;
        if(min_mod == 0){
          printf("%d\n", min_mod);
          return 0;
        }
      }
    }
  }

 printf("%d\n",min_mod);

 return 0;
 
   
}

Measured memory_bytes: 128
#include <iostream>

int rfiguretonum(char r){
	if(r == 'I')return 1;
	if(r == 'V')return 5;
	if(r == 'X')return 10;
	if(r == 'L')return 50;
	if(r == 'C')return 100;
	if(r == 'D')return 500;
	if(r == 'M')return 1000;
	return 0;
}

int main(){
	std::string s;
	while(std::cin >> s, !std::cin.eof()){
		int res = 0;
		for(int i=0;i<s.length()-1;i++){
			if(rfiguretonum(s[i]) < rfiguretonum(s[i+1]))
				res -= rfiguretonum(s[i]);
			else
				res += rfiguretonum(s[i]);
		}
		res += rfiguretonum(s[s.length()-1]);
		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    int cur = 0;
    int ans = 0;
    rep(i, 3) {
        if (s[i] == 'R') {
            cur++;
            ans = max(ans, cur);
        } else {
            cur = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
number = gets.to_i

t1,x1,y1 = 0,0,0

judge = "Yes"

number.times do
  s = gets
  
  t2,x2,y2 = s.split.map(&:to_i)
  t = t2 - t1
  d = (x2 - x1).abs + (y2 - y1).abs
  if d <= t && (t - d).even?
    t1 = t2
    x1 = x2
    y1 = y2
  else
    judge = "No"
    break
  end
end
puts judge

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a != b && b == c) {
    cout << a << endl;
  } else if (a != b && b != c) {
    cout << b << endl;
  } else {
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[100001];
ll minCost(int arr[], int n){
	//base condition
	if(n==1) return 0;
	if(n==0) return INT_MAX;
	if(dp[n]!=-1) return dp[n];
	//choice code
	return dp[n] = min(minCost(arr, n-1) + (ll)abs(arr[n-1]-arr[n-2]), minCost(arr,n-2) + (ll)abs(arr[n-1]-arr[n-3]));
}

int main(){
	memset(dp, -1 ,sizeof(dp));
	int n; cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	ll ans = minCost(arr, n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 int main() {
string s;cin>>s;
   if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(2)!=s.at(1))
     cout<<"Yes";
   else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)&&s.at(2)!=s.at(1))
     cout<<"Yes";
    else if(s.at(0)==s.at(3)&&s.at(2)==s.at(1)&&s.at(0)!=s.at(1))
     cout<<"Yes";
      else
        cout<<"No";
      }
      

Measured memory_bytes: 256
INT_MAX= 100000000
n=int(input())
dp  = [INT_MAX]*(100001)
h=[int(X) for X in input().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):

    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]))

print(dp[n-1])

Measured memory_bytes: 21356
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
a,b,h,m = map(int, input().split())		# 5 7 2

hDeg = (30 * h) + (0.5 * m)
mDeg = (6 * m)


import math

rad = math.radians( abs(hDeg - mDeg) )

p(hDeg, mDeg, rad)

ans = pow( pow(a,2) + pow(b,2) - 2*a*b*math.cos(rad), 1/2)

print(ans)


Measured memory_bytes: 9544
n, p = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a = factorization(p)
ans = 1
for i in a:
    if i[1] >= n:
        ans = ans * i[0]**(i[1]//n)
print(ans)

Measured memory_bytes: 9468
import sys
input = sys.stdin.readline
a, b, c, d = map(int, input().split())

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def calc(x):
    return x-(x//c)-(x//d)+(x//lcm(c,d))

print(calc(b)-calc(a-1))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#define N 1000001
#define M 2000001
#define inf 2147483647
#define int long long
using namespace std;
int n,m,hd[N],t,x,y,z,vis[N],d[N];
int q[N],fst,lst;
struct edge
{
    int to,nt,w;
}e[M];
void add(int u,int v,int w)
{
    e[++t].to=v,e[t].w=w;
    e[t].nt=hd[u],hd[u]=t;
}
bool spfa(int s)
{
    vis[s]=true,q[lst++]=s;
    if(lst==N)lst=0;
    while(lst!=fst)
    {
        int k=q[fst++];
        if(fst==N)fst=0;
        for(int i=hd[k],kk,w;i;i=e[i].nt)
        {
            kk=e[i].to,w=e[i].w;
            if(vis[kk]){if(d[kk]!=d[k]+w)return 1;}
            else
            {
                vis[kk]=true,d[kk]=d[k]+w;
                q[lst++]=kk;
                if(lst==N)lst=0;
            }
        }
    }
    return 0;
}
signed main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&z);
        add(x,y,z),add(y,x,-z);
    }
    for(int i=1;i<=n;i++)
        if(vis[i]==0&&spfa(i)){printf("No");return 0;}
    printf("Yes");
    return 0;
}


Measured memory_bytes: 22784
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

char board[300][300];
int main(){
	int N;
	cin >> N;
	rep(i, N) cin >> board[i];
	int count = 0;
	rep(A, N){
		bool flag = true;
		rep(i, N) rep(j, N){
			if(board[(i + A) % N][j] != board[(j + A) % N][i]){
				flag = false;
			}
		}
		if(flag){
			count += N;
		}
	}
	cout << (count) << endl;
	return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val S = next()
    var L = 0
    var n = 0
    while (n < S.length / 2) {
        if (S[n] == S[S.length - n - 1]) L += 1
        n += 1
    }
    println((S.length - L * 2) / 2)
}
fun next() = readLine()!!

Measured memory_bytes: 31736
inpl = lambda: list(map(int,input().split()))
class ParityTree:
    def __init__(self,N):
        self.parent = [-1]*int(N)
        self.parity = [0]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n, 0
        else:
            m, p = self.root(self.parent[n])
            self.parent[n] = m
            self.parity[n] = (p + self.parity[n]) % 2
            return m, self.parity[n]

    def merge(self, m, n, parity):
        rm, pm = self.root(m)
        rn, pn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm
            self.parity[rn] = (pm + pn + parity) % 2

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def aresame(self, m, n):
        return self.root(m) == self.root(n)

N = int(input())
pt = ParityTree(N)
for i in range(N-1):
    u, v, w = inpl()
    pt.merge(u-1,v-1,w)

for i in range(N):
    print(pt.root(i)[1])

Measured memory_bytes: 82264
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  int ans = 0;
  queue<vector<int>> que;
  que.push(vector<int>(1, 1));

  while (true) {
    vector<int> A = que.front();
    que.pop();
    if ((int)A.size() == N + 2) {
      break;
    }

    int score = 0;
    if ((int)A.size() == N + 1) {
      for (int i = 0; i < Q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) {
          score += d[i];
        }
      }
    }
    ans = max(ans, score);

    int tail = A.back();
    for (int add_elem = tail; add_elem <= M; add_elem++) {
      A.push_back(add_elem);
      que.push(A);
      A.pop_back();
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18180
#include <cstdio>
#include <iostream>
#include <map>

using std::map;
using std::cout;

int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  map<long long, int> mp;
  mp[sum] = 1;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum = sum + x;
    mp[sum]++;
  }
  long long res = 0;
  for (auto x : mp) {
    res += (long long)x.second * (x.second - 1) / 2;
  }
  cout << res << std::endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  vector<int> v(3);
  while (cin >> v) {
    sort(v.begin(), v.end());
    cout << (v[0] == 5 && v[1] == 5 && v[2] == 7 ? "YES" : "NO") << endl;
  }
  
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int count=0;

    for (int i=0; i<N; i++){
        string S;
        cin >> S;
        count++;
        if (S=="Y") {cout << "Four" << endl; break;}

    }

    if (count==N) {cout << "Three" << endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

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

int main() {
    int N; string S; cin >> N >> S;
    vector<int> hai(9);

    vector<vector<long long> > num(10, vector<long long>(10, 0));
    for (int i = 0; i + 1 < N; ++i) {
        int a = S[i] - '0';
        int b = S[i+1] - '0';
        num[a][b]++;
    }
    iota(hai.begin(), hai.end(), 1);

    long long mi = 1LL<<60;
    vector<int> mii;
    do {
        // Warshall-Floyd
        long long dp[10][10];
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                dp[i][j] = 1<<29;
            }
            dp[i][i] = 0;
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                int v = hai[i*3+j];
                for (int dir = 0; dir < 4; ++dir) {
                    int ni = i + dx[dir], nj = j + dy[dir];
                    if (ni < 0 || ni >= 3 || nj < 0 || nj >= 3) continue;
                    int w = hai[ni*3+nj];
                    dp[v][w] = dp[w][v] = 1;
                }
            }
        }
        for (int k = 0; k < 10; ++k)
            for (int i = 0; i < 10; ++i)
                for (int j = 0; j < 10; ++j) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                    //cout << i << ", " << j << ": " << dp[i][j] << endl;
                }

        long long res = 0;
        for (int i = 1; i < 10; ++i) {
            for (int j = 1; j < 10; ++j) {
                res += num[i][j] * dp[i][j];
            }
        }

        if (mi > res) {
            mi = res;
            mii = hai;
        }
                    
    } while (next_permutation(hai.begin(), hai.end()));

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) cout << mii[i*3+j];
        cout << endl;
    }
}



Measured memory_bytes: 3280
#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main(){
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);

    int a;
    cin >> a;
    a = a + a*a + a*a*a;
    cout << a << "\n";
    
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			String s = "";
			int sum = 0;
			int cp, cq;
			for(int j=0;j<2;j++){
				s = sc.next();
				for(int k=0;k<s.length();k++){
					cq = 1;
					cp = s.codePointAt(k);
					if(cp<58){
						cq = cp - 48;
						k++;
						cp = s.codePointAt(k);
					}
					if(cp==109) sum += cq*1000;
					else if(cp==99) sum += cq*100;
					else if(cp==120) sum += cq*10;
					else if(cp==105) sum += cq;
				}	
			}
			
			cp = 1000;
			cq = 0;
			for(int j=0;j<4;j++){
				cq = sum/cp;
				sum %= cp;
				cp /= 10;
				if(j==0 && cq>1) System.out.print(cq + "m");
				if(j==0 && cq==1) System.out.print("m"); 
				if(j==1 && cq>1) System.out.print(cq + "c");
				if(j==1 && cq==1) System.out.print("c"); 	
				if(j==2 && cq>1) System.out.print(cq + "x");
				if(j==2 && cq==1) System.out.print("x"); 
				if(j==3 && cq>1) System.out.print(cq + "i");
				if(j==3 && cq==1) System.out.print("i"); 
			}
			System.out.println();
			
		}
	}	
}

Measured memory_bytes: 25128