akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(m)]

q = [False for _ in range(n)]
wa = [0] * n

for i, s in ps:
    if q[int(i)-1] == False:
        if s == "WA":
            wa[int(i)-1] += 1
        else:
            q[int(i)-1] = True

print(sum(q), sum([v for k, v in enumerate(wa) if q[k]==True]))

Measured memory_bytes: 34636
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Measured memory_bytes: 42668
s = int(input())
l = s // 100
r = s % 100
def mm(l):
  return 0 < l < 13
if mm(l) and mm(r):
  print("AMBIGUOUS")
elif mm(l):
  print("MMYY")
elif mm(r):
  print("YYMM")
else:
  print("NA")

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N+1);
   vector<int> B(N);
   for (int i=0; i<N+1; i++){
      cin >> A.at(i);
   }
   for (int i=0; i<N; i++){
      cin >> B.at(i);
   }
   long long int sum = 0;
   for (int i=0; i<N; i++){
      if (A.at(i) >= B.at(i)){
         sum = sum + B.at(i);
      } else if (A.at(i) + A.at(i+1) <= B.at(i)){
         sum = sum + A.at(i) + A.at(i+1);
         A.at(i+1) = 0;
      } else if (A.at(i) + A.at(i+1) > B.at(i)){
         sum = sum + B.at(i);
         A.at(i+1) = A.at(i+1) - (B.at(i) - A.at(i));
      }
      //cout << sum << endl;
   }
   cout << sum << endl;
}



Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 99999999.
       01 B PIC 99999999.
       01 C PIC 99999999.
       01 temp1 PIC 999999.
       01 temp2 PIC 999999.
       01 temp3 PIC 999999.
       01 temp4 PIC 999999.
       01 N PIC 999999.
       01 S PIC 999999.
       01 T PIC 999999.
       01 NOW1 PIC 999999.
       01 NOW2 PIC 999999.
       01 NOW3 PIC 999999.
       PROCEDURE DIVISION.
       MAIN.
      	ACCEPT S.
      	PERFORM VARYING T FROM 1 BY 1 UNTIL T > S
       		ACCEPT INP
      		PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
      		END-PERFORM
      		SUBTRACT 1 FROM temp1
      		MOVE INP(1:temp1) TO A
      		ADD 2 TO temp1
      		PERFORM VARYING temp2 FROM temp1 
      			BY 1 UNTIL INP(temp2:1)=SPACE
      		END-PERFORM
      		COMPUTE N=temp2 - temp1
      		MOVE INP(temp1:N) TO B
      		ADD 1 TO temp2
      		PERFORM VARYING temp1 FROM temp2 
      			BY 1 UNTIL INP(temp1:1)=SPACE
      		END-PERFORM
      		COMPUTE N=temp1 - temp2
      		MOVE INP(temp2:N) TO C
      		COMPUTE temp1 = A - NOW1
      		COMPUTE temp2 = B - NOW2
      		COMPUTE temp3 = C - NOW3
      		COMPUTE temp2 = temp2 + temp3
      		IF temp1 < temp2 THEN
      			DISPLAY "No"
      			STOP RUN
      		END-IF
      		COMPUTE temp2 = temp1 / 2
      		COMPUTE temp1 = temp1 - temp2 * 2
      		COMPUTE temp2 = B - NOW2
      		COMPUTE temp3 = temp2 / 2 
      		COMPUTE temp2 = temp2 - temp3 * 2
      		COMPUTE temp3 = C - NOW3
      		COMPUTE temp4 = temp3 / 2
      		COMPUTE temp3 = temp3 - temp4 * 2
      		COMPUTE temp2 = temp2 + temp3
      		COMPUTE temp2 = temp2 - 2
      		IF temp2 = 2 THEN
      			MOVE 0 TO temp2
      		END-if
      		IF temp1 NOT = temp2 THEN
      			DISPLAY "No"
      			STOP RUN
      		END-IF
      		MOVE A TO NOW1
      		MOVE B TO NOW2
      		MOVE C TO NOW3
      	END-PERFORM.
      	DISPLAY "Yes"
        STOP RUN.




Measured memory_bytes: 384
#include <iostream>
#define endl '\n'
using namespace std;

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

	int S,W;
    cin >> S >> W;
    if(S > W){
        cout << "safe";
    }else{
        cout << "unsafe";
    }

    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin>>N;
	vector<int> a(N); for(auto& e:a)cin >> e;
	vector<int>ans(N);
	REP(i,N){
		ans[a[i]-1] = i + 1;
	}
	REP(i,ans.size())cout << ans[i] << " \n"[i+1 == ans.size()];
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());



int main(){
  
    vector<llong> A[int(1e5)];
    llong s;
    cin >> s;
    if( s < 10){
        cout << s << endl;
        return 0;
    }
    int keta=0;
    llong tmp=1;
    while(1){
        tmp*=10;
        keta+=1;
        if( s < tmp) break;
    }
    llong ans=0;
    int bit=1;
    while(1){
        int ind=-1;
        REP(i,keta){
            if( bit & 1 <<i){
                if(ind == -1){
                    ans += s/int( pow( 10, keta-i-1));
                    ind = i;
                }
                else{
                    int x=s/ int( pow( 10, keta-i-1));
                    ans += x % int( pow(10, i-ind));
                    ind = i;
                } 
            }
        }
        ans += s% int( pow(10,keta-ind-1));
        bit +=1;
        if( bit >= int( pow(2,keta -1))) break;
    }
    cout << ans +s<< endl;
}

Measured memory_bytes: 2560
//k-stones
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

int main()
{
    int n, k; cin >> n >> k;
    vi a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    vb state(k+1, 0);
    for(int i = 0; i < k + 1; i++)
        for(auto x: a)
        {
            if(i+x < k+1)
                state[i+x] = state[i+x] || !state[i];
        }
    cout << (state[k]?"First":"Second") <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, X; cin >> N >> X;
	int count = 1; 
	int A[110] = {}; int S[110] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		S[i] = S[i-1] + A[i]; 
		if(S[i] <= X) count ++; 
	}
	cout << count << endl; 
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())

mina = math.ceil(a * 100 / 8)
maxa = math.floor((a + 0.9) * 100 / 8)
minb = math.ceil(b * 100 / 10)
maxb = math.floor((b + 0.9) * 10)

if maxb < mina or maxa < minb:
    print(-1)
elif mina > minb:
    print(mina)
else:
    print(minb)

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

int main(){
  int n;
  cin >> n;
  int64_t l[n+1];
  for(int i=0;i<=n;i++){
    if(i==0){
       l[0]=2; 
    }else if(i==1){
      l[1]=1;
    }else{
      l[i]=l[i-2]+l[i-1];
    }
  }
  cout << l[n] << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, k;
  cin >> n >> k;
  combination tree(2 * n);
  ll ans = k > 1 ? 1: 0;
  REP_FROM(i, 1, min(k, n-1)+1) {
    ll tmp = tree.C(n, i) * tree.C(n-1, i) % mod;
    ans = (ans + tmp) % mod;
   }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int b[4], a[4],i;
	int hit, brow;
	
	while(scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) != EOF){
			scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
			hit = 0; brow = 0;
			for(i = 0; 4 > i; i++){
				if(b[i] == a[i]) {
					hit++;
					b[i] = -1;
					a[i] = -1;
				}
			}
			for(i = 0; 4 > i; i++){
				if(a[i] != -1){
					int c;
					for(c = 0; 4 > c; c++){
						if(a[i] == b[c]){
							brow++;
							a[i] = -1;
							b[c] = -1;
							break;
						}
					}
				}
			}
		printf("%d %d\n", hit, brow);
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S;
	cin >> S;

	char before = S[0];
	int ans = 0;

	for(size_t i = 1; i < S.size(); i++)
	{
		if(S[i]!=before){
			ans++;
			before = S[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    string s;
    cin >> s;
    for (char& c : s) {
        if (c == '?')c = 'D';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3756
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ps(n); cin >> ps;
    auto ps2= ps;
    sort(ps2.begin(), ps2.end());
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cnt += ps[i] != ps2[i];
    }
    cout << (cnt <= 2 ? "YES" : "NO") << '\n';
}


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

int main(){
    ll n, a;
    cin >> n >> a;
    ll ans = a;
    bool flag = false;
    for(int i = 1; i < n; i++){
        cin >> a;
        if(a == 0){
            cout << 0 << endl;
            return 0;
        }
        if(a > (1000000000000000000 / ans)){
            flag = true;
        }
        if(!flag) ans *= a;
    }
    cout << (flag ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int n,m,b[510][510];
int pc[1<<24],dp[2][1<<24],bits[510];
 
void compute() {
  int maxi = 0;
  if( n <= m ) {
    for(int i=0;i<(1<<n);i++) {
      if( maxi >= pc[i] ) continue;
      bool ok = true;
      for(int x=0;x<m;x++) {
    int cnt = 0;
    for(int y=0;y<n;y++) if( ( (i>>y) & 1 ) && b[y][x] ) ++cnt;
    if( cnt & 1 ) {
      ok = false;
      break;
    }
      }
      if( ok ) maxi = max(maxi,pc[i]);
    }
  } else { // n > m
    for(int y=0;y<n;y++) {
      bits[y] = 0;
      for(int x=0;x<m;x++) if( b[y][x] ) bits[y] = bits[y] | (1<<x);
    }
    memset(dp,-1,sizeof dp);
    dp[0][0] = 0;
    for(int y=0;y<n;y++) {
      for(int i=0;i<(1<<m);i++) dp[(y+1)&1][i] = -1;
      for(int state=0;state<(1<<m);state++) if( dp[y&1][state] != -1 ) {
    dp[(y+1)&1][state] = max(dp[(y+1)&1][state],dp[y&1][state]);
    dp[(y+1)&1][state^bits[y]] = max(dp[(y+1)&1][state^bits[y]],dp[y&1][state]+1);
      }
    }
    if( dp[n&1][0] != -1 ) maxi = dp[n&1][0];
  }
  cout << maxi << endl;
}
 
int main() {
  for(int i=0;i<(1<<23);i++) pc[i] = __builtin_popcount(i);
  while( cin >> n >> m, n|m ) {
    for(int i=0;i<n;i++) {
      string s;
      cin >> s;
      for(int j=0;j<m;j++) b[i][j] = ( s[j] == '1' );
    }
    compute();
  }
  return 0;
}



Measured memory_bytes: 168072
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC084D
    {
        static public void Main(string[] args)
        {
            var prime = new HashSet<int>(Prime(100000));
            var sumary = new int[100001];
            foreach (var item in prime)
            {
                if (prime.Contains((item + 1) / 2))
                {
                    sumary[item] = 1;
                }
            }
            for (int i = 1; i <= 100000; ++i)
            {
                sumary[i] += sumary[i - 1];
            }

            var Q = NextInt;
            for (int i = 0; i < Q; ++i)
            {
                var l = NextInt;
                var r = NextInt;
                Console.WriteLine(sumary[r] - sumary[l - 1]);
            }
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


Measured memory_bytes: 18760
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,k,a[202020]; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>k;
	fo(i,0,n)cin>>a[i];
	int l=0,r=1e9+5;
	while(l<=r){
		int mid=(l+r)/2;
		if(mid==0)break;
		ll x=0;
		fo(i,0,n)x+=(a[i]-1)/mid;
		if(x>k)l=mid+1;
		else r=mid-1;
	}
	ll x=0;
	if(l<=1){
		cout<<"1\n";
		return 0;
	}
	fo(i,0,n)x+=(a[i]-1)/(l-1);
	if(x<=k)cout<<l-1<<endl;
	else cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 4300
#include<cstdio>
#include<queue>
#include<climits>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<ctype.h>
#include<set>
#include<vector>
#include<map>
#include<time.h>
#include<list>
#include<stack>
#include<iostream>
using namespace std;
#define mod 1000000007
#define mem(x,k ) memset(x, (k) ,sizeof(x))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define sca scanf
#define pri printf
#define fi first
#define se second

typedef long long LL;
typedef long double LD;
typedef pair< int , int  > pii;

const LL INFLL=0x3f3f3f3f3f3f3f3fll;
const int INF=0x7fffffff;
const double PI=acos(-1.0);
const double  eps=1e-9;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
int n,m;
char s[100005];
int main(){
    scanf("%s",s);
    if (s[0]!=s[ strlen(s)-1 ]){
        if (strlen(s)&1){
            printf("First\n");
        }else{
            printf("Second\n");
        }
    }else{
        if (strlen(s)&1){
            printf("Second\n");
        }else{
            printf("First\n");
        }
    }
    return 0;
}





Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
#include<utility>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc104_c(){
    //入力
    int x,a,b;
	cin >> x >> a >> b;
  
    //処理
    //出力
    cout << (x-a)%b << enter;
    return 0;
}

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


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

int main() {
  int i,j,a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    c-=b;
    if(c<1){
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<1){
      cout<<"No"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3132
#include <algorithm>
#include <cstdio>
#include <cstring>
const int MAXC = 1E5+5;
char buff[MAXC]{ };
int L, T;

int main()
{
	scanf("%s", buff);
	L = T = strlen(buff);
	for(int i = 1; i < L; ++i) if(buff[i-1] != buff[i])
		T = std::min(std::max(i, L-i), T);
	printf("%d\n", T);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S;
  string ans = "";
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      ans += S[i];
    }
  }
  cout << ans <<  endl;
  return 0;
}

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

const int MAXN = 100000, MOD = 1000 * 1000 * 1000 + 7;
int cnt[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    if(n & 1) {
        for(int i = n - 1; i > 0; i -= 2) {
            if(cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        if(cnt[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
    }
    else {
        for(int i = n - 1; i >= 1; i -= 2) {
            if(cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    n /= 2;
    int ans = 1;
    for(int i = 1; i <= n; i++) {
        ans *= 2;
        if(ans >= MOD)
            ans -= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int n;
vi a(0);
bool isOK(int index,int key) {
    if ( a[index]>key )return true;
    else return false;
}
int binary_search(vector<int> l ,int i,int j){
  ll ng =-1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = j;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    
    if (isOK(mid, abs(a[i]-a[j]))) ok = mid;
    else ng = mid;
  }
  return ok ;
}

int main(){
  cin>>n;
  rep(i,n){int l;cin>>l;a.push_back(l);}
 
  bool ok= false;
  int k =1;
  for(int i=0;i<n;i++){
    if(a[i]==k){
      
      k++;
    }
  }
  if(k>1)cout<<n-k+1;
  else cout<<-1<<endl;
}
  


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m = s.size();

  constexpr int kMod = 1'000'000'000 + 7;
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (dp[i][j] == 0) continue;
      (dp[i + 1][max(j - 1, 0)] += dp[i][j]) >= kMod ? dp[i + 1][max(j - 1, 0)] -= kMod : 0;
      (dp[i + 1][j + 1] += 2 * dp[i][j] % kMod) >= kMod ? dp[i + 1][j + 1] -= kMod : 0;
    }
  }
  const int kInv = (kMod + 1) / 2;
  int res = dp[n][m];
  for (int i = 0; i < m; ++i) res = 1LL * res * kInv % kMod;
  cout << res << "\n";
}


Measured memory_bytes: 100096
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,i;
    while(scanf("%d",&a)!=EOF)
    {
       b=0;i=0;
       while(b<a)
       {
            b=b+i;
            i++;
       }
       printf("%d\n",i-1);
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 A, B;
  int K;
  cin >> A >> B >> K;

  for (int i = 0; i < K; ++i) {
    if (A & 1) { --A; }
    B += A/2;
    A -= A/2;
    swap(A,B);
  }

  if (K&1) swap(A,B);

  cout << A << ' ' << B << endl;

  return 0;
}



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

#define mx 200005
#define ll long long
int n, m, mm, tc=1;
bitset <mx> color;
vector <int> v[mx];

void bfs(int start)
{
    int cnt=0;
    queue <int> q;
    q.push(start);
    while(!q.empty()){
        ll x = q.front();
        q.pop();
        if(!color[x])
            cnt++;
        for(auto it : v[x]){
            if(!color[it]){
                q.push(it);
                cnt++;
                color[it]=1;
            }
        }
        color[x]=1;
    }
    mm = max(mm, cnt);
}

void solve(int kk)
{
    cin >> n >> m;
    for(int i=1, a, b; i<=m; i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1; i<=n; i++){
        if(!color[i])
            bfs(i);
    }
    cout << mm << "\n";
    
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("D:\\Codings\\CPP\\input.in", "r", stdin);
    freopen("D:\\Codings\\CPP\\output.in", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int kk = 0;
    //cin >> tc;
    //scanf("%d", &tc);
    while (++kk <= tc)
        solve(kk);

    return 0;
}

Measured memory_bytes: 14952
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    cin >> n;

    cout << (n+1)/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define N 110
#define INF 0x3f3f3f3f
int w[N][N];
int main(){


    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) w[i][j] = 0;
            else w[i][j] = INF;
        }
    }

    for(int i = 0; i < n; i++){
        int k;
        int a;
        scanf("%d %d", &a, &k);
        for(int j = 0; j < k; j++){
            int c, d;
            scanf("%d %d", &c, &d);
            w[a][c] = d;
        }
    }

    int d[n];
    int used[n];
    int p[n];
    for(int i = 0; i < n; i++){
        d[i] = w[0][i];
        used[i] = 0;
        p[i] = i;
    }
    d[0] = 0;
    used[0] = 1;

    for(int num = 1; num < n; num++){
        int min = INF;
        int mini = 0;
        for(int i = 1; i < n; i++){
            if(used[i] == 0 && d[i] < min){
                min = d[i];
                mini = i;
            }
        }

        used[mini] = 1;
        for(int i = 1; i < n; i++){
            if(d[mini] + w[mini][i] < d[i]){
                d[i] = d[mini] + w[mini][i];
                p[i] = mini;
            }
        }
    }

    for(int i = 0; i < n; i++){
        printf("%d %d\n", i, d[i]);
    }

    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s;
	cin >> s;
	int f1, f2;
	bool ok=true;
	rep(i,s.length()){
		if(s[i]=='A' && ok){
			ok=false;
			f1=i;
		}
		if(s[i]=='Z') f2=i;
	}
	cout << f2-f1+1 << endl;
	return 0;
}

Measured memory_bytes: 3764
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

map<int, int> factNum;

void fact(int n) {
    for(int i=2; i*i<=n; ++i) {
        while(n % i == 0) {
            factNum[i]++;
            n /= i;
        }
    }
    if(n != 1) {
        factNum[n]++;
    }
}

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

    if(N <= 2) {
        cout << N << endl;
        return 0;
    }
#if 1 
    for(int i=2; i <= N; ++i) {
        fact(i);
    }
#else
    fact(N);
#endif
    int64_t ret = 1;
    for(int i=1; i <= N; ++i) {
//        cout << i << " " << factNum[i] << endl;
        ret *= (factNum[i]+1);
        ret %= 1000000007;
    }
    cout << ret << endl;

    return 0;
}



Measured memory_bytes: 3180
h,w = list(map(int, input().split()))
s = [ list(input()) for _ in range(h)]
res = [ [0] * w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if(s[i][j] == "#"):
      res[i][j] = "#"
      for k in [-1,0,1]:
        for l in [-1,0,1]:
          if(0 <= i + k and i + k < h):
            if(0 <= j + l and j + l < w):
              if(res[i+k][j+l] != "#"):
                res[i+k][j+l] += 1
for i in range(h):
  print("".join(list(map(str, res[i]))))

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

int main() {
 char a;
 cin >> a;
 if (a == 'a') {
  cout << "vowel" << endl;
 } else if (a == 'e') {
  cout << "vowel" << endl;
 } else if (a == 'i') {
  cout << "vowel" << endl;
 } else if (a == 'o') {
  cout << "vowel" << endl;
 } else if (a == 'u') {
  cout << "vowel" << endl;
 } else {
  cout << "consonant" << endl;
 }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
  long x;
  readf("%d\n", &x);
  long[] xs = readln.strip.split(" ").map!(to!long).array;

  long[] ans = [];
  bool flag = false;
  foreach (i; 1..x+1) {
    flag = false;
    foreach_reverse (j; 0..xs.length) {
      if (j+1 == xs[j]) {
        ans ~= j+1;
        xs = xs[0..j] ~ xs[j+1..$];
        flag = true;
        break;
      }
    }
    if (!flag) {
      break;
    }
  }
  if (flag) {
    foreach_reverse(a; ans) {
      writeln(a);
    }
  } else {
    writeln(-1);
  }
}


Measured memory_bytes: 380
c = [list(map(int, input().split())) for i in range(3)]
a = [0]*3
b = [0]*3
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C, D;
    int counter = 0;
    cin >> A >> B >> C >> D;
    for(int i = A; i < B; i++){
        for(int j = C; j < D; j++){
            if(i == j){
                counter++;
            }
        }
    }
    
    cout << counter << endl;
    
}


Measured memory_bytes: 256
/**
 * File              : D-tutorial.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 15.03.2020
 * Last Modified Date: 16.03.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

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

ll cnt(ll n) {
    return n * (n - 1) / 2;
}

ll fneg(vector<ll> const & neg, vector<ll> const & pos, ll x) {
    ll cnt = 0;
    for (int i = 0, j = 0; i < (int)neg.size(); ++i) {
        for (;j < (int)pos.size() && neg[i] * pos[j] <= x; ++j);
        cnt+=j;
    }
    return cnt;
}

ll solveneg(vector<ll> const & a, ll k) {
    vector<ll> neg; 
    vector<ll> pos;
    for (int i = 0; i < (int)a.size(); ++i) {
        if (a[i] > 0LL) {
            pos.push_back(a[i]);
        } else if (a[i] < 0LL) {
            neg.push_back(a[i]);
        }
    }
    reverse(neg.begin(), neg.end());
    reverse(pos.begin(), pos.end());
    ll x = -1e18;
    for (ll b = 1e18; b >= 1; b >>= 1) {
        while (fneg(neg, pos, x + b) < k) x += b;
    }
    return x + 1;
}

ll fposs(vector<ll> const & neg, vector<ll> const & pos, ll x) {
    ll cnt = 0;
    for (ll i = neg.size() - 1, j = 0; i >= 0; --i) {
       for(;j < i && neg[i] * neg[j] <= x; ++j); 
       //cout << i << ' ' << j << endl;
       cnt += min(i, j);
    }
    for (int i = pos.size() - 1, j = 0; i >= 0; --i) {
       for(;j < i && pos[i] * pos[j] <= x; ++j); 
       cnt += min(j, i);
    }
    return cnt;
}

ll solvepos(vector<ll> const& a, ll k) {
    vector<ll> neg;
    vector<ll> pos;
    for (int i = 0; i < (int)a.size(); ++i) {
        if (a[i] > 0LL) {
            pos.push_back(a[i]);
        } else if (a[i] < 0LL) {
            neg.push_back(a[i]);
        }
    }
    reverse(neg.begin(), neg.end());
    ll x = 0;
    for (ll b = 1e18; b >= 1; b >>= 1) {
        while(fposs(neg, pos, x + b) < k) x += b;
    }
    return x + 1;
}



int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    ll cntn, cntz, cntp;
    cntn = cntz = cntp = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] > 0LL) {
            cntp++;
        } else if (a[i] < 0LL) {
            ++cntn;
        } else {
            ++cntz;
        }
    }
    sort(a.begin(), a.end());
    ll totz, totn, totp;
    totn = cntn*cntp;
    totz = cnt(cntz) + (cntz * (n - cntz));
    totp = cnt(cntn) + cnt(cntp); 

    if (k <= totn) {
        cout << solveneg(a, k);
    } else if (k <= totn + totz) {
        cout << 0;
    } else {
        cout << solvepos(a, k - totn - totz);
    }

    return 0;
}


Measured memory_bytes: 4084
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[X]*n
new = [abs(a-b) for (a,b) in zip(x,y)]
import fractions
if len(new) == 1:
    print(new[0])
elif len(new) ==2:
    print(fractions.gcd(new[0],new[1]))
else:
    gcd=fractions.gcd(new[0],new[1])
    for i in range(2,len(new)-1):
        gcd=fractions.gcd(gcd,new[i])
    print(gcd)


Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
const int inf = (int)1e9;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
 
 


 
int main(void){
	ll L,R,d;
	cin>>L>>R>>d;
	ll X = R/d;
	ll Y = (L-1)/d;
	cout<<X-Y<<endl;
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int>v(n);
    for (auto &i : v) {
        cin >> i;
    }
    sort(all(v));
    ll ans = 0;
    for (int i = 0 ; i < n ; i++) {
        for (int j = i + 1 ; j < n ; j++) {
            ans += lower_bound(all(v), v[i] + v[j]) - v.begin() - j - 1;
        }
    }
    cout << ans << '\n';
}

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

int main(void){
    int a, b, x; cin >> a >> b >> x;
  if(a <= x && x <= a+b) cout << "YES" << endl;
  else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 100010;
const int INF = INT_MAX/2;

int n;
vector <pi> v;
int pre[maxn],suf[maxn];

int dist(int x, int y) {
	return max(y - x + 1,0ll);
}

int32_t main() {
	cin >> n;
	v.push_back(pi(0,0));
	for (int i =1;i<=n;i++) {
		int a,b; cin >> a >> b;
		v.push_back(pi(a,b));
	}
	sort(all(v));
	
	//CASE 1: All .f of group 1 < All .f of group 2
	//prefix[i] from 1 to i
	int maxl=0, minr=INF;
	
	for (int i = 1;i<=n;i++) {
		maxl = max(maxl,v[i].f); 
		minr = min(minr,v[i].s);
		
		pre[i] = dist(maxl,minr);
	}
	int whack = pre[n];
	
	//Suffix[i] from n to i+1
	maxl = 0; minr = INF;
	for (int i =n-1;i>=1;i--) {
		maxl = max(maxl,v[i+1].f);
		minr = min(minr,v[i+1].s);
		
		suf[i] = dist(maxl,minr);
	}
	int ans = 0;
	for (int i =1;i<n;i++) {
		ans = max(ans, pre[i] + suf[i]);
	}
	
	//CASE 2: Just take largest guy for group 1 and throw the rest into group 2.
	
	for (int i =1;i<=n;i++) {
		ans = max(ans, whack + dist(v[i].f,v[i].s));
	}
	cout << ans;
}








Measured memory_bytes: 3440
from itertools import permutations as pmt
 
N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
 
a,b = None,None
i = 0
for od in pmt([i+1 for i in range(N)]):
    order = list(od)
    if P == order:
        a = i
    if Q == order:
        b = i
    i += 1
print(abs(a-b))

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A.begin(), A.end());
  int b = A[N/2];
  long long ans = 0;
  for(int i = 0; i < N; i++){
    ans += abs(A[i] - b);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
ll d,t,s;
int main(void){
	cin>>d>>t>>s;
	if(t*s>=d)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

queue<int> q1;
int parent[100005];
int num[100005];

int check_parent(int x){
	if(parent[x]!=-1)return check_parent(parent[x]);
	int a;
	while(!q1.empty()){
		a=q1.front(),q1.pop();
		parent[a]=x;
	}
	return x;
}

void connect(int x,int y){
	x=check_parent(x),y=check_parent(y);
	if(x==y)return;
	if(num[x]>num[y])swap(x,y);
	parent[x]=y;
	num[y]+=num[x];
}

int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	cin>>n>>m;
	memset(parent,-1,sizeof(parent));
	for(i=0;i<n;i++)num[i]=1;
	for(i=0;i<m;i++){
		cin>>a>>b>>c;
		a--,b--;
		connect(a,b);
	}
	for(i=0;i<n;i++){
		if(parent[i]==-1)s++;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 1024
l,r = list(map(int,input().split()))
if r-l >= 2019:
  print(0)
  exit()
l = l % 2019
r = r % 2019
l = min(l,r)
r = max(l,r)
ans = []
if r == l:
  print(0)
  exit()
for i in range(l,r+1):
  for j in range(i,r+1):
    if i != j:
      ans += [(i * j) %2019]
      
print(min(ans))


Measured memory_bytes: 75416
import java.io.*;
import java.util.*;
 class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length-1;
        long sum = 0;
        for(int i = 0; i <(1<<n);i++){
            int num = i;
            int k =1;
            int start = 0;
            while(num>0){
                int j = num%2;
                if(j==1){
                    sum+=toInt(s,start,k);
                    start = k;
                    k++;
                }
                else{
                    k++;
                }
                num/=2;
            }
            sum+=toInt(s,start,s.length);
        }
        System.out.println(sum);
    }
    public static long toInt(char[] s,int lo,int hi){
        long num =0;
        for(int i = lo; i < hi ; i++){
            num	= num*10+s[i]-'0';
        }
        return num;
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<math.h>
main(){
  int t,y,h,n,i=0,r,temp,a[10010];
  while(1){
    scanf("%d %d %d",&t,&y,&h);
    if(t==0 && y==0 && h==0){
      break;
    }
    scanf("%d",&n);
    if(y<t){
      temp=t;
      t=y;
      y=temp;
    }
    if(h<y){
      temp=h;
      h=y;
      y=temp;
    }
    if(y<t){
      temp=t;
      t=y;
      y=temp;
    }
    for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    r=sqrt(t*t+y*y)/2;
    if(a[i]<=r){
      printf("NA\n");
    }
    else{
      printf("OK\n");
    }
    r=0;
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }

char s[210];
char t[110];
int main()
{
  scanf("%s%s", s, t);
  ll n = strlen(s);
  // rep(i, 0, n) #fix:1
  for (int i = 0; i < n; i++)
  {
    if (!strcmp(s + i, t))
    {
      puts("Yes");
      return 0;
    }
    s[n + i] = s[i];
  }
  puts("No");
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int h1,h2,m1,m2,k;
int tot;
int main()
{
	cin>>h1>>m1>>h2>>m2>>k;
	tot=(h2-h1)*60+m2-m1;
	cout<<tot-k;
	return 0;
}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

int n, m;

list<int> edge[MAX_N + INDEX];

int v;

bool isUsed[MAX_N + INDEX];

list<int> ans;

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

    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        int a, b;

        cin >> a >> b;

        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    ans.push_back(1);

    isUsed[1] = true;

    v = 1;
    while (true) {
        bool isBreak = true;

        for (auto u: edge[v]) {
            if (!isUsed[u]) {
                ans.push_back(u);

                isUsed[u] = true;

                v = u;

                isBreak = false;

                break;
            }
        }

        if (isBreak) {
            break;
        }
    }

    v = 1;
    while (true) {
        bool isBreak = true;

        for (auto u: edge[v]) {
            if (!isUsed[u]) {
                ans.push_front(u);

                isUsed[u] = true;

                v = u;

                isBreak = false;

                break;
            }
        }

        if (isBreak) {
            break;
        }
    }

    cout << ans.size() << endl;

    bool isFirst = true;
    for (auto v: ans) {
        if (!isFirst) {
            cout << ' ';
        }

        isFirst = false;

        cout << v;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	sort(v.begin(), v.end());
	int q = 100001;
	int ans = 1;
	for(auto p : v){
		if(p.first >= q){
			ans++;
			q = p.second;
		}
		else{
			q = min(p.second, q);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

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

long long modpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = (ret * x) % MOD;  
        x = (x * x) % MOD;
        n >>= 1;  
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<pll> ab(n);
    rep(i,n){
        cin >> ab[i].first >> ab[i].second;
        ll g = gcd(ab[i].first,ab[i].second);
        if(g == 0LL) continue;
        ab[i].first /= g;
        ab[i].second /= g;
        if(ab[i].second < 0 || (ab[i].second == 0 && ab[i].first > 0)){
            ab[i].first = - ab[i].first;
            ab[i].second = - ab[i].second;
        }
    }

    map<pll,pll> mp; // (a,b) (a,-b) 
    ll cnt = 0;

    rep(i,n){
        if(ab[i].first == 0 && ab[i].second == 0){
            ++ cnt;
            continue;
        }

        if(ab[i].first < 0){
            mp[pll(ab[i].second,-ab[i].first)].second ++;
        }else{
            mp[ab[i]].first ++;
        }
    }

    ll ans = 1;

    for(auto p:mp){
        ans = (ans * (modpow(2,p.second.first) + modpow(2,p.second.second) - 1LL))%MOD;
        //cout << p.second.first <<"  "<< p.second.second << endl;
    }

    cout << (ans + cnt - 1LL + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 21928
#include<iostream>
using namespace std;
int main(){
  int k,a,b;
  cin>>k;
  cin>>a>>b;
  int flag = 0;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      flag = 1;
      break;
    }
  }
  if(flag)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;
  return 0;
  
}
  

Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B, K;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3636