akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 2019;

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

  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t x;
  if (B <= N) {
    x = B - 1;
  } else {
    x = N;
  }
  cout << (A * x) / B << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    vector<int> arr0(n, 0);
    for(auto& val: arr0)
        cin >> val;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++)
        arr[i] = i;
    sort(arr.begin(), arr.end(), [&](int i, int j) {
        return arr0[i] < arr0[j];
         });
    int upper = 1, lower = -1;
    int pre = arr[0];
    vector<int> a = {arr[0]};
    vector<int> b = {0};
    //  2  3
    //  0 -1
    //  2  1  3
    for(int i = 1; i < n; i++) {
        upper = a.back()+1;
        lower = b.back()-1;
        if (arr[i] > pre) {
            upper = arr[i] - lower;
        } else if (arr[i] < pre) {
            lower = arr[i] - upper;
        }
        a.push_back(upper);
        b.push_back(lower);
        pre = arr[i];
    }
    int ma = *min_element(a.begin(), a.end());
    int mb = *min_element(b.begin(), b.end());
    for(int i = 0; i < n; i++)
        cout << a[i]-(ma-1) << " ";
    cout << endl;
    for(int i = 0; i < n; i++)
        cout << b[i]-(mb-1) << " ";
    cout << endl;
    return 0;
}




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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int inf = 1e9 + 7;

vector <string> v;

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i ++) {
		string s;
		cin >> s;
		v.pb(s);
	}	
	sort(v.begin(), v.end());
	for (string i : v)
		cout << i;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
l = len(S)
judge = True
for ii in range(l):
    if ii%2==0: # odd
        if S[ii]=='L':
            judge = False
    if ii%2==1: # even
        if S[ii]=='R':
            judge = False
if judge:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  string s;

  cin >> N >> s;
  REP(i, s.size()){
    s[i] += N;
    if(s[i] >= 91) s[i] -= 26;
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())

s = [input() for i in range(n)]
c = Counter(s)
ans = []
cnt = 0
for k in sorted(c.keys()):
    if c[k] > cnt:
        ans = [k]
        cnt = c[k]
    elif c[k] == cnt:
        ans.append(k)
[print(i) for i in ans]


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

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

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

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

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

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

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

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

use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        v: [i64; n],
    }
    let mut vv = v;
    vv.sort_by_key(|&x| Rev(x));

    let mut cursor = 0;
    let mut attack_count = 0;

    for i in vv {
        if cursor < m {
            cursor += 1;
            continue;
        }

        cursor += 1;
        attack_count += i;
    }

    println!("{}", attack_count);
}

Measured memory_bytes: 9464
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#define N 105
int dfn[N],low[N],scc[N],n,m,head[N],cnt,head2[N],cnt2,f1[N],f2[N],head3[N],cnt3,vis[N],is[N],ct,ct2,fg,e1[N][2],e2[N][2],in[N],T;
struct edge{int t,next;}ed[N*10],ed2[N*10],ed3[N*10];
stack<int> tp;
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;}
void adde2(int f,int t){ed2[++cnt2]=(edge){t,head2[f]};head2[f]=cnt2;ed2[++cnt2]=(edge){f,head2[t]};head2[t]=cnt2;}
void adde3(int f,int t){ed3[++cnt3]=(edge){t,head3[f]};head3[f]=cnt3;}
void dfs1(int u,int fa){f1[u]=fa;for(int i=head[u];i;i=ed[i].next)if(ed[i].t!=fa)dfs1(ed[i].t,u);}
void dfs2(int u,int fa){f2[u]=fa;for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)dfs2(ed2[i].t,u);}
void dfs3(int u,int fa)
{
	vis[u]=1;
	for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)is[ed2[i].t]=1;
	queue<int> tp;
	for(int i=head[u];i;i=ed[i].next)if(is[ed[i].t])tp.push(ed[i].t);
	for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)is[ed2[i].t]=0;
	while(!tp.empty())dfs3(tp.front(),u),tp.pop();
}
void dfs4(int u)
{
	tp.push(u);
	dfn[u]=low[u]=++ct;
	for(int i=head3[u];i;i=ed3[i].next)
	{
		if(!dfn[ed3[i].t])dfs4(ed3[i].t),low[u]=min(low[u],low[ed3[i].t]);
		else if(!scc[ed3[i].t])low[u]=min(low[u],dfn[ed3[i].t]);
	}
	if(dfn[u]==low[u])
	{
		int st=++ct2,s=tp.top();
		tp.pop();scc[s]=st;
		while(s!=u)
		{
			s=tp.top();tp.pop();
			scc[s]=st,fg=1;
		}
	}
}
int check(int s)
{
	int as=0;
	for(int i=1;i<=n;i++)head[i]=head2[i]=head3[i]=scc[i]=low[i]=dfn[i]=vis[i]=0;
	ct=ct2=fg=cnt=cnt2=cnt3=0;
	for(int i=1;i<n;i++)adde(e1[i][0],e1[i][1]),adde2(e2[i][0],e2[i][1]);
	dfs1(s,0);dfs2(s,0);dfs3(s,0);
	for(int i=1;i<=n;i++)if(!vis[i]){as++;if(!vis[f1[i]])adde3(i,f1[i]);if(!vis[f2[i]])adde3(f2[i],i);}
	for(int i=1;i<=n;i++)if(!dfn[i])dfs4(i);
	if(fg)return -1;
	return as;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<n;i++)scanf("%d%d",&e1[i][0],&e1[i][1]);
		for(int i=1;i<n;i++)scanf("%d%d",&e2[i][0],&e2[i][1]);
		int mn=1e9,fg2=0;
		for(int i=1;i<=n;i++){int st=check(i);if(st!=-1&&st<mn)mn=st;}
		if(mn<1e9)printf("%d\n",mn);
		else
		{
			for(int i=1;i<=n;i++)
			{
				int st=0;
				for(int j=1;j<n;j++)if(e1[j][0]==i||e1[j][1]==i){if(st)st=-1;else st=j;}
				if(st==-1)continue;
				int l1=e1[st][0],l2=e1[st][1];
				for(int j=1;j<=n;j++)if(j!=i){e1[st][0]=i,e1[st][1]=j;if(check(i)!=-1)fg2=1;}
				e1[st][0]=l1,e1[st][1]=l2;
			}
			if(fg2)printf("%d\n",n);
			else printf("-1\n");
		}
	}
}

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

int main() {
int N;
int sum=0;
    cin >> N ;
    for (int i = 0; i < N; ++i) {
      int a,b;
      cin >> a >> b;
      sum +=b-a+1;
    }
  cout << sum  << endl;  
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,a,b,q;
  cin>>n>>a>>b>>q;
  vector<Int> x(a),y(b),h(b),z(q);
  vector<char> c(a);
  for(Int i=0;i<a;i++) cin>>x[i]>>c[i],x[i]--;
  for(Int i=0;i<b;i++) cin>>y[i]>>h[i],y[i]--,h[i]--;
  for(Int i=0;i<q;i++) cin>>z[i],z[i]--;

  y.emplace_back(n);

  auto pos=
    [&](Int k)->Int{
      Int j=b;
      while(1){
	while(j>=0&&k<y[j]) j--;
	if(j<0||h[j]<0||y[j+1]<=k) return k;
	Int l=y[j+1]-y[j];
	if(h[j]+l<=y[j]){
	  k=h[j]+(k-y[j]);
	  continue;
	}
	Int m=y[j]-h[j];
	k=h[j]+(k-y[j])%m;
      }
    };
  
  map<Int, char> dp;  
  for(Int i=0;i<a;i++) dp[pos(x[i])]=c[i];
  for(Int i=0;i<q;i++){
    Int k=pos(z[i]);
    cout<<(dp.count(k)?dp[k]:'?');
  }
  cout<<endl;  

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;

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

    int x, y;
    cin >> x >> y;
    for (int cranes = 0; cranes <= x; cranes++) {
        int turtles = x - cranes;
        if (cranes * 2 + turtles * 4 == y) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int DN=1e5+5;
int n,m,f,g,b[DN],a[DN],ma,dp[DN];
vector<int>v[DN];
void dfs(int nod)
{
	for(auto i:v[nod])
	{
		dp[i]=max(dp[i],dp[nod]+1);
		a[i]++;
		if(a[i]==b[i])
			dfs(i);
	}
}
int main()
{
    cin>>n>>m;
    while(m--)
    {
    	cin>>f>>g;
    	v[f].pb(g);
    	b[g]++;
    }
    for(int i=1;i<=n;i++)
    	if(b[i]==0)
    		dfs(i);
    for(int i=1;i<=n;i++)
    	ma=max(ma,dp[i]);
    cout<<ma;
}


Measured memory_bytes: 9984
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;
typedef pair<int, int> P;

int main()
{
    int x, y, z, n, buf, r;
    while(1){
        cin >> x >> y >> z;
        if(x == 0) break;
        cin >> n;
        
        if(x > y){
            buf = x;
            x = y; 
            y = buf;
        }
        if(y > z){
            buf = y;
            y = z;
            z = buf;
        }
        if(x > y){
            buf = x;
            x = y;
            y = buf;
        }
        
        for (int i=0; i<n; i++) {
            cin >> r;
            if(2*r*2*r > x*x + y*y) cout << "OK";
            else cout << "NA";
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

#define SET_LIMIT 10000

int main (void) {
    int x = -1;
    int idx = 0;
    int dataSet[10000];
    
    while (1) {
        
        if (x == 0) {
            break;
        }
        
        scanf("%d", &x);
        if (x < 1 || x > 10000) {
            continue;
        }
        
        dataSet[idx++] = x;
    }
    
    dataSet[idx] = '\0';
    
    for (x = 0; x < idx; x++) {
        printf("Case %d: %d\n", x + 1, dataSet[x]);
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<ll> vec(3);

//解法
void solve() {

	SORTS2L(ll, vec);

	cout << (vec[0] * vec[1]) / 2;

	return;
}

int main() {
	//入力

	//cin >> N >> M >> L;
	rep(i, 3) cin >> vec[i];

	solve();
	//cout << endl;
	return 0;
}

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

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

    double ans = ((n-1)/2 + 1);
    ans /= n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin >> h>>w;
  vector<vector<int>> s(h+2,vector<int>(w+2));
  for(int i = 1;i<=h;i++){
    for(int j=1;j<=w;j++){
      char t;
      cin >> t;
      if(t =='#'){
        s.at(i).at(j) = 9;
        s.at(i).at(j+1)++;
        s.at(i).at(j-1)++;
        s.at(i+1).at(j)++;
        s.at(i+1).at(j+1)++;
        s.at(i+1).at(j-1)++;
        s.at(i-1).at(j)++;
        s.at(i-1).at(j+1)++;
        s.at(i-1).at(j-1)++;
      }
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s.at(i).at(j) >=9){
        cout << '#';
      }
      else{
        cout << s.at(i).at(j);
      }
      if(j==w){
        cout <<endl;
      }
    }
  }
}


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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

char s[20];

int main()
{
    cin>>s;
    if(strlen(s)<4) cout<<"No"<<endl;
    else
    {
        if((s[0]=='Y')&&(s[1]=='A')&&(s[2]=='K')&&(s[3]=='I')) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>
using namespace std;

string solve(int par, pair<long long, long long> XY){
    string ans;
    if(par == 0){
        ans += "L";
        XY.first++;
    }
    long long U = (XY.first+XY.second+((1LL<<31)-1))/2;
    long long V = (XY.first-XY.second+((1LL<<31)-1))/2;
    vector<int> uu(31), vv(31);
    for(int i=0; i<=30; i++){
        uu[i] = (U >> i) & 1;
        vv[i] = (V >> i) & 1;
    }
    for(int i=0; i<=30; i++)
        if(uu[i] == 0 && vv[i] == 0)
            ans += "L";
        else if(uu[i] == 1 && vv[i] == 1)
            ans += "R";
        else if(uu[i] == 0 && vv[i] == 1)
            ans += "D";
        else if(uu[i] == 1 && vv[i] == 0)
            ans += "U";
    return ans;
}

int main(){
    int N;
    cin >> N;
    vector<pair<long long, long long>> XY(N);
    for(int i=0; i<N; i++) cin >> XY[i].first >> XY[i].second;

    int par = ((1LL<<31) + XY[0].first + XY[0].second) % 2;
    for(int i=0; i<N; i++){
        if(((1LL<<31) + XY[i].first+XY[i].second)%2!=par){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> d;
    if(par == 0)
        d.push_back(1);
    for(int i=0; i<=30; i++)
        d.push_back(1<<i);
    cout << d.size() << endl;
    for(int x : d)
        cout << x << " ";
    cout << endl;

    for(int i=0; i<N; i++){
        string str = solve(par, XY[i]);
        long long x = 0, y = 0;
        for(int j=0; j<d.size(); j++){
            if(str[j] == 'L')
                x -= d[j];
            else if(str[j] == 'R')
                x += d[j];
            else if(str[j] == 'U')
                y += d[j];
            else if(str[j] == 'D')
                y -= d[j];
        }
        assert(x == XY[i].first);
        assert(y == XY[i].second);
    }

    for(int i=0; i<N; i++)
        cout << solve(par, XY[i]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int partition(int*, int, int);

int main()
{
  int n, A[100000], q, i;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&A[i]);
    }

  q = partition(A, 0, n-1);

  for(i = 0; i < q; i++)
    {
      printf("%d ",A[i]);
    }

  printf("[%d] ",A[q]);

  for(i = q+1; i < n-1; i++)
    {
      printf("%d ",A[i]);
    }

  printf("%d\n",A[n-1]);
  
  return 0;
}

int partition(int *A, int p, int r)
{
  int x, i, j, temp;
  
  x = A[r];
  i = p-1;

  for(j = p; j < r; j++)
    {
      if(A[j] <= x)
	{
	  i++;
	  temp = A[i];
	  A[i] = A[j];
	  A[j] = temp;
	}
    }

  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return i+1;
}



Measured memory_bytes: 2120
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    def isOK(x):
        kaisu = 0
        for ae in a:
            kaisu += ceil(ae / x) - 1
        if kaisu <= k:
            return True
        else:
            return False
    ng = 0
    ok = max(a)
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31576
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;

int main(){
	int W,a,b;
	cin>>W>>a>>b;
	int ans;
	if(a+W<=b){
		ans=b-a-W;
	}else if(ck(b,a,a+W)){
		ans=0;
	}else{
		ans=a-b-W;
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define P(i,j) pair<i,j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    ll n,m;
    cin>>n>>m;
    V(V(char)) g(n,V(char)(m));
    V(V(ll)) dp(n,V(ll)(m,0));
    rep(i,n)
    {
        rep(j,m)
        {
            cin>>g[i][j];
        }
    }
    
    rep(i,n)
    {
        rep(j,m)
        {
            if(g[i][j] == '.')
            {
                if(i==0 && j==0)
                {
                    dp[i][j]=1;
                }
                else if(j == 0)
                {
                    dp[i][j]=dp[i-1][j];
                }
                else if(i==0)
                {
                    dp[i][j] = dp[i][j-1];
                }
                else
                {
                    dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
                }
                
            }
        }
    }
    cout<<dp[n-1][m-1]%MOD;
    return 0;
}

Measured memory_bytes: 12156
#include <stdio.h>
int main(void)
{
	int a,b,c,x=0,y=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5){
		x+=1;
	}
	if(a==7){
		y+=1;
	}
	if(b==5){
		x+=1;
	}
	if(b==7){
		y+=1;
	}
	if(c==5){
		x+=1;
	}
	if(c==7){
		y+=1;
	}
	if(x==2 && y==1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
        public static void main(String arg[]){
                Scanner sc = new Scanner(System.in);
                while(true){
                        int a = sc.nextInt();
                        int b = sc.nextInt();
                        if (a == 0 && b == 0) {
                                break;
                        }
                        b -= a;
                        System.out.println((b%500/100)+" "+(b%1000/500)+" "+(b/1000));
                }
        }
}

Measured memory_bytes: 33424
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))

n = int(input())
nums = []
ans = "No"


for i in range(0, n):
  nums.append(int(input()))

for i in range(0,3):
  if row1[i] in nums: row1[i] = "O"
  if row2[i] in nums: row2[i] = "O"
  if row3[i] in nums: row3[i] = "O"

#Columns
for i in range(0,3):
  if row1[i] == row2[i] == row3[i]: ans = "Yes"
    
#Rows
if row1 == ["O","O","O"] or row2 == ["O","O","O"] or row3 == ["O","O","O"]: ans = "Yes"
  
#Diagonals
if row1[0] == row2[1] == row3[2] or row1[2] == row2[1] == row3[0]: ans = "Yes"
  
print(ans)


Measured memory_bytes: 9148
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double b[10];
int perm[10];
double PI=acos(-1.0);
double EPS=1e-9;
double solve(int a){
	double left=0;
	double right=PI;
	for(int i=0;i<100;i++){
		double M=(left+right)/2;
		double th=M;
		double val=M;
		for(int j=0;j<a-1;j++){
			if(b[perm[(j+a-1)%a]]*cos(th)>b[perm[j+1]]){val=0;break;}
			double L=acos(b[perm[(j+a-1)%a]]*cos(th)/b[perm[j+1]]);
			val+=L;
			th=L;
		}
		if(val>2*PI)right=M;
		else left=M;
	}
	double t=right;
	double s=b[perm[0]]*b[perm[a-1]]*sin(right);
	double now=t;
	for(int i=0;i<a-1;i++){
		if(b[perm[(i+a-1)%a]]*cos(t)>b[perm[i+1]]+EPS)return 0;
		double L=acos(b[perm[(i+a-1)%a]]*cos(t)/b[perm[i+1]]);
		t=L;
		now+=t;
		s+=b[perm[i]]*b[perm[i+1]]*sin(t);
	}
	if(now>2*PI+EPS)return 0;
	/*if(s/2>800000){
		for(int i=0;i<a;i++)printf("%d ",perm[i]);
		printf(", %f %f\n",right,s/2);
		printf("\n");
	}*/
	return s/2;
}
int v[10];
int n;
double dfs(int a){
	double ret=0;
	if(a>=3)ret=max(ret,solve(a));
	if(a<n){
		for(int i=0;i<n;i++){
			if(v[i])continue;
			v[i]=1;
			perm[a]=i;
			ret=max(ret,dfs(a+1));
			v[i]=0;
		}
	}
	return ret;
}
int main(){
	int a;
	scanf("%d",&a);
	n=a;
	for(int i=0;i<a;i++)scanf("%lf",b+i);	
	printf("%.12f\n",dfs(0));
}

Measured memory_bytes: 1212
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

left = 0
right = 0
cnt = 0
temp = 0
ans = 0

while right < n:
    if temp & a[right] == 0:
        temp += a[right]
        cnt += 1
        ans += cnt
        right += 1
        
    else:
        temp -= a[left]
        cnt -= 1
        left += 1
        
print(ans)

Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a1,a2,a3,b1,b2,b3,c1,c2,c3;
    cin>>a1>>a2>>a3>>b1>>b2>>b3>>c1>>c2>>c3;
    for(int x1=0;x1<101;x1++){
        for(int x2=0;x2<101;x2++){
            for(int x3=0;x3<101;x3++){
                int y1=a1-x1;
                int y2=a2-x1;
                int y3=a3-x1;
                if(y1>=0&&x2+y1==b1&&x3+y1==c1){
                    if(y2>=0&&x2+y2==b2&&x3+y2==c2){
                        if(y3>=0&&x2+y3==b3&&x3+y3==c3){
                            cout<<"Yes"<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

def bellman_ford(V,G,start=0):
    dist = [inf]*V
    dist[start]=0
    negative_cycle = False
    for _ in range(1,V):
        for u in G:
            for v,d in G[u]:
                if dist[v]>dist[u]+d:
                    dist[v] = dist[u]+d
    ans = dist[V-1]
    for u in G:
        for v,d in G[u]:
            if dist[v] > dist[u]+d:
                dist[v] = dist[u]+d
    if dist[V-1]<ans:
        return -1
    else:
        return dist

V,E = map(int,input().split())
G = defaultdict(list)
for i in range(E):
    u,v,d = map(int,input().split())
    G[u-1].append((v-1,-d))
d = bellman_ford(V,G,0)
if d==-1:
    print("inf")
else:
    print(-1*d[V-1])

Measured memory_bytes: 47960
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  map<int, int>cs;
  F0R(i, N) {
    int a;
    cin >> a;
    cs[a]++;
  }
  F0R(i, M) {
    int b, c;
    cin >> b >> c;
    for (auto& p : cs) {
      if (p.first >= c) break;
      if (b >= p.second) {
        cs[c] += p.second;
        b -= p.second;
        cs.erase(p.first);
        if (!b) break;
      }
      else {
        p.second -= b;
        cs[c] += b;
        break;
      }
    }
  }
  i64 result = 0;
  for (auto& p : cs) {
    result += (i64)p.first * p.second;
  }
  cout << result;
}
#endif


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

int main(void) {
    int K,S;cin>>K>>S;
    int result = 0;
    for (int X = 0 ; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            if (S - X - Y <= K && S - X - Y >= 0) result++;
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 384
def resolve():
    s = int(input())
    top = s//100
    bottom = s%100
    if (top>12 or top==0) and bottom<=12 and bottom>0:
        print('YYMM')
    elif top<=12 and top>0 and (bottom>12 or bottom==0):
        print('MMYY')
    elif top<=12 and top>0 and bottom<=12 and bottom>0:
        print('AMBIGUOUS')
    else:
        print('NA')

if __name__ == "__main__":
    resolve()

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, k) {
        vi b(n+1);
        rep(j, n) {
            int l = max(0, j-a[j]);
            int r = min(n-1, j+a[j]);
            b[l]++; b[r+1]--;
        }
        rep(j, n) b[j+1] += b[j];
        b.pop_back();
        if (i >= 42) break;
        a = b;
    }
    rep(i, n) cout << a[i] << (i<n-1?' ':'\n');
    return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;


struct Infant {
    ll index;
    ll active;
};

queue<P> enu(int n) {
    queue<P> q;
    for (int i = 0; i < n; i++) {
        for (int x = 0; x <= i; x++) {
            q.push({x, i - x});
        }
    }
    return q;
}

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

    vector<Infant> infants(n);
    rep(i, n) infants[i].index = i;
    rep(i, n) cin >> infants[i].active;

    sort(infants.rbegin(), infants.rend(), [&](Infant i, Infant j) { return i.active < j.active; });

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    queue<P> q = enu(n);


    while (!q.empty()) {
        P p = q.front();
        q.pop();
        ll i = p.first + p.second;
        Infant infant = infants[i];
        ll from = dp[p.first][p.second];

        ll to_l = abs(infant.index - p.first) * infant.active;
        ll to_r = abs(infant.index - (n - p.second - 1)) * infant.active;

        cmax(dp[p.first + 1][p.second], from + to_l);
        cmax(dp[p.first][p.second + 1], from + to_r);
    }

    vector<ll> candidate;
    rep(i, n) {
        ll now = *max_element(dp[i].begin(), dp[i].end());
        candidate.push_back(now);
    }
    ll ans = *max_element(candidate.begin(), candidate.end());
    cout << ans << endl;

}

//ll ans = 0;
//rep(i, n) {
//Infant infant = target[i];
//ll diff = abs(infant.index - i);
//ll now = infant.active * diff;
//ans += now;
//}
//return ans;

Measured memory_bytes: 67344
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  int arr[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&arr[i]);
  }
  int j,k, count=0;
  for(j=0;j<N;j++){
    for(k=j+1;k<N;k++){
      count+=arr[j]*arr[k];

	}
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
mod = 10**9 + 7
ans = [0] * (N+1)
ans[0] = 1
ans[1] = 1 if 1 not in A else 0
for i in range(2, N+1):
  ans[i] = (ans[i-1]+ans[i-2])%mod if i not in A else 0
print(ans[N])

Measured memory_bytes: 13216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,M=N*N*N;
int n,m,d,fa[N];
struct node{
	int v; ll w;
}a[N];
bool cmp(node x,node y){
	return y.w*x.v>x.w*y.v;
}
ll f[M],F=1e15;
int ans,p[M]; node q[M];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m>>d>>a[1].w; a[1].v=1;
	for(int i=2;i<=n;i++) scanf("%lld%d",&a[i].w,&fa[i]),a[i].v=1;
	for(int i=n;i>1;i--) a[fa[i]].w+=a[i].w,a[fa[i]].v+=a[i].v;
	sort(a+1,a+n+1,cmp);
	f[0]=0; for(int i=1;i<M;i++) f[i]=F;
	int l=min(d,n),s=0;
	for(int i=1;i<=n;i++){
		s+=n*a[i].v;
		for(int x=0;x<a[i].v;x++){
			int t=0,ft=0,tl=0;
			for(int j=x;j<=s;j+=a[i].v) p[++t]=j;
			for(int j=t,k=t;j;j--){
				while(ft<tl && q[ft+1].v>j) ft++;
				while(k && k>=j-l){
					node u=(node){k,f[p[k]]-a[i].w*k};
					while(ft<tl && q[tl].w>=u.w) tl--;
					q[++tl]=u;
					k--;
				}
				f[p[j]]=min(f[p[j]],q[ft+1].w+a[i].w*j);
			}
		}
	}
	for(int i=0;i<=s;i++){
		//printf("i=%d x=%lld\n",i,f[i]);
		if(f[i]>m) continue;
		int x=m-f[i],su=i;
		for(int j=1;j<=n;j++){
			int u=(int)(((ll)x)/a[j].w);
			if(a[j].v<n) u=min(u,d-l);
			su+=a[j].v*u; x-=a[j].w*u;
			if(x<a[j].w) break;
		}
		//cout<<"su="<<su<<endl;
		ans=max(ans,su);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[0] == s[2]) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

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





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<pll> a(n);
	rep(i,n) cin >> a.at(i).first >> a.at(i).second;
	sort(a.begin(),a.end());
	vector<pll> b(n),c(n);
	ll lmax = a.at(0).first, rmin = a.at(0).second;
	rep(i,n){
		lmax = max(lmax, a.at(i).first);
		rmin = min(rmin, a.at(i).second);
		b.at(i).first = lmax;
		b.at(i).second = rmin;
	}
	lmax = a.at(n - 1).first;
	rmin = a.at(n - 1).second;
	for(int i = n - 1; i >= 0; i--){
		lmax = max(lmax, a.at(i).first);
		rmin = min(rmin, a.at(i).second);
		c.at(i).first = lmax;
		c.at(i).second = rmin;
	}
	ll ans = 0;
	rep(i,n - 1){
		ans = max(ans, max(b.at(i).second - b.at(i).first + 1, 0LL) + max(c.at(i + 1).second - c.at(i + 1).first + 1, 0LL));
	}
	ans = max(ans, a.at(0).second - a.at(0).first + 1 + max(c.at(1).second - c.at(1).first + 1, 0LL));
	ans = max(ans, a.at(n - 1).second - a.at(n - 1).first + 1 + max(b.at(n - 2).second - b.at(n - 2).first + 1, 0LL));
	for(int i = 1; i < n - 1; i++){
		ans = max(ans, a.at(i).second - a.at(i).first + 1 + max(min(b.at(i - 1).second,c.at(i + 1).second) - max(b.at(i - 1).first,c.at(i + 1).first) + 1, 0LL));
	}
	cout << ans << endl;
}

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

const int N = 4e3;
double dp[N][N];
double p[N];
// float
// double
// long double 
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];

	dp[n][0] = 1 - p[n];
	dp[n][1] = p[n];

	for (int i = n - 1; i >= 1; i--)
		for (int j = 0; j <= n; j++) {
			if (j >= 1)
				dp[i][j] = dp[i + 1][j - 1] * p[i];
			dp[i][j] += dp[i + 1][j] * (1 - p[i]);
		}

	double sum = 0;
	for (int i = ceil(n / 2.0); i <= n; i++)
		sum += dp[1][i];

	cout << fixed << setprecision(10) << sum;
	cin >> n;
	return 0;
}

Measured memory_bytes: 94208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll ans=0;
    string S,M;
    ll A[100010];
    int temp[100]={0};
    bool f=false;
    bool fir=true;
    ll sum=0;

int main(){
    cin>>S;
    REP(i,(signed)S.size())M+=S[S.size()-i-1];
    S==M?cout<<"Yes":cout<<"No";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
#define K 55
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;

signed main() {
    ios::sync_with_stdio(0); 
    cin.tie(NULL); cout.tie(NULL);
    string s; cin>>s;
    int n = s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='?')s[i] = 'D';
        cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 


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

Measured memory_bytes: 3636
#include <stdio.h>

using namespace std;

int main(){
	int n,m,tmp;
	scanf("%d %d",&n,&m);
	int** A = new int*[n];
	for(int i = 0; i < n; i++) A[i] = new int[m];
	int b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&tmp);
			A[i][j] = tmp;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d",&tmp);
		b[i] = tmp;
	}
	long long int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		printf("%lld\n",sum);
	}
}



Measured memory_bytes: 2784
#include <stdio.h>

int main(void) {
  int a;
  char buf1[20];
  fgets(buf1, 20, stdin);
  sscanf(buf1, "%d", &a);
  
  if(a < 1200){
  printf("ABC \n");
  }
  else{
  printf("ARC \n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

//ref~ https://github.com/bqi343/USACO/blob/master/Implementations/content/graphs%20(12)/DSU/DSU%20(7.6).h
struct DSU {
	vi e; void init(int n) { e = vi(n,-1); }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); } 
	bool sameSet(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	bool unite(int x, int y) { // union-by-rank
		x = find(x), y = find(y); if (x == y) return 0;
		if (e[x] > e[y]) swap(x,y);
		e[x] += e[y]; e[y] = x; return 1;
	}
};
/**template<class T> T kruskal(int n, vector<pair<T,pii>> ed) {
	sort(all(ed));
	T ans = 0; DSU D; D.init(n+1); // edges that unite are in MST
	trav(a,ed) if (D.unite(a.s.f,a.s.s)) ans += a.f; 
	return ans;
}*/

void solve(){
	int n, m; 
	re(n,m);
	DSU d ;
	d.init(n);
	while(m--){
		int a ,b ,c ; 
		re(a,b,c);
		a-- ; b-- ; 
		d.unite(a,b);
	}
	set<int>se;
	rep(i,0,n){
		se.insert(d.find(i));
	}
	cout << sz(se) << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 8676
class Node
  attr_accessor :parent, :rank

  def initialize(n)
    @parent = n
    @rank = 0
  end
end

class UnionFindTree
  def initialize(n)
    @nodes = (0..n).to_a.map { |i| Node.new(i) }
  end

  def find(x)
    return x if @nodes[x].parent == x

    @nodes[x].parent = find(@nodes[x].parent)
  end

  def unite(a, b)
    a = find(a)
    b = find(b)
    return if a == b

    if @nodes[a].rank < @nodes[b].rank
      @nodes[a].parent = b
    else
      @nodes[b].parent = a
      @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
    end
  end

  def same?(a, b)
    find(a) == find(b)
  end
end

def main
  n, m = ARGF.gets.split.map(&:to_i)
  # puts("Error") if n <= 0

  seq = ARGF.gets.split.map(&:to_i)
  # pp seq

  # グループ分け
  nft = UnionFindTree.new(n)
  m.times do
    p0, p1 = ARGF.gets.split.map(&:to_i)
    nft.unite(p0, p1)
  end

  match_num = 0
  pos = 1
  seq.each do |num|
    if num == pos
      # 既に所定の位置にある場合は即インクリメント
      match_num += 1

    elsif nft.same?(pos, num)
      # pickした数字を所定の位置に持っていけるか？
      # 現在のpos数 と pickした数字 が同じGroup なら持っていける
      match_num += 1
    end

    pos += 1
  end

  puts match_num
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 18060
def main():
    S = input()
    N = len(S)

    def solve(S):
        from collections import deque
        cur = deque([S[0]], maxlen=1)
        ans = 1
        i = 1
        plus = 1
        while i+plus <= N:
            if S[i:i+plus] in cur:
                plus += 1
            else:
                ans += 1
                cur.append(S[i:i+plus])
                i = i+plus
                plus = 1
        return ans
    print(solve(S))


if __name__ == '__main__':
    main()


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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  vector<char> vec(W+2,'#');
  
  for (int i=0; i<W+2; i++) cout << vec.at(i);
  cout << endl;
  
  string str;
  for (int i=0; i<H; i++) {
    cin >> str;
    for (int j=0; j<W; j++) vec.at(j+1) = str.at(j);
    for (int j=0; j<W+2; j++) cout << vec.at(j);
    cout << endl;
  }
  
  vec = vector<char>(W+2,'#');
  for (int i=0; i<W+2; i++) cout << vec.at(i);
  cout << endl;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	q := nextInt(sc)
	A := make([][]int, n)
	ans := make([][]int, 0)
	for i := 0; i < q; i++ {
		op := nextInt(sc)
		t := nextInt(sc)
		if op == 0 {
			v := nextInt(sc)
			A[t] = append(A[t], v)
		} else if op == 1 {
			ans = append(ans, A[t])
		} else {
			A[t] = make([]int, 0)
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(ans); i++ {
		if len(ans[i]) == 0 {
			fmt.Fprintf(wtr, "\n")
		} else {
			for j := 0; j < len(ans[i]); j++ {
				if j > 0 {
					fmt.Fprintf(wtr, " ")
				}
				fmt.Fprintf(wtr, "%d", ans[i][j])
			}
			fmt.Fprintf(wtr, "\n")
		}
	}
	wtr.Flush()
}



Measured memory_bytes: 22872
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W, A, B) = nextIntList()
    val X = B
    val y = H - A - 1
    val combi = Combination(200000)
    var ans = MInt(0)
    for (x in X until W) {
        ans += combi(x + y, x) * combi(W - x - 1 + A - 1, A - 1)
    }
    println(ans)
}

class Combination(n: Int) {
    private val fact = Array<MInt?>(n + 1) { null }
    private val ifact = Array<MInt?>(n + 1) { null }

    init {
        fact[0] = MInt(1)
        (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }
        ifact[n] = fact[n]!!.inv()
        (n downTo 1).forEach { i -> ifact[i - 1] = ifact[i]!! * MInt(i) }
    }

    operator fun invoke(n: Int, k: Int): MInt {
        if (k < 0 || n < k) return MInt(0)
        return (fact[n]!! * ifact[k]!! * ifact[n - k]!!)
    }
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a.v += b.v
        if (a.v >= MOD) a.v -= MOD
        return a
    }

    operator fun plus(b: Int) = plus(MInt(b))
    operator fun plus(b: Long) = plus(MInt(b))

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a.v -= b.v
        if (a.v < 0) a.v += MOD
        return a
    }

    operator fun minus(b: Int) = minus(MInt(b))
    operator fun minus(b: Long) = minus(MInt(b))

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a.v *= b.v
        a.v %= MOD
        return a
    }

    operator fun div(b: MInt): MInt {
        return MInt(v) * b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(N: Int) = pow(N.toLong())

    fun pow(N: Long): MInt {
        var ans = MInt(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans *= a
            }
            a *= a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 57324
#include<iostream>

using namespace std;

int prime[50001];

void make(){

  for(int i = 0; i < 50001; i++) prime[i] = 1;

  prime[0] = 0;
  prime[1] = 0;

  for(int i = 2; i*i < 50001; i++){
    if(prime[i] == 1){
      for(int j = i*2; j < 50001; j+=i) prime[j] = 0;
    }
  }
}


int main(){

  make();

  int n;

  while(cin >> n){
    if(n == 0) break;

    int sum = 0;

    for(int i = 2; i <= n/2; i++){
      if(prime[i] == 1 && prime[n-i] == 1) sum++;
    }
    cout << sum << endl;
  }

  return 0;     
}
  

Measured memory_bytes: 1060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		int c = Integer.parseInt(s[2]);
		int count = 0;
		for(int i = a ; i < b+1;i++){
			if(c%i==0){
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 24312
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

A = int(input())
#S = input()
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

print(A ** 3 + A ** 2 + A)

Measured memory_bytes: 65148