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

namespace AtCoder10
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if(a == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int b = int.Parse(Console.ReadLine());
                int c = int.Parse(Console.ReadLine());
                Console.WriteLine(b+c);
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int n = b - a - 1;
    int xa = 0;
    for(int i = 1;i<=n;i++){
      xa += i;
    }
    int x = xa - a;
    System.out.println(x);
  }
}


Measured memory_bytes: 35816
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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



signed main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
}


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

using namespace std;

int main(){
  int N, i, dist = 0;
  int d[110];
  cin >> N;
  for (i = 0; i < N; i++){
    cin >> d[i];
  }
  int num[110] = {0};
  for (i = 0; i < N; i++){
    num[d[i]]++;
  }
  for (i = 0; i <= 100; i++){
    if (num[i]){
      dist ++;
    }
  }
  cout << dist;
  return 0;
}


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

int main(){

  while(1){
    int data[11][11]={{0}};
    int n;
    scanf("%d",&n);
    if(n==0) break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	scanf("%d",&data[i][j]);
	data[n][j]+=data[i][j];
	data[i][n]+=data[i][j];
	data[n][n]+=data[i][j];
      }
    }
    
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	printf("%5d",data[i][j]);
      }
      printf("\n");
    }
    
  }
  return 0;
}

Measured memory_bytes: 1204
s=input()

tmp=0
length=[]

for i in range(len(s)):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        tmp+=1
        if i==len(s)-1:
            length.append(tmp)
    else:
        length.append(tmp)
        tmp=0
print(max(length))

Measured memory_bytes: 9056
antenna = []
for i in range(5):
  antenna.append(int(input()))
K = int(input())

d = True
for i in range(5):
  if d:
    for j in range(i,5):
      if antenna[j]-antenna[i] > K:
        print(':(')
        d = False
        break
if d:
  print('Yay!')

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

int gcd(int n1, int n2) {
	return (n2 == 0) ? n1 : gcd(n2, n1 % n2);
}

int main() {
	int n, X;
	cin >> n >> X;
	vector<int> x(n + 1);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	x[n] = X;
	if (n == 1) {
		cout << abs(x[0] - x[1]) << endl;
		return 0;
	}
	sort(x.begin(), x.end());
	vector<int> d(n);
	for (int i = 0; i < n; i++)
		d[i] = x[i + 1] - x[i];
	int ans = gcd(d[0], d[1]);
	for (int i = 2; i < n; i++)
		ans = gcd(ans, d[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  stack<int> st;
  while (getline(cin, s)) {
    int x = stoi(s);
    if (x) {
      st.push(x);
    } else {
      cout << st.top() << '\n';
      st.pop();
    }
  }
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<ll, ll>;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<pint> v(M);
    for (int i = 0; i < M; ++i)cin >> v[i].first >> v[i].second;
    ll L_max = 0, R_min = N+1;
    for (int i = 0; i < M; i++){
      L_max = max(L_max, v[i].first);
      R_min = min(R_min, v[i].second);
    }
    ll cnt = 0;
    for (int i = 1; i <= N; i++) {
      if (i >= L_max && i <= R_min) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4768
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
g = int(input())
h = int(input())
i = int(input())
j = int(input())
print(a+b+c+d+e+f+g+h+i+j)


Measured memory_bytes: 5588
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

string newString(string now) {
	string res;
	stringstream ss;
	int count = 1;

	for(int i = 0; i < (int)now.length(); i++) {
		if(i < (int)now.length() && now[i] == now[i + 1]) { count++; }
		else {
			ss.str("");
			ss.clear(stringstream::goodbit);
			ss << count;
			res.append(ss.str());
			res.append(1, now[i]);
			count = 1;
		}
	}

	return res;
}

int main(void) {
	string in;
	int num;
	int i;

	while(true) {
		cin >> num;
		if(num == 0) { break; }
		cin >> in;
		for(i = 0; i < num; i++) {
			in = newString(in);
		}
		cout << in << endl;
	}

	return 0;
}

Measured memory_bytes: 1112
def main():
    h,w = map(int,input().split())
    c = []
    for i in range(0,10):
        cc = list(map(int,input().split()))
        c.append(cc)
    a = []
    for i in range(0,h):
        aa = list(map(int,input().split()))
        a.append(aa)
    # ワーシャルフロイド（最短経路だす）
    for i in range(10):
        for j in range(10):
            for k in range(10):
                c[j][k] = min(c[j][k], c[j][i] + c[i][k])
    cnt = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] != 1 and a[i][j] >= 0:
                cnt += c[a[i][j]][1]
    print(cnt)


if __name__=='__main__':
    main()


Measured memory_bytes: 3444
n, m = map(int, input().split())
if n % 2 == 1:
    tmp = n
    for i in range(1, m+1):
        print(i, tmp)
        tmp -= 1
else:
    tmp = n
    for i in range(1, m+1):
        print(i, tmp)
        if tmp - i == n//2 + 1:
            tmp -= 2
        elif tmp - i == n//2 + 2:
            tmp -= 2
        else:
            tmp-= 1

Measured memory_bytes: 9084
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    String S = sc.next();
    char[]ss = S.toCharArray();
    ArrayList<Integer>ans  = new ArrayList<>();

    int a = 0;
    ans.add(a);
    for(int i=0; i<n; i++) {
    	if(ss[i] == 'I') {
    	a += 1;
    	ans.add(a);
    	}else {
    	a -= 1;
    	ans.add(a);
    	}
    }
    	Collections.sort(ans,Collections.reverseOrder());   		

    	System.out.println(ans.get(0));
    }
}


Measured memory_bytes: 35820
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main(){
    long long n,k;
    string s="";
    cin >> n;
    k=n;
    while(k--){
        s= char(k%26+'a')+s;
        k /= 26;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))
A = A + A
ans = [0] * N
a = 0
for i in range(N-1):
    a ^= A[i]
ans[N-1] = a
W = N - 1
for i in range(N-1):
    remove = A[i]
    addition = A[i+W]
    a = remove^a^addition
    ans[i] = a

print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 43504
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val s = (0 until m).map {
        sc.nextInt() - 1 to sc.nextInt()
    }

    println(abc157c(n, s))
}

private fun abc157c(n: Int, sc: List<Pair<Int, Int>>): Int {
    val scs = sc.sortedBy { it.first }
    val start = when (n) {
        2 -> 10
        3 -> 100
        else -> 0
    }
    val end = when (n) {
        2 -> 99
        3 -> 999
        else -> 9
    }

    for (i in start..end) {
        var ok = true
        for (sci in scs) {
            val s = sci.first
            val c = sci.second
            val istr = i.toString()
            if (istr.get(s).toString() != c.toString()) {
                ok = false
                break
            }
        }
        if (ok) return i
    }

    return -1
}

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

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

  double temp = 1;
  ll ans = 1;

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

  for (ll i = 0; i < N; i++) {
    if (A[i] == 0) {
      cout << 0 << '\n';
      return 0;
    }
  }

  ll M = (ll) 1000000000;
  M = M * M;
  for (ll i = 0; i < N; i++) {
    M = (M + A[i] - 1) / A[i];
    if (M == 0) {
      cout << -1 << '\n';
      return 0;
    }
  }

  M = (ll) 1000000000;
  M = M * M;
  for (ll i = 0; i < N; i++) {
    temp *= A[i];
    ans *= A[i];
    if (ans > M || ans < 0 || temp > M) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3992
#include <stdio.h>
int main()
{
	int N, M, P;
	int X[100], sum;
	while (scanf("%d%d%d", &N, &M, &P) && N) {
		sum = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &X[i]);
			sum += X[i];
		}
		sum *= (100 - P);
		printf("%d\n", X[M - 1] ? sum / X[M - 1] : 0);
	}
	return 0;
}



Measured memory_bytes: 2028
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int L, R, d; cin >> L >> R >> d;
    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
		if (i >= L && i <= R && i % d == 0) ++ans;
	}
	cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3608
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
d = {}
ans = 0
for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
    else:
        d[A[i]] = 1

for i in d:
    if d[i] % 2 == 1:
        ans += 1
print(ans)

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

int main()
{
    int N,M;cin >> N >> M;
    vector<vector<int>> graph(N,vector<int> (N,0));
    int u,v;
    for (int i=0;i<M;i++)
    {
        cin >> u >>v;
        u--;v--;
        graph[u][v]=1;
        graph[v][u]=1;
    }
    vector<int> num(N-1);
    for (int i=1;i<N;i++) num[i-1]=i;
    int ans=0;
    bool can=true;
    do
    {
        can=true;
        if (graph[0][num[0]]==0) can=false;
        else
        {
            for (int i=0;i<N-2;i++)
            {
                if (graph[num[i]][num[i+1]]==0)
                {
                    can=false;
                    break;
                }
            }
            if (can) ans++;
        }
    }while (next_permutation(num.begin(),num.end()));
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

vector<vector<int>> v;
vector<int> dic;

int rec(int i){ 
  // iから始めたときの最長パスの長さ
  if(dic[i] != -1) return dic[i];

  int ret = 0;
  for(auto x: v.at(i)){
    ret = max(ret, rec(x) + 1);
  }

  dic[i] = ret;

  return ret;
}

int main(){
  cout << setprecision(10);
  int N,M;
  cin >> N >> M;

  v.assign(N, vector<int>());
  dic.assign(N, -1);

  for(int i = 0; i < M; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;

    v.at(tmp1).push_back(tmp2);
  }

  int max_val = 0;
  for(int i = 0; i < N; i++){
    max_val = max(max_val, rec(i));
  }
  cout << max_val << endl;

}


Measured memory_bytes: 8192
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;


    vector<bool> seen;
    void dfs(const Graph &G,int v){
        int cnt = 0;
        seen[v] = true;
        for(auto nv:G[v]){
            if(seen[nv])continue;
            cnt++;
            dfs(G,nv);
        }
    }

    int main(){
      ll n,k;cin>>n>>k;
      VEC(ll,h,n);
      sort(h.begin(),h.end());
      ll sum = 0;
      rep(i,n-k){
          sum += h[i];
      }
      cout<<sum;
    }


Measured memory_bytes: 1792
using System;
using System.Linq;

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var K = line[0];
        var A = line[1];
        var B = line[2];
        var ans = 1L;
        //1円→ビスケット
        if (B - A > 2)
        {
            while (0 < K)
            {
                if(A <= ans && 2<=K)
                {
                    K-=2;
                    ans += B-A;
                }
                else if (2<K && (A+2)-ans <= K)
                {
                    K -= (A+2-ans);
                    ans += B-ans;
                }
                else
                {
                    ans += K;
                    K = 0;
                    break;
                }
            }
        }
        else
        {
            ans = K + 1;
        }
        Console.WriteLine(ans);
    }
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int A[n], B[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    if(k >= n) {
        cout << abs(A[0] - A[n-1]);
        return 0;
    }

    B[0] = 0;
    for(int i = 1; i < k; i++){
        B[i] = abs(A[i] - A[0]);
    }

    for(int i = k; i < n; i++){
        int temp = INT_MAX;
        for(int j = i-k; j < i; j++){
            temp = min(B[j] + abs(A[i]-A[j]), temp);
        }
        B[i] = temp;
    }
    cout << B[n-1];
}




Measured memory_bytes: 4416
use std::collections::VecDeque;
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> VecDeque<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn main() {
    let mut s = read_str_as_char_vec();
    let q: usize = read_str_as_T();

    let mut rev = 1;
    for _i in 0..q {
        // let in_vec: Vec<char> = read_line();
        let mut temp = String::new();
        stdin().read_line(&mut temp).ok();
        let mut in_iter = temp.trim().split_whitespace();
        let mut t = in_iter.next().unwrap().chars();

        if t.next().unwrap() == '1' {
            rev *= -1;
        } else {
            let f: usize = in_iter.next().unwrap().parse().unwrap();
            let mut p = in_iter.next().unwrap().chars();
            if f == 1 {
                if rev == 1 {
                    s.push_front(p.next().unwrap());
                } else {
                    s.push_back(p.next().unwrap());
                }
            } else {
                if rev == -1 {
                    s.push_front(p.next().unwrap());
                } else {
                    s.push_back(p.next().unwrap());
                }
            }
        }
    }

    let mut res: String = String::new();
    if rev == 1 {
        for &c in s.iter() {
            res.push(c);
        }
    } else {
        for &c in s.iter().rev() {
            res.push(c);
        }
    }

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


Measured memory_bytes: 6652
#include <bits/stdc++.h>
using namespace std;
string S;int p1,p2;
int main() {
	cin>>S;
	for(int i=S.size()-1;i>=0;i--){if(S[i]=='A')p1=i;}
	for(int i=0;i<S.size();i++){if(S[i]=='Z')p2=i;}
	cout<<p2-p1+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;

int main(){


    int n;
    cin>>n;
    vector<pair<int,int>> vec;
    while(n--){

        int a,b;
        cin>>a>>b;
        vec.push_back(make_pair(a,b));
    }

    bool flag1 = false;
    bool flag2 = false;
    bool flag3 = false;

    for(int i=0;i<vec.size();i++){
        if(vec[i].first==vec[i].second && !flag1){
            flag1 = true;
        }
        else if(vec[i].first==vec[i].second && !flag2){
            flag2 = true;
        }
        else if(vec[i].first==vec[i].second && !flag3){
            flag3 = true;
        } else{
            flag1 = false;
            flag3 = false;
            flag2 = false;
        }

        if(flag3 && flag2 && flag1){
            cout<<"Yes\n";
            return 0;
        }
    }

    cout<<"No\n";




    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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 int INF = 1<<29;
int main() {
    ll N, M; cin >> N >> M;
    ll S = 0;
    vector<ll> A(M);
    for (int i=0;i<M;++i) {
        cin >> A[i];
        S += A[i];
    }
    if (N - S >= 0) cout << N-S << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3708
//Littleboy123 Template 1.1

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

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){  
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	int a;
	string s;
	cin >> a >> s;
	if(a >= 3200){
		cout << s << nl;
	}
	else{
		cout << "red\n";
	}
	return 0;
}

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

n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    
    const int NO_OF_ALPHABETS = 26;
    vector <vector <int> > locations(NO_OF_ALPHABETS);
    for(int i = 0; i < S.size(); i++)
    {
        locations[S[i] - 'a'].push_back(i);
    }
    
    int no_of_concatenations = 1, matched_prefix = -1;
    for(int i = 0; i < T.size(); i++)
    {
        if(locations[T[i] - 'a'].size() == 0)
        {
            cout << "-1\n";
            
            return 0;
        }
        
        auto it = upper_bound(locations[T[i] - 'a'].begin(), locations[T[i] - 'a'].end(), matched_prefix);
        
        if(it == locations[T[i] - 'a'].end())
        {
            no_of_concatenations++;
            
            matched_prefix = locations[T[i] - 'a'][0];
        }
        else
        {
            matched_prefix = *it;
        }
    }
    
    long long final_length = (no_of_concatenations - 1)*1LL*S.size() + (matched_prefix + 1);
    cout << final_length << "\n";
    
    return 0;
}


Measured memory_bytes: 1216
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
    int n,p=0,w=0,g=0,y=0;
    cin >> n;
    vector<char> s(n);
    for(int i=0; i<n; i++){
        cin  >> s[i];
    }
    for(int i=0; i<n; i++){
        if(s[i]=='P' && p == 0) p++;
        else if(s[i]=='W' && w == 0) w++;
        else if(s[i]=='G' && g == 0) g++;
        else if(s[i]=='Y' && y == 0) y++;
    }
    if((p+w+g+y)==3) cout << "Three" << endl;
    else cout << "Four" << endl;
}

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

int main()
{
  string w;
  cin >> w;
  bool good = true;
  vector<int> cnt(200);
  for (int i = 0; i < w.size(); i++)
  {
    cnt[w.at(i)]++;
  }
  for (int i = 0; i < cnt.size(); i++)
  {
    if (cnt[i] % 2 != 0)
    {
      good = false;
    }
  }
  if (good)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n;
    cin >> n;
    if(n % 2){
        cout << n * 2 << endl;
    }else{
        cout << n << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);                                            
      
      int H = sc.nextInt();
      int W = sc.nextInt();
      
     for(int i = 0;i < H;i++){
       for(int j = 0;j < W;j++){
           String s = sc.next();
           if(s.equals("snuke")){
               System.out.println((char)('A' + j) + "" + (int)(i+1));              
           }
       }  
     }
      
      
      
   }
        
 }
        
        

Measured memory_bytes: 22996
a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np


from collections import deque
ans = []

ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)

print(min( min(ans), min(a1)+min(b1) ))


Measured memory_bytes: 52160
#include<stdio.h>

#define MAX 101
#define inf 1000000000
#define NIL -1000000000
#define WHITE 0
#define BLACK 1

int n;
int d[MAX],pi[MAX],color[MAX],G[MAX][MAX];

dijkstra(){
  int v,i,u,mincost;

  for(v=0;v<n;v++){
    d[v]=inf;
    pi[v]=NIL;
    color[v]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=inf;

    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==inf) break;

    color[u]=BLACK;

    for(v=0;v<n;v++){
      if(G[u][v]!=-1){
	if(color[v]!=BLACK && d[u]+G[u][v]<d[v]){
	  pi[v]=u;
	  d[v]=d[u]+G[u][v];
	}
      }
    }
  }
}

int main(){
  int i,j,u,k,v,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=inf;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      G[u][v]=c;
    }
  }

  dijkstra();

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

  return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];

    vec<P> b(n);
    REP(i,n) b[i]={a[i],i};
    sort(all(b),greater<P>());

    Matrix dp(n+1,Array(n+1,0));//i番目まで見て、j個左に置く
    REP(i,n){
        REP(j,i+1){
            ll p = b[i].first;
            ll x = b[i].second;
            if(x>=j) chmax(dp[i+1][j+1],dp[i][j]+p*abs(x-j));
            if(x<=n-1-i+j) chmax(dp[i+1][j],dp[i][j]+p*abs(x-(n-1-i+j)));
        }
    }

    ll ans=0;
    REP(i,n+1){
        chmax(ans,dp[n][i]);
    }
    cout<<ans<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 34600
def make(a, b)
  (a+b).times.map{|i| i}.combination(a).to_a.each_with_object([]) do |x, y|
    arr = ["B"]*(a+b)
    x.each{ |j| arr[j] = "A" }
    y << arr.join
  end
end
def make2(a, b)
  if a == 5
    make(a-1, b).map{|s| s + "A"}
  else
    make(a, b-1).map{|s| s + "B"}
  end
end
a, b = gets.split.map(&:to_i)
if a <= 4 && b <= 4
  arr = make(a, b)
elsif (a == 5 || b == 5) && a + b < 10
  arr = make2(a, b)
else
  x = make2(5, 4)
  y = make2(4, 5)
  if a == 5 && b == 5
    arr = (x.map{|s| s + "B"} + y.map{|s| s + "A"}).sort
  elsif a == 6
    arr = x.map{|s| s + "A"}
  else
    arr = y.map{|s| s + "B"}
  end
end
arr.each{|res| puts res}

Measured memory_bytes: 8784
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int A,B;
    cin >> A >> B;
    if(abs(A-B)%2==0){
        cout << (A+B)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int x[10][10];
int n,d;

int abs_(int a)
{
    if(a<0)return (-1)*a;
    return a;
}

bool ok(int i,int j){
    int dis=0;
    REP(k,d)dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    for(int k=1;k*k<=dis;k++)if(dis==(k*k)){
        // cout<<dis<<" "<<k<<endl;
        return true;
    }
    return false;
}

int main()
{
    cin>>n>>d;
    REP(i,n)REP(j,d)cin>>x[i][j];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(ok(i,j)){
                // cout<<i<<" "<<j<<endl;
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 256
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]

m = [[0] * n for i in range(n)]

for l in range(2, n + 1):
    for i in range(n - l + 1):
        j = i + l - 1
        m[i][j] = float('inf')
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i][0] * p[k][1] * p[j][1])

print(m[0][n - 1])

Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll D; vll path; vector<string> A; ll magic = 0; vpll list;
//***********//
int main() {
	cin >> N >> M;
	vl A(N), B(M);
	vl X(N *M,-1), Y(N*M,-1);
	ll valid = 1;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		if (X[A[i] - 1] != -1) valid = 0;
		X[A[i] - 1] = i;
	}
	for (i = 0; i < M; i++) {
		cin >> B[i];
		if (Y[B[i] - 1] != -1) valid = 0;
		Y[B[i] - 1] = i;
	}
	if (!valid) {
		cout << 0; exit(0);
	}
	ans = 1;
	ll vX = 0;
	ll vY = 0;
	ll count = N * M;
	for (k=N*M-1; k >= 0; k--) {
		if (X[k] != -1 && Y[k] != -1) {
			vX++; vY++;
		}
		else if (X[k] != -1) {
			(ans *= vY) %= MOD; vX++;
		}
		else if(Y[k] != -1){
			(ans *= vX) %= MOD; vY++;
		}
		else {
			(ans *= (vX * vY - (N*M-count))) %= MOD;
		}
		count--;
		//debug(k + 1, vX,vY,ans);
		if (vX == N && vY == M) break;
		if (ans == 0) {
			cout << 0; exit(0);
		}
	}
	for (i = 1; i <= count; i++) {
		(ans *= i) %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 100010;
LL a[SIZEN];
int N;
LL M;
LL check(int x){
    LL ret = 0;
    for(int i = 1;i <= N;i++){
        int pos = lower_bound(a+1,a+1+N,x - a[i]) - a;
        ret += N-pos+1;
    }
    //printf("x = %d,ret = %lld\n",x,ret);
    return ret;
}
LL sum[SIZEN] = {0};
int main(){
    scanf("%d%lld",&N,&M);
    for(int i = 1;i <= N;i++)scanf("%d",&a[i]);
    sort(a+1,a+1+N);
    for(int i = 1;i <= N;i++)sum[i] = sum[i-1] + a[i];
    LL ans = 0;
    int l = 0,r = 2e5,mid;
    while(l <= r){
        mid = (l+r)>>1;
        if(check(mid) >= M)l = mid+1,ans = mid;
        else r = mid-1;
    }
    LL res = 0;
   // printf("ans = %lld\n",ans);
    for(int i = 1;i <= N;i++){
        int pos = lower_bound(a + 1, a + 1 + N,ans-a[i]) - a;
        res += sum[N] - sum[pos-1] + a[i] * (N-pos+1);
    }
    printf("%lld\n",res - (check(ans) - M)*ans);
    return 0;
}

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

int main() {
    unsigned long long X;
    cin >> X;
    int i = 1;
    unsigned long long int j = 100;
    while (true) {
      j *= 1.01;
      if (j >= X) {
        cout  << i << endl;
        break;
      }
      i++;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n;
ll a[200005],s[200005],c[200005],ans;
int main(){
	in(n);
	for(int i=1;i<=n;i++)in(a[i]);
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
		c[i]=c[i-1]^a[i];
	}
	int l=1;
	for(int i=1;i<=n;i++){
		while((s[i]-s[l-1])!=(c[i]^c[l-1]))l++;
		ans+=i-l+1;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
4
2 5 4 6
9 
0 0 0 0 0 0 0 0 0
19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1
*/

Measured memory_bytes: 4992
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 1e5 + 10;
int n;
ll a[maxN], b[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    ll already = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = n; i >= 1; i--) {
        ll cur = a[i] + already;
        ll need = ((cur + b[i] - 1) / b[i]) * b[i];
        already = need - a[i];
    }
    cout << already << '\n';
    return 0;
}

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

    int w,h,x,y;
    cin>>w>>h>>x>>y;

    cout<<(double(w)*double(h)/2.0);
    if(2*x==w&&2*y==h)  cout<<" "<<1<<endl;
    else    cout<<" "<<0<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int w,h,c;
	int a;
	int i;
	scanf("%d%d%d",&w,&h,&c);
	for(i=1;i<=w;i++){
		if(w%i==0 && h%i==0){
			a=i;
		}
	}
	printf("%d\n",w/a*h/a*c);
	return 0;
}

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

int main() {
  int h, w, d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> s.at(i).at(j);
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s.at(i).at(j) == '#') {
        int f = 0;
        for(int k = 0; k < 4; k++)
          if(0 <= i + d[k][1] && i + d[k][1] < h && 0 <= j + d[k][0] &&
             j + d[k][0] < w)
            if(s.at(i + d[k][1]).at(j + d[k][0]) == '#')
              f = 1;
        if(!f) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

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

ll mod = 1e9+7;
ll memo[1<<17];
ll modPow(ll,ll,ll);
int main(){
    ll n,k,ans=0;
    cin >> n >> k;

    for(ll i = k; i >= 1; i--){
        memo[i]= modPow(k/i,n,mod);  //gcdがiになる個数
        
    
        for(ll j = 2*i; j <= k ; j = j + i){
            memo[i] -= memo[j];
        }
        ans += memo[i]*i%mod;
        
    }

    cout << ans%mod << endl;    

}


ll modPow(ll a,ll n,ll mod) {
  if (n == 1) return a % mod;
  if (n % 2 == 1) return (a * modPow(a, n - 1, mod)) % mod;
  ll t = modPow(a, n / 2, mod);
  return (t * t) % mod;
}

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

int main(){
    using namespace std;
    unsigned long N, M, V, P;
    cin >> N >> M >> V >> P;
    --P;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    partial_sort(A.begin(), A.end() - P, A.end());
    A.erase(A.end() - P, A.end());
    V -= min(V, P);
    N -= P;
    unsigned long ans{P};
    for(unsigned long i{0}, s{accumulate(A.begin(), A.end(), 0UL)}; i < N; ++i){
        s -= A[i];
        if(V)V--;
        ans += A[i] + M >= A.back() && (A[i] + M) * (N - i - 1) >= s + M * V;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> x(m);
  vector<int> dx(m-1);
  
  for(int i=0; i<m; i++){
    int xx;
    cin >> xx;
    x[i] = xx;
  }
  sort(x.begin(), x.end());
  for(int i=0; i<m-1; i++){
    dx[i] = x[i+1] - x[i];
  }
  sort(dx.begin(), dx.end());
  
  int sum = 0;
  for(int i=0; i<m-n; i++){
    sum += dx[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

def lcm(a, b):
    return abs(a // gcd(a, b) * b)

def cnt_2(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2

    cnt = cnt_2(a[0])
    for i in range(1, n):
        if cnt_2(a[i]) != cnt:
            return 0

    l = reduce(lcm, a, a[0])
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14588
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  sort(arr, arr+n);
  long long sum = 0;
  for (int i=n-k-1; i>=0; i--){
      sum += arr[i];
  }
  cout << sum;
  return 0; 
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

    int N;
    cin >> N;
  vector<string> A(N);
 map<string,int> m;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(!m.count(A[i])) m[A[i]]=1;
    else {cout<<"No"<<endl;goto end;}}
    for(int i=0;i<N;i++){

    if(i<N-1){
    if(A[i][A[i].size()-1]!=A[i+1][0]){cout<<"No"<<endl;break;}}
    if(i==N-1)cout<<"Yes"<<endl;}
end : N;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int n=1;n<=N;n++){
    ans=0;
    for(int A=2;A<=141;A++){
      for(int B=2;B<=141;B++){
        int C=sqrt(2*n-A*A-B*B);
        int S=A+B+C;
        if(C*C==2*n-A*A-B*B && S%2==0 && S/2>max({A,B,C})){
          ans++;
        }
        
      }
    }
    cout<<ans<<endl;
    }
  return 0;}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
	return 0;
}


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

using namespace std;

int main()
{
    string s,t;
    int cnt=0;
    cin>>s>>t;
    if(s==t)
    {
        cout<<3;
    }
    else
    {
        for(int i=0;i<3;i++)
        {
            if(s[i]==t[i])
                cnt++;
        }
        cout<<cnt;
    }
    cout<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N,T;
  scanf("%d %d",&N,&T);
  int arr[N];
  int a,b;
  for(int i=0;i<N;i++){
    scanf("%d %d",&a,&b);
    if(b<=T){
      arr[i]=a;
    }
    else{
      arr[i]=1001;
    }
  }
  
  int min=1001;
  for(int i=0;i<N;i++){
    if(arr[i]<min){
      min=arr[i];
    }
  }
  if(min<1001){
    printf("%d",min);
  }
  else{
    printf("TLE");
  }
}

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

//---List---
struct List{
  int x;
  struct List *next;
  struct List *back;
};
typedef struct List * ListPointer;
//struct List head,end;
ListPointer head;
ListPointer end;
ListPointer find(int);
void insert(int);
void delete(int);
void deleteFirst(int);
void deleteLast(int);

int trance_com(char *);


//---main---
int main()
{
  //(*commnd[])(int) is a method pointer.
  void (*commnd[])(int)={insert, delete, deleteFirst, deleteLast};
  int n;
  char com[20];
  int x;
  int i, j, k;
  ListPointer P;

  //initialization
  head=malloc(sizeof(struct List));
  end=malloc(sizeof(struct List));
  head->next=end;
  head->back=NULL;
  end->next=NULL;
  end->back=head;


  //start
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%s", com);
      j=trance_com(com);
      switch(j)
	{
	  //insert or delete
	case 0:
	case 1:
	  scanf("%d", &x);
	  (*commnd[j])(x);
	  break;

	  //deleteFirast or deleteLast
	case 2:
	case 3:
	  (*commnd[j])(x);
	  break;

	case -1:
	  printf("not command");
	  break;
	  }
    }


  //print
  for(P=head->next; P->next!=NULL; P=P->next)
    {
      if(P != head->next) printf(" ");
      printf("%d", P->x);
      /*
      if(P->next->next!=NULL)printf("%d ", P->x);
      else if(P->next->next==NULL)
	{
	  printf("%d\n", P->x);
	  break;
	}
      */
    }
  printf("\n");

  return 0;
}


//---method---
int trance_com(char *com)
{
  if(strcmp(com, "insert")==0)return 0;
  else if(strcmp(com, "delete")==0)return 1;
  else if(strcmp(com, "deleteFirst")==0)return 2;
  else if(strcmp(com, "deleteLast")==0)return 3;
  //not command
  else return -1;
}


ListPointer find(int x)
{
  ListPointer n;
 for(n=head->next; n->next!=NULL; n=n->next)
    {
      if(n->x==x)return n;
    }
 return NULL;
}

void insert(int x)
{
  ListPointer n;
  n=malloc(sizeof(struct List));
  /*
  if(n==NULL)
    {
      printf("Error. It could not make node.\n");
      exit(1);
    }
  */
  n->x=x;
  n->back=head;
  n->next=head->next;
  head->next->back=n;
  head->next=n;
}

void delete(int x)
{
  ListPointer n;
  n=find(x);
  /*
  if(n==NULL)printf("Cannot find number!\n");
  else
    {
      n->back->next=n->next;
      n->next->back=n->back;
      free(n);
    }
  */
  if(n != NULL){
    n->back->next=n->next;
    n->next->back=n->back;
    free(n);
  }
}

void deleteFirst(int x)
{
  ListPointer n;
  n=head->next;
  head->next=n->next;
  n->next->back=head;
  free(n);
}

void deleteLast(int x)
{
  ListPointer n;
  n=end->back;
  n->back->next=end;
  end->back=n->back;
  free(n);
}

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

using namespace std;
using ll = long long;
int main(){
    int N;
    cin>>N;
    vector<int> s(N+1);
    for(int i=0;i<N;++i) cin>>s[i];
    vector<bool> dp(10050);
    dp[0] = true;
    for(int i=0;i<N;++i){
        for(int j=10050;j>=s[i];--j){
            dp[j] =dp[j] || dp[j-s[i]];
        }
    }
    int sum=0;
    for(sum=10000;sum>0;sum--){
        if(dp[sum] && sum%10!=0){
            break;
        }
    }
    cout << sum << endl;
return 0;
}

Measured memory_bytes: 256