akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  string s;
  cin >> n;
  cin >> s;
  ll ans = 0;
  rep(i, n - 2) {
    if (s.substr(i, 3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		vector<vector<int>> a(n, vector<int>(m, 0));
		for(int i=0; i<n; i++)for(int j=0; j<m; j++)cin >> a[i][j];
		for(int i=0; i<n; i++)for(int j=0; j<m; j++)a[i][j]--;
		vector<int> cnt(m, 0);
		vector<bool> flag(m, 0);
		vector<int> idx(n, 0);
		int ret = n;
		for(int i=0; i < n; i++)cnt[a[i][0]]++;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				while(idx[j] != m && flag[a[j][idx[j]]]){
					cnt[a[j][idx[j]]]--;
					idx[j]++;
					cnt[a[j][idx[j]]]++;
				}
			}
			int max_cnt = 0;
			int max_idx = -1;
			for(int i=0; i < m; i++){
				if(cnt[i] > max_cnt){
					max_cnt = cnt[i];
					max_idx = i;
				}
			}
			updmin(ret, max_cnt);
			flag[max_idx] = true;
		}
		cout << ret << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main(){
	int n;cin>>n;
	set<string>se;
	rep(i,n){
		string s;cin>>s;se.insert(s);
	}
	cout<<se.size()<<endl;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t> h(N);
  for(int i=0;i<N;++i){
    cin>>h.at(i);
  }

  sort(h.begin(),h.end());
  int64_t ans=h.at(K-1)-h.at(0);
  for(int i=0;i+K-1<N;++i){
    ans=min(ans,h.at(i+K-1)-h.at(i));
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit __builtin_popcountll
#define bs binary_search
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// binary search using recursion.


int main(){
int x;
cin>>x;
if(x>=30)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= (0);--i)
#define ALL(v) v.begin(),v.end()
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define INF 1000000000

typedef long long ll;
typedef pair<ll, ll> P;

int dp[66][66][3333];

void chmin(int &a, int b){
    a = min(a, b);
}

int main() {
    ll n, k;cin >> n >> k;
    vector<int> v(n);
    int sum = 0, red_sum = 0, black_sum = 0;
    REP(i, n) {
        cin >> v[i];
        sum += v[i];
    }
    sort(ALL(v), greater<int>());
    vector<int> r(k);
    REP(i, k){
        cin >> r[i];
        red_sum += r[i];
    }
    sort(ALL(r), greater<int>());
    vector<int> b(k);
    REP(i, k){
        cin >> b[i];
        black_sum += b[i];
    }
    sort(ALL(b), greater<int>());

    REP(i, 66)REP(j, 66)REP(k, 3333)dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    REP(red, k+1){
        REP(black, k+1){
            if(red + black >= n)continue;
            REP(red_sum, 3333)if(dp[red][black][red_sum] != INF){
                int id = red + black;
                if(red < k){
                    int nxt_sum = red_sum + v[id];
                    int cost = max(0, v[id] - r[red]);
                    chmin(dp[red+1][black][nxt_sum], dp[red][black][red_sum] + cost);
                }
                if(black < k){
                    int nxt_sum = red_sum;
                    int cost = max(0, v[id] - b[black]);
                    chmin(dp[red][black+1][nxt_sum], dp[red][black][red_sum] + cost);
                }
            }
        }
    }

    int ans = INF;
    REP(i, 66){
        REP(j, 66){
            if(i + j != n)continue;
            REP(k, 3333){
                if(k > red_sum)continue;
                if(sum - k > black_sum)continue;
                chmin(ans, dp[i][j][k]);
            }
        }
    }

    cout << ((ans == INF) ? -1 : ans) << endl;
}



Measured memory_bytes: 59868
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int di[] = {0, -1, 0, 1};
  int dj[] = {-1, 0, 1, 0};
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h){
    cin >> s[i];
  }
  int ans=0;
  rep(si, h)rep(sj, w){
    if(s[si][sj]=='#')continue;
    queue<P> q;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[si][sj]=0;
    q.push(P(si, sj));
    while(!q.empty()){
      int i=q.front().first;
      int j=q.front().second;
      q.pop();
      rep(dir, 4){
        int ni=i+di[dir];
        int nj=j+dj[dir];
        if(ni<0 || ni>=h || nj<0 || nj>=w)continue;
        if(s[ni][nj]=='#')continue;
        if(dist[ni][nj]!=INF)continue;
        dist[ni][nj]=dist[i][j]+1;
        q.push(P(ni, nj));
        ans=max(ans, dist[ni][nj]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

#define MX_INT (2147483647)

typedef long long ll;

using namespace std;

int a_arr[100000 + 5];
int b_arr[100000 + 5];
int a_min = 2147483647;
int b_min = 2147483647;

int a, b, m;

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

	scanf("%d %d %d", &a, &b, &m);
	
	for (int i = 0; i < a; ++i)
	{
		scanf("%d", &a_arr[i]);
		if (a_arr[i] < a_min) a_min = a_arr[i];
	}
	for (int i = 0; i < b; ++i)
	{
		scanf("%d", &b_arr[i]);
		if (b_arr[i] < b_min) b_min = b_arr[i];
	}

	int ans = a_min + b_min;

	for (int i = 0; i < m; ++i)
	{
		int _x, _y, _c;
		scanf("%d %d %d", &_x, &_y, &_c);
		if (a_arr[_x - 1] + b_arr[_y - 1] - _c < ans) ans = a_arr[_x - 1] + b_arr[_y - 1] - _c;
	}

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

	return 0;
}

Measured memory_bytes: 1024
def main():
    n, y = [int(i) for i in input().split()]
    sw1 = False
    for i in range(n+1):
        for j in range(n-i+1):
            if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
                sw1 = True
                print(i, j, n-j-i)
                break
        if sw1:
            break
    else:
        print(-1, -1, -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};



int main(){
    ll n, m; cin >> n >> m;
    vector<pll> Q(m); 
    rep(i, m){
        ll a, b; cin >> a >> b; a--; b--; Q[i] = {a, b};
    }
    reverse(all(Q));
    vector<ll> res(m); res[0] = n*(n-1)/2;
    UnionFind uf(n);
    rep(i, m-1){
        ll a = Q[i].first, b = Q[i].second;
        ll siz_a = uf.size(a), siz_b = uf.size(b);
        uf.merge(a, b);
        ll siz_af = uf.size(a);
        ll num = res[i] - (siz_af*(siz_af-1)/2) + (siz_a*(siz_a-1)/2) + (siz_b*(siz_b-1)/2);
        if(siz_af == siz_a) num = res[i];
        res[i+1] = num;
    }
    for(int i=m-1; i>=0; i--){
        cout << res[i] << ln;
    }
}


Measured memory_bytes: 4096
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int x[500],y[500];
int n,d,N;
int sx[4]={-1,0,1,0};
int sy[4]={0,-1,0,1};
int main(void){
	while(1){
		scanf("%d",&N);
		if(N==0)break;
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		int x_min=0,x_max=0,y_min=0,y_max=0;
		for(int i=1;i<N;i++){
			scanf("%d %d",&n,&d);
			x[i]=x[n]+sx[d];
			y[i]=y[n]+sy[d];
			x_min=min(x_min,x[i]);
			x_max=max(x_max,x[i]);
			y_min=min(y_min,y[i]);
			y_max=max(y_max,y[i]);
		}
		printf("%d %d\n",x_max-x_min+1,y_max-y_min+1);
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = (a+b) % 24;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 double d,t,s;
 cin >> d >> t >> s;
 if (d/s <= t)cout << "Yes" << endl;
 else cout << "No" << endl; 
}


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

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int itr = 0;
    rep(i, m) {
        cin >> a[i];
        if(a[i] < x) itr++;
    }
    int right = m - itr;
    if(right < itr){
        cout << right << endl;
    }else{
        cout << itr << endl;
    }


}


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

using namespace std;

int mapData[10][10];

int main() {
	int n,tmp,sum;
	double x[100], y[100];
	char c;

	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> c >> y[i];
		}

		sum = 0;
		for (double a = 0; (a-10) < 0.0001; a += 0.01) {
			for (double b = 0; (b-10) < 0.0001; b += 0.01) {
				tmp = 0;
				for (int i = 0; i < n; i++) {
					if( pow((a - x[i]), 2) + pow((b - y[i]), 2) - 1 < 0.0001) {
						tmp++;
					}
				}
				sum = max(sum, tmp);
			}
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>

using namespace std;

int main() {
	
	double a,b;

	cin >> a >> b;

	cout << (int)a / (int)b << " " << (int)a%(int)b << " ";

	printf("%.5f\n", a / b);

	return 0;
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var S = vals[2];

        var list = new List<int>();
        list.AddRange(Enumerable.Repeat(S, K));
        var other = S + 1;
        if (other > (int)1e9)
        {
            other = S - 2;
        }
        list.AddRange(Enumerable.Repeat(other, N - list.Count));

        Console.WriteLine(string.Join(" ", list));
    }
}

Measured memory_bytes: 23900
#include <iostream>
#include <vector>
#include <assert.h>
#include <cmath>
#include <iomanip>

using edge_type = std::vector<std::pair<int32_t, int32_t>>;
using edge_vect_type = std::vector<edge_type>;

void dfs(edge_vect_type& edge_vect, std::vector<int32_t>& vertex_colors, int32_t parent, int32_t child, int32_t color){
    vertex_colors[child] = color;
    for(int32_t i = 0; i < (int32_t)edge_vect[child].size(); i++){
        if(parent == edge_vect[child][i].first){
            continue;
        }
        int32_t c = edge_vect[child][i].second % 2;
        c = c ^ color;
        dfs(edge_vect, vertex_colors, child, edge_vect[child][i].first, c);
    }
    return;
}

int main(){
    int32_t N;
    std::cin >> N;
    edge_vect_type edge_vect(N);
    for(int32_t i = 0; i < N - 1; i++){
        int32_t u,v,w;
        std::cin >> u >> v >> w;
        edge_vect[u-1].push_back(std::make_pair(v-1, w));
        edge_vect[v-1].push_back(std::make_pair(u-1, w));
    }

    std::vector<int32_t> vertex_colors(N, -1);    
    dfs(edge_vect, vertex_colors, -1, 0, 0);
    for(auto& res : vertex_colors){
        std::cout << res << std::endl;
    }


    return 0;
}

Measured memory_bytes: 9728
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}



Measured memory_bytes: 2988
import java.util.*;
import java.lang.*;

public class Main {
	static long mod = 1000000007;
	static int h;
	static int w;
	static int k;
	static long[][] dp;
	static int i;
	static int j;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		k = sc.nextInt();
		dp = new long[h + 1][w + 2];
		dp[0][1] = 1;
		for (i = 1; i <= h; i++) {
			for (j = 1; j <= w; j++) {
				dfs(1, false, false, false);
			}
		}
		System.out.println(dp[h][k]);
	}
	static void dfs(int now, boolean te, boolean mae, boolean ato) {
		if (now == w) {
			if (mae) {
				dp[i][j] += dp[i - 1][j - 1];
				dp[i][j] %= mod;
			} else if (ato) {
				dp[i][j] += dp[i - 1][j + 1];
				dp[i][j] %= mod;
			} else {
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= mod;
			}
			return;
		}
		if (te) {
			dfs(now + 1, false, mae, ato);
		} else if (now == j - 1) {
			dfs(now + 1, true, true, false);
			dfs(now + 1, false, mae, ato);
		} else if (now == j) {
			dfs(now + 1, true, mae, true);
			dfs(now + 1, false, mae, ato);
		} else {
			dfs(now + 1, true, mae, ato);
			dfs(now + 1, false, mae, ato);
		}

	}
}


Measured memory_bytes: 22100
def func(A,B):
  cntA=1
  while A//10:
    A//=10
    cntA+=1
  cntB=1
  while B//10:
    B//=10
    cntB+=1
  return max(cntA,cntB)
ans=10000000001
N=int(input())
NN=int((N+1)**0.5)
for i in range(1,NN+1):
  if N%i==0:
    j=N//i
    tmp=func(i,j)
  ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define MAX_SIZE (40)

typedef struct
{
  int index;
  char suit;
  int num;
} Data;

void Reset(Data(*D)[MAX_SIZE], const char (*A)[3], int N)
{
  for (int i = 0; i < N; ++i)
  {
    ((*D)[i + 1]).index = i;
    ((*D)[i + 1]).suit = A[i][0];
    ((*D)[i + 1]).num = std::atoi(&A[i][1]);
  }
}

void BubbleSort(Data (*D)[MAX_SIZE], int N)
{
  for (int i = 1; i < N; ++i)
  {
    for (int j = N; j > i; --j)
    {
      if (((*D)[j - 1]).num > ((*D)[j]).num)
      {
        std::swap((*D)[j - 1], (*D)[j]);
      }
    }
  }
}

void SelectionSort(Data(*D)[MAX_SIZE], int N)
{
  for (int i = 1; i < N; ++i)
  {
    int minj = i;
    for (int j = i + 1; j <= N; ++j)
    {
      if (((*D)[j]).num < ((*D)[minj]).num)
      {
        minj = j;
      }
    }
    std::swap((*D)[i], (*D)[minj]);
  }
}

void Dump(const Data (&D)[MAX_SIZE], const char (*A)[3], int N)
{
  bool isStable = true;
  for (int i = 1; i <= N; ++i)
  {
    if (i > 1) std::cout << " ";
    std::cout << A[D[i].index];
    if (D[i - 1].num == D[i].num && D[i - 1].index > D[i].index)
    {
      isStable = false;
    }
  }
  std::cout << std::endl;

  if (isStable)
  {
    std::cout << "Stable";
  }
  else
  {
    std::cout << "Not stable";
  }
  std::cout << std::endl;
}

int main()
{
  int N;
  char A[MAX_SIZE][3];
  Data D[MAX_SIZE];
  D[0].index = -1;
  D[0].suit = 'X';
  D[0].num = 0;

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

  Reset(&D, A, N);
  BubbleSort(&D, N);
  Dump(D, A, N);

  Reset(&D, A, N);
  SelectionSort(&D, N);
  Dump(D, A, N);
  
  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define pb push_back
#define getarray(a,n)  for(int i=0;i<n;i++) cin>>a[i]
#define ll long long 
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vi vector<int>
#define w(t) int t;cin>>t;while(t--)
using namespace std;

int main()
{
    fast
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;

    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<string>
#include<queue>
using namespace std;

int main() {
  char com[20];
  priority_queue<int> PQ;

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      int key ; scanf("%d", &key);
      PQ.push(key);
    } else if ( com[1] == 'x' ) {
      printf("%d\n", PQ.top());
      PQ.pop();
    } else if ( com[0] == 'e' ) {
      break;
    }
  }

  return 0;
}


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

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define mp 					make_pair
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x) 				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 2e9 + 5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 1e5+5;
int n, val[MAXN][3], ad[MAXN], jml[3], bts[3];
priority_queue < pii > pq[3][3];
vi np, dpt, rem;

int get (int a, int b, int kd) {
	while (1) {
		assert(!pq[a][b].empty());
		pii now = pq[a][b].top();
		if (ad[now.se]!=a) {
			pq[a][b].pop();
			continue;
		}
		if (!kd) return now.fi;
		else return now.se;
	}
}

void add (int x, int no) {
	ad[x] = no;
	for (int j=0; j<3; j++) {
		if (j==no) continue;
		pq[no][j].push({-val[x][no]+val[x][j], x});
	}
}

LL solve() {
	LL ret = 0LL;
	vi tmp;
	setnul(jml);
	for (int i=1; i<=n; i++) {
		sort(all(np));
		int mks = -inf;
		do {
			tmp.clear();
			int cst = val[i][np[0]];
			for (int j=0; j<3; j++) {
				int va = np[j];
				if (jml[va]<bts[va]) break;
				assert(j<2);
				int vb = np[j+1];
				cst += get(va,vb,0);
				tmp.psb(get(va,vb,1));
			}
			if (cst>mks) {
				mks = cst;
				dpt = np;
				rem = tmp;
			}
		} while (next_permutation(all(np)));
		assert(mks!=-inf);
		ret += (LL) mks;
		int skr = i;
		for (int j=0; j<3; j++) {
			int va = dpt[j];
			add(skr,va);
			if (jml[va]<bts[va]) {
				jml[va]++;
				break;
			}
			assert(j<2);
			skr = rem[j];
		}
	}
	return ret;
}

int main() {
	n = 0;
	for (int i=0; i<3; i++) {
		gi(bts[i]);
		jml[i] = 0;
		n+= bts[i];
		np.psb(i);
	}
	for (int i=1; i<=n; i++)
		for (int j=0; j<3; j++) gi(val[i][j]);
	printf("%lld\n", solve());
	return 0;
}


Measured memory_bytes: 5740
import java.util.Scanner;

public class Main {
	public static final long x = 62L;
	public static final long one = 1L;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final long a = scanner.nextLong();
		final long b = scanner.nextLong();
		final long n = b - a + 1;
		long result = 0;
		for (int i = 0; i < x; i++) {
			long T = one << i + 1;
			long ra = a % T;
			long r = n % T;
			if (i == 0) {
				long ones = calcOnes(T, ra, r);
				ones += n / T;
				result = result ^ ((ones % 2) << i);
				continue;
			}
			long ones = calcOnes(T, ra, r);
			result ^= ((ones % 2) << i);
		}
		System.out.println(result);
		scanner.close();
	}

	public static long calcOnes(long T, long ra, long r) {
		long zero2ra = Math.max(0, ra - T/2);
		long zero2raPr;
		if(r + ra > T) {
			zero2raPr = T/2 + Math.max(0, (r + ra - T) - T/2);
		}else {
			zero2raPr = Math.max(0, ra + r - T/2);
		}
		long ones = zero2raPr - zero2ra;
		return ones;
	}
}


Measured memory_bytes: 24020
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var arr = chunk.split(" ");
  w = Number(arr[0])
  h = Number(arr[1])
  x = Number(arr[2])
  y = Number(arr[3])
  r = Number(arr[4])
  if ((r <= x) && (r <= w - x) && (r <= y) && (r <= h - y)) {
    console.log("Yes")
  }else{
    console.log("No")
  }
}); 

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long int MOD = 1e9+7;

int main(){
    int  n;
    ll   k; 
    cin >> n >> k;
    vector<int> a;
    ll b_cnt=0;
    int max_n=0;
    for(int i=0; i<n; i++){
        int tmp = 0; cin >> tmp;
        if(tmp>max_n) max_n = tmp;
        a.push_back(tmp);
        for(int j=0; j<i; j++){
            if(a[j] > a[i]){
                b_cnt++;
            }
        }
    }
    b_cnt = b_cnt % MOD;
    
    ll ans =0;
    ans = b_cnt * k;
    ans = ans % MOD;

    ll c_cnt=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(a[i]>a[j]) c_cnt++;
        }
    }
    ll select = k*(k-1)/2;
    select = select % MOD;
    ans += select * c_cnt;
    ans = ans % MOD;

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3540
//JI SRI KRISHNA.//
#include<iostream>
using namespace std;
int main()
{
    int a[4],f=0,s=0,i;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
        if(a[i]==5)
            f++;
        if(a[i]==7)
            s++;
    }
   if(f==2&&s==1)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;
}



Measured memory_bytes: 3416
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 101001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
int p[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
string S[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
int wa[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
short ac[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

          // Main program
void solve() {
    ll N, K, M;
    cin >> N;
    cin >> M;


    ll sum = 0;
    for (ll i = 0; i < M; i++) {
        cin >> p[i];
        cin >> S[i];
    }

    ll sumCor = 0;
    ll sumPen = 0;

    for (ll i = 0; i < M; i++) {
        if (ac[p[i]]!=1) {
            if (S[i] == "WA") {
                wa[p[i]]++;
            }
            else {
                ac[p[i]]=1;
            }
        }
    }

    for (ll i = 0; i <= N; i++) {
        sumCor += ac[i];
        if (ac[i] != 0) {
            sumPen += wa[i];
        }
    }

    cout << sumCor;
    cout << ' ';
    cout << sumPen;

    return;

}

int main() {
    solve();
    return 0;
}







Measured memory_bytes: 6656
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)


typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};


signed main(){

	lli n,m;
	cin>>n>>m;

	UnionFind uf(n);

	map<lli,vector<lli>> lang;
	REP(i,0,n){
		lli k;
		cin>>k;
		REP(j,0,k){
			lli now;
			cin>>now;
			lang[now].push_back(i);
		}
	}

	for(auto e:lang){
		REP(i,1,e.second.size()){
			uf.unite(e.second.at(i-1),e.second.at(i));
		}
	}

	if(DEBUG)cout<<"ufSize="<<uf.getSize(0)<<endl;
	if(uf.getSize(0)==n){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}



	return 0;
}

Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,lis[100][100]={};
  cin>>n;
  for(int c=0;c<n;c++){
    int u,k,v;
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      lis[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<lis[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
int main(){
int n,C;
int s[100000];
int t[100000];
int c[100000];

scanf("%d %d",&n,&C);
for(int i=0;i<n;i++){
	scanf("%d %d %d",&s[i],&t[i],&c[i]);
}
int m=100001;
int T[31][100001];
for(int i=0;i<C+1;i++){
	for(int j=0;j<m;j++){
		T[i][j]=0;
	}
}
for(int i=0;i<n;i++){
	for(int j=s[i];j<=t[i];j++){
		if(T[c[i]][j]==0){
			T[c[i]][j]=1;
		}
	}
}
int x=0;
for(int i=0;i<m;i++){
	int y=0;
	for(int j=0;j<C+1;j++){
		y=y+T[j][i];
	}
	if(x<y){
		x=y;
	}
}
printf("%d\n",x);
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
const int M=200010;
string s[M];

int n , maxx = 0 , sum;

int main() {
	cin >> n;
	
	for (int i = 1; i <= n; i ++) cin >> s[i];
	
	sort(s + 1, s + n + 1 );
	
	for (int i = 1 , sum = 1 ; i <= n; i ++)
	if (s[i] != s[i + 1]){
		
		maxx = max(maxx, sum) ; sum = 1;
		
	}
	else sum ++;
	
	sum = 1;
	
	for (int i = 1 , sum = 1 ; i <= n; i ++)
	if (s[i] != s[i + 1]){
		
		if (sum == maxx){
			
			cout << s[i] << endl ; 
		}
		sum = 1;
	}
	else sum ++;
	return 0;
}

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


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

  int n;
  cin >> n;
  vector<vector<int> > t(n+1);
  for (int i=0; i<3; i++) t[0].push_back(0);
  
  for (int i=1; i<=n; i++) {
    for (int j=0; j<3; j++) {
      int x;
      cin >> x;
      t[i].push_back(x);
    }
  }

  
  for (int i=0; i<n; i++) {
    int tt = t[i+1][0] - t[i][0];
    int xx = abs(t[i+1][1] - t[i][1]);
    int yy = abs(t[i+1][2] - t[i][2]);
    if (tt == xx + yy) { continue; }
    tt -= xx; tt -= yy;
    if (tt <= 0) {
      cout << "No" << "\n";
      return 0;
    } else if (tt%2 == 0) {
      continue;
    } else {
      cout << "No" << "\n";
      return 0;
    }
  }

  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 5760
import numpy as np

N, M, C = map(int, input().split())
B = np.array([int(i) for i in input().split()])
inputs = [
    sum(np.array([int(i) for i in input().split()]) * B) + C for _ in range(N)
]

print(sum([1 if inputs[i] > 0 else 0 for i in range(N)]))


Measured memory_bytes: 13504
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<string,int> m;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        ++m[s];
    }
    int c = 0;
    for (auto i:m)
    {
        c = max(c,i.second);
    }
    for (auto i:m)
    {
        if(c == i.second)
            cout << i.first << endl;
    }
    return 0;
}

Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modsub(long long a, long long b){
	return (a % MOD - b % MOD + MOD) % MOD;
}
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
int main(){
  int N;
  cin >> N;
  vector<vector<long long>> dp(N + 1, vector<long long>(3, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    dp[i + 1][0] = dp[i][0] * 8 % MOD;
    dp[i + 1][1] = (dp[i][1] * 9 + dp[i][0] * 2) % MOD;
    dp[i + 1][2] = (dp[i][2] * 10 + dp[i][1]) % MOD;
  }
  cout << dp[N][2] << endl;
}

Measured memory_bytes: 57900
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll a;
	long double b;
	cin>>a>>b;
	cout<<(ll)((a*(ll)(b*100+0.5)/100))<<endl;
	return 0;
}

Measured memory_bytes: 3748
m = list(map(int, input().split()))
a = m[0]
b = m[1]
k = m[2]
c = min(a, b)
d = 0
e = 0

for i in range(c):
    if(a % (c - i) == 0 and b % (c - i) == 0):
        d += 1
    if(d == k):
        e = c - i
        break
print(e)

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

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

    int N = 11;
    vector<vector<int>> dp(N, vector<int>(10, 0));
    for (int i = 0; i < 10; i++)
    {
        dp[0][i] = 1;
    }

    int digit = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j < 10; j++)
        {
            if (j > 0)
            {
                sum += dp[i][j];
            }
            dp[i + 1][j] += dp[i][j];
            if (j - 1 >= 0)
            {
                dp[i + 1][j - 1] += dp[i][j];
            }
            if (j + 1 < 10)
            {
                dp[i + 1][j + 1] += dp[i][j];
            }
        }
        if (sum >= K)
        {
            digit = i + 1;
            break;
        }
        else
        {
            K -= sum;
        }
    }

    int from = 1;
    int to = 9;
    for (int i = digit - 1; i >= 0; i--)
    {
        int tmp = 0;
        for (int j = from; j <= to; j++)
        {
            if (tmp + dp[i][j] >= K)
            {
                cout << j;
                from = max(0, j - 1);
                to = min(9, j + 1);
                K -= tmp;
                break;
            }
            else
            {
                tmp += dp[i][j];
            }
        }
    }
    cout << endl;
}


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

int main(void){
    
    char input[19];
    
    for(int i = 0; i < 19; i++){
        
        cin >> input[i];
        
    }
    
    input[5] = ' ';
    input[13] = ' ';
    
    for(int i = 0; i < 19; i++){
        
        cout << input[i];
        
    }
    
    return 0;
    
}


Measured memory_bytes: 256
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    A, B, K = input([int, 3])
    a = A - K
    if K <= A:
        print(A - K, B)
        return
    if K <= A + B:
        print(0, B - (K - A))
        return
    print(0, 0)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+10;
int vis[N];
ll inv(ll b){
    return b==1||b==0?1:(mod-mod/b)*inv(mod%b)%mod;
}
ll f[N];
ll C(ll n,ll m){
    if(n<m) return 0;
    return f[n]*inv(f[m])%mod*inv(f[n-m])%mod;
}
void init(){
    f[0]=1;
    for(int i=1;i<N;i++) f[i]=f[i-1]*i%mod;
}
int main(){
    int n,first,last,dig;
    init();
    memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    for(int i = 1;i <= n+1;i++)
    {
        scanf("%d",&dig);
        if(vis[dig]) first = vis[dig],last = i;
        else vis[dig] = i;
    }
    for(int i=1;i<=n+1;i++) printf("%lld\n",(C(n+1,i)-C(n+1-(last-first+1),i-1)+mod)%mod);
}

Measured memory_bytes: 2432
////ABC 079
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

string a;

signed main() {

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

	cin >> a;
	ll count = 0;
	REP(i, 3) {
		if (a[i] == a[i + 1]) {
			count++;
			if (count == 2) {
				cout << "Yes";
				return 0;
			}
		}
		else {
			count = 0;
		}
	}

		cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
  
    int n;
    cin>>n;
    
    int s=n%10;
    int d=10;
    
    for(int i=1;i<12;i++){
        
        s+=(n%(10*d))/d;
        
        d=d*10;
    }
    
    if(n%s==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}







Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(998244353)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b,c,d; cin>>a>>b>>c>>d;
	int x=max(a,c),y=min(b,d);
	cout<<(y-x+abs(y-x))/2<<"\n";
	return 0;
}

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

int main() {
    char s;
    cin >> s;
    string a = "abcdefghijklmnopqrstuvwxyz";
    rep(i,a.size()){
        if(s == a[i]){
            cout << 'a' << endl;
            return 0;
        }
    }
    cout << 'A' << endl;
}

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

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

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>> > &G){
    int n=G.size();
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;
    vector<T> d(n, INF);
    vector<int> b(n,-1);
    priority_queue<P,vector<P>,greater<> > Q;
    d[s]=0;
    Q.emplace(d[s],s);
    while(!Q.empty()){
        T cost;
        int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    u32 n;
    cin >> n;
    vector<vector<edge<ll>>> v(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        v[a-1].emplace_back(b-1, c);
        v[b-1].emplace_back(a-1, c);
    }
    int q, k;
    cin >> q >> k;
    vector<ll> d = dijkstra(k-1, v);
    for (int j = 0; j < q; ++j) {
        int x, y;
        scanf("%d %d", &x, &y);
        cout << d[x-1] + d[y-1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 11504
sx,sy,tx,ty = list(map(int, input().split()))

# (x,y)のケースで場合分けすればできそう
x = tx-sx
y = ty-sy
str = ""

if(x > 0) and (y > 0):
    #1
    str += "R"*x
    str += "U"*y
    #2
    str += "L"*x
    str += "D"*y
    #3
    str += "L"
    str += "U"*(y+1)
    str += "R"*(x+1)
    str += "D"
    #4
    str += "R"
    str += "D"*(y+1)
    str += "L"*(x+1)
    str += "U"

elif(x > 0) and (y < 0):
    #1
    str += "R"*x
    str += "D"*y
    #2
    str += "L"*x
    str += "U"*y
    #3
    str += "L"
    str += "D"*(y+1)
    str += "R"*(x+1)
    str += "U"
    #4
    str += "R"
    str += "U"*(y+1)
    str += "L"*(x+1)
    str += "D"

elif(x < 0) and (y > 0):
    #1
    str += "L"*x
    str += "U"*y
    #2
    str += "R"*x
    str += "D"*y
    #3
    str += "R"
    str += "U"*(y+1)
    str += "L"*(x+1)
    str += "D"
    #4
    str += "L"
    str += "D"*(y+1)
    str += "R"*(x+1)
    str += "U"
    
elif(x < 0) and (y < 0):
    #1
    str += "L"*x
    str += "D"*y
    #2
    str += "R"*x
    str += "U"*y
    #3
    str += "R"
    str += "D"*(y+1)
    str += "L"*(x+1)
    str += "U"
    #4
    str += "L"
    str += "U"*(y+1)
    str += "R"*(x+1)
    str += "D"

elif(x==0) and (y < 0):
    #1
    str += "D"*y
    #2
    str += "R"
    str += "U"*y
    str += "L"
    #3
    str += "L"
    str += "D"*y
    str += "R"
    #4
    str += "D"
    str += "LL"
    str += "U"*(y+2)
    str += "RR"
    str += "D"

elif(x==0) and (y > 0):
    #1
    str += "U"*y
    #2
    str += "R"
    str += "D"*y
    str += "L"
    #3
    str += "L"
    str += "U"*y
    str += "R"
    #4
    str += "U"
    str += "LL"
    str += "D"*(y+2)
    str += "RR"
    str += "U"

elif(x > 0) and (y == 0):
    #1
    str += "R"*x
    #2
    str += "U"
    str += "L"*x
    str += "D"
    #3
    str += "D"
    str += "R"*x
    str += "U"
    #4
    str += "R"
    str += "UU"
    str += "L"*(y+2)
    str += "DD"
    str += "R"
    
elif(x < 0) and (y == 0):
    #1
    str += "L"*x
    #2
    str += "U"
    str += "R"*x
    str += "D"
    #3
    str += "D"
    str += "L"*x
    str += "U"
    #4
    str += "L"
    str += "UU"
    str += "R"*(y+2)
    str += "DD"
    str += "L"
    
print(str)

Measured memory_bytes: 3284
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = new int[N].Select(x => x = int.Parse(Console.ReadLine())).ToArray();
            var ok = false;
            var count = 1;
            var next = A[0];
            var checker = new bool[N + 1];
            checker[1] = true;
            while (!checker[next])
            {
                if (next == 2)
                {
                    ok = true;
                    break;
                }
                checker[next] = true;
                next = A[next - 1];
                count++;
            }
            Console.WriteLine(ok ? count : -1);
        }
    }
}


Measured memory_bytes: 31904
#include <iostream>
#define Input cin
#define Output cout
using namespace std;

int main() {
  int N;
  Input >> N;
  int x[N], y[N], h[N];
  for (int i = 0; i < N; i++) {
    Input >> x[i] >> y[i] >> h[i];
  }
  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      int H = -1;
      bool flag = true;
      for (int i = 0; i < N; i++) {
        if (h[i] == 0) {
          continue;
        }
        int setH = h[i]+abs(x[i]-Cx)+abs(y[i]-Cy);
        if (H == -1) {
          H = setH;
        }
        if (H != setH) {
          flag = false;
          break;
        }
      }
      for (int i = 0; i < N; i++) {
        int seth = max(H-abs(x[i]-Cx)-abs(y[i]-Cy),0);
        if (h[i] != seth) {
          flag = false;
          break;
        }
      }
      if (flag) {
        Output << Cx << " " << Cy << " " << H << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [i32; n],
        b: [i32; n],
        c: [i32; n - 1],
    }
    let mut ans = 0;
    for i in 0..n {
        ans += b[a[i] as usize - 1];
        if i > 0 && a[i - 1] == a[i] - 1 { ans += c[a[i - 1] as usize - 1] }
    }
    println!("{}", ans);
}


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


void solve(long long N, long long M){
	cout << N*(N-1)/2 + M*(M-1)/2 << endl; 
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256