akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
    int N;
    int ans=0;
    int flag[110]={0};
    cin>>N;
    for(int i=0;i<N;i++){
        int d;
        cin>>d;
        flag[d] = 1;
    }
    for(int i=0;i<110;i++){
        ans += flag[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N, A, B;

    std::cin >> N;

    if (N == 1)
    {
        std::cout << "Hello World" << std::endl;
    }

    if (N == 2)
    {
        std::cin >> A;
        std::cin >> B;

        std::cout << A + B << std::endl;
    }

    return 0;
}


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

int[200][200] mk_map()
{
    int[200][200] ret;
    foreach (ref e; ret) e = int.max / 3;
    return ret;
}

int[200][200] MAP = mk_map();

void main()
{
    auto nmr = readln.split.to!(int[]);
    auto N = nmr[0];
    auto M = nmr[1];
    auto R = nmr[2];
    auto rs = readln.split.map!(s => s.to!int - 1).array;

    foreach (_; 0..M) {
        auto abc = readln.split.to!(int[]);
        auto a = abc[0] - 1;
        auto b = abc[1] - 1;
        auto c = abc[2];
        MAP[a][b] = c;
        MAP[b][a] = c;
    }

    foreach (_; 0..N)
        foreach (i; 0..N)
            foreach (j; 0..N)
                foreach (k; 0..N)
                    if (MAP[i][j] > MAP[i][k] + MAP[k][j])
                        MAP[i][j] = MAP[i][k] + MAP[k][j];

    int[string][200] MEMO;
    int solve(int before, int[] rest) {
        if (rest.empty) return 0;
        auto key = rest.to!string;
        if (before != -1 && key in MEMO[before]) return MEMO[before][key];
        int min_ret = int.max;
        foreach (i, next; rest) {
            int ret;
            if (before >= 0) ret = MAP[before][next];
            ret += solve(next, rest[0..i] ~ rest[i+1..$]);
            min_ret = min(min_ret, ret);
        }
        if (before == -1) return min_ret;
        return MEMO[before][key] = min_ret;
    }

    writeln(solve(-1, rs));
}

Measured memory_bytes: 1532
W, H ,N = map(int,input().split())
#白い部分の長方形の左右上下を設定
r = W
l = 0
m = H
n = 0
#左右上下を入力の度に更新
for _ in range(N):
    x, y , a = map(int,input().split())
    if a == 1:
        l = max(x,l)
    if a == 2:
        r = min(x,r)
    if a == 3:
        n = max(y,n)
    if a == 4:
        m = min(y,m)
#長方形ができないときは面積０だよ
if l >= r or n >= m:
    print(0)
else:
    print((r-l)*(m-n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, sum = 0, ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    int b = sum / N;
    if (abs(b * N - sum) >= abs((b + 1) * N - sum)) {
        b = b + 1;
    }
    for (int i = 0; i < N; i++) {
        ans += (b - A.at(i)) * (b - A.at(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed); cout.precision(18)
typedef long long ll;
typedef long double ld;

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);
	int x,y;
	cin>>x>>y;
	cout<<x+(y/2)<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int n,a[210];
int num[5];

const ll mod = 1000000007LL;

ll coef[5];
ll ans = 0LL;

ll dp[210][810];
ll ten[810];
ll P[210][210];
ll C[210][210];

void init(){
	rep(i,201)rep(j,i+1){
		if(j==0 or j==i)
			C[i][j]=1LL;
		else
			C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
	}

	rep(i,201)rep(j,i+1){
		if(j==0)
			P[i][j]=1LL;
		else
			P[i][j] = (i+1-j) * P[i][j-1] %mod;
	}

	ten[0] = 1LL;
	rep(i,1,801) ten[i] = 10LL * ten[i-1] %mod;
}

void func(int tar){
	if(num[tar]==0) return;
	num[tar]--;

	rep(i,210)rep(j,810) dp[i][j]=0LL;
	dp[0][0] = 1LL;

	rep(len,1,5){
		rep(loop,num[len]){
			rrep(j,n+1)rep(k,4*n+1){
				if(dp[j][k]==0) continue;
				dp[j+1][k+len] += 1LL * (j+1) * dp[j][k] % mod;	
				dp[j+1][k+len] %= mod;
			}
		}
	}

	coef[tar] = 0LL;

	const int m = n - 1 - num[0];

	rep(rnzero,m+1)rep(len,4*m+1){
		if(dp[rnzero][len]==0) continue;
		const int restnzero = m - rnzero;

		rep(lnzero,m-rnzero+1){
			rep(rzero,num[0]+1){
				rep(lzero,num[0]-rzero+1){

					ll cur = dp[rnzero][len];
					cur = 1LL * cur * ten[len + rzero] % mod;

					cur = 1LL * cur * P[restnzero][lnzero] % mod;
					cur = 1LL * cur * P[rnzero+rzero][rzero] % mod;

					if(lnzero == 0 and lzero == 0)
						cur = 1LL * cur;	
					else if(lnzero == 0  and lzero > 0)
						cur = 0;
					else
						cur = 1LL * cur * P[lnzero-1+lzero][lzero] % mod;

					//cerr << lnzero << " " << rnzero << " " << len << " " << lzero << " " << rzero << " " << cur << endl;

					coef[tar] = (coef[tar] + cur) % mod;
				}
			}
		}
	}
	num[tar]++;
}


int main(void){
	init();
	cin >> n;
	rep(i,n) cin >> a[i];

	rep(i,n){
		string tmp = to_string(a[i]);
		if(tmp == "0")
			num[0]++;
		else
			num[tmp.size()]++;
	}

	rep(i,1,5) func(i);

	//cerr << coef[1] << " " << coef[2] << " " << coef[3] << " " << coef[4] << endl;

	rep(i,n){
		string tmp = to_string(a[i]);
		if(tmp == "0") continue;
		ans += 1LL * coef[tmp.size()] * a[i] % mod;
		ans %= mod;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	lli m;
	cin>>n>>m;
	map<lli,vector<lli>> d;
	lli data[100100];
	REP(i,0,100100)data[i]=0;
	REP(i,0,m){
		lli a,b;
		cin>>a>>b;
		d[a].push_back(b);
		d[b].push_back(a);
		data[a]++;
		data[b]++;
	}

	REP(i,0,100100){
		if(data[i]%2!=0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;

	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    rep(i, 0, s.size()/2){
        if(s[i] != s[s.size()-i-1]){
            ans = "No";
        }
    }
    string a;
    rep(i, 0, (s.size()-1) / 2){
        a += s[i];
    }
    //cout << a << endl;
    rep(i, 0, a.size()/2){
        if(a[i] != a[a.size()-i-1]){
            ans = "No";
        }
    }
    reverse(s.begin(), s.end());
    //cout << s << endl;
    string b;
    rep(j, 0, (s.size()-1) / 2){
        b += s[j];
    }
    //cout << b << endl;
    rep(i, 0, b.size()/2){
        if(b[i] != b[a.size()-i-1]){
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000003 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> cnt(n, 0);
	vector<pair<int, pii>> v(m);
	cu(i,0,m){
		cin >> v[i].S.F >> v[i].F;
		v[i].S.S = i;
	}
	sort(all(v));
	vector<pii> ans(m);
	cu(i,0,m){
		++cnt[v[i].S.F];	
		ans[v[i].S.S].F = cnt[v[i].S.F];
		ans[v[i].S.S].S = v[i].S.F;
	}
	cu(i,0,m)printf("%06d%06d\n",ans[i].S,ans[i].F);
}


Measured memory_bytes: 3840
import java.util.*;
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s =sc.next();
    int ans = 999;
    for(int i=0;i<s.length()-2;i++) {
      //System.err.println(s.substring(i, i+3));
      String temp = s.substring(i, i+3);
      int digit = Integer.valueOf(temp);
      if(digit <= 753) {
        ans = Math.min(ans, 753-digit);
      } else {
        ans = Math.min(ans, digit-753);
      }
    }
    System.out.println(ans);
  }
}


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

int main(){
	
	int i, j, input[5];
	
	for(i=0; i<5; i++) cin >> input[i];
	
	sort(input, input+5, greater<int>());
	
	cout << input[0];
	
	for(j=1; j<5; j++) cout << " " << input[j];
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 1176
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
  ll n;cin>>n;cout<<3*n*n<<endl;
}


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

using namespace std;

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

    int cnt=0;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            s[i]^=1;
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b; cin >> a >> b;
    ll p = (a-1)/50 + 1;
    ll q = (b-1)/50 + 1;
    ll h = p*2 + q*2;
    ll w = 100;
    cout << h << " " << w << endl;
    ll siro = a-1;
    ll kuro = b-1;
    char s[h][w];
    for(ll i=0; i<p*2; i += 2){
        rep(j,w){
            if(j%2 == 0){
                if(siro > 0){
                    s[i][j] = '.';
                    siro--;
                }else{
                    s[i][j] = '#';
                }
            }else{
                s[i][j] = '#';
            }
        }
        rep(j,w) s[i+1][j] = '#';
    }
    for(ll i=2*p; i<h-1; i+=2){
        rep(j,w) s[i][j] = '.';
        rep(j,w){
            if(j%2 == 0){
                if(kuro > 0){
                    s[i+1][j] = '#';
                    kuro--;
                }else{
                    s[i+1][j] = '.';
                }
            }else{
                s[i+1][j] = '.';
            }
        }
    }
    rep(i,h){
        rep(j,w) cout << s[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <deque>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define maxn 200010

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n;
LL a[maxn];
deque<LL> d;

int main() {
  GI(n);
  FORN(i, n) GLL(a[i]);

  bool front = true;
  FORN(i, n) {
    if (front) d.push_front(a[i]);
    else d.push_back(a[i]);

    front = !front;
  }

  if (n%2) {
    for (auto dd : d) {
      printf("%lld ", dd);
    }
  } else {
    for (auto it = d.rbegin(); it != d.rend(); it++) {
      printf("%lld ", *it);
    }
  }
  printf("\n");
    
  return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<vector>
using namespace std;

int n, m, r;
vector<int> l;
int d[200][200];
int ans = 1e9;

void solve(int x, int sum, vector<int> v) {
    if (v.empty()) ans = (ans < sum) ? ans : sum;
    else {
        for (auto &i : v) {
            vector<int> w;
            for (auto &j : v) {
                if (j != i) w.push_back(j);
            }
            if (v.size() == r) solve(i, 0, w);
            else solve(i, sum + d[x][i], w);
        }
    }
}

int main() {
    scanf("%d %d %d", &n, &m, &r);
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            d[i][j] = 1e9;
            d[j][i] = 1e9;
        }
    }
    for (int i = 0; i < r; i++) {
        int x;
        scanf("%d", &x);
        l.push_back(x - 1);
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = (d[i][j] < d[i][k] + d[k][j]) ?
                          d[i][j] :
                          d[i][k] + d[k][j];
            }
        }
    }
    
    solve(0, 0, l);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(a) (a).begin(),(a).end()
// #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
// int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int n; cin >> n;
  int m; cin >> m;

  vector<int> v(m);
  for (auto it = v.begin(); it < v.end(); ++it) *it = 0;

  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    for (int j = 0; j < k; ++j) {
      int a; cin >> a;
      v[a - 1]++;
    }
  }

  for (int i = 0; i < m; ++i) {
    if (v[i] == n) ++num;
  }
  
  // array<int, SIZE> a;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) cin >> *it;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) num += *it;

  cout << num << endl;
  return 0;
}


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

using namespace std;

long long oddsolve(long long a){return (a+1)/2%2;}

long long solve(long long a){
  if (a%2==1) return oddsolve(a);
  else return oddsolve(a+1)^(a+1);
}

int main(){
  long long A,B; cin>>A>>B;
  cout<<(solve(B)^solve(A-1))<<endl;
  
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    K,A,B = map(int, input().split())
    left = 0
    right = 2 ** 100
    if A >= K:
        print (1)
        exit()
    if B >= A:
        print (-1)
        exit()
    while (right - left > 1):
        med = (right + left) // 2
        res = (A - B) * med
        if res >= K:
            right = med
        else:
            left = med
    # print ((A - B) * right)
    res = 2 * right
    for x in range(max(1, res - 100), res+10):
        a1 = x // 2
        a2 = x - a1
        tmp = A * a2 - B * a1
        if tmp >= K:
            print (x)
            exit()


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second & 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X; cin >> X;
  if (X >= 30) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 3632
// https://www.youtube.com/watch?v=obyyaEuNAnY

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,flag,ans;
    cin>>n;
    map<ll,ll>mp;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    //sort(a,a+n);
//    for(i=1;i<n-1;i++){
//        if((a[i-1]^a[i+1])!=a[i]){
//            cout<<"No";
//            return 0;
//        }
//    }
////    cout<<ll(a[1]^a[n-1])<<endl;
////    cout<<ll(a[0]^a[n-2])<<endl;
////    cout<<a[0]<<endl<<a[n-1]<<endl;
//    if((a[1]^a[n-1])!=a[0] || (a[0]^a[n-2])!=a[n-1]){
//        cout<<"No";
//        return 0;
//    }
    temp=a[0];
    mp[a[0]]--;
    vector<ll>v;
    v.pb(a[0]);
    for(i=1;i<n;i++){
        if(mp[(a[0]^a[i])]){
            v.pb(a[i]);
            v.pb((a[0]^a[i]));
            mp[a[i]]--;
            mp[(a[0]^a[i])]--;
            break;
        }
    }
    if(v.size()==1){
        cout<<"No";
        return 0;
    }
    while(v.size()<n){
        if(!mp[(v[v.size()-1]^v[v.size()-2])]){
            cout<<"No";
            return 0;
        }else{
            mp[(v[v.size()-1]^v[v.size()-2])]--;
            v.pb((v[v.size()-1]^v[v.size()-2]));
        }
    }
    if((v[0]^v[n-2])!=v[n-1] || (v[1]^v[n-1])!=v[0]){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 7808
#include<stdio.h>
int main(){
	int input,h,m,s;
	scanf("%d",&input);
	h=(input/(60*60));
	m=((input-(h*60*60))/60);
	s=(input-(m*60)-(h*60*60));
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(){
    long long a,b,m,n,r;
    cin>>a>>b;
    m=a;
    n=b;
    do{
        r=m%n;
        m=n;
        n=r;
    }while(r!=0);
    cout<<a*b/m;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n)         for(int i=0; i<(n); i++)
#define P pair<int, int>
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"

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

const int INF = 100100100;
int a[12][12];

int main(){
    double t, x, ans;
    cin >> t >> x;
    ans = t / x;
    prtd(10, ans);
}

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

long long dp[3010][3010];
int main() {
  int n, s;
  cin>>n>>s;
  int a[n];
  for (int i=0; i<n+1; i++) cin>>a[i];
  for (int i=0; i<1; i++) {
    for (int j=0; j<s+1; j++) {
      dp[i][j] = 0;
    }
  }
  long long mod = 998244353;
  for (int i=0; i<n; i++) {
    ++dp[i][0];
    for (int j=0; j<s+1; j++) {
      dp[i+1][j] += dp[i][j];
      if (j - a[i] >= 0) {
        dp[i+1][j] += dp[i][j-a[i]];
        dp[i+1][j] %= mod;
      }
    }
  }
  long long ans = 0;
  for (int i=1; i<n+1; i++) {
    ans += dp[i][s];
    ans %= mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 70784
import java.util.*;
import java.io.*;

public class Main {
    public static final long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        Integer i,j,k,n=0,m=0,h=0,w=0,ans=0;
        long a=0,b=0,c=0,d=0,x=0,y=0,z=0;
        List<Integer> l = new ArrayList<>();
        List<String> s = new ArrayList<>();

        a=sc.nextLong();
        b=sc.nextLong();
        c=sc.nextLong();
        d=sc.nextLong();

        x=lcm(c,d);

        z=(b-b/c-b/d+b/x)-(a-1-(a-1)/c-(a-1)/d+(a-1)/x);

        print(z);
        
        out.flush();
    }

    private static void print(Object o) {
        System.out.println(o.toString());
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22484
na1 = []

for i1 in range(5):
    na1.append(int(input()))

r1 = 0
n1 = 0
for i1 in range(5):
    r1 += ((na1[i1] + 9) // 10) * 10
    if (na1[i1] % 10) != 0:
        if n1 == 0:
            n1 = (na1[i1] % 10)
            r1 -= 10 
        elif n1 > (na1[i1] % 10):
            n1 = na1[i1] % 10

r1 += n1
print(r1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1)
#define set(x,i) (x|(1<<i))
#define unset(x,i) (x&~(1<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}

int main()
{
	boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

string a;
string b;
cin>>a>>b;
int i,f=0;
int n=a.size();
REP(i,n)
{
	if(a[i]!=b[i])
		f=1;
}
if(f==1)
	cout<<"No";
else
	cout<<"Yes";
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  long double total = 1;
  ll a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (total != -1) {
      total *= a;
    }
    if (total > 1000000000000000000 || total < 0) {
      total = -1;
    }
    if (a == 0) {
      total = 0;
    }
  }
  cout << (ll)total << endl;
  return 0;
}

Measured memory_bytes: 3684
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n=arr.shift()-0;
var a=arr.shift().split(" ");
var myMap = new Map();
for(var i=0;i<n;i++){
   myMap.set(a[i], 0);
}
var q=arr.shift();
var s="";
for(var i=0;i<q;i++){
   s+=((myMap.has(arr[i]))?1:0)+"\n";
}
console.log(s.trim());


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

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

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < 3; ++i) {
    char c = s.at(i);
    if (c == 'R') {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main(){
  int r,rad,nrad;
  double x,y;
  x = y =  nrad = 0;
  while(true){
    scanf("%d,%d",&r,&rad);
    if(r+rad == 0)break;
    x += r*sin(nrad*(M_PI/180));
    y += r*cos(nrad*(M_PI/180));
    nrad += rad;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }

  int cnt = 0;
  for (int i=1;i<N;i++){
    if (a[i]==a[i-1]){
      a[i] += 1;
      cnt +=1;
      if(i != N-1){
        if(a[i] == a[i+1]){
          a[i] +=1;
        }
      }
    }
  }
    cout << cnt << endl;
}


Measured memory_bytes: 256
k=int(input())
ans=[]
p=[i for i in range(1,10)]
for _ in range(9):
    q=[]
    for x in p:
        y=x%10
        q.append(x*10+y)
        if y<9: q.append(x*10+y+1)
        if y>0: q.append(x*10+y-1)
    for x in p:
        ans.append(x)
    p=[q[i] for i in range(len(q))]

for x in q:
    ans.append(x)

ans=sorted(ans)
print(ans[k-1])

Measured memory_bytes: 67312
#include <bits/stdc++.h>
using namespace std;
int n,x,y,arr[100001];
int pre[100001],dp[100001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>x;
    if (n*500>=x) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n,W;
	cin>>n>>W;
	vector<lli> w(n),v(n);
	for(lli i=0;i<n;i++)cin>>w[i]>>v[i];
	lli V=0;
	for(int i=0;i<n;i++)V=max(V,v[i]);
	V*=n;
	lli oo=1e18+5;
	vector<lli> dp(V+1,oo);
	dp[0]=0;
	for(lli i=0;i<n;i++){
		vector<lli> newdp(V+1,oo);
		for(lli j=0;j<=V;j++){
			
			if(j-v[i]>=0&&dp[j-v[i]]!=oo)
				newdp[j]=min(dp[j-v[i]]+w[i],dp[j]);
			else{
				newdp[j]=dp[j];
			}
		}

		dp=newdp;
	}
	
	for(lli i=V;i>=0;i--){
		if(dp[i]<=W){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}


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

const int MAX_N = 100000;

int main() {
    int N, K, height[MAX_N];
    cin >> N >> K;

    for(int i = 0; i < N; i++) {
        cin >> height[i];
    }

    sort(height, height + N);
    int count = 0;
    for(int j = 0; j < N; j++) {
        if(height[j] >= K) {
            count = N - j;
            break;
        } 
    }    
    cout << count << endl;

}

Measured memory_bytes: 640
from collections import Counter
from itertools import accumulate
from bisect import bisect_right

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = []
    app = result.append
    if n < 2: return Counter()
    while n % 2 == 0:
        app(2)
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            app(p)
            n //= p
        p += 2
    if n > 1: app(n)
    return Counter(result)

cumsum = list(accumulate(range(1, 50)))

N = int(input())
factors = prime_factorization(N)
ans = 0
for _, n in factors.items():
    ans += bisect_right(cumsum, n)
print(ans)

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

vector<int> par(100000);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
  }
}
int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}
bool same(int x, int y){
  return root(x) == root(y);
}
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  par.at(x) = y;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    vec.at(i)--;
  }
  
  vector<pair<int,int>> shift(M);
  pair<int,int> P;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    P = make_pair(min(a,b),max(a,b));
    shift.at(i) = P;
  }
  sort(shift.begin(),shift.end());
  
  init(N);
  for(int i=0; i<M; i++){
    P = shift.at(i);
    unite(P.first,P.second);
  }
  
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(same(vec.at(i),i)){
      cnt++;
    }
  }
  cout << cnt << endl;
}    

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
#define MOD 1000000007
ll dp[1010][1010];
ll H,W;
char arr[1010][1010];
int main(){
	fast;
	cin>>H>>W;
	for(ll i=1;i<=H;i++){
		for(ll j=1;j<=W;j++){
			cin>>arr[i][j];
		}
	}
	for(ll i=0;i<=H;i++){
		arr[i][0]='#';
	}
	for(ll i=0;i<=W;i++){
		arr[0][i]='#';
	}
	dp[1][1]=1;
	for(ll i=0;i<=H;i++){
		for(ll j=0;j<=W;j++){
			if(arr[i][j]=='.'){
				if(arr[i-1][j]=='.'){
					dp[i][j]+=dp[i-1][j];
				}
				if(arr[i][j-1]=='.'){
					dp[i][j]+=dp[i][j-1];
				}
				dp[i][j]=dp[i][j]%MOD;
			}
		}
	}
	cout<<dp[H][W]<<endl;
	return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>

main(){
  int N;
  scanf("%d",&N);
  int A[N+1], i, j, hozon,count=0, min;

  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<N; i++){
    min = i;
    for(j=i; j<N; j++){
      if(A[min] > A[j]){
	min = j;
      }
    }
    if(min != i){
	hozon = A[i];
	A[i] = A[min];
	A[min] = hozon;
	count++;
    }
  }

  for(i=0; i<N; i++){
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=2e5+11;
int n;
pii p[N];
int main(){
	n=rd();
	int mx=-inf,mi=inf;
	rep(i,1,n){
		p[i].x=rd();
		p[i].y=rd();
		if(p[i].x>p[i].y)swap(p[i].x,p[i].y);
		mx=max(mx,p[i].y);
		mi=min(mi,p[i].y);
	}
	sort(p+1,p+n+1);
	ll ans=1LL*(mx-mi)*(p[n].x-p[1].x);
	int mii,mxx;
	mxx=mii=p[1].y;
	rep(i,2,n){
		ll tmp=1LL*(mx-p[1].x)*( max(mxx,p[n].x) - min(mii, p[i].x) );
		ans=min(ans,tmp);
		mxx = max(mxx, p[i].y);
		mii = min(mii, p[i].y);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
mod=10**9+7
n,x=map(int,input().split())
S=list(map(int,input().split()))
S.sort()
DP=[[0]*(x+1) for _ in range(n+1)]
for i in range(x+1):
    DP[1][i]=i%S[0]
for i in range(1,n):
    for j in range(x+1):
        DP[i+1][j]=(DP[i][j]*i+DP[i][j%S[i]])%mod
print(DP[n][x])

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

#ifdef _WIN32
#define scanfll(x) scanf("%I64d", x)
#define printfll(x) printf("%I64d", x)
#else
#define scanfll(x) scanf("%lld", x)
#define printfll(x) printf("%lld", x)
#endif
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>;
using ld = long double;  using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
string bits_to_string(ll mask, ll n) { string s; rep(i, n) s += '0' + !!(mask & (1ll << i)); return s; }
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n); rep(i, a.size()) { cin >> a[i]; a[i]--; }
    ll ret= 0 ;
    rep(i, n) {
        if (a[a[i]] == i) {
            ret++;
        }
    }
    cout << ret / 2 << endl;
    return 0;
}


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

using namespace std;

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

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

    int total = (a * 3 + b) / 2;
    cout << total << '\n';
    cout.flush();
    return 0;
}

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


int main(){
    int n, a, b;
    cin>>n>>a>>b;
    int tmp;
    int tmp2 = 0;
    int i;
    int ans = 0;
    for(i=1; i<=n; i++){
        tmp = i;
        tmp2 = 0; 
        while(tmp){
            tmp2 += tmp%10;
            tmp = tmp/10;
        }
        if(tmp2>=a && tmp2<=b){
            ans += i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#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() {
    string s;
    int cnt = 0;
    cin >> s;
    for(char c: s) {
        if (c == '+') cnt += 1;
        else if (c == '-') cnt -= 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
using namespace std;
int main(){
    string num;
    int count=0;
    cin>>num;
    for(int i=0; i<3; i++){
        if(num.at(i)=='1'){
            count++;
        }
    }
    cout<<count<<endl;
}


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

using namespace std;

int main()
{
	int n;
	string str;

	cin >> n;
	
	cin >> str;

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			if (str[i] != str[i + n / 2]) {
				cout << "No" << endl;
				return 0;
			}
		}

		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    int h,w, n;
    cin>>h>>w>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<vector<int>> c(h, vector<int>(w, 0));

    
        int x=0;
        int y=0;

        for(int i=0;i<n;i++){
            for(int j=0;j<a[i];j++){
                c[x][y]=i+1;
                y++;
                if(y==w){
                    x++;
                    y=0;
                }
            }
        }
        for(int i=0;i<h;i++){
            if(i&1){
                reverse(c[i].begin(), c[i].end());
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<c[i][j];
                if(j!=w-1) cout<<" ";
            }
            cout<<endl;
        }
        return 0;
    

    
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    vector<int> N(3);
    cin >> N[0]; cin >> N[1]; cin >> N[2];
    sort(N.begin(), N.end(), greater<int>());
    cout << N[0]*10+N[1]+N[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10][10];
bool vis[10][10];
int main()
{
    for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
    cin>>a[i][j];
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        for(int j=1;j<=3;j++)
        for(int k=1;k<=3;k++)
        {
            if(a[j][k]==x)vis[j][k]=1;
        }
    }
    int bj=0;
    for(int i=1;i<=3;i++){
    int ans=0;
    for(int j=1;j<=3;j++){
        ans+=vis[i][j];
    }
    if(ans==3)bj=1;
    }
    for(int j=1;j<=3;j++){
        int ans=0;
        for(int i=1;i<=3;i++)ans+=vis[i][j];
        if(ans==3)bj=1;
    }
    int ans=0;
    for(int i=1;i<=3;i++)ans+=vis[i][i];
    if(ans==3)bj=1;
    ans=0;
    for(int i=1;i<=3;i++)ans+=vis[i][3-i+1];
    if(ans==3)bj=1;
    if(bj)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define sf(a)                scanf("%lld",&a)
#define sff(a,b)             scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)          scanf("%lld %lld %lld",&a,&b,&c)
#define case(a,b)            printf("Case %lld: %lld\n",a,b)
#define pf(a)                printf("%lld\n",a)
#define pff(a,b)             printf("%lld %lld\n",a,b)
#define pb                   push_back
#define cln(x)               memset(x, 0, sizeof(x))
#define nl                   printf("\n");
const int N=123456;
ll arr[N], i, j;
using namespace std;
int main()
{
    ll a, b, c, x, y;
    while(sfff(a,b,c)==3)
    {
        sff(x,y);
        ll cost1, cost2, cost3;
        cost1=(x*a+y*b);
        ll mn=min(x,y);
        cost2=(mn*2*c);
        if(x>y)
        {
            cost2+=(a*(x-y));
        }
        else cost2+=(b*(y-x));
        ll mx=max(x,y);
        cost3=mx*c*2;
        //cout<<cost1<<" "<<cost2<<" "<<cost3<<endl;
        ll ans=min(cost1,min(cost2,cost3));
        pf(ans);
    }
    return 0;
}


/*
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
*/









Measured memory_bytes: 256