akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int b1[10000]={0};
	int a,b,c,i=0;
	int aa=0;
	cin>>a>>b>>c;
	if(a%2==0&&b%2==0&&c%2==1){
		cout<<"NO"<<endl;
	}
	else if(a==1){
		cout<<"YES"<<endl;
	}
	else{
		int sum=a;
		while(1){
			if(sum%b==c){
				cout<<"YES"<<endl;
				break;
			}
			else{
				b1[i]=sum%b;
				for(int j=0;j<i;j++){
					if(b1[j]==b1[i]){
						cout<<"NO"<<endl;
						aa=1;
						break;
					}
				}
				if(aa==1)break;
			}
			sum+=a;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
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();
		String s = sc.next();

		String ans = "Yes";
		for(int i = 0; i < a + b; i++) {
			char ch = s.charAt(i);

			if(i == a && ch != '-') {
				ans = "No";
				break;
			} else if( i != a &&  !('0' <= ch && ch <= '9') ) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['G'] = 'C';
    mp['C'] = 'G';
    char b;
    cin >> b;
    cout << mp[b] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll const maxn=4e5+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll a,b;
   cin>>a>>b;
   ll n=__gcd(a,b);
   ll ans=0;
   for(int i=2;i<=sqrt(n);i++){
    if(n%i==0){
        ans++;
        while(n%i==0)n/=i;
    }
   }
   if(n>1)ans++;
   cout<<ans+1;
    return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) h -= a[i];
  if (h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int visited[300000] = {};
int main() {
	int a, b;
	cin >> a >> b;
	vector<tuple<int,int,int>> input;
	REP(i, b) {
		int a, b;
		cin >> a >> b;
		input.push_back(make_tuple(a,1, i));
		input.push_back(make_tuple(b,0, i));
	}
	sort(input.begin(), input.end());
	queue<int> gogo;
	int ans = 0;
	for (int i = 0; i < input.size(); ++i) {
		if (get<1>(input[i]) == 1) {
			gogo.push(get<2>(input[i]));
			visited[get<2>(input[i])] = 1;
		}
		else {
			if (visited[get<2>(input[i])] == 1) {
				ans++;
				while (gogo.empty() == false) {
					visited[gogo.front()] = 0;
					gogo.pop();
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4980
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
ll x;


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

  cin >> N >> x;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  sort(A.begin(), A.end());
  ll cnt = 0ll;
  int ans = N-1;
  rep(i, N){
    cnt += A[i];
    if (x == cnt){
      ans = i+1;
      break;
    }
    if (x < cnt){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int ans = 0;
int bfs(int x, vector<int> a, vector<vector<int>> r){
  a[x] = 1;
  bool flag = true;
  rep(i,a.size()) if(a[i] != 1) flag = false;
  if(flag) {
    ans++;
    return 0;
  }
  
  rep(i,r[x].size()) if(a[r[x][i]] == 0)bfs(r[x][i], a, r);
  
  return 0;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<vector<int>> r(n);
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    r[a[i]].push_back(b[i]);
    r[b[i]].push_back(a[i]);
  }

  vector<int> arr(n,0);
  bfs(0,arr,r);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (auto i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    int countMax = 0;
    for (int i = 0; i < n - 1; i++)
    {
        int count = 0;
        for (int j = i; j < n - 1; j++)
        {
            if (h[j] >= h[j + 1])
            {
                //cout << "h" << h[j] << " " << h[j + 1] << endl;
                count++;
            } else break;
        }
        //cout << i << " " << count << endl;
        countMax = max(countMax, count);
        i += count;
    }
    cout << countMax << endl;
    return 0;
}


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

#define ll long long

using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   
   int N; cin >> N;
   
   int points = 0;
   while(N >= 500) {
      N -= 500;
      points += 1000; 
   }
   while(N >= 5){
      N -= 5;
      points += 5;
   }
   cout << points;
   return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<3;
	else if(s[0]=='R' && s[1]=='R') cout<<2;
	else if(s[2]=='R' && s[1]=='R') cout<<2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<1;
	else cout<<0;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



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

int main() {
    int S;
    cin >> S;
    int a = S / 1000;
    int b = (S / 100) - (a * 10);
    int c = (S / 10) - (a * 100) - (b * 10);
    int d = S - a * 1000 - b * 100 - c * 10;

    if(a == b || b == c || c == d){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}


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

int main(){
  int N;
  cin >> N;
  long long int sum=0;

  for(int i=1; i<N+1 ;i++){
    
    if( i%15 == 0 ){
      continue;}
    
    if( i%3 == 0 ){
      continue;}
    
    if( i%5 == 0 ){
      continue;}

    sum += i;}
cout << sum << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll n;
vector<ll> ve[200005];
ll d[200005];
ll cnt1, cnt2;
bool v[200005];
vector<ll> a[9];
ll ans[200005];

void dfs(ll p, ll q)
{
    if(d[p]) return;
    d[p] = q;
    for(ll i = 0; i < ve[p].size(); i++)
    {
        dfs(ve[p][i], 3 - q);
    }
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n - 1; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    dfs(1, 1);
    for(ll i = 1; i <= n; i++)
    {
        if(d[i] == 1) cnt1++, a[1].push_back(i);
        else cnt2++, a[2].push_back(i);
    }
    if(cnt1 <= n / 3)
    {
        for(ll i = 0; i < cnt1; i++)
        {
            ans[a[1][i]] = (i + 1) * 3;
            v[(i + 1) * 3] = true;
        }
        ll j = 1;
        for(ll i = 1; i <= n; i++)
        {
            if(ans[i]) continue;
            while(v[j]) j++;
            v[j] = true;
            ans[i] = j;
        }
    }
    else if(cnt2 <= n / 3)
    {
        for(ll i = 0; i < cnt2; i++)
        {
            ans[a[2][i]] = (i + 1) * 3;
            v[(i + 1) * 3] = true;
        }
        ll j = 1;
        for(ll i = 1; i <= n; i++)
        {
            if(ans[i]) continue;
            while(v[j]) j++;
            v[j] = true;
            ans[i] = j;
        }
    }
    else
    {
        for(ll i = 0; i < (n + 2) / 3; i++)
        {
            ans[a[1][i]] = i * 3 + 1;
            v[i * 3 + 1] = true;
        }
        for(ll i = 0; i < (n + 1) / 3; i++)
        {
            ans[a[2][i]] = i * 3 + 2;
            v[i * 3 + 2] = true;
        }
        ll j = 1;
        for(ll i = 1; i <= n; i++)
        {
            if(ans[i]) continue;
            while(v[j]) j++;
            v[j] = true;
            ans[i] = j;
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        printf("%lld ", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 22124
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <cstdio>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	fast();
	string s;
	cin >> s;

	if ((s[0] - '0') + (s[1] - '0') + (s[2] - '0') + (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '+' << s[1] - '0' << '+' << s[2] - '0' << '+' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') + (s[1] - '0') - (s[2] - '0') - (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '+' << s[1] - '0' << '-' << s[2] - '0' << '-' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') + (s[1] - '0') + (s[2] - '0') - (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '+' << s[1] - '0' << '+' << s[2] - '0' << '-' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') + (s[1] - '0') - (s[2] - '0') + (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '+' << s[1] - '0' << '-' << s[2] - '0' << '+' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') - (s[1] - '0') - (s[2] - '0') - (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '-' << s[1] - '0' << '-' << s[2] - '0' << '-' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') - (s[1] - '0') - (s[2] - '0') + (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '-' << s[1] - '0' << '-' << s[2] - '0' << '+' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') - (s[1] - '0') + (s[2] - '0') - (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '-' << s[1] - '0' << '+' << s[2] - '0' << '-' << s[3] - '0' << '=' << 7 << endl;
	}


	else if ((s[0] - '0') - (s[1] - '0') + (s[2] - '0') + (s[3] - '0') == 7)
	{
		cout << s[0] - '0' << '-' << s[1] - '0' << '+' << s[2] - '0' << '+' << s[3] - '0' << '=' << 7 << endl;
	}


}



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

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(s=="Y"){
      cout<<"Four"<<endl;
      break;
    }else if(i==N-1){
      cout<<"Three"<<endl;
    }
  }
}

Measured memory_bytes: 3612
fun main(args: Array<String>) {
    val s = readLine()!!.toString()
    var most = 0
    var cnt = 0
    s.forEach { char ->
        val it = char.toString()
        if (it == "A" || it == "C" || it == "G" || it == "T") {
            cnt++
        } else {
            if (cnt > most) {
                most = cnt
            }
            cnt = 0
        }
    }
    println(if (cnt >0 && cnt > most) cnt else most)
}

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

using ll = long long;
using ull = unsigned long long;

using namespace std;

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

    ll k,x;

    cin>>k>>x;

    if(k*500>=x) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';

    return 0;
}

Measured memory_bytes: 256
import sys

sys.path.append("/home/contestant/.local/lib/python3.8/site-packages")

import networkx as nx

import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, M = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for i in range(M)]

# Will WA if you don't include nodes with no in/outdegrees
graph = nx.DiGraph()
for i in range(N):
    graph.add_node(i)
for u, v in edges:
    graph.add_edge(u, v)


SCC = list(nx.algorithms.components.strongly_connected_components(graph))
print(len(SCC))
for comp in reversed(SCC):
    print(len(comp), *comp)


Measured memory_bytes: 685576
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 15;
const string FILENAME = "sample";

int n, m, p[maxN];
vector<int> bulb[maxN];

void read(){
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int sz;  cin >> sz;
		bulb[i].resize(sz);
		for(int j = 0; j < sz; j++){
			cin >> bulb[i][j];
		}
	}

	for(int i = 1; i <= m; i++){
		cin >> p[i];
		p[i] %= 2;
	}
}

void solv(){
	int ans = 0;
	for(int bitmask = 0; bitmask < (1 << n); bitmask++){
		bool on[maxN];
		fill_n(on, maxN, false);
	
		for(int i = 1; i <= m; i++){
			int sz = bulb[i].size();
			int cnt = 0;
			for(int j = 0; j < sz; j++){
				int x = bulb[i][j];
				x--;
				if(bitmask & (1 << x))
					cnt++;
			}

			if(cnt % 2 == p[i]){
				on[i] = true;
			}
		}
		
		bool flag = true;
		for(int i = 1; i <= m; i++){
			if(!on[i])
				flag = false;
		}

		ans += flag;
	}

	cout << ans << '\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

typedef pair<long long int, long long int> P;

int main(){
	
	while(true){
		int P, N[6], price[6] = {1, 5, 10, 50, 100, 500}, S = 0;
		cin >> P;
		for(int i = 0; i < 6; i++){
			cin >> N[i];
			S += price[i] * N[i];
		}
		if(P == 0){
			break;
		}
		int ans = 100000;
		for(int i = P; i <= S; i++){
			int rem = i, cnt = 0;
			for(int j = 5; j >= 0; j--){
				int num = min(N[j], rem / price[j]);
				cnt += num;
				rem -= num * price[j];
			}
			if(rem > 0){
				continue;
			}
			int diff = i - P, cnt2 = 0;
			for(int j = 5; j >= 0; j--){
				cnt2 += diff / price[j];
				diff -= diff / price[j] * price[j];
			}
			ans = min(ans, cnt + cnt2);
		}
		cout << ans << endl;
	}
	return 0;
}



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

int main()
{
    long long N, K;
    cin >> N >> K;
    vector<long long> B(N);
    long long ans1 = 0;
    long long ans2 = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (B[i] > B[j])
            {
                ans1++;
            }
        }
    }

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (B[i] < B[j])
            {
                ans2++;
            }
        }
    }
    long long md = (long long)(1e9 + 7);
    //cout << ans1 << ans2 << endl;
    long long ans = 0;
    ans += K * ans1 % md;
    ans += (K * (K - 1) / 2) % md * ans2;
    ans %= md;
    cout << ans << endl;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

class union_find {
private:
    vector<int> parent, rank, gs;
    int size;

public:
    int count_group;
    union_find() = default;
    union_find(int n) { init(n); }

    void init(int n) {
        size = n;
        count_group = n;
        parent.resize(size);
        rank.assign(size, 0);
        gs.assign(size, 1);
        for (int i = 0; i < size; ++i) parent[i] = i;
    }

    int find(int x) {
        if (parent[x] == x)
            return x;
        else
            return parent[x] = find(parent[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            parent[x] = y;
            gs[y] += gs[x];
        } else {
            parent[y] = x;
            gs[x] += gs[y];
            if (rank[x] == rank[y]) ++rank[x];
        }
        --count_group;
    }

    bool is_same_group(int x, int y) {
        return find(x) == find(y);
    }

    int group_size(int x) {
        return gs[find(x)];
    };
};

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,M;
    cin >> N >> M;

    vector<pair<i64,i64>> AB(M);
    rep(i,0,M){
        cin >> AB[i].first >> AB[i].second;
        --AB[i].first;
        --AB[i].second;
    }

    vector<i64> ans(M);
    union_find uf(N);
    i64 ic=N*(N-1)/2;
    for(i64 i=M-1; i>=0; --i){
        ans[i]=ic;

        i64 a=AB[i].first,b=AB[i].second;

        if(uf.is_same_group(a,b)){
            continue;
        }

        i64 sa=uf.group_size(a),sb=uf.group_size(b);
        ic-=sa*sb;

        uf.unite(a,b);
    }

    rep(i,0,M){
        cout << ans[i] << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main()
{
	int n, k;
	cin >> n >> k;
	Radix r;
	string ans = r.to(n, k);
	cout << ans.length() << endl;
	
	return 0;
}


Measured memory_bytes: 256
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function that returns true if n 
// is prime else returns false 
bool isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
	
	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n%2 == 0 || n%3 == 0) return false; 
	
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
	
	return true; 
} 

// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 

	// Base case 
	if (N <= 1) 
		return 2; 

	int prime = N; 
	bool found = false; 

	// Loop continuously until isPrime returns 
	// true for a number greater than n 
	while (!found) { 
		prime++; 

		if (isPrime(prime)) 
			found = true; 
	} 

	return prime; 
} 

// Driver code 
int main() 
{ 
	int N;
	cin >> N;

	cout << nextPrime(N-1); 

	return 0; 
} 


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

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

int main(){
    int a,b; cin >> a >> b;
    if(a!=1&&b!=1){
        cout << 1 << endl;
    }else if(a!=2&&b!=2){
        cout << 2 << endl;
    }else if(a!=3&&b!=3){
        cout << 3 << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) {
    return(conj(a)*b).imag(); 
}

int main() {
    xy_t p[30];
    double x, y;
    char c;
    int idx = 0;
    while (cin >> x >> c >> y) {
        p[idx] = xy_t(x, y);
        idx++;
    }

    double sm = 0.0;
    for (int i = 0; i < idx - 2; i++) {
        xy_t a = p[0], b = p[i + 1], c = p[i + 2];
        sm += cross_product(b - a, c - a) / 2.0;
    }

    cout << sm << endl;
}

/*
g++ -std=c++14 pr_prog/_main.cpp
 */


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* sort the job w/ deadline asc and do the job as early as possible */

typedef tuple<int,int> Job;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<Job> A;
        FOR(i,0,n) {
            int a,b; cin >> a >> b;
            A.push_back(Job(b,b-a));
        }
        sort(ALL(A));
        int t = 0; bool good = true;
        FOR_ALL(a,A) {
            int y,x; tie(y,x) = *a;
            if (t > x)
                good = false;
            t += y-x;
        }
        cout << (good ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> P;

const int dice[7][4]={
  {},
  {5,4,2,3}, //1
  {6,3,1,4}, //2
  {5,1,2,6}, //3 
  {5,6,2,1}, //4
  {6,4,1,3}, //5
  {5,3,2,4}  //6
};
int ans[6];
int Fdice[6]; 
/*
0 -> top
1 -> front
2 -> right 
3 -> R-front
4 -> R-right
5 -> R-top
 */


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


P graph[500][500];//first -> roll, second -> height

void CreateFdiceForYou(int top,int front){
  int frontIsHere;
  rep(i,4){
    if(dice[top][i] == front){
      frontIsHere = i;
      break;
    }
  }
  //cout << frontIsHere << " <- frontIsHere " << endl;
  Fdice[0] = top;
  Fdice[5] = 7-top;

  rep(i,4){
    if(frontIsHere == 4)frontIsHere = 0;
    Fdice[i+1] = dice[top][frontIsHere++];
  }
  /*
  rep(i,6){
    cout << i << "番目は" << Fdice[i] << endl;
  }
  */

}


void Display(){

  REP(i,240,260){
      REP(j,240,260){
	cout << graph[i][j].first<< " ";
      }
      cout << endl;
    }

}

int Boxing(int front,int dir){
  if(dir == 1){
    return 0;
  }
  if(dir == 2){
    return 1;
  }
  if(dir == 3){
    return 5;
  }
  if(dir == 4){
    return 1;

  }
}


void decideTheDestinyOfTheDice(int x,int y,int top,int front){
  P choice = P(-1,-1);
  int roll,Here;
  //cout << "top = "<< top << ", front = " << front << endl;
  //cout << "x = " << x << ", y = " << y << endl;
  roll = Here = 0;
  CreateFdiceForYou(top,front);
  rep(i,4){
    P p = P(x+dx[i],y+dy[i]);
    if(graph[p.second][p.first].second < graph[y][x].second){
      if(Fdice[i+1] == 4 || Fdice[i+1] == 5 || Fdice[i+1] == 6){
	if(roll < Fdice[i+1]){
	  roll = Fdice[i+1];
	  Here = i+1;
	  choice = P(p.first,p.second);
	}
      }
    }
  }

  //cout << "choice = " << choice.first << "  " << choice.second << endl;
  if(choice == P(-1,-1)){
    graph[y][x] = P(top,graph[y][x].second+1);
  }
  else{
    //cout << "Here = " << Here << endl;
    int dir = Boxing(front,Here);
    //cout << "7-roll = " << 7-roll << ", Fdice[here] = " << Fdice[Here] << ", Here = " << Here << endl;
    //cout << "dir = " << dir << ", Ddice[dir] = " << Fdice[dir] << endl;
    decideTheDestinyOfTheDice(choice.first,choice.second,7-roll,Fdice[dir]);
  }
  return;
}


int main(){
  int n,t,f;
  while(cin >> n && n){
    rep(i,500)rep(j,500)graph[i][j] = P(0,0);
    rep(i,6)ans[i] = 0;    

    rep(i,n){
      cin >> t >> f;
      decideTheDestinyOfTheDice(250,250,t,f);
    }

    //Display();
    REP(i,100,400){
      REP(j,100,400){
	if(graph[i][j].second != 0){
	  ans[graph[i][j].first-1]++;
	}
      }
    }

    rep(i,6){
      cout << ans[i];
      if(i != 5)cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
int main()
{
  string s;
  cin>> s;
  if (s=="MON")
    cout<<"6"<<endl;
  else if (s=="TUE")
    cout<<"5"<<endl;
  else if (s=="WED")
    cout<<"4"<<endl;
  else if (s=="THU")
    cout<<"3"<<endl;
  else if (s=="FRI")
    cout<<"2"<<endl;
  else if (s=="SAT")
    cout<<"1"<<endl;
  else
    cout<<"7"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define deb(x)  cout << #x << ' ' << x << endl;
#define md 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long 
ll bp(ll a,ll b){
    a %= md;
    ll res = 1;
    while(b > 0){
        if(b&1){
            res = res * a %md;
        }
        a = a *a %md;
        b /= 2;
    }
    return res;
}
void solve() {
    ll n; cin >> n;
    ll ans = (bp(10,n) - 2*bp(9,n) + bp(8,n)) %md;
    ans = (ans + md)%md;
    cout << ans << endl;
}
int main(){
  
    int T = 1; 
    // cin >> T;	
    while(T--){
        solve();
    }
    return 0;
            
}

Measured memory_bytes: 3608
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	int n,m;
	int a[5];
	bool ans;
	int main(){
		IOS
		cin>>n>>m;
		memset(a,-1,sizeof(a));
		for(int i=0;i<m;i++){
			int t1,t2;
			cin>>t1>>t2;
			if(a[t1]==-1){
				a[t1]=t2;
			}	
			else if(a[t1]!=t2)
				ans=1;
			if(ans)
				break;
		}
		if(a[1]==-1&&n>1)
			a[1]=1;
		for(int i=1;i<=n;i++)
			if(a[i]==-1)
				a[i]=0;
		if(n>1&&a[1]==0)
			ans=1;
		if(ans){
			cout<<"-1\n";
			return 0;
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			ans=ans*10+a[i];
		cout<<ans<<endl;
//		for(int i=1;i<=n;i++)
//			cout<<a[i];
//		cout<<endl;
	} 

Measured memory_bytes: 256
n, m = map(int, input().split())
ans = 0
lights = []
for i in range(m):
  lights.append(list(map(lambda x: int(x)-1, input().split()[1:])))
p = list(map(int, input().split()))

from copy import copy
on_off = []
def search(l, on):
  new_l = copy(l)  
  new_l.append(on)
  if len(new_l) < n:
    search(new_l, 1)
    search(new_l, 0)
  else:
    on_off.append(new_l)
search([], 0)
search([], 1)

ans = 0
for states in on_off:
  for j in range(m):
    s = 0
    for i in range(n):
      if states[i] == 1 and i in lights[j]:
        s += 1
    if s % 2 != p[j]:
      break
  else:
    ans += 1
print(ans)

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

int main() {
	int x, y;
	cin >> x >> y;

	if ( x % y == 0 ) {
		cout << -1 << endl;
		return 0;
	}
	else {
		for ( int i = 0; ; i++ ) {
			if ( i * x % y != 0 ) {
				cout << i * x << endl;
				return 0;
			}
		}
	}
}


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

int C, D, W, X;
int E[100][100];
int F[100][100];

int day[100][100][2]; //iツ禿コツ姪堋づ泳ツづ個閉可担ツつェツつゥツつゥツづゥツづつォツづ個催妥・ツ猟伉益
int dp[100][100][10]; //iツ禿コツ姪堋づ慊づづ泳ツづ個閉可担ツつェツつゥツつゥツづィ2ツ度ツ暗按湘」ツδ可イツブツつオツつスツ禿コツつェkツづ個づつォツづ個催妥・ツ猟伉益

void calcDay(){
  memset(day, -1, sizeof(day));

  for(int j = 0; j < D; j++){
    for(int i = 0; i < C; i++){
      if(E[i][j] == 0) continue;
      if(F[i][j] > W) continue;
      day[j][F[i][j]][0] = max(day[j][F[i][j]][0], E[i][j]);

      int sumE = E[i][j];
      int sumF = F[i][j];

      for(int k = i + 1; k < C; k++){
        if(E[k][j] == 0) break;

        sumE += E[k][j];
        sumF += F[k][j];

        if(sumF > W) break;

        day[j][sumF][1] = max(day[j][sumF][1], sumE);
      }
    }
  }
}

void solve(){
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;

  for(int i = 0; i < D; i++){
    for(int j = 0; j <= W; j++){
      for(int k = 0; k <= X; k++){
        if(dp[i][j][k] == -1) continue;
        dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);

        for(int l = 0; j + l <= W; l++){
          if(day[i][l][0] != -1){
            dp[i + 1][j + l][k] = max(dp[i + 1][j + l][k], dp[i][j][k] + day[i][l][0]);
          }
          if(k + 1 <= X && day[i][l][1] != -1){
            dp[i + 1][j + l][k + 1] = max(dp[i + 1][j + l][k + 1], dp[i][j][k] + day[i][l][1]);
          }
        }
      }
    }
  }

  int ans = 0;

  for(int j = 0; j <= W; j++){
    for(int k = 0; k <= X; k++){
      ans = max(ans, dp[D][j][k]);
    }
  }

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

int main(){
  while(scanf("%d%d%d%d", &C, &D, &W, &X) != EOF, C || D || W || X){
    for(int i = 0; i < C; i++){
      for(int j = 0; j < D; j++){
        scanf("%d", &E[i][j]);
      }
    }

    for(int i = 0; i < C; i++){
      for(int j = 0; j < D; j++){
        scanf("%d", &F[i][j]);
      }
    }

    calcDay();
    solve();
  }
}

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

#define MOD (long long)(1000000007)

using namespace std;

int main(void)
{
    long long sum = 0;
    int num_cnt;
    vector<long long> nums;


    cin >> num_cnt;

    for(int i = 0; i < num_cnt; i++){
        long long n;
        cin >> n;
        sum += n;
        nums.push_back(n);
    }
    sum %= MOD;

    long long prod_sum = 0;

    for(int i = 0; i < num_cnt; i++){
        sum -= nums[i];
        if(sum < 0){
            sum += MOD;
        }

        prod_sum += nums[i] * sum;
        prod_sum %= MOD;
    }

    cout << prod_sum << endl;

    return 0;
}

Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	cout << n * (n + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key){
   int i = 0;
   A[n] = key;
   while( A[i] != key) i++;
   return i != n;
}

int main(){
   int i, n, A[10000+1], q, key, sum = 0;
   scanf("%d", &n);
   for( i=0; i<n; i++) scanf("%d", &A[i]);
   
   scanf("%d", &q);
   for( i=0; i<q; i++) {
      scanf("%d", &key);
      if( search(A, n, key)) sum++;
   }
   printf("%d\n", sum);

   return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int x[110000],n,w[110000],A[110000];
const int mo=1e9+7;
int main(){
	scanf("%d",&n); 
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	sort(x+1,x+n+1); w[1]=0; w[2]=0;
	for (int i=3;i<=n;i++)
		if (x[i-1]==x[i-2]+1&&x[i-1]<=(i-1-w[i-1]-1)*2) w[i]=w[i-1]+1; else w[i]=w[i-1];
//	for (int i=1;i<=n;i++) cout<<w[i]<<" "; cout<<endl;
	for (int i=1;i<=n;i++) A[w[i]+1]++;
	for (int i=1;i<=n;i++) A[i]+=A[i-1];
	int ans=1;
	for (int i=1;i<=n;i++) ans=1ll*ans*(A[i]-i+1)%mo;
	printf("%d\n",ans);
	return 0;
}
	

Measured memory_bytes: 1408
from collections import deque
#定数
#3≦n≦2*10^3
n, x, y = map(int, input().split())

#答えの計算
A = [0 for i in range(n)]   #Answers
for i in range(n):  #O(n)
    Q = deque([i])  #Queue BFSのためのもの
    #Record 位置iからの距離を記録
    R = [-1 for i in range(n)]  
    R[i] = 0
    #BFS O(n)
    while len(Q) != 0:
        t = Q[0]    #target
        d = R[t]    #distance(target)
        Q.popleft()
        #Queueに値を入れるとともに距離を更新する
        def push_and_record(t:int, d:int):
            if R[t] < 0:
                R[t] = d
                Q.append(t)
            else:
                pass
        #+方向
        if t < n-1:
            push_and_record(t+1, d+1)
        else:
            pass
        #-方向
        if t > 0:
            push_and_record(t-1, d+1)
        else: 
            pass
        #xとy
        if t == x-1:
            push_and_record(y-1, d+1)
        elif t == y-1:
            push_and_record(x-1, d+1)
        else:
            pass
    #Ansに距離の結果を入れる
    for i in range(n):
        A[R[i]] += 1

#答えの出力
for i in range(1, n):
    print(A[i] // 2)    #組み合わせ

Measured memory_bytes: 58332
import sys
import collections

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

MAXNUM = 1000001

def main():
    N = int(input())
    A = list(map(int, readline().split()))
    A.sort()
    Acounter = collections.Counter(A)
    acount1 = Acounter[1]
    if acount1 >= 1:
        if acount1 == 1:
            print(1)
            return
        else:
            print(0)
            return
    numset = set()
    for a in A:
        acount = Acounter[a]
        if a in numset:
            continue
        if acount > 1:
            numset.update(set(range(a, MAXNUM, a)))
        else:
            numset.update(set(range(2*a, MAXNUM, a)))

    cnt = 0
    for a in A:
        cnt += a not in numset

    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 122064
#include <iostream>
#define Nmax 100005
#define ll long long
using namespace std;

ll n, v[Nmax][4], dp[Nmax][4];

int main()
{

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i][1] >> v[i][2] >> v[i][3];
    }

    dp[1][1] = v[1][1];
    dp[1][2] = v[1][2];
    dp[1][3] = v[1][3];
    for (int i = 2; i <= n; ++i) {
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + v[i][1];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + v[i][2];
        dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + v[i][3];
    }
    cout << max(max(dp[n][1], dp[n][2]), dp[n][3]);
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int n;
Int h[108000];
Int dp[108000];
int main(){
  cin >> n;
  for(int i = 1;i <= n;i++)cin >> h[i];
  fill(dp, dp + 108000, INF);
  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for(int i = 3;i <= n;i++){
    dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1920
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

#############################################

N, K = s_inpl()

print(N-K+1)

Measured memory_bytes: 3800
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll divi(ll x,ll y){return mul(x,mpow(y,mod-2));}
/*
ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}
*/

/*
ll nCr(ll n,ll r){
  r=min(r,n-r);
  ll A=1,B=1;
  for(ll i=0;i<r;i++){
    A=mul(A, (n-i)%mod );
    B=mul(B, (i+1)%mod );
  }
  return divi(A,B);
}
*/


ll fact[10000000]={1}, factc=0;
ll Fact(ll x){
  while( factc < x ){
    factc++;
    fact[factc]=mul( fact[factc-1] , factc );
  }
  return fact[x];
}

ll nCr(ll n,ll r){
  return divi( Fact(n) , mul( Fact(n-r) , Fact(r) )   );
}


/*
ll nHr(ll n,ll r){
  return nCr( n+r-1 , n );
}
*/

ll dp[1001][1001];
int main(){
  ll n,k;
  cin>>n>>k;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      dp[i][j]+=dp[i-1][j-1];
      dp[i][j]+=dp[i-1][j]*j;
      dp[i][j]%=mod;
    }
  }
  ll ans=0;
  for(int j=1;j<=k;j++)
    ans=add(ans,dp[n][j]);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 10964
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using edge=struct{int to; ll cost;};

const int limit=100010;
vector<edge> tree[limit];
ll dis[limit];

void dfs(int k,int i,ll d){
  dis[k]=d;
  for(auto &e:tree[k]){
    if(i==e.to) continue;
    dfs(e.to,k,d+e.cost);
  }
}

int main(){
  int n; cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c; cin>>a>>b>>c;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }int q,k; cin>>q>>k;
  dfs(k,-1,0);
  for(int i=0;i<q;i++){
    int x,y; cin>>x>>y;
    cout<<dis[x]+dis[y]<<endl;
  }
}

Measured memory_bytes: 14336
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	s = chomp(readline())
	if s == "zyxwvutsrqponmlkjihgfedcba"
		println(-1)
	elseif length(s) < 26
		t = split(s, "")
		t = sort(t)
		flg = 0
		for i in 1:length(t)
			if Int(t[i][1]) != i+96
				print(s,Char(i+96))
				flg = 1
				break
			end
		end
		if flg == 0
			print(s,Char(length(t)+97))
		end
	else
		cand = Char[]
		for i in 0:24
			push!(cand,s[26-i])
			if s[26-i] > s[25-i]
				cand = sort(cand)
				print(s[1:24-i])
				for j in 1:length(cand)
					if s[25-i] < cand[j]
						println(cand[j])
						break
					end
				end
				break
			end
		end
	end
end
main()

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

using namespace std;

int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  char S[100000], T[100000];
  scanf("%s%s", S, T);
  
  // 最大公約数を計算
  int g = __gcd(N, M);
  int stepS = N / g;
  int stepT = M / g;
  for (int i = 0; i < N; ++i) {
    if (i % stepS == 0) {
      if (S[i] != T[i / stepS * stepT]) {
        puts("-1");
		return 0;
      }
	}
  }
  printf("%lld", 1ll * N / g * M);
  return 0;
}

Measured memory_bytes: 384
/*
    If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

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

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b)
{
    a+=b; a%=MOD;
    if(a<0) a+=MOD;
    return a;
}
ll mult(ll a, ll b)
{
    if(a>MOD) a%=MOD;
    if(b>MOD) b%=MOD;
    ll ans=(a*b)%MOD;
    if(ans<0) ans+=MOD;
    return ans;
}
ll pw(ll a, ll b)
{
    ll r=1;
    while(b){
        if(b&1) r=mult(r,a);
        a=mult(a,a);
        b>>=1;
    }
    return r;
}

void solve(){
    string a,b;
    cin>>a>>b;
    string tmp = "";
    int j=0,l=0;
    for(int  i = 0 ; i < a.length()+b.length() ; i++){
        if(!(i&1)){tmp+=a[j];j++;}
        else {tmp+=b[l];l++;}
    }
    cout<<tmp<<endl;
}

int main(){
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;
        //cout<<"Case "<<k<<": ";
        solve();
    }
}



Measured memory_bytes: 3656
object Main {

  def printArray(arr: Array[Int]): Unit =
    println(arr.mkString("\n"))

  def main(args: Array[String]): Unit = {
    import scala.collection.immutable.Queue
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()

    def solve(): Long = {
      val MD = 1000000000 + 7
      val memo = Array.fill(N)(scala.collection.mutable.Map.empty[Queue[Char], Long])

      def dfs(i: Int, last3: Queue[Char]): Long =
        if (i < N)
          if (memo(i).contains(last3))
            memo(i).apply(last3)
          else {
            val dequeued = last3.dequeue._2
            val v = last3 match {
              case Queue(_, 'A', 'G') =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('G')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
              case Queue(_, 'A', 'C') =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('C')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
              case Queue(_, 'G', 'A') =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('G')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
              case Queue('A', _, 'G') =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('G')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
              case Queue('A', 'G', _) =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('G')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
              case _ =>
                (dfs(i + 1, dequeued.enqueue('A')) +
                  dfs(i + 1, dequeued.enqueue('C')) +
                  dfs(i + 1, dequeued.enqueue('G')) +
                  dfs(i + 1, dequeued.enqueue('T'))) % MD
            }
            memo(i).put(last3, v)
            v
          }
        else 1

      dfs(0, Queue('T', 'T', 'T'))
    }

    println(solve())
  }

}


Measured memory_bytes: 45940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		while (true) {
			a = sc.nextInt();
			String op = sc.next();
			b = sc.nextInt();
			if (op.equals("+"))
				System.out.println(a + b);
			else if (op.equals("-"))
				System.out.println(a - b);
			else if (op.equals("*"))
				System.out.println(a * b);
			else if (op.equals("/"))
				System.out.println(a / b);
			else
				break;
		}
		sc.close();
	}
}



Measured memory_bytes: 26452
n,m=map(int,input().split())
A=list(map(int,input().split()))
D={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
C=[]
for i in range(1,10):
    if i in A:
        C.append(D[i])
DP=[-float('inf')]*(n+1)
DP[0]=0
for i in range(1,n+1):
    for j in C:
        if i>=j:
            tmp=DP[i-j]+1
            DP[i]=max(DP[i],tmp)
A=sorted(A,reverse=True)
ans=''
while DP[n]:
    for i in A:
        if n-D[i]<0:
            continue
        if DP[n-D[i]]==DP[n]-1:
            ans+=str(i)
            n-=D[i]
            break
print(ans)

Measured memory_bytes: 3408