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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ff(i,a,b) for(int i = a; i < b; i++)
#define fb(i,a,b) for(int i = a; i > b; i--)
#define MOD 1000000007


ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}



/*void solve(){
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	int x[3];
	x[0]=a; x[1]=b; x[2]=c;
	sort(x,x+3);
	//cout<<x[0]<<" "<<x[1]<<" "<<x[2];
	int m=n/x[0];
	fb(i,m,-1){
		ff(j,0,n/x[1]+1){
			ff(k,0,n/x[2]+1){
				//cout<<x[0]*i+x[1]*j+x[3]*k<<"\n";
				if(((x[0])*i+(x[1])*j+(x[3])*k)==n){
					cout<<(i+j+k)<<"\n";
					return;
				}
			}
		}
	}
}*/

void solve(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll y=x/d;
	ll ans;
	if(y>=k) cout<<x-d*k;
	else{
		ans=x-y*d;
		k-=y;
		if(k%2) cout<<abs(ans-d);
		else cout<<ans;
	}
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	//int t;
    //cin>>t;
	//while(t--)
		solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3796
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
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; }

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    for (int i = 0; i < a; i++) cout << b;
    cout << endl;
    return 0;
}

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

    ll x,c1=0,c2=0;
    cin>>x;

    c1=x/500;

    ll rem=x%500;
    c2=rem/5;
    cout<<(c1*1000)+(c2*5)<<endl;


}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int x;
int main() {
	scanf("%d",&x);
	for (long long i = -1000;i <= 1000;i++)
		for (long long j = -1000;j <= 1000;j++) if (i*i*i*i*i-j*j*j*j*j == 1ll*x) return 0*printf("%lld %lld",i,j);
    return 0;
}

Measured memory_bytes: 3828
import time
start = time.time()

import sys
input = sys.stdin.readline

N = int(input())
A = [[int(i) - 1 for i in input().split()] for _ in range(N)]

cur = [0] * N

max_pairs = N * (N - 1)

pairs = 0
cnt = 1
for _ in range(max_pairs // 2):
    visited = [False] * N
    for i, a in enumerate(A):
        if cur[i] >= N - 1:
            continue
        p = a[cur[i]]
        if A[p][cur[p]] == i:
            # print(cnt, p + 1, A[p][cur[p]] + 1, i + 1)
            visited[i] = True
            visited[a[cur[i]]] = True
            pairs += 1

    # print(pairs)
    if pairs == max_pairs:
        break
    if pairs > max_pairs:
        print(-1)
        quit()

    update = False
    for i, v in enumerate(visited):
        if v:
            cur[i] += 1
            update = True

    if not update:
        print(-1)
        quit()

    if time.time() - start > 1.8:
        print(N * (N - 1) // 2)
        exit()

    cnt += 1

print(cnt)

Measured memory_bytes: 55000
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    char x, y; cin >> x >> y;

    if (x > y) print(">");
    else if(x == y) print("=");
    else print("<");

}

Measured memory_bytes: 3660
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
std::map<T, int> prime_factorize(T x) {
  std::map<T, int> primes;
  for (T factor = 2; factor * factor <= x; factor++) {
    if (x % factor == 0) {
      T count = 0;
      while (x % factor == 0) {
          count++;
          x /= factor;
      }
      primes[factor] = count;
    }
  }
  if (x != 1) primes[x] = 1;
  return primes;
}

int main() {
  int N; cin >> N;
  int total = 0;
  for (int i = 1; i <= N; i += 2) {
    auto m = prime_factorize(i);
    int cnt = 1;
    for (auto [k, v] : m) cnt *= v + 1;
    if (cnt == 8) {
      ++total;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
import math


def fact(N):
  ret = set()
  for i in range(1,math.ceil(N**(0.5))+1):
    if N % i == 0:
      ret.add(i)
  return ret


if __name__ == "__main__":
  N = int(input())  
  ret = fact(N)
  ans = len(str(N))
  for r in ret:
    ans = min(ans, max(len(str(r)), len(str(N//r))))
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		
		int N = 0;
		int tre = 0;
		int count = 0;
		int minj = 0;
		int A[];
		
		N = Integer.parseInt(as.next());
		
		A = new int[N];
		
		for(int i=0;i<N;i++){
			
			A[i] = Integer.parseInt(as.next());
			
		}
		
		for(int i=0;i<=N-1;i++){
			
			minj = i;
			for(int j=i;j<=N-1;j++){
				
				if(A[j] < A[minj]){
					
					minj = j;
					
				}
				
			}
			
			tre = A[i];
			A[i] = A[minj];
			A[minj] = tre;
			if(i != minj)
				count++;
			
		}
		
		for(int i=0;i<N;i++){
			
			if(i != N-1){
				
				sb.append(A[i]).append(' ');
			
			}
			else{
				
				sb.append(A[i]);
				
			}
		}
		System.out.println(sb.toString());
		sb.setLength(0);
		sb.append(count);
		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 26132
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,R;
  cin >> N >> R;
  if(N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100*(10-N) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        if((r*100+g*10+b*1)%4==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21712
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
using namespace std;
int main() {
	int n;;
	while (cin >> n, n) {
		vector<long long> a(n);
		for (long long &x : a)cin >> x;
		sort(a.begin(), a.end());
		long long sum = 0, sum1 = 0;
		//for (long long &x : a)sum1+=sum,sum+=x;
		for (long long &x : a)x = (sum += x);
		sum = 0;
		for (long long &x : a)x = (sum += x);
		cout << (n <= 1 ? 0 : a[n - 2]) << endl;
		//cout << sum1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int index=-1;
  bool flag=true;
  REP(i,s.size()-t.size()+1){
    REP(j,t.size()){
      if(s[i+j]=='?'){
        continue;
      }else if(s[i+j]==t[j]){
        continue;
      }else{
        flag=false;
        break;
      }
    }
    if(flag){
      index = i;
    }
    flag=true;
  }
  
  if(index==-1){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }else{
    string ans="";
    REP(i,index){
      if(s[i]=='?'){
        ans += 'a';
      }else{
        ans += s[i];
      }
    }
    ans += t;
    for(int i=index+t.size();i<s.size();i++){
      if(s[i]=='?'){
        ans += 'a';
      }else{
        ans += s[i];
      }
    }
    cout<<ans<<endl;
    return 0;
  }
  return 0;
}

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

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  
  ll ans = 0;
  if(a+b<k){
    ans = k-a-b;
    ans = a-ans;
  }else if(a<k && k <=(a+b)){
    ans = a;
  }else if(a>=k){
    ans = k;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
import kotlin.math.abs
import kotlin.math.min

fun solver(n: Int, k: Int, xs: List<Int>): Int {
    var sum = 0

    xs.forEach { x ->
        sum += min(x, abs(x - k)) * 2
    }

    return sum
}

fun main(args: Array<String>) {
    
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map { it.toInt() }
     
/*
    val n = 5
    val k = 20
    val xs = listOf(11, 12, 9, 17, 12)
*/
    val result = solver(n, k, xs)

    println(result)
}


Measured memory_bytes: 36464
#include <iostream>
#include <bitset>
using namespace std;
const int INF=0x3f3f3f3f,maxn=2010;
bitset<2000010> dp;
int a[maxn],n,sum,m;
int main()
{
	int i,j,k,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	sum+=a[i];
	}
    dp[0]=1;
    for(i=n-1;i>=0;i--)
		dp|=dp<<a[i];
    for(i=(sum+1)/2;i<=sum;i++)
        if(dp[i])
        {
            cout<<i;
            return 0;
        }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>
int 
main(){
	double N;
	double ans ;	
	scanf("%lf",&N);
	
	if(fmod(N,2)==0) ans = 1/2.;
	else ans = (int)(N/2+1)/N;
	printf("%lf\n",ans);
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
#define ll long long int
using namespace std;

int main()
{
    //freopen("a.inp","r",stdin);
    ll n,d,dem=0,m, x, y;
    cin>>n>>d;
    for(ll i=1; i<=n; ++i)
    {
        cin>>x>>y;
        m= x*x + y*y;
        //cout<<sqrt(m)<<endl;
        if( sqrt(m)<=d ) dem++;
    }
    cout<<dem;
    return 0;
}


Measured memory_bytes: 3636
import math
def combinations_count(n,r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    

n,m = map(int,input().split())

s = n + m
print(combinations_count(s,2) - (combinations_count(n,1)*combinations_count(m,1)))

Measured memory_bytes: 3060
def tousa_sum(amin, amax, d): # amin以上amax以下 公差d 
    n = (amax-amin) // d + 1
    return n * (2*amin + (n-1)*d) // 2

n = int(input())
total = 0
for i in range(1, n+1):
    total += tousa_sum(i, n, i)
print(total)

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

int main()
{
	int n;
	cin >> n;
	string s = to_string(n);

	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) == '1')
		{
			s.at(i) = '9';
		}
		else
		{
			s.at(i) = '1';
		}
	}

	cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n, m, a;
	cin>>n>>m;
	a = m*n;
	p(a);	return 0;
}	

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a = ivec(n);
    vec b = ivec(n);
    vec c = ivec(n - 1);

    int pt = b[a[0] - 1];
    For(i, 1, n - 1) {
        pt += b[a[i] - 1];
        if (a[i] == a[i - 1] + 1) pt += c[a[i - 1] - 1];
    }
    print(pt);

    return 0;
}


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


int HP[100], M;
long long dp1[100001], dp2[100001];

int solve(int N)
{
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
    
  for(int i = 0; i < N; i++) {
    cin >> HP[i];
  }
  cin >> M;

  bool end = false;
  while(M--) {
    string Name, Target;
    int MP, Damage;
    cin >> Name >> MP >> Target >> Damage;
    if(MP == 0) {
      if(Damage > 0) end = true;
      continue;
    }
    long long *dp = Target.size() == 3 ? dp1 : dp2;
    for(int i = MP; i <= 100000; i++) {
      dp[i] = max(dp[i], dp[i - MP] + Damage);
    }
  }
  if(end) return(0);
  
  int best = 1 << 30;
  for(int i = 0; i <= 100000; i++) {
    int ret = 0;
    for(int j = 0; j < N; j++) {
      ret += lower_bound(dp2, dp2 + 100001, HP[j] - dp1[i]) - dp2;
    }
    best = min(best, i + ret);
  }
  return(best);
}

int main()
{
  int N;
  while(cin >> N, N) {
    cout << solve(N) << endl;
  }
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), M = input();
    auto rg = make_vector(N, 0, 0);
    range(i, 0, M) {
        int x = input() - 1, y = input() - 1;
        rg[y].push_back(x);
    }
    
    vector< int > dp(N, -1);
    function< int(int) > dfs = [&](int v) {
        if (~dp[v]) return dp[v];
        int &res = dp[v];
        res = 0;
        for (auto to: rg[v]) chmax(res, dfs(to) + 1);
        return res;
    };

    int ans = 0;
    range(i, 0, N) {
        chmax(ans, dfs(i));
    }
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 12160
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI


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

    int a=0; int w=0; int t=0; int r=0;
    rep(i,n){
        string in;
        cin>>in;
        if(in== "AC") ++a;
        else if(in=="WA") ++w;
        else if(in=="TLE") ++t;
        else ++r;
    }
    cout << "AC" << " x " << a <<endl;
    cout << "WA" << " x " << w <<endl;
    cout << "TLE" << " x " << t <<endl;
    cout << "RE" << " x " << r <<endl;
}

Measured memory_bytes: 3628
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;
 
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll M =  500 + 10;
const ll N = 100 * 1000 + 10;

vector <int> adj[N];
set <int> g[N];
bool mark[N];
ll par[N];

void dfs(int v)
{
	mark[v] = 1;
	vector <int> ver;
	for (auto u : adj[v])
	{
		if(!mark[u])
		{
			if(g[u].size() == 1)
				par[u] = v + 1, ver.push_back(u);
			else
			{
				g[u].erase(g[u].find(v));
			}
		}
	}
	for (auto u : ver)
		dfs(u);
}

int main()
{
	faster();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m + n - 1; i++)
	{
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u);
		g[u].insert(v);
	}
	int root;
	for (int i = 0; i < n; i++)
	{
		if(g[i].empty())
		{
			root = i;
		}
	}
	dfs(root);
	par[root] = 0;
	for (int i = 0; i < n; i++)
	{
		cout << par[i] << "\n";
	}
}

Measured memory_bytes: 29056
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int ans = 0;
    for(int i=0;i<n;++i)
    {
        if(a[i] == b[i] && b[i] == c[i])
        {
            // no increment
        }
        else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i])
        {
            ans += 1;
        }
        else
        {
            ans += 2;
        }
        
    }

    cout << ans << endl;
}

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

S = [0]*(N+1)
for i in range(N):
  S[i+1] = S[i] + (1+p[i])/2

ans = 0
for i in range(N-K+1):
  diff = S[i+K] - S[i]
  ans = max(ans, diff)
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     int n,m,i,cnt=0,res=0;
     double ans,mmd;
 
     cin>>n>>m;
     int a[n];
     mmd = (1.0)/(4.0*m);
     for(i = 0; i < n; i++)
     {
          cin>>a[i];
          res+=a[i];
     }
     for(i = 0; i < n; i++)
     {
          ans = (a[i]*1.0)/(res*1.0);
 
          if(ans<mmd)
               cnt=cnt;
          else
               cnt++;
     }
     if(cnt>=m)
          cout<<"Yes\n";
     else
          cout<<"No\n";
 
 
     return 0;
}

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

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

lint stl(char x){
    return (lint)(x - 'a');
}
int main(){
    STR(s, t); lint n = Size(s);
    vector<vlint> cnt(26, vlint());
    rep(i, 2*n){
        cnt[stl(s[i%n])].pb(i);
    }
    lint ans = -1;
    rep(i, Size(t)){
        auto it = upper_bound(all(cnt[stl(t[i])]), ans%n);
        if (cnt[stl(t[i])].empty()){
            ans = -2; break;
        }
        ans += *it - ans%n;
    }
    print(ans+1);
}


Measured memory_bytes: 5692
N=int(input())
l=[]
L=[]
for i in range(N):
  a,b=(input().split())
  l.append((a,b))
for i in range(N):
    c,d=l[i]
    if d=="JPY":
        L.append(float(c))
    else:
        L.append(float(c)*380000.0)
print(sum(L))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        int tmp;cin>>tmp;
        a[i]-=tmp;
    }
    int tot=0;
    rep(i,n)if(a[i]>0)tot+=a[i];
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 256
def height(cx, cy, D):
    for x, y, h in D:
        if h <= 0: continue
        return h + abs(x-cx) + abs(y-cy)
    return 0

def valid(cx, cy, H, D):
    for x, y, h in D:
        if h != max(H - abs(x-cx) - abs(y-cy), 0):
            return False
    return True

def solve():
    for cy in range(0, 101):
        for cx in range(0, 101):
            H = height(cx, cy, D)
            if valid(cx, cy, H, D):
                return (cx, cy, H)
    return (0, 0, 0)

N = int(input())
D = []
for i in range(N):
    x, y, h = map(int, input().split())
    D.append((x, y, h))
cx, cy, H = solve()
print(cx, cy, H)



Measured memory_bytes: 44380
import sys
input = lambda: sys.stdin.readline().rstrip()

from heapq import heappop, heappush, heapify
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

sum_list = []
seen_list = set()
ans = []

heappush(sum_list, (-(A[0]+B[0]+C[0]), 0, 0, 0))

for _ in range(K):
    s, i, j, k = heappop(sum_list)
    
    ans.append(-s)

    if i+1 < len(A) and (i+1, j, k) not in seen_list:
        heappush(sum_list, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
        seen_list.add((i+1, j, k))

    if j+1 < len(B) and (i, j+1, k) not in seen_list:
        heappush(sum_list, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
        seen_list.add((i, j+1, k))

    if k+1 < len(C) and (i, j, k+1) not in seen_list:
        heappush(sum_list, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
        seen_list.add((i, j, k+1))

for i in range(0, K):
    print(ans[i])

Measured memory_bytes: 55132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define endll "\n"

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,s,c=0;
    cin >> k >> s;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-(i+j)>=0 && s-(i+j)<=k){
                c++;
            }
        }
    }
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3640
N=int(input())

for i in range(1,N+1):
    if(N<=(i*(i+1)//2)):
        print(i)
        if(N==1 or N==2):
            exit()
        M=N-i
        j=i-1
        while(M>0):
            if(M>=j):
                M-=j
                print(j)
            j-=1
        exit()
            
        



Measured memory_bytes: 3316
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 1e5;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

const int MAX_LOG = 20;

int f[MAXN + 5][MAX_LOG + 1];

int ans = 0;

inline void dfs(int u, int fa)
{
	for(auto v : adj[u]) if(v != fa)
	{
		dfs(v, u);
		for(int i = 0; i <= MAX_LOG; ++i) f[u][i] += f[v][i];
	}

	int k = 0;
	for(int i = MAX_LOG; i >= 0; --i) if(f[u][i] >= 2) { k = i + 1; break; }
	while(f[u][k] == 1) ++k;

	chkmax(ans, k), ++f[u][k];
	for(int i = 0; i < k; ++i) f[u][i] = 0;
}

inline void solve()
{
	dfs(1, 0);
	printf("%d\n", ans);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 17920
import sys
A, B = map(int,input().split())
S = input()
for i in range(A + B + 1):
    if i == A:
        if S[i] != '-':
            print('No')
            sys.exit()
    else:
        if not S[i] in '0123456789':
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 9168
/*
 * @Author: Kaizyn
 * @Date: 2020-05-10 20:58:25
 * @LastEditTime: 2020-05-10 21:02:00
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

int a, b, c, k;

inline void solve() {
  cin >> a >> b >> c >> k;
  int res = 0, g;
  g = min(a, k);
  a -= g;
  k -= g;
  res += g;
  g = min(b, k);
  b -= g;
  k -= g;
  g = min(c, k);
  c -= g;
  k -= g;
  res -= g;
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3648
n=int(input())
x=[0]*n
u=[0]*n
k=0
b=0
for i in range(n):
  x[i],u[i]=map(str,input().split())
  x[i]=float(x[i])

for i in range(n):
  if u[i]=='JPY':
    k+=x[i]
  else:
    b+=x[i]
    
b=b*380000
print(k+b)

Measured memory_bytes: 3064
N=int(input())
S=input()
A=[0]*N
B=[0]*N
count=0
for i in range(N):
    if S[i]=='W':
        count+=1
    A[i]=count
cnt=0

for i in range(N)[::-1]:
    if S[i]=='E':
        cnt+=1
    B[i]=cnt
mini=10000000
if mini>B[1]:
    mini=B[1]
if mini>A[N-2]:
    mini=A[N-2]

for i in range(1,N-1):
    if mini>(A[i-1]+B[i+1]):
        mini=A[i-1]+B[i+1]

print(mini)

Measured memory_bytes: 17568
use std::collections::HashMap;

macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(i64);
    let mut m = HashMap::new();
    for _ in 0..n {
        let a = scan!(i64);
        let v = m.entry(a).or_insert(0);
        *v += 1;
    }
    let mut ans = 0;
    for val in m.values() {
        if val % 2 == 1 {
            ans += 1
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
N = int(input())

INF = float('inf')
dp = [INF] * (N+10)
dp[0] = 0

coin6 = [6**n for n in range(1,10) if 6**n <= N]
coin9 = [9**n for n in range(1,10) if 9**n <= N]

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+1)
    for j in coin6:
        if j+i <= N:
            dp[i+j]=min(dp[i+j],dp[i]+1)
    for j in coin9:
        if j+i <= N:
            dp[i+j]=min(dp[i+j],dp[i]+1)
print(dp[N])

Measured memory_bytes: 47948
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<int,int> P;
vector<P> v[1000];
int main(){
  int n,m,a;
  while(cin >> n >> m >> a,n){
    a--;
    rep(i,1000) v[i].clear();
    int h,p,q;
    rep(i,m){
      cin >> h >> p >> q;
      v[h-1].push_back(P(p-1,q-1));
    }
    rep(i,1000){
      int j=999-i;
      rep(k,v[j].size()){
        if(v[j][k].first==a) a=v[j][k].second;
        else if(v[j][k].second==a) a=v[j][k].first;
      }
    }
    cout << a+1 << endl;
  }
  return 0;
}




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

int main(){
    int n, m; cin >> n >> m;
    int a[m], b[m], c[m], dist[n][n];
    REP(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }
    /* Initialization */
    REP(i, n) REP(j, n) {
        if(i == j) dist[i][j] = 0;
        else dist[i][j] = INF;
    }
    REP(i, m) {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = dist[a[i]][b[i]];
    }
    /* Update */
    REP(k, n) REP(i, n) REP(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    /* Check */
    int ans = m;
    REP(i, m){
        bool shortest = false;
        REP(j, n) if(dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
        if(shortest == true) ans--;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main() {
    bool flag = true;
    int a, b;
    cin >> a;
    set<int> s;
    for (int i = 0; i < a; i++) {int t;cin >> t;s.insert(t);}
    cin >> b;
    for (int i = 0; i < b; i++) {
        int t;
        cin >> t;
        if (s.count(t)==0) {
            flag = false;
            break;
        }
    }
    cout << flag << endl;
    return 0;
}


Measured memory_bytes: 12480
N = int(input())
A = ''.join(list(map(lambda x: format(int(x), '060b'), input().split(' '))))
mod = 10 ** 9 + 7
ans = 0
for n in range(60):
    one = A[59-n::60].count('1')
    ans = (ans + 2**n *one*(N-one))%mod
print(ans)

Measured memory_bytes: 254584
#include <iostream>
using namespace std;
int main (){
    int a,b;
    cin>>a;
    cin>>b;
    if (a==b)
        cout<<"Draw";
    else if (a==1)
        cout<<"Alice";
    else if (b==1)
        cout<<"Bob";
    else if (a>b)
        cout <<"Alice";
    else
        cout<<"Bob";
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		Map<String, String> map = new HashMap<String, String>();

		map.put("ABC", "ARC");

		map.put("ARC", "ABC");

		if(map.containsKey(a)) {



		System.out.println(map.get(a));

	}
	else {

		System.out.println("もう一度やり直して下さい");
	}
}
}

Measured memory_bytes: 35576
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll K;
  string S;
  cin >> K >> S;
  if(S.size() <= K) cout << S << endl;
  else {
    for(ll i = 0; i < K; i++) cout << S.at(i);
    for(ll i = 0; i < 3; i++) cout << '.';
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int a, b, h; cin >> a >> b >> h;
    cout << (a + b) * h / 2 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;

struct UnionFind {
    vector<int> t;
    UnionFind(int size): t(size, -1) {}
    int root(int x) {return t[x] < 0 ? x : t[x] = root(t[x]);}
    int size(int x) {return -t[root(x)];}
    bool is_same(int x, int y) {return root(x) == root(y);}
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x != y) {
            if(t[y] < t[x]) swap(x, y);
            t[x] += t[y], t[y] = x;
        }
        return x != y;
    }
};

int n, m, k;
UnionFind uf(111111);

signed main() {
    cin>>n>>m>>k;
    int a, b, c, d, ans;
    int fri[111111] = {};
    vector<int> block[111111];
    for (int i = 0; i < m; i++) {
        cin>>a>>b;
        a--, b--;
        uf.unite(a, b);
        fri[a]++;
        fri[b]++;
    }
    for (int i = 0; i < k; i++) {
        cin>>c>>d;
        c--, d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    for (int i = 0; i < n; i++) {
        ans = uf.size(i) - 1 - fri[i];

        for (auto j: block[i]) {
            if (uf.is_same(i, j)) ans--;
        }
        cout<<ans<<' ';
    }
}

Measured memory_bytes: 8704
import java.io.IOException;
import java.util.Scanner;
public class Main {

	/**
	 * ??¶?´???????????????????
	 * @param S
	 */
	public static int judge(int sec){
		int result=0;
		if(sec<0||sec>=86400){
			result = 1;
		}
		else{
			result = 0;
		}
		return result;

	}

	 public static void main(String[] args) throws IOException{

		/*?????°?????£?¨?*/
		int h,m,s,sec=0; //?????????????????¨????????????????§???°
		int hour,minutes; //??????(?§?)?????????
		String str;

		 /* ?????????????????\???(????????????????§???°????±????) */
		Scanner scan = new Scanner(System.in);
		str = scan.next();
		sec = Integer.parseInt(str);

		/*???????????????*/
		h = sec/3600;
		hour = sec%3600; //?????£????§???°

		m = hour/60;
		minutes = hour%60;

		s = minutes;

		if(judge(sec) == 0){
			System.out.println(h+":"+m+":"+s);
		}
		else if(judge(sec) == 1){
			System.out.println("??\?????§????????????0~86399?????§??§???.???????????????.");
		}

	}

}

Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<< #x << " = "<<(x)<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

typedef pair<int,int> P;

struct edge{
  int u,v,cost;
};
bool comp(const edge& e1,const edge& e2){
  return e1.cost < e2.cost;
}
int uni[1000010];
void init(int N){
  for(int i=0;i<N;i++){
    uni[i]=-1;
  }
}

int root(int a){
  if(uni[a] < 0)return a;
  else return uni[a] = root(uni[a]);
}
bool unite(int a,int b){
  a = root(a);
  b = root(b);
  if(a==b) return false;
  if(uni[a] > uni[b]) swap(a,b);
  uni[a]+=uni[b];
  uni[b]=a;
}
bool same(int a,int b){
  return root(a)==root(b);
}

vector<edge> es;
vector<P> xbox;
vector<P> ybox;
int n,E;

int kruskal(){
  sort(es.begin(),es.end(),comp);
  init(n+10);
  int res=0;
  rep(i,es.size()){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);

      res+=e.cost;
    }
  }
  return res;
}

signed main(){
  cin>>n;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    xbox.push_back(P(x,i));
    ybox.push_back(P(y,i));
  }
  sort(xbox.begin(),xbox.end());
  sort(ybox.begin(),ybox.end());
  //辺をはる
  rep(i,n-1){
    es.push_back((edge){xbox[i].second,xbox[i+1].second,xbox[i+1].first-xbox[i].first});
    es.push_back((edge){xbox[i+1].second,xbox[i].second,xbox[i+1].first-xbox[i].first});
    es.push_back((edge){ybox[i].second,ybox[i+1].second,ybox[i+1].first-ybox[i].first});
    es.push_back((edge){ybox[i+1].second,ybox[i].second,ybox[i+1].first-ybox[i].first});
  }

  cout<<kruskal()<<endl;


}


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


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

    int mod = n%1000;

    if(mod == 0)
    {
        cout<<0<<endl;
    }
    else{
        cout<<1000-mod<<endl;
    }

    return 0;
}




Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N;
	long long int sum=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		if(i%3!=0&&i%5!=0)sum+=i;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
S=input()
T=input()

N_max = len(T)
for i in range(len(S)-len(T)+1):
  score=0
  for j in range(len(T)):
    if(S[i+j] != T[j]):
      score += 1
      
  N_max = min(score, N_max)
  
print(N_max)

Measured memory_bytes: 8976
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  sort(a.begin(),a.end(),greater<int>());

  int suma = 0,sumb = 0;
  for(int i=0;i<n;i++){
    if(i%2 == 0) suma += a[i];
    else sumb += a[i];
  }

  cout << suma - sumb << endl;
}

Measured memory_bytes: 3620
package main

import "fmt"

func main() {
	var r, D, x int
	fmt.Scanf("%d", &r)
	fmt.Scanf("%d", &D)
	fmt.Scanf("%d", &x)

	for i := 1; i <= 10; i++ {
		x = r * x - D
		fmt.Printf("%d\n", x)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;double ans,k;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&k);
		ans+=1/k;
	}
	printf("%.10lf",1/ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    ll a[n+5];
    ll out[n+5] = {};
    ll i;
    ll val = 0;
    FOR0(i, n)
    {
        cin>>a[i];
        if(i%2==0)
            val += a[i];
        else val -= a[i];
    }
    ll x = val/2;
    out[0] = x;
    FOR(i, 1, n)
    {
        out[i] = a[i-1] - out[i-1];
    }
    FOR0(i, n) cout<<2*out[i]<<" ";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 2944