akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<P, vector<P>, greater<P>> que;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        que.push({a, b});
    }

    ll ans = 0;
    priority_queue<int> candidate;
    for(int d = 1; d <= m; d++){
        auto t = que.top();
        while(que.size() != 0 && t.first <= d){
            if(t.first <= d){
                que.pop();
                candidate.push(t.second);
                t = que.top();
            }
        }
        if(candidate.size() != 0){
            ans += candidate.top();
            candidate.pop();
        }
    }

    cout << ans << endl;
}

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

vector<pair<ll,int>> fac(ll n){
  vector<pair<ll,int>> ans;
  for(ll i=2;i*i<=n;i++){
    if(n%i)continue;
    ans.emplace_back(i,0);
    while(n%i==0){
      n /= i;
      ans.back().second++;
    }
  }
  if(n!=1) ans.emplace_back(n,1);
  return ans;
}

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

int main(){
  ll a,b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = fac(g);
  ll ans = f.size()+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Devarshi

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync


int n;
ld t,a;
cin>>n>>t>>a;
int ans;
ld maam;
forn(i,n){
  ld h;
  cin>>h;
  ld tp = t-0.006*h;
  ld dif=a-tp;
  if(dif<0.0) dif=-dif;
  if(i==0){ans=i+1; maam=dif;}
  else{
    if(maam>dif){
      maam=dif;
      ans=i+1;
    }
  }
 // double tp=t-(double)h*(0.006)
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())
H = list(map(int, input().split()))

flag = np.full(N, True)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        flag[B-1] = False
    if H[B-1] >= H[A-1]:
        flag[A-1] = False

print(np.count_nonzero(flag))
     


Measured memory_bytes: 38388
#include<stdio.h>

#define MAX 2000000000

int H,A[MAX];

void maxHeapify(int);

int main(){
  int i;

  scanf("%d",&H);

  for(i=1;i <=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=H/2;i >= 1;i--){
    maxHeapify(i);
  }

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;

}

void maxHeapify(int i){
  int l,r,largest,tmp;

  l=i*2;
  r=i*2+1;

  if( l  <=  H  &&  A[l]  >  A[i]){
    largest=l;
  }
  else {
    largest=i;
  }

  if(r  <= H  &&  A[r]  >  A[largest]){
    largest=r;
  }

  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }

}



Measured memory_bytes: 3652
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    def dfs(p, g, pre=-1):
        for e in edg[p]:
            if e == pre: continue
            if e == g:
                return [d[(p, e)]]
            tmp = dfs(e, g, p)
            if tmp:
                return tmp + [d[(p, e)]]
        return False

    n = II()
    edg = [[] for i in range(n)]
    t = 0
    ab = defaultdict(int)
    d = defaultdict(int)
    for _ in range(n - 1):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
        d[(a, b)] = t
        d[(b, a)] = t
        t += 1
    m = II()
    path = [0] * m 
    uv = LIR_(m)
    for i, uvi in enumerate(uv):
        u, v = uvi
        pat = dfs(u,v)
        for p in pat:
            path[i] |= 1 << p
    ans = 1 << (n - 1)
    for mask in range(1, 1 << m):
        tmp = 0
        t = 0
        for i in range(m):
            if mask & (1 << i):
                t += 1
                tmp = tmp | path[i]
        x = 0
        while tmp:  
            x += tmp & 1
            tmp >>=1
        ans += (1 << (n - x - 1)) * (-1) ** t
    print(ans)


    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 43116
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back
#define mp make_pair
#define ll long long
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vll;

void solve(){
    int n,x,t,nm,ans=0;
    cin>>n>>x>>t;
    if(n%x==0){
        nm = n/x;
        ans = nm*t;
    }else{
        nm = n/x +1;
        ans = nm*t;
    }
   cout<<ans;
}

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








Measured memory_bytes: 3636
#include <bits/stdc++.h>
int main()
{
  int n, m;
  std::cin>>n>>m;
  if(n>12)
  {
    std::cout<<m;
  }
  else if(n>5)
  {
    std::cout<<m/2;
  }
  else
  {
    int a=0;
    std::cout<<a;
  }
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    vector<long long> b(n);
    for (int i=0; i<n;i++) cin>>a[i]>>b[i];
    
    vector<int> id(n);
    iota(id.begin(), id.end(),0);
    sort(id.begin(), id.end(), [&](int i, int j){
        return b[i] < b[j];});
    long long sum=0;
    bool flag=true;
    for (auto i: id) {
        sum+=a[i];
        if (sum>b[i]) flag=false;
    }
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 7140
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        
        int n;
        int[]R;
        
        Scanner scan = new Scanner(System.in);       
        n = scan.nextInt();
        R = new int[n];
        
        for(int i=0 ; i < n;i++) {
            R[i] = scan.nextInt();
        }
        
        
         int answer = R[1] - R [0] ; 
         int min = R[0];
        
        for (int i = 1 ; i < n; i++){
                    if (R[i] - min > answer) answer = R[i] - min;
                    if(min> R[i]) min = R [i];
                

            } 

       
        System.out.println(answer);
    }
  }

Measured memory_bytes: 97524
#include<iostream>
using namespace std;
int main(){
	int n;
  cin>>n;
  int x = n%10;
  if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout<<"hon"<<endl;
  else if(x == 0 || x == 1 || x == 6 || x == 8) cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
}


Measured memory_bytes: 3624
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut maxp = 0;
    let mut sump = 0;
    for _ in 0..n {
        let p = read(&mut stdin_lock, &mut buf, b'\n');
        maxp = max(maxp, p);
        sump += p;
    }
    let ans = sump - maxp + maxp / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := intScanner(), intScanner(), intScanner()
	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0,max=0;
  char c;
  cin >> n;
 
  for(int i=0;i<n;i++){
    cin >> c;
    if(c == 'I'){
      ans++;
      if(ans > max ) max=ans;
    }else{
      ans--;
    }
  }

  cout << max << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    long N, A, B;
    long X[100000];
    long ans = 0;
    cin >> N >> A >> B;
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    for(int i = 1; i < N; i++){
        if((X[i]- X[i-1])*A > B){
            ans += B;
        }else{
            ans += (X[i]- X[i-1])*A;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/



int main(){
	int n, k;
	cin >> n >> k;
	if (n%k == 0)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

typedef struct P{
    int parent;
    int left;
    int right;
}Node;

void pre(Node node[],int n){
    if(n==-1){return;}
    printf(" %d",n);
    pre(node,node[n].left);
    pre(node,node[n].right);
}

void ino(Node node[],int n){
    if(n==-1){return;}
    ino(node,node[n].left);
    printf(" %d",n);
    ino(node,node[n].right);
}

void post(Node node[],int n){
    if(n==-1){return;}
    post(node,node[n].left);
    post(node,node[n].right);
    printf(" %d",n);
}

int main(void){
    int n,i,j,k,l;
    Node *node;
    scanf("%d",&n);
    node = (Node*)malloc(sizeof(Node)*n);
    for(i=0;i<n;i++){
        node[i].parent = -1;
        node[i].left = -1;
        node[i].right = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d",&k);
        scanf("%d",&l);
        node[k].left = l;
        node[l].parent = k;
        scanf("%d",&l);
        node[k].right = l;
        node[l].parent = k;
    }
    
    for(i=0;i<n;i++){
        if(node[i].parent==-1){
            k = i;
            break;
        }
    }

    printf("Preorder\n");
    pre(node,k);
    printf("\nInorder\n");
    ino(node,k);
    printf("\nPostorder\n");
    post(node,k);
    printf("\n");
    
    
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int D[100][2];
    for (int i = 0; i < N; i++) {
        int DD;
        scanf("%d", &DD);
        D[i][0] = DD;
        scanf("%d", &DD);
        D[i][1] = DD;
    }
    bool flag = false;
for (int i = 0; i < N-2; i++) {
    if (D[i][0] == D[i][1] && 
        D[i+1][0] == D[i+1][1] && 
        D[i+2][0] == D[i+2][1] ) {
        flag = true;
        break;
    }
} 
if(flag) {
    cout << "Yes" << endl;
} else {
        cout << "No" << endl;

}

    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;


int main(){
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll t,i,q,j,x,y,k,temp,temp2,z,l,tt,n,m,sum=0;
    cin >> x >> y >> z >> k;
    while(y<=x){
        y*=2;
        k--;
    }
    while(z<=y){
        z*=2;
        k--;
    }
    if(k<0){
        cout << "No\n";
    }
    else cout << "Yes\n";
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    string s;
    cin >> s;
    cout << "2018/01" << s.substr(7, 23) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static String z;
    static ArrayList<String>arr ;


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        z="";
        int n = word.length()-1;
        arr = new ArrayList<>();
        for(int i=0;i<word.length();i++){
            if(i!=word.length()-1)z+=word.charAt(i)+" ";
            else z+=word.charAt(i);
        }

        solve(0,n,"");
        long sum=0;
        for(String f : arr){
            String acc = "";
            for(int i=0;i<f.length();i++){
                if(f.charAt(i)=='+'){
                    sum+= Long.parseLong(acc);
                    acc="";
                }
                else {
                   acc+=f.charAt(i);
                }
            }
            sum+= Long.parseLong(acc);

        }
        System.out.println(sum);

    }

    public static void solve(int start, int n,String acc){
        if(start==n){
            String res="";
            for(int i=0,j=0;i<z.length();i++){
                if(z.charAt(i)==' '){
                    if(acc.charAt(j++)=='+')res+='+';
                }
                else res+=z.charAt(i);
            }

            arr.add(res);
        }
        else{
            solve(start+1,n,acc+" ");
            solve(start+1,n,acc+"+");
        }
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

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

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

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

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

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

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 28140
def num2alpha(n):
    if n <= 26:
        return chr(n + 96)
    elif n % 26 == 0:
        return num2alpha(n // 26 - 1) + chr(122)
    else:
        return num2alpha(n // 26) + chr(96 + n % 26)
print(num2alpha(int(input())))

Measured memory_bytes: 9192
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

int K;

int main() {
	cin >> K;
	cout << (K / 2) * ((K + 1) / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  ll diff = abs(n - m);
  if (diff >= 2) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  FOR(i, 1, n + 1) {
    ans *= i;
    ans %= MOD;
  }
  FOR(i, 1, m + 1) {
    ans *= i;
    ans %= MOD;
  }

  if (diff == 0) {
    cout << (ans * 2) % MOD << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 998244353
#define MAX 500005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,m;
long long fac[MAX],facinv[MAX],pwn1[MAX],pwm1[MAX];
long long mo(long long x)
{
	return x<mod?x:x-mod;
}
long long quick_pow(long long x,long long y)
{
	long long re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
long long C(long long down,long long up)
{
	return fac[down]*facinv[down-up]%mod*facinv[up]%mod;
}
int main()
{
	n=read();m=read();
	int up=max(n,m);
	fac[0]=1;
	for(int i=1;i<=up;i++)
		fac[i]=fac[i-1]*i%mod;
	facinv[up]=quick_pow(fac[up],mod-2);
	for(int i=up;i;i--)
		facinv[i-1]=facinv[i]*i%mod;
	pwn1[0]=1;
	for(int i=1;i<=m;i++)
		pwn1[i]=pwn1[i-1]*(n+1)%mod;
	pwm1[0]=1;
	for(int i=1;i<=n;i++)
		pwm1[i]=pwm1[i-1]*(m+1)%mod;
	long long ANS=0;
	for(int i=0;i<=min(n,m);i++)
		if(!(i&1)) ANS=(ANS+C(n,i)*C(m,i)%mod*fac[i]%mod*pwm1[n-i]%mod*pwn1[m-i])%mod;
		else ANS=mo(ANS-C(n,i)*C(m,i)%mod*fac[i]%mod*pwm1[n-i]%mod*pwn1[m-i]%mod+mod);
	printf("%lld",ANS);
	return 0;
}

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

int main() {
  int i, r, n;
  cin >> n >> r;
  i = n >= 10 ? r : r + 100*(10-n);
  cout << i << endl;
  
  return 0;
}

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

const int ALP_SIZE = 26;

int main(){
	std::string str;
	int counts[ALP_SIZE] = {};

	while (std::cin >> str)
	{
		for (size_t i = 0; i < str.length(); i++)
		{
			if (str[i] >= 'a' && str[i] <= 'z')
			{
				++counts[str[i] - 'a'];
			}
			else if (str[i] >= 'A' && str[i] <= 'Z')
			{
				++counts[str[i] - 'A'];
			}
		}
	}
	{
		char alp = 'a';
		for (const auto& count : counts)
		{
			std::printf("%c : %d\n", alp, count);
			++alp;
		}
	}
}


Measured memory_bytes: 3256
def abc_147_b
    s = gets.chomp
    if s.length == 1
        puts 0
    else
        m = s.length / 2
        cnt = 0
        for i in 0..(m-1)
            cnt += 1 unless s[i] == s[-1*(i+1)]
        end
        puts cnt
    end
end

abc_147_b

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

const int inf = 1e9 + 1e5;

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

	VI shops(n, 0);
	VVI P(n, VI(11, 0));
	for (int i = 0; i < n; i++) {
		int tmp = 0;
		for (int j = 0; j < 10; j++) {
			cin >> f;
			tmp <<= 1;
			tmp |= f;
		}
		shops[i] = tmp;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < P[0].size(); j++) {
			cin >> P[i][j];
		}
	}

	int limit = 1 << 10;
	int ans = -inf;
	for (int i = 1; i < limit; i++) {
		int profit = 0;
		for (int j = 0; j < n; j++) {
			profit += P[j][__builtin_popcount(i & shops[j])];
		}
		ans = max(ans, profit);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=8 && b<=8){
		cout<<"Yay!"<<endl;
		return 0;
	}
	else{
		cout<<":("<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for (ll i = 0; i < 1000; i++)
    {
        string pin;
        ss.str("");                      // バッファクリア
        ss.clear(stringstream::goodbit); // 状態クリア
        ss.copyfmt(init_ss);             // 書式クリア
        ss << setw(3) << setfill('0') << i;
        ss >> pin;
        ll k = 0;
        for (ll j = 0;; j++)
        {
            if (k == 3)
            {
                ans++;
                break;
            }
            if (j == n)
                break;
            if (pin[k] == s[j])
                k++;
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


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

#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second

using namespace std ;

int z , o ;

int ans = 1 , ansa = 0 ; 

int main(){

	int a[3] ;
	for(int i = 0 ; i < 3 ; i ++ ){
		cin >> a[i] ;
	}

	swap( a[0] , a[1] );
	swap( a[0] , a[2] );

	for( int i = 0 ; i < 3 ; i ++ ){
		cout << a[i] << ' ';
	}

	return 0 ;

}

Measured memory_bytes: 256
String.prototype.splitByIndention = function () {
        return this.split('\n');
};
String.prototype.splitBySpace = function () {
        return this.split(' ');
};
Array.prototype.parseIntToEach = function () {
        return this.map(parseFloat);
};
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

function main(input){
  const K = input[0];
  const X = input[1];
  
  console.log(Array(K * 2 - 1).fill(X - K + 1).map((value,index) => value + index).join(' '));
}
main(input.splitBySpace().parseIntToEach());

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
 
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}
 
ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return 
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}
 
 
 
/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;

int main()
{
    IO;
	int n,m;
	cin>>n>>m;
	if(n!=m) cout<<"No";
	else cout<<"Yes";
	
	
	return 0;
}



















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    vector<ll> xvec(n, 0);
    vector<ll> yvec(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> xvec[i] >> yvec[i];
    }

    vector<ll> xy0;
    vector<ll> xy1;
    for(int i = 0; i < n; ++i) {
        xy0.emplace_back(xvec[i]-yvec[i]);
        xy1.emplace_back(xvec[i]+yvec[i]);
    }

    sort(xy0.begin(), xy0.end());
    sort(xy1.begin(), xy1.end());
    ll ans = max((xy0[n-1]-xy0[0]), (xy1[n-1]-xy1[0]));
    cout << ans << endl;
}

Measured memory_bytes: 9748
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            int[] dp = new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0] = 0;
            dp[1] = Math.abs(ar[1] - ar[0]);
            for (int i = 2; i < n; i++)
                for (int d = 1; d <= k; d++)
                    if (i - d >= 0)
                        dp[i] = Math.min(dp[i], dp[i - d] + Math.abs(ar[i] - ar[i - d]));
                    else
                        break;
            out.println(dp[n - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

Measured memory_bytes: 34240
N = int(input())
words = []
for i in range(N):
    w = input()
    words.append(w)
ac_len = words.count('AC')
wa_len = words.count('WA')
tl_len = words.count('TLE')
re_len = words.count('RE')
print(f'AC x {ac_len}')
print(f'WA x {wa_len}')
print(f'TLE x {tl_len}')
print(f'RE x {re_len}')

Measured memory_bytes: 16284
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, M, K, Ans = 0;cin >> N >> M >> K;
vector<ll> A(N + 1, 0);
vector<ll> B(M + 1, 0);

    rep(i, 1, N + 1){
    ll a;cin >> a;
    A[i] = A[i - 1] + a;
    }

    rep(i, 1, M + 1){
    ll b;cin >> b;
    B[i] = B[i - 1] + b;
    }

    rep(i, 0, N + 1){
    auto Iter = upper_bound(ALL(B), K - A[i]);
    if(K - A[i] < 0)break;
    ll P = Iter - B.begin();
    Ans = max(Ans, i + P - 1);
    }

cout << Ans;
}

Measured memory_bytes: 6380
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    char c;
    cin>>c;
if((c=='a')||(c=='i')||(c=='u')||(c=='o')||(c=='e')){
    cout<<"vowel"<<endl;
}else{
    cout<<"consonant"<<endl;
}
}   



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private static Scanner sc;
    long n;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            n = sc.nextLong();

            List<Long> l = new ArrayList<>();
            for (long i = 1; i < Math.floor(Math.sqrt(n)) + 1; i++) {
                if (n % i == 0) {
                    l.add(i - 1);
                    if (i != n/i) {
                        l.add(n/i - 1);
                    }
                }
            }

            long sum = 0;
            for (long i: l) {
                if (i == 0) continue;
                if (n%i == n/i) sum += i;
            }
            System.out.println(sum);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

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

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

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

Measured memory_bytes: 23220
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int h, N, sum = 0;
  cin >> h >> N;
  int a[N];

  rep(i, N){
    cin >> a[i];
    sum += a[i];
  }

  if(h > sum) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;

bool binarySearch(int* array, int size, int object){
    int left = 0, right = size;
    while(left < right){
        int mid = (left + right) / 2;
        if(array[mid] == object) return true;
        else if(array[mid] > object) right = mid;
        else left = mid + 1;
    }

    return false;
}

int main(){
    int n, s[100000], q, t, ans = 0;

    cin >> n;
    for(int i=0; i<n; ++i) scanf("%d", &s[i]);
    cin >> q;
    
    while(q--){
        scanf("%d", &t);
        ans += binarySearch(s, n, t);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3496
def main():
    a, b, c = map(int, input().split())
    if 4*a*b < pow(c - (a + b), 2):
        ans = 'Yes'
    else:
        ans = 'No'
    if c - (a + b) <= 0:
        ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C && A % 2 == 0){
    cout << -1 << endl;
  } else {
    int cnt = 0;
    while (1){
      if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        long long A2 = (B + C) / 2;
        long long B2 = (C + A) / 2;
        long long C2 = (A + B) / 2;
        A = A2;
        B = B2;
        C = C2;
        cnt++;
      } else {
        break;
      }
    }
    cout << cnt << endl;
  }
}

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

int main(){
string S;
  cin>>S;
  if(S.at(0)!=S.at(1) && S.at(1)!=S.at(2) && S.at(2)!=S.at(0)){
  cout<<"Yes"<<endl;
  
  }  
else{cout<<"No"<<endl;

}  
  
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a1, a2, a3, a4, a5, a6, a7, a8, a9; cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6 >> a7 >> a8 >> a9;
	int bingo[3][3] = {{a1, a2, a3}, {a4, a5, a6}, {a7, a8, a9}};
	int blank[3][3] = {};
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		int x; cin >> x;
		for (int r = 0; r < 3; ++r) {
			for (int c = 0; c < 3; ++c) {
				if (bingo[r][c] == x) {
					blank[r][c] = 1;
				}
			}
		}
	}
	string result = "No";
	for (int r = 0; r < 3; ++r) {
		int rCount = 0;
		for (int c = 0; c < 3; ++c) {
			rCount += blank[r][c];
		}
		if (rCount == 3) result = "Yes";
	}
	for (int c = 0; c < 3; ++c) {
		int cCount = 0;
		for (int r = 0; r < 3; ++r) {
			cCount += blank[r][c];
		}
		if (cCount == 3) result = "Yes";
	}
	if (blank[0][0] + blank[1][1] + blank[2][2] == 3) result = "Yes";
	if (blank[2][0] + blank[1][1] + blank[0][2] == 3) result = "Yes";
	cout << result;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
int n;
int x[105];
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i];
	int mi = inf;
	for(int i = 1;i <= 100;i++){
		int tmp = 0;
		for(int j = 0;j < n;j++){
			tmp += (x[j]-i)*(x[j]-i);
		}
		mi = min(tmp,mi);
	}
	cout << mi << endl;
    return 0;
}


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

using ll = long long;

const ll MOD = 1e9+7;

int main() {
   int H, W, K;
   cin >> H >> W >> K;
   --K;

   ll dp[H+1][W];
   fill(dp[0], dp[H+1], 0);
   dp[0][0] = 1;

   for (int h = 0; h < H; h++) { // それぞれの高さについてループを回す
      for (int b = 0; b < (1<<(W-1)); ++b) { // bit全探索のループ

      // 横線が隣り合っていないかチェック
         bool judge = true;
         for (int i = 0; i < W-2; ++i) {
            // これで末尾が11のときにはじくことが出来る
            if (((b >> i) & 3) == 3) judge = false;
         }

         if (!judge) continue;

         int perm[W];
         for (int i = 0; i < W; ++i) perm[i] = i;

         for (int i = 0; i < W-1; ++i) {
            if ((b >> i) & 1) swap(perm[i], perm[i+1]);
         }

         for (int i = 0; i < W; ++i) {
            dp[h+1][perm[i]] += dp[h][i];
            dp[h+1][perm[i]] %= MOD;
         }
      }
   }

   cout << dp[H][K] << endl;

   return 0;
}

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

long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

int main() {
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: */
  /* stocahstic */
  for (int t = 1; t <= 500; ++t) {
    for (int dd = 0; dd < n; ++dd) {
      for (int tt = 0; tt < 26; ++tt) {
        if (tt == options[dd]) continue;
        int ot = options[dd];
        long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                            options, dd, tt, ot);
        //cout << ns << endl;
        if (ns > 0) {
          total += ns;
          options[dd] = tt;
    	}
      }
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll ans = 0;
    while(*max_element(ALL(a)) > n-1){
        dump(a);
        ll S = 0;
        rep(i, n){
            S += a[i]/n;
        }
        rep(i, n){
            a[i] += S - a[i]/n - a[i]/n*n;
        }
        ans += S;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main(){
	int N,T,A;
  	scanf("%d",&N);
	scanf("%d %d",&T,&A);
	double best_height = 45600;
	int best_id = 0;
	int hi,tmp;
	
	//printf("%d",N);
	//printf("%d %d\n",T,A);
	for(int i=0;i<N;i++){
		scanf("%d", &hi);
		if(abs(T-0.006*hi-A)<best_height){
			best_height = abs(T-0.006*hi-A);
			best_id = i+1;
		}
		//printf("%d ",hi);
 
	}
	printf("%d\n",best_id);
 
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int mod = 2 * K;
    auto MAP = make_v(2, mod + 1, mod + 1, 0);  // Black, White
    int Bsum = 0, Wsum = 0;
    REP(i, 0, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= mod;
        y %= mod;
        MAP[c == 'W'][y + 1][x + 1]++;
        Bsum += (c == 'B');
        Wsum += (c == 'W');
    }
    REP(k, 0, 2) {
        REP(i, 0, mod + 1) {
            REP(j, 0, mod) {
                MAP[k][i][j + 1] += MAP[k][i][j];
            }
        }
        REP(j, 0, mod + 1) {
            REP(i, 0, mod) {
                MAP[k][i + 1][j] += MAP[k][i][j];
            }
        }
    }

    function<int(int, int, int, int, int)> func = [&](int c, int x, int y, int nx, int ny) {
        auto &mp = MAP[c];
        if (x > mod) {
            x -= mod;
            nx -= mod;
            return func(c, x, y, nx, y);
        }
        if (y >= mod) {
            y -= mod;
            ny -= mod;
            return func(c, x, y, nx, ny);
        }
        if (nx <= mod && ny <= mod) {
            return mp[ny][nx] - mp[ny][x] - mp[y][nx] + mp[y][x];
        } else if (nx <= mod && ny > mod) {
            ny -= mod;
            return func(c, x, y, nx, mod) + func(c, x, 0, nx, ny);
        } else if (nx > mod && ny <= mod) {
            nx -= mod;
            return func(c, x, y, mod, ny) + func(c, 0, y, nx, ny);
        } else {
            nx -= mod;
            ny -= mod;
            return func(c, x, y, mod, mod) + func(c, 0, 0, nx, ny) + func(c, 0, y, nx, mod) + func(c, x, 0, mod, ny);
        }
    };

    int ans = 0;

    REP(y, 0, K) {
        REP(x, 0, K) {
            int ny = y + K, nx = x + K;
            int b1 = func(0, x, y, nx, ny), b2 = func(0, nx, ny, nx + K, ny + K);
            int rb = Bsum - b1 - b2;
            int w1 = func(1, x, y, nx, ny), w2 = func(1, nx, ny, nx + K, ny + K);
            int rw = Wsum - w1 - w2;
            /*
            dump(x);
            dump(y);
            dump(b1);
            dump(b2);
            dump(rb);
            dump(w1);
            dump(w2);
            dump(rw);
            cout << endl;
            //*/
            ans = max({ans, b1 + b2 + rw, rb + w1 + w2});
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 49408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=1e5+10;
int n,q;
int a[maxn];
priority_queue<P>que;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
     scanf("%d",&a[i]);
        int x,y;

        sort(a,a+n);
 for(int i=0;i<m;i++)
 {
   scanf("%d%d",&x,&y);
     que.push({y,x});
 }
  for(int i=0;i<n;i++)
  {
      int x=a[i];
      if(!que.empty()&&que.top().first>x)
      {
          a[i]=que.top().first;
          if(que.top().second-1==0)
            que.pop();
          else
          {
                int v=que.top().second-1;
                int w=que.top().first;
                que.pop();
                que.push({w,v});
          }
      }
      else
        break;
  }
  ll ans=0;
  for(int i=0;i<n;i++)
    ans+=a[i];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1784