akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

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

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF = 1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct solver_of_linear_equations {
	int n;
	ld a[102][102];
	void run(){
		rep(i,n){
			for(int j = i ; j < n ; j ++){
				if(abs(a[j][0]) > abs(a[i][0]))swap(a[i],a[j]);
			}
			for(int j = i+1 ; j < n ; j ++){
				for(int k = n ; k >= i ; k --){
					a[j][k] -= a[i][k]*a[j][i]/a[i][i];
				}
			}
		}
		rrep(i,n){
			for(int j = i+1 ; j < n ; j ++){
				a[i][n] -= a[j][n]*a[i][j];
				a[i][j] = 0;
			}
			a[i][n] /= a[i][i];
			a[i][i] = 1.0;
		}
	}
}solver;

int main(){
	while(1){
		static int n,s,t;
		static int q[102];
		static int a[102][102];
		scanf("%d%d%d",&n,&s,&t);
		if(n == 0)break;
		rep(i,n)scanf("%d",&q[i]);
		rep(i,n)rep(j,n)scanf("%d",&a[i][j]);
		
		static int d[102][102];
		rep(i,102)rep(j,102)d[i][j] = INF;
		rep(i,n)rep(j,n)d[i][j] = (a[i][j]==0)?INF:a[i][j];
		rep(i,n)d[i][i] = 0;
		rep(k,n)rep(i,n)rep(j,n)d[i][j] = min ( d[i][j] , d[i][k] + d[k][j]);
		
		if(d[s-1][t-1] == INF){
			puts("impossible");
			return 0;
		}
		
		/*rep(i,n){
			rep(j,n)printf("%d ",d[i][j]);
			cout << endl;
		}*/
		
		solver.n = n;
		rep(i,n)rep(j,n+1)solver.a[i][j] = 0;
		rep(i,n){
			int cnt = 0;
			rep(j,n){
				if(q[i] == 0){
					if(a[i][j] != 0){
						cnt ++;
						solver.a[i][n] -= a[i][j];
						solver.a[i][j] = 1.0;
					}
				}
				else {
					if(a[i][j] != 0 && d[i][t-1] == d[j][t-1] + a[i][j]){
						cnt ++;
						solver.a[i][n] -= a[i][j];
						solver.a[i][j] = 1.0;
					}
				}
			}
			solver.a[i][i] -= cnt;
		}
		rep(i,n+1)solver.a[t-1][i] = 0;
		solver.a[t-1][t-1] = 1.0;
		
		/*rep(i,n){
			rep(j,n+1){
				printf("%lf ",solver.a[i][j]);
			}
			cout << endl;
		}*/
		
		solver.run();
		
		/*rep(i,n){
			rep(j,n+1){
				printf("%lf ",solver.a[i][j]);
			}
			cout << endl;
		}*/
		cout.precision(20);
		cout << solver.a[s-1][n] << endl;
		/*if(solver.a[s-1][n] >= 0){}
		else {
			printf("%d %d %d\n",n,s,t);
			rep(i,n)printf("%d ",q[i]); puts("");
			rep(i,n){
				rep(j,n){
					printf("%d ",a[i][j]);
				}
				cout << endl;
			}
			return 0;
		}*/
	}
}

Measured memory_bytes: 1508
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {ans+=(a[i-1]-a[i]);a[i]=a[i-1];}

    }
    cout<<ans;
}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int ans[310][310];
string board[310];

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

	rep(i, h) cin >> board[i];

	int idx = 1;
	rep(j, w){
		int pidx = -1;

		rep(i, h) {
			if(board[i][j] == '#') {
				pidx = idx++;
			}
			ans[i][j] = pidx;
		}

		pidx = -1;
		rrep(i, h) {
			if(ans[i][j] == -1) {
				ans[i][j] = pidx;
			}
			pidx = ans[i][j];
		}
	}

	rep(j, 1, w) {
		if(ans[0][j] == -1){
			rep(i, h){
				ans[i][j] = ans[i][j - 1];
			}
		}
	}

	rrep(j, w - 1) {
		if(ans[0][j] == -1){
			rep(i, h){
				ans[i][j] = ans[i][j + 1];
			}
		}
	}

	rep(i, h){
		rep(j, w) cout << (j?" ":"") << ans[i][j];
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1280
import sys

def divisor(N, B):
    i = 1
    d = []
    while i ** 2 <= N:
        if N % i == 0:
            B[i-1] = (B[i-1] + 1) % 2
            if i ** 2 < N: B[N // i - 1] = (B[N//i - 1] + 1) % 2 
        i += 1
    return 0


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [0] * N
    ans = []
    M = 0

    for i in reversed(range(N)):
        if B[i] != A[i]:
            divisor(i+1, B)
            M += 1
            ans.append(i+1)

    print(M)
    print(" ".join(map(str, ans)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 83960
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int result = 700;
		for(int i = 0 ; i < 3 ; i++) {
			if(S.charAt(i) == 'o') {
				result += 100;
			}
		}
		System.out.println(result);
		
		
		
	}

}


Measured memory_bytes: 22732
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int n;
  int i,j;
  int alice,bob;
  int temp;
  int nlayer=1;
  
  cin>>n;
  vector<int> d(n,0);
  for(i=0;i<n;i++)cin>>d.at(i);
 
  for(i=0;i<n;i++){
    for(j=0;j<n-i-1;j++){
      if(d.at(j)<d.at(j+1)){
      	temp = d.at(j);
        d.at(j) = d.at(j+1);  
        d.at(j+1) = temp;}
    }
  }
  for(i=0;i<n-1;i++){
    if(d.at(i)!=d.at(i+1))nlayer++;
  }
  cout<<nlayer;
}

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

using namespace std;

int main(void) {
	int K, N;
	int input;
	vector<int> A, dist;
	cin >> K >> N;
	for (int i = 0; i < N; i++) {
		cin >> input;
		A.emplace_back(input);
	}
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			dist.emplace_back(abs(A[i] - A[N - 1]));
		}
		else {
			dist.emplace_back(abs(A[i] + K - A[i - 1]));
		}
	}
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			dist.emplace_back(abs(A[N - 1] - A[i]));
		}
		else {
			dist.emplace_back(abs(A[i - 1] + K - A[i]));
		}
	}
	sort(dist.begin(), dist.end());
	cout << dist[0] << endl;
	return 0;
}

Measured memory_bytes: 3188
from collections import deque


def isPalindrome(s):
    L = len(s)
    rst = True
    if L:
        for i in range(L // 2):
            if s[i] != s[L - 1 - i]:
                rst = False
                break
    return rst


N = int(input())
S = []
for _ in range(N):
    s, c = input().split()
    S.append((s, int(c)))

path = [dict() for _ in range(2)]
q = deque()
S.sort(key=lambda x: x[1])
for s, c in S:
    if s not in path[0] or path[0][s] > c:
        path[0][s] = c
        q.append((0, s, c))

ans = float('inf')
isPossible = False
while q:
    side, s0, c0 = q.popleft()
    if isPalindrome(s0):
        ans = min(ans, c0)
        isPossible |= True
    else:
        for s1, c1 in S:
            if side == 0:
                l = s0
                r = s1
            else:
                l = s1
                r = s0

            isCandidate = False
            if len(l) > len(r):
                for i in range(len(r)):
                    if l[i] != r[-1 - i]:
                        break
                else:
                    ns = l[len(r):]
                    nc = c0 + c1
                    nside = 0
                    isCandidate |= True
            elif len(l) < len(r):
                for i in range(len(l)):
                    if l[i] != r[-1 - i]:
                        break
                else:
                    ns = r[:-len(l)]
                    nc = c0 + c1
                    nside = 1
                    isCandidate |= True
            else:
                for i in range(len(l)):
                    if l[i] != r[-1 - i]:
                        break
                else:
                    ns = ''
                    nc = c0 + c1
                    nside = 0
                    isCandidate |= True
            if isCandidate and (ns not in path[nside] or path[nside][ns] > nc):
                path[nside][ns] = nc
                q.append((nside, ns, nc))
if isPossible:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 74672
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
 long long int d[101][100001];
 long long int knapsack(long long int a[],long long int b[], long long int n, long long int w,long long int i){
      long long int k=0,l=0;
       if(n==1||w==0)
       	return 0;
       if(d[n-1][w-1]==-1){
      k=knapsack(a,b,n-1,w,i);
   if(a[n-1]<=w){
   l=b[n-1]+knapsack(a,b,n-1,w-a[n-1],i);
}
d[n-1][w-1]=max(l,k);
}
         
	return(d[n-1][w-1]);
}
int main(){
	 long long int n,i,j,k,l,w;
	cin>>n>>w;
	long long int a[n+1],b[n+1];
	for(i=1;i<=n;i++){
		cin>>j>>k;
		a[i]=j;
		b[i]=k;
	}
	memset(d,-1,sizeof(d));
	//cout<<d[0][1];
	l=knapsack(a,b,n+1,w,0);
cout<<l;
}

Measured memory_bytes: 79104
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int x, t;

int main(){
	cin >> x >> t;
	if(x <= t){
		cout << "0";
	}else{
		cout << x - t;
	}

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;

	vector<int> cnt(3, 0);
	for (int i = 0; i < s.size(); ++i) {
		int idx = (int)(s[i] - 'a');
		++cnt[idx];
	}
	sort(cnt.rbegin(), cnt.rend());

	bool can = true;
	for (int i = 0; i < 3; ++i) {
		int len = s.size() / 3;
		if (s.size() % 3 > i) { ++len; }
		if (cnt[i] != len) { can = false; }
	}

	if (can) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

bool Bsearch(int key, int A[], int len) {
	int l = 0, r = len - 1;
	while (l <= r) {
		int mid = l + (r - l) / 2;
		if (A[mid] > key)
			r = mid - 1;
		else if (A[mid] < key)
			l = mid + 1;
		else
			return true;
	}
	return false;
}

int main() {
	int n, *S;
	int q, *T;
	int ans = 0;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	T = new int[q];
	for (int i = 0; i < q; i++)
		cin >> T[i];

	sort(S, S + n);
	for (int i = 0; i < q; i++)
		if (Bsearch(T[i], S, n) == true)
			ans++;
	cout << ans << endl;

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

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int cnt1=0;
    rep(i,2,n-1){
    if (s[i]=='C') cnt1++;
    }
    int cnt2=0;
    rep(j,0,n){
        if(s[j]>='A'&&s[j]<='Z') cnt2++;
    }
    if(s[0]!='A') cout<<"WA";
    else if (cnt1!=1) cout<<"WA";
    else if (cnt2!=2) cout<< "WA";
    else cout<<"AC";
}


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

int main(){
  int N , flag = 1 , counter = 0;
  int A[100];
  cin >> N;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    A[i] = tmp;
  }

  while(flag){
    flag = 0;
    for(int j=0;j<N-1;j++){
      if(A[j] > A[j+1]){
        int tmp;
        tmp = A[j+1];
        A[j+1] = A[j];
        A[j] = tmp;
        flag = 1;
        counter++;
      }
    }
  }

  for(int i=0;i<N-1;i++){
    cout << A[i] << ' ';
  }
  cout << A[N-1] << endl << counter << endl;
  return 0;
}



Measured memory_bytes: 3088
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, A, B = map(int, input().split())
S = input()

for s in S:
    if s == 'a' and A + B > 0:
        print("Yes")
        if A > 0:
            A -= 1
        else:
            B -= 1
    elif s == 'b' and B > 0:
        print("Yes")
        B -= 1
    else:
        print("No")

Measured memory_bytes: 4572
#include<iostream>
#include<string>
#include<vector>
#include<iterator>

using namespace std;

int count = 0;

struct Card
{

  bool flag;
  string number;

};

int LiningUpTheCards(int k, Card card, vector<Card> &bunch_card , vector<Card> &kind_num)
{

  int dummy;
  int start;

  if(k == 0)
    {

      bool flag = true;

      for(int i = 0; i < kind_num.size(); ++i )
          if(!kind_num[i].number.compare(card.number))
            {
              flag = false;
              break;
            }

      if(flag)
        {
          kind_num.push_back(card);
          count++;
        }

      return 0;

    }

  else{

    for(int j = 0; j < bunch_card.size(); ++j)
      {

        if(bunch_card[j].flag)
          {

            bunch_card[j].flag = false;
            start = card.number.length();
            card.number += bunch_card[j].number;
            dummy = LiningUpTheCards(k-1,card,bunch_card,kind_num);
            bunch_card[j].flag = true;
            card.number.erase(start);

          }

      }

  }

  return 0;

}

int main()
{

  int k;
  int n;
  int dummy;
  Card input;
  vector<Card> kind_num;
  vector<Card> bunch_card;

  input.flag = true;

  cin >> n;
  cin >> k;

  while(n != 0 || k != 0)
    {

      for(int i = 0; i < n; ++i)
        {
          cin >> input.number;
          bunch_card.push_back(input);
        }

      input.number.erase();

      dummy = LiningUpTheCards(k,input,bunch_card,kind_num);

      kind_num.clear();
      bunch_card.clear();

      cout << count << endl;

      cin >> n;
      cin >> k;

      count = 0;

    }

}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    VS s(h); cin >> s;

    auto dis = defvec<int>(INF, h, w);
    queue<pair<int, int>> bfs;
    FOR(y, 0, h)FOR(x, 0, w)if (s[y][x] == '#') {
        dis[y][x] = 0;
        bfs.emplace(y, x);
    }
    int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
    while (!bfs.empty()) {
        int y, x;
        tie(y, x) = bfs.front();
        bfs.pop();
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            if (!chmin(dis[ny][nx], dis[y][x] + 1))continue;
            bfs.emplace(ny, nx);
        }
    }

    int ans = 0;
    each(i, dis)chmax(ans, *max_element(all(i)));
    cout << ans << "\n";
}

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

using namespace std;

int main () {
	int n; cin >> n;
	
	
	string a, b;
	cin >> a >> b;
	
	long long res = 3;
	
	if (a[0] != b[0]) res *= 2;
	
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] ) {
			if (i + 1 < n) {
				res *= 2;
			}
		}
		else if (i + 2 < n) {
			i++;
			if (a[i + 1] != b[i + 1]) {
				res *= 3;
			}
		}
		res %= 1000000007;
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

n,ans=int(input()),0

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
C.sort()

for b in B:
  j = bisect_left(A,b)
  k = bisect_right(C,b)
  ans += j*(n-k)
  
print(ans)

Measured memory_bytes: 23156
#include<iostream>
#include<algorithm>
#define REP(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

int nlist[2010];
int b[2010];

int main(){
  lli N,x;
  cin>>N>>x;
  REP(i,0,N){
    cin>>nlist[i];
    b[i] = nlist[i];
  }
  
  lli ans = 1LL<<62;
  REP(k,0,N){
    lli temp = 0;
    REP(i,0,N){
      b[i] = min(b[i],nlist[(i-k+N)%N]);
      temp += b[i];
    }
    ans = min(ans,temp + x*k);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;

bool Vis[MAXN];

int main()
{
    int N, K;
    cin >>  N >> K;
    for(int i = 0; i< K; ++i)
    {
        int d, si;
        cin >> d;
        for(int j = 0; j < d; ++j)
        {
            cin >> si;
            Vis[si] = true;
        }
    }

    int ans = 0;
    for(int i = 1; i <= N; ++i)
        if(!Vis[i])
            ans ++;
    cout << ans << endl;

    return 0;
}


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

class Program
{
	static void Main(string[] args)
	{
		var inputs = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
		int result = Calc(inputs[0]) + Calc(inputs[1]);
		Console.WriteLine(result.ToString());
	}

	private static int Calc(int num)
	{
		return (num * (num - 1))/2;
	}
}


Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n>m)swap(n,m);
	for(register int i=1;i<=m;i++)printf("%d",n);
	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
ABCD = [tuple(map(int, input().split())) for _ in range(Q)]

X = []
ans = 0

def calc():
    ret = 0
    for a, b, c, d in ABCD:
        if X[b - 1] - X[a - 1] == c:
            ret += d
    return ret

def search():
    global ans

    if len(X) == N:
        ans = max(ans, calc())
        return

    for i in range(X[-1], M + 1):
        X.append(i)
        search()
        X.pop()

    return

for i in range(1, M + 1):
    X.append(i)
    search()
    X.pop()

print(ans)


Measured memory_bytes: 9260
#include <stdio.h>

int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

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

int main(void){
    int n;
    scanf("%d",&n);
    int a,b;
    scanf("%d",&a);
    for(int i=1;i<n;i++){
        scanf("%d",&b);
        a=lcm(a,b);
    }
    printf("%d\n",a);
}


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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    string ans = "NO";
    if (a.back() == b.front() && b.back() == c.front()) ans = "YES";
    cout << ans << endl;
}

Measured memory_bytes: 256
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
n=int(input())
a=[int(input()) for i in range (n)]
if l1[0] in a:
  l1[0]=0
if l1[1] in a:
  l1[1]=0   
if l1[2] in a:
  l1[2]=0 
if l2[0] in a:
  l2[0]=0 				
if l2[1] in a:
  l2[1]=0 
if l2[2] in a:
  l2[2]=0 
if l3[0] in a:
  l3[0]=0 
if l3[1] in a:
  l3[1]=0
if l3[2] in a:
  l3[2]=0 
ans="No"
if l1==[0,0,0]:
  ans="Yes"
if l2==[0,0,0]:
  ans="Yes"
if l3==[0,0,0]:
  ans="Yes"
if l1[0]==l2[0]==l3[0]==0:
  ans="Yes"
if l1[1]==l2[1]==l3[1]==0:
  ans="Yes"
if l1[2]==l2[2]==l3[2]==0:
  ans="Yes"
if l1[0]==l2[1]==l3[2]==0:
  ans="Yes"
if l1[2]==l2[1]==l3[0]==0:
   ans="Yes"
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	cin >> N >> K; 
	string S;
	cin >> S;
	int num = 0;
	for (int n = 0;n<S.size();++n) {
		if (0 == n) {
			++num;
		}
		else {
			if (S[n-1] !=S[n]) {
				num++;
			}
		}
	}
	int tmp = max(1, num-2*K);
	cout << N-tmp<<endl;
	return 0;
}


Measured memory_bytes: 3736
import heapq

x,y,z,k=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
b=sorted(list(map(int,input().split())),reverse=True)
c=sorted(list(map(int,input().split())),reverse=True)

q=[(-(a[0]+b[0]+c[0]),0,0,0)]
trash=[]

for _ in range(k):
  v,i,j,k=heapq.heappop(q)
  print(-v)
  if (i+1,j,k) not in trash and i+1<x:
    heapq.heappush(q,(-(a[i+1]+b[j]+c[k]),i+1,j,k))
    trash.append((i+1,j,k))
  if (i,j+1,k) not in trash and j+1<y:
    heapq.heappush(q,(-(a[i]+b[j+1]+c[k]),i,j+1,k))
    trash.append((i,j+1,k))
  if (i,j,k+1) not in trash and k+1<z:
    heapq.heappush(q,(-(a[i]+b[j]+c[k+1]),i,j,k+1))
    trash.append((i,j,k+1))

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

#define REP(i, n) for(int i = 0;i < n;i++)
using namespace std;


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

    if(N < 105)
        cout << 0 << endl;
    else if(N < 135)
        cout << 1 << endl;
    else if(N < 165)
        cout << 2 << endl;
    else if(N < 189)
        cout << 3 << endl;
    else if(N < 195)
        cout << 4 << endl;
    else
        cout << 5 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<vector<int>> G(n);
    vector<P> vp;
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    }

    int k=0;
    map<P, int> I;
    vector<int> cs(n, 0);

    vector<int> used(n, 0);
    queue<int> q;
    used.at(0) = 1;
    q.emplace(0);

    while(!q.empty()){
        int v=q.front(); 
        q.pop();
        k = max(k, (int)G.at(v).size());
        int cur = 1;
        for(auto u:G.at(v)){
            if(used.at(u)) continue;
            if(cur==cs.at(v)) cur++;
            cs.at(u) = I[make_pair(u, v)] = I[make_pair(v, u)] = cur;
            cur++;
            used.at(u) = 1;
            q.emplace(u);
        }
    }

    cout << k << endl;
    for(auto p:vp) cout << I[p] << endl;

    return 0;
}


Measured memory_bytes: 20084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    int c= 0;
	    for(int i = 0; i < N; i++) {
	        long a = Long.parseLong(scanner.next());
	        int ad = getDigit(a);
	        c += ad;
	    }

        System.out.print(c);
	}

	public static int getDigit(long n) {
	    int c = 0;
		while (n % 2 == 0) {
	    	c++;
	    	n = n/2;
	    }
		return c;
	}
}


Measured memory_bytes: 43260
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ',')cout << " ";
		else cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import math

n,goal = map(int,input().split())
x = [None]*n
y = [None]*n
k = 0
l = 0

for i in range(n):
    
    x[i],y[i]=map(int, input().split())
    d_2 = x[i]**2 + y[i]**2
    d = math.sqrt(d_2)
    if d<=goal:
      k+=1
          
print("{}".format(k))


Measured memory_bytes: 24688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int h, w, k;
    cin >> h >> w >> k;
    char g[h][w];
    int ans[h][w];
    rep (i, 0, h) rep (j, 0, w) ans[i][j] = 0;
    int cnt = 0;
    rep (i, 0, h) {
        rep (j, 0, w) {
            cin >> g[i][j];
            if (g[i][j] == '#') ans[i][j] = ++cnt;
        }
    }
    rep (i, 0, h) {
        rep (j, 1, w) {
            if (ans[i][j] == 0) {
                ans[i][j] = ans[i][j - 1];
            }
        }
        per (j, 0, w - 1) {
            if (ans[i][j] == 0) {
                ans[i][j] = ans[i][j + 1];
            }
        }
    }
    rep (i, 1, h) {
        if (ans[i][0] == 0) {
            rep (j, 0, w) ans[i][j] = ans[i - 1][j];
        }
    }
    per (i, 0, h - 1) {
        if (ans[i][0] == 0) {
            rep (j, 0, w) ans[i][j] = ans[i + 1][j];
        }
    }
    rep (i, 0, h) {
        rep (j, 0, w) cout << ans[i][j] << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 4448
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <cstring>
#include <fstream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int MAX_N = 12+1;
const double INF = 1e+100;
double dist[10+1][10+1]; // åå¾ a ã®ã±ã¼ã­ã®ä¸­å¿ã¨åå¾ b ã®ã±ã¼ã­ã®ä¸­å¿ã¨ã®è·é¢ã
double d[MAX_N][MAX_N];
double dp[1<<MAX_N][MAX_N];
int n, w;
int a[MAX_N];

// ã±ã¼ã­éã®è·é¢ãæ±ãã
int calc (void )
{
	for (int i = 3; i <= 10; i++ )
		for (int j = 3; j <= 10; j++ )
			dist[i][j] = 2.0*sqrt ((double)i*j );
}

// çµè·¯ã®æ¥ç¶ãæ±ãã
void make (void )
{
	// åæå
	rep (i, n+1 )
		rep (j, n+1 )
				d[i][j] = INF;

	rep (i, n )
		rep (j, n )
			d[i][j] = dist[a[i]][a[j]];

	rep (i, n ){
		d[n][i] = a[i]; d[i][n] = a[i];
	} // end rep
	n++;
}

// bitDP
double solve (){

	// åæå
	rep (S, 1<<n ){
		fill (dp[S], dp[S]+n, INF );
	} // end rep

	dp[(1<<n)-1][0] = 0;
	for (int S = (1 << n ) - 2; S >= 0; S-- )
		rep (v, n ) rep (u, n )
			if (!(S >> u & 1 ) )
				dp[S][v] = min (dp[S][v], dp[S | 1 << u][u] + d[v][u] );

	return dp[0][0];
}

int main()
{
	calc ();
	string str = "";

	while (getline (cin, str ) ){
		vector <int> cake; 
		stringstream ss (str );
		ss >> w;
		int i = 0, m;
		while (ss >> m ){
			 a[i++] = m;
		} // end while
		n = i;
		make ();
		if ((double)w >= solve () ){
			printf ( "OK\n" );
		}else{
			printf ( "NA\n" );
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1744
N = int(input())
h = list(map(int, input().split()))

dp = [10 ** 10] * N

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])


Measured memory_bytes: 52208
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int h = scan.nextInt();
		int w = scan.nextInt();
		String[] t = new String[h];
		for(int i = 0; i < h; i++)
			t[i] = scan.next();

		int r = scan.nextInt();
		int c = scan.nextInt();
		String[] p = new String[r];
		for(int i = 0; i < r; i++)
			p[i] = scan.next();

		PtFind f = new PtFind(t, p, false);

		scan.close();
		System.exit(0);
	}
}

class PtFind{
	boolean debug;

	public PtFind(String[] t, String[] p, boolean d){
		debug = d;

		boolean[][] jg = new boolean[t.length - p.length + 1][t[0].length() - p[0].length() + 1];
		//length????????????????´???°???length()??????????????°
		for(int y = 0; y < jg.length; y++)
			for(int x = 0; x < jg[0].length; x++)
				jg[y][x] = true; //true?????£??\??????

		for(int r = 0; r < p.length; r++){
			StFind stf = new StFind(p[r], d);
			for(int y = 0; y < jg.length; y++){
				boolean[] result = new boolean[jg[0].length];
				stf.find(t[y+r], p[r], result);
				for(int x = 0; x < jg[0].length; x++)
					jg[y][x] &= result[x];
					//a &= b??????a = a & b
			}
		}

		for(int y = 0; y < jg.length; y++)
			for(int x = 0; x < jg[0].length; x++)
				if(jg[y][x])
					System.out.println(y + " " + x);
	}
}

//
class StFind{
	boolean debug;
	int[] msft;
	int[] sft = new int[Character.MAX_CODE_POINT];

	public StFind(String p, boolean d){
		debug = d;
		createMatchPt(p);
	}

	public void find(String t, String p, boolean[] result){
		int x = 0;
		for(int st = 0; st < t.length() - p.length() + 1;){
			if((x = isBaEqual(t, p, st)) == p.length())
				result[st] = true;
			st += msft[x];
		}
	}

	private void createMatchPt(String p){
		msft = new int[p.length() + 1];
		msft[0] = p.length();

		for(int sft = p.length(); sft > 0; sft--){
			for(int m = 1; m < msft.length; m++){
				if(m > p.length() - sft){
					msft[m] = sft;
					continue;
				}
				if(p.charAt(p.length() - m) != p.charAt(p.length() - m- sft)){
					msft[m-1] = sft;
					break;
				}else if(m == p.length() -sft)
					msft[m] = sft;
			}
		}

		if(debug)
			for(int i = 0; i < msft.length; i++)
				System.out.println("--- " + i + " : " + msft[i]);
	}

	//
	int stPre = 0;
	int retPre = 0;

	private int isBaEqual(String t, String p, int st){
		int clen = p.length();
		if(st >= stPre + p.length() - retPre && st < stPre + p.length())
			clen -= stPre + p.length() - st;
		for(int i = 0; i < clen; i++){
			if(t.charAt(p.length() - 1 - i + st) != p.charAt(p.length() - 1 - i)){
				stPre = st;
				retPre = i;
				return i;
			}
		}
		stPre = st;
		retPre = p.length();
		return p.length();
	}
}

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

int main() {
    long long a, ans;
    string b;
    cin >> a >> b;
    long long b100 = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
    ans = a * b100 / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string S;
	string set[4] = { "dream","dreamer","erase","eraser" };
	for (int i = 0; i < 4; ++i) {
		reverse(set[i].begin(), set[i].end());
	}
	cin >> S;
	reverse(S.begin(), S.end());
	bool ans1 = true;
	for (int i = 0; i < S.size();) {
		bool ans = false;
		for (int j=0; j < 4; ++j) {
			if (S.substr(i, set[j].size()) == set[j]) {
				i += set[j].size();
			    ans = true;
			}
		}
		if (!ans) {
			ans1 = false;
			break;
		}
	}
	if (!ans1)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}

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

int main() {
	
 	unsigned long long int n,i,j,k,sum=0,count=0,ans=0,l,r,x,y;
	cin>>n;
	unsigned long long int a[1000002]={0},b[1000002]={0};
	for(i=1;i<1000002;i++)
	{
	    if((i%3)!=0 && (i%5)!=0)
	    a[i]=i;
	    b[i]=a[i];
	    b[i]+=b[i-1];
	}
	cout<<b[n];
	return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


ll ans = 0LL;
void dfs(ll n, ll x, int stat){
    if(x > n) return;
    if(stat == 0b111) ++ans;
    dfs(n, x*10+3, stat | 0b100);
    dfs(n, x*10+5, stat | 0b010);
    dfs(n, x*10+7, stat | 0b001);
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    dfs(n, 0, 0);
    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;


int a[maxN];
int b[maxN];
int c[maxN];
char s[maxN]; 

int main() {
	int n;
	scanf("%d",&n);
	scanf("%s",s+1); 
	string x = "";
	x.push_back(s[1]);
	for(int i=2;i<=n;i++)
	{
		if(s[i] == x.back())continue;
		else
		{
			x.push_back(s[i]);
		}
	}
	int ans = x.size();
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int N = 55;
int n;
int arr[N];
vector < pair < int , int > > v;
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
	}
	int idx = 1;
	for(int i = 2 ; i <= n ; ++i){
		if(abs(arr[i]) > abs(arr[idx])){
			idx = i;
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		if(arr[idx] >= 0 && arr[i] < 0){
			arr[i] += arr[idx];
			v.emplace_back(make_pair(idx , i));
		}
		if(arr[idx] <= 0 && arr[i] > 0){
			arr[i] += arr[idx];
			v.emplace_back(make_pair(idx , i));
		}
	}
	if(arr[idx] >= 0){
		for(int i = 2 ; i <= n ; ++i){
			if(arr[i - 1] > arr[i]){
				arr[i] += arr[i - 1];
				v.emplace_back(make_pair(i - 1 , i));
			}
		}
	}
	else{
		for(int i = n - 1 ; i >= 1 ; --i){
			if(arr[i] > arr[i + 1]){
				arr[i] += arr[i + 1];
				v.emplace_back(make_pair(i + 1 , i));
			}
		}
	}
	printf("%d\n" , int(v.size()));
	for(auto it : v){
		printf("%d %d\n" , it.first , it.second);
	}
}

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

using namespace std;

int main () {
    int64_t A, B;
    uint64_t V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if (A < B) {
        if (A+T*V >= B+T*W) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else if (A > B) {
        if (A + T*W <= B + T*V) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  cin >> N;
  ll taka = 1, aoki = 1;
  REP(i, N) {
    ll T, A;
    cin >> T >> A;
    taka += T - (taka - 1) % T - 1;
    if (taka / T * A >= aoki) {
      aoki = taka / T * A;
    } else {
      aoki += A - (aoki - 1) % A - 1;
      taka = aoki / A * T;
    }
  }
  cout << taka + aoki << endl;
  return 0;
}

Measured memory_bytes: 256
c = [0] * 3
for i in range(3):
    c[i] = list(map(int, input().split()))

if c[2][1] - c[2][0] == c[0][1] - c[0][0] and c[0][2] - c[1][2] == c[0][0] - c[1][0] and c[1][2] - c[2][2] == c[1][0] - c[2][0] and c[0][2] - c[2][2] == c[0][0] - c[2][0] and c[1][1] - c[0][1] == c[1][0] - c[0][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9212
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 23636
# @author 

import sys

class MCandies:
    def solve(self):
        MOD = 10 ** 9 + 7

        n, k = [int(_) for _ in input().split()]
        a = [int(_) for _ in input().split()]

        dp = [[0] * (n + 1) for _ in range(k + 1)]
        dp[0] = [1] * (n + 1)

        # d = 0
        # dp[k][i] Number of ways of getting k with the first i constraints
        pre = [[0] * (n + 1) for _ in range(k + 2)]
        for i in range(n + 1):
            pre[0][i] = 1
        for v in range(1, k + 1):
            pre[v][0] = pre[v - 1][0]
            for i in range(1, n + 1):
                dp[v][i] += (pre[v][i - 1] - pre[v - min(v, a[i - 1]) - 1][i - 1]) % MOD
                pre[v][i] = pre[v - 1][i] + dp[v][i]

        print(dp[k][n] % MOD)

solver = MCandies()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 205832
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define NN 9
 
struct Puzzle {
  int f[NN];
  int space;
  string path;
 
  bool operator < (const Puzzle &p) const {
    for(int i=0; i<NN; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};
 
static const int x[4] = {-1, 0, 1, 0};
static const int y[4] = {0, -1, 0, 1};
static const char dr[4] = {'u', 'l', 'd','r'};
 
bool isTarget(Puzzle p) {
  for(int i=0; i<NN; i++)
    if(p.f[i] != (i+1)) return false;
  return true;
}
 string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;
   while(!Q.empty()){
    u = Q.front(); Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r=0; r<4; r++){
      int tx = sx+x[r];
      int ty = sy+y[r];
      if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
      v=u;
      swap(v.f[u.space], v.f[tx*N+ty]);
      v.space = tx*N+ty;
      if(!V[v]){
        V[v] = true;
        v.path += dr[r];
        Q.push(v);
      }
    }
  }
  return "usdolvable";
}
 
int main(){
  Puzzle p;
 for(int i=0; i<NN; i++){
    cin >> p.f[i];
    if(p.f[i] == 0){
      p.f[i] = NN;
      p .space = i;
    }
  }
  string ans = bfs(p);
  cout << ans.size() << endl;
 
  return 0;
}

Measured memory_bytes: 30584
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	
	public static int[] readInts(String cad) {
		String read[] = cad.split(" ");
		int res[] = new int[read.length];
		for (int i = 0; i < read.length; i++) {
			res[i] = Integer.parseInt(read[i]);
		}
		return res;
	}
	
	
	
	static void printMatrixInt(long[][] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				if (j > 0)
					System.out.print(" ");
				System.out.print(array[i][j]);
			}
			System.out.println();
		}

	}
	
	public static class Item {
		
	}
	
	public static void main(String[] args) throws IOException {
		StringBuilder out = new StringBuilder();
		BufferedReader in;
		
			in = new BufferedReader(new InputStreamReader(System.in));

		int values[] = readInts(in.readLine());
		int n = values[0];
		int w = values[1];
		
		int items[][] = new int[n][];
		
		for( int i =0; i < n; i++ )
			items[i] = readInts(in.readLine());
		
		Arrays.sort(items, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[0] - o2[0];
			}
		} );
		
		long dp[][] = new long[n][w+1];
		
		
		for( int i =0; i <=w ; i++ ) {
			if( i >= items[0][0])
				dp[0][i] = items[0][1];
		}
		
		for( int i = 1; i < n; i++ ) {
			for( int j = 1; j <= w; j++ ) {
				if( items[i][0] <= j ) {
					dp[i][j] = Math.max(items[i][1] + dp[i-1][j- items[i][0]], dp[i-1][j]);
				}else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		//printMatrixInt(dp);
		System.out.println(dp[n-1][w]);
	}
	
}


Measured memory_bytes: 127700
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string w;
  cin >> w;
  map<char,int>mp;
  bool ok = true;
  rep(i,w.size()){
    mp[w[i]]++;
  }
  for(auto p:mp){
    if(p.second%2!=0)ok=false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

char stack[1024];
int h = 0;

void push(char ch)
{
    stack[h++] = ch;
}

char pop(void)
{
    return stack[--h];
}

int main(void)
{
    while(1){
        char line[126];
        int index = 0;
        int flag = 0;
        h = 0;

        fgets(line, sizeof(line), stdin);
        line[strlen(line) - 1] = '\0';

        if(strcmp(line, ".") == 0)
            break;

        while(line[index] != '.'){
            char ch;
            switch(line[index]){
                case '(':
                    push('(');
                    break;
                case ')':
                    if(h <= 0)
                        flag = 1;
                    else{
                        ch = pop();
                        if(ch != '(')
                            flag = 1;
                    }
                    break;
                case '[':
                    push('[');
                    break;
                case ']':
                    if(h <= 0)
                        flag = 1;
                    else{
                        ch = pop();
                        if(ch != '[')
                            flag = 1;
                    }
                    break;
            }
            index++;
        }

        if(h == 0 && flag == 0)
            printf("yes\n");
        else
            printf("no\n");

    }

    return 0;
}

Measured memory_bytes: 520
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    int a[201]={};

    a[105]=1;
    a[135]=1;
    a[189]=1;
    a[165]=1;
    a[195]=1;

    int s=0; 

    for(int i=1;i<n+1;i++){
        if(a[i]==1) s+=1;
    }

    cout << s << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
long long n,d,x,a,ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	d=read();
	x=read();
	ans=x;
	for (int i=1;i<=n;++i)
	{
		a=read();
		ans+=(d-1)/a+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,M,i;
int A[10000];
cin>>N>>M;
int sum=0;
for(i=0;i<M;i++)
{
cin>>A[i];
sum=sum+A[i];}
if(sum<=N)
{cout<<(N-sum)<<endl;}
else
{cout<<"-1"<<endl;}


return 0;




}

Measured memory_bytes: 3636
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 E PIC 9(15).
        01 F PIC 9(15).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
      		IF INP(1:1) = 'A'
      			DISPLAY 'T'
      		END-IF.
      		IF INP(1:1) = 'T'
      			DISPLAY 'A'
      		END-IF.
      		IF INP(1:1) = 'C'
      			DISPLAY 'G'
      		END-IF.
      		IF INP(1:1) = 'G'
      			DISPLAY 'C'
      		END-IF.
		STOP RUN.

Measured memory_bytes: 384