akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

enum lim = 80 * 80 * 2;

void main() {
    int H, W;
    scan(H, W);
    auto a = iota(H).map!(i => readln.split.to!(int[])).array;
    auto b = iota(H).map!(i => readln.split.to!(int[])).array;

    auto c = new int[][](H, W);
    foreach (i ; 0 .. H) {
        foreach (j ; 0 .. W) {
            c[i][j] = abs(a[i][j] - b[i][j]);
        }
    }

    auto dp = new bool[][][](H, W, lim);
    dp[0][0][c[0][0]] = true;

    foreach (i ; 0 .. H) {
        foreach (j ; 0 .. W) {
            if (i - 1 >= 0) {
                foreach (k ; 0 .. lim) if (dp[i - 1][j][k]) {
                    dp[i][j][abs(k - c[i][j])] = true;
                    dp[i][j][abs(k + c[i][j])] = true;
                }
            }
            if (j - 1 >= 0) {
                foreach (k ; 0 .. lim) if (dp[i][j - 1][k]) {
                    dp[i][j][abs(k - c[i][j])] = true;
                    dp[i][j][abs(k + c[i][j])] = true;
                }
            }
        }
    }

    int ans = -1;

    foreach (k ; 0 .. lim) {
        if (dp[H - 1][W - 1][k]) {
            ans = k;
            break;
        }
    }
    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 105596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vi c(26);
    rep(i, 26) cin >> c[i];
    vvi s(D, vi(26));
    rep(i, D) rep(j, 26) {
        cin >> s[i][j];
    }

    vi t(D);
    rep(i, D) {
        t[i] = i%26;
    }
    vi last(26);
    vector<set<int> > se(26);
    rep(i, 26) {
        se[i].insert(D);
    }
    ll gh = 0;
    rep(d, D) {
        se[t[d]].insert(d);
        gh += s[d][t[d]];
        last[t[d]] = d+1;
        rep(j, 26) {
            gh -= c[j]*(d+1-last[j]);
        }
    }

    vvi bits(26, vi(D+1));
    auto add = [&](int al, int d, int x) {
        while(d <= D) {
            bits[al][d] += x;
            d += d&-d;
        }
    };
    auto sum = [&](int al, int d) {
        if(d == 0) return 0;
        int res = 0;
        while(d) {
            res += bits[al][d];
            d &= d-1;
        }
        return res;
    };


    rep(i, D) {
        rep(j, 26) {
            add(j, i+1, 1);
        }
    }

    rep(i, D) {
        int now = sum(t[i], i+1);
        add(t[i], i+1, -now);
    }

    int X = 100000;
    while(X--) {
        int nowd = s[rand()%D][rand()%26]%D;
        int nowal = s[rand()%D][rand()%26]%26;
        if(t[nowd] == nowal) continue;
        ll nowgh = gh;
        nowgh += s[nowd][nowal]-s[nowd][t[nowd]];
        auto itr = se[nowal].lower_bound(nowd);
        nowgh += (*itr - nowd)*sum(nowal, nowd+1) * c[nowd];
        itr = se[t[nowd]].upper_bound(nowd);
        nowgh -= (*itr-nowd)*(sum(t[nowd], nowd)+1) * c[t[nowd]];
        if(nowgh > gh) {
            add(t[nowd], nowd+1, sum(t[nowd], nowd)+1);
            add(nowal, nowd+1, -sum(nowal, nowd+1));
            se[t[nowd]].erase(nowd);
            se[nowal].insert(nowd);
            t[nowd] = nowal;
            gh = nowgh;
        }
    }

    rep(i, D) {
        cout << t[i]+1 << endl;
    }
}

Measured memory_bytes: 3784
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    
	    long N = nextLong();
	    long A = nextLong();
	    long B = nextLong();
	    
	    long ANS= N/(A+B) * A;

	    if((N - (A+B)*(N/(A+B))) > A) {
	        out.println(ANS + A);
	    } else{
	        out.println(ANS + (N - (A+B)*(N/(A+B))));
	    }


	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 22228
import sys
input = sys.stdin.readline

def main():
    S = input().strip()
    l = []
    count = [0] * len(S)
    for i in range(len(S)-1, -1, -1):
        if S[i] == "L":
            l.append(i)
        else:
            if (l[-1] - i)&1 == 0:
                count[l[-1]] += 1
            else:
                count[l[-1]-1] += 1
    r = []
    for i in range(len(S)):
        if S[i] == "R":
            r.append(i)
        else:
            if (i - r[-1])&1 == 0:
                count[r[-1]] += 1
            else:
                count[r[-1]+1] += 1
    
    for i in range(len(S)-1):
        print(count[i],end=" ")
    print(count[-1])

    

if __name__ == "__main__":
    main()
            

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<power(10, 9) + 7>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? fact[i - 1] * i : 1;
  inv_fact[n] = power(fact[n], mint::mod - 2);
  for (int i = n; i--; ) inv_fact[i] = (i + 1) * inv_fact[i + 1];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template <> mint& mint::operator/=(mint b) {
  return *this *= b.v < minv.size() ? minv[b.v] : power(b, mod - 2);
}

vector<mint> f(int n) {
  vector<mint> res(n);
  res[0] = 1;
  for (int x = 1; x < n; ++x) {
    for (int i = 0; i < n - x; ++i) {
      int a = n - i - 1, b = x - 1;
      res[x] += binom(a + b, a) - binom(a + b, a + 1);
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  prepare(2 * n);
  if (k == 1) {
    cout << power<mint>(2, max(n - 2, 0)).v << '\n';
    exit(0);
  }
  auto a = f(k - 1);
  mint res;
  for (int x = 0; x < k - 1; ++x) {
    res += binom(n - 1 - x, k - 1 - x) * a[x];
  }
  res *= power<mint>(2, max(n - k - 1, 0));
  cout << res.v << '\n';
}


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

int main(){
    bool flag = true;
    int n; cin >> n;
    for( int i = 0; i < n; i++ ){
        int a;
        cin >> a;
        if( a%2 == 0 &&(a%3 > 0 && a%5 > 0) ){
            flag = false;
        }
    }
    if( flag ){
        cout << "APPROVED\n";
    }else{
        cout << "DENIED\n";
    }
}


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

int main() {
    int n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++) cin >> s[i];
    long long m=0,a=0,r=0,c=0,h=0;
    for(int i=0;i<n;i++){
        if(s[i].at(0) == 'M') m++;
        if(s[i].at(0) == 'A') a++;
        if(s[i].at(0) == 'R') r++;
        if(s[i].at(0) == 'C') c++;
        if(s[i].at(0) == 'H') h++;
    }
    long long ans=m*a*(r+c+h)+(m+a)*r*(c+h)+(m+a+r)*c*h;
    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Integer[] ary = new Integer[10];
		Scanner sc = new Scanner(System.in);
		
		for(int i = 0; i < ary.length; ++i){
			ary[i] = sc.nextInt();
		}
		
		Arrays.sort( ary );
		
		System.out.println(ary[9]);
		System.out.println(ary[8]);
		System.out.println(ary[7]);
	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ll y = n / i;
		ans += y*(y+1)/2 *i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{   int  AT;
    char a,b,TO;
    while(cin>>a>>b)
    {if(a=='H') AT=1;
    else
        AT=0;

    if(b=='H')
    {
        if(AT==1) TO='H';
        else
            TO='D';
    }
    else
    {
        if(AT==1) TO='D';
        else
            TO='H';
    }

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


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

int main() {
  int n,ans=0;
  cin >> n;
  int a[n+1];
  a[0]=0;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    if(a[i]>a[i-1]) {
      ans+=a[i]-a[i-1];
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {

   long long int n;
   cin>>n;
   
   
   long long int tot=0;
   tot+=(n-2)*2;
   
   int c=0;
   long long int temp=1;
   while(1)
   {
       if((temp*temp)<n)
       {
           c++;
       }
       else
       {
           break;
       }
       temp++;
   }
   
   //cout<<tot<<endl;
   tot+=c;
   
 
   c=0;
   
   int f=0;
   for(int i=2;i<n;++i)
   {   
       long long int zz=i;
       zz*=(i+1);
       
       if(zz<n)
       {
       for(int j=i+1;j<n;++j)
       {
           long long int sample =i;
           sample*=j;
           
           if(sample<n)
           {
               c+=2;
           }
           else
           {
               break;
           }
       }
       }
       else
       {
           break;
       }
       
   }
   tot+=c;
   
   cout<<(tot)<<endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long[] params = new long[4];
        for (int i = 0; i < 4; i++) {
            params[i] = scanner.nextInt();
        }
        long a = params[0];
        long b = params[1];
        long c = params[2];
        long d = params[3];

        if (a >= 0) {
            if (c >= 0) {
                System.out.println(b * d);
            } else if (d >= 0) {
                System.out.println(b * d);
            } else {
                System.out.println(a * d);
            }
        } else if (b >= 0) {

            if (c >= 0) {
                System.out.println(b * d);
            } else if (d >= 0) {
                // a<0  b>=0   c<0  d>=0
                if (a * c  > b * d) {
                    System.out.println(a * c);
                } else {
                    System.out.println(b * d);
                }
            } else {
                System.out.println(a * c);
            }

        } else {

            if (c >= 0) {
                System.out.println(b * c);
            } else if (d >= 0) {
                System.out.println(a * c);
            } else {
                System.out.println(a * c);
            }

        }
    }
}

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

int main() {
  int n, r;
  while (cin >> n >> r, n || r) {
    vector<int> a;
    a.reserve(n);
    for (int i = 0; i < n; ++i) {
      a.emplace_back(n - i);
    }
    for (int i = 0; i < r; ++i) {
      int p, c;
      cin >> p >> c;
      vector<int> b;
      b.reserve(n);
      for (int j = p - 1; j < p - 1 + c; ++j) {
        b.emplace_back(a[j]);
      }
      for (int j = 0; j < n; ++j) {
        if (p - 1 <= j && j < p - 1 + c) continue;
        b.emplace_back(a[j]);
      }
      a = b;
    }
    cout << a[0] << endl;
  }
}

Measured memory_bytes: 3012
// reference: 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 mut 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")
    };
}

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        s: chars
    }

    let n = s.into_iter().collect::<String>().parse::<i64>().unwrap();
    let a = n / 100;
    let b = n % 100;

    let ans = if 1 <= a && a <= 12 && 1 <= b && b <= 12 {
        "AMBIGUOUS"
    } else if 0 <= a && a <= 99 && 1 <= b && b <= 12 {
        "YYMM"
    } else if 1 <= a && a <= 12 && 0 <= b && b <= 99 {
        "MMYY"
    } else {
        "NA"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
A,B,C=map(int,input().split())
K=int(input())

black_board=[A,B,C]
for i in range(K):
    max_index=black_board.index(max(black_board))
    black_board[max_index]*=2
sum=0
for i in range(len(black_board)):
    sum+=black_board[i]

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int A, B;
	cin >> A >> B;
	cout << max(0, A-2*B) << endl;
	
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

int f(int b, int n) {
  if (b > n) return n;
  return f(b, n / b) + n % b;
}

void solve() {
  int n, s;
  cin >> n >> s;
  if (n == s) {
    cout << n + 1 << '\n';
    return;
  }
  for (int i = 2; i * i <= n; i++) {
    if (f(i, n) == s) {
      cout << i << '\n';
      return;
    }
  }
  for (int i = sqrt(n - s); i >= 1; i--) {
    if ((n - s) % i == 0 && f((n - s) / i + 1, n) == s) {
      cout << (n - s) / i + 1 << '\n';
      return;
    }
  }
  cout << -1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  // ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,t,x,y,now=0,now_x=0,now_y=0;
    cin>>n;
    int flag=0;
    for (int i=0;i<n;i++) {
        cin>>t>>x>>y;
        int tmp=t-now;
        tmp-=x-now_x;
        if (tmp<0||(tmp==0&&y!=now_y)) {
            cout<<"No"<<endl;
            flag=1;
            break;
        } else {
            if (tmp>y-now_y) {
                if ( (tmp-(y-now_y))%2==1 ) {
                    cout<<"No"<<endl;
                    flag=1;
                    break;
                }
            } else if (tmp<y-now_y) {
                cout<<"No"<<endl;
                flag=1;
                break;
            }
        }
        now=t;
        now_x=x;
        now_y=y;
    }
    if (flag==0) {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N (2 << 15) + 1

bool prime[N] = {false};

void makePrime();

int main(){
    makePrime();
    int n;
    while(cin >> n){
        if(n == 0) break;
        int i = 0, cnt = 0;
        while(i <= (n / 2)){
            if(prime[i] && prime[n - i]){
                cnt++;
            }
            i++;
        }
        cout <<cnt <<endl;
    }
    return 0;
}

void makePrime(){
    for(int i = 2; i < N; i++){
        prime[i] = true;
    }
    for(int i = 0; i < N; i++){
        if(!prime[i]) continue;
        for(int j = i + i; j < N; j += i){
            prime[j] = false;
        }
    }
}

Measured memory_bytes: 0
n,x,y=list(map(int,input().split()))
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min([j-i,abs(x-i)+1+abs(j-y)])-1]+=1
for i in ans:
    print(str(i))

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

using namespace std;


typedef int32_t h_int32;
typedef int64_t h_int64;
typedef uint32_t uh_int32;
typedef uint64_t uh_int64;
typedef h_int64 h_int;

#define REP( i, n ) for(int i = 0; i < ( int )( n ); ++i )
#define REPR( i, n ) for(int i = ( int )( n ); i >= 0; --i)
#define FOR( i, a, n ) for(int i = ( int )( a ); i < ( int )( n ); ++i )
#define FORR( i, a, n ) for(int i = ( int )( n ); i >= ( int )( a ); --i)

#define VINIT( v, type, n )vector<type> v; v.resize( n );
#define VINIT2( v, type, n, a )vector<type> v; v.resize( n, a );
#define VCIN( v, type, n ) VINIT( v, type, n ) REP( i, n ) cin >> v[i];

#define DOUT( x ) cerr << #x << " = " << x << "\n";
#define COUT( x ) cout << ( x ) << "\n";

#define INF 999999999



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

        int n; cin >> n;
        int cnt = 0;
        int cnt4 = 0;
        REP( i, n )
        {
                int a;
                cin >> a;
                if( a % 2 == 1) ++cnt;
                else if( a % 4 == 0) ++cnt4;
        }
        if( cnt - cnt4 == 1)
        {
                if( n - cnt - cnt4 == 0)
                {
                        COUT( "Yes" );
                }
                else
                        COUT( "No" );
                return 0;
        }
        COUT( ( cnt - cnt4 > 0 ) ? "No" : "Yes" );



        return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int W, a, b;
    cin >> W >> a >> b;
    if(b >= a+W) {
        cout << b-a-W << endl;
    } else if(b+W <= a) {
        cout << a-b-W << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import copy
from operator import itemgetter

n, t = map(int, input().split())
p = []
for i in range(n) :
    a = [int(num) for num in input().split()]
    p.append((a[0],a[1]))

answer = []
for j in range(len(p)) :
    e = p[j]
    if (e[1] <= t):
        answer.append(copy.deepcopy(e))
answer = sorted(answer, key=itemgetter(0), reverse=False)
    
if len(answer) == 0 :
    print("TLE")
else :
    print(answer[0][0])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
const int STEPS [8][2]= {{-1,-1},{-1,0},{0,-1},{-1,1},{0,1},{1,-1},{1,0},{1,1}};
bool checkIndex(int my, int maxVal)
{
    return (my<0||my>=maxVal);

}
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for (int i =0; i<n; i++)
    {
        cin>>arr[i];
    }
    char WALL = '#';
    char answer[n][m];
    for (int i =0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            answer[i][j]='0';
        }
    }
    for (int i =0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            if(arr[i][j]!=WALL)
            {
                for (auto STEP: STEPS)
                {
                    int x = i+STEP[0];
                    int y = j+STEP[1];
                    if(checkIndex(x,n)||checkIndex(y,m)) continue;
                    if(arr[x][y]==WALL)
                    {
                        answer[i][j]++;
                    }
                }
            }
            else answer[i][j]=WALL;
        }
    }
    for (int i =0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cout<<answer[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())

def primes(N):
    sieve = [False]*(N+1)
    sieve[2] = True
    searched = [False]*(N+1)
    
    for i in range(3, N+1, 2):
        if searched[i]:
            continue
        sieve[i] = True
        searched[i:N+1:i] = [True]*(N//i)
    return sieve

sieve = primes(55555)
ans = []
for i in range(55556):
    if sieve[i] and (i-1)%15 == 0:
        ans.append(i)

print(*ans[:N])

Measured memory_bytes: 4212
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(){
    ll k;
    ll n;
    scanf("%lld",&k);
    if(k>=50){
        n=50;
        ll a[n];
        ll rem=k/50;
        ll x=49+rem;
        ll t=k%50;
        ll i,j;
        for(i=0;i<50;i++) a[i]=x;
        for(i=0;i<t;i++){
            a[i]+=50;
            for(j=0;j<50;j++) if(j!=i) a[j]--;
        }
        printf("50\n");
        for(i=0;i<50;i++) printf("%lld ",a[i]);
    } else if(k>=2){
        n=k;
        printf("%lld\n",n);
        for(int i=0;i<n;i++) printf("%lld ",n);
    } else if(k==0) printf("4\n3 3 3 3\n");
    else printf("3\n1 0 3\n");
    return 0;
}


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

// #include "../../template-proj/myMente.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int n,k; string s;
	cin>>n>>k>>s;
	char dif = 'A'-'a';
	rp(i,n){
		if(i+1==k){
			s[i] = s[i] - dif;
		}
	}
	cout<< s <<endl;
}


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

int main()
{
    int x;
    cin>>x;
    if(x>99)
    cout<<"ABC"<<x<<endl;
     else if(x>9)
    cout<<"ABC0"<<x<<endl;
     else if(x<10)
    cout<<"ABC00"<<x<<endl;
    return 0;
}


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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define YES_RTN s_cout("Yes");return 0
#define NO_RTN  s_cout("No");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int    A[100001], N, min, tmp, i;
	i_cin(N);
	i_cins(N, A);

	qsort(A, N, sizeof(int), s_asort);

	min = A[0];
	for (i = N - 1; i > 0; i--) {
		tmp = A[i] % min;
		if (min > tmp && tmp) min = tmp;
		A[i] = tmp;
	}

	while (1) {

		qsort(A, N, sizeof(int), s_asort);
		if (!A[N - 2]) { i_cout(min); return 0; }

		for (i = N - 1; i >= 0; i--) {
			if (A[i] == 0)break;
			tmp = A[i] % min;
			if (min > tmp && tmp) min = tmp;
			A[i] = tmp;
		}
	}
	i_cout(min);
	return 0;
	}
	
//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}

Measured memory_bytes: 1012
/* 
    HARSHAD VAGHASIYA

        @DAIICT
    
          H_M_Vaghasiya
    
            */
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
ll gcd(ll a,ll b){return __gcd(a,b);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm; 
}
ll pow2(ll n,ll k){
    ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;
        n=n*n;
        k/=2;
    }return ans;
}
void solve(){
    ll i,j,k,n,m,x,y,z;
    
}
int main()
{
    FS; 
    ll i,j,k,n,m,x,y,z;
    //string s[]={"Sunny", "Cloudy", "Rainy"};
    string t;
    cin>>t;
    if(t[0]=='S'){
        cout<<"Cloudy"<<endl;
    }
    else if(t[0]=='C'){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on



auto Main() {
	ll n;
	cin>>n;

	string s;
	while(n>0) {
		auto r = n%26;
		if(r) {
			s.push_back('a'+r-1);
			n/=26;
		} else {
			s.push_back('z');
			n = n/26-1;
		}
	}
	reverse(begin(s), end(s));
	cout << s;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3652
using System;

namespace ABC116C
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    class MainClass
    {
        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            int ans = 0;
            int tmp = 0;
            int diff = 0;

            for(int i = 0; i < s[0]; i++)
            {
                diff = n[i] - tmp;
                if (diff > 0)
                {
                    ans += diff;
                }
                tmp = n[i];

            }

            Console.WriteLine(ans);
            return;
        }
    }
}


Measured memory_bytes: 13268
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

    long a,b,c,d;
    while (std::cin >> a >> b) {
        if (a > b){
            c = a;
            d = b;
        }else{
            c = b;
            d = a;
        }
        long temp;
        while (c % d != 0){
            temp = d;
            d = c % d;
            c = temp;
        }
        std::cout << d << " " << a*b/d << std::endl;
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3036
k, a, b = map(int, input().split())

if a + 2 >= b:
    print(k + 1)
elif k <= a - 1:
    print(k + 1)
else:
    remain = k - (a - 1)
    d, m = divmod(remain, 2)
    ans = a + (b - a) * d + m
    print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
string s="CODEFESTIVAL2016";
string a;
long long ans;
int main(){
    cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n : usize,
        w : usize,
        a : [(usize, usize); n],
    }

    let mut dp = vec![vec![0; w+1]; n+1]; 

    for i in 1..n+1 {
        for j in 0..w+1 {
            dp[i][j] = if j < a[i-1].0 { 
                dp[i-1][j]
            } else {
                cmp::max(dp[i-1][j], dp[i-1][j-a[i-1].0] + a[i-1].1)
            };
        }
    }

    println!("{}", dp[n][w]);


}

Measured memory_bytes: 106748
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int> a(5);
   
   
    rep(i,5){
        cin >> a[i];
        if(a[i]==0){
            cout << i+1;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
MOD = 10 ** 9 + 7
n, a, b = map(int, input().split())

if a > b:
    a, b = b, a

dp_1s = [0] * b
for l in range(a + 2, b):
    dp = [[0, 0] for _ in range(l + 1)] # at i, 0/1 precedes
    dp[1][1] = 1
    for i in range(1, l):
        dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % MOD
        dp[i + 1][1] = (dp[i + 1][1] + dp[i][0] + dp[i][1]) % MOD
        if i + a < l:
            dp[i + a][0] = (dp[i + a][0] + dp[i][1]) % MOD
    dp_1s[l] = dp[l][1] - 1

dp_0s_edge = [0] * b
for l in range(a + 1, b):
    dp = [[0, 0] for _ in range(l + 1)]
    dp[a][0] = 1
    for i in range(1, l):
        dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % MOD
        dp[i + 1][1] = (dp[i + 1][1] + dp[i][0] + dp[i][1]) % MOD
        if i + a < l:
            dp[i + a][0] = (dp[i + a][0] + dp[i][1]) % MOD
    dp_0s_edge[l] = dp[l][1] 

# starting at i, 0s/1s precede, i.e., 1s/0s follow
# when 0s precede, len of preceding 0s is lt a
dp = [[0, 0] for _ in range(n + 1)]

dp[0] = [1, 1]
# starting with 0s whose len is gt or eq to a
for l in range(a + 1, b):
    dp[l][1] = dp_0s_edge[l]

for i in range(n):
    for j in range(i + 1, min(n + 1, i + b)):
        dp[j][1] = (dp[j][1] + dp[i][0]) % MOD
    for j in range(i + 1, min(n + 1, i + a)):
        dp[j][0] = (dp[j][0] + dp[i][1]) % MOD
    for l in range(a + 2, b):
        if i + l <= n:
            dp[i + l][1] = (dp[i + l][1] + dp[i][0] * dp_1s[l]) % MOD

# ending with 0s whose len is gt or eq to a
for l in range(a + 1, b):
    dp[n][0] = (dp[n][0] + dp[n - l][0] * dp_0s_edge[l]) % MOD

print((pow(2, n, MOD) - sum(dp[n])) % MOD)


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

int main() {
  int n;ll k;cin>>n>>k;
  int pn[n];rep(i,n)cin>>pn[i];
  ll cn[n];rep(i,n)cin>>cn[i];
  
  vector<ll> dp[n];
  rep(i,n) {
    int next = pn[i] - 1;
    dp[i].push_back(cn[next]);
    rep(j, n-1) {
      next = pn[ next ] - 1;
      dp[i].push_back( dp[i][j] + cn[next] );
      if (next == i) break;
    }
  }
  
  ll a,b,m;
  //rep(i,n) { for (auto j: dp[i]) cout<<j<<" ";cout<<endl; }
  
  ll maxi[n];rep(i,n) maxi[i]=dp[i][0];
  rep(i, n) {
    m = dp[i].size();
    a = k / m;
    b = k % m;
    //cout<<a<<" "<<b<<endl;
    if (b==0) {b=m;a--;}
    
    ll maxi0 = dp[i][0];
    rep(j, b) maxi0 = max(maxi0, dp[i][j]);
    if (a>0 && dp[i][m-1] > 0) maxi0 += dp[i][m-1]*a;
    
    if (a>0) {
      ll maxi1 = dp[i][0];
      rep(j, m) maxi1 = max(maxi1, dp[i][j]);
      if (dp[i][m-1] > 0) maxi1 += dp[i][m-1]*(a-1);
    
      maxi[i] = max(maxi0, maxi1);
    } else {
      maxi[i] = maxi0;
    }
  }
  ll ans = maxi[0];
  rep(i, n) ans = max(ans, maxi[i]);
  cout<<ans;
}


Measured memory_bytes: 218888
#!/usr/bin/env python3

def f(d,m):
    return 1 + (d-1)//m

def solve(d,x,a):
    ans = x
    for i in range(len(a)):
        ans += f(d,a[i])
    return ans



def main():
    N = int(input())
    D,X = map(int,input().split())
    a = [int(input()) for _ in range(N)]
    print(solve(D,X,a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n, m, k = map(int, input().split())
mod = 998244353

N = 10**5 * 2  # N!まで求める
fact  = [1, 1]  # 階乗の元テーブル
fact_inv = [1, 1]  # 階乗の逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル 1,2,,...の逆元を求めてる

# 計算 O(1)
def comb(n, r, mod):
    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

# 順列
def perm(n, r, mod):
    if (r<0 or r>n):
        return 0
    return fact[n] *  fact_inv[n-r] % mod

# 前処理 O(n)
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    fact_inv.append((fact_inv[-1] * inv[-1]) % mod)

ans = 0
for i in range(k+1):
    ans += comb(n-1, i, mod) * m * pow(m-1, n-i-1, mod)
    ans %= mod

print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    long long m1 = 0;
    bool p = true;
    for (int i = 0; i < n; i++) {
        if (p) m1 += a.at(i) * 2;
        else m1 -= a.at(i) * 2;

        p ^= 1;
    }
    m1 /= 2;
    cout << m1 << " ";
    long long r = m1;
    for (int m = 1; m < n; m++) {
        r = a.at(m - 1) * 2 - r;
        cout << r << " ";
    }
    cout << endl;
}   

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s, n) for(int i = s; i < (int)n; i++)
#define ll long long 
using namespace std;
ll combination(ll n){
  ll a;
  if(n%2==0) {
    a=n/2*(n-1);
  }else {
    a=(n-1)/2*n;
  }
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep2(i,1,n+1) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep2(i,1,n+1) sum+=combination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if(mp[vec[i]]==2){
      cout <<sum-1<<endl;
    }else{
      cout <<sum<<endl;
    }
  }
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

void yes() {
    cout << "Yes" << endl;
    exit(0);
}

void no() {
    cout << "No" << endl;
    exit(0);
}

class UnionFind {
    vector<int> par, Size;

  public:
    ll c; // 連結成分
    UnionFind(int n) : par(n), Size(n, 1), c(n) { rep(i, n) par[i] = i; }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(Size[x] > Size[y]) {
            Size[x] += Size[y];
            par[y] = x;
        } else {
            Size[y] += Size[x];
            par[x] = y;
        }
        c--;
        return true;
    }
    int size(int x) { return Size[root(x)]; }
};

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

    ll n, m, q;
    cin >> n >> m >> q;
    UnionFind uf(n);
    using P = array<ll, 2>;
    V<P> vec;
    rep(_, q) {
        ll u, v, c;
        cin >> u >> v >> c;
        if(c == 0)
            uf.unite(u, v);
        else
            vec.push_back(P{u, v});
    }
    if(m == n - 1) {
        if(vec.size() == 0) yes();
        no();
    }
    for(P p : vec)
        if(uf.same(p[0], p[1])) no();
    if(m <= n + uf.c * (uf.c - 3) / 2) yes();
    no();

    return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
    int  num;
    int num1;
    scanf("%d",&num1);
    num=(num1%10);
    //printf("%d",num);    
    if(num==2 || num==4 || num==5 || num==7 || num==9){
        printf("hon\n");
    }else if(num==0 || num==1 || num==6 || num==8){
        printf("pon\n");
    }else if(num==3){
        printf("bon\n");
    }

    return 0;
}

Measured memory_bytes: 1656
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  cin >> s;
  int ans=700;
  rep(i,3){
    if(s[i]=='o')ans+=100;
  } 
  pri(ans);
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std; 
 
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()
#define INF 1e9
 
typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	
 
 
int main(){
	
	
	int n;
	
	vi dp(100005);
	
	f(i,1,100005){
		dp[i] = i;
		
	}
	
	vi gen;
	int i = 1;
	while(1){
		int idx = pow(6,i);
		
		if(idx>=100005) break;
		 
		gen.pb(idx);
		
		i++;

	}
	i = 1;
	while(1){
		int idx = pow(9,i);
		
		if(idx>=100005) break;
		
		gen.pb(idx);

		i++;
	}
	
	sort(all(gen));

	f(i,0,SZ(gen)){
		int dx = gen[i];
		dp[dx] = 1;
		f(j,1,100005){
			if(dx+j>=100005)break;
			dp[dx+j] = min(dp[dx+j],1+dp[j]);
		}
	}
	
	

	cin >> n;
 
	cout << dp[n] << endl;
 
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

const int MAXQ = 50;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        int now = 0;
        rep(i, q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(1,1));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660