akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
const int maxN=3e2+100;
int n,m,st,fn;
int cap[maxN][maxN],excess[maxN],height[maxN];
vector<int> g[maxN];
set<pair<int,int> > candidates;

void input()
{
  cin>>n>>m;
  //cin>>st>>fn;
  st=1; fn=n;
  for(int i=1;i<=m;i++)
    {
      int k1,k2,val;
      cin>>k1>>k2>>val;
      k1++;k2++;
      if(cap[k1][k2]==0 && cap[k1][k2]==0){
	g[k1].push_back(k2);
	g[k2].push_back(k1);
      }
      cap[k1][k2]+=val;
    }
}
int findExcessedVertex()
{
    while(candidates.size()>0)
      {
	auto item=*candidates.begin();
	if(item.second==st || item.second==fn)
	  candidates.erase(item);
	else
	  return item.second;
      }
    return 0;
}
bool push(int v)//change to multi push
{
  bool done=false;
  for(auto u :g[v])
    if(cap[v][u]>0 && height[v]>=height[u]+1)
	{
	int delta=min(excess[v],cap[v][u]);
	cap[v][u]-=delta;
	cap[u][v]+=delta;
	excess[v]-=delta;
	if(excess[v]==0)
	  candidates.erase({height[v],v});
	if(excess[u]==0)
	  candidates.insert({height[u],u});
	excess[u]+=delta;
	done=true;
	return done;
      }
  return done;
}
void relabel(int v)
{
  height[v]++;
  if(candidates.find({height[v]-1,v})!=candidates.end()){
    candidates.erase({height[v]-1,v});
    candidates.insert({height[v],v});}
}
void GT_init()
{
  height[st]=n;
  height[fn]=0;//not done
  for(auto u:g[st])
    if(cap[st][u]>0)
      {
      int delta=cap[st][u];
      cap[st][u]-=delta;
      cap[u][st]+=delta;
      excess[st]-=delta;
      if(excess[st]==0)
	candidates.erase({height[st],st});
      if(excess[u]==0)
	candidates.insert({height[u],u});
      excess[u]+=delta;
    }
}
int Goldberg_Tarjan()
{
  GT_init();
  while(int v=findExcessedVertex())
    {
      
      // cout<<"gt "<<v<<" "<<excess[v]<<" "<<height[v]<<endl;
      if(!push(v))
	relabel(v);
    }
  return excess[fn];
}
int main()
{
  input();
  int Maxflow=Goldberg_Tarjan();
  cout<<Maxflow<<endl;
  
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

struct Sieve {
  vector<int> table;
  Sieve(int x): table(x+1) {
    table[0] = table[1] = -1;
    for (ll i=2; i<=x; i++) {
      if(table[i]) continue;
      table[i] = i;
      for(ll j=i*i; j<=x; j+=i) {
        table[j] = i;
      }
    }
  }
  map<int,int> primes(int x) {
    map<int,int> p;
    if (x < 2) return p;
    while(table[x]!=x) {
      p[table[x]]++;
      x /= table[x];
    }
    p[table[x]]++;
    return p;
  }
};

struct mint {
  ll x;
  mint(ll x=0): x((x%mod+mod)%mod) {}
  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
  mint operator-() const {return mint(-x);}
  mint& operator-=(const mint a) {
    if((x-=a.x)<0) x+=mod;
    return *this;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint& operator+=(const mint a) {
    if((x+=a.x)>=mod) x-=mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint& operator*=(const mint a) {
    if((x*=a.x) >= mod) x%=mod;
    return *this;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll a) const {
    if(!a) return 1;
    if(a&1ll) return (*this)*pow(a-1);
    mint root = pow(a>>1);
    return root*root;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    (*this) *= a.inv();
    return *this;
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(int argc, char const* argv[])
{
  int n;
  cin>>n;

  Sieve sieve((int)1e6);
  map<int,int> lcm_map;
  vector<int> as;

  REP(i,n) {
    int a;
    cin>>a;
    as.push_back(a);
    map<int,int> p = sieve.primes(a);
    for(auto e: p) lcm_map[e.first] = max(lcm_map[e.first], e.second);
  }

  mint lcm = 1;
  for(auto e: lcm_map) {
    REP(i,e.second) lcm *= e.first;
  }

  mint ans = 0;
  for(auto a: as) {
    mint b = lcm/a;
    ans += b;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans=0;
    vector<int> a={3,5,7,11,13};
    for (int i=0;i<3;i++) {
        for (int j=i+1;j<4;j++) {
            for (int k=j+1;k<5;k++) {
                if (a[i]*a[j]*a[k]<=n) ans++;
            }
        }
    }
    for (int j=1;j<4;j++) {
        if (27*a[j]<=n) ans++;
    }
    cout << ans << endl;
}

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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    int s = 0;
    for(int i = 0; i < 4; ++i) {
        int x; cin >> x;
        s += x;
    }
    cout << s / 60 << "\n" << s % 60 << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)
    cout<<"Balanced"<<endl;
  else if (a+b<c+d)
    cout<<"Right"<<endl;
  else
    cout<<"Left"<<endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
int main(void) {
  int n;
  int cnt=0;
  scanf("%d",&n);
  // for (int i = 1; i < n; i++)
  // {

    
  // }
  if(n%2){
printf("%d\n",(n/2));
  }else{
    printf("%d\n",(n/2)-1);
  }
  

  return 0;
}

Measured memory_bytes: 128
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

long long int nCk(int n, int k){
    long long int bunbo = 1, bunsi = 1;
    while(k>0){
        bunbo *= k;
        bunsi *= n;
        k -= 1;
        n -= 1; 
    }
    return bunsi/bunbo;
}

int main() {

    int n,i;
    int* a;  // 動的メモリの先頭アドレス用のポインタ
    char contest[4];
    scanf("%s", contest);

    if(strcmp(contest,"ABC")==0){
        printf("ARC");
    }else{
        printf("ABC");
    }
    return 0;
}

Measured memory_bytes: 1728
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int c=a[0];
	int ans=0;
	for(int i=1; i<n; i++){
		ans += max(0ll, c-a[i]);
		c=max(c, a[i]);
	}
	cout << ans << endl;
 
	return 0;
}  

Measured memory_bytes: 5200
#include<iostream>

using namespace std;

int main(void)

{
    unsigned long long int n, k, vagfol, sesh, ans;
    cin>>n>>k;
    if(n%k == 0){
        ans = 0;
    }
    else if(n < k){
        sesh = n%k;
        ans = k-sesh;
        if(sesh < ans)
            ans = sesh;
    }
    else{
        sesh = n%k;
        ans = k-sesh;
        if(sesh < ans)
            ans = sesh;
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
N = int(input())
A = [int(i) for i in input().split()]

color = []

for i, a in enumerate(A, 1):
    for _ in range(a):
        color.append(i)

flag = 1
for i in range(H):
    left = i * W
    right = left + W
    print(*color[left:right][::flag])
    flag *= -1

Measured memory_bytes: 42224
k=int(input())
s={7%k}
a=7%k
n=1
flag=True
while not {0}<=s:
    a=(a*10+7)%k
    beforelen=len(s)
    s.add(a)
    if len(s)==beforelen:
        flag=False
        break
    n+=1
print(n if flag else -1)

Measured memory_bytes: 77852
#include <stdio.h>
int main()
{
  int no1,no2;

  scanf("%d",&no1);
  scanf("%d",&no2);
  while ((no1!=0) || (no2!=0)){
    if (no1>no2){
      printf("%d %d\n",no2,no1);
    }else{
      printf("%d %d\n",no1,no2);
    }
    scanf("%d",&no1);
    scanf("%d",&no2);
  }

  return 0;
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
//vector<edges> G;

int n, m;
vector<pair<int, int> > e;

int main(){
	cin >> n >> m;
	FORI(0, m) {
		int u, v;
		cin >> u >> v; u--; v--;

		e.push_back(make_pair(u, v));
		e.push_back(make_pair(v, u));
	}
	int p[10];
	FORI(0, n)p[i] = i;
	int ans = 0;
	do {
		bool flg = true;
		FORI(0, n - 1) {
			if (e.end()==find(e.begin(), e.end(), make_pair(p[i],p[i+1]))) {
				flg = false;
				break;
			}
		}
		if (flg) {
			ans++;
		}
	} while (next_permutation(p + 1, p + n));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
 	ll n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	for(int i = 0; i < n-1; ++i){
		if(s[i]=='A'&&s[i+1]=='C')s[i]='a';
	}
	vector<ll> rui(n+2,0);
for(int i = 0; i < n; ++i){
		rui[i+1]+=rui[i];
		if(s[i]=='a')rui[i+1]++;
	}
 
	for(int i = 0; i < q; ++i){
		ll l,r;
		cin>>l>>r;
		cout<<rui[r-1]-rui[l-1]<<endl;
	}
}

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

using pii = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<pii> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(begin(a), end(a));

    int cnt1 = 1, cnt2 = 1;
    for(int i = 0; i + 1 < n; ++i) {
        int c1 = 1;
        while(i + 1 < n && a[i].second < a[i + 1].second) {
            c1 += 1;
            i++;
        }
        cnt1 = max(cnt1, c1);
    }
    for(int i = n - 1; i >= 1; --i) {
        int c2 = 1;
        while(i - 1 >= 0 && a[i].second > a[i - 1].second) {
            c2 += 1;
            i--;
        }
        cnt2 = max(cnt2, c2);
    }

    cout << n - max(cnt1, cnt2) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
 
int main() {
	int n, x, place = 0, ans = 1;

	cin >> n >> x;
	int l[n];
	rep(i,n) cin >> l[i];
	rep(i,n) {
		place += l[i];
		if(place <= x) ans++;
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
// #include <bits/stdc++.h>
#define req(i,h) for(int i = 0; i < h; i++)

using namespace std;


int main(void) {
    int n , m;
    cin >> n >> m;
    vector<int> data(m);
    req(i,n) {
        int k;
        cin >> k;
        req(j, k) {
            int a;
            cin >> a;
            a--;
            data.at(a)++;
        }
    }
    int ans = 0;
    req(i,m) {
        if(data.at(i) == n) {
            ++ans;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>

using namespace std;
//#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 1e13
#define ll long long
#define mod  998244353
const int N = 1e5 + 10;
int main()
{

    ll a,b,c = 0;
    cin>>a>>b;
    if(a == 3)
    c += 100000;
    else if(a == 2) c +=200000 ;
    else if(a == 1) c += 300000;
     if(b == 3)
    c += 100000;
    else if(b == 2) c +=200000 ;
    else if(b == 1) c += 300000;
    if(a == 1&&b == 1) c += 400000;
    cout<<c;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    double a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double x,y;
    x = min(e+c/2.0,a/2.0);
    y = min(f+d/2.0,b/2.0);
    x = (x+e-c/2.0)/2.0;
    y = (y+f-d/2.0)/2.0;
    //cout << x << "  " << y << endl;
    cout << fixed << setprecision(20) <<y/x << endl;

    return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

class UnionFind { private: std::vector<size_t> P; std::vector<size_t> R; size_t find(size_t x) { return P[x] == x ? x : P[x] = find(P[x]); } public: UnionFind(size_t n) { P.resize(n); iota(P.begin(), P.end(), 0); R.resize(n); fill(R.begin(), R.end(), 0); } void unite(size_t x, size_t y) { x = find(x); y = find(y); if (x == y) return; if (R[x] < R[y]) { P[x] = y; } else { P[y] = x; if (R[x] == R[y]) ++R[x]; } } bool same(size_t x, size_t y) { return find(x) == find(y); }
  size_t size() {
    set<size_t> s;
    REP(i, P.size()) {
      s.insert(find(i));
    }
    return s.size();
  }
};

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  REP(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x -= 1;
    y -= 1;
    uf.unite(x, y);
  }
  cout << uf.size() << endl;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int gcd(int m, int n)
{
	while(1) {
		if (m == n) break;
		if (m > n) m = m - n;
		else n = n - m;
	}
	return m;
}

int lcm(int x, int y)
{
	return x * y / gcd(x, y);
}

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	int get = lcm(a + b, 60);
	int max = get / 60;
	int ans = - 1;
	for (int i = 0; i < max; i++) {
		int time = 60 * i + c;
		if (time % (a + b) <= a) {
			ans = time;
			break;
		}
	}

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

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

int main()
{
    int a ,b;
    cin >> a >> b;
    if (a == 2){
    cout << "No" ;
    }
    else if (b == 2){
    cout << "No" ;
    }
    else {
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 3636
D,N = map(int,input().split())

if D == 0:
  if N == 100:
    print(101)
  else:
    print(N)
else:
  if D == 1:
    if N == 100:
      print(10100)
    else:
      print(N * 100)
  else:
    if N == 100:
      print(1010000)
    else:
      print(N * 10000)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

X, N = map(int, input().split())
A = list(map(int, input().split()))

B = set(A)
t = 10**15
ans = -1
for i in range(103):
    if not i in B and abs(i-X) < t:
        t = abs(i-X)
        ans = i

print(ans)

Measured memory_bytes: 9132
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int yen = sc.nextInt();
      int s = yen/1000-n;
      for(int i = 0;i<= Math.min(s/9,n);i++){
      	for(int j = 0;j<= Math.min(n-i,s/4);j++){
        	if(i*9+j*4==s){
            	System.out.println(i+" "+j+" "+(n-i-j));
                return;
            }
        }
      }
      System.out.println((-1)+" "+(-1)+" "+(-1));
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

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

int main(){
    int c,d;
    cin >> c >> d;
    if(c<d)printf("%s\n", "a < b");
    if(c>d)printf("%s\n", "a > b");
    if(c==d)printf("%s\n", "a == b");
    return 0;
}


Measured memory_bytes: 3084
/*
  AUTHOR:SOURABH
  CREATED:26:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll n,m,i,v,sum=0;
    cin>>n>>m;
    fn(i,m)
    {
        cin>>v;
        sum+=v;
    }
    if(sum>=n)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}



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

int main() {
    int n, k;
    while (cin >> n >> k) {
        int min = 0;
        int max = (n - 1) * (n - 2) / 2;
        if (k < min || k > max) {
            printf("-1\n");
            continue;
        }
        int m = n * (n - 1) / 2 - k;
        vector<int> edge;
        int current = k;
        for (int i = n - 2; i > 0; --i) {
            if (current <= i) {
                edge.push_back(current);
                break;
            }
            edge.push_back(i);
            current -= i;
        }
        vector<vector<int>> ans;
        int size = edge.size();
        printf("%d\n", m);
        for (int i = 1; i < n; ++i) {
            if (i > size) {
                for (int j = n; j > i; --j) {
                    printf("%d %d\n", i, j);
                }
            }
            else {
                for (int j = n, end_j = i + edge[i - 1]; j > end_j; --j) {
                    printf("%d %d\n", i, j);
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

using namespace std;



int main()
{
	char pat[8][8];
	
	//入力
	for (int i=0; i<8; i++)
	{
		cin >> pat[i];
	}
	
	//90
	cout << "90" << endl;
	for (int i=0; i<8; i++)
	{
		for (int j=7; j>=0; j--)
		{
			cout << pat[j][i];
		}
		cout << endl;
	}
	
	//180
	cout << "180" << endl;
	for (int i=7; i>=0; i--)
	{
		for (int j=7; j>=0; j--)
		{
			cout << pat[i][j];
		}
		cout << endl;
	}
	
	//270
	cout << "270" << endl;
	for (int i=7; i>=0; i--)
	{
		for (int j=0; j<8; j++)
		{
			cout << pat[j][i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1136
#include<bits/stdc++.h> 
using namespace std;
#define MOD 1000000007
using ll = long long ;
 
ll arr[105],dp[105][100005];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll i,j,n,k;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>arr[i];
	dp[0][0]=1; 
	for(i=1;i<=k;i++) dp[0][i]=0; 
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++)
			dp[i-1][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
			
		for(j=0;j<=k;j++){
			ll mn=j-arr[i]-1;
			dp[i][j]=dp[i-1][j];
			if(mn>=0) dp[i][j]=(dp[i][j]-dp[i-1][mn]+MOD)%MOD;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 82512
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;





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

while(n)
{
    if(n%10==9)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    n/=10;
}
cout<<"No"<<endl;

 return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int check(lli n){
    for(lli i=2;i<n;i++){
        if(n%i==0) return 0;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);\
    lli n;
    cin>>n;
    if(check(n)==1){
            cout<<n;
            return 0;
        }
    while(n++){
        if(check(n)==1){
            cout<<n;
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    VI A(N);
    map<int, int> B;
    rep(i,N){
        cin >> A[i];
        B[A[i]]++;
    }
    VP C;
    stl_rep(i,B){
        C.push_back(pair<ll,ll>(i->S,i->F));
    }
    sort(all(C));
    int ans=0;
    int count=C.size()-K;
    rep(i,count){
        ans+=C[i].F;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    string N;
    cin >> N;
    int ans = 0;
    int flag = false;
    rep(i, N.size() - 1) {
        if (N[i + 1] != '9') flag = true;
        ans += 9;
    }
    int tmp;
    if (flag) {
        tmp = N[0] - '1';
    } else {
        tmp = N[0] - '0';
    }
    ans += tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int maxn=50+10;
int n;
int len;
int ma[30];
char s[maxn][maxn];
char sum[maxn];
int cnt=0;
map < char,int > p[maxn];
void init(){
	scanf("%d",&n);
	memset(ma,10,sizeof(ma));
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		len=strlen(s[i]+1);
		for(int j=1;j<=len;++j)
			++p[i][s[i][j]];
		for(int j=1;j<=26;++j)
			ma[j]=min(ma[j],p[i]['a'-1+j]);
	}
}
void work(){
	for(int i=1;i<=26;++i)
		for(int j=1;j<=ma[i];++j)
			sum[++cnt]='a'-1+i;
}
void prin(){
	printf("%s\n",sum+1);
}
int main(){
	//freopen(".in" ,"r",stdin );
	//freopen(".out","w",stdout);
	init();
	work();
	prin();
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n){cin >> d[i];}
  
  int sum = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      sum += d[i]*d[j];
    }
  }
  
  cout << sum << endl;
}

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

ans = 0
s_len = 1
for i in range(1, n): 
    if a[i] == a[i-1]:
        s_len += 1
    else:
        ans += (s_len // 2)
        s_len = 1
ans += (s_len // 2)
print(ans)

Measured memory_bytes: 3060
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(K)]
MOD = 998244353

dp = [0] * N
sdp = [0] * (N + 1)
dp[0] = 1
sdp[1] = 1

for i in range(1, N):
    for l, r in X:
        dp[i] += sdp[max(0, i - l + 1)] - sdp[max(0, i - r)]
        dp[i] %= MOD
    sdp[i + 1] = sdp[i] + dp[i]
    sdp[i + 1] %= MOD

print(dp[-1])


Measured memory_bytes: 76304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
    
  int main(){
     lint N;
     cin>>N;
     lint A[N];
     rep(i,N)cin>>A[i];
     vector<lint>x;
     vector<lint>y;
     x.resize(N);
     x[1]=A[0];
     y.resize(N);
     y[N-2]=A[N-1];
    rep(i,N-2){
       x[i+2]=__gcd(x[i+1],A[i+1]);
    }
    repm(i,N-2){
            y[i]=__gcd(A[i+1],y[i+1]);
    }
    lint ans=0;
   
    rep(i,N){
            if(x[i]==0)ans=max(ans,y[i]);
            else if(y[i]==0)ans=max(ans,x[i]);
            else ans=max(ans,__gcd(x[i],y[i]));
    }
    cout<<ans;
  }
  

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  ll n, ans = 1, a;
  bool over = false, zero = false;
  cin >> n;
  rep(i, n) {
    cin >> a;
    if (a == 0) {
      zero = true;
      break;
    }
    if (a <= INF / ans)
      ans *= a;
    else {
      over = true;
    }
  }

  if (zero)
    puts("0");
  else if (over)
    puts("-1");
  else
    cout << ans << endl;
  return 0;
}


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

int digitSum( int n )
{
	char s[10];
	sprintf( s, "%d", n );
	int len = strlen(s);
	int sum = 0;
	for( int i = 0; i < len; i++ ) {
		sum += s[i] & 0x0f;
	}
	return sum;
}

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

	cin >> n >> a >> b;

	for( int i = 1; i <= n; i++ ) {
		int nn = digitSum( i );
		if( a <= nn && nn <= b ) {
			ans += i;
		}
	}
	cout << ans << endl;

	return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;cin>>n;
    vector<long double> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    if(a[0]==0){
        cout<<0<<endl;
        return 0;
    }
    ld ans=1;
    rep(i,n){
        if((1e18/ans)<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        else ans*=a[i];
    }
    cout<<(ll)ans<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    	long long int n,x;
    	cin >> n >> x;
    	long long int a[n]; 
    	for(int i=0;i<n;i++){
          	cin >> a[i];
    	}  
    	long long int b;
      	b=0;
      	if(a[0] > x){
          	b = b + a[0] - x;
           	a[0] = x;
        }
        for(int i=1;i<n;i++){
    		if(a[i] > (x - a[i-1])){
        		b = b + a[i] + a[i-1] - x;
            	a[i] = x - a[i-1];
    		}
    	}
    	cout << b << endl;
    }

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

int main(){
  int var;
  int ans = 0;
  cin >> var;
  vector<int> a(var), b(var), c(var);
  //data input and basic points
  for (int i=0; i<var; i++){
    cin >> a[i];
  }
  for (int i=0; i<var; i++){
    cin >> b[i];
    ans += b[i];
  }
  for (int i=0; i<var-1; i++){
    cin >> c[i];
  }
  //bonus points
  int count = a[0];
  for (int i=1; i<var; i++){
    if (a[i] == count+1){
      ans += c[count-1];
    }
    count = a[i];
  }
  cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  int total = 0;
  for (int i = 0; i < s.size(); i++) {
    total = (total + (s[i] - '0')) % 9;
  }
  if (total) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3708
package main

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

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W := nextInt(), nextInt()
	S := []string{}
	for i := 0; i < H; i++ {
		S = append(S, nextLine())
	}

	fmt.Printf("%d\n", AGC043A(H, W, S))
}

// AGC043A ...
func AGC043A(H, W int, S []string) int {
	dp := make([][]int, H)
	for i := 0; i < H; i++ {
		dp[i] = make([]int, W)
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if i == 0 && j == 0 {
				if S[0][0] == '#' {
					dp[0][0] = 1
				} else {
					dp[0][0] = 0
				}
			} else {
				up, left := math.MaxInt32, math.MaxInt32
				if i != 0 {
					up = dp[i-1][j]
					if S[i-1][j] == '.' && S[i][j] == '#' {
						up++
					}
				}
				if j != 0 {
					left = dp[i][j-1]
					if S[i][j-1] == '.' && S[i][j] == '#' {
						left++
					}
				}

				if up < left {
					dp[i][j] = up
				} else {
					dp[i][j] = left
				}
			}
		}
	}

	return dp[H-1][W-1]
}


Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    ll len = 0;
    REP(i,n) {
        cin >> v[i];
        len += v[i];
    }
    
    ll ans = 1LL << 60;
    ll clen = 0;
    int i = 0;
    while(i < n) {
        clen += v[i];
        ll clen2 = len - clen;
        ans = min(ans,abs(clen2 - clen));
        //cerr << ans << endl;
        i++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
 int n,i,j,k,d[100];
 while(cin >> n) {
	 if (n==0) break;
	 for (i=0;i<n;i++) cin >> d[i];
	 k=0;
	 for (i=1;i<n;i++) for (j=0;j<n-i;j++) if (d[j]>d[j+1]) { swap(d[j],d[j+1]); k++;} 
	 cout << k << endl;
 }
 return 0;
 }

Measured memory_bytes: 1160
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    30256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
ll n, a, c[5], ans = 1;
void solve()
{
    cin >> n;
    for( int i = 0; i < n; i ++ )
    {
        cin >> a;
        ll cnt = 0;
        if( c[1] == a )cnt ++;
        if( c[2] == a )cnt ++;
        if( c[3] == a )cnt ++;
        ans *= cnt;
        if( c[1] == a )c[1] ++;
        else if( c[2] == a )c[2] ++;
        else c[3] ++;
        ans %= M;
    }
    cout << ans;
}

int main()
{

   // sc( "%I64d", &tests );
    for(int i = 0; i < ttt; i ++ )
        solve();
}






Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

using namespace std;

// ユークリッドの互除法
// 最大公約数を求める
int CalcGCD(int a, int b)
{
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return CalcGCD(a % b, b);
}

int main() {

	int N;
	cin >> N;

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

	int gcd = vNum[0];
	for (int i = 1; i < N; ++i)
	{
		gcd = CalcGCD(gcd, vNum[i]);
	}
	
	cout << gcd << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,C;
  int Q,T,F;
  cin >> S >> Q;
  string b="",a="";
  int tflag=0;
  for(int i=0;i<Q;i++){
    cin >> T;
    if(T==1){
      if(tflag==0){
        tflag=1;
      }else{
        tflag=0;
      }
    }else{
      cin >> F >> C;
      if((F+tflag)%2==1){
        b = C+b;
      }else{
        a = a+C;
      }
    }
  }
  S = b+S+a;
  if(tflag==1){
    reverse(S.begin(), S.end());
  }
  cout << S << "\n";
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    double n,m,d;
    cin>>n>>m>>d;

    double ans = 0.0;
    if(d==0){
        ans = 1.0/n*(m-1);
    }else{
        ans = 2.0*(n-d)/(n*n)*(m-1);
    }
    cout << ans << endl;
    return  0;
}


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

int a[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        ans += t - i;
    }
    cout << ans << endl;
}


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

 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define v vector<long long int> 
#define vv vector< int> 

#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(i,n) for(int i=0;i<n;i++)
#define fe(d,e) for(auto d:e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
#define ordered_set tree<pa, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
// ll mul(ll a,ll b)

using namespace std;
ll power(ll x, unsigned long long  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y/2; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

  
void dfs(int node,vv adj[] ,int dp[] ,bool vis[] )
{
    vis[node] = true ;

    for (int i=0 ; i< adj[node].size();i++)
    {
        if (!vis[adj[node][i]])
            dfs(adj[node][i],adj,dp,vis);
        dp[node] = max(dp[node],1+dp[adj[node][i]]);
    }

    
}
int longest(vector <int> adj[],int n)
{
    int dp[n+1];
    memset(dp,0,sizeof dp);
    bool vis[n+1];
    memset(vis,false,sizeof vis); 

    for (int i=1 ;i<=n ;i++)
    {
        if (!vis[i])
        {
            dfs(i,adj,dp,vis);
        }
    }
    int ans=0;
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 

int main()
{
    int n,m;
    vv adj[n+1];
    cin>>n>>m;
    for (int i=0,x,y;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
    }
    cout<<longest(adj,n)<<'\n';

}


    


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

namespace abc081_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var item = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var n = item[0];
            var k = item[1];

            var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var d = new Dictionary<int, int>();
            foreach(var i in a){
                if(d.ContainsKey(i)){
                    d[i] += 1;
                }else{
                    d.Add(i,1);
                }
            }
            var ans = 0;
            var l = d.Count - k;
            var j = 0;
            foreach(var t in d.OrderBy(x => x.Value)){
                if(j < l){
                    ans += t.Value;                
                }
                j += 1;
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    while (1)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
            return 0;

        REP(i, H)
        {
            REP(j, W)
            cout << "#";
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120