akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i,N) for (int i = 0; i < N; i++)
int main(){
        int c[3][3];
        int diff[3];
        rep(i,3) rep(j,3) cin >> c[i][j];
        rep(i,3){
                rep(j,3){
                        diff[j] = c[i][j]-c[(i+1)%3][j];
                }
                rep(j,2){
                        if(diff[j]!=diff[j+1]) {
                                cout << "No" << endl;
                                return 0;
                        }
                }
        }
        rep(j,3){
                rep(i,3){
                        diff[i] = c[i][j]-c[i][(j+1)%3];
                }
                rep(j,2){
                        if(diff[j]!=diff[j+1]) {
                                cout << "No" << endl;
                                return 0;
                        }
                }
        }
        cout << "Yes" << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N,M,R,r[10],a,b,c;
int d[201][201];
int main(){
    cin>>N>>M>>R;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i==j)d[i][j]=0;
            else d[i][j]=1e9;
        }
    }
    for(int i=0;i<R;i++)cin>>r[i];
    for(int i=0;i<M;i++){
        cin>>a>>b>>c;
        d[a][b]=c;
        d[b][a]=c;
    }
    sort(r,r+R);
    for(int k=1;k<=N;k++)
        for(int i=1;i<=N;i++)
            for(int j=1;j<=N;j++)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int ans=1e9,num;
    do{
        num=0;
        for(int i=1;i<R;i++)num+=d[r[i-1]][r[i]];
        ans=min(ans,num);
    }while(next_permutation(r,r+R));
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,k;cin>>k>>n;
    vector<ll>a(n+1);
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[n]=k+a[0];
    ll ans=k;
    ll maxm=-1;
    for(ll i=0;i<n;i++){
        chmax(maxm,a[i+1]-a[i]);
    }
    cout<<ans-maxm<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





























Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n:i32 = read();
    println!("{}",n*n);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;

int main(){
  string a;
  cin >> a;
  int n=a.size();
  int cnt=0;
  rep(i,n){
    if((i%2==0&&a[i]=='0')||(i%2==1&&a[i]=='1'))cnt++;
  }
 // cout << cnt << endl;
  cout << min(cnt,n-cnt) << endl;
}

Measured memory_bytes: 512
S = list(input())
T = list(input())

from collections import Counter
cs = Counter(S)
ct = Counter(T)

anss = ['Yes','No']
ans = 0
if len(cs.keys()) != len(ct.keys()): ans = 1
else:
    As = sorted(cs.values())
    At = sorted(ct.values())
    for i in range(len(cs.keys())):
        if As[i] != At[i]:
            ans = 1
            break
print(anss[ans])

Measured memory_bytes: 6704
def main():
    n = int(input())
    c = [0,0,0,0]
    for i in range(n):
        s = input()
        if s == 'AC':
            c[0] += 1
        elif s  == 'WA':
            c[1] += 1
        elif s == 'TLE':
            c[2] += 1
        elif s == 'RE':
            c[3] += 1
    print("AC x {}".format(c[0]))
    print("WA x {}".format(c[1]))
    print("TLE x {}".format(c[2]))
    print("RE x {}".format(c[3]))

if __name__=='__main__':
    main()


Measured memory_bytes: 9068
#include <stdio.h>

#define F(a)	((a) * (a))

int main(void)
{
	int ans;
	int x;
	int y;
	int input;
	
	while (scanf("%d", &input) != EOF){
		ans = 0;
		for (x = input; x < 600; x += input){
			ans += input * F(x);
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += b[a[i]];
        if (i != 0 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1]];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N, T;
    cin >> N >> T;
    int ans = 10000;
    int c, t;
    lpn(i, N)
    {
        cin >> c >> t;
        if (t>T) continue;
        ans = min(ans, c);
    }
    if (ans == 10000) cout << "TLE";
    else cout << ans;
    cout << endl;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    while(a[i]%2==0) {
      ++ans;
      a[i]/=2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());
	
	int res = 0;
	for (auto i = l.end() - 1; i > l.begin() + 1; i--) {
	for (auto j = l.begin();   j < i;			  j++) {
		//if (i == j) continue;
		auto it = upper_bound(j + 1, i, *i - *j);
		if (it != i) {
			res += (int)(i - it);
			//cout << "*i=" << *i << " *j=" << *j << " *it=" << *it << " res=" << res << endl;
		}
	}
	//cout << endl;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long int answer=0;
    cin >> N;
    for(int i=1;i<N+1;i++){
        answer+=i;
        if(i%3 == 0 || i%5 == 0){
            answer-=i;
        }
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;cin>>N;
    ll ans1,ans2;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ans1=A[0];
    vector<pair<ll,ll>>B(N);
    rep(i,N){
        B[i].second=A[i];
        B[i].first=min(A[i],ans1-A[i]);
    }
    sort(B.begin(),B.end());
    ans2=B[N-1].second;
    if(ans2==ans1){
        ans2=B[N-2].second;
    }
    cout<<ans1<<" "<<ans2<<endl;
}

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


int main(){
int H,W;
int h,w;
cin >> H >> W;
cin >> h >> w;
cout << H*W-(h*W+w*H-h*w) << endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  char p[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> p[i][j];
    }
  }
  for(int i = 0; i < w+2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < h; i++){
    cout << "#";
    for(int j = 0; j < w; j++){
      cout << p[i][j];
    }
    cout << "#" << endl;
  }
  for(int i = 0; i < w+2; i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 3608
def match(S,pat):
    i = 0
    for s in S:
        if s == pat[i]:
            i += 1
        if i == 3:
            return True
    return False

N = int(input())
S = input()
ans = 0

for n in range(1000):
    s = str(n)
    if len(s) == 1:
        s = '00'+s
    elif len(s) == 2:
        s = '0'+s
    else:
        pass
    if  match(S,s):
        ans += 1
    
print(ans)

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------
using pd = pair<ld, ld>;

template <typename T, typename U> class dijkstra {
public:

    struct edge {
        T to;
        U cost;
    };

    typedef pair<U, T> P;
    map<T, vector<edge> > E;
    map<T, U> d;

    void calc(T s) {
        priority_queue <P, vector<P>, greater<P> > que;
        REP(i, -1, limit) d[i] = LINF;
        que.emplace((U) 0, s);
        d[s] = 0;
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            T v = p.second;
            if (d[v] < p.first) continue;

            for (auto& e : E[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.emplace(d[e.to], e.to);
                }
            }
        }
    }
};

struct query {
    ld x, y, r;
};

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

    dijkstra<int, ld> ds;
    map<int, query> Q;

    ld xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    Q[-1] = {xs, ys, 0.0};
    Q[n] = {xt, yt, 0.0};

    rep(i, n) {
        ld xi, yi, ri;
        cin >> xi >> yi >> ri;
        Q[i] = {xi, yi, ri};
    }

    for (int i = -1; i <= n; ++i) for (int j = -1; j <= n; ++j) {
            if (i == j) continue;
            ld c = max((ld) 0, sqrt((Q[i].x - Q[j].x)*(Q[i].x - Q[j].x) + (Q[i].y - Q[j].y)*(Q[i].y - Q[j].y))
                    - Q[i].r - Q[j].r);
            ds.E[i].push_back({j, c});
        }

    ds.calc(-1);
    cout << setprecision(20) << ds.d[n] << endl;

    return 0;
}


Measured memory_bytes: 50672
package main

import (
	"fmt"
	"sort"
)

type grid struct {
	x int
	y int
}

func main() {
	var input string
	fmt.Scan(&input)

	var x, y int
	fmt.Scan(&x)
	fmt.Scan(&y)

	a := 0
	tate := 0
	xs := make([]int, 0)
	ys := make([]int, 0)
	for _, command := range input {
		if command == 'F' {
			a++
		} else {
			if tate == 0 {
				x = x - a
				tate = -1
			} else if tate == -1 {
				ys = append(ys, a)
				tate = 1
			} else if tate == 1 {
				xs = append(xs, a)
				tate = -1
			}
			a = 0
		}
	}
	if tate == 0 {
		x = x - a
		tate = -1
	} else if tate == -1 {
		ys = append(ys, a)
		tate = 1
	} else if tate == 1 {
		xs = append(xs, a)
		tate = -1
	}

	ansX := 0
	ansY := 0
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
	sort.Sort(sort.Reverse(sort.IntSlice(ys)))

	for _, po := range xs {
		if ansX > x {
			ansX -= po
		} else {
			ansX += po
		}
	}

	for _, po := range ys {
		if ansY > y {
			ansY -= po
		} else {
			ansY += po
		}
	}

	ans := ansX == x && ansY == y

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    
int N;
cin >> N;
int a;
int oddnumber=0;
rep(i,N){
    cin >> a;
    if(a%2==1){
    oddnumber++;
    }
}

if(oddnumber%2==0){
    cout <<"YES"<<endl;
}
else{
    cout << "NO"<<endl;
}


 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

ll calc_gcd(ll a, ll b) {
  while (true)
    if (a)
      b %= a, swap(a, b);
    else
      return b;
}

ll calc_lcm(ll a, ll b) { return a * b / calc_gcd(a, b); }

void solve() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  rep (i, N) cin >> A[i];

  rep (i, N) A[i] /= 2;
  // Ak * (2*p + 1)

  ll lcm = 1;
  rep (i, N) {
    lcm = calc_lcm(lcm, A[i]);
    if (lcm > M) {
      cout << 0 << endl;
      return;
    }
  }

  rep (i, N) {
    ll tmp = lcm / A[i];
    if (tmp % 2 == 0) {
      cout << 0 << endl;
      return;
    }
  }

  ll ans = M / lcm;
  ans = (ans + 1) / 2;

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }
    else if(a<b){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  ll h[n];
  for(ll i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  reverse(h,h+n);
  
  for(ll i=0;i<n;i++){
    if(i<k){
      continue;
    }else{
      ans = ans + h[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5192
#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 d;
  cin >> d;
  if (d == 25) cout << "Christmas" << endl;
  else if (d == 24) cout << "Christmas Eve" << endl;
  else if (d == 23) cout << "Christmas Eve Eve" << endl;
  else  cout << "Christmas Eve Eve Eve" << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static int total;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            MergeSort(A, 0, n);
            Console.WriteLine(string.Join(" ", A));
            Console.WriteLine(total);
        }

        static void Merge(int[] A, int left, int mid, int right)
        {
            var n1 = mid - left;
            var n2 = right - mid;
            var L = new int[n1 + 1];
            var R = new int[n2 + 1];

            for (var i = 0; i < n1; i++) L[i] = A[left + i];
            for (var i = 0; i < n2; i++) R[i] = A[mid + i];

            L[n1] = int.MaxValue;
            R[n2] = int.MaxValue;
            int x = 0, y = 0;

            for ( var k = left; k < right; k++)
            {
                if (L[x] <= R[y])
                {
                    A[k] = L[x];
                    x++;
                }
                else
                {
                    A[k] = R[y];
                    y++;
                }
                total++;
            }
        }

        static void MergeSort(int[] A, int left, int right)
        {
            if (left + 1 < right)
            {
                var mid = (left + right) / 2;
                MergeSort(A, left, mid);
                MergeSort(A, mid, right);
                Merge(A, left, mid, right);
            }
        }
    }
}



Measured memory_bytes: 84728
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int A, B, C, X;
int ans = 0;

int main()
{

	IN >> A >> B >> C >> X;

	LEP(a, A + 1)
	{
		LEP(b, B + 1)
		{
			LEP(c, C + 1)
			{
				if (a * 500 + b * 100 + c * 50 == X)
					ans++;
			}
		}
	}

	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
dict = {}

for i in range(q):
  temp = int(input())
  if temp in dict.keys():
    dict[temp] += 1
  else:
    dict.setdefault(temp, 1)
    
for i in range(1, n+1):
  if i not in  dict.keys():
    if k - q > 0:
      print('Yes')
    else:
      print('No')
  else:
    if k + dict[i] - q > 0:
      print('Yes')
    else:
      print('No')

Measured memory_bytes: 9064
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <sstream>

using namespace std;

vector<string> split20190517(const string &s, char delimiter) {
    vector<string> elements;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delimiter)) {
        if (!item.empty()) {
            elements.push_back(item);
        }
    }
    return elements;
}

 int stringToInt20190517(string str) {
    int number = atoi(str.c_str());
    return number;
}

int main() {
    string s;
    cin >> s;
    vector<string> strArray = split20190517(s, '/');

    int year = stringToInt20190517(strArray[0]);
    int month = stringToInt20190517(strArray[1]);
    int day = stringToInt20190517(strArray[2]);

    if (year <= 2019 && month <= 4 && day <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

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

main()
{
    const int mod=998244353;
    int n; cin>>n;
    int S; cin>>S;
    long long dp[6666]={};
    dp[0]=1;
    for(int i=0; i<n; ++i) dp[0]=dp[0]*2%mod;
    long long inv2=(mod+1)/2;
    for(int i=0; i<n; ++i)
    {
        int a; cin>>a;
        for(int x=S; x>=a; --x)
        {
            dp[x]+=dp[x-a]*inv2;
            dp[x]%=mod;
        }
    }
    cout << dp[S] << "\n";
}

Measured memory_bytes: 3700
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
      
        if (3200 <= a) {
            System.out.println(s);
            
        } else {
            System.out.println("red");
            
        }


    }
}

Measured memory_bytes: 21972
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll x, n;
set<ll> st;
int main() {
	io(); cin >> n;
	rep(i, 1, n) {
		cin >> x;
		st.insert(x);
	}
	if (st.size() == n) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;

  vector<bool>has(n+1,false);

  for(int i=1;i<=k;i++){
     int d;
     cin>>d;
     while(d--){
       int a;
       cin>>a;
       has[a]=true; 
     }
  }
 int ans=0;
  for(int i=1;i<=n;i++){
   if(!has[i]){
       ans++;
   }
  }
  cout<<ans<<endl;
  
     
  return 0;
}


Measured memory_bytes: 3660
a = list(map(int, input().rstrip().split()))
A = a[0]
B = a[1]
C = a[2]
D = a[3]

while True:
    C -= B
    if C <= 0:
        print('Yes')
        break

    A -= D
    if A <= 0:
        print('No')
        break

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> memo;
    while (n)
    {
        int r = n % (-2);
        if (r < 0)
            r *= -1;
        n = (n - r) / -2;
        memo.push_back(r);
        if (n == 0)
        {
            break;
        }
    }

    string ans;
    for (int i = memo.size() - 1; i >= 0; i--)
    {
        ans += to_string(memo[i]);
    }
    if (ans == "")
        ans = "0";
    cout << ans << endl;
    return 0;
}

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


#define ll long long
#define pii pair<int,int >
#define pll pair<long long ,long long >
#define pbb pair<bool,bool>
#define plll pair<long long,pair<long long ,long long > > 
#define sefi second.first
#define sese second.second
#define fi first
#define se second
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) x.size()
#define cont continue
//#define int long long 

const long long  md = 1e9 + 9;
const int Inf = 1e9;
const ll Inf64 = 1e18;
const ll MaxN = 1e5 + 10;
const ll MaxM = 11;
const ld eps = 1e-15;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { 1,0,-1,0 };
const ll ddx[4] = { 1,1,-1,-1 };
const ll ddy[4] = { 1,-1,1,-1 };

using namespace std;

ll gcd(ll a, ll b) {
	while (a) {
		b %= a;
		swap(a, b);
	}
	return b;
}
ll gcdex(ll a, ll mod = md) {
	ll g = mod, r = a, x = 0, y = 1;
	while (r != 0) {
		ll q = g / r;
		g %= r;
		swap(g, r);
		x -= q * y;
		swap(x, y);
	}
	return x < 0 ? x + mod : x;
}

ll binpow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) {
			res *= a;
			res %= md;
		}
		a *= a;
		a %= md;
		n >>= 1;
	}
	return res % md;
}
// /
/// ////
// ///////



signed main() {
	ios_base::sync_with_stdio(0);
	//ifstream cin("penalty.in");
	//ofstream cout("penalty.out");
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	// //
	//cout << fixed,cout.precision(10);
	// //

	
	ll N, M;
	cin >> N >> M;
	if (M == 1) cout << 0;
	else {
		N -= M;
		cout << N;
	}


	/// ///////////////
	cerr << '\n' << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << '\n';

	return 0;

}
/*


*/

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int cnt[4];
	fill(cnt, cnt + 4, 0);

	for(int i = 0; i < s.length(); i++){
		if(s.at(i) == 'E') cnt[0]++;
		else if(s.at(i) == 'W') cnt[1]++;
		else if(s.at(i) == 'S') cnt[2]++;
		else cnt[3]++;
	}

	for(int i = 0; i < 4; i++){
		if(cnt[i] != 0) cnt[i] = 1;
	}

	if((cnt[0] + cnt[1] == 1) || (cnt[2] + cnt[3] == 1)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int,input().split()))
last_di = [0] * 26
for d in range(1, D+1):
    s = list(map(int,input().split()))
    satisfaction_list = [0] * 26
    for i in range(26):
        satisfaction_list[i] = c[i] - (d - last_di[i])
    min_index = satisfaction_list.index(min(satisfaction_list))
    print(min_index + 1)


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

int main(){
  string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
     }
  if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  if(S=="Rainy"){
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int m, d;
	while(cin >> m >> d) {
		int ans = 0;
		for(int i = 1; i <= m; i++) {
			for(int j = 22; j <= d; j++) {
				if(j%10 < 2)
					continue;
				if((j/10)*(j%10) == i) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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



int main(){
    int N,K;
    cin>>N>>K;
    out((N%K==0?0:1));
}

Measured memory_bytes: 256
#include <algorithm> 
#include <iostream> 
#include <string>
using namespace std; 
int main(){
long long int max=0,sam=0,n;
string s;
cin>>n>>s;
for(int i=0;i<s.size();i++){
if(s[i]=='I'){
sam++;
}else{
sam--;
}
if(max<sam){
max=sam;
}
}
cout<<max<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
MOD = 10**9 + 7
ans = 0
temp1 = 0
temp2 = 0
for i in range(n):
    temp1 += i*x[i] -(n-(i+1))*x[i]
    temp1 %= MOD

for i in range(m):
    temp2 += i*y[i] -(m-(i+1))*y[i]
    temp2 %= MOD

ans = temp1*temp2
ans %= MOD
print(ans)

Measured memory_bytes: 18624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Objects;

class Puddle {
    int pos;
    int area;

    Puddle(int pos, int area) {
        this.pos = pos;
        this.area = area;
    }
}

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            Deque<Integer> downStack = new LinkedList<>();
            Deque<Puddle> puddleStack = new ArrayDeque<>();

            char[] line = in.readLine().toCharArray();
            int A = 0;
            for (int i = 0; i < line.length; i++) {
                char c = line[i];
                if (c == '\\') {
                    downStack.addFirst(i);
                } else if (c == '/') {
                    if (downStack.isEmpty()) continue;

                    int downPos = downStack.removeFirst();
                    int area = i - downPos;
                    A += area;
                    while (!puddleStack.isEmpty() && puddleStack.peekFirst().pos > downPos) {
                        area += puddleStack.removeFirst().area;
                    }

                    puddleStack.addFirst(new Puddle(downPos, area));
                }
            }

            int k = puddleStack.size();
            String[] L = new String[puddleStack.size()];
            for (int i = 0; i < k; i++) {
                L[i] = String.valueOf(Objects.requireNonNull(puddleStack.pollLast()).area);
            }

            System.out.println(A);

            StringBuilder sb = new StringBuilder();
            sb.append(k);
            if (k > 0) {
                sb.append(" ");
                sb.append(String.join(" ", L));
            }
            System.out.println(sb.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 25964
N = int(input())
A =list(map(int, input().split()))
minus = [i for i in A if i < 0]
if len(minus) % 2 == 0:
  max_num = [abs(i) for i in A]
  print(sum(max_num))
else:
  max_num = [abs(i) for i in A]
  print(sum(max_num) - (2*min(max_num)))

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(k>=max({a,b,c,d,e})-min({a,b,c,d,e}))
    cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n,x = list(map(int, input().split()))
    l = list(map(int, input().split()))

    d = 0
    count = 1
    for i in range(n):
        d = d + l[i]
        if(d <= x):
            count += 1
        
    print(count)




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

bool prime_check(ll x){
	bool flag = true;
	if(x==1) flag = false;
	ll sqx = sqrt(x)+1;
    for(ll j=2;j<sqx+1;j++){
    	if(x==j) continue;
        if(x%j==0){
            flag = false;
            break;
        }
    }
    return flag;
}

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

    ll N;
    cin >> N;

    ll cnt = 0;
    REP(i, 55555+1){
    	if(i>=2 && prime_check(i) && i%5==1){
    		cout << i << " ";
    		cnt++;
    	}
    	if(cnt==N) break;
    }
    cout << endl;
    return 0;
}

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

cur = 0
ans1 = 0
for i in range(N):
    cur += a[i]
    if i % 2:
        if cur <= 0:
            ans1 += -cur + 1
            cur = 1
    else:
        if cur >= 0:
            ans1 += cur + 1
            cur = -1
cur = 0
ans2 = 0
for i in range(N):
    cur += a[i]
    if i % 2:
        if cur >= 0:
            ans2 += cur + 1
            cur = -1
    else:
        if cur <= 0:
            ans2 += -cur + 1
            cur = 1
print(min(ans2,ans1))

Measured memory_bytes: 14468
N, Y = map(int, input().split())

for y10k in range(N + 1):
	for y5k in range(N + 1):
		if N < y10k + y5k:
			break
		y1k = N - (y10k + y5k)
		if Y == 10000 * y10k + 5000 * y5k + 1000 * y1k:
			print(y10k, y5k, y1k)
			exit()
else:
	print(-1, -1, -1)


Measured memory_bytes: 3060
// failed to generate code
 
#include <bits/stdc++.h>
using namespace std;
 
int best[100010] = {};
int main(){
	int N,T;
	cin >> N >> T;
	
	int mn = 1e9;
	int mx = 0;
	for(int i = 0 ; i < N ; i++){
		int A;
		cin >> A;
		best[i] = A - mn;
		mx = max(mx,best[i]);
		mn = min(A,mn);
	}
	int ans = 0;
	for(int i = 0 ; i < N ; i++){
		if( best[i] == mx ) ans++;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func min(x, y int) int {
	if x <= y {
		return x
	}
	return y
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	set := n / (a + b)
	ans := set * a
	mod := n % (a + b)
	ans += min(mod, a)
	fmt.Println(ans)
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
num = [0 for i in range(10**5)]
sum = 0
for i in range(len(A)):
    num[A[i]-1] += 1
    sum += A[i]
Q = int(input())
for i in range(Q):
    B, C = map(int,input().split())
    sum += num[B-1] * (C-B)
    num[C-1] += num[B-1]
    num[B-1] = 0
    print(sum)

Measured memory_bytes: 20840
const main = (input) => {
  const [n, ...rows] = input.trim().split('\n')
  const k = ['AC', 'WA', 'TLE', 'RE']
  const ans = {}
  for (let v of k) ans[v] = 0

  for (let r of rows) ans[r] += 1

  for (let v of k) console.log(`${v} x ${ans[v]}`)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 44300
#include <iostream>
    using namespace std;
     
    int main()
    {
      int n;
      cin >> n;
      int ans = 0;
      for(int i = 105; i <= n; i += 2)
      {
        int k = 2;
        for(int j = 3; j < i; j += 2)
        {
          if(i % j == 0)
          {
            k++;
          }
        }
        if(k==8)
        {
          ans++;
        }
      }
      cout << ans << endl;
    }

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    cin >> s;

    bool f=true;
    char tmp=s[0];
    rep(i, s.size()) {
        if (tmp != s[i]) f=false;
    }
    if (f) {
        cout << 0 << endl;
        return 0;
    }

    map<char, int> mp;
    rep(i, s.size()) mp[s[i]]++;
    int ret=1e8;
    string S = s;
    for (auto m : mp) {
        char ch = m.first;
        s = S;
        int ans=0;
        while (true) {
            string t = "";
            bool ok = true;
            rep(i, s.size()-1) {
                if (s[i] == ch or s[i+1] == ch) {
                    t += ch;
                }
                else {
                    t += s[i];
                }
            }
            ans++;
            rep (i, t.size()) {
                if (t[i] != ch) ok = false;
            }
            s = t;
            if (ok) break;
        }
        ret = min(ret, ans);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  int[] nk = readNums!int[];

  if(nk[1] == 1){
    writeln("0");
  } else {
    nk[0] -= nk[1];
    writeln(nk[0]);
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    int result1, result2, result3, max1, max2;

    cin >> a >> b;

    result1 = a + b;
    result2 = a - b;
    result3 = a * b;

    max1 = max(result1, result2);
    max2 = max(max1, result3);

    cout << max2 << endl;

    return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	pair<long long, long long> a[n];
	for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	long long ans = 0;
	int i = 0;
	while (m > 0) {
		if (m >= a[i].second) {
			ans += a[i].first * a[i].second;
			m -= a[i].second;
		}
		else {
			ans += a[i].first * m;
			m = 0;
		}
		i++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;

struct ca
{
  long  si,ei;
};


int binarySearch(vector<int> arr, int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
         
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
       
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    
    return -1; 
} 

int prime[1000001]={};

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

void pr()
{
  prime[1]=0;

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

}

int countSetBits( int n) 
{ 
     int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 

long sum=0;




int main()
{

  //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

   //pr();
  int t;
   //cin>>t;
  t=1;
  int id=1;

  while(t--)
{
    unordered_map<string,int> mr;

     int n;
      cin>>n;
     int cnt=0;
    for(int i=0;i<n;i++)
   {
      string s;
       cin>>s;

       if(mr.find(s)==mr.end())
     {
           cnt++;
           mr.insert(make_pair(s,1));
     }
    }

   cout<<cnt;
}

     
   


return 0;
}


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

int main() {
  while(1) {
    int m, f, r;
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) {
      break;
    }
    if(m == -1 || f == -1) {
      cout << "F" << endl;
    } else if((m + f) >= 80) {
      cout << "A" << endl;
    } else if(m + f >= 65) {
      cout << "B" << endl;
    } else if(m + f >= 50) {
      cout << "C" << endl;
    } else if(m + f >= 30) {
      if(r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else {
      cout << "F" << endl;
    }
  }
  return 0;
}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}


class UnionFind {
public:
	vector<ll> parent;

	UnionFind(int n) {
		parent = vector<ll>(n, -1);
	}

	int root(int a) {
		if (parent[a] < 0) return a;
		return parent[a] = root(parent[a]);
	}

	int size(int a) {
		return -parent[root(a)];
	}

    bool same(int x, int y){
        return root(x) == root(y);
    }

	bool unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) {
			return false;
		}

		if (size(a) < size(b)) swap(a, b);

		parent[a] += parent[b];
		parent[b] = a;

		return true;
	}
};


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);

    int num = n;
    rep(i, m){
        int x, y, z;
        cin >> x >> y >> z;
        if(uf.unite(x, y)) --num;
    }
    ppp(num);
    return 0;
}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10**9)

INF = 10**12
LIM = 20
N = int(input())
D = dict()
for _ in range(N):
    s, c = input().split()
    if s in D.keys():
        D[s] = min(D[s], int(c))
    else:
        D[s] = int(c)

def check_kaibun(s):
    n = len(s)
    return all(s[i] == s[-i-1] for i in range(n//2))

def calc_cost(use):
    return sum(D[s] * n for (s, n) in use.items())

def find_candidate(cost, use, s, is_left):
    if check_kaibun(s):
        return min(cost, calc_cost(use))

    if is_left:
        for t in D.keys():
            # reversed s is included in the end of t
            if t[::-1].find(s) == 0:
                use[t] += 1
                if use[t] > LIM:
                    return INF
                c = find_candidate(cost, use, t[:-len(s):], False)
                cost = min(cost, c)
                use[t] -= 1
            # reveresed t is included in the begin of s
            elif s.find(t[::-1]) == 0:
                use[t] += 1
                c = find_candidate(cost, use, s[len(t):], True)
                cost = min(cost, c)
                use[t] -= 1
    else:
        for t in D.keys():
            # t is included in the end of reversed s
            if s[::-1].find(t) == 0:
                use[t] += 1
                c = find_candidate(cost, use, s[:-len(t):], False)
                cost = min(cost, c)
                use[t] -= 1
            # s is included in the begin of reveresed t
            elif t.find(s[::-1]) == 0:
                use[t] += 1
                c = find_candidate(cost, use, t[len(s):], True)
                cost = min(cost, c)
                use[t] -= 1

    return min(cost, INF)

def solve():
    ans = INF
    for s in D.keys():
        use = {s: 0 for s in D.keys()}
        use[s] = 1
        ans = find_candidate(ans, use, s, True)
    return ans if ans < INF else -1

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9344
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(ns())
M=[0]
M2=[-1]
ans=[0]*len(S)


for i in range(len(S)-1):
    if(S[i]=='R' and S[i+1]=='L'):
        M.append(i)
    if(S[i]=='L' and S[i+1]=='R'):
        M2.append(i)

M2.append(len(S)-1)

for i in range(1,len(M)):
    ans[M[i]]=(M[i]-M2[i-1])//2+(M[i]-M2[i-1])%2+(M2[i]-M[i])//2
    ans[M[i]+1]=(M[i]-M2[i-1])//2+(M2[i]-M[i])//2+(M2[i]-M[i])%2
print(*ans)



Measured memory_bytes: 10940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-5;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    ll a,b,n; cin >> a >> b >> n;
    ll x = min(b-1,n);
    ll ans = a*x/b-a*(x/b);
    cout << ans << endl;
}   

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
    string s;
    getline(cin, s);

    for (char& c : s) {
        if (islower(c)) {
            c = (char) toupper(c);
        } else if (isupper(c)) {
            c = (char) tolower(c);
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1184
dict = {}

def insert(word):
    global dict

    dict[word] = 0

def find(word):
    global dict
    if word in dict:
        print('yes')
    else:
        print('no')

def main():
    N = int(input())
    order = [list(input().split()) for _ in range(N)]

    for i in range(N):
        if order[i][0] == 'insert':
            insert(order[i][1])
        elif order[i][0] == 'find':
            find(order[i][1])

main()



Measured memory_bytes: 248112