akhauriyash/Code-Regression huggingface dataset:
N=input()
DP=[[0]*(len(N)+1) for i in range(4)]
DP[0][0]=1#後側が位置
mod=10**9+7
for i in range(len(N)):
   if N[i]=="A":
      DP[0][i+1]=DP[0][i]%mod
      DP[1][i+1]=(DP[1][i]+DP[0][i])%mod
      DP[2][i+1]=DP[2][i]%mod
      DP[3][i+1]=DP[3][i]%mod
   elif N[i]=="B":
      DP[0][i+1]=DP[0][i]%mod
      DP[1][i+1]=DP[1][i]%mod
      DP[2][i+1]=(DP[2][i]+DP[1][i])%mod
      DP[3][i+1]=DP[3][i]%mod
   elif N[i]=="C":
      DP[0][i+1]=DP[0][i]%mod
      DP[1][i+1]=DP[1][i]%mod
      DP[2][i+1]=DP[2][i]%mod
      DP[3][i+1]=(DP[3][i]+DP[2][i])%mod
   else:
      DP[3][i+1]=(3*DP[3][i]+DP[2][i])%mod
      DP[0][i+1]=(DP[0][i]*3)%mod
      DP[1][i+1]=(DP[1][i]*3+DP[0][i])%mod
      DP[2][i+1]=(DP[2][i]*3+DP[1][i])%mod
print(DP[3][-1]%mod)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] prices = new int[3];
        for (int i = 0; i < 3; i++) {
            prices[i] = sc.nextInt();
        }
        Arrays.sort(prices);
        System.out.println(prices[0] + prices[1]);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);

void solv()
{
    int a, v;
    int b, w;
    int t;
    scanf("%d%d", &a, &v);
    scanf("%d%d", &b, &w);
    scanf("%d", &t);
    if (w >= v)
    {
        printf("NO\n");
        return;
    }
    if (abs(a - b) <= t * 1LL * (v - w))
        printf("YES\n");
    else
        printf("NO\n");
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <climits>
using namespace std;

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

template <typename T>
class RMQ {
private:
	vector<T> _dat;
	int _n;
	T _initial;

public:
	RMQ(int n, int initial) {
		init(n, initial);
	}

	void init(int n, T initial) {
		_initial = initial;
		_n = 1;
		while(_n < n) _n *= 2;
		_dat.resize(_n*2-1, _initial);
	}

	void update(int x, T y) {
		x += _n-1;
		_dat[x] = y;
		while(x > 0) {
			x = (x-1) / 2;
			_dat[x] = min(_dat[x*2+1], _dat[x*2+2]);
		}
	}

	T query(int a, int b) {
		return query(a, b, 0, 0, _n);
	}

	T query(int a, int b, int k, int l, int r) {
		if(b<=l || r<=a) return _initial;
		if(a<=l && r<=b) return _dat[k];
		return min( query(a,b,k*2+1,l,(l+r)/2), query(a,b,k*2+2,(l+r)/2,r) );
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	RMQ<int> rmq(n, INT_MAX);
	rep(i, q) {
		int c, x, y;
		cin >> c >> x >> y;
		if(c == 0) {
			rmq.update(x, y);
		} else {
			cout << rmq.query(x, y+1) << endl;
		}
	}

	return 0;
}

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

int main(void) {
  ll N, M, A, B;
  cin >> N >> M >> A >> B;

  bool ok;
  vector< vector<char> > ans(N, vector<char>(M, '.'));
  ll a = A, b = B;

  if(N % 2 == 1) {
    REP(i, 0, M / 2) {
      if(a == 0) break;
      ans[N - 1][i * 2 + 0] = '<';
      ans[N - 1][i * 2 + 1] = '>';
      a--;
    }
  }
  if(M % 2 == 1) {
    REP(i, 0, N / 2) {
      if(b == 0) break;
      ans[i * 2 + 0][M - 1] = '^';
      ans[i * 2 + 1][M - 1] = 'v';
      b--;
    }
  }

  ll y = 0, x = 0;
  ll n = N / 2 * 2, m = M / 2 * 2;
  while(a >= 2) {
    if(y >= n) break;
    ans[y + 0][x + 0] = '<';
    ans[y + 0][x + 1] = '>';
    ans[y + 1][x + 0] = '<';
    ans[y + 1][x + 1] = '>';
    a -= 2;
    x += 2;
    if(x >= m) {
      y += 2;
      x = 0;
    }
  }
  while(b >= 2) {
    if(y >= n) break;
    ans[y + 0][x + 0] = '^';
    ans[y + 1][x + 0] = 'v';
    ans[y + 0][x + 1] = '^';
    ans[y + 1][x + 1] = 'v';
    b -= 2;
    x += 2;
    if(x >= m) {
      y += 2;
      x = 0;
    }
  }

  if(y < n && N >= 3 && N % 2 == 1 && M >= 3 && M % 2 == 1 && a == 1 && b == 1) {
    ans[N - 3][M - 3] = '<';
    ans[N - 3][M - 2] = '>';
    ans[N - 2][M - 3] = '^';
    ans[N - 1][M - 3] = 'v';
    ans[N - 1][M - 2] = '<';
    ans[N - 1][M - 1] = '>';
    a--;
    b--;
  } else {
    if(y < n && a == 1) {
      ans[y + 0][x + 0] = '<';
      ans[y + 0][x + 1] = '>';
      a--;
      x += 2;
      if(x >= m) {
        y += 2;
        x = 0;
      }
    }
    if(y < n && b == 1) {
      ans[y + 0][x + 0] = '^';
      ans[y + 1][x + 0] = 'v';
      b--;
      x += 2;
      if(x >= m) {
        y += 2;
        x = 0;
      }
    }
  }

  if(a == 0 && b == 0) {
    cout << "YES" << endl;
    REP(i, 0, N) {
      REP(j, 0, M) cout << ans[i][j];
      cout << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        map<int, int> D;
        rep(i, N) {
            int d; cin >> d;
            D[d]++;
        }
        bool ok = true;
        int M; cin >> M;
        rep(i, M) {
            int d; cin >> d;
            if(D[d] <= 0) ok = false;
            D[d]--;
        }
        cout << (ok ? "YES" : "NO") << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 9728
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String x = sc.next();
        // final String y = sc.next();

        final int x = sc.nextInt();
        final int y = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();
        System.out.println(Solve(x) == Solve(y) ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }

    static int Solve(int val){
        if (val == 2) {
            return 3;
        } else if ("135781012".contains(String.valueOf(val))){
            return 1;
        } else {
            return 2;
        }


    }

}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int n,m;
int a[2000],b[2000],c[2000],d[2000],e[2000],f[2000];
int sum1[5000][5000],sum2[5000][5000];
int dist[5000][5000];

int lwb(vector<int>&v,int x){
	return lower_bound(v.begin(),v.end(),x)-v.begin();
}

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

int ok(int x,int y,int d){
	if(d==0){
		return sum2[x+1][y]==0;
	}
	else if(d==1){
		return sum2[x][y]==0;
	}
	else if(d==2){
		return sum1[x][y+1]==0;
	}
	else{
		return sum1[x][y]==0;
	}
}

int main(){
	cin>>n>>m;
	vector<int>xs,ys;
	xs.push_back(0);ys.push_back(0);
	xs.push_back(-2e9);xs.push_back(2e9);
	ys.push_back(-2e9);ys.push_back(2e9);
	rep(i,n){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		xs.push_back(a[i]);
		xs.push_back(b[i]);
		ys.push_back(c[i]);
	}
	rep(i,m){
		scanf("%d%d%d",&d[i],&e[i],&f[i]);
		xs.push_back(d[i]);
		ys.push_back(e[i]);
		ys.push_back(f[i]);
	}
	sort(xs.begin(),xs.end());xs.erase(unique(xs.begin(),xs.end()),xs.end());
	sort(ys.begin(),ys.end());ys.erase(unique(ys.begin(),ys.end()),ys.end());
	rep(i,n){
		a[i]=lwb(xs,a[i]);
		b[i]=lwb(xs,b[i]);
		c[i]=lwb(ys,c[i]);
		sum1[a[i]][c[i]]++;
		sum1[b[i]][c[i]]--;
	}
	rep(i,m){
		d[i]=lwb(xs,d[i]);
		e[i]=lwb(ys,e[i]);
		f[i]=lwb(ys,f[i]);
		sum2[d[i]][e[i]]++;
		sum2[d[i]][f[i]]--;
	}
	rep(i,xs.size()+1){
		rep(j,ys.size()+1){
			if(i)sum1[i][j]+=sum1[i-1][j];
			if(j)sum2[i][j]+=sum2[i][j-1];
		}
	}
	queue<P>que;
	memset(dist,-1,sizeof(dist));
	int sx=lwb(xs,0),sy=lwb(ys,0);
	dist[sx][sy]=0;
	que.push(P(sx,sy));
	while(!que.empty()){
		P p=que.front();que.pop();
		rep(k,4){
			int nx=p.first+dx[k],ny=p.second+dy[k];
			if(0<=nx&&nx<xs.size()-1&&0<=ny&&ny<ys.size()-1&&dist[nx][ny]==-1&&ok(p.first,p.second,k)){
				dist[nx][ny]=dist[p.first][p.second]+1;
				que.push(P(nx,ny));
			}
		}
	}
	if(dist[0][0]!=-1){
		puts("INF");return 0;
	}
	ll ans=0;
	rep(i,xs.size()-1)rep(j,ys.size()-1){
		if(dist[i][j]!=-1){
			ll h=xs[i+1]-xs[i],w=ys[j+1]-ys[j];
			ans+=h*w;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 195836
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Node{
  int key;
struct  Node *right,*left,*parent;
};
struct Node *root,*NIL;
void insert(int k)
{
struct  Node *y=NIL;
struct  Node *x=root;
 struct  Node *z;
  z=(struct Node*)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  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(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
   
   
}
void preorder(struct Node *u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
struct Node *find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}
int main()
{
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",com);
      if(strcmp(com,"find")==0){
	scanf("%d",&x);
	struct Node *t=find(root,x);
	if(t!=NIL) printf("yes\n");
	else printf("no\n");
      }
      else if(strcmp(com,"insert")==0){
    scanf("%d",&x);
    insert(x);
      }
      else if(strcmp(com,"print")==0){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
      }
    }
  return 0;
}

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

int main() {
  int s;
  cin >> s;
  
  int s1 = (s % 100) % 10;
  int s2 = (s % 100) / 10;
  int s3 = s / 100;
  
  cout << s1+s2+s3 << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000007;

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    ll a = 0, b = 0;
    for(int i = 1; i <= N+1; i++){
        a = (a + i-1) % MAX;
        b = (b + N-i+1) % MAX;
        if(i < K)continue;
        ans = (ans + b - a + 1 + MAX) % MAX;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <sstream>
using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> pages(n);
        for (int i = 0; i < n; i++) {
            cin >> pages[i];
        }
        vector<pair<int, int> > results;
        for (int i = 0; i < n; i++) {
            int start, end;
            start = end = pages[i];
            for (int j = i + 1; j < n; j++) {
                if (end + 1 == pages[j]) {
                    end++;
                    i++;
                } else {
                    break;
                }
            }
            results.push_back(make_pair(start, end));
        }
        stringstream ss;
        for (vector<pair<int, int> >::iterator it = results.begin(); it != results.end(); it++) {
            if (it->first == it->second) {
                ss << " " << it->first;
            } else {
                ss << " " << it->first << "-" << it->second;
            }
        }
        string result(ss.str());
        result.erase(0, 1);
        cout << result << endl;
    }
}

Measured memory_bytes: 0
/*************************************************************************
  >         File: A.cc
  >       Author: Yuan Lei
  >         Mail: yuanlei@indeed.com
  > Created Time: Sat Apr  1 21:02:44 2017
*************************************************************************/
#include <vector>
#include <cstdio>
#include <bitset>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <cstring>
#include <cassert>
#include <numeric>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>

const int N = 1e5 + 5;
int a[N * 3];
using LL = long long;

int main() {
  std::ios::sync_with_stdio(0);
  int n;
  std::cin >> n;
  n *= 3;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  LL sum = 0;
  std::sort(a, a + n);
  int left = 0, right = n - 1;
  while (left < right) {
    sum += a[right - 1];
    left++, right -= 2;
  }
  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

#define mod 1000000007
ll c[2001][2001];

int main(){
    int n, k;
    cin >> n >> k;
    
    c[0][0] = 1;
    // rep(i, n+1)c[0][i] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(j < 1)c[i][j] = c[i-1][j];
            else c[i][j] = (c[i-1][j] + c[i-1][j-1])%mod;
        }
    }

    for(int i = 1; i <= k; i++){
        cout << c[n-k+1][i]*c[k-1][i-1]%mod << endl;
    }


}

Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

void solve()
{

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string a,b; cin >> a >> b;
    int c=0;
    for (int i=0; i<a.size();i++)
    {
        if (a[i]!=b[i]) c++;
    }
    cout << c;
}


Measured memory_bytes: 3804
#include <iostream>
using namespace std;
  int p[10000001];
int main(){

  for(int i = 2 ; i < 10000001 ; i++ )p[i] = 1;
  p[0]=p[1]=0;
  for(int i = 2 ; i*i < 10000001 ; i++ ){
    if(p[i])for(int j = i*2 ; j < 10000001 ; j+=i)p[j]=0;
  }

  int n;
  while(cin >> n, n){
    for(int i = n ; i >= 0 ; i--){
      if(p[i] == 1 && p[i-2] == 1 && p[i-6] == 1 && p[i-8] == 1){
	cout << i << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 40220
from fractions import gcd
a,b,c,d=map(int,input().split())
cd=gcd(c,d)
D=b//d-(a-1)//d
C=b//c-(a-1)//c
CD=b//(c*d//cd)-(a-1)//(c*d//cd)
print(b-a+1-(D+C-CD))

Measured memory_bytes: 5688
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define db double
#define ld long double
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define TEST int T; cin >> T; while(T--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//#define int long long
 
const int N = 2e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;

int h[N], a[N];
ll dp[N], f[N];

void inc(int i, ll val) {
    for (; i < N; i |= i + 1) {
        f[i] = max(val, f[i]);
    }
}

ll get(int i) {
    ll ans = 0;
    for (; i >= 0; i &= i + 1, i--) {
        ans = max(ans, f[i]);
    }
    return ans;
}


signed main() { __
//    freopen("lcm.in", "r", stdin);
//    freopen("lcm.out", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        dp[i] = 0;
        dp[i] = get(h[i] - 1) + a[i];
//        for (int j = 1; j < i; j++) {
//            if(h[i] > h[j])
//                dp[i] = max(dp[i], dp[j]);
//        }
        inc(h[i], dp[i]);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 4992
class Node:
    def __init__(self,key):
        self.key=key
        self.left=None
        self.right=None


def insert(root,node):#rootを根に持つ２分探索木にnodeを追加する
    if(root.key <= node.key):
        if(root.right is None):
            root.right=node
        else:
            insert(root.right,node)
    
    else:
        if(root.left is None):
            root.left=node
        else:
            insert(root.left,node)


def find(root,key):
    if(root.key==key):
        return 1

    elif(root.key < key):
        if(root.right is not None):
            return find(root.right,key)
        else:
            return 0

    else:
        if(root.left is not None):
            return find(root.left,key)
        else:
            return 0



    

def Preorder(root,order):
    order.append(root.key)
    if(root.left is not None):
        Preorder(root.left,order)
    
    if(root.right is not None):
        Preorder(root.right,order)




def Inorder(root,order):
    if(root.left is not None):
        Inorder(root.left,order)
    
    order.append(root.key)

    if(root.right is not None):
        Inorder(root.right,order)




n=int(input())

root=None

for loop in range(n):
    ope=input().split()

    if(ope[0]=="insert"):
        tmp_node=Node(int(ope[1]))
        try:
            insert(root,tmp_node)
        except:
            root=tmp_node
    
    elif(ope[0]=="find"):
        try:
            if(find(root,int(ope[1]))):
                print("yes")

            else:
                print("no")
        except:
            print("no")

    else:
        in_order=[]
        p_order=[]
        
        Inorder(root,in_order)
        Preorder(root,p_order)

        for x in in_order:
            print(f" {x}",end="")
        print()
        for x in p_order:
            print(f" {x}",end="")
        print()


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

int main() {
  int n, c, s, f, time = 0;
  vector<int> vc, vs, vf;
  cin >> n;
  
  for (int i=0; i<n-1; i++) {
    cin >> c;
    vc.push_back(c);
    cin >> s;
    vs.push_back(s);
    cin >> f;
    vf.push_back(f);
  }
  
  for (int i=0; i<n-1; i++) {
    time = 0;
    for (int j=i; j<n-1; j++) {
      if (time<vs[j]) time=vs[j];
      else {
        if (time%vf[j]==0) {;}
        else time+=(vf[j]-(time%vf[j]));
      }
      time+=vc[j];
    }
    cout << time << '\n';
  }
  
  cout << 0 << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int value[200010];
int main() {
    int n;
    cin >> n;
    int all = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        value[i] = a;
        all ^= a;
    }
    int ans;
    for (int i = 0; i < n; i++) {
        ans = all ^ value[i];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4276
from collections import defaultdict

N,M = map(int,input().split())

S = defaultdict(list)

for i in range(M):
    inp = list(map(int,input().split()))
    for j in range(1,inp[0]+1):
        S[inp[j]].append(i)

P = list(map(int,input().split()))

ans = 0
for i in range(int(pow(2,N))):
    u = i
    s_list = [0 for i in range(M)]
    for j in range(1,N+1):
        if u%2==1:
            for s in S[j]:
                s_list[s] += 1
        u//=2
    is_tento = True
    for s in range(M):
        if s_list[s]%2!=P[s]:
            is_tento = False
            break
    if is_tento:ans += 1

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    vector<int> a(3);
    REP(i,3){
        cin >> a[i];
    }
    sort(ALL(a));
    int x = a[2] - a[1];
    int y = a[2] - a[0];
    int ans=0;
    if ((x + y) % 2 == 0)
    {
        ans = x / 2 + y / 2 + (x % 2 == 1);
    }
    else{
        ans = x / 2 + y / 2 + 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){

    long double n, k ;
    cin >> n >> k;
    long double ans = 0 ;
    for(long double i = 1; i <= n; i++){

        long double tmp = i;
        int s = 0 ;
        while(tmp < k){
            tmp*= 2 ;
            s++ ;
        }
        ans += (long double)1/(long double)(1<<s) ;

    }
    cout << fixed << setprecision(11) << ans/n ;

}


Measured memory_bytes: 256
#import random
n = int(input())
a = list(map(int,input().split()))

#n = 3
#a = [1,2,3,4,5,6,7,8,9]

a = sorted(a,reverse=True)

ans = 0
for i in range(n):
  ans += a[2*i+1]
print(ans)


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

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll>a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }

  for(ll i=k;i<n;i++){
    if(a[i-k]<a[i]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

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

int main(void){
    // Your code here!
    string s,t;
    cin >> s >> t;
    int ans = t.size();
    rep(i,s.size() - t.size() + 1) {
        string now = s.substr(i,t.size());
        int diff = 0;
        rep(j,t.size()) {
            if(t[j] != now[j]) diff++;
        }
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
// ABC176A - Takoyaki

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N, X, T;
	cin >> N >> X >> T;

	cout << ((N+X-1)/X) * T << endl;

	return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int x = 0, y = 0;
  for (int i = 1; i < 1010; i++)
  {
    if (int(i * 0.08) == a)
    {
      //cout << i<< endl;
      x = i;
      if (int(i * 0.1) ==b)
      {
        y = i;
        break;
      }
    }
  }
  
  /*for (int i = x; i > 0; i--)
  {
    if (int(i * 0.1) == b)
    {
      y = i;
      break;
    }
  }*/
  //cout << x << y << endl;
  
  if (x == y)
    cout << x << endl;
  else
    cout << -1 << endl;
}

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

typedef long long int ll; 

int main(void)
{
	ll x,y;
	cin >> x >> y;
	ll c,t;
	ll temp = y-(2*x);
	if(temp<0)
		cout << "No\n";
	else
	{
		if(temp%2==1)
			cout << "No\n";
		else
		{
			t = temp/2;
			c = x-t;
			if(c >= 0 && t>=0)
				cout << "Yes\n";
			else
			cout << "No\n";
		}
	}


	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll N, A, B; cin >> N >> A >> B;
  ll AB = A+B, ans = 0;
  ans += N/AB*A;
  N -= N/AB*(A+B);
  ans += min(N, A);
  cout << ans << endl;
  return 0;
}


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

int main(){
  int h,w,k;
  cin >>h>>w>>k;
  vector<vector<char>> field(h, vector<char>(w));
  vector<vector<char>> tmp(h, vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >>field.at(i).at(j);
    }
  }
  
  int ans=0;
  for(int bith=0;bith<(1<<h);bith++){
    for(int bitw=0;bitw<(1<<w);bitw++){
      for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
      		tmp.at(i).at(j)=field.at(i).at(j);
    	}
      }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if((bith>>i)&1){
            for(int jj=0;jj<w;jj++){
              tmp.at(i).at(jj)='r';
            }
          }
          if((bitw>>j)&1){
            for(int ii=0;ii<h;ii++){
              tmp.at(ii).at(j)='r';
            }
          }
        }
      }
      int tmp3=0;
      for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
          if(tmp.at(i).at(j)=='#')tmp3++;
    	}
      }
      if(tmp3==k)ans++;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int N,Q,a,b,i;
long long sum=0;
vector<int> A;
unordered_map<int,int> mp;
int main(){
  cin>>N;
  A.resize(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    mp[A.at(i)]++;
    sum+=A.at(i);
  }
  cin>>Q;
  for(i=0;i<Q;i++){
    cin>>a>>b;
    mp[b]+=mp[a];
    sum+=(b-a)*mp[a];
    mp[a]=0;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int j=s.size();
  rep(i,j)cout<<'x';
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define int long long

using namespace std;

signed main()
{
	int n;
	vector<int> a;
	vector<int> x;

	cin >> n;

	a.resize(n);
	x.resize(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	int sign = 1;
	for(int i = 0; i < n; ++i)
	{
		x[0] += a[i] * sign;
		sign *= -1;
	}

	for(int i = n - 1; i > 0; --i)
	{
		x[i] = 2 * a[i] - x[(i + 1) % n];
	}

	cout << x[0];
	for(int i = 1; i < n; ++i)
	{
		cout << " " << x[i];
	}
	cout << endl;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll k, n; cin >> k >> n;
    vl v(n); _for(i,0,n) cin >> v[i];
    sort(all(v));

    ll mx = 0;
    _for(i,1,n) mx = max(v[i] - v[i-1], mx);

    mx = max((k - (v[n-1] - v[0])),mx);

    cout << k - mx;
}

Measured memory_bytes: 4752
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
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;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int N = []() -> int {
        int t;
        cin >> t;
        return t;
    }();
    vector<int> t(N);
    vector<double> v(N);
    rep(i, N) cin >> t[i];
    rep(i, N) cin >> v[i];
    const int T = [&t]() -> int {
        int tmp = 0;
        for (auto& ti : t) tmp += ti;
        return tmp;
    }();
    vector<double> maxv(T * 2 + 1, (double)INF);
    int nowT = 0;
    rep(i, N) {
        rep(ti, t[i]) {
            int t1 = nowT + ti * 2;
            int t2 = nowT + ti * 2 + 1;
            maxv[t1] = min(maxv[t1], v[i]);
            maxv[t2] = min(maxv[t2], v[i]);
        }
        nowT += t[i] * 2;
        maxv[nowT] = min(maxv[nowT], v[i]);
    }
    maxv[0] = maxv[2 * T] = 0;
    rep(ti, 2 * T) { maxv[ti + 1] = min(maxv[ti + 1], maxv[ti] + 0.5); }
    for (int ti = 2 * T - 1; ti >= 0; ti--) {
        maxv[ti] = min(maxv[ti], maxv[ti + 1] + 0.5);
    }
    double ans = 0.0;
    rep(i, 2 * T + 1) { ans += (maxv[i] + maxv[i + 1]) * 0.5 / 2.0; }
    printf("%.6f\n", ans);

    return 0;
}

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

int main(){
    
    // 1. 入力情報.
    int K, T;
    scanf("%d %d", &K, &T);
    int maxA = 0, total = 0;
    rep(i, T){
        int a;
        scanf("%d", &a);
        maxA = max(maxA, a);
        total += a;
    }
    
    // 2. 前日と同じ種類のケーキを食べる日数を最小化する.
    int ans = max(0, maxA - (total - maxA) - 1);
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(){
	int a,b;
	cin >> a >>b;
	cout << a/b << " " << a%b << " ";
	cout << fixed << setprecision(7);
	cout << (double)a/b<<endl;
	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
struct Node{
    int key;
    Node *r,*l,*p;
};
Node *root,*NIL;
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    while(x != NIL) {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;
    if(y == NIL) root = z;
    else {
        if(z->key < y->key) y->l = z;
        else y->r = z;
    } 
}

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

int main() {
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i = 0;i < n;i++) {
        cin>>com;
        if(com == "insert") {
            scanf("%d",&x);
            insert(x);
        }
        else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26704
import sys
c = [int(sys.stdin.readline()) for _ in range(5)]
cc = [(v + 9) // 10 * 10 for v in c]
ccc = sorted(zip(cc, c), key=lambda x:x[1] - x[0], reverse=True)
ret = sum([v[0] for v in ccc[:-1]]) + ccc[-1][1]
print(ret)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	int n; cin >> n;
	if (n % 1000 == 0) {
		cout << n % 1000 << endl;
	}
	else {
		cout << 1000 - n % 1000 << endl;
	}
	return 0;

}


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

int main(){
	char lun[11];
	scanf("%s", lun);
	int min=643;
	int x;
	int i=0;
	while(lun[i+2] != '\0'){
		x=0;
		x+=(lun[i]-'0')*100;
		x+=(lun[i+1]-'0')*10;
		x+=lun[i+2]-'0';
		x= abs(x-753);
		if(x<min) min = x;
		i++;
	}
	printf("%d", min);
	
	return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <cstdio>
using namespace std;
int a[26];
int main()
{
    char c;
    int n, m, x=0, y=0, g=0;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; ++i)
    {
        getchar();
        for(int j=0; j<m; ++j)
        {
            scanf("%c",&c);
            ++a[c-'a'];
        }
    }
    for(int i=0; i<26; ++i)
    {
        if(a[i]&1)
        {
            ++x;
            --a[i];
        }
        a[i] %= 4;
        if(a[i]) ++y;
    }
    if((!(n&1) && !(n&1) && x) || x > 1) return 0*puts("No");
    if(n&1) g += m/2;
    if(m&1) g += n/2;
    if(y <= g) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
A = list(map(int, input().split()))
B = [0] * (N)
for i in range(N):
  B[i] = A[i] - (i+1)
B.sort()
  
if N%2 == 0:
  median_l = B[N//2-1]
  median_r = B[N//2]
  ans_l = 0
  ans_r = 0
  for i in range(N):
    ans_l += abs(A[i]-(median_l+i+1))
    ans_r += abs(A[i]-(median_r+i+1))
  print(min(ans_l, ans_r))
else:
  median = B[N//2]
  ans = 0
  for i in range(N):
    ans += abs(A[i]-(median+i+1))
  print(ans)


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

int mapp[200010];
int dp[200010];

int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&mapp[i]);
	}
	dp[1]=0;
	dp[2]=abs(mapp[1]-mapp[2]);
	for (int i=3;i<=n;i++){
		dp[i]=min(dp[i-2]+abs(mapp[i]-mapp[i-2]),dp[i-1]+abs(mapp[i]-mapp[i-1]));
	}
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = []
B = []
cnt = 0
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(N)[::-1]:
    amari = (A[i] + cnt) % B[i]
    if amari != 0:
        add = B[i] - amari
        cnt += add
print(cnt)    

Measured memory_bytes: 11052
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 101;
const int mod = 1e9 + 7;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int f[MAX][MAX*MAX];

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);

  f[N][0] = 1;
  for (int i = N; i >= 1; --i) {
    for (int x = 0; x <= (N-i)*K; ++x) {
      for (int ai = 0; ai <= K; ++ai) {
        int nx = ai > i ? x : (x + (x + ai) / i);
        f[i-1][nx] = add(f[i-1][nx], f[i][x]);
      }
    }
  }

  int kills = 0;
  for (int x = 0; x <= N*K; ++x) {
    kills = add(kills, mul(x, f[0][x]));
  }

  int total = 1;
  REP(i, N-1) total = mul(total, K+1);
  total = mul(total, N);
  total = mul(total, K*(K+1)/2);

  int ans = sub(total, kills);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, M, sum = 0; cin >> N >> M;
  vector<ll> A(N), D(N, 0);
  vector<pair<ll, ll>> CB(M);
  rep(i, 0, N) {
  	cin >> A[i];
  }
  vsort(A);
  rep(i, 0, M) {
  	ll B, C; cin >> B >> C;
    CB[i] = make_pair(C, B);
  }
  sort(CB.begin(), CB.end(), greater<pair<ll, ll>>());
  ll j = 0;
  rep(i, 0, N) {
    D[i] = CB[j].first;
    CB[j].second--;
    if (CB[j].second <= 0) {
    	j++;
    }
    if (CB[M - 1].second <= 0) break;
  }
  rep(i, 0, N) {
  	if (A[i] < D[i]) {
    	A[i] = D[i];
    }
    sum += A[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
using namespace std;
int d[51][51],m[51];
bool ans[51];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		ans[i]=false;
	for(int i=0;i<k;i++){
		cin>>m[i];
		for(int j=0;j<m[i];j++)
			cin>>d[i][j];
		sort(d[i],d[i]+m[i]);
	}
	int r,p,q;
	cin>>r;
	for(int u=0;u<r;u++){
		cin>>p>>q;
		for(int i=0;i<k;i++){
			bool tp=false,tq=false;
			for(int j=0;j<m[i];j++){
				if(d[i][j]==p)tp=true;
				if(d[i][j]==q)tq=true;
			}
			if(tp==true&&tq==true)
			ans[p]=true,ans[q]=true;
		}
	}
	int aans=0;
	for(int i=0;i<=n;i++)
		if(ans[i]==true)aans++;
	cout<<aans<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  bool check=false;
  
  
  for(int i=0;i<N/4+1;i++){
    for(int j=0;j<N/7+1;j++){
      if(4*i+7*j==N){
        check=true;
      }
    }
  }
  
  if(check){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>
using namespace std;

int main(){
	cout << fixed << setprecision(10);
	const long double EPS=1e-8;
	long double Re,Im;
	int q;
	complex<long double>p1,p2;
	
	cin>>Re>>Im;
	p1.real(Re);
	p1.imag(Im);
	cin>>Re>>Im;
	p2.real(Re);
	p2.imag(Im);
	cin>>q;
	
	for(int i=0;i<q;i++){
		cin>>Re>>Im;
		complex<long double>tmp(Re,Im),p1_copy=p1,p2_copy=p2;
		
		
		tmp-=p1_copy;
		p2_copy-=p1_copy;
		complex<long double>p1_re=p1_copy;
		p1_copy-=p1_copy;
		tmp=tmp/p2_copy;
		complex<long double>p2_re=p2_copy;
		p2_copy=p2_copy/p2_copy;
		complex<long double>res=tmp;
		res.imag(0);
		
		
		res*=p2_re;
		res+=p1_re;
		cout<<res.real()<<" "<<res.imag()<<endl;
	}
	
}


Measured memory_bytes: 3296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0, };
typedef pair<int, int>P;

int H, W, N;
string S, T;
int sx, sy;
signed main() {
	cin >> H >> W >> N;
	cin >> sx >> sy;
	cin >> S >> T;
	int x = sx, y = sy;
	REP(i, N) {
		if (S[i] == 'D') {
			x++;
		}
		if (x > H) {
			print("NO"); return 0;
		}
		if (T[i] == 'U') {
			if (x > 1)x--;
		}
	}
	x = sx;
	REP(i, N) {
		if (S[i] == 'U') {
			x--;
		}
		if (x ==0) {
			print("NO"); return 0;
		}
		if (T[i] == 'D') {
			if (x <H)x++;
		}
	}
	REP(i, N) {
		if (S[i] == 'R') {
			y++;
		}
		if (y>W) {
			print("NO"); return 0;
		}
		if (T[i] == 'L') {
			if (y>1)y--;
		}
	}
	y = sy;
	REP(i, N) {
		if (S[i] == 'L') {
			y--;
		}
		if (y == 0) {
			print("NO"); return 0;
		}
		if (T[i] == 'R') {
			if (y <W)y++;
		}
	}
	print("YES");
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll n;
    string s;
    cin >> n >> s;
    
    ll res = 1;
    char temp = s[0];
    For(i, 1, n){
        if(s[i] != temp){
            res ++;
            temp = s[i];
        }
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			HashSet<string> strSet = new HashSet<string>() {
				"A", "C", "G", "T"
			};

			var input = Console.ReadLine().ToCharArray();
			int count = 0;
			for ( int i = 0; i < input.Length; i++ ) {
				int tmpCount = 0;
				for ( int j = i; j < input.Length; j++ ) {
					if ( strSet.Contains(input[j].ToString()) ) {
						tmpCount++;
						if ( count < tmpCount ) {
							count = tmpCount;
						}
					}
					else {
						tmpCount = 0;
					}
				}
			}
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 13280
#include <iostream>

using namespace std;

int main(){

  int N,D,X,A;
  int ans = 0;

  cin >> N >> D >> X;
  ans = X;

  for(int i = 0; i < N; i++){
    cin >> A;
    
    ans += 1 + (D - 1) / A;

  }

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>

int n, m, a, b;

int main()
{
	std::ios::sync_with_stdio(0);
	std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> m >> a >> b;
	std::cout << (n - a) * (m - b) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  map<int,int> memo;
  ll ans=0;
  for(int i=1;i<n+1;i++){
    int a;
    cin>>a;
    memo[a+i]++;
    ans+=memo[i-a];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 20664
H,W = map(int,input().split())
MOD = 10 ** 9 + 7

grid = [""] * H
for i in range(H):
  grid[i] = input()
  
dp = [[0] * W for i in range(H)]
dp[0][0] = 1
for i in range(H):
  for j in range(W):
    if i + 1 < H and grid[i + 1][j] != "#":
      dp[i + 1][j] += dp[i][j]
      dp[i + 1][j] %= MOD
    if j + 1 < W and grid[i][j + 1] != "#":
      dp[i][j + 1] += dp[i][j]
      dp[i][j + 1] %= MOD
      
print(dp[-1][-1])

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    while ((a[i] & 1) == 0) {
      a[i] = a[i] >> 1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n, m, a[100][100], b[100];
    int i, j, s;

    scanf("%d %d", &n, &m);
    for (i=0; i<n; i++) {
        for (j=0; j<m; j++) {
	    scanf("%d", &a[i][j]);
	}
    }
    for (i=0; i<m; i++) scanf("%d", &b[i]);
    for (i=0; i<n; i++) {
        s=0;
	for (j=0; j<m; j++) s+=a[i][j]*b[j];
	printf("%d\n", s);
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n, m;
    cin >> n >> m;

    int L = 0, R = n + 1;
    for (int i = 0, l, r; i < m; ++i) {
        cin >> l >> r;
        L = max(L, l); R = min(R, r);
    }

    if (L <= R) cout << R - L + 1 << endl;
    else cout << "0\n";

    return 0;
}


Measured memory_bytes: 256