akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long  xorx(long long  n)
{
    long long   k = (n%4);
    if(k == 0ll)
        return n;
    if(k == 1ll)
        return 1ll;
    if(k == 3ll)
        return 0ll;
    if(k == 2ll)
        return (n + 1ll);
}

int  main()
{

   long long  a , b;
   cin >> a >> b;
  if(a > 0)
    a--;
   long long  first = xorx(a);
   long long  second = xorx( b);
   long long  answer = (first ^ second);
   cout << answer << "\n";



return 0;}


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

using namespace std;

const int MAXN = 200 * 1000 + 10;
const int MAXM = 200 * 1000 + 10;

int a[MAXN], b[MAXM];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> b[i];
	sort(a, a + n);
	sort(b, b + m);
	int i = 0;
	while (i < m)
	{
		int j = i;
		while (i < m && b[i] == b[j])
			i++;
		int have = upper_bound(a, a + n, b[j]) - lower_bound(a, a + n, b[j]);
		if (have < i - j)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int main()
{
    int n, k;
    std::cin >> n >> k;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;

        ans += std::min(temp * 2, (k - temp) * 2);
    }
    std::cout << ans << std::endl;
}


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

class DisjointSet{
  public:
    vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for ( int i = 0; i < size; i++)makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

  void unite(int x, int y){
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if ( rank[x] > rank[y]){
      p[y] = x;
    } else {
      p[x] = y;
      if ( rank[x] == rank[y])rank[y]++;
    }
  }

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

  int findSet(int x){
    if ( p[x] != x){p[x] = findSet(p[x]); }
    return p[x];
  }
};

class Edge {
  public:
    int source, target, cost;

  Edge(int source = 0, int target = 0, int cost = 0):
  source(source), target(target), cost(cost) {}
  bool operator < (const Edge &e) const {
    return cost < e.cost;
  }
};

int kruskal(int n, vector<Edge> edges){
  int totalCost = 0;
  DisjointSet ds = DisjointSet(n + 1);

  for ( int i = 0; i < edges.size(); i++){
    Edge e = edges[i];
    if ( !ds.same(e.source, e.target) ){
      totalCost += e.cost;
      ds.unite(e.source, e.target);
    }
  }
  return totalCost;
}

int main(){
  int v, e;
  cin >> v >> e;
  vector<Edge> edges;
  int s, t, w;
  for ( int i = 0; i < e; i++){
    cin >> s >> t >> w;
    Edge e = Edge(s, t, w);
    edges.push_back(e);
  }

  sort(edges.begin(), edges.end());

  cout << kruskal(v, edges) << endl;

  return 0;
}


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

typedef long long int LL;

int n;
vector<LL> a;
vector<vector<LL>> dp;

LL solve() {
	if (n == 1)
		return 0;
	vector<pair<LL, LL>> order;
	dp = vector<vector<LL>>(n + 1, vector<LL>(n + 1, 0));
	for (int i = 0; i < n; i++)
		order.emplace_back(a[i], i);
	sort(order.begin(), order.end(), [](pair<LL, LL> L, pair<LL, LL> R) {
		if (L.first != R.first)
			return L.first > R.first;
		return L.second < R.second;
	});
	for (int i = 1; i <= n; i++) {
		dp[0][i] = dp[0][i - 1] + abs(order[i - 1].second - n + i) * order[i - 1].first;
		dp[i][0] = dp[i - 1][0] + abs(order[i - 1].second - i + 1) * order[i - 1].first;
	}
	for (int i = 2; i <= n; i++)
		for (int L = 1; L < i; L++) {
			int R = i - L;
			dp[L][R] = max(
				dp[L][R],
				max(dp[L - 1][R] + abs(order[i - 1].second - L + 1) * order[i - 1].first,
					dp[L][R - 1] + abs(order[i - 1].second - n + R) * order[i - 1].first)
			);
		}
	LL ans = dp[0][n];
	for (int L = 0; L <= n; L++)
		ans = max(ans, dp[L][n - L]);
	dp.clear();
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	while (cin >> n) {
		a = vector<LL>(n);
		for (auto &&x : a)
			cin >> x;
		cout << solve() << endl;
		a.clear();
	}
}

Measured memory_bytes: 34604
from itertools import combinations
N = int(input())
s = [input()[0] for _ in range(N)]
s.sort()
x = [s.count('M'), s.count('A'), s.count('R'), s.count('C'), s.count('H')]
ans = 0
for v in combinations(x, 3):
    ans += v[0] * v[1] * v[2]
print(ans)

Measured memory_bytes: 4336
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

string t = "abcdefghijklmnopqrstuvwxyz";
int main() {
  assert(t.size() == 26);
  int n; cin >> n;
  set<char> S;
  map<char, int> M;
  string s; cin >> s;
  for (auto c: s) M[c]++;
  
  loop(i,1,n) {
    cin >> s;
    map<char, int> M2;
    for (auto c: s) M2[c]++;
    for (auto c: t) M[c] = min(M[c], M2[c]);
  }
  s = "";
  for (auto m: M) {
    loop(i,0,m.second) s += m.first;
  }
  sort(s.begin(), s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int in(N);

  vector<double> p(N);
  rep(i, N) cin >> p[i];

  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));
  dp[0][0] = 1.0;
  rep(i, N) rep(j, N) {
    dp[i+1][0] = (1-p[i]) * dp[i][0];
    dp[i+1][j+1] = (1-p[i]) * dp[i][j+1] + p[i] * dp[i][j];
  }
  double ans;
  rep(i, N+1) {
    if (i > (N-i))
      ans += dp[N][i];
  }
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    long double a,b,c;
    cin>>a>>b;
    c = a*b;
    cout<<(ll)c;

    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
using namespace std;
int main()
{
    string str;
    cin>>str;
    int t=0;
    for(int i=0;i<3;i++)
    {
        if(str[i]==str[i+1])
            t=1;
    }
    if(t)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 29
 
using namespace std;
 
int n, m, s, g1, g2;
int cost[101][101];
 
int main(){
 
  while(scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2) && n){
    s--;g1--;g2--;
    rep(i, n) rep(j, n) cost[i][j] = INF;
    rep(i, n) cost[i][i] = 0;
    int a, b, c;
    rep(i, m){
      scanf("%d%d%d", &a, &b, &c);
      a--;b--;
      cost[a][b] = c;
    }
 
    rep(i, n) rep(j, n) rep(k, n)
      cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
 
    /*    rep(i, n){
      rep(j, n) printf("%d ", cost[i][j]);
      puts("");
      } */
  
    int res = INF;
    rep(i, n){
      res = min(res, cost[s][i] + cost[i][g1] + cost[i][g2]);
      //      printf("%d + %d + %d\n", cost[s][i], cost[i][g1], cost[i][g2]);
    }
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
string ans="No";
for(int i=0;i*4<=N;i++){
    for(int j=0;j*7<=N;j++){
        if(N-((i*4)+j*7)==0){
            ans="Yes";
            break;
        }
    }
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, C;
    cin >> N >> C;
    vv<int> D = vvec(C, C, 0);
    rep(i, C) rep(j, C) cin >> D[i][j];
    vv<int> c = vvec(N, N, 0);
    rep(i, N) rep(j, N) cin >> c[i][j];

    vv<int> cnt = vvec(3, C, 0);
    rep(i, N) rep(j, N) {
        cnt[(i + j) % 3][c[i][j] - 1]++;
    }

    int color[3];
    ll ans = LINF;
    for (color[0] = 0; color[0] < C; ++color[0])
        for (color[1] = 0; color[1] < C; ++color[1])
            for (color[2] = 0; color[2] < C; ++color[2]) {
                if (color[0] == color[1] || color[1] == color[2] || color[2] == color[0]) continue;

                ll iwakan = 0;
                rep(i, 3) rep(j, C) {
                    iwakan += D[j][color[i]] * cnt[i][j];
                }
                ans = min(ans, iwakan);
            }

    write(ans);
}

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

int main() {
  string S;
  int Q;
  cin >> S;
  cin >> Q;
  int revflag = 0;
  vector<string> add(2);
  int cnt = 0;
  rep(qi, Q) {
    int T;
    cin >> T;
    if (T == 1) {
      revflag = 1 - revflag;
      cnt++;
    } else {
      int F;
      cin >> F;
      char C;
      cin >> C;
      if (F == 1) {
        add.at(revflag) += C;
      } else {
        add.at(1 - revflag) += C;
      }
    }
  }
  reverse(add.at(0).begin(), add.at(0).end());
  string ans = "";
  ans += add.at(0);
  ans += S;
  ans += add.at(1);
  if (cnt % 2 == 1) {
    reverse(ans.begin(), ans.end());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1348
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    
    int rating[n];
    
    int a[9];
    
    for(int i = 0; i < 9; i++){
        a[i]=0;
    }
    
    for(int i = 0; i < n; i++){
        cin>>rating[i];
    }
    
    for(int i = 0; i < n; i++){
        if(rating[i]>=1 && rating[i] <=399){
            a[0]++;
        }else if(rating[i] >=400 && rating[i] <=799  ){
            a[1]++;
        }else if(rating[i] >=800 && rating[i] <=1199  ){
            a[2]++;
        }else if(rating[i] >=1200 && rating[i] <=1599  ){
            a[3]++;
        }else if(rating[i] >=1600 && rating[i] <= 1999 ){
            a[4]++;
        }else if(rating[i] >=2000 && rating[i] <= 2399 ){
            a[5]++;
        }else if(rating[i] >= 2400 && rating[i] <= 2799 ){
            a[6]++;
        }else if(rating[i] >= 2800 && rating[i] <= 3199 ){
            a[7]++;
        }else if(rating[i] >= 3200){
            a[8]++;
        }
    }    
    
    int difmin=0;
    
    for(int i = 0; i < 9; i++){
        if(a[i]>0 && i!=8){
            difmin++;
        }
    }
    
    int difmax = difmin + a[8];
    
    if(difmin==0 && a[8]){
        difmin=1;
    }
        
    
    cout << difmin << " " << difmax;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

if len(a) == 1:
    ans = a[0]
else:
    ans = gcd(a[0],a[1])
    for i in range(2,n):
        ans = gcd(ans,a[i])

print(ans)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int n,m,k,f,x,y,i,h,g,flg,a,b,j;
int oya[100001],len[100001],bct[100001];
vector<int> hy[200000];
int main(void)
{
	cin>>n>>m>>k;
	for(i=0;i<k;i++){
		cin>>f>>a>>b;
		hy[i].push_back(f);
		hy[i].push_back(a);
		hy[i].push_back(b);
	}
	flg=0;
	for(i=1;i<=n;i++) oya[i]=i,len[i]=1,bct[i]=0;
	for(i=0;i<k;i++){
		x=hy[i][1]; y=hy[i][2]; 
		if(hy[i][0]==1){
			while(x!=oya[x]) x=oya[x];
			while(y!=oya[y]) y=oya[y];
			if(bct[x]!=0&&bct[y]!=0&&bct[x]!=bct[y]){
				printf("%d\n",i+1);
				flg=1;
			}
			if(bct[x]!=0&&bct[y]==0) bct[y]=bct[x];
			else bct[x]=bct[y];
			if(x!=y){
				if(len[x]>len[y]) oya[y]=x;
				else if(len[x]<len[y]) oya[x]=y;
				else oya[y]=x,len[x]++;
			}
		}
		else {
			if(bct[x]!=0&&bct[x]!=y){
				printf("%d\n",i+1);
				flg=1;
			}
			else if(bct[x]==0) bct[x]=y;
			while(x!=oya[x]){
				x=oya[x];
				if(bct[x]!=0&&bct[x]!=y){
					printf("%d\n",i+1);
					flg=1;
				}
				else if(bct[x]==0) bct[x]=y;
			}
		}
		if(flg==1) break;/*
		cout<<i<<endl;
		for(j=1;j<=n;j++) printf("%2d ",oya[j]);
		cout<<endl;
		for(j=1;j<=n;j++) printf("%2d ",bct[j]);
		cout<<endl;*/
	}
	if(flg==0) printf("0\n");
	return 0;
}


Measured memory_bytes: 15412
import math

def rot60(s, t):
    v = t - s
    a = 1/2 + complex(0,(math.sqrt(3)/2))
    return v * a + s

def pr(p):
    x = p.real
    y = p.imag
    print('%.10f %.10f'%(x, y))

def dfs(p1, p2, n):
    if n == 0:
        return
    

    s = (p2 - p1) * (1/3) + p1
    t = (p2 - p1) * (2/3) + p1
    u = rot60(s, t)
    dfs(p1, s, n - 1)
    pr(s)
    dfs(s, u, n - 1)
    pr(u)
    dfs(u, t, n - 1)
    pr(t)
    dfs(t, p2, n -1)
    
n = int(input())
s = (0 + 0j)
t = (100 + 0j)
pr(s)
dfs(s, t, n) 
pr(t)



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

using namespace std;

int extgcd(int a, int b, int &x, int &y) {
  x = 1, y = 0;
  int g = a;
  if(b != 0) {
    g = extgcd(b, a % b, y, x);
    y -= a / b * x;
  }
  return g;
}

int main() {
  int A, B;
  cin >> A >> B;
  int X, Y;
  extgcd(A, B, X, Y);
  cout << X << " " << Y << endl;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    ++mp[a];
  }
  int cnt = 0;
  for(auto v : mp) {
    if( v.first != v.second ) {
      if( v.second > v.first ) {
	cnt += ( v.second - v.first );
      } else {
	cnt += v.second;
      }
    }
  }
  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 4736
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define                   pi acos(-1)


int main () {
    ll n,an;
    cin>>n;
    an=n/2;
    if(n%2!=0)
        an++;
    cout<<an<<endl;
    End;
}
/* pray for me
All is well
*/





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

using namespace std;

int main()
{
	string str;
	char c[26];
	for (int i = 0; i < 26; i++)
	{
		c[i] = ' ';
	}
	cin >> str;

	for (int i = 0; i < str.length(); i++)
	{
		for (int h = 0; h < 26; h++)
		{
			if (str[i] == c[h])
			{
				cout << "no" << endl;
				return 0;
			}
		}
		c[i] = str[i];
			
	}

	cout << "yes" << endl;

	return 0;

	
}

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

int main() {
    ll H,W;
    cin >> H >>W;
   
    if(H%3 ==0 || W%3==0){
        cout << 0 << endl;
        return 0;
    }
     ll ans = min(H,W);
    //まずはHから分割
    for(int i=0;i<2;i++){
        vector<ll> temp;
        ll h = (H/3) +i;
        temp.push_back(h*W);
        ll w = W/2;
        temp.push_back((H-h)*w);
        temp.push_back((H-h)*(W-w));
        sort(temp.begin(),temp.end());
        ans = min(ans,temp[2]-temp[0]);
    }
    //Wを分割
     for(int i=0;i<2;i++){
        vector<ll> temp;
        ll w = (W/3) +i;
        temp.push_back(H*w);
        ll h = H/2;
        temp.push_back((W-w)*h);
        temp.push_back((W-w)*(H-h));
        sort(temp.begin(),temp.end());
        ans = min(ans,temp[2]-temp[0]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	LL m = n;

	if (m % 2 == 1) {
		cout << 0 << endl;
	}

	else {
		LL p5 = 5;
		LL cnt = 0;

		while (m >= p5) {
			cnt += m/(2*p5);
			p5 *= 5;
		}
		cout << cnt << endl;
	}
}

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

const int INF = 1000000000;
const int MAX_N = 100000;
struct edge {int to, s;};
vector<edge> G[MAX_N];
bool used[MAX_N];

struct constraint {bool sign; long long a;};
constraint c[MAX_N];
bool valid[MAX_N];

long long x;
int xmax, xmin;

bool dfs(int v) {
	used[v] = true;
	for(int i=0;i<G[v].size();i++) {
		edge e = G[v][i];
		constraint d = {!c[v].sign, e.s - c[v].a};
		if(valid[e.to]) {
			if(c[e.to].sign == d.sign) {
				if(c[e.to].a != d.a) return false;
			} else { // x + a == -x + b
				long long a = d.a - c[e.to].a;
				if(d.sign) a = -a;
				if(a % 2 == 1 || a <= 0) return false;
				if(x >= 0 && 2 * x != a) return false;
				x = a / 2;
			}
		} else {
			valid[e.to] = true;
			c[e.to] = d;
			if(d.sign && xmin < -d.a) xmin = -d.a;
			if(!d.sign && xmax > d.a) xmax = d.a;
		}
		if(!used[e.to]) {
			if(!dfs(e.to)) return false;
		}
	}
	return true;
}

int solve() {
	x = -1;
	xmin = 0;
	xmax = INF;
	c[0] = {true, 0};
	if(!dfs(0)) return 0;
	if(x >= 0) {
		if(xmin < x && x < xmax) return 1;
		else return 0;
	} else {
		int ans = xmax - xmin - 1;
		return ans > 0 ? ans : 0;
	}
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i=0;i<m;i++) {
		int u, v, s;
		scanf("%d %d %d", &u, &v, &s);
		u--; v--;
		G[u].push_back({v, s});
		G[v].push_back({u, s});
	}
	printf("%d\n", solve());
	return 0;
}


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

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

    long long x;
    cin >> x;

    long long ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int h, w, n, cou = 0;
    cin >> w >> h >> n;
    vector<vector<bool>> g(h, vector<bool>(w, false));
    for(int i = 0; i < n; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
        switch(a) {
        case 1:
            for(int j = 0; j < h; ++j) {
                for(int k = 0; k <x; ++k) {
                    g.at(j).at(k) = true;
                }
            }
            break;
        case 2:
            for(int j = 0 ; j < h; ++j) {
                for(int k = x; k < w; ++k) {
                    g.at(j).at(k) = true;
                }
            }
            break;
        case 3:
            for(int j = 0; j < y; ++j) {
                for(int k = 0; k < w; ++k) {
                    g.at(j).at(k) = true;
                }
            }
            break;
        case 4:
            for(int j = y; j < h; ++j) {
                for(int k = 0 ; k < w; ++k) {
                    g.at(j).at(k) = true;
                }
            }
        }
    }
    for(int i = h-1; i >=0; --i) {
        for(int j = 0; j < w; ++j) {
            if(!g.at(i).at(j)) {
                ++cou;
            }
            //cout << g.at(i).at(j);
        }
        //cout << endl;
    }
    cout << cou << endl;
}

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

int main()
{
	int n;
	cin>>n;
	vector<string> s(n);
	for(size_t i = 0; i<n; i++)
	{
		cin>>s[i];
	}
	sort(s.begin(),s.end());
	int max = 0;
	int l = 1;
	for(size_t i = 0; i<n-1; i++)
	{
		if(s[i]==s[i+1])
		{
			l++;
		}
		else
		{
			if(l>=max)
			{
				max = l;
			}
			l = 1;
		}
	}
	if(l>=max)
	{
		max = l;
	}
	l = 1;
	for(size_t i = 0; i<n-1; i++)
	{
		if(s[i]==s[i+1])
		{
			l++;
		}
		else
		{
			if(l==max)
			{
				cout<<s[i]<<endl;
			}
			l = 1;
		}
	}
	if(l==max)
	{
		cout<<s[n-1]<<endl;
	}
}

Measured memory_bytes: 14208
package main

import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    m := a
    if m < b {
        m = b
    }
    if m < c {
        m = c
    }
    fmt.Println(a + b + c + m * 9)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
	int debt, n;

	cin >> n;

	debt = 100000;

	for (int i = 0; i < n; i++){
		debt *= 1.05;
		if (debt % 1000 != 0){
			debt = debt - (debt % 1000);
			debt += 1000;
		}
	}

	cout << debt << endl;
}

Measured memory_bytes: 3072
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll H, W; cin >> H >> W;

    ll ans = INF;
    if (H % 3 == 0 || W % 3 == 0) ans = 0;
    else {
        FOR(i,1,W){
            ll s1 = i * H;
            ll s2 = (W - i)*((H + 1) / 2);
            ll s3 = (W - i)*(H / 2);
            ll smax = max(s1, max(s2, s3));
            ll smin = min(s1, min(s2, s3));
            ans = min(ans, smax - smin);

            s2 = ((W - i + 1) / 2) * H;
            s3 = ((W - i) / 2) * H;
            smax = max(s1, max(s2, s3));
            smin = min(s1, min(s2, s3));
            ans = min(ans, smax - smin);
        }

        FOR(i,1,H){
            ll s1 = W * i;
            ll s2 = ((W + 1) / 2)*(H - i);
            ll s3 = (W / 2)*(H - i);
            ll smax = max(s1, max(s2, s3));
            ll smin = min(s1, min(s2, s3));
            ans = min(ans, smax - smin);

            s2 = W * ((H - i + 1) / 2);
            s3 = W * ((H - i) / 2);
            smax = max(s1, max(s2, s3));
            smin = min(s1, min(s2, s3));
            ans = min(ans, smax - smin);
        }
    }

    cout << ans << endl;  

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> pre, in, post;
int pos = 0;

void reconstruction(int l, int r)
{
  if(l >= r)  return ;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  reconstruction(l, m);
  reconstruction(m+1, r);
  post.push_back(root);
}

void solve()
{
  int n = in.size();
  reconstruction(0, n);
  for(int i=0; i < n; i++)
  {
    if(i) printf(" ");
    cout << post[i] ;
  }
  printf("\n");
}

int main()
{
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    int t;
    scanf("%d", &t);
    pre.push_back(t);
  }
  for(int i=0; i<n; i++)
  {
    int t;
    scanf("%d", &t);
    in.push_back(t);
  }
  solve();

  return 0;
}



Measured memory_bytes: 3240
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;


int main() {
    int n = 0;
    cin >> n;
    vector<ll> a(n+1);
    ll buf = 0;
    for (int i=1; i<n+1; i++) {
        cin >> buf;
        a.at(i) = buf + a.at(i-1);
    }
    sort(a.begin(), a.end());
    ll counter = 1;
    ll ans = 0;
    for (int i=1; i<n+1; i++) {
        if (a.at(i) != a.at(i-1)) {
            ans += (counter-1)*counter/2;
            counter = 1;
        }
        else {
            counter++;
        }
    }
    ans += (counter-1)*counter/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124
{
    class Program
    {
        static void Main(string[] args)
        {
            //Buttons(); // 8min
            GreatOceanView();
        }

        static void GreatOceanView()
        {
            int n = ReadInt();
            int[] xs = ReadIntArray();

            int ans = 0;
            int max = 0;

            for(int i = 0; i < n; i++)
            {
                if (max <= xs[i])
                {
                    max = xs[i];
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }

        static void Buttons()
        {
            int[] xs = ReadIntArray();

            int ans = 0;

            for(int i = 0; i < 2; i++)
            {
                if (xs[0] > xs[1])
                {
                    ans += xs[0]--;
                }
                else
                {
                    ans += xs[1]--;
                }
            }

            Console.WriteLine(ans);
        }

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<ll> x(m, 0);
  for(int i = 0; i < m; i++)
  {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  if(n < 2)
  {
    ll result = 0;
    for(int i = 1; i < m; i++)
    {
      result += x[i] - x[i - 1];
    }
    cout << result << endl;
    return 0;
  }else if(n >= m)
  {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> memo;
  for(int i = 0; i < m - 1; i++)
  {
    memo.push_back(x[i + 1] - x[i]);
  }
  sort(memo.begin(), memo.end());
  reverse(memo.begin(), memo.end());
  ll result = x[m - 1] - x[0];
  for(int i = 0; i < n - 1; i++)
  {
    result -= memo[i];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>

int main()
{
    long long N,A,B,b;
    scanf("%lld %lld %lld",&N,&A,&B);
    if (N%(A+B)>=A) {
        b = N/(A+B)*A + A;
    }
    else {
        b = N/(A+B)*A + N%(A+B);
    }
    printf("%lld\n",b);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double

int main() {

  int N, M;
  cin >> N >> M;

  cout << (1 << M) * (100 * (N - M) + M * 1900) << endl;

  return 0;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

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

    int ans=0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        ans += min(2 * t, 2 * abs(t-k));
    }

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

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int N=200000+10;
const int mod=1e9+7;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
int inv[N],jc[N];
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m){
	return jc[n]*inv[m]%mod*inv[n-m]%mod;
}
int calc(int x,int y,int X,int Y){
	int n=abs(X-x),m=abs(Y-y);
	return C(n+m,n);
}
main(){
    //file("");
	jc[0]=1;
	for(int i=1;i<=N-10;i++)
		jc[i]=jc[i-1]*i%mod;
	inv[N-10]=ksm(jc[N-10],mod-2);
	for(int i=N-11;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%mod;
	int H=read(),W=read(),A=read(),B=read(),ans=calc(1,1,H,W);
	for(int i=H-A+1;i<=H;i++)
		ans=(ans-calc(1,1,i,B)*calc(i,B+1,H,W)%mod+mod)%mod;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3328
n=gets.chomp.to_i
t = n
kq = 0
stt = t.to_s.length
if stt == 1
  kq = n
elsif(stt%2==0)
  for num in 1..(stt-1) do
    if num % 2 == 1
      kq += 10**(num-1)*9
    end
  end  
elsif(stt%2==1)
  for num in 1..(stt-2) do
    if num % 2 == 1
      kq += 10**(num-1)*9
    end
  end
  kq = kq + n + 1 - 10**(stt-1)
end
puts kq


Measured memory_bytes: 1788
A, B = map(int, input().split())
a_0 = int((25 * A + 1) / 2)
a_1 = int((25 * (A + 1) - 1) / 2)
b_0 = int(10 * B)
b_1 = int(10 * (B + 1) - 1)
if a_0 >= b_0 and a_0 <= b_1:
    print(a_0)
elif b_0 >= a_0 and b_0 <= a_1:
    print(b_0)
else:
    print('-1')

Measured memory_bytes: 9124
K, A, B = map(int, input().split(" "))

if B - A <= 1:
    print(K + 1)
else:
    bisket_sum = A
    k_remained = K - A + 1
    bisket_sum += (k_remained // 2) * (B - A)
    bisket_sum += k_remained % 2
    print(bisket_sum)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,sum,ans;
string st;
map<long long,long long> mp;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n;
	mp[0]=1;
	for (i=1;i<=n;i++)
	{
		long long x;
		cin>>x;
		sum+=x;
		ans+=mp[sum];
		mp[sum]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll Q,H,S,D;
    cin >> Q >> H >> S >> D;
    H=min(2*Q,H);
    S=min(2*H,S);
    D=min(2*S,D);
    ll N;
    cin >> N;
    cout << N/2*D+S*(N%2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  int n;
  cin>>n;
  int temp=n%10;
  if(temp==2|| temp==4 || temp==5 || temp==7 || temp==9)
  {
    cout<<"hon"<<endl;
  }
  else if(temp==0|| temp==1 || temp==6 || temp==8)
  {
    cout<<"pon"<<endl;
  }
  else
  {
    cout<<"bon"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ffor(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) ffor(i, 0, j, 1)
#define rrep(i, j) rfor(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
//#define f first
//#define s second
#define inf (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define trace1(x)                     cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)        cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double pi=acos(-1.0);
typedef pair<long long int,long long int> pii;
typedef long long ll;
typedef vector<long long int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<long long int,long long int> mpii;
typedef set<long long int> sei;
typedef multiset<long long int> msei;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
ll dp[3000+1][3000+1];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    if(n%2==0)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n-i+1;j++)
            {
                if(i==1)
                dp[i][j]=a[i];
                else if(i==2)
                dp[i][j]=max(a[j]-a[j+1],a[j+1]-a[j]);
                else
                {
                    dp[i][j]=max(a[j]-dp[i-1][j+1],a[i+j-1]-dp[i-1][j]);
                }
            }
        }
    }
    else
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n-i+1;j++)
            {
                if(i==1)
                dp[i][j]=a[i];
                else if(i==2)
                dp[i][j]=max(a[j]-a[j+1],a[j+1]-a[j]);
                else
                {
                    dp[i][j]=max(a[j]-dp[i-1][j+1],a[i+j-1]-dp[i-1][j]);
                }
            }
        }
    }
    cout<<dp[n][1];
    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	int64_t N;
	std::cin >> N;
	int64_t c = 0;

	for (int64_t n = 0; n < N; ++n)
	{
		int64_t a;
		std::cin >> a;
		if (((n + 1) % 2 == 1) && (a % 2 == 1)) {
			++c;
		}
	}

	std::cout << c << std::endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#define DEBUG

int main(){

	char strW[11] ={};					//????????????????±?
	char END[12]={"END_OF_TEXT"};		//???????????¶??¨
	char strT[1001]={};					//????????????????????¨

	int i = 0;							//???????????°
	int cnt = 0;						//????????????

	scanf("%s",strW);			//????????????????±?????????????????????????
#ifdef DEBUG
	printf("strW???%s\n",strW);
#endif

	for(i = 0 ; strW[i] != '\0' ; i++){		//strW[i]???\0??????????????§for????????????
		if(isupper(strW[i])){				//??§??????????????°
			strW[i] = tolower(strW[i]);		//?°?????????????????????????
		}
	}
#ifdef DEBUG
	printf("?°???????????????????????????????strW???%s\n",strW);
#endif


	/*???????????????????????????*/
	while(1){
		scanf("%s",strT);				//?¬?????????????????????????
#ifdef DEBUG
	printf("strT???%s\n",strT);
#endif
		if(!strcmp(strT,END)){			//strT???END_OF_TEXT?????£??????
			printf("%d\n",cnt);			//???????????????????????¨?????????
			return 0;					//?????????????????????????????????
		}

		/*???????????£??????????????¨????°??????????????????????*/
		for(i = 0 ; strT[i] != '\0' ; i++){		//strT[i]???\0??????????????§for????????????
			if(isupper(strT[i])){				//??§??????????????°
			strT[i] = tolower(strT[i]);		//?°?????????????????????????
			}
		}//?°??????????????????????????????§

#ifdef DEBUG
	printf("?°???????????????????????????????strT???%s\n",strT);
#endif

		if(!strcmp(strT,strW)){			//strT???strW??¨?????´????????°strcmp???????????????0
			cnt++;						//????????´?????????????????¢??????
		}

	}//?????????????????????????????§?????????return?????\?????§??????????????¨????????????
	return 0;
}

Measured memory_bytes: 552
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s1 = in.next(), s2 = in.next();
        char[][] dm = {s1.toCharArray(), s2.toCharArray()};
        long ans = 1;
        int mod = 1000000007;
        
        int before = 0;
        for(int i = 0; i < n; i++) {
            if(i == 0) {
                if(dm[0][i] == dm[1][i]) {
                    ans = 3;
                    before = 1;
                }else {
                    ans = 6;
                    i++;
                    before = 2;
                }
            }else {
                if(dm[0][i] == dm[1][i]) {
                    ans = (ans % mod) * (long)(before == 1 ? 2 : 1);
                    before = 1;
                }else {
                    ans = (ans % mod) * (long)(before == 1 ? 2 : 3);
                    i++;
                    before = 2;
                }
            }
        }
        System.out.println(ans % mod);
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int r=0;int w=0;
  rep(i,n){
    if(s[i]=='R')++r;
    else ++w;
  }
  int res=0;
  rep(i,r){
    if(s[i]=='W')++res;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define forn(i, a, b) for(int i=(a); i<=(b); i++)
#define rforn(i, a, b) for(int i=(a); i>=(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define gcd __gcd
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define mod 1000000007
#define endl '\n'
#define int ll
using namespace std;
#define N 100005
#define inf 100000000000009LL


int32_t main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    clock_t clk = clock();

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

    for(int i = 1; i < n; i++){
        a[i] += max(b[i-1] , c[i-1]);
        b[i] += max(c[i-1] , a[i-1]);
        c[i] += max(b[i-1] , a[i-1]);
    }
    
    cout << max(a[n-1] , max(b[n-1] , c[n-1])) ;
    cerr<< "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
}

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

using Vec = std::vector<int>;

void print_vec(Vec vec) {
    for (auto iter = vec.begin(); iter != vec.end(); ++iter) {
        std::cout << *iter;
        if (iter != vec.end() - 1) std::cout << ' ';
    }
    std::cout << std::endl;
}

int main(void) {
    int n;
    std::cin >> n;

    Vec vec{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        vec.push_back(a);
    }
    Vec vec0(vec);

    if (std::prev_permutation(vec.begin(), vec.end())) print_vec(vec);
    print_vec(vec0);
    if (std::next_permutation(vec0.begin(), vec0.end())) print_vec(vec0);
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(N - 1) - a.at(0) << endl;
}


Measured memory_bytes: 256
S=input()
while 1:
    l=len(S)
    if S[-7:]   =="dreamer":
        S=S[0:l-7]
    elif S[-5:] =="dream":
        S=S[0:l-5]
    elif S[-6:] =="eraser":
        S=S[0:l-6]
    elif S[-5:] =="erase":
        S=S[0:l-5]
    else:break
if S=="":
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
  int n,z=0;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0) z++;
  }
  if(z>0){
    cout<<0<<endl;
    return 0;
  }
  long long prod=1;
  for(int i=0;i<n;i++){
    if(a[i]<=1000000000000000000/prod){
      prod *=a[i];
    }
    else{
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<prod<<endl;
  return 0;
}
    


Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
int N, M;

int main() {
  cin >> N >> M;
  priority_queue<int> A;
  int64_t sum;
  for(int i=0,x; i<N; i++){cin >> x;A.push(x);}
  
  while(M--){
    int temp = A.top(); A.pop();
    A.push(temp/2);
  }

  while(!A.empty()){sum += A.top(); A.pop();}

  cout << sum << endl; 
  return 0;
}

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

int n, ut, va;
vector<vector<int>> g(100010);
vector<int> depth(100010), mxd(100010), par(100010);

void dfs(int v, int p) {
    par[v] = p;
    for (auto u : g[v])
        if (u != p) {
            depth[u] = depth[v] + 1;
            dfs(u, v);
            mxd[v] = max(mxd[u] + 1, mxd[v]);
        }
}

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

    cin >> n >> ut >> va;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(va, -1);
    ll ans = (depth[ut] - 1) / 2;
    ll x = depth[ut];
    rep(i, 0, ans) ut = par[ut];
    cout << ans + mxd[ut] + (x - 1) % 2 << endl;

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[5] == '0' && (s[6] == '4'||s[6] == '3'||s[6] == '2'||s[6] == '1')) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

typedef long long ll;
ll dp[4000][7000];
struct node
{
    ll t,w;
    bool operator <(const node &x) const
    {
        return t<x.t;
    }
}p[4000];
int main()
{
    ll n,T;
    scanf("%lld%lld", &n, &T);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&p[i].t,&p[i].w);
    }
    sort(p+1,p+1+n);
    for(int i=1;i<=n;i++){
        for(int j=0;j<T+p[i].t;j++){
            if(j<p[i].t) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i].t]+p[i].w);
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,dp[n][T+p[i].t-1]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 156248
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
ll n,x,a,gc;
cin >> n>>x;
vector <ll> v;
for(int i=0;i<n;i++){
  cin >> a;
  v.push_back(a);
}
v.push_back(x);
gc=1e9;
sort(v.begin(),v.end());
for(int i=1;i<n+1;i++){
  ll t=abs(v[i-1]-v[i]);
  if(i==1) gc=t;
  else gc=gcd(t,gc);
}
cout << gc<<endl;
}


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

int main() {
  int N ;
    cin>>N ;
  if(1<=N&&N<=9)
    cout<<N<<endl;
  else if(10<=N&&N<=99)
    cout<<"9"<<endl;
  else if(100<=N&&N<=999)
    cout<<9+(N-99)<<endl;
  else if(1000<=N&&N<=9999)
    cout<<"909"<<endl;
  else if(10000<=N&&N<=99999)
    cout<<909+(N-9999)<<endl;
  else {
    cout<<"90909"<<endl;
  }
}

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

int main() {
	int N,M,C;
	int i,j,count,wa;
	count = 0;
	wa = 0;

	cin >> N >> M >> C;

	vector<vector<int>> A(N,vector<int>(M));
	vector<int> B(M);


	for (i = 0; i < M; i++) {
		cin >> B[i];
	}
	
	for (j = 0; j < N; j++) {
		for (i = 0; i < M; i++) {
			cin >> A[j][i];
		}
	}

	for (j = 0; j < N; j++) {
		for (i = 0; i < M; i++) {
			wa += A[j][i] * B[i];
		}

		if (wa + C > 0)
			count++;
		wa = 0;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256