akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll maxp = 0;
    vi result(n,0);
    map<char, int> handscore;
    handscore['r'] = p;
    handscore['s'] = r;
    handscore['p'] = s;
    vector<bool> jud(n, true);
    for(int i = n-1; i> -1; i--) {
        if(!jud[i])  continue;
        if(i-k > -1) {
            if(t[i] == t[i-k]) {
                jud[i-k] = false;
                maxp += handscore[t[i]];
            }
            else maxp += handscore[t[i]];
        }
        else maxp += handscore[t[i]];
    }
    cout << maxp << endl;
}

Measured memory_bytes: 896
import math
import itertools
import numpy as np
n,a,b=map(int,input().split())
mod=10**9+7
def comb(k, r):
    z=1
    for y in range(1,r+1):
        z=z*y%mod
    x=1
    for w in range(k-r+1,k+1):
        x=x*w%mod
    return x*pow(z,mod-2,mod)
c=comb(n,a)
d=comb(n,b)
e=pow(2,n,mod)
print((e-1-c-d)%mod)


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

using namespace std;

const int maxn = 190;

int n, m;
int rig[maxn][maxn][maxn], down[maxn][maxn][maxn];
int tag_rig[maxn][maxn][maxn], tag_down[maxn][maxn][maxn];
char A[maxn][maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%s", A[i] + 1);
	for (int i = n; i >= 1; i--) {
		for (int l = 1; l <= m; l++) {
			for (int r = l; r <= m; r++) {
				if (A[i][r] != A[i][l]) break;
				down[i][l][r] = 1;
				if (A[i][l] == A[i+1][l]) down[i][l][r] = down[i+1][l][r] + 1;
			}
		}
	}
	for (int i = m; i >= 1; i--) {
		for (int l = 1; l <= n; l++) {
			for (int r = l; r <= n; r++) {
				if (A[r][i] != A[l][i]) break;
				rig[i][l][r] = 1;
				if (A[l][i] == A[l][i+1]) rig[i][l][r] = rig[i+1][l][r] + 1;
			}
		}
	}
	if (down[1][1][m] >= n) {
		printf("%d\n", 0);
		return 0;
	}
	for (int T = 1; T <= 20; T++) {
		for (int i = n; i >= 1; i--) {
			for (int len = m; len >= 1; len--) {
				for (int l = 1; l+len-1 <= m; l++) {
					int r = l+len-1;
					int nl = down[i][l][r] + down[i+down[i][l][r]][l][r];
					tag_down[i][l][r] = max(tag_down[i][l][r], nl);
					tag_rig[l][i][i+nl-1] = max(tag_rig[l][i][i+nl-1], r-l+1);
				}
			}
		}
		for (int i = m; i >= 1; i--) {
			for (int len = n; len >= 1; len--) {
				for (int l = 1; l+len-1 <= n; l++) {
					int r = l+len-1;
					int nl = rig[i][l][r] + rig[i+rig[i][l][r]][l][r];
					tag_rig[i][l][r] = max(tag_rig[i][l][r], nl);
					tag_down[l][i][i+nl-1] = max(tag_down[l][i][i+nl-1], r-l+1);
				}
			}
		}
		for (int i = n; i >= 1; i--) {
			for (int len = m; len >= 1; len--) {
				for (int l = 1; l+len-1 <= m; l++) {
					int r = l+len-1;
					down[i][l][r] = max(down[i][l][r], tag_down[i][l][r]);
					down[i][l][r] = max(down[i][l][r], down[i][l-1][r]);
					down[i][l][r] = max(down[i][l][r], down[i][l][r+1]);
				}
			}
		}
		for (int i = m; i >= 1; i--) {
			for (int len = n; len >= 1; len--) {
				for (int l = 1; l+len-1 <= n; l++) {
					int r = l+len-1;
					rig[i][l][r] = max(rig[i][l][r], tag_rig[i][l][r]);
					rig[i][l][r] = max(rig[i][l][r], rig[i][l-1][r]);
					rig[i][l][r] = max(rig[i][l][r], rig[i][l][r+1]);
				}
			}
		}
		if (down[1][1][m] >= n) {
			printf("%d\n", T);
			break;
		}
	}
	return 0;
}

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

int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<set<int>> V(26);
  for (int i = 0; i < N; i++) {
    int tmp = S.at(i) - 'a';
    V.at(tmp).insert(i);
  }
  while (Q--) {
    int q;
    cin >> q;
    if (q == 1) {
      int a;
      char b;
      cin >> a >> b;
      a--;
      int tmp = b - 'a';
      int pre = S.at(a) - 'a';
      V.at(pre).erase(a);
      V.at(tmp).insert(a);
      S.at(a) = b;
    } else {
      int a, b;
      cin >> a >> b;
      a--, b--;
      int cnt = 0;
      for (int i = 0; i < 26; i++) {
        auto it1 = V.at(i).lower_bound(a);
        if (it1 == V.at(i).end()) continue;
        auto it2 = V.at(i).upper_bound(b);
        if (it1 != it2) cnt++;
      }
      cout << cnt << "\n";
    }
  }
}

Measured memory_bytes: 27236
#include <cstdio>
#include <stdlib.h>
using namespace std;

int gcd(int a, int b) {
    if (a%b == 0) {
        return b;
    } else {
        return gcd(b, a%b);
    }
}
int main() {
	int x, y;
	scanf("%d %d", &x, &y);
    int result = gcd(x, y);
    printf("%d\n", result);
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<endl;
  }else{
    cout<<b-a<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
  r = a % b
  r.zero? ? b : gcd(b, r)
end

a, b, c, d = gets.split.map(&:to_i)
g = c * d / gcd(c, d)
cnt1 = b / c - (a - 1) / c
cnt2 = b / d - (a - 1) / d
cnt3 = b / g - (a - 1) / g
puts (b - a + 1) - (cnt1 + cnt2 - cnt3)

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

bool isFinish(int a, int b) {
  return (abs(a-b) >= 2 && (a >= 11 || b >= 11));
}

int main() {
  while(1) {
    string s;
    for(int i = 0; i < 3; ++i) {
      string t;
      cin >> t;
      if(t == "0") return 0;
      s += t;
    }
    int a = 0, b = 0;
    for(int i = 1; i < s.size(); ++i) {
      if(s[i] == 'A') ++a;
      else ++b;
      if(isFinish(a,b)) {
        cout << a << " " << b << endl;
        a = b = 0;
      }
    }
    if(isFinish(a+1, b)) {
      cout << a+1 << " " << b << endl;
    } else {
      cout << a << " " << b+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
int dp[11][11];
int main(void)
{
	int n,i,f,l,j;
	long long int sum = 0;
	scanf("%d",&n);
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			dp[i][j] = 0;
		}
	}
	for(i=1;i<=n;i++)
	{
		f=i;
		while(f>=10)
		{
			f/=10;
		}
		l = i%10;
		dp[f][l]++;
//printf("%d %d\n",f,l);
	}
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			sum+=dp[i][j]*dp[j][i];
		}
	}
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 128
using System;


class Program
{
    public static void Main(string[] args)
    {
        string[] tmp = Console.ReadLine().Split(' ');
        int a = int.Parse(tmp[0]);
        int b = int.Parse(tmp[1]);
        int c = int.Parse(tmp[2]);
        int canSpeakDist = int.Parse(tmp[3]);

        if (Math.Abs(a - b) <= canSpeakDist && Math.Abs(b - c) <= canSpeakDist)
        {
            Console.WriteLine("Yes");
        }
        else if (Math.Abs(c - a) <= canSpeakDist)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
        System.Threading.Thread.Sleep(1000);
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場
i64 cup(i64 xxx38, i64 yyy38) {//切り上げ
	return (xxx38 + yyy38 - 1) / yyy38;
}
//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<int> dat(n,0);
	int num = 0;
	ff(i, 1, n) {
		if (s[i] == 'C') {
			if (s[i - 1] == 'A') {
				num++;
			}
		}
		dat[i] = num;
	}
	ff(i, 0, q) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << dat[r] - dat[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 1488
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string n;
  cin >> n;
  
  cout << (n[0] == n[2] ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = array.count(max(array, key = array.count))
for a in sorted(s):
    if array.count(a) == mx:
        print(a)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<"@"<<__LINE__<<": "<<x<<endl
using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> x(300);
    x[1] = 3e5;
    x[2] = 2e5;
    x[3] = 1e5;
    int a, b;
    cin >> a >> b;
    int sum = x[a]+x[b];
    if(a==1 && b==1) sum += 4e5;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    if ((n - 1) * (n - 2) / 2 < k)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        int m = 0;
        vector<pair<int, int>> v;
        rep(i, 1, n)
        {
            v.push_back({i, n});
            //cout << i << " " << n << endl;
            m++;
        }
        int now = (n - 1) * (n - 2) / 2;
        int x = 1;
        int y = 2;
        while (now != k)
        {
            while (x >= y)
            {
                x++;
                if (x >= n)
                {
                    x = 1;
                    y++;
                }
            }
            v.push_back({x, y});
            m++;
            //cout << x << " " << y << endl;
            now--;
            x++;
        }
        cout << m << endl;
        rep(i, v.size())
        {
            cout << v[i].first << " " << v[i].second << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;
int main (){
    string s;
    cin >> s;
    int l=s.size();
    int aloc,zloc;
    int i=0;
    while (s[i]!='A'){
        i++;
    }
    aloc=i;
    i=l-1;
    while (s[i]!='Z'){
        i--;
    }
    zloc=i;
    cout << zloc-aloc+1 <<"\n";

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 1e9;
	if(a + b < 2*c){
		ans = a*x + b*y;
	}else{
		if(y > x){
			ans = min(ans, 2*c*x + (y-x)*b);
			ans = min(ans, 2*c*y);
		}else{
			ans = min(ans, 2*c*y + (x-y)*a);
			ans = min(ans, 2*c*x);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int L;
  int n,e=0;
  scanf("%d",&L);

  for(n=0;L>=2<<n;n++)
    if(L&1<<n)
      e+=3;
  //      printf("1");
    else
      e+=2;
  //  printf("0");
  //  printf("1\n");
  
  printf("%d %d\n",n+1,e);
  
  for(n=0;L>=2<<n;n++){
    printf("%d %d %d\n",n+1,n+2,0);
    printf("%d %d %d\n",n+1,n+2,1<<n);
  }
  
  e=0;
  for(int i=0;L>=2<<i;i++)
    if(L&1<<i){
      printf("%d %d %d\n",i+1,n+1,(1<<n)+e);
      e+=1<<i;
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef long double ld;
using namespace std;
void solve()
{
    ull n,k; cin >> n >> k;
    n%=k; cout << min(n,k-n);
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b;
  cin>>a>>b;
  if(a<=0&&b>=0) cout<<"Zero"<<endl;
  else if(a<0&&b<0&&(b-a)%2==0) cout<<"Negative"<<endl;
  else if(a<0&&b<0&&(b-a)%2==1) cout<<"Positive"<<endl;
  else if(a>0&&b>0) cout<<"Positive"<<endl;
}


Measured memory_bytes: 256
#素因数分解して[素因数,個数]の形で返す
require "prime"
n = gets.to_i
if n == 1
  puts 0
else
  a = Prime.prime_division(n)
  s = 0
  i = 0
  while i < a.size do
    s += (Math.sqrt(2*a[i][1]+0.25)-0.5).floor
    i += 1
  end
  puts s
end

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

int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;
    int ans = 700;

    if (S[0] == 'o') {
        ans += 100;
    } 
    if (S[1] == 'o') {
        ans += 100;
    } 
    if (S[2] == 'o') {
        ans += 100;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
import sys
#sys.exit()
#sorted( ,reverse=True)
x = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1
if x==0:
    print(1)
else:
    print(0)


#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

Measured memory_bytes: 9084
/*
*
*  Created By : Pritish Thakkar 
*  Hackerrank : ma5terdrag0n
*  CodeChef : solo_loser
*  Hackerearth : pritish9
*------------------------------------
*  OS : Ubuntu 16.04
*  Language : CPP14
*  Editor : Sublime Text 3
*  C++ compiler : g++
*
*/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

bool isUpper(char c) {return (c >= 'A' && c <= 'Z');}
bool isLower(char c) {return (c >= 'a' && c <= 'z');}
bool iplpha(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z');}
bool isnum(char c){return (c >= '0' and c <= '9');}
bool isalnum(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z')||(c >= '0' && c <= '9');}
char toUpper(char c){return isUpper(c)?c:c-'a'+'A';}
char toLower(char c){return isLower(c)?c:c+'a'-'A';}
bool isvowel(char c){c = toLower(c); return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u');}
template<typename t> t gcd(t a, t b){return ((b == 0) ? a : gcd(b, a%b));} 
template<typename t> t lcm(t a, t b){return (a * (b / gcd(a, b)));}
template <typename T> T modpow(T base, T exp, T modulus) {base %= modulus;T result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
string toLowerCase(string s){rep(s.size()){if(!isLower(s[i])){s[i] = toLower(s[i]);}}return s;}
string toUpperCase(string s){rep(s.size()){s[i] = toUpper(s[i]);}return s;}
template<typename T> void cumulative(T *a, T *b, T n){rep(n){i ? b[i] = b[i-1] + a[i] : b[i] = a[i];}}
bool ispal(string s){ll lo, hi;lo = 0;hi = s.length()-1;while(lo <= hi){if(s[lo] != s[hi]){return 0;}lo++;--hi;}return 1;}
template<class T >string toString(T n){string v = "";while(n){v.pb(n % 10 + '0');n /= 10;}reverse(all(v));return v;}

//--------------------------------------------------------------------

void solve(){
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min (n*a, b) << endl;   
}


int main(){
    std::ios::sync_with_stdio(0);
    // int start = clock();
    // #ifdef ONLINE_JUDGE
    // #else
    //   freopen("input.in" , "r" , stdin);
    //   // freopen("output.txt", "w", stdout);
    // #endif
    solve();
    // cout << n;
    // int stop = clock();
    // cout << (stop - start) / 1000.0000<< endl;
}





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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

void add(ll a, ll b){
  a = (a+b) % MOD;
}

void mul(ll& a, ll b){
  a = (a*b) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=0;
  ll pow=1;
  rep(i,60){
    ll x=0,y=0;
    rep(j,n){
      if((a[j]>>i)&1) x++;
      else y++;
    }
    ans+=(x*y)%MOD*pow%MOD;
    ans%=MOD;
    mul(pow,2);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, P[1 << 18], V[1 << 18], cnt;

int main() {
	cin >> N; V[0] = 10000000;
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
		V[i] = min(V[i - 1], P[i]);
	}
	for (int i = 1; i <= N; i++) {
		if (V[i] == P[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
T = input()

T_list = list(T)

if T_list[0] == '?':
    T_list[0] = 'D'
    
for i in range(len(T)-1):
    if T_list[i] == 'P' and T_list[i+1] == '?':
        T_list[i+1] = 'D' 
    elif T_list[i] == '?' and T_list[i+1] == '?':
        T_list[i] = 'P'
        T_list[i+1] = 'D'
    elif T_list[i] == '?' and T_list[i+1] != '?':
        T_list[i] = 'D'
    else:
        continue

if T_list[-1] == '?':
    T_list[-1] = 'D'
    
S = "".join(T_list)
 
print(S)


Measured memory_bytes: 10896
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

s = str(input())
t= str(input())
if(s==t[:len(t)-1]):
    print('Yes')
else:
    print('No')


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    REP(i, m){
        int a, b;
        cin >> a >> b;
        chmax(l, a);
        chmin(r, b);
    }
    cout << max(0, r - l + 1) << endl;
    return 0;
}


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

char graph[3000][3000];
bool rireki[60];
int n,m;
int x;
int ok = 0;
int bfs(){
  int count = 0;
  queue<int> que;
  rireki[1] = true;
  for(int i = 2;i <= n;i++){
    rireki[i] = false;
  }
  que.push(1);
  
  while(que.size()){
    x = que.front(); que.pop();
    for(int i = 1;i <= n;i++){
      if(graph[x][i] == 1 && rireki[i] == false){
        rireki[i] = true;
        que.push(i);
      }
    }
  }
  for(int k = 1;k <= n;k++){
    if(rireki[k] == true){
      count++;
    }
  }
  if(count == n){
    return 0;
  }else{
    return 1;
  }
}

int main(){
  cin >> n >> m;
  int a[3000];
  int b[3000];
  int kekka = 0;
  for(int i = 1;i <= m;i++){
    cin >> a[i] >> b[i];
    graph[a[i]][b[i]] = 1;
    graph[b[i]][a[i]] = 1;
  }
  for(int i = 1;i <= n;i++){
    for(int j = 1;j < i;j++){
      if(graph[i][j] == 1){
        graph[i][j] = 0;
        graph[j][i] = 0;
        kekka += bfs();
        graph[i][j] = 1;
        graph[j][i] = 1;
      }
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX_SIZE (1000001)

int prime[MAX_SIZE];

int main(void)
{
	int n, i, j;
	
	for (i = 0; i < MAX_SIZE; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	
	for (i = 2; i * i < MAX_SIZE; i++){
		if (prime[i] == 1){
			for (j = i * i; j < MAX_SIZE; j += i){
				prime[j] = 0;
			}
		}
	}
	
	for (i = 1; i < MAX_SIZE - 1; i++){
		prime[i + 1] += prime[i];
	}
	
	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}
	
	return (0);
}

Measured memory_bytes: 4500
#include<iostream>

using namespace std;

void test_case()
{
string s,t;
cin>>s;
cin>>t;
int n=3,ans=0;
for(int i=0;i<n;++i)
{
if(s[i]==t[i])
{
ans++;
}
else
continue;
}
cout<<ans<<"\n";
}
int main()
{
test_case();
return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
struct prog { int s, t; };
vector<prog> progs[30+1];
vector<prog> squished[30+1];
vector<prog> all;
multiset<int> finish;
multiset<int>::iterator lt(const auto& bst, auto v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, C;
    cin >> n >> C;
    for(int i = 1; i <= n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        progs[c].push_back({s, t});
    }
    for(int i = 1; i <= C; i++) {
        sort(progs[i].begin(), progs[i].end(), [](prog& p1, prog& p2) {
            return p1.s < p2.s;
        });
        for(prog& p : progs[i]) {
            if(squished[i].empty() or squished[i].back().t < p.s) {
                squished[i].push_back(p);
            } else {
                squished[i].back().t = p.t;
            }
        }
        for(prog& p : squished[i]) {
            all.push_back(p);
        }
    }
    sort(all.begin(), all.end(), [](prog& p1, prog& p2) {
        return p1.s < p2.s;
    });
    for(prog& p : all) {
        if(lt(finish, p.s) != finish.end()) {
            finish.erase(lt(finish, p.s));
        }
        finish.insert(p.t);
    }
    cout << finish.size() << endl;
    return 0;
}


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

void main() {
  const N = readln.chomp.to!int;
  
  foreach (x; 1..10) foreach (y; x..10) {
    if (x*y == N) {
      "Yes".writeln; return;
    }
  }
  "No".writeln;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  final static int INF = 1001001001;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    // 入力データを変数に格納する
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[][] a = new int[12][12];
    int[] c = new int[n];
    for (int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
      for (int j = 0; j < m; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    sc.close();

    // 回答=コストの最小値なので最小値比較のために大きな数値で初期化しておく。
    int ans = INF;

    // 全ての組み合わせパターンをチェックする
    // 全ての組み合わせは「1<<n」通りある。
    // 二進数で考える。例としてn=3のときは
    // 1: 000
    // 2: 001
    // 3: 010
    // 4: 011
    // 5: 100
    // 6: 101
    // 7: 110
    // 8: 111
    // の８パターン(1<<3 = 8)
    for (int s = 0; s < 1<<n; s++) {
      int cost = 0;         // このs番目の組み合わせのコスト
      int[] d = new int[m]; // このs番目の組み合わせでの各アルゴリズムの理解度

      // ２進数で各ビットが1になっているかどうか調べる
      for (int i = 0; i < n; i++) {

        // 右にi個シフトすると調べたいビットが一番右にくる。
        if ((s>>i & 1) > 0) {
          cost += c[i];
          for (int j = 0; j < m; j++) {
            d[j] += a[i][j];
          }
        }
      }

      // 全てのアルゴリズムの理解度がxを超えているかチェックする
      boolean ok = true;
      for (int j = 0; j < m; j++) {
        if (d[j] < x) ok = false;
      }
      // チェックOKであれば、そのコストが最小値を更新するかどうか。
      if (ok) ans = Math.min(ans, cost);

    }

    // 全てのアルゴリズムの理解度がxを超えるパターンが１つもない場合はansがINFのままになってる
    if (ans == INF) System.out.println(-1);
    else System.out.println(ans);

  }
}

Measured memory_bytes: 37376
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  double n; cin>>n;
  n = n / 3;
  cout<<setprecision(10)<<fixed<<(n*n*n)<<endl;
}

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

using namespace std;

int v[31];

int main() {

  int n, m, l, ans = 0, hol, horse;
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    cin >> hol;
    for(int j = 1;j <= hol;j++){
      cin >> horse;
      v[horse]++;
    }
  }
  for(int i = 1;i <= m;i++){
    if(v[i] == n){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3640
while gets
  m, f, r = $_.split.map(&:to_i)
  if m == -1 && f == -1 && r == -1
    break
  end

  rank = nil
  if m == -1 || f == -1
    rank = "F"
  elsif m+f >= 80
    rank = "A"
  elsif m+f >= 65
    rank = "B"
  elsif m+f >= 50 || (m+f >= 30 && r >= 50)
    rank = "C"
  elsif m+f >= 30
    rank = "D"
  else
    rank = "F"
  end

  puts rank
end



Measured memory_bytes: 6872
def 解():
    iN = int(input())
    iD = 10**9 + 7


    if iN < 3:
        print(iN)
        exit()

    d素={2:1}
    for i in range(2,iN + 1):
        b素 = 1
        for j in range(2,int(i**0.5)+2):
            if i % j == 0:
                b素 = 0
                break
        if b素 :
            d素[i]=1
    for i in range(2,iN+1):
        for i素 in d素:
            while i % i素 == 0:
                d素[i素]+=1
                i //= i素
    iAns = 1
    for i素,num in d素.items():
        iAns *= num
        iAns %= iD
    print(iAns)
解()


Measured memory_bytes: 3192
from collections import Counter

N = int(input())
src = list(map(int,input().split()))

ctr = Counter(src)
most = ctr.most_common(1)[0][0]
i1 = src.index(most)
i2 = src[i1+1:].index(most) + i1+1
d = i2 - i1

MOD = 10**9+7

def mul(a,b):
    return (a*b) % MOD

def pow(a,n): # a^n
    ret = 1
    mag = a
    while n > 0:
        if n & 1:
            ret = mul(ret, mag)
        mag = mul(mag, mag)
        n >>= 1
    return ret

def inv(a):
    return pow(a, MOD-2)

fac = [1]
fac_inv = [1]
for n in range (1,N+3):
    f = mul(fac[n-1], n)
    fac.append(f)
    fac_inv.append(inv(f))

def ncr(n,r):
    return mul(mul(fac[n], fac_inv[n-r]), fac_inv[r])

anss = []
for r in range(1,N+2):
    anss.append(ncr(N+1,r))
n = N-d
for r in range(n+1):
    anss[r] -= ncr(n,r)
    anss[r] %= MOD

print(*anss, sep='\n')


Measured memory_bytes: 29164
from collections import deque
d = deque()
for x in input():
    d.append(x)
Q = int(input())
f = 0
for _ in range(Q):
    l = list(input().split())
    if l[0] == '1':
        f ^= 1
    else:
        if f == 0: 
            if l[1] == '2': d.append(l[2])
            else: d.appendleft(l[2])
        else:
            if l[1] == '2': d.appendleft(l[2])
            else: d.append(l[2])
if f:
    d.reverse()
print("".join(d))



Measured memory_bytes: 74712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi v;
ll dp[3005][3005][2];
ll solve(int i,int j,int c,ll sum){
    if(i==j)return sum;
    if(dp[i][j][c]!=-1)return sum+dp[i][j][c];
    if(c)dp[i][j][c]=min(solve(i+1,j,1-c,-v[i]),solve(i,j-1,1-c,-v[j-1]));
    else dp[i][j][c]=max(solve(i+1,j,1-c,v[i]),solve(i,j-1,1-c,v[j-1]));
    return sum+dp[i][j][c];
}
int main(){
    int n;cin>>n;
    v=vi(n);
    rep(i,n)cin>>v[i];
    rep(i,n+1)rep(j,n+1)rep(k,2)dp[i][j][k]=-1;
    out(solve(0,n,0,0));
}

Measured memory_bytes: 141440
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([][]int, n)
	b := make([][]int, m)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		var s string
		fmt.Scan(&s)
		for j := 0; j < n; j++ {
			a[i][j] = int(s[j])
		}
	}
	for i := 0; i < m; i++ {
		b[i] = make([]int, m)
		var s string
		fmt.Scan(&s)
		for j := 0; j < m; j++ {
			b[i][j] = int(s[j])
		}
	}
	ok := false
	for ly := 0; ly < n; ly++ {
		for lx := 0; lx < n; lx++ {
			if ly+m > n || lx+m > n {
				continue
			}
			match := true
			for y := 0; y < m; y++ {
				for x := 0; x < m; x++ {
					if a[ly+y][lx+x] != b[y][x] {
						match = false
					}
				}
			}
			if match {
				ok = true
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e6)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		string s, p;
		cin >> s >> p;
		if (p.length() - s.length() == 1) {
			for (int i = 0; i < (int)s.length(); i++) {
				if (s[i] != p[i]) {
					cout << "No\n";
					return 0;
				}
			}
			cout << "Yes\n";
			return 0;
		}
		cout << "No\n";
	}


	return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        String S = scanner.next();

        if (S.length() > K) {
            S = S.substring(0, K);
            System.out.println(S + "...");
        } else {
            System.out.println(S);
        }
    }
}


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

const int d = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;

  vector<bool> dang(n + 10, false);
  for (int i = 0; i < m; i++){
    int a;
    cin >> a;
    dang.at(a) = true;
  }

  vector<int> dp(n + 10, 0);
  dp.at(0) = 1;
  for (int i = 0; i < n; i++){
    if (dang.at(i)) continue;
    dp.at(i) %= d;
    if (!dang.at(i + 1)){
      dp.at(i + 1) += dp.at(i);
    }
    if (!dang.at(i + 2)){
      dp.at(i + 2) += dp.at(i);
    }
  }
  cout << dp.at(n) % d << endl;
}

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

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

  map<int, int> mp;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    mp[a]++;
  }

  int ans = -1;
  for (int i = 0; i < 1e5; ++i) {
    ans = max(ans, mp[i]+mp[i+1]+mp[i+2]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 4992
while True:
    a,op,b = map(str, raw_input().split())
    if op == "?":
        break
    if op == "+":
        print int(a)+int(b)
    if op == "-":
        print int(a)-int(b)
    if op == "*":
        print int(a)*int(b)
    if op == "/":
        print int(a)/int(b)


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

#define rep(i,n) for(int i=0;i<n;i++)
#define r_rep(i,n) for(int i=n-1;i>=0;i--)
#define ll long long

int main(){
    ll n;
    cin>>n;
    ll sum=0;
    rep(i,n) sum+=i;
    cout<<sum<<endl;
}

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

int main() {
	int n;
	while (1) {
		int num = 0;
		cin >> n;
		if (n == 0) break;
		while (n != 1) {
			if (n % 2 == 0) n = n / 2;
			else n = n * 3 + 1;
			num++;
		}
		cout << num << endl;
	}
	return 0;
}


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

int main()
{
    string x, y;
    int n ,s = 0 ,t = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        if(x > y){
           s += 3;
        }
        if(x == y){
            s++;
            t++;
        }
        if(x < y){
            t += 3;
        }
    }
    cout << s <<" "<< t << endl;
    
    return 0;
}


Measured memory_bytes: 3176
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <vector <int> > vvi;
typedef vector <vector <ll> > vvl;
typedef vector <pair<int,int> > vii;
typedef vector <pair<ll,ll> > vll;

string itos(int n) {stringstream ss;ss<<n;string s=ss.str();return s;}

ll ppow(ll x,ll y,ll mod) {
    ll res=1;
    while(y) {
        if(y&1) res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}



int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    if (int(s.size())%2) {
        cout << "No";
        exit(0);
    }
    bool ok=1;
    for (int i=0;i<s.size();i+=2) {
        if (s[i] != 'h' || s[i+1] != 'i') {
            ok=0;
            break;
        }
    }
    if (ok) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int prev[100001];
int rank[100001];

void init(int n){
	for(int i=1; i<=n; i++){ prev[i]=i; rank[i]=1; }
}
int root(int x){
	return prev[x]==x?x:(prev[x]=root(prev[x]));
}
void join(int x, int y){
	x=root(x), y=root(y);
	if(x==y) return;
	if(rank[x]<rank[y]){
		prev[x]=y;
	}else if(rank[x]>rank[y]){
		prev[y]=x;
	}else{
		prev[x]=y;
		rank[y]++;
	}
}

char a[100001];
int main(void){
	int n=nextpint();
	int m=nextpint();
	init(n);
	for(int i=0; i<m; i++){
		int x=nextpint();
		int y=nextpint();
		nextpint();
		join(x, y);
	}
	int ans=0;
	for(int i=1; i<=n; i++){
		int r=root(i);
		ans+=(a[r]==0);
		a[r]=1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include<iostream>

const int MOD = 1000000007;

typedef long long ULL;

using namespace std;

int main(){
    int N;
    int i;
    ULL ans;
    ULL *A;
    ULL sum;

    cin >> N;
    A = new ULL[N];

    sum = 0;
    for(i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    ans = 0;
    for(i=0;i<N-1;i++){
        sum -= A[i];
        ans += ( A[i] * (sum % MOD) ) % MOD; 
        ans %= MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
int main(){
const double PI=3.14159265358979323846;
cout << setprecision(12) << endl;
int n;
cin >> n;
cout << n * 2 * PI << endl;
return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(whole(a));
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    ll ans = 0;
    auto it = mp.end();
    vector<ll> x;
    while (1) {
        it--;
        //debug(it->second);
        if (it->second<=1) {
            if (it==mp.begin()) break;
            continue;
        }
        x.push_back(it->first);
        it->second -= 2;
        it++;
        if (x.size()==2) break;
        if (it==mp.begin()) break;
    }
    //debug(x.size());
    if (x.size()==2) ans = x[0]*x[1];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8116
n = int(input())
a = list(map(int, input().split(" ")))

sum_step = 0
max_height = a[0]
for i in range(1, n):
    if a[i] > max_height:
        max_height = a[i]
    if a[i] < max_height:
        sum_step += max_height - a[i]

print(sum_step)

Measured memory_bytes: 32180
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll MOD = 998244353;

ll POW(ll a, ll b){
    //a**b
    ll ans = 1;
    rep(i,b) ans *= a % MOD, ans %= MOD;
    return ans % MOD;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> D(N);
    vector<ll> d(1e6,0);
    rep(i,N) cin >> D[i];
    rep(i,N) d[D[i]]++;
    
    if(D[0] != 0 || d[0] != 1){
        pr(0);
        return 0;
    }

    ll mx = *max_element(ALL(D));
    ll ans = 1;
    rep1(i,mx) ans *= POW(d[i-1],d[i]) % MOD, ans %= MOD;
    pr(ans%MOD);
}

Measured memory_bytes: 8832
#include <stdio.h>

char m[6][7];
char mask[6][7];

int count(int h,int w){
  int i,j,result=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(m[i][j]=='#' && mask[i][j]=='0'){
        result++;
      }
    }
  }
  return result;
}

int main(){
  int h,w,k,i,j,x,y,result=0,tmp;
  int tmp_i,tmp_j;
 
  for(i=0;i<6;i++){
    for(j=0;j<6;j++){
      mask[i][j]='0';
    }
  }
  
  scanf("%d %d %d",&h,&w,&k);
  for(i=0;i<h;i++){
    scanf("%s",m[i]);
  }

  
  //if no select
  /*tmp=count(h,w);
  if(k==tmp){
    printf("1");
    return 0;
  }*/
  
  //ordinary pattern
  for(i=0;i<(1<<h);i++){
    for(j=0;j<(1<<w);j++){
      for(x=0;x<h;x++){
        for(y=0;y<w;y++){
          //printf("ss%d,%d,%d %d\n",i,j,x,y);
          if((i&(1<<x))>0 || (j&(1<<y))>0){
            mask[x][y]='1';
          } else {
            mask[x][y]='0';
          }
        }
      }
      tmp=count(h,w); 
      
      /*
      for(x=0;x<h;x++){
          printf("%s\n",m[x]);
      }
      for(x=0;x<h;x++){
          printf("%s\n",mask[x]);
      }
      printf("%d\n",tmp);
      */

      if(tmp==k){
        result++;
      }
    }
  }
  
  printf("%d",result);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

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

  int N;
  cin >> N;
  P p[N];
  rep(i,N){
    cin >> p[i].first >> p[i].second;
  }
  P ans = P(p[0].first, p[0].second);
  for(int i=1;i<N;i++){
    int M = max((p[i].first+ans.first-1)/p[i].first, (p[i].second+ans.second-1)/p[i].second);
    ans = P(M*p[i].first, M*p[i].second);
  }
  cout << ans.first+ans.second << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        for(int i = A; i < Math.min(A+K, B+1); i++) System.out.println(i);
        for(int i = Math.max(B-K+1, A+K); i <= B; i++) System.out.println(i);
        sc.close();

    }

}


Measured memory_bytes: 23380
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int number[] = new int[3];
        for(int i = 0; i < 3; i++){
            number[i] = scan.nextInt();
        }

        Arrays.sort(number);

        int a = number[2] - number[0];
        int b = number[2] - number[1];

        if(a%2 == 0 && b%2 == 0){

            System.out.println((a/2)+(b/2));

        }else if(a%2 != 0 && b%2 == 0){

            System.out.println((a/2)+(b/2) + 2);

        }else if(a%2 == 0 && b%2 != 0){

            System.out.println((a/2)+(b/2) + 2);

        }else{

            System.out.println((a/2)+(b/2) + 1);
        }
    }
}

Measured memory_bytes: 21712
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
bits=[[] for i in range(29)]
for i in range(29):
  mod = 2**(i+1)
  for j in b:
    bits[i].append(j%mod)
  bits[i].sort()

ans = 0
for k in range(29):
  al = []
  cnt = 0
  mod = 2**k
  for i in a:
    al.append(i%(2*mod))
  al.sort(reverse=True)
  r1 = r2 = r3 = 0
  for j in al:
    while r1 < N and bits[k][r1]+j < mod:
      r1 += 1
    while r2 < N and bits[k][r2]+j < 2*mod:
      r2 += 1
    while r3 < N and bits[k][r3]+j < 3*mod:
      r3 += 1
    cnt += N-r3+r2-r1
  ans += (cnt%2) << k
print(ans)

Measured memory_bytes: 217452
n = int(input())
h = list(map(int, input().split()))
count = 0
ans = []
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)
print(max(ans))


Measured memory_bytes: 20468
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

static void inputString(std::vector<char>& v1)
{
    std::string tmp;

    if (0x00 == &v1) {
        std::cerr << "v1 is null" << std::endl;
        exit (1);
    }

    std::cin >> tmp;
    for (int i = 0; i < tmp.size(); i++) {
        v1.push_back(tmp.at(i));
    }
}

static void reverseString(std::vector<char>& v1, std::vector<char>& v2)
{
    if (0x00 == &v1 || 0x00 == &v2) {
        std::cerr << "v1 or v2 are null." << std::endl;
        exit (1);
    }

    if (v2.empty()) {
        v2.resize(v1.size());
    }

    std::reverse_copy(v1.begin(), v1.end(), v2.begin());
}

int main()
{
    std::vector<char> vec1;
    std::vector<char> vec2;
    
    inputString(vec1);
    reverseString(vec1, vec2);
    for (int i = 0; i < vec2.size(); i++) {
        std::cout << vec2.at(i);
    }
    std::cout << std::endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	cout<<max(0,c-(a-b))<<"\n";
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ikeru = [[] for _ in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

fukasa = [10**18 for _ in range(n)]
kaisuu = 0
settansaku = set([])
setmada = set([0])

while len(setmada) != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					fukasa[k] = kaisuu

if fukasa[n-1] <= 2:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 59152