akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

long long res[3000][3000];


long long min(long long a, long long b){
	if(a > b) return b;
	return a;
}

long long max(long long a, long long b){
	if(a < b) return b;
	return a;
}

int main(){
	vector<long long> vec;
	int n;
	cin>>n;
	for(int i =0; i<n; i++){
		int a;
		cin>>a;
		vec.push_back(a);
	}
	
	
	for(int i = n-1; i>=0; i--){
		for(int j = i; j<n; j++){
			if(i == j){
				res[i][j] = vec[i];
			}else{
				long long win = max(vec[j] - res[i][j-1], vec[i] - res[i+1][j]);
				res[i][j] = win;
			}
		}
	}
	
	cout<<res[0][n-1];
	
}


Measured memory_bytes: 70016
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut dp: Vec<u64> = vec![0; k + 1];
    dp[0] = 1;
    let p = 1000000007;
    for x in a {
        let mut sum = 0;
        for i in ((k - x + 1)..(k + 1)).rev() {
            sum += dp[i];
        }
        for i in (0..(k + 1)).rev() {
            if i >= x {
                sum += dp[i - x];
            }
            let v = sum % p;
            sum -= dp[i];
            dp[i] = v;
        }
    }
    println! ("{}", dp[k]);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    cout<<(n-1+k-2)/(k-1)<<endl;

	return 0; 
}

Measured memory_bytes: 768
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: Int -> [Int] -> Int
solve n l = iter (-10^9) (-10^9, 10^9) (n-1) (reverse l) where
    iter _ (ms, mb) _ [] = ms - mb
    iter mr (ms, mb) i (x:xs) = iter (max mr x) next (i-1) xs where
        next | mr - x > ms - mb = (mr, x)
             | otherwise = (ms, mb)

main :: IO() 
main = do
    n <- readLn
    l <- replicateM n readLn :: IO [Int]
    print (solve n l)



Measured memory_bytes: 125008
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> query;
typedef vector<vector<ll>> matrix;

int n;
int lhs[100005];
int rhs[100005];
void solve() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> lhs[i] >> rhs[i];
  }
  sort(lhs, lhs+n+1);
  sort(rhs, rhs+n+1);
  ll ret = 0;
  ll curr = 0;
  for(int i = 0; i <= n; i++) {
    curr += lhs[n-i];
    curr -= rhs[i];
    ret = max(ret, curr);
  }
  cout << 2*ret << "\n";
}

void casesolve() {
  int t;
  cin >> t; cin.ignore();
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ab = b - a
ac = c - a
ad = d - a
ae = e - a
bc = c - b
bd = d - b
be = e - b
cd = d - c
ce = e - c
de = e - d

if ab <= k and ac <= k and ad <= k and ae <= k and bc <= k and bd <= k and be <= k and cd <= k and ce <= k and de <= k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define _GLIBCXX_DEBUG
// head

int main(){
    int n,m;
    cin >> n>>m;
    int x = (1900*m+100*(n-m))*pow(2,m);
    cout << x << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007

int i,j,k;

struct edge {
    int to;
    int cost;
};

typedef long long ll;
using namespace std;
using P = pair<int, int>;

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    int h,w;
    cin >> h >> w;
    vector<string> s;
    for(i=0;i<h;i++){
        string ss;
        cin >> ss;
        s.push_back(ss);
    }
    int y[h+10][w+10];
    int t[h+10][w+10];
    
    int ans=0;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            y[i][j]=0;
            t[i][j]=0;
        }
        
    }
    for(i=0;i<h;i++){
        int su=0;
        int prev=0;
        for(j=0;j<w;j++){
            if(s[i][j]=='.'){
                su++;
                y[i][j]=su;
            }else{
                su=0;
                y[i][j]=0;
            }
        }
        su=y[i][w-1];
        for(j=w-1;j>=0;j--){
            if(y[i][j]){
                if(prev==0){
                    prev=y[i][j];
                }
                y[i][j]=prev;
            }
            prev=y[i][j];
        }
    }
    for(j=0;j<w;j++){
        int su=0;
        int prev=0;
        for(i=0;i<h;i++){
            if(s[i][j]=='.'){
                su++;
                t[i][j]=su;
            }else{
                su=0;
                t[i][j]=0;
            }
        }
        su=y[h-1][j];
        for(i=h-1;i>=0;i--){
            if(y[i][j]){
                if(prev==0){
                    prev=t[i][j];
                }
                t[i][j]=prev;
            }
            prev=t[i][j];
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(ans<y[i][j]+t[i][j]-1){
                ans=y[i][j]+t[i][j]-1;
            }
        }
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35840
#include<algorithm>
#include<iostream>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define repd(i,a) for(int i=(a);i>=0;--i)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_X = 1000, MAX_Y = 1000;

int q;
std::string X, Y;
int dp[MAX_X+1][MAX_Y+1];

int main()
{
    std::cin >> q;
    while( q-- )
    {
        std::cin >> X >> Y;

        clr( dp, 0 );

        repd( i, X.size()-1 ) repd( j, Y.size()-1 )
        {
            if( X[i] == Y[j] )
                dp[i][j] = dp[i+1][j+1]+1;
            else
                dp[i][j] = std::max( dp[i+1][j], dp[i][j+1] );
        }

        printf( "%d\n", dp[0][0] );
    }

    return 0;
}

Measured memory_bytes: 7240
#include <iostream>
#include <algorithm>
using namespace std;
int c[3][3];
int main(){
	for(int i=0;i<3;++i){
		int mn=110;
		for(int j=0;j<3;++j){
			cin>>c[i][j];
			mn=min(mn,c[i][j]);
		}
		for(int j=0;j<3;++j){
			c[i][j]-=mn;
		}
	}
/*
	for(int i=0;i<3;++i){
		for(int j=0;j<3;++j){
			cout<<c[i][j]<<" ";
		}
		cout<<endl;
	}
	**/
	for(int i=0;i<3;++i){
		if(c[0][i]!=c[1][i] || c[1][i]!=c[2][i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

map<ll, ll> prime_factorization(ll x){
	map<ll, ll> mp;
    bool flag = true;
    while(flag){
        ll sqx = sqrt(x)+1;
        for(ll j=2;j<sqx+1;j++){
            if(x%j==0){
                mp[j]++;
                x/=j;
                break;
            }
            if(j==sqx) flag = false;
        }
    }
    if(x!=1){
        mp[x]++;
    }
    return mp;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll powLL(ll a, ll n, ll m){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= m;
        }
        a = a*a;
        a %= m;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    map<ll, ll> tot;
    REP(i, N){
    	auto mp = prime_factorization(A[i]);
    	for(auto x: mp){
    		ll val = x.first;
    		ll cnt = x.second;
    		if(tot.find(val) == tot.end()){
    			tot[val] = cnt;
    		}else{
    			tot[val] = max(tot[val], cnt);
    		}
    	}
    }

    ll l = 1;
    for(auto x: tot){
    	l *= powLL(x.first, x.second, mod);
    	l %= mod;
    }

    //dump(l)

    
    ll res = 0;
    REP(i, N){
    	res += (l * modinv(A[i], mod))%mod;
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
int main(){ 
    long long n, d, x, a, cal = 0;
    cin >> n >> d >> x;
    for (int i = 0; i<n; i++){
    	cin >> a;
    	cal++;
    	cal+=(d-1)/a;
	}
	cout << cal+x;
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	string s;
	cin >> s;
	int first = 0, last;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			first = i;
			break;
		}
	}

	for (int i = s.size(); i > first; i--) {
		if (s[i] == 'Z') {
			last = i;
			break;
		}
	}


	cout << last - first + 1 << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> ds(N);
  for (int i = 0; i < N; i++) {
    cin >> ds.at(i);
  }
  
  sort(ds.begin(), ds.end());
  
  int num = 1;
  int prev = ds.at(0);
  for (int i = 1; i < N; i++) {
    if (prev != ds.at(i)) {
      num++;
      prev = ds.at(i);
    }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
//
// Created by yozaam on 12/06/20.
//

//
// Created by yozaam on 04/06/20.
//



/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, x,t,i;
//=======================

void solve() {
    cin>>n>>x>>t;

    int ans = 0 ;

    ans += (n)/x;

    if(n%x)ans+=1;

    cout<<ans*t;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

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

    return 0;
}

Measured memory_bytes: 50000
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
// isBipartite ? =======================================================
vector<vector<int>> g;
vector<int> color;
bool isBipartite_proc(int, int);
bool isBipartite() {
  color.resize(g.size(), 0);
  rep(i, 0, g.size()) {
    if (color[i] == 0) {
      if (!isBipartite_proc(i, 1))
        return false;
    }
  }
  return true;
}
bool isBipartite_proc(int v, int c) {
  color[v] = c;
  for (auto u : g[v]) {
    if (color[u] == c)
      return false;
    if (color[u] == 0 and !isBipartite_proc(u, -c))
      return false;
  }
  return true;
}
//======================================================================

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  g.resize(N);
  loop(M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  if (isBipartite()) {
    int b = 0;
    for (auto c : color)
      b += (c == 1);
    int w = N - b;
    cout << b * w - M << endl;

  } else {
    cout << N * (N - 1) / 2 - M << endl;
  }

  return 0;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(0);
  ll x;
  cin >> x;
  ll k = 100;
  int cnt = 0;
  while(k < x)
  {
    k = k + k*0.01;
    // cout << k << endl;


    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int x=cin.nextInt();
        int y = cin.nextInt();
      int ans=0;
        if(x==1&&y==1)ans=1000000;
        else
        {
          if(x==1)ans+=300000;
          else if(x==2)ans+=200000;
          else if(x==3)ans+=100000;
          if(y==1)ans+=300000;
          else if(y==2)ans+=200000;
          else if(y==3)ans+=100000;

        }Console.WriteLine(ans);

        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, x, t, p;
	cin >> n >> x >> t;
	if (n % x)
		p = n / x + 1;
	else
		p = n / x;
	cout << p*t << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  vector<ll> c(n), d(n + 1, 0), e(n + 1), f(n + 1, 0);
  rep(i, n){
    in(c[i]);
    a = c[i];
    d[a]++;
  }
  b = 0;
  rep(i, n + 1){
    e[i] = d[i] * (d[i] - 1) / 2;
    if(d[i] > 0)
      f[i] = (d[i] - 1) * (d[i] - 2) / 2;
    b += e[i];
  }
  rep(i, n){
    a = c[i];
    out(b - e[a] + f[a]);
    memi;
  }
}

Measured memory_bytes: 8832
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var n = consoleReader.Int;
            var p = consoleReader.Split.Int;
            var count = 0;
            for (int i = 1; i < n - 1; i++)
            {
                if ((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1]))
                    count++;
            }
            return count;
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 13396
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

ruiseki = [0 for _ in range(N+5)]
for i in range(N):
    ruiseki[i+1] = ruiseki[i] + A[i]

ans = 0
for i in range(N):
    ans += A[i] * (ruiseki[N] - ruiseki[i+1])
    ans %= mod

print(ans)

Measured memory_bytes: 31416
x = int(input())

max_num = 0
for i in range(x):
	if x == 1:
		max_num = 1
		break
	j = 1

	while (i+2) ** j <= x:
		if max_num < (i+2) ** j:
			max_num = (i+2) ** j
		j += 1
	if j == 2:
		break
print(max_num)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  ll a, b, c, d; cin >> a >> b >> c >> d;
  cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e5 + 5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200)cout << s;
    else cout << "red";
}


Measured memory_bytes: 892
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for(int i = 0; i < n - 1; i++) {
            a[i] = sc.nextInt();
            sc.nextInt();
        }
        a[n - 1] = sc.nextInt();
        a[n] = sc.nextInt();

        int[][] dp = new int[n][n + 1]; //i番目から(j - 1)番目まで

        // compute
        for(int i = 2; i <= n; i++) {
            for(int j = 0; j <= n - i; j++) {// j番目から(j + i - 1)番目まで
                dp[j][j + i] = Integer.MAX_VALUE;
                for(int k = j + 1; k < j + i; k++) {
                    int tmp = dp[j][k] + dp[k][j + i] + a[j] * a[k] * a[j + i];
                    dp[j][j + i] = Math.min(dp[j][j + i], tmp);
                }
            }
        }

        System.out.println(dp[0][n]);

        sc.close();
    }
}



Measured memory_bytes: 26668
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(a, b, c, d):
	return max([a*c, a*d, b*c, b*d])

a, b, c, d = list(map(int, input().split()))
print(solve(a, b, c, d))

Measured memory_bytes: 62280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		//while (true) {
		int sum = 0;//初期化
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {//
			sum = 0;
			String sr = br.readLine();//文字列入力
			if (sr.equals("0")) {
				break;
			}
			for (int i = 0; i < sr.length(); ++i) {//桁数分の繰り返し
				char ch = sr.charAt(i);//桁ごとに数字を抜き出し

				sum += Character.getNumericValue(ch);//抜き出した数字を順番に加算

			}
			System.out.println(sum);
		}

	}

}



Measured memory_bytes: 24244
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,A,B = inpl()

ans = 0
for i in range(1,N+1):
	S = sum(map(int,list(str(i))))
	if A <= S <= B:
		ans += i
print(ans)


Measured memory_bytes: 4208
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int a, b;
		Map<Integer, HashSet<Integer>> mp = new HashMap<>();
		for (int i = 0; i < m; i++) {
			a = in.nextInt();
			b = in.nextInt();
			HashSet<Integer> s1 = null, s2 = null;
			if (mp.get(a) != null) {
				s1 = mp.get(a);
			}
			if (mp.get(b) != null) {
				s2 = mp.get(b);
			}
			if (mp.get(a) == null) {
				s1 = new HashSet<Integer>();
			}
			if (mp.get(b) == null) {
				s2 = new HashSet<Integer>();
			}
			s1.add(b);
			s2.add(a);
			mp.put(a, s1);
			mp.put(b, s2);
		}
		for (Integer x : mp.get(1)) {
			if (mp.get(x).contains(n)) {
				System.out.println("POSSIBLE");
				System.exit(0);
			}
		}
		System.out.println("IMPOSSIBLE");

		in.close();
	}
}


Measured memory_bytes: 230856
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n+1); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   string s;
   cin>>s;
   int ans=0;
   vi acgt;
   //cout<<s.size();
   rep(i,s.size()){
       if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='G'||s.at(i)=='C'){
 
       }else{
           acgt.push_back(i);
       }
   }
   if(acgt.size()==0)cout<<s.size();
   else{
        ans=acgt.at(0);
   //rep(i,acgt.size())cout<<acgt.at(i);
   rep(i,acgt.size()-1){
       ans=max(ans,acgt.at(i+1)-acgt.at(i)-1);
   }
   //cout<<acgt.back()<<endl;
   int k=s.size()-acgt.back()-1;
   ans=max(ans,k);
   cout<<ans<<endl;
   }
  
}

   
    

   


    

   



Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(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

using namespace std;

typedef long long ll;
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;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

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

const int N = 2e6 + 2;
ll fact[N+1], finv[N+1], inv[N+1];

void comb_init() {
    // init
    REP(i, 2) {
        fact[i] = 1;
        finv[i] = 1;
        inv[i] = 1;
    }

    FOR(i, 2, N+1) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;

    return (fact[n] * finv[k] % MOD) * finv[n-k] % MOD;
}


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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    comb_init();

//    ll ans = 0;
//    FOR(i, r1, r2+1) {
//        ans = ((ans + comb(i+c2+1, i+1)) %MOD + MOD - comb(i+c1, i+1)) % MOD;
//    }
//    cout << ans % MOD << endl;

    ll ans = (comb(r2+c2+2, c2+1) + MOD - comb(r1+c2+1, c2+1)) % MOD;
    ans = (ans + MOD - comb(r2+c1+1, c1) + comb(r1+c1, c1)) % MOD;

    cout <<  ans << endl;

}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    vector<bool> front(N, false), back(N, false);

    REP(i, M)
    {
        int a, b; cin >> a >> b;

        a--;
        b--;

        if( a == 0 ) front[b] = true;
        if( b == N - 1 ) back[a] = true;
    }

    bool found = false;
    REP(i, N)
    {
        found |= front[i] && back[i];
    }

    cout << (found ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

void solve() {
    LL n;
    cin >> n;
    map<string, int> mp;
    while(n--) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

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

int main(){
    string str, temp, q, p;
    int cnt, a, b;

    cin >> str;
    cin >> cnt;

    for(int j = 0; j < cnt; j++){

        cin >> q >> a >> b;
        if(q == "print"){
            for(int i = a; i <= b; i++){
                cout << str[i];
            }
            cout << endl;

        }else if(q == "reverse"){
            for(int i = a; i <= b; i++){
                temp[i] = str[i];
            }
            for(int i = a; i <= b; i++){
                str[i] = temp[b-(i-a)];
            }
        }else if(q == "replace"){
            cin >> p;
            for(int i = a; i <= b; i++){
                str[i] = p[i-a];
            }
        }
    }
}




Measured memory_bytes: 3180
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            if(a >= 13){
                Console.WriteLine(b);
            }else if(a >= 6 && a <= 12){
                Console.WriteLine(b / 2);
            }else{
                Console.WriteLine(0);
            }
        }
    }
}


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

int main() {
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  
  sort(a,a+3,greater<int>());
  
  int ans=10*a[0]+a[1]+a[2];
  
  cout<<ans<<endl;
  
}


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int lower = max(a, c);
	int upper = min(b, d);

	cout << max(0, upper - lower) << endl;

	return 0;
}

Measured memory_bytes: 256
module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Array
import           Data.Char
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

parseInt = fst . fromJust . BS.readInt
readInt = parseInt <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine

main = do
  n <- readInt
  arr <- readIntList
  let ans = foldl (\acc val -> if val == acc + 1 then acc + 1 else acc) 0 arr
  print $ if ans == 0 then -1 else n - ans


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

int main()
{
  string d;
  string tar="AIDUNYAN";
  sort(tar.begin(),tar.end());
  cin>>d;
  //  cout<<(int)d.size()-(int)tar.size()<<endl;
  for(int i=0;i<(int)d.size()-(int)tar.size()+1;i++)
    {
      string tmp=d.substr(i,tar.size());
      sort(tmp.begin(),tmp.end());

      //     cout<<tar<<endl;
      //cout<<tmp<<endl;
      if(tmp==tar)
	{
	  d.replace(i,tar.size(),"AIZUNYAN");
	  i+=tar.size()-1;
	}
    }
  cout<<d<<endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
const int MOD = 1e9+7;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	ll sum = 0;
	cin >> n;
	for(int i =1;i<=n;i++){
		cin >> x;
		sum += x;
		v.push_back(x);
	}
	int ans = 0;
	for(int i =0;i<n;i++){
		sum-=v[i];
		ans = (ans+((sum%MOD)*v[i])%MOD)%MOD;  
	}
	cout << ans;
 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  string ans = "Yay!";
  if ( max(max(max(max(a, b), c), d), e) 
      - min(min(min(min(a, b), c), d), e) > k) ans = ":(";
  
  cout << ans << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    LL s = 1;
    for(int i = 2; i <= n; ++i) {
        s *= i;
        s %= MOD;

    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int a[101][101], b[101], c[101];
	int i, j, n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}



Measured memory_bytes: 2112
N = int(input())
TS = []
for i in range(N):
    X, L = map(int, input().split())
#    TS.append((X + L, X - L))
    TS.append([X,L])

mlist=[]
for i in range(N):
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

cur = -10**10
ans = 0
for i in range(N):
    if mlist[i][1] >= cur:
        ans+=1
        cur = mlist[i][0]
print(ans)

Measured memory_bytes: 36652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
long long X;



unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main()
{

	cin >> X;


	long long i=1;
	long long ans = 1;
	while(i < X/i){
		i++;
		if(X%i != 0)
			continue;
		ans = i;
	}
	cout << max(GetDigit(ans),GetDigit(X/ans));


}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

constexpr int max_n = 200'000 + 5;

int n;
vector<int> cs(max_n);
vector<vector<int>> adjs(max_n);
vector<ll> res(max_n);
int et_size;
vector<int> sums(max_n); // sums[c] = 色cの現在の累積和

void dfs(int cur = 1, int par = 0) {
    int &par_color = cs[par], &cur_color = cs[cur];
    int in_i = et_size;
    int memo = sums[par_color];
    et_size++;
    for (auto ch : adjs[cur]) {
        if (ch == par) { continue; }
        dfs(ch, cur);
    }
    int out_i = et_size;
    et_size++;

    sums[cur_color]++;
    int tree_size = (out_i - in_i + 1) / 2;
    ll component_size = tree_size - (sums[par_color] - memo);
    res[par_color] += component_size * (component_size + 1) / 2;
    sums[par_color] += component_size; // = tree_size + memo
}

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin >> n;
    rep(i, n) {
        int c; cin >> c;
        cs[i+1] = c;
    }
    rep(i, n-1) {
        int a,b; cin >> a >> b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    dfs();

    rep(i, n) {
        int tree_size = et_size / 2;
        ll component_size = tree_size - sums[i + 1];
        res[i + 1] += component_size * (component_size + 1) / 2;

        res[i + 1] = (ll)n * (n + 1) / 2 - res[i + 1];
        cout << res[i + 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 32908
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

data=[0 for i in range(0,60)]

for i in range(0,N):
    for j in range(0,60):
        data[j]+=(A[i]>>j &1)

ans=0
for i in range(0,60):
    ans=(ans+pow(2,i,mod)*data[i]*(N-data[i]))%mod

print(ans)

Measured memory_bytes: 122808
#include <cstdio>
//#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
//#include <algorithm>

using namespace std;

int main(){
    int n, max = 0, tmp = 0;
    string s;

    cin >> n >> s;

    vector<int> f1(26, 0), f2(26, 0);
    string s1, s2;

    for(int i = 1; i < n; i++){
        s1 = s.substr(0, i);
        s2 = s.substr(i, n - i);

        for(int i = 0; i < s1.size(); i++) f1[s1[i] - 'a'] = 1;
        for(int i = 0; i < s2.size(); i++) f2[s2[i] - 'a'] = 1;

        for(int i = 0; i < 26; i++){
            if(f1[i] == 1 && f2[i] == 1) tmp++;
            f1[i] = 0; f2[i] = 0;
        }

        if(tmp > max) max = tmp;
        tmp = 0;
    }

    printf("%d\n", max);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int S = 0;
  for (int i = 0; i < N; ++i) S += A[i];
  vector<int> X(N);
  X[0] = S;
  for (int i = 1; i < N; i = i + 2) X[0] -= 2 * A[i];
  for (int i = 1; i < N; ++i) X[i] = (A[i - 1] - X[i - 1] / 2) * 2;
  
  for (int i = 0; i < N; ++i) {
    cout << X[i];
    if (i < N - 1) cout << " ";
  }
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll X, t;
  std::cin >> X >> t;

  ll ans = std::max(0LL, X - t);
  print(ans);

  return 0;
}


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


#define ll long long int

using namespace std;

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int result = 0;
  for (int i = 0; i < a + 1; i++) {
    int y = x;
    y = y - 500*i;
    for (int j = 0; j < b + 1; j++) {
      int z = y;
      z = z - 100*j;
      for (int k = 0; k < c + 1; k++) {
        int w = z;
        w = w - 50*k;
        if (w == 0) {
          result++;
        }
      }
    }
  }

  cout << result << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 26360
N = int(input())
S = input()

Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
d = 0
k = ""

for i in range(len(S)):
    d = N + int(Alpha.find(S[i]))

    while(d >= len(Alpha)):
        d = d - len(Alpha)

    k = k + Alpha[d]

print(k)

Measured memory_bytes: 3060