akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            string[] t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            //スイッチがそれぞれオンオフを考える
            int[,] sw = new int[m,n];
            int[] power = new int[m];
            int[] count = new int[m];
            int ans = 0;

            //スイッチを押すと反応する電球を記憶
            for (int i = 0; i < m; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                for(int j = 0; j < int.Parse(s[0]);j++)
                    sw[i, int.Parse(s[j + 1]) - 1] = 1;
                
            }

            //最後のオンオフの条件も記録
            string[] u = Console.ReadLine().Split(' ');
            for (int i = 0; i < m; i++)
                power[i] = int.Parse(u[i]);


            //ビット全探索
            for (int i = 0; i < (1 << n);i++)
            {
                //まずはオンオフでオンしている数を数える
                for(int j = 0; j < n;j++)
                {
                    if(((i >> j) & 1) == 1)
                    {
                        for(int k = 0;k < m;k++)
                        {
                            if (sw[k, j] == 1)
                                count[k]++;
                        }

                    }
                }

                //もし一つでもオン状態がなければアウト
                for(int j = 0;j < m;j++)
                {
                    if (count[j] % 2 != power[j])
                        break;

                    if (j == m - 1)
                        ans++;

                }

                for(int j = 0; j < m;j++)
                    count[j] = 0;
            }

            Console.WriteLine(ans);
            return;
        }
    }

}


Measured memory_bytes: 13140
#include <stdio.h>

int main() {
	int n, k, q, a, s[100010];
	scanf("%d %d %d", &n, &k, &q);
	for (int i = n; i > 0; i--)
		s[i] = k - q;
	while (q--) {
		scanf("%d", &a);
		s[a]++;
	}
	for (int i = 1; i <= n; i++)
		printf("%s\n", ((s[i] > 0) ? "Yes" : "No"));
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	int n, m; read(n), read(m);
	init(max(n, m));
	int ans = 0;
	for (int i = 0; i <= min(n, m); i++)
		if (i & 1) update(ans, P - 1ll * binom(n, i) * binom(m, i) % P * fac[i] % P * power(n + 1, m - i) % P * power(m + 1, n - i) % P);
		else update(ans, 1ll * binom(n, i) * binom(m, i) % P * fac[i] % P * power(n + 1, m - i) % P * power(m + 1, n - i) % P);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int R,C;
bool fld[10000][10];
void rev(int r){
      REP(i,C)fld[i][r]^=1;
}
int main(){
      while(cin>>R>>C&&(R||C)){
            REP(i,R)REP(j,C)cin>>fld[j][i];
            int ans=0;
            REP(i,1<<R){
                  int sum=0;
                  REP(j,R)if(i>>j&1)rev(j);
                  REP(j,C){
                        int cnt=0;
                        REP(k,R)if(!fld[j][k])cnt++;
                        sum+=max(R-cnt,cnt);
                  }
                  ans=max(ans,sum);
                  REP(j,R)if(i>>j&1)rev(j);
            }
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1256
N,M = map(int,input().split())
X = [int(i) for i in input().split()]

X.sort()

maxlist = [0] * (M-1)
cnt = 0
ans = 0

for i in range(1,M):
    maxlist[i-1]= X[i] - X[i-1]
    ans += maxlist[i-1]
    
maxlist.sort()
maxlist.reverse()

minus = 0
for i in range(min(N,M)-1):
    minus += maxlist[i]
    
print(ans-minus)
    
    

Measured memory_bytes: 52520
#include <iostream>
#include <vector>

using namespace std;
int main(int argc, char const *argv[]) {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H + 1, vector<int>(W + 1));

  vector<pair<pair<int, int>, pair<int, int>>> operation;

  for (int h = 1; h < H + 1; h++) {
    for (int w = 1; w < W + 1; w++) {
      cin >> a[h][w];
    }
  }

  int N = 0;
  for (int h = 1; h < H + 1; h++) {
    for (int w = 1; w < W + 1; w++) {
      if (a[h][w] % 2 != 0) {
        if (w != W) {
          a[h][w]--;
          a[h][w + 1]++;
          N++;
          operation.push_back(make_pair(make_pair(h, w), make_pair(h, w + 1)));
        }
      }
    }
  }

  for (int h = 1; h < H; h++) {
    if (a[h][W] % 2 == 1) {
      a[h][W]--;
      a[h + 1][W]++;
      N++;
      operation.push_back(make_pair(make_pair(h, W), make_pair(h + 1, W)));
    }
  }

  cout << N << "\n";
  for (int i = 0; i < N; i++) {
    cout << operation[i].first.first << " " << operation[i].first.second << " "
         << operation[i].second.first << " " << operation[i].second.second
         << "\n";
  }

  return 0;
}


Measured memory_bytes: 5232
n = int(input())
A = [int(input()) for _ in range(n)]

A.reverse()

import bisect
B = [10**18]
for a in A:
    i = bisect.bisect_right(B, a)
    if 0 <= i < len(B):
        B[i] = a
    else:
        B.append(a)
print(len(B))

Measured memory_bytes: 84384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define pb emplace_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

int main(){
    fastio;
		
	lli n; cin >> n;
	lli act[n+1][3];
	for(int i=1; i<n+1; ++i)
		for(int j=0; j<3; ++j)
			cin >> act[i][j]; 
	
	lli dp[n+1][3]; memset(dp, 0, sizeof(dp));
	for(int k=1; k<n+1; ++k){
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				if(i != j)
				dp[k][i] = max(dp[k][i], dp[k-1][j]+act[k][i]);
			}
		}
	}
	
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
	return 0;
}


Measured memory_bytes: 4992
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(n):
    ret = 0
    for a, b in zip(map(int, input().split()), B):
        ret += a * b
    if ret + c > 0:
        ans += 1
print(ans)

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }



int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];
    map<ll,ll> m;
    rep(i,n) m[a[i]-1] = i;

    set<ll> s;
    s.insert(-1); s.insert(n);
    ll ans = 0;
    rep(i,n){
        ll l,r;
        auto it = s.lower_bound(m[i]);
        r = *it;
        it--;
        l = *it;
        ll cnt = (r-m[i])*(m[i]-l);
        ans += a[m[i]]*cnt;
        s.insert(m[i]);
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 23680
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
ll junretu(ll x, ll y) {
	ll ans;
	ans = 1;
	for (ll i = x; i >= x - y + 1; i--) {
		ans *= i;
		ans %= 1000000007;
	}
	if (ans == 0) {
		ans = 1;
	}
	return ans;
}



int main() {
	ll i, j, k, l, m, n, sum, flag, cc,M,X,H,W,N;
	cin >> N;
	vector<ll>h(N);
	ll inf = 1000000000;
	ll ans[100001];
	REP(i, 0, N+1) {
		ans[i] = inf;
	}
	REP(i, 0, N) {
		cin >> h[i];
	}
	ans[0] = 0;
	ans[1] = abs(h[1] - h[0]);
	REP(i, 2, N) {
		ans[i] = fmin(ans[i - 2] + abs(h[i] - h[i - 2]), ans[i - 1] + abs(h[i] - h[i - 1]));
	}
	output(ans[N - 1]);


	return 0;
}

Measured memory_bytes: 1792
import sys
DBG = True
BIG = 1000000007
n = int(input())
s = input()
cnt = { 'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0 }
for i in range(n):
    cnt[s[i]] += 1

prod = 1
for key in cnt:
    prod = (prod * (cnt[key] + 1)) % BIG
print((prod-1)%BIG)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

int c = 0;
int id = 0;

void dfs(int v , int p , v(vi) &adj , vi &idx  , vi &low){
    idx[v] = low[v] = id++;
    for(auto to : adj[v]){
        if(to == p) continue;
        if(idx[to] == -1){
            dfs(to , v , adj , idx , low);
            low[v] = min(low[v] , low[to]);
            if(idx[v] < low[to]){
                c++;
            }
        }else {
            low[v] = min(low[v] , idx[to]);
        }
    }
}


void solve() {
    int n , m;
    cin>>n>>m;
    v(vi) adj(n);
    for (int i = 0; i < m; ++i) {
        int u , v;
        cin>>u>>v;
        u--,v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    vi low(n) , idx(n , -1);
    dfs(0 , -1 , adj , idx , low);
    cout<<c<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		Integer[] mn = new Integer[n], mx = new Integer[n];
		
		for(int i = 0; i < n; i++) {
			mn[i] = sc.nextInt();
			mx[i] = sc.nextInt();
		}
		
		Arrays.sort(mn);
		Arrays.sort(mx);
		
		if(n % 2 == 1) {
			int lo = mn[n/2], hi = mx[n/2];
			out.println(hi - lo + 1);
		}else {
			int lo = mn[(n - 1)/2] + mn[n / 2];
			int hi = mx[(n - 1)/2] + mx[n / 2];
			out.println(hi - lo + 1);
		}
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

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

int N,M;
int A[200020];
int n[200020] = {0};
int sum[400040] = {0};
int ans;

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        A[i + 1] = a;
        sum[a - n[a] + N]++;
        n[a]++;
    }
    for(int i = N; i < N * 2; i++)if(sum[i + 1] == 0)ans++;
    for(int i = 0; i < M; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int old = A[x];
        //sum
        n[old]--;
        if(sum[old - n[old] + N] == 1 &&
           N < old - n[old] + N &&
           old - n[old] + N <= N * 2)ans++;
        sum[old - n[old] + N]--;
        A[x] = y;
        if(sum[y - n[y] + N] == 0 &&
           N < y - n[y] + N &&
           y - n[y] + N <= N * 2)ans--;
        sum[y - n[y] + N]++;
        n[y]++;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll get(ll n , ll m)
{
  return n * (n + 1) / 2 * m ;
}
int main()
{
  ll n ;
  cin >> n ;
  ll sum = n * ( n + 1 ) / 2 ;
  //cout << sum << endl ;
  sum -= get(n / 3 , 3) + get(n / 5 , 5) - get(n / 15 , 15) ;
  cout << sum << endl ;
  return 0;
}


Measured memory_bytes: 3632
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    string s;
    cin >> s;
    int current = 0;
    int res = 0;
    REP(i, s.size()) {
        if ((s[i] == 'A') || (s[i] == 'C') || (s[i] == 'G') || (s[i] == 'T')) {
            current++;
        } else {
            res = max(current, res);
            current = 0;
        }
    }
    res = max(current, res);
    cout << res << endl;
    return 0;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N;
    cin >> N;

    VI W(N);
    REP(i, N) cin >> W.at(i);
    int mini=INF;
    int S_1,S_2;
    int sum = accumulate(ALL(W),0);
    REP(i, N)
    {
        S_1 = accumulate(W.begin(),W.begin()+i,0);
        S_2 = sum-S_1;
        mini = min(mini, abs(S_1-S_2));
    }

    cout << mini << endl;

    return 0;
}



Measured memory_bytes: 256
X = int(input())

import math

# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
    is_prime = [-1 for _ in range(M+1)]
    for m in range(2, M+1):
        if is_prime[m] == -1:
            is_prime[m] = 1
            l = 2
            while m*l <= M:
                is_prime[m*l] = 0
                l += 1
    primes = []
    for p in range(2, M+1):
        if is_prime[p] == 1:
            primes.append(p)
    return primes

ps = primes(2*10**5)

for p in ps:
    if p >= X:
        print(p)
        break

Measured memory_bytes: 5424
#!usr/bin/env python3
import sys
import bisect
from collections import deque
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]

M = 3*10**9+1
M2 = (M-10**9)**2
n,m = LI()
p = LIR(n)
q = LIR(m)
fx = set([-M,0,M])
fy = set([-M,0,M])
for i in range(n):
    p[i][0] <<= 1
    p[i][1] <<= 1
    p[i][2] <<= 1
    a,b,c = p[i]
    fy.add(a)
    fy.add(b)
    fy.add(b+1)
    fx.add(c)
    fx.add(c+1)

for i in range(m):
    q[i][0] <<= 1
    q[i][1] <<= 1
    q[i][2] <<= 1
    d,e,f = q[i]
    fy.add(d)
    fy.add(d+1)
    fx.add(e)
    fx.add(f)
    fx.add(f+1)
fy = list(fy)
fx = list(fx)
fy.sort()
fx.sort()
s = [0]*len(fx)*len(fy)
for a,b,c in p:
    ai = bisect.bisect_left(fy,a)
    bi = bisect.bisect_left(fy,b)
    ci = bisect.bisect_left(fx,c)
    ka = ai*len(fx)
    kb = (bi+1)*len(fx)
    s[ka+ci] += 1
    s[kb+ci] -= 1
    s[ka+ci+1] -= 1
    s[kb+ci+1] += 1
for d,e,f in q:
    di = bisect.bisect_left(fy,d)
    ei = bisect.bisect_left(fx,e)
    fi = bisect.bisect_left(fx,f)
    kd = di*len(fx)
    kdd = kd+len(fx)
    s[kd+ei] += 1
    s[kd+fi+1] -= 1
    s[kdd+ei] -= 1
    s[kdd+fi+1] += 1
for i in range(len(fy)):
    k = i*len(fx)
    for j in range(len(fx)-1):
        ind = k+j
        s[ind+1] += s[ind]
for i in range(len(fy)-1):
    k = i*len(fx)
    for j in range(len(fx)-1):
        ind = k+j
        s[ind+len(fx)] += s[ind]
sx = bisect.bisect_left(fx,0)
sy = bisect.bisect_left(fy,0)
nh,nw = len(fy)-1,len(fx)-1
for i in range(nw-1):
    fx[i+1] >>= 1
    fx[i] = fx[i+1]-fx[i]
for i in range(nh-1):
    fy[i+1] >>= 1
    fy[i] = fy[i+1]-fy[i]
ans = fx[sx]*fy[sy]
q = deque()
q.append((sy,sx))
f = [1]*nh*nw
f[sy*nw+sx] = 0
d = [(1,0),(-1,0),(0,1),(0,-1)]
while q:
    y,x = q.popleft()
    for dy,dx in d:
        ny,nx = y+dy,x+dx
        if 0 <= ny < nh and 0 <= nx < nw:
            ind = ny*nw+nx
            if f[ind] and not s[ind+ny]:
                if ny < 1 or nx < 1 or ny+1 >= nh or nx+1 >= nw:
                    print("INF")
                    quit()
                ans += fx[nx]*fy[ny]
                f[ind] = 0
                q.append((ny,nx))
print(ans)


Measured memory_bytes: 566472
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

int main() {
	char a;
	cin >> a ;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') cout << "vowel";
	else cout << "consonant";
	return 0;
}

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

#define f(x,y,x1,x2,y1,y2) (y2-y1)*(x-x1)-(x2-x1)*(y-y1)  

int determine(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)//(x3,y3)と(x4,y4)が同じ側にある
{
  //if((f(x3,y3,x1,x2,y1,y2)*f(x4,y4,x1,x2,y1,y2))>0)
  if((f(x3,y3,x1,x2,y1,y2)>0 &&f(x4,y4,x1,x2,y1,y2)>0) ||(f(x3,y3,x1,x2,y1,y2)<0 &&f(x4,y4,x1,x2,y1,y2)<0) )  
    return 1; //同じ側なら1
  else
    return 0; //異なれば0
}

int intri(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)//(x4,y4)が三角形の中にある 
{
  if(determine(x1,y1,x2,y2,x3,y3,x4,y4)==1 && determine(x3,y3,x2,y2,x1,y1,x4,y4)==1 && determine(x3,y3,x1,y1,x2,y2,x4,y4)==1)
    return 1;
  else 
    return 0;
}

int main(void)
{

  double x1,y1,x2,y2,x3,y3,x4,y4;
  // printf("%d,%d\n",f(1,1,0,0,10,0),f(5,5,0,0,10,0));

   while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF){
     if(intri(x1,y1,x2,y2,x3,y3,x4,y4)==1 || intri(x2,y2,x3,y3,x4,y4,x1,y1)==1 || intri(x3,y3,x4,y4,x1,y1,x2,y2)==1 ||intri(x4,y4,x1,y1,x2,y2,x3,y3)==1)
       printf("NO\n");
     else
       printf("YES\n");
   }
   
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>

typedef long long ll;

int main (void) {
  ll N;
  std::cin >> N;
  ll Nmax = std::ceil(std::sqrt(N));

  ll ans = 0;
  for(ll i=1; i<Nmax; i++) {
    if ( N % i == 0 ) {
      ll small = i;
      ll large = N/i;
      if ( large > small+1 ) ans += (large-1);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner scan = null;
    	int[] num = new int[3];
	try {
  	    scan = new Scanner(System.in);
	    for (int i = 0; i < num.length; i++) {
	    	num[i] = scan.nextInt();
	    }
	    Arrays.sort(num);
	    StringBuffer sortlist = new StringBuffer();
	    for (int i = 0; i < num.length; i++) {
	        sortlist.append(num[i]);
		if (i < num.length - 1) {
		    sortlist.append(' ');
		}
	    }
	    System.out.println(sortlist);
	} catch (InputMismatchException e) {
	    System.out.println(e);
	} finally {
	    scan.close();
	}
    }
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 998244353;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}


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

  int n, m;
  cin >> n >> m;

  auto factorials = MakeFactorialTable(n + 3 * m + 1);
  vector<FiniteField> inverse_factorials(n + 3 * m + 1);
  for (int i = 0; i <= n + 3 * m; i++) {
    inverse_factorials[i] = FiniteField(1) / factorials[i];
  }

  auto combination_fn = [&](int n, int r) -> FiniteField {
    if (r < 0 || r > n) return 0;
    return factorials[n] * inverse_factorials[r] * inverse_factorials[n - r];
  };

  FiniteField value = 0;
  for (int k = 0; k <= min(n, m); k++) {
    if (k % 2 != m % 2) continue;
    FiniteField factor1 = combination_fn(n, k);
    int a = (3 * m - k) / 2;
    FiniteField factor2 = combination_fn(a + n - 1, a);
    factor2 -= combination_fn(a - m + n - 1, a - m) * k;
    factor2 -= combination_fn(a - (m + 1) + n - 1, a - (m + 1)) * (n - k);
    value += factor1 * factor2;
  }
  cout << value.Value() << endl;
}


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

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
  
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
    
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26240
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1<<30;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(All(a));
    int res = 0;
    res += a[2] - a[1];
    a[1] += res;
    a[0] += res;
    //cout << a[0] << ' ' << a[1] << ' ' << a[2];
    int d = a[2] - a[0];
    if(d%2==0)
        res += d / 2;
    else
        res += d / 2 + 2;
    cout << res << endl;
}

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

int main()
{
    ll n,w;
    cin>>n>>w;
    ll arr[n+1],val[n+1],i,j;
    for(i=1;i<=n;i++)
        cin>>arr[i]>>val[i];
    
    ll mat[n+1][w+1];
    memset(mat,0,sizeof(mat));
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(j<arr[i])
                mat[i][j]=mat[i-1][j];
            else
                mat[i][j]=max(mat[i-1][j], mat[i-1][j-arr[i]]+val[i]);
        }
    }
    cout<<mat[n][w];
    return 0;
    
}

Measured memory_bytes: 79104
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;

       cin>>m>>n;
     m=(m*(m-1))/2;
     n=(n*(n-1))/2;
     x=m+n;
       cout<<x<<endl;

}


Measured memory_bytes: 256
import math
def calc(aL, bL):
  des2 = 0
  for (a, b) in zip(aL, bL):
#    print("des {} {}".format(a, b))
    des2 += abs(a-b) * abs(a-b)
  return math.sqrt(des2)

n, d = map(int, input().split())
aList = list()
for _ in range(n):
  if d != 1:
    aList.append(list(map(int, input().split())))
  else:
    aList.append(int(input()))
  
count = 0
for aIdx in range(0, len(aList)):
  for bIdx in range(aIdx+1, len(aList)):
#    print("Idx {} {}".format(aIdx, bIdx))
    if aIdx == bIdx:
      continue
    if d != 1:
      des = calc(aList[aIdx], aList[bIdx])
    else:
      des = math.sqrt(abs(aList[aIdx] - aList[bIdx])*(abs(aList[aIdx] - aList[bIdx])))
    if des % 1 == 0:
      count += 1
print(count)
   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
vector<vector<bool>> Chan;


int main() {
    int N, C; cin >> N >> C;
    Chan.assign(C, vector(100007, false));
    rep(i,N) {
        int s,t,c; cin >> s >> t >> c;
        s--,t--,c--;
        for(int j = s; j <= t; j++) Chan[c][j] = true;
    }
    int ma = 0;
    rep(i,100000) {
        int channel = 0;
        rep(j,C) {
            if (Chan[j][i]) channel++;
        }
        ma = max(ma, channel);
    }
    cout << ma << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    string s, t, u;
    cin >> s >> t >> u;
    cout << s.at(0) << t.at(1) << u.at(2) << endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin>>n;
    vector<int >h(n);
    for (int i = 0; i < n; ++i) {
        cin >>h[i];
    }
    reverse(all(h));
    for (int i = 1; i <n; ++i) {
        if(h[i-1]<h[i]){
            if(h[i]-h[i-1]>1){
                puts("No");
                return 0;
            }
            h[i]--;
        }
    }
    puts("Yes");
    return 0;
}

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

for i in range(N):
    L[i][0],L[i][1]=map(int,input().split())
L=sorted(L,key=lambda x: (x[0]))

d=L[N-1][0]
L2=sorted(L,key=lambda x: (x[1]))

c=0
for i in range(N-1,-1,-1):
    if(d>=L2[i][1]):
        break
    c+=1
    H-=L2[i][1]
    if(H<=0):
        break

if(H>0):
    if(H%d!=0):
        c+=1
    c+=(H//d)


print(c)


Measured memory_bytes: 62880
//CF template

import java.io.*;
import java.util.*;
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      //begin
      int k = sc.nextInt();
      int x = sc.nextInt();
      int min = Math.max(x - k + 1, -1000000);
      int max = Math.min(x + k - 1, 1000000);
      for(int i = min; i <= max; i++)
        out.print(i + " ");
      //end
      out.close();
   }
 
   public static PrintWriter out;
      
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
      long nextLong() {
          return Long.parseLong(next());
      }
      double nextDouble() {
          return Double.parseDouble(next());
      }
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 21204
def xxx(n):
    ans = ""
    i = 1

    while True:
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans = chr(ord("a") + n%26) + ans
                n //= 26
            return ans
        else:
            n -= 26 ** i
            i += 1


N = int(input())
print(xxx(N))

Measured memory_bytes: 9180
#include <stdio.h>
 
int main() {
	char s;
	scanf("%c", &s);
	if(s >= 'a' && s <= 'z') {
		printf("a");
	}
	else if(s >= 'A' && s <= 'Z') {
		printf("A");
	}
	 return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N;
    std::cin >> N;

    int mx = N / 3;
    std::cout << mx << std::endl;
}


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

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

    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    vector<pair<int, int>> lr;
    int tmp_l, tmp_r;
    for (int i = 0; i < Q; i++) {
        cin >> tmp_l >> tmp_r;
        lr.push_back(make_pair(tmp_l, tmp_r));
    }
    vector<int> mem;
    int count = 0;
    char buf = ' ';
    for (auto itr = S.begin(); itr != S.end(); ++itr) {
        if (*itr == 'A') {
            buf = 'A';
        } else if (buf == 'A' && *itr == 'C') {
            count++;
            buf = ' ';
        } else {
            buf = ' ';
        }
        mem.push_back(count);
    }
    for (int i = 0; i < Q; i++) {
        cout << mem[lr[i].second - 1] - mem[lr[i].first - 1] << "\n";
    }
}

Measured memory_bytes: 2628
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int n,k;
	    cin>>n>>k;
	    int A[n+1];
	    int dp[n+1];
	    rep(i,1,n+1){
	        cin>>A[i];
	    }
	    dp[0] = INT_MIN;
	    dp[1] = 0;
	    if(n==1)
	    {
	        cout<<"0\n";
	        continue;
	    }
	    dp[2] = abs(A[1]-A[2]);
	    for(int i=3;i<=n;i++){
	        dp[i] = INT_MAX;
	        for(int j=1;j<=k;j++){
	            if(i-j>=1)
	            dp[i] = min(dp[i],abs(A[i]-A[i-j])+dp[i-j]);
	        }
	    }
	    cout<<dp[n]<<"\n";
	}
    return 0;
}


Measured memory_bytes: 4360
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class A {
public:
    bool visited[51];
    bool graph[51][51];
    int u[51], v[51];
    int n,m;
    void dfs(int a){
        if(visited[a]==false){
            visited[a]=true;
            for(int i=1; i<=n; ++i){
                if(graph[a][i]==false) continue;
                if(visited[i]==false) dfs(i);
            }
        }
    }
	void solve(std::istream& in, std::ostream& out) {
        in>>n>>m;

        for(int i=0; i<=n; ++i) for(int j=0; j<=n; ++j) graph[i][j]=false;
        for(int i=0; i<m; ++i){
            in>>u[i]>>v[i];
            graph[u[i]][v[i]]=graph[v[i]][u[i]]=true;
        }
        int res=0;

        for(int i=0; i<m; ++i){
            graph[u[i]][v[i]]=graph[v[i]][u[i]]=false;
            for(int k=1; k<=n; ++k) visited[k]=false;
            dfs(1);
            bool bridge=false;
            for(int j=1; j<=n; ++j) if(visited[j]==false) bridge=true;
            res+=bridge;
            graph[u[i]][v[i]]=graph[v[i]][u[i]]=true;
        }
        out<<res;
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    ll cnt[n+1];
    fill(cnt,cnt+n+1,0);
    rep(i,0,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll ans=0;
    rep(i,1,n+1){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    rep(i,0,n){
        ll t=cnt[a[i]];
        ll sum=ans-t*(t-1)/2;
        t--;
        sum+=t*(t-1)/2;
        cout<<sum<<endl;
    }
}







Measured memory_bytes: 4992
import numpy as np
h, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = np.array(sorted(VW, key=lambda x:(x[0]/x[1],x[0])))
a = VW[:, 0]
b = VW[:, 1]

dp = np.zeros(10**4+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])


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

int main(){
  int N, W; cin >> N >> W;
  vector<int> w(N), v(N);
  for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
  vector<vector<int> > dp(N + 1, vector<int> (W + 1));
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= W; j++){
      if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
      else dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
char a[1000];
int main()
{
	int ac,q=0,w=0;
	gets(a);
	ac=strlen(a);
	for(int i=0;i<=ac;i++)
	{
		if(a[i]=='C') q++;
		if(a[i]=='F'&&q!=0)
		{
			printf("Yes");
			return 0; 
		}
	}
	printf("No");
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string inp;
  cin>>inp;
  int ans = 0;
  if(inp[0]=='R'){
    ans++;
  }
  else if(inp[1]=='R'){
      ans++;
  }
  else if(inp[2]=='R'){
      ans++;
  }
  int index = 1;
  while(index<3){
    if(inp[index]=='R'&&inp[index-1]=='R'){
      ans++;
    }
    index++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
//pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ll mod = 1e9 + 7;
const ll N = 3e5 + 7;



int main() {
	fastIO;
	int n;
	cin >> n;
	vector<pair<ll, ll>> v;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		v.push_back({ b, a });
	}
	sort(v.begin(), v.end());
	int currTime = 0;
	bool valid = true;
	for (int i = 0; i < n; i++) {
		ll time = v[i].second, deadline = v[i].first;
		if (currTime + time <= deadline) {
			currTime += time;
		}
		else {
			valid = false;
			break;
		}
	}
	if (valid)
		cout << "Yes";
	else
		cout << "No";
	


}


Measured memory_bytes: 6512
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (((abs(b - a) <= d) && (abs(c - b) <= d)) || (abs(c-a)<=d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
N, x = map(int, input().split())
a = list(map(int, input().split()))

total = 0
for i in range(len(a)-1):
    diff = a[i+1] + a[i] - x
    if diff>0:
        total += diff
        if a[i+1]>=diff:
            a[i+1] = a[i+1]-diff
        else:
            a[i+1] = 0
            a[i] = a[i] -(diff-a[i+1])
    else:
        pass
    
print(total)

Measured memory_bytes: 14132
"use strict";
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var input = input.split("\n");
    var tmp = input[0].split(" ");
    var n = parseInt(tmp[0], 10);
    var r = parseInt(tmp[1], 10);
    console.log(r + Math.max(0, 100*(10-n)));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30552
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int h = x / 3600;
    int m = (x - h * 3600) / 60;
    int s = (x - h * 3600) % 60;
    cout << h << ":" << m << ":" << s << "\n";
}

Measured memory_bytes: 3208
n,m=map(int,input().split())
a=[1]*(n+1)
for i in range(m):
    a[int(input())]=0
p0=a[0]
p1=a[1]
for i in range(2,n+1):
    if a[i]==1:
        p2=p0+p1
    else:
        p2=0
    p0,p1=p1,p2
print(p1%1000000007)


Measured memory_bytes: 44648
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = collections.Counter(iss())
    T = collections.Counter(iss())

    if sorted(S.values()) == sorted(T.values()):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
  private static readonly int INF = 1001001001;
  static void Main(string[] args)
  {
    string[] nmx = Console.ReadLine().Split(' ');
    int n = int.Parse(nmx[0]);
    int m = int.Parse(nmx[1]);
    int x = int.Parse(nmx[2]);
    int[,] a = new int[12, 12];
    List<int> c;
    List<int> price = new List<int>();
    for (int i = 0; i < n; i++)
    {
      c = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
      price.Add(c[0]);
      for (int j = 0; j < m; j++)
      {
        a[i,j] = c[j + 1];
      }
    }

    int ans = INF;
    for (int bit = 0; bit < (1 << n); bit++)
    {
      int cost = 0;
      int[] d = new int[12];
      for (int i = 0; i < n; i++)
      {
        if ((bit & (1 << i)) > 0)
        {
          cost += price[i];
          for (int j = 0; j < m; j++)
          {
            d[j] += a[i,j];
          }
        }
      }
      bool ok = true;
      for (int j = 0; j < m; j++)
      {
        if (d[j] < x) ok = false;
      }
      if (ok) ans = Math.Min(ans, cost);
    }
    if (ans == INF)
    {
      Console.WriteLine(-1);
    }
    else
    {
      Console.WriteLine(ans);
    }
  }
}

Measured memory_bytes: 28408
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] T = new int[N];
        int[] A = new int[N];
        for (int i = 0; i < N; ++i) {
            T[i] = sc.nextInt();
            A[i] = sc.nextInt();
        }

        System.out.println(solve(T, A));

        sc.close();
    }

    static long solve(int[] T, int[] A) {
        long t = 1;
        long a = 1;
        for (int i = 0; i < T.length; ++i) {
            long factor = Math.max(divideToCeil(t, T[i]), divideToCeil(a, A[i]));

            t = T[i] * factor;
            a = A[i] * factor;
        }

        return t + a;
    }

    static long divideToCeil(long x, int y) {
        return (x + y - 1) / y;
    }
}

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

int main() {
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	((A[0] == 5 && A[1] == 5 && A[2] == 7)) ? printf("YES\n") : printf("NO\n");
	return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    int curr = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x == curr) {
            curr++;
        }
    }

    if (curr == 1) {
        cout << -1 << endl;
    } else {
        cout << n - curr + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256