akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	w := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i])
	}

	last := w[0]
	words := []string{w[0]}
	for i := 1; i < n; i++ {
		if !ok(w[i], last, words) {
			fmt.Println("No")
			return
		}
		words = append(words, w[i])
		last = w[i]
	}
	fmt.Println("Yes")
}

func ok(s, last string, words []string) bool {
	if last[len(last)-1] != s[0] {
		return false
	}
	for _, w := range words {
		if s == w {
			return false
		}
	}
	return true
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define forn(n1,n2) for(ll i=n1;i<n2;i++)
#define w(t) ll t;cin>>t;while(t--)
#define en "\n"
#define mod 1e6+3
#define f first
# define s second
using namespace std;
ll i,n,m,x,y,z,j,k,l,mn=LLONG_MAX,mx=0,c,a[100005],r,cnt=0,sum=0;
string str;char ch;set<ll>s;map<ll,ll>mp;
vector<vector<ll>>g;
vector<ll>v;
void swap(int *xp, int *yp)  
{  
    int temp = *xp;  
    *xp = *yp;  
    *yp = temp;  
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;ll a[n];
    forn(0,n)cin>>a[i];
    ll mx=0,step=0;
    forn(0,n)
    {
        mx=max(mx,a[i]);
        step+=mx-a[i];
    }
    cout<<step;
    return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;

class State
{
public:
	int p,c,f;
	State(int p, int c, int f)
	:p(p),c(c),f(f)
	{}

	bool operator<(const State& s) const
	{
		return c>s.c;
	}
};

int f[30][30];
bool v[(1<<16)];

int main()
{
	int N;
	while(cin  >> N, N)
	{
		memset(v,0,sizeof(v));

		for(int i=0; i<N; i++)
		for(int j=0; j<N+1; j++)
			cin >> f[j][i];

		priority_queue<State> q;
		for(int i=0; i<N; i++)
			q.push(State(i,f[0][i],(1<<i)));

		while(!q.empty())
		{
			State s=q.top(); q.pop();
			if(v[s.f]) continue;
			v[s.f]=1;
			if(s.f == (1<<N)-1)
			{
				cout << s.c << endl;	
				break;
			}
			
			for(int i=0; i<N; i++)
			{
				int nc=f[0][i];
				int nf=s.f;
				if(nf&(1<<i)) continue;
				for(int j=0; j<N; j++)
				{
					if(s.f&(1<<j)) nc=min(nc, f[j+1][i]);
				}

				nf|=(1<<i);
				if(v[nf]) continue;
				q.push(State(i,s.c+nc, nf));
			}
		}
	}
}
	

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int x = 0, max_x = 0;

  for(int i=0; i < N; i++) {
    if(S[i] == 'I') {
      x++;
      max_x = max(max_x, x);
    }else if(S[i] == 'D') {
      x--;
    }
  }
  cout << max_x << endl;
}



Measured memory_bytes: 3560
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n,k;

int main() {
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n){
        cin >> h[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    FOR(i,1,n){
        FOR(j,1,k+1){
            if(0<=(i-j)){
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    put(dp[n-1]);
    return 0;
}




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

int **memory(int h, int w)
{
  int **A;
  A = (int**)malloc(sizeof(int*)*h);
  for(int i=0; i<h; i++){
    A[i] = (int*)malloc(sizeof(int)*w);
  }
  return A;
}

int max(int a, int b)
{
  if(a>b){
    return a;
  } else {
    return b;
  }
}

int **input(int h, int w)
{
  int **A;
  A = memory(h,w);

  char tmp;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> tmp;
      if(tmp == '#'){
        A[i][j] = 0;
      } else {
        A[i][j] = 1;
      }
    }
  }

  return A;
}




int main()
{
  int h,w;
  cin >> h >> w;

  int **A,**L,**R,**D,**U;
  A = input(h,w);
  L = memory(h,w);
  R = memory(h,w);
  D = memory(h,w);
  U = memory(h,w);


  for(int i=0; i<h; i++){
    L[i][0] = A[i][0];
    for(int j=1; j<w; j++){
      L[i][j] = A[i][j]*(L[i][j-1]+1);
    }
  }

  for(int i=0; i<h; i++){
    R[i][w-1] = A[i][w-1];
    for(int j=w-2; j>=0; j--){
      R[i][j] = A[i][j]*(R[i][j+1]+1);
    }
  }

  for(int j=0; j<w; j++){
    U[0][j] = A[0][j];
    for(int i=1; i<h; i++){
      U[i][j] = A[i][j]*(U[i-1][j]+1);
    }
  }

  for(int j=0; j<w; j++){
    D[h-1][j] = A[h-1][j];
    for(int i=h-2; i>=0; i--){
      D[i][j] = A[i][j]*(D[i+1][j]+1);
    }
  }

  int tmp = 0;

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      tmp = max(tmp,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
    }
  }

  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 78592
//Name: Stray Cats, Run...
//Level: 4
//Category: 最大値最小化,二分探索,Binary search,貪欲,Greedy
//Note: 

/**
 * 最大値の最小化なので、最大値について二分探索する。
 *
 * 最初にすべての餌入れに餌を入れるものとする。
 * このとき、最大値を超えて集まっている餌入れがあった場合、その餌入れは使わないようにしないと解消できない。
 * したがって、その餌入れを除いて再配置する。
 * これを繰り返し、条件を満たすことができるかを試していく。
 *
 * 再配置はナイーブにやると O(NM) かかるが、あらかじめ猫がいる全ての点に対して、餌入れを近い順にソートしておくと
 * 1つの最大値についての計算全体で O(NM) にできる。
 *
 * オーダーは O((N^2 + NM) log MC)。
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

typedef pair<long long,long long> P;

struct Cat {
    P pos;
    int c;
};

inline long long norm(const P &a, const P &b) {
    const auto dx = a.first - b.first;
    const auto dy = a.second - b.second;
    return dx*dx + dy*dy;
}

bool solve(bool first) {
    int N, M;
    if(!(cin >> N >> M)) return false;
    if(!N && !M) return false;

    vector<Cat> cats(N);
    long long cat_sum = 0;
    for(int i = 0; i < N; ++i) {
        long long x, y;
        int c;
        cin >> x >> y >> c;
        cats[i] = Cat{P(x, y), c};
        cat_sum += c;
    }

    vector<P> ps(M);
    for(int i = 0; i < M; ++i) {
        long long x;
        cin >> x;
        ps[i] = P(x, 0);
    }
    sort(begin(ps), end(ps));

    vector<vector<int>> ord(N);
    for(int i = 0; i < N; ++i) {
        vector<pair<long long,int>> v;
        for(int j = 0; j < M; ++j) {
            v.emplace_back(norm(cats[i].pos, ps[j]), j);
        }
        sort(begin(v), end(v));
        for(auto e : v) {
            ord[i].push_back(e.second);
        }
    }

    long long left = 0, right = cat_sum;
    vector<long long> buf(M, 0);
    while(left+1 < right) {
        const long long LIM = (left + right) / 2;
        vector<bool> avail(M, true);
        vector<int> cursor(N, 0);
        int remain = M;
        bool ok = false;
        while(!ok && remain > 0) {
            fill(begin(buf), end(buf), 0);
            for(int i = 0; i < N; ++i) {
                while(!avail[ord[i][cursor[i]]]) ++cursor[i];
                assert(cursor[i] < ord[i].size());
                const int dest = ord[i][cursor[i]];
                buf[dest] += cats[i].c;
            }
            ok = true;
            for(int i = 0; i < M; ++i) {
                if(buf[i] > LIM) {
                    avail[i] = false;
                    --remain;
                    ok = false;
                }
            }
        }
        if(ok) {
            right = LIM;
        } else {
            left = LIM;
        }
    }
    cout << right << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 5248
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count_A = Counter(A)
n2c = {k:v*(v-1)//2 for k, v in count_A.items()}
base = sum(n2c.values())
ans = 0
for ai in A:
    count_ai = count_A[ai]
    if count_ai == 1:
        ans = base
    else:
        ans = base - n2c[ai] + ((count_ai - 1) * (count_ai - 2) // 2)
    print(ans)


Measured memory_bytes: 98124
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int M=sc.nextInt();
		
		
		
		for(int i=0;i<M;i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			
			if(!map.containsKey(a)) {
				map.put(a, new ArrayList<Integer>());
			}
			if(!map.containsKey(b)) {
				map.put(b, new ArrayList<Integer>());
			}
			map.get(a).add(b);
			map.get(b).add(a);
		}
		
		
		int v[]=new int[N];
		Queue<Integer> qq=new ArrayDeque<>(); 
		
		int sum=0;
		
		qq.add(1);
		while(sum<N&&qq.peek()!=null) {
			int t=qq.poll();
			ArrayList<Integer> cc=map.get(t);
			for(int i:cc) {
				if(v[i-1]==0) {
					v[i-1]=t;
					qq.add(i);
				}
			}
		}
		
	
		
		
	
	
		
		p("Yes");
		for(int i=1;i<N;i++) {
				p(v[i]);
		}
		
		
	}
	public static Map<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>(20001);	
		
	//static int ans=10000009;
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 85488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

int main() {
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  int x = 0, y = 0, z = 0;
  rep(i,n){
    int p;
    cin >> p;
    if (p <= a) x++;
    if (a+1 <= p && p <= b) y++;
    if (b+1 <= p) z++;
  }
  cout << min(x, min(y,z)) << endl;
  return 0;
}


Measured memory_bytes: 3544
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H, N = MI()
    AB = LLIN(N)

    dp = [inf]*(H+1)
    dp[0] = 0
    for a,b in AB:
        for h in range(H+1):
            if h>=a:
                dp[h] = min(dp[h], dp[h-a] + b)
            else:
                dp[h] = min(dp[h], b)

    print(dp[H])
if __name__ == '__main__':
    main()

Measured memory_bytes: 70104
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		ll v = -max( max(a * a, b * b), c * c ) + a * a + b * b + c * c;
		int n; cin >> n;
		for (int i = 0; i < n; ++i) {
			ll r; cin >> r;
			r *= 2;
			r *= r;
			if (r > v) cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
ll cost(ll n,ll m){
    ll s = abs(n - m);
    return s * s;
}
int main() {
    ll N;
    cin >> N;
    ll n = 0;
    ll wa = 0;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
        wa += vec[i];
    }
    wa /= N;
    ll num = wa+1;
    ll ans = 0;
    ll kane = 0;
    rep(i,N){
        ans += cost(wa,vec[i]);
    }
    rep(i,N){
        kane += cost(num,vec[i]);
    }
    cout << min(kane,ans) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

ll n;
long double tmp;
ll ans;
int main(void) {
    cin >> n;
    tmp = n/2.0;
    ans = tmp*(n-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ban = N if N%2 else N+1
ans = []
for i in range(1,N):
    for j in range(i+1,N+1):
        if i+j == ban: continue
        ans.append((i,j))

print(len(ans))
for a,b in ans:
    print(a,b)

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int m;
  cin >> m;
  cout << 48 - m << endl;
  return 0;
}


Measured memory_bytes: 256
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let rec binary_search left right eval =
  if right - left <= 1 then right
  else
    let mid = (left + right) / 2 in
    if eval mid then binary_search left mid eval
    else binary_search mid right eval

let eval a f n k value =
  let require = ref 0 in
  let _ =
    for i = 0 to n-1 do
      require := !require + max 0 (a.(i) - value / f.(i))
    done in
  !require <= k

let init_val = int_of_float 1e12

let solve () =
  let n = scan_int() and k = scan_int() in
  let a = scan_array n scan_int in
  let f = scan_array n scan_int in
  let _ = Array.fast_sort (fun x y -> x - y) a in
  let _ = Array.fast_sort (fun x y -> y - x) f in
  binary_search (-1) init_val (eval a f n k)


let () = print_int (solve())

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


int main () {

	int a,b,c,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		
		if(a>b){
			int temp=a;
			a=b;
			b=temp;
		}
		if (b>c) {
			int t=b;
			b=c;
			c=t;
		}
		if(a>b){
			int d=a;
			a=b;
			b=d;
		}
		if(c*c==a*a+b*b)
			cout << "YES" << endl;
		else{
			cout<< "NO" << endl;
		}
		
	}
		
		
	
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+2,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll arr[M],subtree[M]={0};
ll cnt=0,cost=0,mx=0,NODE,t,par,zero=0,pos=0,neg=0;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    //freopen("kamona.txt","r",stdin);
    ll a,b,c,n,t,sum=0,mx=0,l,x,y,i=0,j=0,res,m,second=0,d;
    cin>>a;
    sum=3*a*a;
    cout<<sum<<endl;

    return 0;
}


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

def prime(x):
    if x==1: return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

N=int(input())
ans=0
for i in range(N):
    if prime(int(input())):
        ans+=1
print(ans)


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;
    if(s.length()<26){
        for(char c = 'a'; c <= 'z'; c++){
            if(s.find(c)==-1){
                cout << s << c << endl;
                return 0;
            }
        }
    }
    else {
        set<char> x;
        while(!s.empty()){
            char c = s.back();
            x.insert(c);
            s.pop_back();
            if(c != *x.rbegin()){
                cout << s << *x.upper_bound(c) << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll sum;
ll x;
int main(){
  ll x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

string s;

int mlen(int p)
{
	int r=0;
	for(int i=p;i<s.length();i++)
	{
		if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T')
		{
			break;
		}
		r++;
	}
	return r;
}

int main()
{
	int r=0;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		r=max(mlen(i),r);
	}

	cout<<r<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
int main() {
    cin>>N>>M;
    vec div(0);
    ll k = -1;
    reps(i,2,M+1){
        if(M%i == 0) {
            div.push_back(0);
            ++k;
        }
        while(M%i == 0) {
            M /= i;
            ++div[k];
        }
        if(i*i > M) break;
    }
    if(M != 1) div.push_back(1LL);
    vec nCm(35,1);
    rep(i,34){
        ll temp = nCm[i];
        (temp *= N + i) %=MOD;
        (temp *= fastpow(i+1, MOD - 2))%=MOD;
        nCm[i+1] = temp;
    }
    ll ans = 1;
    for(ll d : div){
        //cout<<d<<endl;
        (ans *= nCm[d])%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S,T;
	cin>>S>>T;
	int ans=1e9;
	for(int i=0;i+T.length()<=S.length();i++){
		int c=0;
		for(int j=0;j<T.length();j++){
			c+=T[j]!=S[j+i];
		}
		ans=min(ans,c);
	}
	cout<<ans;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    long n;
    while(cin>>n)
    {
        if(n<1200)
        {
            cout<<"ABC\n";
        }
        else
            cout<<"ARC\n";
    }
    return 0;
}


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

using namespace std;

typedef long long int __int64;

const int N = 2e5 + 10;
__int64 nums[N];
map<__int64, __int64> dict; 

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> nums[i];
		dict[nums[i]]++;
	}
	__int64 ans = 0;
	for(int i = 1; i <= n; i++)
		ans += (dict[i] * (dict[i]-1)) / 2;
	for(int i = 1; i <= n; i++) {
		int inp = nums[i];
		ans -= (dict[inp] * (dict[inp]-1)) / 2;
		dict[inp]--;
		ans += (dict[inp] * (dict[inp]-1)) / 2;
		cout << ans << "\n";
		ans -= (dict[inp] * (dict[inp]-1)) / 2;
		dict[inp]++;
		ans += (dict[inp] * (dict[inp]-1)) / 2;
	}
	
	return 0;
}

Measured memory_bytes: 16640
N = input()
cnt = 0

if int(N) < 357:
    print(0)
    exit()

def solve(s):

    global cnt
    

    if len(s) >= 3:
        if int(s) > int(N):
            return

        n7 = s.count("7")
        n5 = s.count("5")
        n3 = s.count("3")

        if n7 >= 1 and n5 >= 1 and n3 >= 1 and n7+n5+n3 == len(s) and int(s) <= int(N):
            cnt += 1
        
    solve(s+"7")
    solve(s+"5")
    solve(s+"3")

solve("")
print(cnt)
    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	char col[5] = "RYGB";
	int h, w, d;
	cin >> h >> w >> d;
	for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            printf("%c", col[((i + j) / d & 1) << 1 | ((i - j + w) / d & 1)]);
        }
        printf("\n");
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

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;
}

const ll MOD = 1000000007;

bool is_all_zero(const vector<ll> &A) {
    for (int i = 0; i < (int) A.size(); i++) {
        if (A[i] != 0) {
            return false;
        }
    }
    return true;
}

ll solve(vector<ll> &A) {
    vector<int> res;
    ll carry = 0;
    while (!is_all_zero(A)) {
        ll count_zero = 0;
        ll count_one = 0;
        for (int i = 0; i < (int) A.size(); i++) {
            if (A[i] % 2 == 0) {
                count_zero++;
            } else {
                count_one++;
            }
            A[i] >>= 1;
        }
        ll acc = count_zero * count_one;
        res.push_back((acc + carry) % 2);
        carry = (acc + carry) / 2;
    }

    while (carry > 0) {
        res.push_back(carry % 2);
        carry >>= 1;
    }

    reverse(res.begin(), res.end());

    // for (int i = 0; i < (int) res.size(); i++) {
    //     cout << res[i] << " ";
    // }
    // cout << endl;

    ll answer = 0;
    for (int i = 0; i < (int) res.size(); i++) {
        answer = (((answer * 2) % MOD) + res[i]) % MOD;
    }
    return answer;
}

int main(void) {
    int N;
    cin >> N;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << solve(A) << endl;
    
    return 0;
}


Measured memory_bytes: 2560
S = input()
l = len(S)
k = 'keyence'
if S == k:
  print('YES')
elif S[len(S)-7:len(S)] == k:
  print('YES')
elif S[0:1]+S[len(S)-6:len(S)] == k:
  print('YES')
elif S[0:2]+S[len(S)-5:len(S)] == k:
  print('YES')
elif S[0:3]+S[len(S)-4:len(S)] == k:
  print('YES')
elif S[0:4]+S[len(S)-3:len(S)] == k:
  print('YES')
elif S[0:5]+S[len(S)-2:len(S)] == k:
  print('YES')
elif S[0:6]+S[len(S)-1:len(S)] == k:
  print('YES')
elif S[0:7]== k:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int a[n+1];
    for(int i = 0; n > i; i++)cin>>a[i];
    int q;cin>>q;
    int ans = 0;
    for(int i = 0; q > i; i++){
        int s;cin>>s;
        a[n]=s;
        int j = 0;
        while(a[j]!=s)j++;
        if(j != n)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <iostream>
using namespace std;
const int NMAX=2e5+5;
int n,k,sol;
int a[NMAX];
int main()
{
    cin>>k>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sol=min(a[n]-a[1],a[1]+k-a[2]);
    for(int i=2;i<n;i++)
    {
        sol=min(sol,k-a[i]+a[i-1]);
        sol=min(sol,a[i]+k-a[i+1]);
    }
    sol=min(sol,k-a[n]+a[n-1]);
    sol=min(sol,a[n]-a[1]);
    cout<<sol;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int m[]={5,1,2,4,1,3,1,0,0,2,3,2,2,4,5,1,4,0,4,3,3,5,0,5};
int main(){
	for(int a,b,c,n,r,d;a=c=0,b=r=scanf("%d",&n),n;printf("%d\n",r)){
		for(char s[9];n--;r+=a%3?b%3?(b+6-a)%6<3?2:5:b?3:4:a?6:1){
			scanf("%s",s);
			d=-1;
			if(s[0]=='L')c+=3; 
			if(s[0]=='R')c++;
			if(s[0]=='W')d=1;
			if(s[0]=='N')d=0;
			if(s[0]=='E')d=3;
			if(s[0]=='S')d=2;
			if(d!=-1)
				a=m[4*a+(d+c)%4],
				b=m[4*b+(d+c)%4];
		}
	}
}

Measured memory_bytes: 0
n = int(input())
a = 0
b = n
total = []

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(1, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Measured memory_bytes: 3480
n = int(input().strip())

rooms = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(n):
    b, f, r, v = [int(i) for i in input().strip().split()]
    rooms[b-1][f-1][r-1] += v

for i in range(4):
    for line in rooms[i]:
        print(" "+" ".join([str(i) for i in line]))
    if i != 3:
        print("#"*20)



Measured memory_bytes: 5612
#include <stdio.h>
int main(){
    int i,j,a[3][3];
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    if(a[0][0]-a[0][1]==a[1][0]-a[1][1]&&a[0][0]-a[0][1]==a[2][0]-a[2][1]&&a[2][0]-a[2][1]==a[1][0]-a[1][1]&&
       a[0][0]-a[0][2]==a[1][0]-a[1][2]&&a[0][0]-a[0][2]==a[2][0]-a[2][2]&&a[2][0]-a[2][2]==a[1][0]-a[1][2]&&
       a[0][1]-a[0][2]==a[1][1]-a[1][2]&&a[0][1]-a[0][2]==a[2][1]-a[2][2]&&a[1][1]-a[1][2]==a[2][1]-a[2][2]&&
       a[0][0]-a[1][0]==a[0][1]-a[1][1]){
           printf("Yes");
       }else{
           printf("No");
       }
    return 0;
}


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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

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


Measured memory_bytes: 3624
from collections import defaultdict
from itertools import combinations

n = int(input())

mydict = defaultdict(lambda: 0)
s = []
for i in range(n):
	s.append(input())


for word in s:
	mydict[word[0]] += 1

ways = list(combinations("MARCH", 3))

total = 0
for way in ways:
	temp = mydict[way[0]]*mydict[way[1]]*mydict[way[2]]
	#print(way, temp)
	total += temp

print(total)

Measured memory_bytes: 10112
#include <stdio.h>
int main(void)
{
    int i,N;
    int a,b,c,a2,b2,c2;

    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%d %d %d",&a,&b,&c);

        a2=a*a;
        b2=b*b;
        c2=c*c;

        if(a2==b2+c2 || b2==c2+a2 || c2==a2+b2){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
        
    }

    return 0;
}


Measured memory_bytes: 2100
N, M = map(int, input().split())

AC = 0
WA = 0

list_AC = [-1] * N

P = []
S = []

for m in range(M):
    p, s = input().split()
    p    = int(p) - 1
    P.append(p)
    S.append(s)
    if s == 'AC':
        if list_AC[p] == -1:
            AC += 1
            list_AC[p] = m

for m in range(M):
    p = P[m]
    s = S[m]
    if s == 'WA':
        if list_AC[p] != -1:
            if m < list_AC[p]:
                WA += 1
print(AC, WA)


Measured memory_bytes: 17348
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	double d, t, s;
	cin >> d >> t >> s;
	if (d / s <= t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3704
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	//std::cout << std::fixed << std::setprecision(15);

	long long n;
	std::string s;
	std::cin >> n >> s;

	for (size_t i = 0; i < s.size(); ++i)
	{
		int diff = s.at(i) - 'A';

		std::cout << static_cast<char>('A' + (diff + n) % 26);
	}

	std::cout << std::endl;

	return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;



int main() {
  int n,a;
  cin >>n>>a;
  cout << n*n-a << endl;
}
      
       



Measured memory_bytes: 3604
#include <iostream>

 

using namespace std;

 

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


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int count;
  int ans = 1e7;
  for (int i = a[0]; i <= a[n - 1]; i++)
  {
    count = 0;
    for (int j = 0; j < n; j++)
    {
      count += (a[j] - i) * (a[j] - i);
    }
    if (count < ans)
      ans = count;
  }
  cout << ans << endl;
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll N;
vector<vector <pair<ll, ll>>> nbr;
vector<ll> vColor;

void dfs(ll parent, ll node, ll color) {
  vColor.at(node) = color;
  for (auto p : nbr.at(node)) {
    if (p.first == parent) continue;
    if (p.second % 2 == 0) {
      dfs(node, p.first, color);
    }else {
      dfs(node, p.first, 1 - color);
    }
  }
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N;
  nbr.resize(N+1);
  for (ll i = 1; i < N; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    nbr.at(u).push_back(make_pair(v, w));
    nbr.at(v).push_back(make_pair(u, w));
  }
  vColor.resize(N+1);
  dfs(-1, 1, 0);
  
  for (ll i = 1; i <= N; i++) {
    cout << vColor.at(i) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 10880
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)>abs(b-x))cout<<"B"<<endl;
	if(abs(a-x)<abs(b-x))cout<<"A"<<endl;
		return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();   // problems
        int M = sc.nextInt();   // submissions

        Set<Integer> s = new HashSet<>();
        int[] a = new int[N+1];
        int wa = 0;
        int ac = 0;

        for (int i = 0; i < M; i++) {
            int problemId = sc.nextInt();
            String ans = sc.nextLine().trim();
            if (!s.contains(problemId)) {
                if ("AC".equals(ans)) {
                    ac++;
                    wa += a[problemId];
                    s.add(problemId);
                } else {
                    a[problemId]++;
                }
            }
        }
        System.out.println(ac + " " + wa);
    }
}

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

using ll = long long;

struct Cake
{
    ll x, y, z;
};


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

    std::vector<Cake> c(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> c[i].x >> c[i].y >> c[i].z;
    }

    ll ans = 0;
    std::sort(c.begin(), c.end(), [](auto a, auto b) { return a.x + a.y + a.z > b.x + b.y + b.z; });
    ll x = 0, y = 0, z = 0;
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = x + y + z;
    x = 0; y = 0; z = 0;

    std::sort(c.begin(), c.end(), [](auto a, auto b) { return -a.x + a.y + a.z > -b.x + b.y + b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;

    std::sort(c.begin(), c.end(), [](auto a, auto b) { return a.x - a.y + a.z > b.x - b.y + b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;
    std::sort(c.begin(), c.end(), [](auto a, auto b) { return a.x + a.y - a.z > b.x + b.y - b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;
    std::sort(c.begin(), c.end(), [](auto a, auto b) { return -a.x - a.y + a.z > -b.x - b.y + b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;

    std::sort(c.begin(), c.end(), [](auto a, auto b) { return a.x - a.y - a.z > b.x - b.y - b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;

    std::sort(c.begin(), c.end(), [](auto a, auto b) { return -a.x + a.y - a.z > -b.x + b.y - b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;
    std::sort(c.begin(), c.end(), [](auto a, auto b) { return -a.x - a.y - a.z > -b.x - b.y - b.z; });
    for (int i = 0; i < M; i++)
    {
        x += c[i].x;
        y += c[i].y;
        z += c[i].z;
    }
    x = std::abs(x);
    y = std::abs(y);
    z = std::abs(z);
    ans = std::max(x + y + z, ans);

    x = 0; y = 0; z = 0;

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int x, r0, w0, r, c, ans = 0;
  
  while(1){
    cin >> r0 >> w0 >> c >> r;
    if(r0 == 0 && w0 == 0 && c == 0 && r == 0) break;
    
    for(x = 0 ; x < 100000 ; x++){
      if(w0 * c <= r0 + x*r) {
	ans = x;
	break;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3088
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			string s = Console.ReadLine();
			//int x = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			if (s == "ABC") {
				Console.WriteLine("ARC");
			} else {
				Console.WriteLine("ABC");
			}

		}
	}
}


Measured memory_bytes: 25736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n

int main(){
  LL h,w;
  cin >> h >> w;
  VS a(h);
  REP(i,0,h){
    cin >> a[i];
  }
  
  REP(i,0,h){
    bool white = true;
    REP(j,0,w){
      if(a[i][j] != '.'){
        white = false;
      }
    }
    if(white){
      a.erase(a.begin() + i);
      h--;
      i--;
    }
  }
  REP(j,0,w){
    bool white = true;
    REP(i,0,h){
      if(a[i][j] != '.'){
        white = false;
      }
    }
    if(white){
      REP(cnt,0,h){
        a.at(cnt).erase(a.at(cnt).begin() + j);
      }
      w--;
      j--;
    }
  }
  
  REP(i,0,h){
    cout << a[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3592
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
INF = float("inf")
from heapq import heappop, heappush

def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	A = getlist()
	left = 0
	leftlis = [0] * (N + 1)
	rightlis = [0] * (N + 1)
	Q = []
	for i in range(N):
		left += A[i]
		heappush(Q, A[i])
	leftlis[0] = left

	for i in range(N, 2 * N):
		heappush(Q, A[i])
		left -= heappop(Q)
		left += A[i]
		leftlis[i + 1 - N] = left

	Q = []
	right = 0
	for i in range(3 * N - 1, 2 * N - 1, -1):
		right -= A[i]
		heappush(Q, -A[i])

	rightlis[0] = right

	for i in range(2 * N - 1, N - 1, -1):
		heappush(Q, -A[i])		
		right -= heappop(Q)
		right -= A[i]
		rightlis[2 * N - i] = right

	rightlis = list(reversed(rightlis))
	# print(leftlis)
	# print(rightlis)
	ans = -INF
	for i in range(N + 1):
		ans = max(ans, leftlis[i] + rightlis[i])

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 107204
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

int main() {
		int N;
		cin >> N;
		int x[N], y[N];
		for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

		int ans = 1e9;
		for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
						if (i == j) continue;
						int cp = x[j] - x[i];
						int cq = y[j] - y[i];

						int cnt = 0;
						for (int k = 0; k < N; k++) {
								for (int l = 0; l < N; l++) {
										if (cp == x[l]-x[k] && cq == y[l]-y[k]) {
												cnt++;
										}
								}
						}
						ans = min(ans, N-cnt);
				}
		}

		if (N == 1) ans = 1;
		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N, R;
  while (cin>>N>>R, N+R!=0) {
    vector<int> x;
    for (int i = 0; i < N; i++) x.push_back(i+1);
    for (int i = 0; i < R; i++) {
      int p, c; cin>>p>>c;
      p = N-p-c+1;
      for (int j = 0; j < c; j++) {
        x.push_back(x[p]);
        x.erase(x.begin()+p);
      }
    }
    cout << x.back() << endl;
  }
}



Measured memory_bytes: 3068
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) = {
    val x = readLine.split(' ').map(x => x.toInt)
    println(
      if (x(0) < x(1)) "a < b"
      else if (x(0) > x(1)) "a > b"
      else "a == b"
    )
  }
}

Measured memory_bytes: 43724
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int pmax=0;
	int ans=0;
	for(int i=0;i<n;i++){
		int p;
		cin >> p;
		ans+=p;
		pmax=max(pmax,p);
	}
	cout << ans-pmax/2 << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

def dist(perm):
    d = 0
    x0, y0 = X[perm[0]]
    for i in perm[1:]:
        x1, y1 = X[i]
        d += ((x1-x0)**2 + (y1-y0)**2)**0.5
        x0 = x1
        y0 = y1
    return d

def main():
    d = 0
    perms = list(itertools.permutations(range(N)))
    for perm in perms:
        d += dist(perm)
    return d/len(perms)

print(main())

Measured memory_bytes: 8052
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n-1):
    for j in range(i+1, n):
        x_diff = []
        for k in range(len(x[i])):
            x_diff.append(x[i][k]-x[j][k])
        sq_x_diff = [i ** 2 for i in x_diff]
        sum_ = sum(sq_x_diff)**0.5
        if sum_.is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 80; 
const ll MOD = 1e9 + 7;
struct matrix{
	int n;
	ll v[MAXN][MAXN];
	matrix(int _n = 0){
		n = _n;
		memset(v, 0, sizeof(v));
	}
	matrix operator * (matrix m){
		matrix ans = matrix(n);
		for(int i = 1; i <= n; i++){
			for(int j = 1;  j <= n; j++){
				for(int k = 1; k <= n; k++){
					ans.v[i][j] += v[i][k]*m.v[k][j];
					ans.v[i][j] %= MOD;
				}
			}
		}
		return ans;
	}
	matrix operator ^ (ll k){
		matrix ans = matrix(n);
		for(int i = 1; i <= n; i++) ans.v[i][i] = 1;
		for(int i = 62; i >= 0; i--){
			ans = ans*ans;
			if(k&(1LL<<i)){ 
				ans = ans*(*this);			
			}
		}
		return ans;
	}
	ll sum(){
		ll ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				ans += v[i][j];
				ans %= MOD;
			}
		}
		return ans;
	}
};

matrix T;
int n;

ll k;
int main(){
	scanf("%d %lld", &n, &k);
	T = matrix(n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			scanf("%lld", &T.v[i][j]);
		}
	}
	matrix a = T^k;
	printf("%lld\n", a.sum());
}

Measured memory_bytes: 4024
def examB():
    N, K = LI()
    L = LI(); L.sort(reverse = True)
    ans = sum(L[:K])
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

int main(){
  int N;
  cin >> N;
  vector<int> D(N), E(N);
  for(int i = 0; i < N; ++i){
    cin >> D[i] >> E[i];
  }
  int c = 0;
  for(int i = 0; i < N; ++i){
    if(D[i] == E[i])
      ++c;
    else
      c = 0;
    if(c >= 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int64_t Ans(int64_t i){
  if(i==1){
    return 1;
  }
  else{
    return 1+2*Ans(i/2);
  }
}

int main(){
  int64_t H;
  cin >> H;
  cout << Ans(H) << endl;
}

Measured memory_bytes: 256
def main():
    N=int(input())
    A=list(map(int,input().split()))
    a=A[0]
    for i in range(1,len(A)):
        a=a^A[i]
    ans=[]
    for i in A:
        ans.append(i^a)
    ans=map(str, ans)
    print(" ".join(ans))
main()

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

#define ABS(a) (((a) < 0) ? -(a) : (a) )

void solve(long *arr, int len) {
  long sum = 0, min = 1e9 + 100; 
  int i, n_cnt = 0;
  for(i = 0; i < len; ++i) {
    sum += ABS(arr[i]);
    if(arr[i] < 0) { ++n_cnt; }
    if(ABS(arr[i]) < min) { min = ABS(arr[i]); }
  }
  if(n_cnt % 2 != 0) { sum -= (2 * min); }
  printf("%ld\n", sum);
}

int main()
{
  int n, i;
  scanf("%d", &n);
  long *a = (long*)malloc((n+4)*sizeof(long));
  for(i = 0; i < n; ++i) { scanf("%ld", &a[i]); }
  solve(a, n);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,q,t=0,a,b;
	string s;
	cin >> n >>q>> s;
	vector<int>vec(n);
	vec[0] = 0;
	rep(i, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			t++;
		}
		vec[i + 1] = t;
	}
	rep(i, q) {
		cin >> a >> b;
		cout << vec[b - 1] - vec[a - 1] << endl;
	}
}



Measured memory_bytes: 1792