akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, K, R, S, P;
string T;

int get_point(char aite) {
  if (aite=='r') return P;
  else if (aite == 's') return R;
  else return S;
}

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

  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  int ans = 0;
  rep(i, K) {
    int idx = i;
    char now = T[idx];
    int cnt=0;
    while(idx<N) {
      if (now == T[idx]) {
        cnt++;
      }else {
        int z = (cnt+1) /2;
        ans+=get_point(now) *z;
        now = T[idx];
        cnt=1;
      }
      idx+=K;
    }
    int z = (cnt+1) /2;
    ans+=get_point(now) * z;
  }

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

Measured memory_bytes: 512
n=int(input())
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
c=0
for i in range(n):
  if l1[i]>l2[i]:
    c+=l2[i]
    l2[i]=0
  elif l1[i]==l2[i]:
    c+=l1[i]
    l2[i]=0
  else:
    c+=l1[i]
    l2[i]=l2[i]-l1[i]
    if l2[i]>=l1[i+1]:
      c+=l1[i+1]
      l1[i+1]=0
    elif l2[i]<l1[i+1]:
      c+=l2[i]
      l1[i+1]=l1[i+1]-l2[i]
print(c)
  
    

Measured memory_bytes: 18476
#include<stdio.h>
typedef struct tag_q
{
    int l;
    int r;
}query;

int main(void){
    int number_flag[100000];
    int q_num;
    scanf("%d",&q_num);
    query Query[q_num];
    for(int i = 0;i < q_num;i++){
        scanf("%d %d",&(Query[i].l),&(Query[i].r));
    }

    //all flag set 1(prime)
    for(int i = 0;i < 100000;i++){
        number_flag[i] = 1;
    }

    number_flag[0] = 0;//1 is not prime

    //check prime(flag1 = prime)

    for(int i = 1;i < 100000;i++){
        if(number_flag[i] == 1){
            for(int j = 2;((i + 1) * j - 1) < 100000;j++){
                number_flag[(i + 1) * j - 1] = 0;
            }
        }
    }

    //2017_Like Check(flag1 = 2017_Like)
    //all flag set 0(not Like)
    int Like_Check_num[100000];

    for(int i = 0;i < 100000;i++){
        Like_Check_num[i] = 0;
    }

    for(int i = 2;i < 100000;i++){
        if(number_flag[i] == 1 && number_flag[((i + 2) / 2 )- 1] == 1){
            Like_Check_num[i] = 1;
            //printf("%d\n",i + 1);
        }
    }

    int number_cusum[100001];
    number_cusum[0] = 0;

    for(int i = 1;i < 100001;i++){
        number_cusum[i] = number_cusum[i - 1] + Like_Check_num[i - 1];
        //printf("%d",number_cusum[i]);
    }

    //res query
    for(int i = 0;i < q_num;i++){
        //printf("%d - %d\n",Query[i].r + 1,Query[i].l);
        printf("%d\n",number_cusum[Query[i].r] - number_cusum[Query[i].l - 1]);
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <cmath>
#include <limits>
using namespace std;

int main()
{
    // 1000000000000001
    // 01234567890123456789
    unsigned long long int n;
    cin >> n;
    std::string s;
    long long int sum = 0;

    long long int nn = n - sum;
    while(1){
        long long int a = n % 26;
        n = n / 26;
        if(a == 0){
            a = 26;
            n -= 1;
        }
        char tmp = 96 + a;
        s += tmp;
        /*
        cout << a << endl;
        cout << n << endl;
        cout << tmp << endl;
        */
        if(n == 0) break;
        
    }
    std::reverse(s.begin(), s.end());
    cout << s << endl;

    
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
int n,k;
double ans;
double coins(int x){
    double ans=1;
    while(x<k){
        x*=2;
        ans/=2.0;
    }
    return ans;
}
// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        ans+=double(coins(i)/double(n));
    }
    
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

char s[100001];
char t[100001];
int sum1[100001];
int sum2[100001];

int main() {
    int n, m, q, i;
    
    scanf("%s", s);
    scanf("%s", t);
    
    n = strlen(s);
    m = strlen(t);
    
    for (i = 0; i < n; i++) {
        if (s[i] == 'A') {
            sum1[i + 1] = sum1[i] + 1;
        } else {
            sum1[i + 1] = sum1[i] + 2;
        }
    }
    
    for (i = 0; i < m; i++) {
        if (t[i] == 'A') {
            sum2[i + 1] = sum2[i] + 1;
        } else {
            sum2[i + 1] = sum2[i] + 2;
        }
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        int a, b, c, d;
        
        scanf("%d %d %d %d", &a, &b, &c, &d);
        
        if ((sum1[b] - sum1[a - 1]) % 3 == (sum2[d] - sum2[c - 1]) % 3) {
            puts("YES");
        } else {
            puts("NO");
        }
    }
    
    return 0;
}


Measured memory_bytes: 1408
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast	
//cout << setprecision(15) << fixed;

cin >> n;
ll sum =0;
map<ll,ll> mp;
fr(i,0,n)
{
	cin >> k;
	mp[k]++;
	sum += k;
}
ll q;cin>>q;
    fr(i,0,q){
        ll a,b;
        cin>>a>>b;
        sum+=(b-a)*mp[a];
        mp[b]+=mp[a];
        mp[a]=0;
        cout<<sum<<khtm;
    }

 eNd();
  return 0;
 
}

Measured memory_bytes: 9456
#include <iostream>

using namespace std;
int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b + c > a)
    {
        cout << (b+c)-a << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

h1, m1, h2, m2, k = nm()
wu = h1*60 + m1
gb = h2*60 + m2
print(gb - wu - k)


Measured memory_bytes: 9184
import Foundation
let n = Int(readLine()!)!

let a = readLine()!.split(separator: " ").map { Int($0)! }

var prefixSums: [Int] = .init(repeating: 0, count: a.count + 1)
let mod = 1000000007
for i in 0..<a.count {
  prefixSums[i+1] = prefixSums[i] + a[i]
  prefixSums[i+1] = prefixSums[i+1] % mod
}
var ans = 0
for i in 0..<a.count {
  ans = ans + a[i] * (prefixSums.last! - prefixSums[i+1] + mod)
  ans = ans % mod
}
print(ans)

Measured memory_bytes: 26112
#include <stdio.h>

int main(){
	int count[4][3][10], i, j, k, b, f, r, v, n;//b=棟,f=階,r=部屋番号,v=入居者数
	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				count[i][j][k] = 0; //初期化
			}
		}
	}
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		count[b - 1][f - 1][r - 1] += v; //0からの変数になるので-1
	}
	for(i = 0; i < 4; i++){
		if(i != 0){
			printf("####################\n");
		}
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				printf(" %d",count[i][j][k]);
			}
			printf("\n");
			/*if(j == 2 && i < 3){  //3棟目まで実行する
				printf("\n####################\n"); //4段目に#を20個出力する
			}*/
		}
	}
	return 0;
} 


Measured memory_bytes: 2056
/* By : rupesh282
 * link :https://atcoder.jp/contests/dp/tasks/dp_b 
 * */

#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;

int n , k;
vector<int>arr;
ll dp[MAX];

//this is memiozation using 1D dp

ll recur(int ind){
    if(ind == n)return 0;
    else if(ind > n)return INT_MAX;

    if(dp[ind]!=-1)return dp[ind];

    ll ans=INT_MAX;
    for(int i=1;i<=k;i++){
        ans = min(ans , abs(arr[ind] - arr[ind + i]) + recur(ind+i));
    }
    return dp[ind] = ans;
}
                



void solve(){
    cin>>n>>k;
    arr.resize(n+1);
    for(int i=1;i<=n;i++)cin>>arr[i];

    for(int i=2;i<=n;i++)dp[i] = INT_MAX;

    //for memiozation
    //cout<<(recur(1))<<endl;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-j > 0)
                dp[i] = min(dp[i]  , abs(arr[i] - arr[i - j]) + dp[i-j]);
        }
    }
    cout<<(dp[n])<<endl;
    return;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


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

int main()
{
ll i , o , t ;
cin >> i >> o >> t ;
ll j , l , s ;
cin >> j >> l >> s ;
ll z ;
cin >> z ;
ans+=o;
ll ii,jj,ll;
if(i%2){ans+=i/2 *2;ii=1;}
else {ans+=i;ii=0;}
if(j%2){ans+=j/2 *2;jj=1;}
else {ans+=j;jj=0;}
if(l%2){ans+=l/2 *2;ll=1;}
else {ans+=l;ll=0;}

if(ii*jj*ll){ans+=3;ii=0;jj=0;ll=0;}
if(ii*jj && l>1)ans+=1;
if(ii*ll && j>1)ans+=1;
if(jj*ll && i>1)ans+=1;

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
         
        for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
 
        Arrays.sort(a);
         
        System.out.println(a[0] + " " + a[1] + " " + a[2]);
    }
}


Measured memory_bytes: 26224
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int INF = 0x3f3f3f3f;
const int N = 23;
char maze[N][N];
int n, m;

int d[N*N][N*N];

void init() {
    scanf(II,&n,&m);
    rep (i,n) scanf("%s",maze[i]); 
}

const int goes[2][2] = {{0,1},{1,0}};

void solve() {       
    memset(d,INF,sizeof(d));
    rep (i,N*N) d[i][i] = 0;
    rep (i,n) rep (j,m) {
        if (maze[i][j] == '#') continue;
        rep (r,2) {
            int ux = i + goes[r][0];
            int uy = j + goes[r][1];
            if (ux < 0 || ux >= n || uy < 0 || uy >= m) continue;
            if (maze[ux][uy] == '#') continue; 
            d[i*m+j][ux*m+uy] = d[ux*m+uy][i*m+j] = 1;
        }
    }
    rep (i,n*m) rep (j,n*m) { ses(i); ses(j); see(d[i][j]); }
    rep (r,n*m) rep (u,n*m) rep (v,n*m) checkMin(d[u][v] , d[u][r] + d[r][v]);
    rep (i,n*m) rep (j,n*m) { ses(i); ses(j); see(d[i][j]); }
    int ans =0;
    rep (i,n*m) rep (j,n*m) if ( d[i][j] != INF ) checkMax(ans,d[i][j]);
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<float.h>
#include<string>

#define llong long long; 
using namespace std;

int main(){
  string s, t, u; cin >> s >> t >> u;
  transform(s.begin(), s.end(), s.begin(), ::toupper);
  transform(t.begin(), t.end(), t.begin(), ::toupper);
  transform(u.begin(), u.end(), u.begin(), ::toupper);

  cout << s[0] << t[0] << u[0] << endl;
}

Measured memory_bytes: 256
<?php

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $s = trim(fgets(STDIN));
    
    if (implode('', explode('hi', $s)) == '') {
        output('Yes');
    } else {
        output('No');
    }


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

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

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Numeric

main = do
    ss <- words <$>getLine
    let a:b:_ = [ read s | s <- ss] ::[Int]
    putStrLn $ show (div a b) ++" "++ show (mod a b) ++" "++ (showFFloat Nothing ((/) (fromIntegral a) (fromIntegral b))) ""

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

int main() {
    int n,x=0,ans=0;
    string c;
    cin >> n >> c;
    rep(i,n) x += bool(c.at(i)=='R');
    rep(i,x) ans += bool(c.at(i)=='W');
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;

    for(auto& p: mp){
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
import sys
from collections import defaultdict, deque

def main():
    input = sys.stdin.readline
    N = int(input())
    d = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        d[u-1].append((v-1, w))
        d[v-1].append((u-1, w))

    dist = [0] * N
    q = deque()
    q.append((0, 0))
    visited = set()

    while len(q) > 0:
        q_ = deque()
        while len(q) > 0:
            node1, cost1 = q.popleft()

            dist[node1] = cost1
            visited.add(node1)

            for node2, cost2 in d[node1]:
                if node2 in visited:
                    continue

                q_.append((node2, cost1 + cost2))

        q = q_

    for d in dist:
        print(d % 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 112428
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


using namespace std;

int cell[10000][10000];

int main()
{
  int r, c;
  cin >> r >> c;
  for(int i = 0; i < r; i++)
  {
    for(int j = 0; j < c; j++)
    {
      cin >> cell[i][j];
      cell[i][c] += cell[i][j];
      cell[r][j] += cell[i][j];
    }
  }
  for(int i = 0; i < c; i++)
  {
    cell[r][c] += cell[r][i];
  }
  for(int i = 0; i <= r; i++)
  {
    for(int j = 0; j <= c; j++)
    {
      cout << cell[i][j];
      if(j != c)
        cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
/**
AHMAD;HASSAN;SAEED
*/
using namespace std;
vector<long long>sum;

int n;
int cnt=0;
vector<vector<long long> >dp(405,vector<long long>(405,-1ll));
long long slv(int i=0,int j=n-1){
    cnt++;
    if(i==j)
        return 0ll;
    if(dp[i][j]!=-1ll)
        return dp[i][j];
    long long ad=LONG_LONG_MAX;
    for(int k=i+1;k<=j;k++){
        ad=min(ad,slv(i,k-1)+slv(k,j));
    }
    return dp[i][j]=ad+sum[j+1]-sum[i];
}


int main()
{
    cin>>n;
    vector<long long>v(n+1);
    for(int i=0;i<n;i++){
        long long tm;
        cin>>tm;
        v[i+1]=v[i]+tm;
    }
    sum=v;
    cout<<slv()<<'\n';
/**
10
10
1 1 1 1 1 1 1 1 1 1
*/
    return 0;
}


Measured memory_bytes: 4968
/**
 * author:    Ziel
 * created:   24.04.2020 11:56:32
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;
	
	vector<vector<pll>> g(n + 1);
	for (int i = 1; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		g[x].pb({y, z}), g[y].pb({x, z});
	}
	
	vector<ll> d(n + 1, INF);
	{
		set<pll> q;
		
		q.insert({0, 1});
		d[1] = 0;
		
		while (sz(q)) {
			int v = q.begin()->se;
			q.erase(q.begin());
			
			for (auto edge: g[v]) {
				ll to = edge.fi, len = edge.se;
				
				if (d[to] > d[v] + len) {
					q.erase({d[to], to});
					d[to] = d[v] + len;
					q.insert({d[to], to});
				}
			}
		}
	}
	
	vector<int> col(n + 1);
	for (int i = 1; i <= n; i++) {
		col[i] = !(d[i] & 1);
	}
	for (int i = 1; i <= n; i++) cout << col[i] << '\n';
	
	return 0;
}

/*
	Raise your standard.
*/

Measured memory_bytes: 9588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	int A[N+2], B[N+2], C[N+2];
	int ans = 0;
	for(int i = 1; i < N+1; i++){
		cin >> A[i];
	}
	for(int i = 1; i < N+1; i++){
		cin >> B[i];
	}
	for(int i = 1; i < N; i++){
		cin >> C[i];
	}
	ans+=B[A[1]];

	for(int i = 2; i < N+1; i++){
		ans+=B[A[i]];
		if(A[i]==A[i-1]+1){
			ans+=C[A[i-1]];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vvll t(n,vll(0));
  vll c(n);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  rep(i,n)cin>>c[i];
  sort(rall(c));
  vll ans(n);
  queue<ll> que;
  que.pu(0);
  vb ch(n,false);
  ch[0]=true;
  ans[0]=c[0];
  ll cu=1;
  while(sz(que)){
    ll s=que.front();
    que.pop();
    for(auto p:t[s]){
      if(ch[p]) continue;
      ch[p]=true;
      ans[p]=c[cu];
      cu++;
      que.pu(p);
    }
  }
  ll hh=0;
  rep(i,n-1){
    hh+=c[i+1];
  }
  COUT(hh);
  rep(i,n){
    cout<<ans[i]<<" ";
  }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<pair<long, long>> v;
  for(int i = 0; i < n; i++){
    long a, b;
    cin >> a >> b;
    v.emplace_back(a, b);
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for(auto p: v){
    if(cnt+p.second >= k){
      cout << p.first << endl;
      return 0;
    }
    cnt += p.second;
  }
  return 0;
}

Measured memory_bytes: 2420
N,K=map(int,input().split())
H=[int(input()) for i in range(N)]

H.sort()
ANS=10**10
for i in range(K-1,N):
    if ANS>H[i]-H[i-K+1]:
        ANS=H[i]-H[i-K+1]
print(ANS)

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

int main(){
    int n, q;
    vector<int> edges[200000];
    static int64_t val[200000] = {0};
    static int parent[200000];

    cin >> n >> q;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p, x;
        cin >> p >> x;
        val[p-1] += x;
    }

    queue<int> Q;
    Q.push(0);
    parent[0] = -1;
    while(!Q.empty()){
        int t = Q.front();
        Q.pop();
        if(parent[t] >= 0) val[t] += val[parent[t]];
        for(auto c : edges[t]){
            if(c == parent[t]) continue;
            parent[c] = t;
            Q.push(c);
        }
    }

    for(int i=0;i<n;i++){
        cout << val[i] << " \n"[i==n-1];
    }
    
    return 0;
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right){
    int i, j, k;
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for (k = left; k < right; k++){
        if (L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
            cnt += n1 - i; //=mid + j - k - 1
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
    int mid;
    llong v1, v2, v3;
    if (left + 1 < right){
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }else return 0;
}

int main(){
    int A[MAX], n, i;

    cin >> n;
    for (i = 0; i < n; i++){
        cin >> A[i];
    }

    llong ans = mergeSort(A, n, 0, n);
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	string s;
	cin>>s;
	if(s[0]==s[2]){
		cout<<"Yes\n";
		return 0;
	}	
	cout<<"No\n";
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int N,M,Q;
int A[50],B[50],C[50],D[50];
int ans=0;
vi now;

void check()
{
    int sum=0;
    rep(i,Q)if(now[B[i]]-now[A[i]]==C[i]){
        sum+=D[i];
    }
    chmax(ans,sum);
}

void dfs(int idx, int top)
{
    if (idx==N){
        check();
        return;
    }
    FOR(i,top,M){
        now.push_back(i);
        dfs(idx+1,i);
        now.pop_back();
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>M>>Q;
    rep(i,Q) cin>>A[i]>>B[i]>>C[i]>>D[i];
    rep(i,Q) A[i]--, B[i]--;
    dfs(0,1);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
  char a[123];
  scanf("%s", a);
  int k = strlen(a), o = 0;
  for (int i = 0; i < k; i++) {
    o += (a[i] == 'o');
  }
  puts(o + 15 - k >= 8 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 128
n = int(input())

hito = list(map(int, input().split()))
hito.sort()

a = min(hito)
b = max(hito)

res = []

for i in range(a,b + 1):
  s = 0
  for j in hito:
    s += (i - j) * (i - j)
  res.append(s)
print(min(res))

Measured memory_bytes: 3064
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    long n = long.Parse(input[0]);
    long p = long.Parse(input[1]);
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long mod = 1000000007;
    long answer = 0;
    long oneCount = 0;//1(mod2)の個数

    for(int i = 0; i < n; i++)
    {
      nums[i] %= 2;
      if(nums[i] == 1) oneCount++;
    }

    for(long i = p; i <= oneCount; i+=2)//1(mod2)の個数
    {
      answer += Comb(oneCount, i, mod);
      //Console.WriteLine(answer+" "+i+" "+oneCount);
    }

    for (long i = 0; i < n-oneCount; i++) answer *= 2;

    Console.WriteLine(answer);
     
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    for(long i = a; i > a-b; i--)
    {
      answer *= i;
      answer %= p;
    }
    answer *= DivideModFactorial(b, p);
    answer %= p;
    return answer;
  }
  
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define N 1e7
int main(){
    int a,d,n;
    vector<int> arr(N);
    arr[0]=arr[1]=0;
    for(int i=2; i<N; i++){
        arr[i] = 1;
    }

    for(int i=2; i<sqrt(N); i++){
        if(arr[i]){
            for(int j=0; i*(j+2)<N; j++){
                arr[i*(j+2)]=0;
            }
        }
    }  
    while(1){
        cin>>a>>d>>n;
        if(a==0 && d ==0 && n==0 ) break;
        int sum=a,cnt=0;
        while(1){
            if(arr[sum]) {
                cnt++;
            }
            if(cnt == n)break;
            sum += d;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int N;

int main(){
    cin >> N;

    int score = 0, ans = 0;
    while ( score < N ) score += ++ans;

    for(int i=ans;i>0;i--){
        if( i <= N){
            cout << i << endl;
            N -= i;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int s=1;
	int a[500],n,i,c=0;
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n-1);
    for(i=n-1;i>=0;i--,c++){
    	if((a[i]-c/4)<0)continue;
    	else s+=a[i]-c/4;
    }
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1180
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

A1 = A[0][0]
A2 = sum(A[1])

result = A1+A2

for i in range(1,N):
    A1 += A[0][i]
    A2 -= A[1][i-1]
    result = max(result, A1+A2)
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  rep(i,n/4+1) {
    rep(j,n/7+1) {
      if (4*i+7*j==n) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())

na = [a / 0.08, (a+1) / 0.08]
nb = [b / 0.1,  (b+1) / 0.1 ]

def adjust_float(l):
    mn, mx = l
    return [
        math.ceil(mn),
        math.floor(mx) if mx % 1 != 0 else int(mx - 1),
    ]

na = adjust_float(na)
nb = adjust_float(nb)

if nb[1] < na[0] or na[1] < nb[0]:
    print(-1)
elif na[0] <= nb[0] and nb[0] <= na[1]:
    print(int(nb[0]))
elif nb[0] <= na[0] and na[0] <= nb[1]:
    print(int(na[0]))


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

using namespace std;
typedef long long ll;

ll f(const ll n, vector<ll> a, vector<ll> b) {
	vector<ll> dp(n + 1);
	for (int i = 0; i <= n; ++i)
		dp[i] = i;

	for (int j = 0; j < 3; ++j)
		for (int i = 0; i <= n; ++i)
			dp[i] = max(dp[i], (i < a[j] ? 0 : dp[i - a[j]] + b[j]));

	return dp[n];
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	ll n;
	cin >> n;

	vector<vector<ll>> a(2, vector<ll>(3));
	for (vector<ll> &v : a)
		for (ll &x : v)
			cin >> x;

	n = f(n, a[0], a[1]);
	cerr << n << endl;
	n = f(n, a[1], a[0]);
	cout << n;
	return 0;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
#define ms(x,y) memset(x,y,sizeof(x))
#define ll long long 
using namespace std;


int a[20],b[20],len;
ll n,f[20][205];
ll ans;
ll nprod;
int c[20];
ll fact[20];

void calc2(int len){
	ll tmpans=fact[len];
	for(int i=0;i<=9;i++)
		tmpans/=fact[c[i]];
	ans+=tmpans;
}

void calc(){
	int i;
	for(i=1;i<=len;i++){
		for(int j=0;j<a[i];j++){
			if(c[j]!=0){
				c[j]--;
				calc2(len-i);
				c[j]++;
			}
		}
		if(c[a[i]]!=0)
			c[a[i]]--;
		else break;
	}
	for(i=i-1;i>=1;i--)c[a[i]]++;
}


void dfs(int now,int lim,int sum,ll prod){
	if(now==10){
		if(lim==0 && sum==0){
			if(prod==nprod)calc();
			else calc2(len);
		}
		return;
	}
	for(int i=0;i<=lim && now*i<=sum && prod<=nprod;i++,prod*=now+1){
		c[now]=i;
		dfs(now+1,lim-i,sum-now*i,prod);
	}
}

int main(){
	char ch[20];
	scanf("%s",ch+1);
	len=strlen(ch+1);
	for(int i=1;i<=len;i++)
		a[i]=ch[i]-'0';
	int sum=0;
	nprod=1;
	for(int i=1;i<=len;i++){
		sum+=a[i];
		nprod*=a[i]+1;
	}
	fact[0]=1;
	for(int i=1;i<=14;i++)
		fact[i]=fact[i-1]*i;

	ans=0;
	//calc
	ms(f,0);f[0][0]=1;
	for(int i=1;i<=len;i++)
		for(int nu=0;nu<=9;nu++)
			for(int k=nu;k<=sum;k++)
				f[i][k]+=f[i-1][k-nu];
	for(int i=0;i<sum;i++)
		ans+=f[len][i];
	
	dfs(0,len,sum,1);

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

Measured memory_bytes: 1200
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, s.size() - 2)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
	cout << ans << endl;
}


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

public class Main{

	static int MOD=(int)1e9+7;
	static PrintWriter out=new PrintWriter(System.out);;
	static int [][][]memo;
	static int []x;
	static int D;
	
	static int dp(int idx,int mod,int equal) {
		if(idx==x.length)
			return mod>0?0:1;
		if(memo[equal][mod][idx]!=-1)
			return memo[equal][mod][idx];
		int up=equal==1?x[idx]:9;
		int ans=0;
		for(int d=0;d<=up;d++) {
			int newEqual=equal==0?0:d<up?0:1;
			ans=ans+dp(idx+1,(mod+d)%D,newEqual);
			if(ans>=MOD)
				ans-=MOD;
		}
		return memo[equal][mod][idx]=ans;
	}
	
		
		
	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		
		char []tmp=sc.next().toCharArray();
		x=new int [tmp.length];
		for(int i=0;i<x.length;i++)
			x[i]=tmp[i]-'0';
		D=sc.nextInt();
		memo=new int [2][D][x.length];
		for(int [][]a2:memo)
			for(int []a:a2)
				Arrays.fill(a, -1);
		int ans=dp(0, 0, 1)-1;
		if(ans<0)
			ans+=MOD;
		out.println(ans);
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

int digit_sum(int n)
{
  int res = 0;
  while (0 < n)
  {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main()
{
  int N;
  cin >> N;
  int ans = INT32_MAX;
  for (int i = 1; i <= N / 2; i++)
  {
    int tmp = digit_sum(i) + digit_sum(N - i);
    if (tmp < ans)
      ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int N;
cin>>N;
vector<long>a;
  for(int i=0;i<3*N;i++){
    int x;
    cin>>x;
  a.push_back(x);}
  sort(a.begin(),a.end());
  long res=0;
  for(int i=3*N-2;i>=N;i=i-2){
  res+=a[i];}
  cout<<res;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ld long double
#define MOD 1000000007
#define N 1000006
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
// int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; }

#define int long long int

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n ;i++){
        if(i%3==0 || i%5==0) continue;
        ans += i;
    }
    cout<<ans<<"\n";
}

signed main(){
    fastio
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

int main() {
	int N; cin >> N;
	string s[110000];
	long long a[5];
	for (int i = 0; i < 5; i++) {
		a[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		if (s[i][0] == 'M')a[0]++;
		else if (s[i][0] == 'A')a[1]++;
		else if (s[i][0] == 'R')a[2]++;
		else if (s[i][0] == 'C')a[3]++;
		else if (s[i][0] == 'H')a[4]++;
	}
	long long ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector <string> vs;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef vector< vpii > vvpii;
typedef vector< vpll > vvpll;
#define all(v)     (v).begin(), (v).end()
#define srt(v)    sort (all (v))
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0,c=0;
	for(auto x:s){
		if(x=='R')r++;
	}
	for(int i=0;i<r;i++){
		if(s[i]=='W')c++;
	}
	cout<<c<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const int INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int D,G;
	cin >> D >> G;
	vector<int> p(D),c(D);
	for(int i = 0; i < D; i++){
		cin >> p[i] >> c[i];
	}
	int ans = INF;
	for(int bit = 0; bit < (1<<D); bit++){
		int GG = G;
		int res = 0,point=0;
		for(int i = 0; i < D; i++){
			if(bit&(1<<i)){
				res += p[i];
				point += c[i] + p[i]*100*(i+1);
			}
		}

		// if(G-point<0)continue;
		GG -= point;
		//cout << point << endl;
		for(int i = D-1; i >= 0; i--){
			if(!(bit&(1<<i))){
				for(int j = 0; j < p[i]-1; j++){
					// cout << GG << endl;
					if(GG<=0){
						ans = min(ans,res);
						//cout << ans << endl;
						continue;
					}
					GG -= 100*(i+1);
					res++;
				}
			}
		}

		if(GG<=0){
			ans = min(ans,res);
			//cout << ans << endl;
			continue;
		}
		// cout << GG << endl;
		// cout << res << endl;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main () {
    int n; cin >> n;
    int sum = 0;
    vector<int> delicious;

    for (int i = 0; i < n; i++) {
        int d; cin >> d;
        delicious.push_back(d);
    }


    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += delicious[i] * delicious[j];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
  
    int n;
    cin>>n;
    if(n==1){cout<<1<<endl;return 0;}
    int anm=0;
    int ans=0;
    for(int i=2;i<=n;i++){
        int suu=i;
        ll anss=0;
        while(suu>=1&&suu%2==0){
            suu/=2;
            anss++;
        }
        if(anm<anss){
            anm=anss;
            ans=i;
        }
    }
    
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int gcd(int x, int y){
  if(y == 0){
    return x;
  }
  if(x < y)swap(x,y);
  int z;
  z = x%y;
  x = y;
  y = z;
  return gcd(x,y);
}

int gcd3(int a, int b, int c){
  int x,y;
  x = gcd(a,b);
  y = gcd(x,c);
  return y;
}

ll ans = 0;

int main(){
  int K;
  cin >> K;
  for(int i = 1;i <= K;i++){
    for(int j = 1;j <= K;j++){
      for(int k = 1;k <= K;k++){
        ans += gcd3(i,j,k);
      }
    }
  }

  cout << ans << endl;

 }


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int n,m;
vi man;
vii hako;
int memo[10005][505];
int f(int mj=0,int ha=0){
    if(memo[mj][ha]>-1)return memo[mj][ha];
    if(mj>=m||ha>=n){
        if(mj!=0)return memo[mj][ha]=man[mj-1];
        return memo[mj][ha]=0;
    }else{
        int ans=0;
        int you=hako[ha].second;
        int cost=hako[ha].first;
        int mcos=0;
        you=min(m-mj,you);
        //if(mj==0){
          //  mcos=man[you];
            //you=min(m,you);
        //}else {
          //  mcos=man[mj+you-1]-man[mj-1];
        //}
        //if(cost<mcos){
            ans=f(mj+you,ha+1)-cost;
        //}
        //cout << mj << " ha " << you <<" m " << mcos << " cost " << cost << endl;
        //if((man[m-1]-man[mj+you])<cost)return ans;
        return memo[mj][ha]=ans=max(f(mj,ha+1),ans);
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> m >> n;
    rep(i,0,10005){
        rep(j,0,505){
            memo[i][j]=-1;
        }
    }
    rep(i,0,m){
        int x;cin >> x;
        man.pb(x);
    }
    rep(i,0,n){
        int x,y;cin >> x >> y;
        hako.pb(mp(y,x));
    }
    sort(ALL(man),greater<int>());
    sort(ALL(hako));
    rep(i,0,m-1){
        man[i+1]+=man[i];
     //   cout << i << " " << man[i] << endl;
    }
    cout << f() << endl;
    return 0;
}

Measured memory_bytes: 42828
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    print(N**3)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21404