akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for(int i = int(b)-1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll total = 0, suff = 0;
    int n;
    cin >> n;
    vi a(n), ans(n);
    forn(i, n)cin >> a[i], total += a[i];
    for(int i = 1; i < n; i+=2) suff+=a[i];
    ans[0] = total - 2*suff;
    forab(i, 1, n) ans[i] = 2*a[i-1]-ans[i-1];
    forn(i, n) cout << ans[i] << " ";
    cout << "\n";
    return 0;
}


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

int main() {
  int a[3][3], n;
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++) scanf("%d", &a[i][j]);
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    for(int i = 0; i < 9; i++)
      if(a[i / 3][i % 3] == b) a[i / 3][i % 3] = -1;
  }
  for(int i = 0; i < 3; i++) {
    int s = 0;
    for(int j = 0; j < 3; j++) s += a[i][j];
    if(s == -3) {
      printf("Yes\n");
      return 0;
    }
  }
  for(int i = 0; i < 3; i++) {
    int s = 0;
    for(int j = 0; j < 3; j++) s += a[j][i];
    if(s == -3) {
      printf("Yes\n");
      return 0;
    }
  }
  int s = 0;
  for(int i = 0; i < 3; i++) s += a[i][i];
  if(s == -3) {
    printf("Yes\n");
    return 0;
  }
  s = 0;
  for(int i = 0; i < 3; i++) s += a[i][2 - i];
  if(s == -3) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
}

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

using namespace std;

int main()
{
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
  
    for(int i = 0; i < n; i++){
        cin >> s.at(i);
        cin >> t.at(i);
    }

	string x; cin >> x;
    int sum = 0;

    for(int j = 0; j < n; j++){
        if(s.at(j) == x){
            for(int k = j + 1; k < n;k++){
                sum = sum + t.at(k); 
            }
        break;
        }
        
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MIN (-1) * (1 << 30)
 
using namespace std;
 
int main(void) {
	int H, W, i = 0, j, l, sum, ans = 0;
	cin >> H >> W;
	vector<vector<int>> x(H, vector<int>(W, 0));
	vector<string> s(H);
	for (; i < H; i++)
		cin >> s[i];
	for (i = 0; i < H; i++) {
		l = 0;
		for (j = 0; j < W; j++) {
			while (j < W && s[i][j] == '.')
				j++;
			sum = j - l;
			for (; l < j; l++)
				x[i][l] = sum;
			if (j < W)
				x[i][j] = MIN;
			l = j + 1;
		}
	}
	for (j = 0; j < W; j++) {
		l = 0;
		for (i = 0; i < H; i++) {
			while (i < H && s[i][j] == '.')
				i++;
			sum = i - l;
			for (; l < i; l++)
				x[l][j] += sum;
			l = i + 1;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			ans = max(ans, x[i][j]);
		}
	}
	cout << ans - 1 << "\n";
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1]+='a'-'A';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// *** Using PBDS ***
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// *** Using PBDS ***
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}
bool comp(pii a,pii b)
{
    if(a.first==b.first)
    return a.second<b.second;
    return a.first>b.first;
    
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//unordered_map<long long, int, custom_hash> safe_map;



signed main()
{
	haha
	int s,w;
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";
	
	
	
}


  
    

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

using namespace std;

const int N_MAX = 302;

const int MOD = 998244353;

int n, k;

string s;

int m;

int a[N_MAX];
int spa[N_MAX];

int dp[N_MAX][N_MAX][N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> k;
    n = s.size();
    s = " " + s;
    for(int i = 1; i <= n; i++)
        if(s[i] == '1')
            a[i - (++m) + 1]++;
    for(int i = 1; i <= n; i++)
        spa[i] = spa[i - 1] + a[i];
    k = min(k, n);
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int sp = spa[i]; sp <= spa[n]; sp++)
            for(int sum = 0; sum <= k; sum++)
            {
                for(int x = 1; x <= sum && (a[i] - x) <= sp && x <= a[i]; x++)
                {
                    dp[i][sp][sum] += dp[i - 1][sp - (a[i] - x)][sum - x];
                    if(dp[i][sp][sum] >= MOD)
                        dp[i][sp][sum] -= MOD;
                }
                for(int x = 0; (a[i] + x) <= sp; x++)
                {
                    dp[i][sp][sum] += dp[i - 1][sp - (a[i] + x)][sum];
                    if(dp[i][sp][sum] >= MOD)
                        dp[i][sp][sum] -= MOD;
                }
            }
    int ans = 0;
    for(int i = 0; i <= k; i++)
    {
        ans += dp[n][spa[n]][i];
        if(ans >= MOD)
            ans -= MOD;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    string s,t;
    cin>>s>>t;
    int counter=0;
    for (int i=0;i<s.size();i++){
        if (s[i]!=t[i])
            counter++;
    }
    cout<<counter;

    return 0;
}


Measured memory_bytes: 3912
#include <stdio.h>

int main(void)
{
  int n = 0;
  int a[100];
  int i;
  int max = 0;
  int sum = 0;
  
  scanf("%d", &n);
  
  for (i = 0; i < n;i++){
    scanf("%d", &a[i]);
    if(max < a[i]){max = a[i];}
    sum += a[i];
  }
  if(max < (sum - max)){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return (0);
}
  
  
  

Measured memory_bytes: 128
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	char c;

	cin>>c;

	if(c=='a'){
		cout<<"vowel"<<endl;
	}else if(c=='i'){
		cout<<"vowel"<<endl;
	}else if(c=='u'){
		cout<<"vowel"<<endl;
	}else if(c=='e'){
		cout<<"vowel"<<endl;
	}else if(c=='o'){
		cout<<"vowel"<<endl;
	}else{
		cout<<"consonant"<<endl;

	}
	return 0;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define M 1000000007


ll power(ll x, ll y)
{ ll res = 1;
  x=x%M;
  while (y > 0)
    {if (y & 1)
      res = (res*x)%M;
     y = y>>1;
     x = (x*x)%M;
    }
    return res;
}

ll prime(ll x)
{ fe(i,2,sqrt(x))
   {if(x%i==0)
    return 0;
   }
return 1;
}


int main()
{ ll t=1;
  //cin>>t;
  while(t--)
  { ll n=0,i=0,j=0,k=0,x=0,y=0,a=0,b=0,c=0,flag=0,flag1=0;
    cin>>x>>y>>a>>b>>c;
    ll aa[a],bb[b],cc[c];
    vi v;
    f(i,0,a)
     cin>>aa[i];
    f(i,0,b)
     cin>>bb[i];
    f(i,0,c)
     cin>>cc[i];

    sort(aa,aa+a);
    sort(bb,bb+b);
    sort(cc,cc+c);

    while(x--)
    { v.pb(aa[a-1]);
      a--;
    }

    while(y--)
    { v.pb(bb[b-1]);
      b--;
    }

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

    f(i,0,v.size())
      { if(v[i]<cc[c-1])
          { v[i]=cc[c-1];
            c--;
          }
        if(c==0)
          break;
      }

    f(i,0,v.size())
      { k+=v[i];
      }
    cout<<k<<endl;
  }
return 0;
}


Measured memory_bytes: 4724
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    boolean[][] s = new boolean[H][W];
    String line;
    for (int i=0; i<H; i++) {
      line = sc.next();
      for (int j=0; j<W; j++) {
        s[i][j] = (line.charAt(j) == '#');
      }
    }

    boolean ret = true;
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        if (s[i][j]) {
          if (i>0 && s[i-1][j]) {
            continue;
          }
          if (j>0 && s[i][j-1]) {
            continue;
          }
          if (i<H-1 && s[i+1][j]) {
            continue;
          }
          if (j<W-1 && s[i][j+1]) {
            continue;
          }
          // failed.
          ret = false;
          i = H;
          j = W;
        }
      }
    }
    String ans;
    if (ret) {
      ans = "Yes";
    } else {
      ans = "No";
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	long long int sum = 0;
	scanf("%d", &n);
	for(int i= 1; i <= n; i++)
	{
		sum = sum + i;
		}
	printf("%lld\n",sum);
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x;
    cin >> a >> b >> x;
    double ans;
    if(a*a*b>2*x)ans = 180*atan((double)(a*b*b)/(2.0*x))/M_PI;
    else{ans = 180*atan((2.0*(a*a*b-x))/(double)(a*a*a))/M_PI;}
    cout << fixed << setprecision(16);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

#define ll long long
ll n,a,b,c,d;

int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n--;  a=b-a;
	for(int i=0;i<=n;i++)
	if(i*d-(n-i)*c>=a&&a>=i*c-(n-i)*d){
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
F = [None] * 4

for i in range(4):
    F[i] = []

for i in range(3):
    a, b  = map(int, input().split())
    a    -= 1
    b    -= 1
    F[a].append(b)
    F[b].append(a)

L = [len(f) for f in F]

L.sort()

if L == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')


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

int gcd(int m,int k){
    if(m<k) swap(m,k);
    if(!k) return m;
    else return gcd(m%k,k);
}


int n;

int main()
{
    cin>>n;
    int h=gcd(360,n);
    int k=360/h;
    cout<<k;
    return 0;

}

Measured memory_bytes: 3632
N, M = [int(elm) for elm in input().split(" ")] 

Ls = []
Rs = []
for i in range(M):
    L, R = [int(elm) for elm in input().split(" ")] 
    Ls.append(L)
    Rs.append(R)
    
max_L = max(Ls)
min_R = min(Rs)

#print(max_L, min_R)
out = max(min_R - max_L+1, 0)
print(out)

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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int n;
  cin >>n;
  int tmp = n;
  int s = 0;
  while(tmp){
    s+= tmp%10;
    tmp /= 10;
  }
  if(n%s == 0)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) 
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    return u;
  if(k < u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  y = NIL;
  x = root;
  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL)
      root = z;
    else if(z->key < y->key)
      y->left = z;
    else
      y->right = z;
}

void inorder(Node u){
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    string s, T;
    cin >> s;
    cin >> T;
    int n = s.size(), m = T.size();
    vector<string> Vs;
    string a;
    bool flag = true;
    rep(i, n - m + 1)
    {
        flag = true;
        rep2(j, i, i + m)
        {
            if (s[j] != T[j - i] and s[j] != '?')
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            a.erase();
            rep(k, n)
            {
                if (k < i or i + m <= k)
                {
                    if (s[k] != '?')
                        a.push_back(s[k]);
                    else
                    {
                        a.push_back('a');
                    }
                }
                else
                {
                    a.push_back(T[k - i]);
                }
            }
            Vs.push_back(a);
        }
    }
    if (Vs.empty())
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(all(Vs));
    string S = Vs[0];
    rep(i, n)
    {
        if (S[i] == '?')
        {
            cout << 'a';
        }
        else
        {
            cout << S[i];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod = 1e9 + 7;

ll dp[1000][1000];

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    dp[0][0] = 1;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            for(int bit=0; bit < (1 << (w-1)); bit++){
                //check
                bool flag = true;
                for(int k=0; k < w-2; k++){
                    if(((bit >> k) & 1) && (((bit >> (k+1)) & 1))) flag = false;
                }

                if(flag == false) continue;
                
                // 左に移動する場合
                if(j > 0 && ((bit >> (j-1)) & 1)){
                    dp[i+1][j-1] += dp[i][j];
                    dp[i+1][j-1] %= mod;
                }
                // 右に移動する場合
                else if(j < w-1 && ((bit >> j) & 1)){
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                // そのまま
                else {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
            }
        }
    }

    cout << dp[h][k-1] << endl;
    return 0;
}

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

#define F first
#define S second
#define pb push_back

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int Log[MAXN];

int sparsuha1[MAXN][50];
int sparsuha2[MAXN][50];

int ans[MAXN][2];

int main() {
    int n = readInt(), Z = readInt(), W = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    }      
    if (n > 1)
	cout << max(abs(a[n] - W), abs(a[n - 1] - a[n]));
	else 
	cout << abs(a[n] - W);
	return 0;
}

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

d = []
a = []

for i in range(k):
    temp = int(input())
    d.append(temp)

    t = list(map(int,input().split()))
    a.append(t)


a_set = set()
for i in a:
    for j in i:
        a_set.add(j)

print(n - len(a_set))

Measured memory_bytes: 9192
#include<stdio.h>
int main(void)
{
	int i,x;
	for(i=1;i>0;i++){
		scanf("%d",&x);
		if(x!=0){
			printf("Case %d: %d\n",i,x);
			}
		else{
			break;
		}
	}
	
	return 0;
}

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

const int mod = 1e9+7;
int n, a, b, c, dt[45][1<<17];

int main()
{
	scanf("%d%d%d%d",&n,&a,&b,&c);
	dt[0][0] = 1;
	int B = (1<<(a+b+c))-1;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=B;j++) {
			for(int k=1;k<=10;k++) {
				int C = ((j<<k) + (1<<(k-1)))&B;
				if((C & (1<<(c-1))) && (C & (1<<(b+c-1))) && (C & (1<<(a+b+c-1)))) continue;
				dt[i][C] = (dt[i][C] + dt[i-1][j]) % mod;
			}
		}
	}
	int ans = 0;
	long long n10 = 1;
	for(int i=1;i<=n;i++) {
		n10 = n10 * 10 % mod;
	}
	for(int i=0;i<=B;i++) {
		ans = (ans + dt[n][i]) % mod;
	}
	printf("%lld\n", (n10 + mod - ans) % mod);
}


Measured memory_bytes: 22272
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

LL llpow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int main() {
    LL n;
    cin >> n;
    vector<int> keta(60, 0);

    LL max_keta;
    LL tmp=0;

    if(n>=0){
        max_keta=0;
        tmp+=llpow(2, max_keta);
        while(n>tmp){
            max_keta+=2;
            tmp+=llpow(2, max_keta);
        }
    }else{
        max_keta=1;
        tmp-=llpow(2, max_keta);
        while(n<tmp){
            max_keta+=2;
            tmp-=llpow(2, max_keta);
        }
    }

    LL max_plus=0;
    LL min_minus=0;
    LL tmp_keta=0;
    while(tmp_keta<=max_keta){
        if(tmp_keta%2==0){
            max_plus+=llpow(2, tmp_keta);
        }else{
            min_minus-=llpow(2, tmp_keta);            
        }
        tmp_keta++;
    }

    tmp_keta=max_keta;
    while(tmp_keta>=0){
        if(tmp_keta%2==0){
            max_plus-=llpow(2, tmp_keta);
            if(n>max_plus){
                keta[tmp_keta]=1;
                n-=llpow(2, tmp_keta);
            }
        }else{
            min_minus+=llpow(2, tmp_keta);
            if(n<min_minus){
                keta[tmp_keta]=1;
                n+=llpow(2, tmp_keta);
                //cout << tmp_keta << " " << keta[tmp_keta] << endl;

            }            
        }
        //cout << tmp_keta << " " << n << endl;
        tmp_keta--;
    }

    for(int i=max_keta; i>=0; i--){
        cout << keta[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3636
//
// Created by Undefined on 2018/2/2.
//

#include <iostream>

using namespace std;

int main() {
    int a, b, c, tmp;
    a = b = c = 0;
    for (int i = 0; i < 10; i++) {
        scanf("%d", &tmp);
        if (tmp > a) {
            c = b;
            b = a;
            a = tmp;
        } else if (tmp > b) {
            c = b;
            b = tmp;
        } else if (tmp > c) {
            c = tmp;
        }
    }
    printf("%d\n%d\n%d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 3184
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll n = 6;
        ll a[10];
        rep(i, 6) cin >> a[i];
        rep(i, 5) rep(j, 5) if(abs(a[i] - a[j]) > a[5]){
            cout << ":(" << endl;
            return;
        }
        cout << "Yay!" << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
      */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  int x[n],y[n],h[n];
  int hmx =0;
  int hmxi;
  for(int i = 0; n > i; i++){
    cin>>x[i]>>y[i]>>h[i];
    if(hmx < h[i])hmx=h[i],hmxi=i;
  }
  for(int i = 0; 101 > i; i++){
    for(int j = 0; 101 > j; j++){
      int height = abs(i-x[hmxi]) + abs(j - y[hmxi])+hmx;
      bool ok = true;
      for(int k = 0; n > k; k++){
        //height == abs(i-x[k]) + abs(j - y[k])+h[k]//h[k]>0
        //height == abs(i-x[k]) + abs(j - y[k])+h[k]//h[k]<=0
        //height >= abs(i-x[k]) + abs(j - y[k])-h[k]//h[k]==0(今回の成約)
        if((h[k] != 0 && height != abs(i-x[k]) + abs(j - y[k])+h[k]) || (h[k] == 0 && height > abs(i-x[k]) + abs(j - y[k]))){
          ok = false;
          break;
        }
      }
      if(ok){
        cout << i << " " << j << " " << height << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int64_t> p(A), q(B), r(C);
    for(int i=0; i<A; i++) {
        cin >> p[i];
    }
    for(int i=0; i<B; i++) {
        cin >> q[i];
    }
    for(int i=0; i<C; i++) {
        cin >> r[i];
    }

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());

    priority_queue<int64_t, vector<int64_t>, greater<int64_t> > pq1, pq2;
    for(int i=0; i<X; i++) {
        pq1.push(p[i]);
    }
    for(int i=0; i<Y; i++) {
        pq2.push(q[i]);
    }
    for(auto e: r) {
        if(e < pq1.top() && e < pq2.top()) break;
        if(pq1.top() < pq2.top()) {
            pq1.pop();
            pq1.push(e);
        } else {
            pq2.pop();
            pq2.push(e);
        }
    }

    int64_t ans = 0;
    while(!pq1.empty()) {
        ans += pq1.top();
        pq1.pop();
    }
    while(!pq2.empty()) {
        ans += pq2.top();
        pq2.pop();
    }

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


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

int main()
{
  int N;
  cin >> N;
  
  int A[2][N];
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < N; ++j)
      cin >> A[i][j];
  
  for (int j = 1; j < N; ++j)
    A[0][j] += A[0][j-1];
  
  for (int j = N-2; j >= 0; --j)
    A[1][j] += A[1][j+1];
  
  int sum[N];
  int maxSum = 0;
  for (int j = 0; j < N; ++j) {
    sum[j] = A[0][j] + A[1][j];
    if (sum[j] > maxSum)
      maxSum = sum[j];
  }
  
  cout << maxSum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
bool binarysearch(int A[],int x,int n){
	int left=0,right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(A[mid]==x){
			return 1;
		}else if(x<A[mid]){
			right=mid;
		}else{
			left=mid+1;
		}
	}
	return 0;
}
	
			
int main(){
	int n,q;
	int S[100000],T[100000];
	int cnt=0;
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	std::cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>T[i];
	}
	for(int i=0;i<q;i++){
		if(binarysearch(S,T[i],n)){
			cnt++;
		}
	}
	std::cout<<cnt<<"\n";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

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

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;
int n;

struct node {
	int l, r, id;
} L[N], R[N], Seg[N];

inline bool cmpL(node a, node b) { return a.l > b.l; }

inline bool cmpR(node a, node b) { return a.r < b.r; }

bitset<N> vis;

int Near(int a, int b, int pos) {
	if (min(a, b) <= pos && pos <= max(a, b)) return pos;
	if (fabs(a - pos) < fabs(b - pos)) return a; else return b;
}

int main () {
	File();
	n = read();

	For (i, 1, n) {
		int l = read(), r = read();
		L[i] = (node) {l, r, i};
		R[i] = (node) {l, r, i};
		Seg[i] = (node) {l, r, i};
	}
	sort(L + 1, L + 1 + n, cmpL);
	sort(R + 1, R + 1 + n, cmpR);

	int FrontL = 1, FrontR = 1;

	long long ans = 0, res = 0; vis.reset();

	int pos = 0;
	For (i, 1, n) {
		int now;
		if (i & 1) {
			while (vis[L[FrontL].id]) ++ FrontL;
			now = Near(L[FrontL].l, L[FrontL].r, pos);
			vis[L[FrontL].id] = true;
		} else {
			while (vis[R[FrontR].id]) ++ FrontR;
			now = Near(R[FrontR].l, R[FrontR].r, pos);
			vis[R[FrontR].id] = true;
		}
		res += fabs(pos - now);
		pos = now;
	}
	res += fabs(pos);
	ans = max(ans, res);

	vis.reset();

	FrontL = FrontR = 1;
	res = 0; pos = 0;
	For (i, 1, n) {
		int now;
		if (!(i & 1)) {
			while (vis[L[FrontL].id]) ++ FrontL;
			now = Near(L[FrontL].l, L[FrontL].r, pos);
			vis[L[FrontL].id] = true;
		} else {
			while (vis[R[FrontR].id]) ++ FrontR;
			now = Near(R[FrontR].l, R[FrontR].r, pos);
			vis[R[FrontR].id] = true;
		}
		res += fabs(pos - now);
		pos = now;
	}
	res += fabs(pos);

	ans = max(ans, res);

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

    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int size = S.size();
    if ((S == "hi") || (S == "hihi") || (S == "hihihi") || (S == "hihihihi") || (S == "hihihihihi"))
    {
        cout << " Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	int n,k;
	cin >> n >> k;

	vector<bool> sunuke(n, false);
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int a;
			cin >> a;
			a--;
			sunuke[a] = true;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (sunuke[i]==false) {
			ans++;
		} 
	}
	cout << ans <<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> b(n);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      b[j - 1].push_back(i - 1);
    }
  }
  vector<int> c(n), ans;
  for (int i = n - 1; i >= 0; i--) {
    if ((c[i] + a[i]) % 2 == 1) {
      ans.push_back(i + 1);
      for (auto &j : b[i]) c[j]++;
    }
  }
  cout << ans.size() << endl;
  if (ans.size()) {
    cout << ans[0];
    for (int i = 1; i < ans.size(); i++) cout << " " << ans[i];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 24316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  string S;
  cin>>S;
  vector<ll> X(26);
  rep(i,S.size()) X[S[i]-'a']++;
  ll ans=S.size()*(S.size()-1)/2+1;
  rep(i,26) ans-=X[i]*(X[i]-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h;i ++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}cout<<endl;
	}
return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int n,m,k,a[100000],b[1000][1000];
  cin>>n>>m>>k;
  for(int i=1;i<=k;i++){
   cin>>a[i];   
  }
  
  int d=1;
 
  for(int i=0;i<n;i++){
   if(i%2==0){
     for(int j=0;j<m;j++){  
    if(a[d]==0){
     d++;   
    }http://cpp.sh/#
        b[i][j]=d; 
    a[d]--;
   }
   }  
      if(i%2==1){
     for(int j=m-1;j>=0;j--){  
    if(a[d]==0){
     d++;   
    }
     b[i][j]=d;
    a[d]--;
   }
   }  
    
  }
    for(int i=0;i<n;i++){

     for(int j=0;j<m;j++){  
         
         cout<<b[i][j]<<" ";
     }
    cout<<endl;
    }
    
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
typedef long long ll;

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.length()>k){
        rep(i,0,k) cout<<s[i];
        cout<<"...";
    }
    else cout<<s;
}


Measured memory_bytes: 3628
N=int(input())
H=list(map(int,input().split()))
max_ans=0
ans=0
for i in range(N-1):
    if H[i]>=H[i+1]:
        ans=ans+1
    else:
        max_ans=max(ans,max_ans)
        ans=0
max_ans=max(ans,max_ans)
print(max_ans)

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

typedef long long ll;

const int MAX = 510000;
// const int MOD = 1000000007;
const ll MOD=998244353ll;

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

void COMinit(int n) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; 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;
    }
}

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

int main() {
  	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	ll k;
	cin>>n>>a>>b>>k;
    COMinit(n);
  	ll ans=0;
	for(int i=0; i<=n; ++i){
		if((k-i*a)%b==0){
			int j=(k-i*a)/b;
			if(j>=0 && j<=n){
				ans=(ans+COM(n, i)*COM(n, j)%MOD)%MOD;
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 10624
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int tBit = 0;
			for(int i = 0; i < k; i++) {
				int j = sc.nextInt();
				if((tBit>>j&1)==0)
					tBit += 1<<j;
			}
			for (int bit = 0; bit < (1<<n); bit++) {
				if((bit|tBit) == bit) {
					System.out.print(bit + ":");
					for (int j = 0; j < n; j++) {
						if (((bit>>j) & 1) == 1) {
							System.out.print(" " + j);
						}
					}
					System.out.println();
				}
			}
		}
	}
}


Measured memory_bytes: 66552
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}


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

using namespace std;

#define ll long long

int main()
{

	ll n,m;
	cin>>n>>m;

	set<ll> s;

	for(ll i = 0 ; i < m ; i++)
	{
		ll t1;
		cin>>t1;

		s.insert(t1);
	}

	ll dp[n  + 1];

	dp[0] = 1;

	if(s.count(1))
	{
		dp[1] = 0;
	}
	else
	{
		dp[1] = 1;
	}

	if(s.count(2))
	{
		dp[2] = 0;
	}
	else
	{
		dp[2] = dp[1] + dp[0];
	}

	for(ll i = 3 ; i <= n ; i++)
	{
		if(s.count(i))
		{
			dp[i] = 0;
		}
		else
		{
			dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
		}
	}
	
	cout<<dp[n]<<endl;


}

Measured memory_bytes: 5760
n = int(input())
playlists = []

for _ in range(n):
    title, playtime = input().split()
    playlists.append([title, int(playtime)])

titles, playtimes = list(zip(*playlists))
lastmusic = input()

lastmusic_timing = titles.index(lastmusic)
print(sum(playtimes[lastmusic_timing + 1:]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	int t = b - a;
	int ans;
	int i = 2;
	int aa = 1;
	int ab = 3;
	while (t != ab - aa) {
		aa += i;
		ab += i + 1;
		//cout << aa << " " << ab <<  endl;
		i++;
	}
	//cout << aa << " " << ab << endl;
	ans = ab - b;

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);

	puts((abs(b-a)+1)&1 ? "Alice" : "Borys");

	return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int n = N;
        String ans = "";
        while(n != 0){
            if(n % 2 == 0){
                ans = "0" + ans;
                n /= -2;
            }else{
                ans = "1" + ans;
                n = (n-1) / (-2);
            }
        }
        if(N == 0){
            System.out.println("0");
        }else{
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct list{
  struct list *next;
  struct list *prev;
  int n;
};
struct list *ls;
void init();
void insert(int,int);
void delete(int);
void print();
void deleteFirst();
void deleteLast();
int main(){
  int n,i,com;
  char command[13];
  init();
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(!strcmp(command,"deleteFirst"))deleteFirst();
    else if(!strcmp(command,"deleteLast"))deleteLast();
    else{
      scanf("%d",&com);
        if(!strcmp(command,"insert")) insert(com,i);
        else if(!strcmp(command,"delete"))  delete(com);
    }
  }
  print();

  return 0;
}
void init(){
  ls=(struct list *)malloc(sizeof(struct list));
  ls->next=ls;
  ls->prev=ls;
}
void insert(int com,int i){
  struct list *array;
  array=(struct list *)malloc(sizeof(struct list));
  array->n=com;
  ls->next->prev=array;
  array->next=ls->next;
  array->prev=ls;
  ls->next=array;
  if(i==0)ls->prev=array;
}
void print(){
  struct list *a=ls->next;
  while(1){
    printf("%d",a->n);
    if(a->next==ls){
        printf("\n");
        return;
    }
    printf(" ");
    a=a->next;
    free(a->prev);
  }
}
void delete(int x){
  struct list *a=ls->next;
  while(1){
    if(a==ls)return;
    if(a->n==x){
      a->prev->next=a->next;
      a->next->prev=a->prev;
      free(a);
      return;
    }
    a=a->next;
  }
}

void deleteFirst(){
  ls->next=ls->next->next;
  ls->next->prev=ls;
}
void deleteLast(){
  ls->prev->prev->next=ls;
  ls->prev=ls->prev->prev;
}



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

int wa(int a)
{
  int res = a;
  int sum = 0;
  while (res != 0) {
    sum += res % 10;
    res /= 10;
  }
  return sum;
}
int main()
{
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  for (int i=1; i<=N; i++) {
    int waa = wa(i);
    if (A <= waa && waa <= B) 
      ans +=  i;

  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int N;
const int mod = 1000000000 + 7;
int dp[110][4][4][4];

char to_char(int a){
    if(a == 0) return 'A';
    else if(a == 1) return 'C';
    else if(a == 2) return 'G';
    return 'T';
}

int rec(int pos, int p1, int p2, int p3){
    if(dp[pos][p1][p2][p3] >= 0) return dp[pos][p1][p2][p3];
    ll res = 0;
    if(pos == N){
        res = 1;
    }
    else{
        for(int i = 0; i < 4; i++){
            int np1 = i;
            int np2 = p1;
            int np3 = p2;
            int np4 = p3;
            if(pos < 2){
                (res += rec(pos + 1, np1, np2, np3)) %= mod;
            }
            else{
                string s = "";
                s+= to_char(np3);
                s+= to_char(np2);
                s+= to_char(np1);
                if(s == "AGC") continue;
                if(s == "GAC") continue;
                if(s == "ACG") continue;
                
                if(pos >= 3){
                    if(to_char(np4) == 'A' && s.substr(1) == "GC") continue;
                    if(to_char(np4) == 'A' && to_char(np3) == 'G' && to_char(np1) == 'C') continue;
                }
                (res += rec(pos + 1, np1, np2, np3)) %= mod;
            }
        }
    }
    return dp[pos][p1][p2][p3] = res;
}

int main(){

    cin >> N;
    memset(dp, -1 ,sizeof(dp));
    cout <<rec(0, 0, 0, 0) << endl;
    

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	string s; cin >> s;
	bool f[26] = {};
	for (int i = 0; i < s.length(); i++) f[s[i] - 'a'] = 1;
	int res = 26;
	for (int i = 0; i < 26; i++) if (!f[i]) {
		res = i; break;
	}
	if (res == 26) cout << "None" << endl;
	else cout << (char)('a' + res) << endl;
	return 0;
	
}

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF= 1e9;
const int MOD= 1000000007;

#define rep(i,n) for(int i=0, i<n; i++)
const int MAX= 2000005;
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;
}

ll g(int p,int q){
  ll res= 0;
  for(int i=1; i<=p+1; i++){
    res= (res+ COM(i+ q,q))% MOD;
  }
  return res;
}

int main(){
 COMinit();
  int r1,r2,c1,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  
  ll a,b,c,d;
  a= g(r2,c2);
  b= g(r2,c1-1);
  c= g(r1-1,c2);
  d= g(r1-1,c1-1);
  ll ans= ((a+d)% MOD-(b+c)% MOD+ MOD)% MOD;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 47104
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u==NIL) return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u==NIL)return;
	inParse (T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(void){
	int i,v,l,r,root;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p=NIL;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l !=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
		
	for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
	}


Measured memory_bytes: 2120
n = int(input())
A = list(map(int,input().split()))
s = max(A[0],1)
cnt1 = abs(A[0]-s) #sを正にするまで
for a in A[1:]:
    if s>0:
        b=min(a, -s-1) #aを何の値にするかがb
    if s<0:
        b=max(a,-s+1)
    s += b #bを足してs更新
    cnt1 += abs(a-b)

s = min(A[0],-1)
cnt2 = abs(A[0]-s)
for a in A[1:]:
    if s>0:
         b=min(a, -s-1) #aを何の値にするかがb
    if s<0:
        b=max(a,-s+1)
    s += b #bを足してs更新
    cnt2 += abs(a-b)
print(min(cnt1,cnt2))

Measured memory_bytes: 14468