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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

const int mod = 1e9+7;

int N;
auto dp = vectors(111, 9, 9, 9, -1); // dp[i][x][y][z]: i文字目までみたとき、iの3文字前がx、2文字前がy、1文字前がzのとき、AGC文字列以外の組み合わせの数

// 渡されたリストがAGCになるかの判定
bool isAGC(vector<int> C) {
  return C[0] == 0 and C[1] == 1 and C[2] == 2;
}

int rec(int idx, int c3, int c2, int c1) {
  if (idx >= N) {
    return !isAGC({c3, c2, c1});
  }

  if (dp[idx][c3][c2][c1] != -1) {
    return dp[idx][c3][c2][c1];
  }

  int ret = 0;

  for (int now = 0; now < 4; now++) {
    vector<int> t = {c3, c2, c1, now};
    bool ok = true;

    // tがAGC文字列になるかを判定する
    if (isAGC({c3, c2, c1}) or isAGC({c2, c1, now})) {
      ok = false;
    }

    // tをスワップしてAGC文字列になるかを判定する
    for (int i = 0; i < 3; i++) {
      vector<int> tt = t;
      swap(tt[i], tt[i+1]);
      if (isAGC({tt[0], tt[1], tt[2]}) or isAGC({tt[1], tt[2], tt[3]})) {
        ok = false;
      }
    }

    // tがAGC文字列にならないなら遷移させる
    if (ok) {
      Add(ret, rec(idx + 1, c2, c1, now));
    }
  }

  return dp[idx][c3][c2][c1] = ret;;
}

signed main() {
  cin >> N;

  int ans = 0;
  ans = rec(0, 5, 5, 5);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1148
/*
  author:@Prashant Singh
  created on : 30/11/2019 00:39 AM


*/

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


typedef long long int ll;

vector<ll> adj[1000001]; 

ll i;
#define mod 747474747
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define rep(i,st,end) for( i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// to find root  call using root(arr,element)





int main()
{
  fio;
  ll m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  ll arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  if(d1==arr[m1] )
  {
    if((d2==1 && m2-m1==1) ||(d2==1 && m1==12 && m2==1))
      prt1(1);
    

  }
  else
    prt1(0);
 

  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

string S;

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

	cin >> S;

	int a = 0,b = 0;
	REP(i,S.size()){
		if(S[i] == '1'){
			a++;
		}else{
			b++;
		}
	}

	cout << min(a,b) * 2 << endl;



}


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

int main(){
  
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  
  if (n <= k){
    
    cout << n * x << endl;
    
    
  }else{
    
    cout << k * x + (n - k) * y << endl;
    
    
  }
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N; //N<=200000
	cin >> N;
	int a[N];
	bool flag = true;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	std::sort(a, a + N);
	for (int i = 0; i < N; i++) {
		if (a[i] == a[i + 1]) flag = false;
	}
	if (flag == true) cout << "YES";
	else cout << "NO";
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

ll zat(ll a,ll b){
  if(a>=b) return a-b;
 else  return b-a;
  
}


int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool flag =false;
    for(int i=1;i<100000;i++){
      if(a<=k*i && k*i<=b){
        flag=true;
        break;
      }
    }
    if(flag) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	long n,q = 1;cin >> n;
	string s;cin >> s;
	for(int i = 0;i<n-1;i++)
		if(s[i]!=s[i+1])
			q++;
	cout << q;
	return 0;
}

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

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

	if (N[N.size() - 1] == '2' || N[N.size() - 1] == '4' || N[N.size() - 1] == '5' || N[N.size() - 1] == '7' || N[N.size() - 1] == '9')
		cout << "hon" << endl;
	else if (N[N.size() - 1] == '0' || N[N.size() - 1] == '1' || N[N.size() - 1] == '6' || N[N.size() - 1] == '8')
		cout << "pon" << endl;
	else
		cout << "bon" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int k,x;
    scanf("%d%d", &k, &x);

    int i;
    for(i=MAX(-1000000,x-k+1); i<MIN(1000000,x+k); i++) {
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;


long f(long n) {
  if (n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}


int main() {
  long a;
  vector<long> memo((int)(1e6 + 2), -1);
  cin >> a;
  memo[a] = 1;

  long prev = a;
  for (long i = 2;; i ++) {
    a = f(prev);
    if (memo[a] != -1) {
      cout << i << endl;
      break;
    }
    memo[a] = i;
    prev = a;
  }
  return 0;
}


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

int main(){
	double input;
	int a,b,n;
	
	while(cin>>a>>b>>n){
		int s=0;
		for(int i=0;i<n;i++){
			a=10*(a%b);
			s+=a/b;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1164
const double PI = 3.14;

#include <bits/stdc++.h>

using namespace std;

void solve() {
  long long d, a, tm;
  cin >> d >> a;
  for(int i=0; i<a; i++) {
    cin >> tm;
    if (d >= 0) d -= tm;
  }
  if (d < 0) cout << "-1";
  else cout << d;
}

int main () {
  solve();
  return 0;
}


Measured memory_bytes: 3636
inputs = readlines

inputs.map(&:chomp).each do |line|
  h, w = line.split.map(&:to_i)
  exit if h.zero? && w.zero?

  h.times do |a|
    if a == 0 || a == h - 1
      puts "#" * w
    else
      puts "#" + "." * (w - 2) + "#"
    end
  end
  puts ""
end


Measured memory_bytes: 6976
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int a,b,c,d;
        double e;
        a=sc.nextInt();
        b=sc.nextInt();
        c=a/b;
        d=a%b;
        e=(double)a/(double)b;
        System.out.println(c+" "+d+" "+String.format("%.8f",e));
    }
}


Measured memory_bytes: 26456
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	vector<int>	vi;

int main(){
	static bool er[100000]={};	er[0]=er[1]=true;
	rep(i,400) if(!er[i]) for(int j=i*i;j<100000;j+=i) er[j]=true;

	vi pr;
	rep(i,100000) if(!er[i]) pr.pb(i);

	for(int m,a,b;scanf("%d%d%d",&m,&a,&b),m;){
		int popt=2,qopt=2;
		rep(i,pr.size()){
			int p=pr[i];
			if(p*p>m)	break;
			int q=*(upper_bound(pr.begin()+i,pr.end(),min(b*p/a,m/p))-1);
			if(popt*qopt<p*q)	popt=p,qopt=q;
		}
		printf("%d %d\n",popt,qopt);
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 100002

int main(void){
  int n,h[N],m,a,b,c[N]={0};
  int i,j,tmp,ans=0;
  
  scanf("%d %d", &n, &m);
  for(i=1;i<=n;i++){
    scanf("%d", &h[i]);
  }
  
  for(i=1;i<=m;i++){
    scanf("%d %d", &a,&b);
    if(c[a]<h[b]) c[a]=h[b];
    if(c[b]<h[a]) c[b]=h[a];
  }
  
  for(i=1;i<=n;i++){
    if(h[i]>c[i])ans++;
  }
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    if(A <=5) {
        cout << 0;
    }else if(A<=12){
        cout << B/2;
    }else{
        cout << B;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
int a;
int t;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(t);
    int amin=1<<30;
    int best=0;
    int ans=0;
    FOR(i, 1, n){
        read(a);
        if(a-amin>best){
            best=a-amin;
            ans=1;
        }
        else if(a-amin==best) ans++;
        amin=min(amin, a);
    }
    write(ans);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
cnt = Counter(a)
#from collections import Counter
if n % 2 == 0:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            quit()
else:
    if cnt[0] != 1:
        print(0)
        quit()
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            quit()
mod = 10 ** 9 + 7
print(2 ** (n // 2) % mod)

Measured memory_bytes: 14692
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=998244353;

string s;
int k;

vector<int> nums;

ll memo[305][305][305];
ll dp(int i,int used,int left){
	if (i==sz(nums)) return used==0;
	if (memo[i][used][left]!=-1) return memo[i][used][left];
	
	ll res=0;
	rep(x,1,305){
		if (305<=used+x || left-x<0) break;
		res+=dp(i+1,used+x,left-x);
	}
	rep(x,0,nums[i]+1){
		if (used-x<0) break;
		res+=dp(i+1,used-x,left);
	}
	
	//cout<<i<<" "<<used<<" "<<left<<" "<<res<<endl;
	return memo[i][used][left]=res%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	memset(memo,-1,sizeof(memo));
	
	cin>>s>>k;
	s+='0';
	
	int curr=0;
	for (auto &it:s){
		if (it=='0'){
			nums.push_back(curr);
			curr=0;
		}
		else{
			curr++;
		}
	}
	
	//for (auto &it:nums) cout<<it<<" ";cout<<endl;
	
	cout<<dp(0,0,min(k,304))<<endl;
}


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

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_arr(arr, n) { cerr << #arr << " "; rep(i, 0, n) cerr << arr[i] << " \n"[i == n]; }
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';

template <typename num_t>
inline void addmod(num_t& a, const long long& b, const int& m) { a = (a + b) % m; if (a < 0) a += m; }
template <typename num_t>
inline void update_max(num_t& a, const num_t& b) { a = max(a, b); }
template <typename num_t>
inline void update_min(num_t& a, const num_t& b) { a = min(a, b); }
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) { return !lhs ? rhs : gcd(rhs % lhs, lhs); }
template <typename num_t>
num_t pw(num_t n, num_t k, num_t mod) {
  num_t res = 1; for (; k; k >>= 1) { if (k & 1) res = 1ll * res * n % mod; n = 1ll * n * n % mod; } return res;
}

typedef long long ll;
const int inf = 1e9 + 7;
const long long ll_inf  = 1ll * inf * inf;
const int MAX_N = 2000000 + 7;
const int mod = inf;

int n, m;
string s, t;

void solve() {
  cin >> n >> m >> s >> t;
  for (int i = 0; i < n; ++i) {
    if (1ll * i * m % n == 0) {
      if (s[i] != t[1ll * i * m / n]) {
        cout << -1; return;
      }
    }
  }
  cout << 1ll * n / gcd(n, m) * m;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
  freopen("in.txt", "r", stdin);
#endif
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test)
    cin >> test;

  for(int i = 0; i < test; ++i) {
    //printf("Case #%d: ", i + 1);
    solve();
  }
#ifdef _LOCAL_
  cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

int main() {
    int a, b;
    cin>>a>>b;
    cout<<gcd(a, b)<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int d, x;
    scanf("%d %d", &d, &x);
    int i;
    int ans = 0;
    int a;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a);
        ans += ((d - 1) / a);
        ans++;
    }
    ans += x;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6+10;

vector<int> G[201];
int pos[201], n;

int bfs(int v){
	queue<int> q;
	q.push(v);
	pos[v] = 1;
	int d = 0;
	while(!q.empty()){
		++d;
		int k = q.size();
		while(k--){
			int t = q.front(); q.pop();
			for(int i:G[t]){
				if(pos[i]){
					if(pos[i] != d+1 && pos[i] != d-1) return -1;
				}
				else{
					pos[i] = d+1;
					q.push(i);
				}
			}			
		}
	}
	return d;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n;
	char buf[201];
	for(int i=0;i<n;++i){
		cin >> buf;
		for(int j=0;j<n;++j){
			if(buf[j] == '1'){
				G[i].push_back(j);
			}
		}
	}
	int ans = -1;
	for(int i=0;i<n;++i){
		memset(pos, 0, sizeof(pos));
		ans = max(ans, bfs(i));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S=input()
lis=list(S)
flag=True
while True:
    if lis[0]!="A":
        flag=False
        break
    Q=lis[1].islower()
    if Q==False:
        flag=False
        break
    W=lis[-1].islower()
    if W==False:
        flag=False
        break
    if "C" not in lis:
        flag=False
        break
    else:
        lis.remove("C")
        lis.remove("A")
    if lis==[]:
        flag=True
        break
    mojiretu=''
    for x in lis:
        mojiretu+=x
    Z=mojiretu.islower()
    if Z==True:
        break
    else:
        flag=False
        break
if flag==True:
    print("AC")
else:
    print("WA")

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

using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

int main (){
    int N,M,C;
    cin >> N >> M >> C;
    int x[300][300];//a
    int y[300];
    int P = N*M;
    cinf(M,y);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> x[i][j];
        }
    }

    int count = 0;
    REP(i,N){
        int total = C;
        REP(j,M){
            int left = x[i][j] * y[j];
            total += left;
        }
        if(total > 0){
            count++;
        }
    }
	cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005];
ll dp[105][105];
char s[100005];

int main(){
    cin>>n>>m;
	if(m==100)m=101;
	for(i=0;i<n;i++){
		m*=100;
	}
	p(m);
	return 0;

}

Measured memory_bytes: 4992
N = int(input())
a = map(int, input().split())

num_d = {}

for num in a:
    num_d.setdefault(num, 0)
    num_d[num] += 1

quad = 0
doub = 0
odd = 0
for k, v in num_d.items():
    if k % 4 == 0:
        quad += v
    elif k % 4 != 0 and k % 2 == 0:
        doub += v
    else:
        odd += v

if quad >= (odd + doub) - 1:
    print("Yes")
elif doub % 2 == 0 and quad >= odd - 1:
    print("Yes")
elif doub % 2 != 0 and quad >= odd - 1 and (quad - odd) >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 23848
# (0,0),(a,b),(c,d)
# (10**9, 1)(x,y)
# 10**9 * y - x == S
# S = 10**9 * a + bとおくと
# y = a + 1
# x = 10**9- b

S=int(input())
if S==10**18:
  print(0,0,10**9,0,0,10**9)
  exit(0)
DIV=10**9
a = S//DIV
b = S%DIV
x = 10**9-b
y = a + 1
if x>10**9:
  print(x)
if y>10**9:
  print(y)
print(0,0,10**9,1,x,y)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int p,n;
    cin>>n>>p;
    cin>>s;
    long long total=0;
    if(p==2){
        for(int i=0;i<n;i++){
            if((s[i]-'0')%2==0)
                total+=(i+1);
        }
    }
    else if(p==5){
        for(int i=0;i<n;i++){
            if((s[i]-'0')%5==0)
                total+=(i+1);
        }
    }
    else{
        map<int,int>m;
        int t=0;
        m[0]=1;
        int p2=1;
        for(int i=n-1;i>=0;i--){
            t=(t+(s[i]-'0')*p2)%p;
            total+=m[t];
            ++m[t];
            p2=p2*10%p;
        }
    }
    cout<<total;
    return 0;
}


Measured memory_bytes: 916
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as Maybe
import qualified Debug.Trace as Trace

solve :: Int -> Int
solve n = solveImpl (maxBound :: Int) 1 n

solveImpl :: Int -> Int -> Int -> Int
solveImpl ans i n
    | i * i > n = ans
    | otherwise =
        if (mod n i == 0)
            then if (tmp < ans)
                then solveImpl tmp (i + 1) n
                else solveImpl ans (i + 1) n
            else solveImpl ans (i + 1) n
    where tmp = (i + (div n i)) - 2

main = do
    n <- (fst . Maybe.fromJust . BS.readInt) <$> BS.getLine
    let ans = solve n
    print ans

Measured memory_bytes: 3768
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		int[] d = new int[k];
		int[][] a = new int[k][];
		boolean[] f = new boolean[n];
		for (i = 0; i < k; i++) {
			d[i] = parseInt(sc.next());
			a[i] = new int[d[i]];
			for (j = 0; j < d[i]; j++) {
				a[i][j] = parseInt(sc.next());
				f[a[i][j]-1] = true;
			}
		}
		sc.close();
		int cnt=0;
		for (i = 0; i < n; i++) {
			if(!f[i])cnt++;
		}
		out.println(cnt);
	}
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

void solve() {
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int cnt = 0;
  for (int i = 0; i*r <= n; ++i) {
    for (int j = 0; j*g <= n-i*r; ++j) {
      if ((n-i*r-j*g) % b == 0) {
        ++cnt;
        //cout << i << ' ' << j << ' ' << n-i-j << '\n';
      }
    }
  }

  cout << cnt << '\n';
}


/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
  FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
  clock_t time_start = clock();
	#endif

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

  solve();

	#ifndef ONLINE_JUDGE
  fclose(FIN);
  cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

  return 0;
}

//////// End Initialization ///////////////////////////////////////

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


int main(){
	int n,a[100],sum1=0,sum2=0;;

	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];

	sort(a,a+n,greater<>());
	for(int i=0;i<n;i++){
		if(i%2==0)sum1+=a[i];
		else sum2+=a[i];
	}
	cout<<sum1-sum2<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long ll;

ll lcm(ll N, ll M) {
    if (N<M) return lcm(M,N);
    ll product=N*M, buf;
    while(M != 0) {
        buf = N;
        N = M;
        M = buf%M;
    }
    return product/N;
}

int main() {
    int i,j=0,k=0;
    ll N,M,L,jump;
    scanf("%lld %lld",&N,&M);
    char S[N+1],T[M+1];
    scanf("%s",S);
    scanf("%s",T);
    L = lcm(N,M);
    N = L/N; M = L/M;
    jump = lcm(N,M);
    for (i=0; i<L/jump; i++) {
        if (S[j] != T[k]) {
            printf("-1\n");
            return 0;
        }
        j += jump/N;
        k += jump/M;
    }
    printf("%lld\n",L);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
bool a[100010];
ll d[10000010];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  fill(a, a + 100010, true);
  fill(d, d + 100010, 0);

  cin >> n >> m;
  REP(i, m) {
    int b;
    cin >> b;
    a[b] = false;
  }

  d[n] = 1;
  if(a[n - 1]) d[n - 1] = 1;
  else d[n - 1] = 0;
  for(int i = n - 2; 0 <= i; i--) {
    if(a[i]) {
      d[i] = (d[i + 1] + d[i + 2]) % mod;
    } else {
      d[i] = 0;
    }
  }

  cout << d[0] << endl;
}


Measured memory_bytes: 1152
#include <iostream> 
#include <unordered_set> 
#include <unordered_map>
#include <algorithm>
#include <string>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	int a,b ,k;
	
	cin >> k>>a>>b;
	if (a%k==0 || b%k==0)
		cout << "OK";
	else {
		int x = a / k;
		x = k * (x + 1);
		if (x < b)
			cout << "OK";
		else
			cout << "NG";
	}
	return 0;
}

Measured memory_bytes: 3632
#include<vector>
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

const int N = 1000001;
const int M = 30;

bool table[M][N];
bool isprime[N];

void generate(){
  for(int i=0;i<N;i+=2)isprime[i]=false;
  for(int i=1;i<N;i+=2)isprime[i]=true;
  isprime[2]=true;
  for(int i=3;i*i <= N ;i+=2){
    if (isprime[i]){
      for(int j=2*i;j<N;j+=i)isprime[j]=false;
    }
  }
}

void solve(int n,int lim,vector<int> & price){
  rep(i,n)rep(j,lim+1)table[i][j]=false;
  
  for(int i=0;i<lim+1;i+=price[0]){
    table[0][i]=true;
  }

  REP(i,1,price.size()){
    rep(j,lim+1){
      table[i][j]=table[i-1][j];
      if (j-price[i] < 0)continue;
      //if (j-price[i] == 0)table[i][j]=true;
      table[i][j]|=(table[i][j-price[i]]|table[i-1][j-price[i]]);
    }
  }

  for(int i=lim;i>0;i--){
    if (isprime[i] && table[n-1][i]){
      cout << i << endl;
      return;
    }
  }
  cout << "NA" << endl;
}


main(){
  int n;
  int lim;
  generate();
  while(cin>>n>>lim && n){
    vector<int> a;
    int tmp;
    rep(i,n){
      cin>>tmp;
      a.push_back(tmp);
    }
    solve(n,lim,a);
  }
  return false;
}

Measured memory_bytes: 30000
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    x_list = list(map(int, input().split()))
    ans = 0
    for i in range(0,len(x_list)):
        if x_list[i] == 0:
            ans = i+1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9536
package main

import (
  "fmt"
  "math"
  "strconv"
)
  
func pow(n, p int) int {
  if p==0 { return 1 }
  calc := 1
  for i:=0; i<p; i++ {
    calc *= n
  }
  return calc
} 

func bitCount(n int) int {
  c := 0
  for _, v := range strconv.FormatInt(int64(n), 2) {
    c += int(v-48)
  }
  return c
}

func main() {
  n := 0
  b := 0
  fmt.Scan(&n)
  f := make([]int, n)
  p := make([][]int, n)
  
  for i:=0; i<n; i++ {
    d := 0
    for j:=0; j<10; j++ {
      fmt.Scan(&b)
      d += b * pow(2,9-j)
    }
    f[i] = d
  }
  
  for i:=0; i<n; i++ {
    tmp := make([]int, 11)
    for j:=0; j<11; j++ {
      fmt.Scan(&tmp[j])
    }
    p[i] = tmp
  }
  
  pmax := -math.MaxInt64
  
  for b:=1; b<(1<<10); b++ {
    pc := 0
    for i:=0; i<n; i++ {
      pc += p[i][bitCount(f[i] & b)]
    }
    if pmax < pc {
      pmax = pc
    }
  }
  
  fmt.Println(pmax)
  
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
x = 1
if A.count(0) == 0:
  for i in range(N):
    y = x
    a = A[i]
    x = a*y
    if x > 10**18:
      break
    
  if x > 10**18:
    print(-1)
  else:
    print(x)
else:
  print(0)

Measured memory_bytes: 21588
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  int K, X; cin >> K >> X;
  for (int i = X - K + 1; i <= X + K - 1; i++)
    cout << i << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

const ll MOD = 998244353;

ll dp[4010][4010];

int main() {
    string S;
    cin >> S;
    int N = S.length();

    int rsum[N * 2 + 1], bsum[N * 2 + 1];
    rsum[0] = bsum[0] = 0;
    // 各ボール数の累積和 (1-indexed)

    for (int i = 1; i <= N; ++i) {
        rsum[i] = rsum[i - 1] + ('2' - S[i - 1]);
        bsum[i] = bsum[i - 1] + (S[i - 1] - '0');
    }
    for (int i = N + 1; i <= N * 2; ++i) {
        rsum[i] = rsum[i - 1];
        bsum[i] = bsum[i - 1];
    }

    dp[0][0] = 1;
    for (int r = 0; r <= rsum[N]; ++r) {
        for (int b = 0; b <= bsum[N]; ++b) {
            if (r == rsum[N] && b == bsum[N]) continue;

            // 赤ボールを置けるか？
            if (rsum[r + b + 1] > r) {
                dp[r + 1][b] += dp[r][b];
                dp[r + 1][b] %= MOD;
            }

            // 青ボールを置けるか？
            if (bsum[r + b + 1] > b) {
                dp[r][b + 1] += dp[r][b];
                dp[r][b + 1] %= MOD;
            }
        }
    }

    cout << dp[rsum[N]][bsum[N]] << endl;
    return 0;
}


Measured memory_bytes: 123392
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n, m;

    long long k = 0;
   
      
    scanf("%lld %lld", &n , &m );


    if( m / 2 >= n ){

        k += n;

        m = m - 2 * n;

        }

    else if( m / 2 < n ){

             k += m / 2;

             m = m % 2;

             }    


    if( m >= 4 ){

        k += m / 4;

        }
   

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


    return 0;
                                                          
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 4005
#define T 4000
#define M 200000


struct node {
    node *L,*R;
    int l,r, val[2];
};
node nodePool[M];
node *newNode() {
    static int pos = 0;
    nodePool[pos].L = nodePool[pos].R = NULL;
    nodePool[pos].val[0] = nodePool[pos].val[1] = 0;
    return &nodePool[pos++];
}
void init(node *root,int l,int r) {
    root->l = l;
    root->r = r;
    if(l==r) {
        return;
    }
    int mid = (l+r)/2;
    node *ln = newNode();
    init(ln,l,mid);
    node *rn = newNode();
    init(rn,mid+1,r);
    root->L = ln;root->R = rn;
}
void update(node *prev,node *cur,int l,int r,int ind,int bit) {
    cur->l = l;
    cur->r = r;
    if(l==r) {
        cur->val[0] = prev->val[0];
        cur->val[1] = prev->val[1];
        ++cur->val[bit];
        return;
    }
    int mid = (l+r)/2;
    if(ind<=mid) {
        cur->R = prev->R;
        node *ln = newNode();
        update(prev->L,ln,l,mid,ind,bit);
        cur->L = ln;
    } else {
        cur->L = prev->L;
        node *rn = newNode();
        update(prev->R,rn,mid+1,r,ind,bit);
        cur->R = rn;
    }
    cur->val[0] = cur->L->val[0] + cur->R->val[0];
    cur->val[1] = cur->L->val[1] + cur->R->val[1];
}
int query(node *root,int l,int r,int ql,int qr,int bit) {
    if(r<ql || qr<l) {
        return 0;
    }
    if(ql<=l && r<=qr) {
        return root->val[bit];
    }
    int mid = (l+r)/2;
    return query(root->L,l,mid,ql,qr,bit) + query(root->R,mid+1,r,ql,qr,bit);
}

node *seg[N];
int a[N],color[N];
int mindex[2][N],dp[T][T];

int solveDp(int l,int r,int n) {
    if(l==n && r==n) {
        return 0;
    }
    int &ret = dp[l][r];
    if(ret!=-1) {
        return ret;
    }
    ret = 1000000000;
    if(l<n) {
        int curIndex = mindex[0][l];int val = l+1;
        int cost = 0;
        if(val+1<=n) {
            cost += query(seg[curIndex],1,n,val+1,n,0);
        }
        if(r<n) {
            cost += query(seg[curIndex],1,n,r+1,n,1);
        }
        ret = min(ret, cost + solveDp(l+1,r,n));
    }
    if(r<n) {
        int curIndex = mindex[1][r];
        int val = r+1;
        int cost = 0;
        if(val+1<=n) {
            cost += query(seg[curIndex],1,n,val+1,n,1);
        }
        if(l<n ) {
            cost += query(seg[curIndex],1,n, l+1,n,0);
        }
        ret = min(ret, cost + solveDp(l,r+1,n));
    }
    return ret;
}
void solve() {
    int n;
    scanf("%d",&n);
    seg[0] = newNode();
    init(seg[0],1,n);
    int pos[2] = {0,0};
    for(int i=1;i<=n*2;++i) {
        char c;scanf(" %c %d ",&c,&a[i]);
        if(c=='B') {
            color[i] = 0;
        } else {
            color[i] = 1;
        }
        mindex[color[i]][a[i]-1] = i;
        seg[i] = newNode();
        update(seg[i-1],seg[i],1,n,a[i],color[i]);
    }
    memset(dp,-1,sizeof(dp));
    printf("%d\n",solveDp(0,0,n));
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 66176
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
long long N, A[87], CurrentMoney = 1000;
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N - 1; i++) {
    long long Stocks = 0;
    if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
    CurrentMoney += (A[i + 1] - A[i]) * Stocks;
  }
  cout << CurrentMoney << endl;
}


Measured memory_bytes: 3636
#include <cstdio>

bool binSearch(int x, int array[], int first, int last) {
    int mid = (first + last) / 2;
    bool ret = false;
    if(array[mid] == x) {
        ret =  true;
    } else {
		if(first >= last) {
			ret = false;
		} else {
		 	if (x < array[mid]) {
	     		ret = binSearch(x, array, first, mid - 1);
	    	} else {
	    		ret = binSearch(x, array, mid + 1, last);
    		}
		}
	}
    return ret;
}

int main(void) {
    int n, q;
    scanf("%d", &n);

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

    scanf("%d", &q);
    int x, sum = 0;
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        if(binSearch(x, S, 0, n - 1)) {
            sum += 1;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3044
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=1e9+7;
const int inv2=(mod+1)>>1;
char ch[MAXN];
int n,a[MAXN],b[MAXN];
int main()
{
	n=read();n<<=1;
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)b[i]=ch[i]=='B'?1:0;
	int ct1=0,ct2=0;
	for(int i=n,lst=0;i>=1;i--)
	{
		if(b[i]^lst)a[i]=1,lst^=1,++ct1;
		else a[i]=-1,lst^=1,++ct2;
	}
	if(ct1!=ct2)return pr2(0),0;
	int ans=1;
	for(int i=1,cnt1=0;i<=n;i++)
	{
		if(a[i]==1&&!cnt1)return pr2(0),0;
		if(a[i]==1)ans=1LL*ans*cnt1%mod,cnt1--;
		else cnt1++;
	}
	for(int i=1;i<=(n>>1);i++)ans=1LL*ans*i%mod;
	pr2(ans);
	return 0;
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int x = Integer.parseInt(line);
        System.out.println(x*x*x);
    }
}

Measured memory_bytes: 24404
#include <stdio.h>

int main(void){
    long int X,money,year=0;
    
    scanf("%ld",&X);
    
    money=100;
    
    while(money<X){
        money=(1.01)*money;
        year++;
    }
    
    printf("%ld\n",year);
    
    return 0;
}

Measured memory_bytes: 2180
$N, $K = gets.chomp.split(' ').map(&:to_i)

$m = []
$bunny = {}

$K.times do |i|
  tmp = gets.chomp.split(' ').map(&:to_i)
  $m << tmp[0]
  tmp[1..-1].each do |b|
    $bunny[b] = [i, false]
  end
end

$R = gets.chomp.to_i

count = 0
$R.times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  ag, ab = $bunny[a]
  bg, bb = $bunny[b]

  next unless ag == bg
  if ab == false
    count += 1
    $bunny[a] = [ag, true]
  end
  if bb == false
    count += 1
    $bunny[b] = [bg, true]
  end
end

puts count



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


int n,k;
int h[100005];
long long f[100005];

int main()
{
    cin>>n>>k;
    fill(f,f+n,1000000000000000);
    for (int i=0;i<n;i++) cin>>h[i];
    f[0]=0;
    f[1]=abs(h[0]-h[1]);
    for (int i=2;i<n;i++)
        for (int j=max(0,i-k);j<i;j++) f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
    cout<<f[n-1];
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] map = new char[n][];
        for(int i = 0; i < n; i++){
            map[i] = sc.next().toCharArray();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(map[i][j] == '.'){
                    ans = Math.max(ans,bfs(n,m,map,i,j));
                }
            }
        }
        System.out.println(ans);
    }
 
    public static int bfs(int n, int m, char[][]map,int sy,int sx){
        char[][] bfsmap = new char[n][];
        for(int i = 0; i < n; i++){
            bfsmap[i] = map[i].clone();
        }
        Point[] D4 = {new Point(-1, 0),new Point(1,0), new Point(0,1), new Point(0,-1)};
        Point start = new Point(sx, sy);
        boolean[][] arrived = new boolean[n][m];
	    int[][] moves = new int[n][m];
	    for(int i = 0; i < n; i++){
            Arrays.fill(moves[i],99999999);
        }
        moves[sy][sx] = 0;
        ArrayDeque<Point> dq = new ArrayDeque<>();
        dq.add(start);
 
        while (dq.size() > 0) {
            Point p = dq.removeFirst();
            for (int i=0; i<4; i++) {
                int x = p.getX()+D4[i].getX();
                int y = p.getY()+D4[i].getY();
                if(!(0 <= y && y < n && 0 <= x && x < m)){
                    continue;
                }
                else if (bfsmap[y][x] == '.') {
                    dq.addLast(new Point(x, y));
                    bfsmap[y][x] = '#';
                    moves[y][x] = Math.min(moves[y][x],moves[p.getY()][p.getX()] + 1);
                    arrived[y][x] = true;
                }
            }
        }
        int ret = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(arrived[i][j]){
                    ret = Math.max(ret,moves[i][j]);
                }
            }
        }
        return ret;
    }
}
 
class Point{
 
	private int x;
	private int y;
 
	Point(int a, int b) {x=a; y=b;}
 
	int getX() {return x;}
	int getY() {return y;}
	void setX(int n) {x = n;}
	void setY(int n) {y = n;}
 
}

Measured memory_bytes: 27608
w=input()
l=[0]*26

for i in range(len(w)):
    if w[i]=="a":
        l[0]+=1
    elif w[i]=="b":
        l[1]+=1
    elif w[i]=="c":
        l[2]+=1
    elif w[i]=="d":
        l[3]+=1
    elif w[i]=="e":
        l[4]+=1
    elif w[i]=="f":
        l[5]+=1
    elif w[i]=="g":
        l[6]+=1
    elif w[i]=="h":
        l[7]+=1
    elif w[i]=="i":
        l[8]+=1
    elif w[i]=="j":
        l[9]+=1
    elif w[i]=="k":
        l[10]+=1
    elif w[i]=="l":
        l[11]+=1
    elif w[i]=="m":
        l[12]+=1
    elif w[i]=="n":
        l[13]+=1
    elif w[i]=="o":
        l[14]+=1
    elif w[i]=="p":
        l[15]+=1
    elif w[i]=="q":
        l[16]+=1
    elif w[i]=="r":
        l[17]+=1
    elif w[i]=="s":
        l[18]+=1
    elif w[i]=="t":
        l[19]+=1
    elif w[i]=="u":
        l[20]+=1
    elif w[i]=="v":
        l[21]+=1
    elif w[i]=="w":
        l[22]+=1
    elif w[i]=="x":
        l[23]+=1
    elif w[i]=="y":
        l[24]+=1
    elif w[i]=="z":
        l[25]+=1
for i in range(26):
    if l[i]%2!=0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3192
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))




def ans():
    A ,B = ints_raw()
    ans =0
    for i in range(2):
        if A>B:
            ans += A
            A-=1
        else:
            ans+=B
            B-=1
    return ans

print(ans())



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

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Card{
public:
	char suit;
	int number;
	int input_order;
};

int partition(std::vector<Card> &A, int p, int r){
	int x = A[r].number;
	int i = p - 1;
	
	for(int j = p; j < r; j++){
		if(A[j].number <= x){
			i++;
			std::swap(A[i], A[j]);
		}
	}
	std::swap(A[i + 1], A[r]);
	return i + 1;
}

void quick_sort(std::vector<Card> &A, int p, int r){
	if(p < r){
		int q = partition(A, p, r);
		quick_sort(A, p, q - 1);
		quick_sort(A, q + 1, r);
	}
	return;
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::vector<Card> A;
	char suit = 0;
	int m = 0;

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	A.resize(n);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> suit >> m;
#else
		std::cin >> suit >> m;
#endif
		A[i].suit = suit;
		A[i].number = m;
		A[i].input_order = i;
	}


	quick_sort(A, 0, n - 1);



	bool is_stable = true;

	for(int i = 1; i < A.size(); i++){
		if(A[i - 1].number == A[i].number && A[i - 1].input_order > A[i].input_order){
			is_stable = false;
			break;
		}
	}

	if(is_stable){
		std::cout << "Stable" << std::endl;
	}
	else{
		std::cout << "Not stable" << std::endl;
	}
	for(unsigned int i = 0; i < A.size(); i++){
		std::cout << A[i].suit << " " << A[i].number << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int a, b, c, n;
vector<int> L(10);
int ans = INF;

void dfs(int id, int alen, int blen, int clen, int cos){
  // cout << "a" << endl;
  if(id == n){
    if(!(alen == 0 || blen == 0 || clen == 0))
    ans = min(ans, cos + abs(a - alen) + abs(b - blen) + abs(c - clen));
  }else{
    dfs(id + 1, alen, blen, clen, cos);
    if(alen == 0)
    dfs(id + 1, alen + L[id], blen, clen, cos);
    else
    dfs(id + 1, alen + L[id], blen, clen, cos + 10);
    if(blen == 0)
    dfs(id + 1, alen, blen + L[id], clen, cos);
    else
    dfs(id + 1, alen, blen + L[id], clen, cos + 10);
    if(clen == 0)
    dfs(id + 1, alen, blen, clen + L[id], cos);
    else
    dfs(id + 1, alen, blen, clen + L[id], cos + 10);
  }
}

int main(){
  cin >> n >> a >> b >> c;
  rep(i, n) cin >> L[i];

  dfs(0, 0, 0, 0, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

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

	int n = s.length();
	if(s[n - 1] == 's')
		s += "es";
	else
		s += "s";

	cout << s << endl;
}

Measured memory_bytes: 3620
//For fast competitive programming

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

//DATA_TYPES
typedef long long ll; 
typedef vector<int> vi;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f; //Infinity

//INITIALISING
//memset(arr, 0, sizeof arr);
//vi v(N, 0);

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(NULL);
	ll ans=0;
	//write your code here
	int t;
	cin>>t;
	for(int z=1;z<=t;z++)
	for(int y=1;y<=t;y++)
	for(int x=1;x<=t;x++)
     ans =ans+ __gcd(z,(__gcd(y,x)));

cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3648
/*#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
bool bst(vector<ll>v,ll data){
	ll l=0,h=v.size()-1;
	while(l<=h){
		ll mid=l+(h-l)/2;
		if(v[mid]==data) return true;
		else if(v[mid]>data) h=mid-1;
		else l=mid+1;
	}
	return false;
}
int main(){
	nes;
	ll n,k;
	cin>>n>>k;
	vector<ll>v(n);
	for(int i=0;i<n;++i) cin>>v[i];
	while(k--){
		//if(bst(v)) cout<<"YES\n";
		//else cout<<"NO\n";
		ll data;cin>>data;
		bst(v,data) ? cout<<"YES\n" : cout<<"NO\n";
	}
	return 0;
}*/
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
	nes;
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0) cout<<(n/x)*t;
	else
	cout<<(n/x)*t+t;
	return 0;
}





















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

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

	vector<int> q(26, 0);
	string s;
	while (cin >> s){
		for (unsigned int i = 0; i < s.size(); i++){
			if ('a' <= s[i] && s[i] <= 'z'){//if small
				q[s[i] - 'a']++;
			}
			else if ('A' <= s[i] && s[i] <= 'Z'){//if capital
				q[s[i] - 'A']++;
			}
		}
	}
	rep(i, 26){
		cout << char('a' + i) << " : " << q[i] << '\n';
	}

	return 0;
}


Measured memory_bytes: 3208