akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>

#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define BITCOUNT(mask) ( __builtin_popcount((mask)) )

int check(VI P) {
   const int N = P.size();

   assert(BITCOUNT(N) == 1);

   VI prefix_xor(N+1);
   VI last(N/2, 0);
   int res = -1;
   for (int j = 1; j <= N; ++j) {
      int x = P[j-1];
      assert(x < int(last.size()));
      prefix_xor[j] = prefix_xor[j-1] ^ x;
      if (last[x] == 0) {
         last[x] = j;
         continue;
      }

      int i = last[x];
      assert(i > 0);

      int k = prefix_xor[j] ^ prefix_xor[i-1];
      if (res < 0)
         res = k;
      else if (res != k)
         return -1;
      last[x] = -last[x];
   }
   return res;
}


VI solve(int M, int K) {
   const int U = 1<<M;
   if (K >= U)
      return VI();

   VI res;

   if (K == 0) {
      for (int n = 0; n < U; ++n) {
         res.push_back(n);
         res.push_back(n);
      }
      return res;
   }
   
   if (M == 1 && K == 1)
      return VI();

   for (int n = 0; n < U; ++n) {
      if (n != K)
         res.push_back(n);
   }
   res.push_back(K);
   for (int n = U-1; n >= 0; --n) {
      if (n != K)
         res.push_back(n);
   }
   res.push_back(K);
   return res;
}

int main() {
/*
   VI P = {7, 6, 4, 3, 2, 1, 0, 5, 0, 1, 2, 3, 4, 6, 7, 5};
   fprintf(stderr, "%d\n", check(P)); 
*/

   int M, K;
   scanf("%d %d", &M, &K);

   VI res = solve(M, K);
   if (res.empty())
      printf("-1\n");
   else {
   // assert( check(res) == K );
      for (int i = 0; i < int(res.size()); ++i) {
         if (i > 0) putchar(' ');
         printf("%d", res[i]);
      }
      printf("\n");
   }

   return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
typedef vector<vector<int > > vec2int;
typedef vector<vector<bool > > vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int h, w;
  cin >> h >> w;
  vec2bool g(h,vecbool(w));
  char tmp;
  int numinit = 0;
  REP(i,h){
    REP(j,w){
      cin >> tmp;
      if(tmp == '.'){
	g[i][j] = true;
      }else{
	g[i][j] = false;
	numinit ++;
      }
    }
  }


  vec2int dist(h,vecint(w,0));
  queue<pair<int,int> > q;
  dist[0][0] = 1;
  q.push(make_pair(0,0));
  while(!q.empty()&&dist[h - 1][w - 1] == 0){
    int x0 = q.front().first;
    int y0 = q.front().second;
    q.pop();
    REP(i,4){
      int x = x0 + dx[i];
      int y = y0 + dy[i];
      if(0 <= x && x<= h - 1 && 0<= y && y<= w - 1){
	if(g[x][y]&&dist[x][y]==0){
	  q.push(make_pair(x, y));
	  dist[x][y] = dist[x0][y0] + 1;
	}
      }
    }
  }
  
  if(dist[h -1][w - 1] > 0){
    cout << h*w - numinit - dist[h - 1][w - 1] << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int M, int T, int P, int R) {
    vector<pair<VI, VI>> team(T);
    REP(i, T) team[i] = MP(VI(P, -1), VI(P, 0)); //(AC?????????, WA??°)
    REP(i, R) {
        int m, t, p, j;
        cin >> m >> t >> p >> j;
        t--;p--;
        if (j == 0) {
            int pena = team[t].second[p] * 20;
            team[t].first[p] = pena + m;
        } else {
            team[t].second[p]++;
        }
    }
    vector<pair<PII, int>> ans(T); //(AC??°, ????¨??????????), ???????????????
    REP(i, T) {
        int ac = 0, tim = 0;
        REP(j, P) {
            if (team[i].first[j] != -1) {
                ac++;
                tim += team[i].first[j];
            }
        }
        ans[i] = MP(MP(ac, tim), i);
    }
    sort(ALL(ans), [](const pair<PII, int>& l, pair<PII, int>& r) {
        if (l.first.first != r.first.first) return l.first.first > r.first.first;
        if (l.first.second != r.first.second) return l.first.second < r.first.second;
        return l.second > r.second;
    });
    PII back = MP(-1, -1);
    REP(i, T) {
        if (i) if (ans[i].first == back) {
            cout << "=";
        } else {
            cout << ",";
        }
        cout << ans[i].second + 1;
        back = ans[i].first;
    }cout << endl;
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m >> p >> a, n) {
        solve(n, m, p, a);
        //return 0;
    }
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        sc.close();

        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }

}


Measured memory_bytes: 21844
N,x=map(int,input().split())
a=list(map(int,input().split()))
temp=x
ans=0
a.sort()
i=-1
while True:
    i+=1
    x-=a[i]
    if x<0:
        break
    ans+=1
    if ans==N:
        break
if sum(a)<temp:
    ans-=1
    
print(ans)


Measured memory_bytes: 9168
def main():
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    n = int(input())

    print(a[n-1])
if __name__=='__main__':
    main()


Measured memory_bytes: 3060
def func(n)
  return n.even? ? (n / 2) : (3 * n + 1)
end

s = gets.to_i
list = [s]
nn = func(s)
count = 2;
while !list.include?(nn)
  list.push(nn)
  nn = func(nn)
  count += 1
end

puts count


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffor(i,a,b) for(ll i=a;i<=b;i++)
#define rfor(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9+7;
const ll N = 1e6+6;
const ll maxN = 1e6+6;

ll power(ll x,ll y, ll M = MOD) // default argument
{ll v=1;x=x%M;while(y>0){if(y&1)v=(v*x)%M;y=y>>1;x=(x*x)%M;}return v;}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input1.txt", "r", stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    FIO
    ll n;
    cin>>n;
    ll ans;
    if(n%1000 == 0){
        ans=0;
    }
    else{
        ll t = n/1000;
        t++;
        ans = (t*1000)-n;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

ll gcd(ll num1, ll num2){ return num2 == 0 ? num1: gcd(num2, num1 % num2); }

// F(r) = (ar + b) mod 26 
// r = F(r) - b + 26k) ≡ 0 (mod a)
char decode(const char ch, int n, int a, int b){
    if(!islower(ch)) return ch;
    int t = (ch - 'a') - b;
    while(t < 0 || t % a != 0) t += n;
    return 'a' + (t/a) % n;
}

int main(){
    string s;
    getline(cin, s);
    int n;
    sscanf(s.c_str(), "%d", &n);

    REP(i,n){
        getline(cin, s);
        REPEAT(j,1,26){
            if(gcd(26,j) != 1) continue;
            REP(k,26){
                string t = s;
                int len = t.size();

                REP(l,len){
                    t[l] = decode(t[l], 26, j, k);
                }

                pf("%d:%d %s\n", j, k, t.c_str());
                char buf[260];
                sprintf(buf, " %s ", t.c_str());
                if(strstr(buf, " that ") != NULL || strstr(buf, " this ") != NULL){
                    cout << t << endl;
                    goto END;
                }
            }
        }
END:;
    }

    return 0;
}

Measured memory_bytes: 1264
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long[] p1 = { sc.nextLong(), sc.nextLong() };
		long[] p2 = { sc.nextLong(), sc.nextLong() };
		if (p1[0] > p2[0]) {
			long tmp = p1[0];
			p1[0] = p2[0];
			p2[0] = tmp;
			tmp = p1[1];
			p1[1] = p2[1];
			p2[1] = tmp;
		}
		int coe = 1;
		if (p1[1] > p2[1]) {
			coe = -1;
			p1[1] *= coe;
			p2[1] *= coe;
		}
		int n = sc.nextInt();
		long[][] p = new long[n][2];
		for (int i = 0; i < n; ++i) {
			p[i][0] = sc.nextLong();
			p[i][1] = sc.nextLong() * coe;
		}
		Arrays.sort(p, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(o1[0], o2[0]);
			}
		});
		int sz = 0;
		for (int i = 0; i < n; ++i) {
			if (p1[0] <= p[i][0] && p[i][0] <= p2[0] && p1[1] <= p[i][1] && p[i][1] <= p2[1])
				++sz;
		}
		long[] a = new long[sz];
		sz = 0;
		for (int i = 0; i < n; ++i) {
			if (p1[0] <= p[i][0] && p[i][0] <= p2[0] && p1[1] <= p[i][1] && p[i][1] <= p2[1]) {
				a[sz++] = p[i][1];
			}
		}
		long lis = LIS(a.length, a);
		double ans = (p2[0] - p1[0] + p2[1] - p1[1]) * 100 + (Math.PI * 5 - 20) * lis;
		if (lis == Math.min(p2[0] - p1[0] + 1, p2[1] - p1[1] + 1))
			ans += Math.PI * 5;
		System.out.println(String.format("%.20f", ans));
	}

	long LIS(int n, long[] a) {
		long[] f = new long[n];
		int sz = 0;
		for (int i = 0; i < n; ++i) {
			if (sz == 0) {
				f[sz] = a[0];
				++sz;
			} else {
				int ok = -1;
				int ng = sz;
				while (ng - ok > 1) {
					int middle = (ok + ng) / 2;
					if (f[middle] < a[i]) {
						ok = middle;
					} else {
						ng = middle;
					}
				}

				f[ok + 1] = a[i];
				if (ok + 1 == sz)
					++sz;
			}
		}
		return sz;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 116588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

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

    auto p = minmax_element(a.begin(), a.end());
    auto it = *p.first + *p.second < 0 ? p.first : p.second;

    auto f = [&](int x, int y) {
        if (it == p.first) x = n - 1 - x, y = n - 1 - y;
        for (int i = 0; i < 2; i++) {
            cout << x + 1 << ' ' << y + 1 << '\n';
        }
    };

    cout << 2 * n << '\n';
    int i = it - a.begin(); if (it == p.first) i = n - 1 - i;
    f(i, 0);
    for (int i = 0; i < n - 1; i++) {
        f(i, i + 1);
    }

    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int, input().split()))


table = collections.defaultdict(int)
for x in a:
    table[x] += 1
ans = 0
for x in table:
    if x < table[x]:
        ans += table[x] - x

    elif x > table[x]:
        ans += table[x]

print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

vector<ll> apply(vector<ll> ar, const vector<ll> &perm)
{
	vector<bool> done(ar.size());
	for(int i=0; i<ar.size(); i++)
	{
		if(!done[i])
		{
			int pos = i, store = ar[i];
			while(perm[pos] != i)
			{
				ar[pos] = ar[perm[pos]];
				done[pos] = true;
				pos = perm[pos];
			}
			ar[pos] = store;
			done[pos] = true;
		}
	}
	return ar;
}

vector<ll> bigpow(vector<ll> &base, ll pw)
{
	vector<ll> ret(base.size());
	for(int i=0; i<ret.size(); i++)
		ret[i] = i;

	while(pw)
	{
		if(pw&1)
			ret = apply(ret,base);
		base = apply(base,base);
		pw >>= 1;
	}

	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	/* freopen("input.txt", "r", stdin); */

	int n;
	cin >> n;
	vector<ll> d(n-1);
	ll a0, prev, cur;
	cin >> a0;
	prev = a0;
	for(int i=0; i<d.size(); i++)
	{
		cin >> cur;
		d[i] = cur - prev; 
		prev = cur;
	}

	vector<ll> perm(n-1);
	for(int i=1; i<perm.size(); i++)
		perm[i] = i;

	int m, ord;
	ll k;
	cin >> m >> k;
	for(int i=0; i<m; i++)
	{
		cin >> ord;
		swap(perm[ord-1],perm[ord-2]);
	}

	perm = bigpow(perm,k);
	d = apply(d,perm);
	
	cout << a0 << '\n';
	for(auto x: d)
	{
		a0 += x;
		cout << a0 << '\n';
	}

	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main() {
    long long int r[100005], n, calc = 1;
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &r[i]);
    }
    for (int i = 0; i < n; i++) {
        if (r[i] == 0) {
            printf("0");
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (r[i] <= (1000000000000000000 / calc)) {
            calc *= r[i];
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", calc);
}

Measured memory_bytes: 2488
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n, ans;
    cin >> a >> b >> n;
    ans = 0;
    if(b > n){
        ans = (a*n)/b - a*(n/b);
        cout << ans <<"\n";
        return 0;
    }
    //bの倍数を超えない最大のnを求める
    ll tmp = n % b + 1;
    tmp = n - tmp;
    ans = (a*tmp)/b - a*(tmp/b);
    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 3596
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000009
#define mod 1000000000
#define INF 1000000000
#define PB push_back
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n;
LL aa[100010], bb[100010];

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(4);

	cin >> n;
	For(i, 0, n)
	{
		cin >> aa[i] >> bb[i];
	}

	LL curr = 0;

	FoR(i, n, 0)
	{
		aa[i] += curr;
		LL kk = aa[i] % bb[i];
		curr += (bb[i] - kk) % bb[i];
	}

	cout << curr << endl;

	return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, M;
    cin >> N >> M;

    scc_graph G(N);
    REP(i, M){
        ll a, b;
        cin >> a >> b;
        G.add_edge(a, b);
    }

    auto res = G.scc();
    
    cout << res.size() << "\n";
    for(auto &v: res){
        cout << v.size() << " ";
        for(auto x: v) cout << x << " ";
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 40588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        s: chars,
    }
    let n = s.len();
    for i in 0..n {
        if i%2 == 0 { 
            print!("{}", s[i]);
        }
    }
    println!();
}


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

using namespace std;

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

  int xx = -x;
  int yy = -y;

  int mn = 2000000000;
  if(x <= y) {
    mn = min(mn, y - x);
  }
  if(x <= yy) {
    mn = min(mn, yy - x + 1);
  }
  if(xx <= y) {
    mn = min(mn, y - xx + 1);
  }
  if(xx <= yy) {
    mn = min(mn, yy - xx + 2);
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    std::cin>>a>>b>>c;
    if((a<c&&b>c)||(a>c&&b<c)){
        std::cout <<"Yes"<< std::endl;
    }else{
        std::cout <<"No"<< std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    int n, t, a;
    cin >> n >> t;
    
    vector<int> as;
    
    REP(i,n) {
        cin >> a;
        as.push_back(a);
    }

    vector<int> v = vector<int>(n, 0);
    
    v[n-1] = as[n-1];
    
    for (int i = n - 2; i >= 0; i--) {
        v[i] = max(v[i+1], as[i]);
    }
    
    int df = 0;
    REP(i,n) {
        df = max(df, v[i] - as[i]);
    }
    
    int ans = 0;
    REP(i,n) {
        if (v[i] - as[i] == df) {
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;
 
template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 122;
int n;
ll a[N];
 
int main(){
	read(n);
	rep(i, 1, n) read(a[i]);
	ll tag = 0;
	for (; ;){
		ll cnt = 0;
		rep(i, 1, n){
			ll cur = a[i] + tag;
			cnt += cur / n;
			a[i] = cur % n - cur / n - tag;
		}
		if (!cnt) break;
		tag += cnt;
	}
	printf("%lld\n", tag);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	char a[100],b[100],c[100];
	scanf("%s", a, 100);
	scanf("%s", b, 100);
	scanf("%s", c, 100);
	printf("%c%c%c\n", a[0], b[0], c[0]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a;

int main(){
	int sum = 0;
	REP(i, 5){
		cin >> a;
		if (a < 40)a = 40;
		sum += a;
	}
	cout << sum / 5 << endl;
}

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

int main(){
	int n;
	scanf("%d",&n);
	
	int a=n/1000;
	int b=n%1000/100;
	int c=n%100/10;
	int d=n%10;
	
	if(a==b||b==c||c==d){
		printf("Bad");
	}else{
		printf("Good");
	}
	return 0;
}

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

using namespace std;
#define ll long long

void init();
void solve();

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int x1, yy1, x2, yy2;
int x3, yy3, x4, yy4;

void init()
{
	cin >> x1 >> yy1 >> x2 >> yy2;
}

void solve()
{
	int a = x2 - x1;
	int b = yy2 - yy1;
	x3 = x2 - b;
	yy3 = yy2 + a;
	x4 = x3 - a;
	yy4 = yy3 - b;
	cout << x3 << " " << yy3 << " " << x4 << " " << yy4 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    string S, T; cin >> S >> T;

    cout << (S[0]==T[0]) + (S[1]==T[1]) + (S[2]==T[2]) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c,max,n;
    scanf("%d %d %d",&a,&b,&c);
    max=a;
    if(b>max)max=b;
    if(c>max)max=c;
    if((3*max)%2==(a+b+c)%2){
        n=(3*max-(a+b+c))/2;
    }else{
        n=(3*(max+1)-(a+b+c))/2;
    }
    printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int getdig(ll x) {
  int cnt = 0;
  while (x) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

int main() {
  ll n;
  cin >> n;
  ll i = 1;
  int ans = INT_MAX;
  while (1) {
    if ((i <= (n / i))) {
      if (i * (n / i) == n) ans = min(ans, getdig(n / i));
    } else break;
    i++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
N, W = map(int, input().split())
v = [0] * N
w = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

M = sum(v)

dp = [[W+1 for _ in range(M + 1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    dp[i+1][v[i]] = min(dp[i][v[i]], w[i])
    for j in range(v[i]):
        dp[i+1][j] = dp[i][j]
    for j in range(v[i], M + 1):
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i])
for i in range(M, -1, -1):
    if dp[N][i] <= W:
        print(i)
        exit()


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int a,b;cin>>a>>b;
	
	writeln(6-a-b);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	long long n;
	cin >> n;
	int a, m;
	cin >> a >> m;
	vector<int> v;
	v.push_back(a);
	vector<int> cnt(N);
	cnt[a] = 1;
	long long sol = 0;
	do
	{
		long long new_a = (v.back() * 1ll * v.back()) % m;
		v.push_back(new_a);
		cnt[new_a]++;
	}while(cnt[v.back()] <= 1);
	int i = 0;
	while(n and cnt[v[i]] == 1)
	{
		sol += v[i++];
		n--;
	}
	int junction = i;
	long long temp = v[i];
	int ct = 1;
	i++;
	while(cnt[v[i]] != 2)
	{
		ct++;
		temp += v[i++];
	}
	sol += n / ct * 1ll * temp;
	n -= n / ct * 1ll * ct;
	while(n)
	{
		sol += v[junction++];
		n--;
	}
	cout << sol;
	
	return 0;
}


Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a1, a2, a3, b1, b2, b3;
ll calc(ll n, vector<int> a, vector<int> b) {
    vector<ll> dp(n + 1);
    for (int i = 0; i < 3; ++i)
        for (ll j = a[i]; j <= n; ++j)
            dp[j] = max(dp[j], dp[j - a[i]] + b[i] - a[i]);
    return n + dp[n];
}
int main() {
    cin >> n >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;
    cout << calc(calc(n, vector<int>{a1, a2, a3}, vector<int>{b1, b2, b3}), vector<int>{b1, b2, b3}, vector<int>{a1, a2, a3}) << endl;
    return 0;
}


Measured memory_bytes: 195584
#include<iostream>
#include<string>
using namespace std;
#define MAX_N 100
void makemap(int h);
void seach();
void setblank(int x, int y, char c);
int h, w, ans;
string str[MAX_N];

int main(){
    while(cin >>h >>w){
        if(h == 0 && w == 0) break;
        ans = 0;
        makemap(h);
        seach();
        cout <<ans <<endl;
    }
    return 0;
}

void makemap(int h){
    for(int i = 0; i < h; i++){
        cin >>str[i];
    }
}

void seach(){
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(str[i][j] == '#' || str[i][j] == '@' || str[i][j] == '*'){
                ans++;
                setblank(j, i, str[i][j]);
            }
        }
    }
}

void setblank(int x, int y, char c){
    int movex[] = {0, 1, 0, -1}, movey[] = {-1, 0, 1, 0};
    for(int i = 0; i < 4; i++){
        int nowx = x + movex[i], nowy = y + movey[i];
        if(nowx >= w || nowx < 0 || nowy >= h || nowy < 0 || str[nowy][nowx] != c) ;
        else{
            str[nowy][nowx] = '!';
            setblank(nowx, nowy, c);
        }
    }
}

Measured memory_bytes: 0
/**-------------------------
|--------From A.R.A--------|
-------------------------**/
#include <bits/stdc++.h>

#define ll long long int
#define ull unsigned long long int
#define FOR(i,n) for(ll i=0;i<n;i++)
#define input (a,i,n)for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n)for(ll i=0;i<n;i++){cout<<a[i]<<" ";}
#define pb push_back
#define sz(c) (c).size()
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define sall(c) sort((c).begin(),(c).end())
#define rsall(c) sort((c).rbegin(),(c).rend())
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
int64_t TN=1;
using namespace std;
void  solution(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int b,k,a;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return;
        }
    }
    cout<<"NG"<<endl;

}
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cin>>TN;
    while(TN--){
        solution();
    }
    return 0;
}


Measured memory_bytes: 3640
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

long INF = 1L<<60;
int N, K;
int[][] toIndex;
long[] c, r;
void main() {
    string[] input = readln.split;
    N = input[0].to!int;
    K = input[1].to!int;
    c = new long[N];
    r = new long[N];
    foreach(int i; 0..N) {
        input = readln.split;
        c[i] = input[0].to!long;
        r[i] = input[1].to!long;
    }
    toIndex = new int[][](N, 0);
    foreach(int i; 0..K) {
        input = readln.split;
        toIndex[input[0].to!int-1] ~= input[1].to!int-1;
        toIndex[input[1].to!int-1] ~= input[0].to!int-1;
    }
    bool[][] passableOnce = new bool[][](N, N);
    foreach(int i; 0..N) {
        passableOnce[i] = getPassableOnce(i);
    }

    Node[] nodes = new Node[N];
    foreach(int i; 0..N) {
        nodes[i] = new Node(i, c[i]);
    }
    nodes.front.value = 0;
    auto rbtree = redBlackTree!("a.value==b.value ? a.index<b.index : a.value<b.value")(nodes.front);
    while(!rbtree.empty) {
        Node e = rbtree.front;
        rbtree.removeFront;
        e.done = true;
        foreach(int i; 0..N) {
            if (!nodes[i].done && passableOnce[e.index][i]) {
                if (e.value+e.cost < nodes[i].value) {
                    rbtree.removeKey(nodes[i]);
                    nodes[i].value = e.value+e.cost;
                    rbtree.insert(nodes[i]);
                }
            }
        }
    }
    nodes.back.value.writeln;
}
bool[] getPassableOnce(int from) {
    long[] ary = new long[N];
    ary[] = INF;
    ary[from] = 0;
    auto list = DList!(int)(from);
    while(!list.empty) {
        int i = list.front;
        list.removeFront;
        if (ary[i] >= r[from]) break;
        foreach(int e; toIndex[i]) {
            if (ary[e] == INF) {
                ary[e] = ary[i]+1;
                list.insert(e);
            }
        }
    }
    return ary.map!(a=>a<INF).array;
}
class Node{
    int index;
    long cost;
    bool done = false;
    long value;
    this(int index, long cost) {
        this.index = index;
        this.cost = cost;
        this.value = INF;
    }
    override string toString() const {return ""; }
}

Measured memory_bytes: 97144
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 9) {
        cout << "Yes";
        return 0;
    }
    else if (n / 10 == 9) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  // まず左回りの方を沢山歩く
  ll N, C;
  cin >> N >> C;
  vector<ll> x(N), v(N);
  for(int i = 0; i < N; i++){
    cin >> x[i] >> v[i];
  }

  vector<ll> rOA(N);
  vector<ll> lOA(N);

  rOA[0] = v[0] - x[0];
  for(int i = 1; i < N; i++){
    rOA[i] = rOA[i-1] - (x[i] - x[i-1]) + v[i];
  }

  vector<ll> maxrOA(N);
  maxrOA[0] = rOA[0];
  for(int i = 1; i < N; i++){
    maxrOA[i] = max(maxrOA[i-1], rOA[i]);
  }

  lOA[N-1] = v[N-1] - 2 * (C - x[N-1]);
  for(int i = N-2; i >= 0; i--){
    lOA[i] = lOA[i+1] + v[i] - 2 * (x[i+1] - x[i]);
  }

  ll ans_r = 0;
  chmax(ans_r, lOA[0]);
  chmax(ans_r, maxrOA[N-1]);
  for(int i = 1; i < N; i++){
    chmax(ans_r, lOA[i] + maxrOA[i-1]);
  }

  vector<ll> rOB(N);
  vector<ll> lOB(N);

  rOB[0] = v[0] - 2 * x[0];
  for(int i = 1; i < N; i++){
    rOB[i] = rOB[i-1] - 2*(x[i] - x[i-1]) + v[i];
  }

  lOB[N-1] = v[N-1] - (C - x[N-1]);
  for(int i = N-2; i >= 0; i--){
    lOB[i] = lOB[i+1] + v[i] - (x[i+1] - x[i]);
  }

  vector<ll> maxlOB(N);
  maxlOB[N-1] = lOB[N-1];
  for(int i = N-2; i >= 0; i--){
    maxlOB[i] = max(maxlOB[i+1], lOB[i]);
  }

  ll ans_l = 0;
  chmax(ans_l ,rOB[N-1]);
  chmax(ans_l, maxlOB[0]);
  for(int i = N-2; i >= 0; i--){
    chmax(ans_l, rOB[i] + maxlOB[i+1]);
  }

  cout << max(ans_r, ans_l) << endl;

  return 0;
}


Measured memory_bytes: 6528
N=gets.to_i
S=gets.chomp
a=Array.new(10){Array.new}
N.times do |i|
  a[S[i].to_i].push(i)
end
cnt=0

def form(i)
  return "00"+i.to_s if i<10
  return "0"+i.to_s if i<100
  return i.to_s if i<1000
end

1000.times do |i|
  s=form(i).split("").map(&:to_i)
  next if a[s[0]].empty?
  x=a[s[0]][0]
  next if a[s[1]].empty?
  y=a[s[1]].bsearch{|e|x<e}
  next if y.nil?
  next if a[s[2]].empty?
  z=a[s[2]].bsearch{|e|y<e}
  next if z.nil?
  cnt+=1
end
puts cnt
  

Measured memory_bytes: 2300
#include<cstdio>
#define LL long long
#define __debug
using namespace std;
const int maxn = 5e5 + 5, mod = 998244353;
int step[maxn], inv[maxn];

LL fpow(LL a, int b) {
	LL ans = 1;
	while(b) {
		if(b & 1) ans = ans * a % mod;
		a = a * a % mod, b >>= 1;
	}
	return ans;
}

void pre(int n) {
	step[0] = inv[0] = 1;
	for(register int i = 1; i <= n; ++i) 
		step[i] = 1ll * step[i - 1] * i % mod;
	inv[n] = fpow(step[n], mod - 2);
	for(register int i = n - 1; i >= 1; --i)
		inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}

int C(int n, int m) {
	if(n < 0) return m & 1 ? -C(m - n - 1, m) : C(m - n - 1, m);
	if(n - m < 0) return 0;
	return (1ll * step[n] * inv[n - m] % mod) * inv[m] % mod;
}

int n, k, ret;
int main() {
	scanf("%d%d", &n, &k), pre(k);
	if(n > k) return printf("0"), 0;
	for(register int i = n; i <= k; ++i) {
		ret += C(k - 1, i - 1) % mod, ret %= mod;
	}
	printf("%d", ret);
	return 0;
}

Measured memory_bytes: 4096
n=int(input())
string_list=[input() for i in range(n)]

sum_otoshidama = 0
for i in range(n):
  if string_list[i].split(' ')[1] == 'JPY':
    sum_otoshidama += float(string_list[i].split(' ')[0])
  else:
    sum_otoshidama += float(string_list[i].split(' ')[0]) * 380000

print(sum_otoshidama)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,M;
   cin >> N >> M;
   int A[M];
   for(int i=0;i<M;i++) cin >> A[i];
   for(int i = 0 ; i <M; i++) N-=A[i];
   cout << max(-1,N)<<endl;;
   return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

int main() {
    int c1,c2,c3;
    while(cin >> c1 >> c2 >> c3) {
        int card[11] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
        card[c1]--;
        card[c2]--;
        card[c3]--;
        int ok = 0;
        for (int i = 1; i <= 10; i++) {
            if (card[i] == 0)continue;
            if (c1+c2+i <= 20)ok++;
        }
        if (ok >= 4)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main() {
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if (A+B==C+D)printf("Balanced\n");
	else {
		printf("%s\n", A+B<C+D?"Right":"Left");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
using namespace std;


int main() 
{
	int a;
	cin >> a;
	for (int b = 0; b < a; b++)
	{
		int c, d, e, f;
		cin >> c >> d >> e >> f;
		int s = c*e + d*f;
		if (e > 4 && f > 1) { cout << s*8/10 << endl; continue; }
		if (e < 5)e = 5;
		if (f < 2)f = 2;
		if (s > (c*e + d*f) * 8 / 10)cout << (c*e + d*f) * 8 / 10 << endl;
		else cout << s << endl;
	}
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define sz(v) (int)(v).size()
#define vec(x) vector < x >
using vi = vector < int >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	string s;
	int n;
	cin >> n;
	cin >> s;

	int t = 0;
	int i = 0, j = n - 1;
	// for0(i, n - 1) {
	// 	if (s[i] == 'W' and s[i + 1] == 'R') t++;
	// }
	// while (i < j) {
	// 	if(s[i]=='W' and s[j]=='R'){
	// 		j--,i++;
	// 		t++;
	// 	}
	// }
	bool f = 0;
	int p = 0;
	int c = 0;
	for0(i, n) {
		if (s[i] == 'W') c++;
	}
	if (c) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[j] == 'R') {
				p++;
			}
			else if (j < (n - c) and p > 0 and s[j] == 'W') {
				t++;
				p--;
			}
		}
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 3716
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:52:15 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
    
all(nstr.count(c) for c in '753')

ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
#A, B, totAB = zip(*ABT)
(x >> i) & 1

"""


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

if B%A ==0:
    print(A+B)
else:
    print(B-A)
    



Measured memory_bytes: 23484
#include<vector>
#include<iostream>
#include<algorithm>
#include<tuple>
#include<bits/stdc++.h>
using namespace std;

class Jud
{
public:
    int a1;
    string calc(int n){
        a1=(n-1)/999;
        if(a1==0){
            return "C";
        }else{
            return "D";
        }

        
            }
    

};
void solve(){
    Jud jud;
    int n;
    string ans;
    cin>>n;
    ans=jud.calc(n);
    cout<<"AB"<<ans<<endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    fastio;
    ll a, b, n;
    cin >> a >> b >> n;
    ll num = min(n, b - 1);
    if(num == 0) cout << "0\n";
    else cout << (a * num) / b << "\n";
    return 0;
}


Measured memory_bytes: 3652
N=int(input())
S=list(map(int,input().split()))
if S[0]==0:
  print(0)
else:
  X=S[0]
for i in range(1,N):
  if S[i]==0:
    X=0
    print(0)
    break
  else:
    if X>10**18:
      continue
    else:
      X=X*S[i]
if 0<X<=10**18:
  print(X)
else:
  if X!=0:
    print(-1)

Measured memory_bytes: 21468
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;




int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    ll n;
    cin>>n;
    ll ans=0;
    ll ar[n+10];
    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(ll i=1;i<n;i++)
    {
        if(ar[i]<ar[i-1])
        {
            ll df=ar[i-1]-ar[i];
            ans+=df;
            ar[i]+=df;
        }
    }
    cout<<ans<<nn;



}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 5104
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int k, t;
	scanf("%d %d", &k, &t);
	int ans = 0, h = (k+1)/2;
	REP(i, 0, t){
		int a;
		scanf("%d", &a);
		if(a>h){
			ans += 2*(a-h) - (k%2==0);
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3804
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())

cnt = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        cnt += i

print(cnt)


Measured memory_bytes: 9172