akhauriyash/Code-Regression huggingface dataset:
/* ex 5_4
   sachiyan */

#include <stdio.h>

int main(void){
    int i;
    //ATCG配列の一時的な長さを宣言
    int len = 0;
    //ATCG配列の最大の長さを宣言
    int maxlen = 0;
    //文字列とポインタを宣言
    char sequence[11], *ptr;

    //文字列をよみとる
    scanf("%s", &sequence[0]);
    
    //ポインタを文字列の最初にする
    ptr = &sequence[0];
    
    //ポインタを動かしてACGT文字列をさがす
    while(*ptr != '\0'){
        while(*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T' ){
            ptr++;
            len++;
        }
        //最長のATCG文字列があればmaxを更新する
        if(len >= maxlen){
            maxlen = len;
        }
        //lenの初期化
        len = 0;
        ptr++;
    }
    //出力する
    printf("%d\n", maxlen);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}
int main(){
  ll A,B,C,D,i,ans = 1;scanf("%lld%lld",&A,&B);
  C = gcd(A,B);D = C;
  for(i=2;i*i<=C;i++){
    if(D%i==0){
      ans++;
      while(D%i==0) D /= i;
    }
  }
  if(D != 1) ans++;
  printf("%lld\n",ans);
}

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

using namespace std;

int ans = 0x3f3f3f3f;
int h, w, k;
char grid[12][1002];

void try_cut(const vector<int> &c) {
    int cut = 0;
    vector<int> block(c.size()+1, 0);
    vector<int> nblock(c.size()+1, 0);
    for (int i = 0; i < w; i++) {
        int p = 0;
        bool should_cut_here = false;
        for (int j = 0; j < h; j++) {
            if (j > c[p]) p++;
            if (grid[j][i] == '1') {
                nblock[p] += 1;
            }
            if (nblock[p] + block[p] > k) {
                should_cut_here = true;
            }
        }
        if (should_cut_here) {
            cut++;
            // printf("%d ", i);
            block = nblock;
        } else {
            for (int i = 0; i < block.size(); i++) {
                block[i] += nblock[i];
            }
        }
        for (auto v : block) {
            if (v > k) return;
        }
        nblock = vector<int>(c.size()+1, 0);
    }
    // puts("");
    // for (int v : c) {
    //     printf("%d ", v);
    // }
    // puts("");
    // printf("%d\n-------------\n", cut+c.size()-1);
    ans = min(ans, int(cut+c.size()-1));
}

void dfs(vector<int> &v, int cur) {
    if (cur == h-1) {
        v.push_back(20);
        try_cut(v);
        v.pop_back();
        return;
    }
    dfs(v, cur+1);
    v.push_back(cur);
    dfs(v, cur+1);
    v.pop_back();
}

int main() {
    // freopen("E.in", "r", stdin);
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0; i < h; i++) scanf("%s", &grid[i]);
    vector<int> vs;
    dfs(vs, 0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main()
{
    long unit = pow(10, 9) + 7;
    long n;
    std::cin >> n;
    long power = 1;
    for(long i = 1; i <= n; i++){
        power = power * i;
        power = power % unit;
    }
    std::cout << power << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;	
const int N=5005;
int n;
string s;
int p[N];
int hashh[N];

int f(int a)
{
//	cout<< a << " STARTT " <<endl;
	for (int i = 1; i < n; ++i)
	for (int j = i+a; j <= n-a+1; ++j)
	{
//		cout << i << " " << j << " " << (hashh[i+a-1]-hashh[i-1])*p[j-i]<< " " <<  (hashh[j+a-1]-hashh[j-1]) << endl; 
		if((hashh[i+a-1]-hashh[i-1])*p[j-i] == (hashh[j+a-1]-hashh[j-1]))
		{
			int fl=1;
			for (int t = 0; t < a; ++t)
				if(s[i+t]!=s[j+t])
					fl=0;
			if(!fl) continue;
			return 1;
		}
	}
	return 0;
}
int main(){
	cin >> n >> s;
	s=' '+s;
	p[0]=1;
	for (int i = 1; i < N; ++i)
		p[i]=p[i-1]*37;
	hashh[0]=1;
	for (int i = 1; i < s.size(); ++i)
	{
		hashh[i]=hashh[i-1]+(s[i]-'a'+1)*p[i];
//		cout << (s[i]-'a'+1)<< " " << " " << p[i]<< " "<<hashh[i] << " ";
	}
	int a=0,b=n;
	while(a<b)
	{
		int orta=(a+b+1)/2;
		if(f(orta))
			a=orta;
		else b=orta-1;
	}
	cout << a;
}

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

#define INF 9999999
#define NIL 0
#define N 100

int prim(int n,int w[N][N],int r){
  int d[n];
  int pi[n];
  char color[n];
  int i,v,u,maincost;
  int num=0;

  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]='W';
  }
  d[r]=0;
  while(1){
    maincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!='B'&&d[i]<maincost){
	maincost=d[i];
	u=i;
      }
    }
    if(maincost==INF) break;
    color[u]='B';
    for(v=0;v<n;v++){
      if(color[v]!='B'&&w[u][v]<d[v]&&w[u][v]!=-1){
	pi[v]=u;
	d[v]=w[u][v];
      }
    }
  }
  
  for(i=0;i<n;i++){
    num+=d[i];
  }
  return num;
}
int main(){
  int n;
  int a[N][N];
  int num;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  printf("%d\n",prim(n,a,0));
  return 0;
}




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

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

  x = x + x;

  int a = x.find(y);

  if (a == -1) cout << "No" << endl;
  else  cout << "Yes" << endl;

  return 0;
}

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

int lt(int ok, int ng, int key, vector<int> a){
  while(abs(ok-ng)>1){
    int mid = (ok+ng)/2;
    if(a[mid]<key) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    // long long cnta = lt(-1,n,b[i],a) + 1;
    long long cnta = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
    long long cntc = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    ans+=cnta*cntc;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 1408
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int col, ans[510][510];

void solve(vector<int> vec) {
    int M = vec.size();
    if(M == 1) return;
    vector<int> v1, v2;
    {
        int s1 = M / 2, s2 = M - s1;
        for(int i=0; i<s1; i++) v1.emplace_back(vec[i]);
        for(int i=0; i<s2; i++) v2.emplace_back(vec[s1 + i]);
    }
    
    queue< pair< vector<int>, vector<int> > > que;
    que.emplace(v1, v2);
    while(true) {
        queue< pair< vector<int>, vector<int> > > nxt;
        col++;
        while(que.size()) {
            vector<int> p1, p2; tie(p1, p2) = que.front(); que.pop();
            {
                int s1 = p1.size(), s2 = p2.size();
                // fprintf(stderr, "!s1 = %d, s2 = %d\n", s1, s2);
                for(int i=0; i<s1; i++) {
                    for(int j=0; j<s2; j++) {
                        int u = p1[i], v = p2[j];
                        if(u > v) swap(u, v);
                        ans[u][v] = col;
                        // fprintf(stderr, "col = %d, u = %d, v = %d\n", col, u, v);
                    }
                }
            }

            // cerr << p1.size() << " " << p2.size() << endl;
            if(p1.size() > 1) {
                int s1 = p1.size() / 2, s2 = p1.size() - s1;
                vector<int> n1, n2;
                for(int i=0; i<s1; i++) n1.emplace_back(p1[i]);
                for(int i=0; i<s2; i++) n2.emplace_back(p1[s1 + i]);
                nxt.emplace(n1, n2);
            }
            if(p2.size() > 1) {
                int s1 = p2.size() / 2, s2 = p2.size() - s1;
                // fprintf(stderr, "s1 = %d, s2 = %d\n", s1, s2);
                vector<int> n1, n2;
                for(int i=0; i<s1; i++) n1.emplace_back(p2[i]);
                for(int i=0; i<s2; i++) n2.emplace_back(p2[s1 + i]);
                nxt.emplace(n1, n2);
            }
        }
        if(nxt.size() == 0) break;
        swap(que, nxt);
    }
}

int main() {
    int N; cin >> N;
    vector<int> vec;
    for(int i=1; i<=N; i++) vec.emplace_back(i-1);

    solve(vec);
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            cout << ans[i][j] << " \n"[j + 1 == N];
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define lli long long int


int main () {
	lli a,h,n,w;
	lli i,j,k;
	cin >> a;

	for(i=a/4;i<=3500;i++){
		for(j = i;j<=3500;j++){
			h=i;
			n=j;
			w = 4*h*n-a*n-a*h;
			if (w>0&&0==a*h*n%w){
				w = a*h*n/w;
				printf("%lld %lld %lld\n",h,n,w );
				return 0;
			}
			
					
			
		}
	}
	

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  set<ll> s;
  ll ans = 0;
  map<ll, ll> m;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (s.find(A[i] + i) == s.end()) {
      s.insert(A[i] + i);
      m[A[i] + i] = 1;
    } else {
      m[A[i] + i]++;
    }
    if (s.find(i - A[i]) != s.end()) {
      ans += m[i - A[i]];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 26548
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

typedef pair<int, int> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second > secondElof.second;
}

signed main(void)
{
	int n;
	cin >> n;
	vector<P> odd;
	vector<P>even;

	rep(i, n) {
		int input;
		cin >> input;
		bool flag = true;
		if (i % 2 == 0) {
			rep(j, even.size()) {
				if (even[j].first == input) {
					flag = false;
					even[j].second++;
				}
			}
			if (flag) {
				even.pb(P(input, 1));
			}
		}
		else {
			rep(j, odd.size()) {
				if (odd[j].first == input) {
					flag = false;
					odd[j].second++;
				}
			}
			if (flag) {
				odd.pb(P(input, 1));
			}
		}
	}
	sort(even.begin(), even.end(), pairCompare);
	sort(odd.begin(), odd.end(), pairCompare);

	if (even[0].first == odd[0].first) {
		if (even.size() == 1 && odd.size() == 1) {
			print(n / 2);
		}
		else {
			int sub = max((even[0].second + odd[1].second), (odd[0].second + even[1].second));
			print(n - sub);
		}
	}
	else {
		print(n - odd[0].second - even[0].second);
	}
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int d[100010];
int main(void){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;scanf("%d%d",&a,&b);
		d[--a]++;d[--b]++;
	}
	for(int i=0;i<n;i++){
		if(d[i]%2!=0){
			printf("NO");return 0;
		}
	}
	printf("YES");return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;
string s;
ll a;

int main(){
       cin >> n;
       int aa=0,bb=0;
       for(int i = 0; i < n; i++){
              cin >> a;
              if(a % 2 == 0)       ++aa;
              else   ++bb;
       }


       if(bb > 0)  cout << "first\n";
       else cout << "second\n";
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll n, c, k; cin >> n >> c >> k;
  vll t(n); rep(i, n) cin >> t[i];
  sort(all(t));
  ll ans = 0;
  ll flag;
  for(ll i = 0;i < n;i++)
  {
    flag = t[i];
    ll human = 1;
    for(i++;i < n&&human < c&&t[i] <= flag + k;i++)
    {
      human++;
    }
    i--;
    ans++;
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main()
{
    speed upp
    int n,x=0,y=0,z=0;
    cin>>n;
    x=n/500;
    y=n%500;
    z=y/5;
    cout<<x*1000 + 5*z;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<set>
#include<map>
using namespace std;

int main() {
	int n, a[251] = {};
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n;i++) {
		cout << "node " << i  << ": key = " << a[i];
		if (i / 2 > 0) cout << ", parent key = " << a[i / 2];
		if (i * 2 <= n) cout << ", left key = " << a[2 * i];
		if (i * 2 + 1 <= n) cout << ", right key = " << a[2 * i + 1];
		cout << ", " << endl;
	}
}



Measured memory_bytes: 3084
//悪い集中とはじっと考えることだと思ったので、じっと考えないでできる考察「N = 2」「Max, Minに注目」をしました。
//本質はN-1回の操作で{a_i >= 0, all i} または {a_i <= 0, all i}にできることで、あとはN = 2の戦略を繰り返すだけ。

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;
typedef pair<int, int> P;

int n;
int a[50];
vector<P> ans;

void solve1() {
	for (int i = 0; i < n - 1; i++) {
		if (a[i] > a[i + 1]) {
			a[i + 1] += a[i];
			ans.push_back(P(i, i + 1));
		}
	}
}

void solve2() {
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] > a[i + 1]) {
			a[i] += a[i + 1];
			ans.push_back(P(i + 1, i));
		}
	}
}

void addMax() {
	int i, id = 0;
	
	for (i = 1; i < n; i++) {
		if (a[id] < a[i]) id = i;
	}
	
	for (i = 0; i < n; i++) {
		if (i == id) continue;
		a[i] += a[id];
		ans.push_back(P(id, i));
	}
}

void addMin() {
	int i, id = 0;
	
	for (i = 1; i < n; i++) {
		if (a[id] > a[i]) id = i;
	}
	
	for (i = 0; i < n; i++) {
		if (i == id) continue;
		a[i] += a[id];
		ans.push_back(P(id, i));
	}
}

signed main()
{
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int Max = a[0];
	int Min = a[0];
	for (i = 1; i < n; i++) {
		if (Max < a[i]) Max = a[i];
		if (Min > a[i]) Min = a[i];
	}
	
	if (Min >= 0) { solve1(); }
	else if (Max <= 0) { solve2(); }
	else if (Max >= -Min) { addMax(); solve1(); }
	else { addMin(); solve2(); }
	
	cout << ans.size() << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
	}
	
	/*cout << "debug" << endl;
	for (i = 0; i < n; i++) {
		cout << a[i] << endl;
	}*/
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=2e5+20;
const int inf=0x3f3f3f3f;

struct Edge {
	int u,v,w;
};
Edge E[maxn<<1];
int m;

int f[maxn];

int n,q;

inline void init()
{
	n=read();q=read();
	memset(f,inf,sizeof(f));
	REP(i,1,q)
	{
		int u=read(),v=read(),c=read();
		E[++m]=(Edge){u,v,c};
		chkmin(f[u],c+1);
		chkmin(f[v],c+2);
	}
	REP(i,0,n-1)chkmin(f[i+1<n?i+1:0],f[i]+2);
	REP(i,0,n-1)chkmin(f[i+1<n?i+1:0],f[i]+2);
	REP(i,0,n-1)E[++m]=(Edge){i,i+1<n?i+1:0,f[i]};
}

inline bool cmp(Edge a,Edge b){ return a.w<b.w;}
int fa[maxn];
int fin(int x){ return x==fa[x]?x:fa[x]=fin(fa[x]);}
inline void merge(int x,int y){ x=fin(x);y=fin(y); fa[y]=x;}

inline void doing()
{
	REP(i,1,n)fa[i]=i;
	sort(E+1,E+m+1,cmp);
	ll ans=0;
	REP(i,1,m)
	{
		int u=E[i].u,v=E[i].v;
		if(fin(u)==fin(v))continue;
		merge(u,v);
		ans+=E[i].w;
	}
	printf("%lld\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



Measured memory_bytes: 6528
#include<cstdio>

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	
	int ans = a+b;
	if (a-b>ans) ans = a-b;
	if (a*b>ans) ans = a*b;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
n, m = map(int,input().split())
result = []
for _ in range(m):
    a, b = input().split()
    a = int(a)
    result.append([a, b])
problems = [0] * (n+1)
ac = 0
wa = 0
for i in range(m):
    if problems[result[i][0]-1] != -1:
        if result[i][1] == "AC":
            ac += 1
            wa += problems[result[i][0]-1]
            problems[result[i][0]-1] = -1
        else:
            problems[result[i][0]-1] += 1

print(ac, wa)

Measured memory_bytes: 22692
#include<cstdio>
using namespace std;
const int maxn=2e5+5;
int n,m,x,a[maxn],Q[maxn],vis[maxn];long long K;
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline long long read(){
	long long ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
int main(){
	n=read(),K=read()+1;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1,j=1;;i=a[i],j++)
	if(!vis[i]) vis[i]=j,Q[j]=i;
	else{x=i,m=j-vis[i];break;}
	if(K>vis[x]) K=(K-vis[x])%m+vis[x];
	printf("%d\n",Q[K]);
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    int ans = max({A+B, A-B, A*B});
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
*P, = map(float, readline().split())
*Q, = map(float, readline().split())

K = [[None]*(N+1) for i in range(N+1)]
C = [[None]*(N+1) for i in range(N+1)]
S = [0]*(2*N+2)
for i in range(2*N+1):
    S[i+1] = S[i] + (P[i//2] if i % 2 else Q[i//2])

for i in range(N+1):
    C[i][i] = Q[i]
    K[i][i] = i

for l in range(1, N+1):
    for i in range(N+1-l):
        j = i+l
        k0 = K[i][j-1]; k1 = K[i+1][j]
        tmp = 1e30
        k2 = None
        for k in range(k0, min(k1+1, j)):
            v = C[i][k] + C[k+1][j]
            if v < tmp:
                k2 = k
                tmp = v
        K[i][j] = k2
        C[i][j] = tmp + (S[2*j+1] - S[2*i])
write("%.10f\n" % C[0][N])


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  double N;
  string S;
  cin >> N;

  cout << N * 2*3.1415926 << endl;
}


Measured memory_bytes: 3840
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    for(int i = 0; i < n; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      for(int j = l; l <= r; l++) {
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 25292
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := ""
	a = sc.NextLine()
	b := ""
	b = sc.NextLine()

	if a == b {
		fmt.Printf("EQUAL\n")
		return
	}

	if len(a) > len(b) {
		fmt.Printf("GREATER\n")
		return
	} else if len(a) < len(b) {
		fmt.Printf("LESS\n")
		return
	}
	if a > b {
		fmt.Printf("GREATER\n")
	} else {
		fmt.Printf("LESS\n")
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ll K, A, B; cin >> K >> A >> B;

    if(K <= A) {
        cout << 1 << endl;
        return 0;
    }
    ll sub = A - B;
    if(A - B <= 0) dame
    ll cnt =  1LL +  (K - A + sub - 1LL) / sub * 2LL;
    cout << cnt << endl;
    return 0;



}



Measured memory_bytes: 256
# C Peaks

N, M = map(int, input().split())
H = list(map(int, input().split()))

goods = [0] * N
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] > H[b-1]:
    goods[b-1] = 1
  elif H[a-1] < H[b-1]:
    goods[a-1] = 1
  elif H[a-1] == H[b-1]:
    goods[a-1] = 1
    goods[b-1] = 1

print(goods.count(0))

Measured memory_bytes: 20100
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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 (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


lint D;
lint decrease[26];
lint satis[365][26];
lint prv[26];

lint downscore(lint passed) {
	lint sum = 0;
	REP(i, 26) {
		sum += decrease[i] * (passed - prv[i]);
	}
	return -sum;
}

int main() {
	cin >> D;
	REP(i, 26) {
		cin >> decrease[i];
	}
	REP(i, D) {
		REP(j, 26) {
			cin >> satis[i][j];
		}
	}

	REP(i, D) {
		lint maxv = -INF, max_idx = 0;
		REP(s, 26) {
			lint inst = 0;
			inst += satis[i][s];
			inst += downscore(i + 1);
			chmax(inst, 0ll);
			if (maxv < inst) {
				maxv = inst;
				max_idx = s;
			}
		}
		prv[max_idx] = i + 1;
		cout << max_idx + 1;
		if (i != D - 1) cout << "\n";
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = a; i <= b; ++i) {
        string s = to_string(i);
        string rev = s;
        reverse(all(s));
        if(rev == s) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N= int(input())
n=[]
j=9
c=0
while N!=0:
    n.append(N%10)
    N//=10
n.reverse()

for i in range(len(n)):
    if n[i-1]==j:
        c+=1

if c > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
# coding: utf-8
while True:
    # a, bの入力
    a, b = map(int, input().split())
    # 終了処理
    if a == 0 and b == 0:
        exit()
    # nおよび工事中の交差点の入力
    n = int(input())
    const = [list(map(int, input().split())) for i in range(n)]
    # 各座標の到達可能経路数をメモする
    memo =[[0, 1] + [0] * (a - 1)] + [[0] + [-1] * a for i in range(b)]
    # 初期位置合わせのための処理
    memo[0][1] = 1
    # 工事中の交差点に行く経路数は0
    for inter in const:
        memo[inter[1]][inter[0]] = 0
    for i in range(1, b + 1):
        for j in range(1, a + 1):
            # 工事中でない場合、その交差点に行く経路数はその西の交差点と南の交差点の経路数の和
            if memo[i][j] == -1:
                memo[i][j] = memo[i - 1][j] + memo[i][j - 1]
    # 交差点(a, b)に行く経路数が求める答えである
    print(memo[b][a])


Measured memory_bytes: 5600
#include<stdio.h> 
#include<stdlib.h> 
#include<string.h> 
  
int main() 
{ 
	char a[100]; 
	int i,len;  
	static int b[52]; 
	int num; 	
	scanf("%s",a); 
	len=strlen(a); 
	for(i=0;i<len;i++) 
	{ 
		if(a[i]<='Z'&&a[i]>='A') 
		{ 
			num=a[i]-65; 
			b[num]++; 
		} 
		if(a[i]<='z'&&a[i]>='a') 
		{ 
			num=a[i]-97+26; 
			b[num]++; 
		} 
	} 
	for(i=0;i<52;i++) 
	{ 
		if(b[i]>=2) 
		{ 
			printf("no"); 
			break; 
		} 
	} 
	if(i==52) 
	{ 
		printf("yes"); 
	}  
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CRepsept {
public:
    ll binpow(ll a,ll b,ll mod){
        ll ret=1;
        while(b>0){
            if(b&1){
                ret=ret*a%mod;
            }
            a=a*a%mod;
            b=b>>1;
        }
        return ret;
    }
	void solve(std::istream& in, std::ostream& out) {
	    ll k;
	    in >> k;
	    ll ans=-1;
        ll m=7%k;
        for(ll i=1;i<999999;i++){
//            out <<m << endl;
            if(m==0){
                ans=i;
                break;
            }else{
                m=((7%k)*(binpow(10,i,k)%k)+m)%k;
            }
        }
        out <<ans << endl;
	}
};


int main() {
	CRepsept solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3568
N,M = map(int, input().split())
edge= [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

result = []

import copy
def dfs(n,used,d):
    if d == N-1:
        result.append(1)
    for e in edge[n]:
        if used[e] == False:
            usedf = copy.deepcopy(used)
            usedf[e] = True
            dfs(e,usedf,d+1)


used = [False]*(N+1)
used[1] = True
dfs(1,used,0)
print(len(result))


Measured memory_bytes: 48088
#include<stdio.h>
using namespace std;

const int MAX = 100000;

int parent(int table[], int child) {
	if (table[child] == -1)return child;
	return table[child] = parent(table, table[child]);
}

int main() {
	int n, m, q;
	int table[MAX];

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)table[i] = -1;
	for (int i = 0; i < m; i++) {
		int s, t;
		scanf("%d %d", &s, &t);
		
		int ps = parent(table, s);
		int pt = parent(table, t);
		if (ps != pt) {
			table[ps] = pt;
		}
	}

	scanf("%d", &q);

	for (int i = 0; i < q; i++) {
		int s, t;
		
		scanf("%d %d", &s, &t);

		int ps = parent(table, s);
		int pt = parent(table, t);

		if (ps == pt) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}
	return 0;
}

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

int main() 
{
    int A,B,T;
    cin >> A >> B >> T;
    int count = 0;

    for( int i=1 ; i<=T ; i++ )
    {
        if( 0 == (i%A) ) count += B;
    }


    cout << count << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b,c=0;
    cin>>k;

    cin>>a>>b;

        for(int j=a;j<=b;j++)
        {
            if(j%k==0)
            {
                c++;
               // break;
            }


        }
        if(c>0)
        {
            cout<<"OK"<<endl;

        }
        else
        {
            cout<<"NG"<<endl;
        }

}


Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const int MAX_N = 50;

int main(void){
    int N;
    int answer = 1e9 + 1;
    int x[MAX_N], y[MAX_N];
    
    cin >> N;
    
    if (N == 1){
        cout << 1 << endl;
        return 0;
    }

    rep(i, N){
        cin >> x[i] >> y[i];
    }

    map<pair<int, int>, int> cnt;

    rep(i, N - 1){
        For(j, i + 1, N){
            int dfx1 = x[i] - x[j];
            int dfx2 = x[j] - x[i];
            int dfy1 = y[i] - y[j];
            int dfy2 = y[j] - y[i];
            cnt[{dfx1, dfy1}] = 0;
            cnt[{dfx2, dfy2}] = 0;
        }
    }

    rep(i, N - 1){
        For(j, i + 1, N){
            int dfx1 = x[i] - x[j];
            int dfx2 = x[j] - x[i];
            int dfy1 = y[i] - y[j];
            int dfy2 = y[j] - y[i];
            cnt[{dfx1, dfy1}] ++;
            cnt[{dfx2, dfy2}] ++;
        }
    }

    for(auto& kv: cnt){
        answer = min(N - kv.second, answer);
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
while(1):
    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break

    count = 0
    for i in range(1, n-1):
        if i*3 >= x:
            break
        for j in range(i+1, n):
            if i+2*j >= x:
                break
            if x-i-j <= n:
                count += 1

    print(count)

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

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

using namespace std;

using ll = long long;

using P = pair<int,int>;



int main() {
ll n,k ;
cin >>n >>k;
ll ans=0 ;
for(ll i=k;i<n+2 ;i++){
ans+=(n-i+1)*i+1 ;
}
ll ama= ans%1000000007   ; 
cout <<ama <<endl;    
    return 0;

}

  

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner	sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int ans = x;
		for(int i = 0 ; i < n ; i++) {
			int cnt = 0;
			if(d % a[i] == 0) cnt = d / a[i];
			else cnt = (d + a[i]) / a[i];
			ans += cnt;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  string s;
  cin >> s;
  rep(i, 3) cout << s[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3600
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll gcd(ll x, ll y){
  if(x > y)return gcd(y, x);
  if(x == 0)return y;
  return gcd(y % x, x);
}

int main(int argc, char const* argv[])
{
  ll x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
	return 0;
}



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

int n, cnt;

int f(int p) {
	int c;
	for(c=0; p; c++, p/=10);
	return c%2;
}

int main() {
	cin>>n;
	for(int i=1; i<=n; i++) cnt += f(i);
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int n, i, f_count = 0, s_count = 0;

    for(i = 0; i < 3; i++){
        scanf("%d", &n);

        if(n == 5){
            f_count++;
        }

        if(n == 7){
            s_count++;
        }
    }

    if(f_count ==2 && s_count == 1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}


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

int main() {
  int m, d;
  cin >> m >> d;
  int a, b;
  long long int ans = 0;
  rep(i,m+1,1){
    rep(j,d+1,1){
      a = j / 10;
      b = j % 10;
      if(i == a*b && a > 1 && b > 1) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

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

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N, 0);
  vl AC(N, 0);
  REP(i, M) {
    string s;
    ll p;
    cin >> p >> s;
    p--;
    if (AC[p] == 0) {
      if (s == "WA")
        A[p]++;
      else
        AC[p] = 1;
    }
  }
  ll a = 0, b = 0;
  REP(i, N) {
    a += AC[i];
    if (AC[i] == 1)
      b += A[i];
  }
  cout << a << " " << b << endl;

  return 0;
}


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

int main() {
    int a, b, c;
    int ans = 0;

    cin >> a >> b >> c;

    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll> T;

ll i,j,k;


int main(){
   ll K,A,B;
   cin>>K>>A>>B;
   bool jud=false;
   for(int i=A;i<=B;i++)if(i%K==0)jud=true;
   if(jud)cout<<"OK"<<endl;
   else cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
line = input().split()
a = 0
for i in line:
	a += int(i)
if a == 17 and ((line[0] == "5" and line[1] == "5") or (line[0] == "5" and line[2] == "5") or (line[1] == "5" and line[2] =="5" )):
	print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
import heapq

k = int(input())
n = 50
div = k//50
mod = k%50

ans = [div+n-1 for i in range(n)]
heapq.heapify(ans)

for i in range(mod):
    Min = heapq.heappop(ans)
    for j in range(n-1):
        ans[j] -= 1
    heapq.heappush(ans,Min+50)

print(n)
print(*ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
signed main(){
    int N,M;
    cin>>N>>M;
    P p[100001];
    for(int i=0;i<N;i++){
        cin>>p[i].F>>p[i].S;
    }
    sort(p,p+N);
    int ans=0;
    for(int i=0;i<N;i++){
        if(M>=p[i].S){
            M-=p[i].S;
            ans+=p[i].F*p[i].S;
            if(M==0) break;
        }
        else {
            ans+=p[i].F*M;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b==c&&a==c){
		printf("No\n");	
	}		
	else if(a!=b&&b!=c&&a!=c){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1596
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

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

    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }

    ll current_num = 5;
    ll res = 0;
    while(true){
        if(current_num > N) break;
        res += (N / current_num) / 2;
        current_num *= 5;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  long long  n;
  cin>>n;
  long long  ans =0;
  for(int i =1;i<=n;i++){
    if(i%3 != 0 && i%5 != 0)
      ans+=i;
  }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    int m = in.nextInt();
        int ar[] = new int[n];
      	int sum=0;
      	for(int i=0;i<m;i++){
          ar[i]=in.nextInt();
          sum+=ar[i];
        }
      	int res = n-sum;
      	
        if(res>=0)
          System.out.println(res);
        else
          System.out.println("-1");
          
	}

}


Measured memory_bytes: 50280
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a <= c && c <=b)
  {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }

  return(0);
}

Measured memory_bytes: 256