akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
for _ in range(N - 1):
  u, v, c = map(int, input().split())
  e[u].append((v, c))
  e[v].append((u, c))
Q, K = map(int, input().split())

dp = [10 ** 15] * (N + 1)
dp[K] = 0
s = [K]
while len(s):
  x = s.pop()
  for y, d in e[x]:
    if dp[y] > dp[x] + d:
      s.append(y)
      dp[y] = dp[x] + d

for _ in range(Q):
  u, v = map(int, input().split())
  print(dp[u] + dp[v])

Measured memory_bytes: 104716
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(b-a == c-b){
			System.out.println("YES");
		}else{
			System.out.println("NO");

		}

		}

	}

	class Pair implements Comparable{
		Character from;
		int end;
		@Override
		public int compareTo(Object other) {
			Pair otherpair = (Pair)other;

			return end - otherpair.end;
		}
	}




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

using namespace std;

const int mod = 998244353;

class BinomialCoefficients{
  int max;
  int mod;
  long long *factorial;
  long long *factorial_inverse;
  long long *inverse;

public:
  int get(int n, int k){
    if(n < 0 || k < 0 || k > n) return 0;
    else return factorial[n] * (factorial_inverse[k] * factorial_inverse[n - k] % mod) % mod;
  }

  BinomialCoefficients(int max = 1000000, int mod = 998244353) : max(max), mod(mod){
    factorial = new long long[max + 1];
    factorial_inverse = new long long[max + 1];
    inverse = new long long[max + 1];

    factorial[0] = factorial[1] = 1;
    factorial_inverse[0] = factorial_inverse[1] = 1;
    inverse[1] = 1;

    for(int k = 2; k <= max; k++){
      factorial[k] = factorial[k - 1] * k % mod;
      inverse[k] = mod - inverse[mod % k] * (mod / k) % mod;
      factorial_inverse[k] = factorial_inverse[k - 1] * inverse[k] % mod;
    }
  }

  ~BinomialCoefficients(){
    delete [] factorial;
    delete [] factorial_inverse;
    delete [] inverse;
  }
};

constexpr long long power(long long b, long long e, long long mod){
  long long ret = 1;
  while(e){
    if(e & 1){
      ret *= b;
      ret %= mod;
      e--;
    }

    b *= b;
    b %= mod;
    e >>= 1;
  }

  return ret;
}

constexpr long long power(long long b, long long e){
  return power(b, e, mod);
}


int main(){
  int N, M, K;
  cin >> N >> M >> K;
  
  long long ans = 0;
  
  BinomialCoefficients binom(1000000);
  for(int k = 0; k <= K; k++){
    ans += (long long)binom.get(N - 1, k) * M % mod * power(M - 1, N - k - 1) % mod;
    ans %= mod;
  }
  
  if(ans < 0ll) ans += mod;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 26756
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
const static int MOD = (1e+9)+7;

int main(){
    int n,m; cin >> n >> m;
    int h[n];
    rep(i,n) cin >> h[i];
    int a[m],b[m];
    vector<vector<int>> v(n);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        v[a[i]].pb(b[i]);
        v[b[i]].pb(a[i]);
        
    }
    int ans=0;
    rep(i,n){
        bool ok=1;
        for(auto u:v[i]){
            if(h[u]>=h[i]) ok=0;
        }
        if(ok) ans++;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 9544
def main():
    abcd = list(input())
    can_break = False
    for i in range(8):
        if can_break:
            break
        p = [""] * 3
        for j in range(3):
            if (i >> j) & 1:
                p[j] = "+"
            else:
                p[j] = "-"
        now = abcd[0] + p[0] + abcd[1] + p[1] + abcd[2] + p[2] + abcd[3]
        if eval(now) == 7:
            print(now + "=7")
            can_break = True
            break


if __name__ == '__main__':
    main()



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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

  cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
  
  return 0;
}




Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	veci p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));
	int aaa, bbb, ccc;
	aaa = bbb = ccc = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] <= a)
			aaa++;
		if (a < p[i] && p[i] <= b)
			bbb++;
		if (p[i] > b)
			ccc++;
	}
	cout << min({aaa, bbb, ccc}) << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

void calc(int N, const vector<vector<int>> &g, 
	vector<int> &c, vector<bool> &visited, int x, int parent)
{
	visited[x] = true;
	for (auto dst : g[x]) {
		if (dst != parent && !visited[dst]) {
			c[dst] += c[x];
			calc(N, g, c, visited, dst, x);
		}
	}
}

int main()
{
	int N, Q;
	cin >> N >> Q;

	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> c(N, 0);
	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> p >> x;
		--p;
		c[p] += x;
	}

	vector<bool> visited(N, false);
	calc(N, g, c, visited, 0, -1);
	for (auto x : c) {
		cout << x << " ";
	}
}


Measured memory_bytes: 29696
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans[] = new int[n];
    int c = y-x;
    int d;
    for(int i = 1; i < n; i++){
      for(int j = n; j > i; j--){
        d = j-i;
        if(i<=x&&y<=j){
          ans[x-i+j-y+1]++;
        } else if(i<=x&&j<y){
          if(d < x-i+1+y-j){
            ans[d]++;
          } else {
            ans[x-i+1+y-j]++;
          }
        } else if(x<i&&i<y&&y<=j){
          if(d < i-x+j-y+1){
            ans[d]++;
          } else {
            ans[i-x+j-y+1]++;
          }
        } else if(x<i&&i<y&&j<y){
          if(d < i-x+1+y-j){
            ans[d]++;
          } else {
            ans[i-x+1+y-j]++;
          }
        } else {
          ans[d]++;
        }
      }
    }
    for(int i = 1; i < n; i++){
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 24404
# グラフ BFS 最短距離　高橋＜青木 で青木君から1番遠いところ

n, u, v = gets.split.map(&:to_i)
edges = []
(n - 1).times { edges << gets.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
# 無向グラフなので両始点のグラフに入れる
edges.each do |f, t|
  graph[f] << [f, t]
  graph[t] << [t, f]
end

takahashi_weights = Array.new(n + 1)
aoki_weights = Array.new(n + 1)
takahashi_queue = [[u, u, 0]]
aoki_queue = [[v, v, 0]]

until takahashi_queue.empty?
  from, to, weight = takahashi_queue.shift
  takahashi_weights[to] = weight
  graph[to].each do |f, t|
    # 逆流しないようにする（両方のグラフに入れているので必ず1つ該当する）
    next if t == from
    takahashi_queue << [f, t, weight + 1]
  end
end

until aoki_queue.empty?
  from, to, weight = aoki_queue.shift
  aoki_weights[to] = weight
  graph[to].each do |f, t|
    # 逆流しないようにする（両方のグラフに入れているので必ず1つ該当する）
    next if t == from
    aoki_queue << [f, t, weight + 1]
  end
end

# 高橋君が先に到着するノード
takahashi_first_nodes = (1..n).each.select { |i| takahashi_weights[i] < aoki_weights[i] }
# 上記のうち、青木君から1番遠いノード
max_index = takahashi_first_nodes.max_by { |i| aoki_weights[i] }
puts aoki_weights[max_index] - 1


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
        int[] ans = new int[n+1];
        for(int a = 1; a <= 100; a++){
            for(int b = 1; b <= 100; b++){
                for(int c = 1; c <= 100; c++){
                    int val = a*a + b*b + c*c + a*b + a*c + c*b;
                    if(val <= n){
                        ans[val]++;
                    }
                }
            }
        }

        for(int i = 1; i <= n; i++){
            System.out.println(ans[i]);
        }
	}
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b)cout << "No" << endl;
    else cout << "Yes" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10000019,MAXM=100010,P=26;
int n,hd[MAXN+10],nx[MAXM],cnt[MAXM],sum;
long long ans,hs,val[MAXM];
char s[20];
int query (long long hs) {
	long long md=hs%MAXN;
	if (!hd[md]) {
		hd[md]=++sum;
		val[sum]=hs,cnt[sum]=1;
		return 0;
	}
	int pre;
	for (int i=hd[md];i;i=nx[i]) {
		pre=i;
		if (val[i]==hs) {
			cnt[i]++;
			return cnt[i]-1;
		}
	}
	nx[pre]=++sum;
	val[sum]=hs,cnt[sum]=1;
	return 0;
}
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%s",s+1);
		sort(s+1,s+11);
		hs=0;
		for (int i=1;i<=10;i++) {hs=hs*P+s[i]-'a';}
		ans+=query(hs);
	}
	printf("%lld\n",ans);
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) ans += (s[i] != t[i]);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	int H,W;

	cin>>H>>W;
	
	map<char,int> mp;

	REP(i,H){
		REP(j,W){
			char k;
			cin>>k;
			mp[k]++;
		}
	}
	
	// for(auto& s : mp){
	// 	cout<<s.second<<endl;
	// }
	int four_num,two_num,one_num;
	

	if( H % 2 == 0){

		if( W % 2 == 0){
			
			four_num = (H / 2) * (W / 2);
			two_num = (H * W - four_num * 4) / 2;
			one_num = 0;
		}
		else{
			four_num = (H / 2 ) * (W / 2);
			two_num = (H * W - four_num * 4) / 2;
			one_num = 0;
		}

	}
	else{

		if( W % 2 == 0){
			
			four_num = (H / 2) * (W / 2);
			two_num = (H * W - four_num * 4) / 2;
			one_num = 0;
		}
		else{
			four_num = (H / 2 ) * (W / 2);
			one_num = 1;
			two_num = (H*W - (four_num * 4 + one_num))/2;
		}
	}
	// cout<<four_num<<","<<two_num<<","<<one_num<<endl;
	
	for(auto& s: mp){
		
		if(s.second % 2 ==  1){
			one_num -= 1;
			s.second -= 1;
		}

		if(s.second >= 4 ){
			
			int test = s.second / 4;
			if(test > four_num){
				s.second -= four_num * 4;
				four_num = 0;
			}
			else{
				four_num -= test;
				s.second -= test * 4;
			}
		}

		if(s.second % 2 == 0){
			int test2 = s.second / 2;

			if(test2 > two_num){
				two_num = 0;
				s.second -= two_num * 2;
			}
			else{
				two_num -= test2;
				s.second -= test2 * 2;
			}
		}
	}	

	int sum = 0;
	for(auto& s : mp){
		sum += s.second;
	}
	bool ans = false;	
	if((sum == 0) && (one_num == 0) && (two_num == 0) &&( four_num == 0))ans = true;
	// cout<<four_num<<","<<two_num<<","<<one_num<<endl;

	
	cout<< (ans ? "Yes" : "No")<<endl;	
	// for(auto& s : mp){
	// 	cout<<s.second<<endl;
	// }
	return 0;
}


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

long long cnt(long long val)
{
  long long keta = 0, digits = log10(val);
  for(int i = 0; i < digits; i++) keta += 9LL * pow(10, i) * (i + 1);
  keta += (val - pow(10, digits) + 1) * (digits + 1);
  return(keta);
}

int main()
{
  int K, N;
  while(cin >> N >> K, N) {
    
    long long low = 1, high = 1LL << 30;
    while(high - low > 0) {
      int mid = (low + high) >> 1;
      if(cnt(mid) < N) low = mid + 1;
      else high = mid;
    }
    long long get = cnt(low);
    string S;
    stringstream ss;
    ss << low; 
    int ptr = ss.str().size();
    for(low; S.size() < K + 10; low++) {
      stringstream sss;
      sss << low;
      S += sss.str();
    }
    cout << S.substr(ptr - get + N - 1, K) << endl;
  }
}

Measured memory_bytes: 1288
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,t;
  int ans=1;
  cin>>n;
  rep(i,n){
    cin>>t;
    ans=ans/__gcd(ans,t)*t;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc118/tasks/abc118_a
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    
    vector<int> v;
    for( int i = 1; i <= B; i++ )
    {
        if( B % i == 0 )
        {
	       v.emplace_back( i );
        }
    }
    cout << ( count( ALL( v ), A ) == 1 ? A + B : B - A ) << endl;
    return 0;
}

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

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	if (N > M) swap(N, M);

	for (int i = 1; i <= M; i++) printf("%d", N);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;
const int MAX=1e6+10;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int 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;
    }
}

int powMOD(int x,int p){
  	int res=1;
    while(p>0){
        if(p & 1)res=res*x%MOD;
        x=x*x%MOD;
        p>>=1;
    }
    return res;
}

map<int,int>ace;
void bunkai(int x){
    map<int,int>memo;
    for(int i=2;i<=sqrt(x);i++){
        while(x%i==0){
            x/=i;
            memo[i]++;
        }
        ace[i]=max(memo[i],ace[i]);
    }
    if(x!=0)memo[x]++;
    ace[x]=max(ace[x],memo[x]);
}

signed main(){
    COMinit();
  	int N;cin>>N;
    int A[N];
    int d=1;
    REP(i,N){
        cin>>A[i];
        bunkai(A[i]);
    }
    for(auto it=ace.begin();it!=ace.end();it++){
        int f=it->first;
        int r=it->second;
        d*=powMOD(f,r);
        d%=MOD;
    }
    while(d<0)d+=MOD;
  	int ans=0;
    REP(i,N){
        ans+=d*inv[A[i]]%MOD;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 24448
import 'dart:io';

main(List<String> args) {
  String S = stdin.readLineSync();
  int N = S.length;
  int id = N;
  bool flag = true;
  while (id > 1) {
    S = S.substring(0, id);
    if (S.endsWith("dreamer")) {
      id -= 7;
    } else if (S.endsWith("eraser")) {
      id -= 6;
    } else if (S.endsWith("dream") || S.endsWith("erase")) {
      id -= 5;
    } else {
      flag = false;
      break;
    }
  }
  if (flag) {
    print("YES");
  } else {
    print("NO");
  }
}

Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e18
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
ll dp[100005];
ll mod=1e9+7;
vll adj[100005];
ll dfs(ll v)
{
    if(dp[v]!=-1)
        return dp[v];
    rep(i,adj[v].size())
        dp[v]=max(dp[v],dfs(adj[v][i])+1);
    return dp[v];
}
int main()
{
    fio;
    fill(dp,-1);
    //cout<<dp[0];
    ll n,m;
    cin>>n>>m;
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    repA(i,1,n)
    if(adj[i].size()==0)
        dp[i]=0;
    repA(i,1,n)
        dp[i]=dfs(i);
    ll ans=MIN;
    repA(i,1,n)
        ans=max(ans,dp[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N ;
    string S,T;
    cin >> S >> T;
    rep(i,N){
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

int main()
{
  long long n;
  long long flow;
  std::vector<long long> v(5);
  std::cin >> n >> v.at(0) >> v.at(1) >> v.at(2) >> v.at(3) >> v.at(4);
  flow = n;
  long long cnt = 0;
  long long min_path = LLONG_MAX;
  for (int i = 0; i < 5; i++) {
    min_path = std::min(min_path, v.at(i));
  }
  if (flow % min_path == 0) {
    cnt = flow / min_path + 4;
  } else {
    cnt = flow / min_path + 5;
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  rep(i,d-b) cout << 'U';
  rep(i,c-a+1) cout << 'R';
  rep(i,d-b+1) cout << 'D';
  rep(i,c-a+1) cout << 'L';
  cout << 'U';
  cout << 'L';
  rep(i,d-b+1) cout << 'U';
  rep(i,c-a+1) cout << 'R';
  rep(i,d-b+1) cout << 'D';
  rep(i,c-a) cout << 'L';
  cout << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3636
/*
   * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
   * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
   * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
   * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
   * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
         * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
         * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
   * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
   * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
#define shit while(t--)
#define fr for(int i=0;i<n;i++)
int maxo=1e9+7;
using namespace std;
int arr[95];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d,ans=-1000000000000000000;
    cin>>a>>b>>c>>d;

    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,c*b);
    ans=max(ans,d*b);

    cout<<ans<<endl;

    return 0;
}


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

int main() {

    int a, b;
    cin >> a >> b;
    int x = 0;
    if (a > b) {
        x += a;
        a--;
    }
    else {
        x += b;
        b--;
    }
    cout << x + max(a, b);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
int main(){
    int max =0;
    int nowL =0;
    string in;
    cin >> in;
 
    for(int i=0;i<in.size();i++){
        switch(in[i]){
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                nowL++;
                if(nowL>max)max = nowL;
                break;
            default:
                nowL = 0;
                break;
        }
    }
 
    cout<<max;
    return 0;
 
}

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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 1e5 + 10;
int a[N], n, m, v, p;
bool cmp(int x, int y) { return x > y; }
bool check(int i) {
	LL S = 1ll * max(0, v - (n - i + p)) * m, t = 0;
//	printf("%lld\n", S);
	for (int j = p; j < i; j++) {
		if (a[i] + m < a[j]) return 0;
		t += a[i] + m - a[j];
	}
	return t >= S;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>(), m = gi<int>(), v = gi<int>(), p = gi<int>();
	for (int i = 1; i <= n; i++) a[i] = gi<int>();
	sort(a + 1, a + 1 + n, cmp);
//	printf("%d\n", check(4));
	int l = p + 1, r = n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", l - 1);
	return 0;
}


Measured memory_bytes: 640
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn f(s: &[char]) -> bool {
    trace!(&s);
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.chars();
    let n = s.len();
    put!(if f(&s) && f(&s[0..(n-1)/2]) && f(&s[(n+3)/2-1..n]) {
        "Yes"
    } else {
        "No"
    });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    set<int> v;
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= a+k-1; ++i) {
        if(i > b) break;
        else v.insert(i);
    }
    for (int j = b; j >= b-k+1; --j) {
        if(j < a) break;
        else v.insert(j);
    }
    for (auto &&x : v) {
        cout << x << "\n";
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    
	unsigned long long sum = 0;
    int n, q;
    int seq[100001] = {};
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
        seq[a]++;
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int c, b;
        cin >> b >> c;
        seq[c] += seq[b];
        sum += seq[b] * (c-b);
        seq[b] = 0;
        cout << sum << endl;
    }
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << (a[0]*a[1])/2;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

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

amin = 10 ** 9 + 1
cntm = 0
asum = 0
for a in A:
    if a < 0:
        cntm += 1
        amin = min(amin, -a)
        asum -= a
    else:
        amin = min(amin, a)
        asum += a
#    print("cntm={},amin={},asum={}".format(cntm,amin,asum))

if(cntm % 2):
    print(asum - 2 * amin)
else:
    print(asum)


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

int main(void){
    int sum = 0;
    int n,l;
    cin >> n >> l;
    int p[n],q[n];
    for(int i=0; i<n; i++){
        p[i] = l + i;
        sum = sum + p[i];
    }
    
    for(int i=0; i<n; i++){
        q[i] = sum - p[i];
        q[i] = abs(sum - q[i]);
    }

    int saisyo = abs(sum);
    int ans = saisyo,j = 0;
    while(ans != 0 and j < n){
        if(q[j] < saisyo){
            saisyo = q[j];
            ans = sum - p[j];
        }
        j++;
    }
    cout << ans << endl;    

    return 0;
}

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

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    vector<ll> b(n);

    rep(i, 0, n-1)
        cin >> b[i];

    vector<ll> a(n+1, 0);

    a[0] = b[0];
    rep(i, 1, n)
    {
        a[i] = b[i-1];

        if (b[i] < b[i-1])
            a[i] = b[i];
    }
    a[n-1] = b[n-2];

    ll sum (0);
    rep(i, 0, n)
    {
        //cout << a[i] << endl;
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}


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

int T,E;
int f(int x){
	for(int i = 1 ; x * i <= T+E ; i++){
		if( T-E <= x * i && x * i <= T+E ){
			return 1;
		}
	}
	return 0;
}
int main(){
	int N;
	while(cin >> N >> T >> E){
		rep(i,N){
			int x;
			cin >> x;
			if( f(x) ){
				cout << i + 1 << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)

const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

ll a,b,c,d;

ll gcd(ll a,ll b)
{
    return b>0?gcd(b,a%b):a;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> a >> b >> c >> d;
    ll ans = b - a + 1;
    ans -= b / c - (a - 1) / c;
    ans -= b / d - (a - 1) / d;

    ll t = c * d / gcd(c,d);
    ans += b / t - (a - 1) / t;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);

    ll T0, A0, T1 = 0, A1 = 0;
    cin >> T0 >> A0;
    ll times = 1;

    for (int i = 1; i < N; i++) {

        ll t, a;
        cin >> t >> a;

        for (int j = 0; j < t; j++) {
            T1 = T0 + j;
            if (T1 % t==0) break;
        }
        for (int j = 0; j < a; j++) {
            A1 = A0 + j;
            if (A1 % a==0) break;
        }

        if ( T1 / t * a > A1 ) {
            A1 = T1 / t * a;
        } else {
            T1 = A1 / a * t;
        }
        T0 = T1, A0 = A1;
    }

    cout << max(T0+A0,T1+A1) << "\n";
    return 0;
}

Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;



int main() {
	int N,count=0,max=0,j=0;
	cin >> N;
	vector<string>S(N);
	vector<int>moji(N,0);
	FOR(N) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	FOR(N) {
		while (i!=N-1&&S[i] == S[i + 1]) {
			count++;
			i++;
		}
		if (count > max) {
			max = count;
		}
		count = 0;
	}
	FOR(N) {
		while (i != N - 1 && S[i] == S[i + 1]) {
			count++;
			i++;
		}
		if (count == max) {
			moji[j]=i;
			j++;
		}
		count = 0;
	}
	FOR(j) {
		cout << S[moji[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
// AOJ 0115: Starship UAZ Advance
// 2017.11.12 bal4u@uu

#include <stdio.h>

#include<stdio.h>
#include<math.h>

#define EPS  1e-7
#define ABS(a)  ((a)>=0?(a):-(a))

typedef struct { int x, y, z; } PP;
typedef struct { double x, y, z; } FPP;

void shift(PP *p, PP a) { p->x -= a.x, p->y -= a.y, p->z -= a.z; }
void diff(FPP *p, PP a, FPP b) { p->x = a.x-b.x, p->y = a.y-b.y, p->z = a.z-b.z; }
void cross(PP *p, PP a, PP b)
{
	p->x = a.y * b.z - a.z * b.y;
	p->y = a.z * b.x - a.x * b.z;
	p->z = a.x * b.y - a.y * b.x;
}
void fcross(FPP *p, FPP a, FPP b)
{
	p->x = a.y * b.z - a.z * b.y;
	p->y = a.z * b.x - a.x * b.z;
	p->z = a.x * b.y - a.y * b.x;
}
int dot(PP a, PP b) { return a.x*b.x + a.y*b.y + a.z*b.z; }

int main()
{
	int i, j, mm, ee, ans;
	double x[3];
	PP m, e, b[3], a;
	FPP c;

	scanf("%d%d%d%d%d%d", &m.x, &m.y, &m.z, &e.x, &e.y, &e.z);
	for (i = 0; i < 3; i++) scanf("%d%d%d", &b[i].x, &b[i].y, &b[i].z);

	ans = 1;

	shift(&m, b[0]), shift(&e, b[0]);
	for (i = 2; i >= 0; i--) shift(b+i, b[0]);

	cross(&a, b[1], b[2]);
	ee = dot(a, e), mm = dot(a, m);

	if (ee == 0) c.x = e.x, c.y = e.y, c.z = e.z;
	else {
		double t;
		if (mm > 0 && ee > 0 || mm < 0 && ee < 0) goto done;
		t = fabs((double)mm/(ABS(mm)+ABS(ee)));

		c.x = (e.x-m.x)*t + m.x;
		c.y = (e.y-m.y)*t + m.y;
		c.z = (e.z-m.z)*t + m.z;
	}

	for (i = 0; i < 3; i++) {
		FPP u, v, t;
		j = i + 1; if (j == 3) j = 0;
	    diff(&u, b[i], c);
		diff(&v, b[j], c);
		fcross(&t, u, v);

 		if      (ABS(a.x) > 0) x[i] = t.x;
		else if (ABS(a.y) > 0) x[i] = t.y;
		else if (ABS(a.z) > 0) x[i] = t.z;
		else                   x[i] = 0;
	}

	if (fabs(x[0]) <= EPS && fabs(x[1]) <= EPS && fabs(x[2]) <= EPS) ans = 0;
	if (x[0] <= 0 && x[1] <= 0 && x[2] <= 0) ans = 0;
	if (x[0] >= 0 && x[1] >= 0 && x[2] >= 0) ans = 0;
done:
	puts(ans ? "HIT" : "MISS");
	return 0;
}

Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<bool> cnt(n, true);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a --, b --;
    if (h[a] >= h[b]) cnt[b] = false;
    if (h[b] >= h[a]) cnt[a] = false;
  }

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

  cout << ans << endl;
}


Measured memory_bytes: 3784
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a;
  cin >> a;
  cout << 24 + (24 - a) << endl;
}


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


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	string s;
	cin >> s;
	int ans = 0;
	if (s[0] == '1')ans++;
	if (s[1] == '1')ans++;
	if (s[2] == '1')ans++;
	cout << ans;
	return 0;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

const long long MAX_N = 10^100;
char A[MAX_N], B[MAX_N];


void solve() {
	if (strlen(A) > strlen(B)) {
		cout << "GREATER" << endl;
	}
	else if (strlen(A) < strlen(B)) {
		cout << "LESS" << endl;
	}
	else if (strlen(A) == strlen(B) && strcmp(A, B) > 0) {
		cout << "GREATER" << endl;
	}
	else if (strlen(A) == strlen(B) && strcmp(A, B) < 0) {
		cout << "LESS" << endl;
	}
	else if (strlen(A) == strlen(B)  && strcmp(A, B) == 0) {
		cout << "EQUAL" << endl;
	}
}

int main()
{
	//入力
	cin >> A >> B;
	solve();
	return 0;
}


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

int main() {
    int count = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size() / 2; ++i){
        if(s[i] != s[s.size() - 1 - i]){
            ++count;
        }
    }
    cout << count;
	return 0;
}


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

using namespace std;
typedef long long ll ;
int main()
{
    int n ;cin>> n;
long long arr[n][3];
    for (int i=0;i<n;i++){
        for (int j=0;j<3;j++)
        {
            cin >> arr[i][j];
        }
    }
    long long dp[n][3];
    dp[0][0]=arr[0][0];

    dp[0][1]=arr[0][1];

    dp[0][2]=arr[0][2];

    for (int i=1;i<n;i++){
        for (int j=0;j<3;j++)
        {
                dp[i][j]= max(dp[i-1][(j+1)%3]+arr[i][j],dp[i-1][(j+2)%3]+arr[i][j]);

        }
    }

    vector <long long > v;
    v.push_back(dp[n-1][0]);
    v.push_back(dp[n-1][1]);
    v.push_back(dp[n-1][2]);
    cout << *max_element(v.begin(),v.end());
}


Measured memory_bytes: 8264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
typedef long long ll; 
 
#define int ll
 
 
main(){
	ll a;
	double b;
	cin >> a >> b;
	b *= 100.0001;
	ll b2  = (ll)b;
	ll ans = (ll) a*b2/100;
	printf("%lld\n",ans);
 
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int> > lr(N, vector<int>(2));

    for(int i=0;i<N;i++){
        cin >> lr.at(i).at(0) >> lr.at(i).at(1);
    }

    int count=0;
    for(int i=0;i<N;i++){
        count += lr.at(i).at(1) - lr.at(i).at(0) + 1;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
int n;
cin>>n;
int a[n+1];
map<int,int>mp;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mp[a[i]]+=1;
}
int ans=0;
map<int,int>::iterator itr;
for (itr = mp.begin(); itr != mp.end(); ++itr) { 
                   if(itr->second>1)
                   {
                   	ans=ans+itr->second*(itr->second-1)/2;
				   }
             }
for(int k=0;k<n;k++)
{ int ans1=0;
	ans1=ans-mp[a[k]]*(mp[a[k]]-1)/2;
	mp[a[k]]--;
	ans1=ans1+mp[a[k]]*(mp[a[k]]-1)/2;
             cout<<ans1<<'\n';
             mp[a[k]]++;
}
}


Measured memory_bytes: 12032
s=input()
S=[s[i] for i in range(len(s))]
A=['0','1']
B=[A[i%2] for i in range(len(S))]
count=0
for i in range(len(S)):
  if S[i]!=B[i]:
    count=count+1
print(min(count,len(S)-count))

Measured memory_bytes: 10572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int segsize = 18;

int SegTree[1<<segsize],Lazy[1<<segsize];
bool Flag[1<<segsize];
void denpa(int k,int l,int r)
{
	if(Flag[k])
	{
		SegTree[k]=Lazy[k];
		if(Lazy[k]!=INT_MAX)
		if(r-l>1)
		{
			Lazy[2*k] = Lazy[2*k+1] = Lazy[k];
			Flag[k*2] = Flag[k*2+1]=true;
		}
		Flag[k] = false;
	}
}

void update(int a,int b,ll x,int k=1,int l=0,int r =-1)
{
	if(r<0)r=(1<<(segsize-1));
	//cout<<a<<' '<<b<<' '<<x<<' '<<k<<' '<<l<<' '<<r<<endl;
	denpa(k,l,r);
	if(b<=l||r<=a)return;
	if(a<=l&&r<=b)
	{
		Lazy[k] = x;
		Flag[k] = true;
		denpa(k,l,r);
	}
	else
	{
		update(a,b,x,k*2,l,(l+r)/2);
		update(a,b,x,k*2+1,(l+r)/2,r);
		SegTree[k] = min(SegTree[k*2],SegTree[k*2+1]);
	}
}

ll getmin(int a,int b,int k=1,int l=0,int r=-1)
{
	if(r<0)r = 1<<(segsize-1);
	denpa(k,l,r);
	if(b<=l||r<=a)return INT_MAX;
	if(a<=l&&r<=b)return SegTree[k];
	ll vl = getmin(a,b,k*2,l,(l+r)/2);
	ll vr = getmin(a,b,2*k+1,(l+r)/2,r);
	return min(vl,vr);
}

int main()
{
	for(int i = 0;i<(1<<segsize);i++)
	{
		SegTree[i]=INT_MAX;
		Lazy[i] = INT_MAX;
	}
	int n,q;
	cin >> n >> q;
	for(int i = 0;i<q;i++)
	{
		int op;
		cin >> op;
		if(op)
		{
			int a,b;
			cin >> a >> b;
			b++;
			cout<<getmin(a,b)<<endl;
		}
		else
		{
			int a,b,x;
			cin >> a >> b >> x;
			b++;
			update(a,b,x);
		}
		//for (int i = 0; i < (1<<segsize); i++){cout<<SegTree[i]<<' '<<Lazy[i]<<endl;}cout<<endl;
		
		
	}
}


Measured memory_bytes: 5356
import sys
input=sys.stdin.readline
def main():
  def dfs(x):
    m=x//2
    if m not in dp or dp[m]>dp[x]+abs(2*m-x)*d+a:
      dp[m]=dp[x]+abs(2*m-x)*d+a
      dfs(m)
    m=0--x//2
    if m not in dp or dp[m]>dp[x]+abs(2*m-x)*d+a:
      dp[m]=dp[x]+abs(2*m-x)*d+a
      dfs(m)
    m=x//3
    if m not in dp or dp[m]>dp[x]+abs(3*m-x)*d+b:
      dp[m]=dp[x]+abs(3*m-x)*d+b
      dfs(m)
    m=0--x//3
    if m not in dp or dp[m]>dp[x]+abs(3*m-x)*d+b:
      dp[m]=dp[x]+abs(3*m-x)*d+b
      dfs(m)
    m=x//5
    if m not in dp or dp[m]>dp[x]+abs(5*m-x)*d+c:
      dp[m]=dp[x]+abs(5*m-x)*d+c
      dfs(m)
    m=0--x//5
    if m not in dp or dp[m]>dp[x]+abs(5*m-x)*d+c:
      dp[m]=dp[x]+abs(5*m-x)*d+c
      dfs(m)
  def solve():
    dp[n]=0
    dfs(n)
    return min(dp[i]+abs(i)*d for i in dp)
  for _ in range(int(input())):
    n,a,b,c,d=map(int,input().split())
    dp={}
    print(solve())
if __name__ == "__main__":
  main()

Measured memory_bytes: 103844