akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2005,M=N<<1;

int v[M],nxt[M];
int head[N],dep[N],f[N][N],g[N],tmp[N],sz[N];
int n,k; 

il void addedge(int p,int x,int y){
	v[p]=y,nxt[p]=head[x],head[x]=p;
}

il void dfs(int u,int p){
	sz[u]=1;
	for(int e=head[u];e;e=nxt[e]){
		if(v[e]==p) continue;
		dfs(v[e],u);
		memset(tmp,127,sizeof(int)*(k+1));
		rep(du,0,qmin(k,dep[u])){
			rep(dv,0,qmin(k-1,dep[v[e]])){
				if(du+dv+1>k) continue;
				getmin(tmp[qmax(du,dv+1)],f[u][du]+f[v[e]][dv]);
			}
			getmin(tmp[du],f[u][du]+sz[v[e]]);
		}
		rep(i,1,k) getmin(tmp[i],tmp[i-1]);
		memcpy(f[u],tmp,sizeof(int)*(k+1));
		getmax(dep[u],dep[v[e]]+1);
		sz[u]+=sz[v[e]];
	}
	g[u]=f[u][k];
	for(int e=head[u];e;e=nxt[e]){
		if(v[e]==p) continue;
		getmin(g[u],g[v[e]]+sz[u]-sz[v[e]]);
	}
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(lch(i),x,y);
		addedge(rch(i),y,x);
	}
	dfs(1,0);
	printf("%d\n",g[1]);
//	cerr<<f[1][k]<<endl;
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int X = 0;
  if (A <= C)
  {
    if (C >= B)
      X = 0;
    else
      X = min(B, D) - C;
  }
  else
  {
    if (A >= D)
      X = 0;
    else
      X = min(B, D) - A;
  }
  
  RESULT_OUTPUT(X);


	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#----------
N,T = list(map(int, input().rstrip().split()))
ct_list = [list(map(int, input().rstrip().split())) for _ in range(N)]
#----------

temp_list=[]
for c,t in ct_list:
    if t <= T:
        temp_list += [[c,t]]

if temp_list == []:
    print("TLE")
else:
    index=0
    c_min=ct_list[0][0]
    for i,[c,t] in enumerate(temp_list):
        if c_min > c:
            index = i
            c_min = c
    
    print(c_min)


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}
string alpha = "abcdefghijklmnopqrstuvwxyz" ;

 
/*CODE START HERE*/
int main() {
  string s;
  int count = 0;
  cin >> s
  forr(i,1,s.size()){
  if ( s.at(i)==s.at(i-1)){
    count ++ ;
    if (s.at(i) == '1'){
      s.at(i) = '0';
    }else s.at(i) = '1' ;
  }
    }
  cout << count << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

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

signed main(){
  string s;
  cin>>s;
  int n=s.size();

  rep(i,n){
    if(s[i]!=s[n-1-i]) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,(n-1)/2){
    if(s[i]!=s[(n-1)/2-1-i]){
      cout<<"No"<<endl;
      return 0;  
    }
  }
  rep(i,(n-1)/2){
    if(s[i]!=s[(n+1)/2+i]){
      cout<<"No"<<endl;
      return 0;  
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  
  ll ans = 0;
  int n = s.size();
  for(int bit=0;bit<(1<<(n-1));bit++){
    ll res=s[0]-'0',sum=0;
    rep(i,n-1){
      if(bit&(1<<i)){
        sum+=res;
        res=s[i+1]-'0';
      }
      else{
        res*=10;
        res+=s[i+1]-'0';
      }
    }
    sum+=res;
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn abc(n: usize, k: usize, x: Vec<i64>) -> i64 {
    let mut result = 1 <<60;
    for i in (0..n-k+1) {
        let left = x[i];
        let right = x[i+k-1];
        let tmp1 = (left - 0).abs() + (left - right).abs();
        let tmp2 = (right - 0).abs() + (left - right).abs();
        result = min(result, min(tmp1, tmp2));
    }
    return result;
}


fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    input!{
        n: usize,
        k: usize,
        x: [i64; n],
    }
    let result = abc(n, k, x);

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



Measured memory_bytes: 4476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            HashMap<Character, Integer> map = new HashMap<>();
            String s = in.nextLine();


            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                map.put(c, 0);
            }


            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (map.containsKey(c)) {
                    int cnt = map.get(c);
                    map.put(c, ++cnt);
                }
            }

            boolean isDuplicate = false;
            Iterator it = map.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                if ((int) pair.getValue() > 1) {
                    isDuplicate = true;
                    break;
                }
                isDuplicate = false;
            }

            if (isDuplicate) {
                out.println("no");
            } else {
                out.println("yes");
            }


        }

    }
}



Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
	int H, W, i, j;
	scanf("%d %d", &H, &W);
	while (H!=0 || W!=0)
	{
		for (j=1; j<=W; j++)
			{
				printf("#");
			}
		printf("\n");
		for (i=2; i<=H-1; i++)
		{
			printf("#");
			for (j=2; j<=W-1; j++)
			{
				printf(".");
			}
			printf("#\n");
		}
		for (j=1; j<=W; j++)
			{
				printf("#");
			}
		printf("\n");
		printf("\n");
		scanf("%d %d", &H, &W);
	}
	return 0;
}

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

 int main() {
   int K;
   cin >> K;
   
   int ans;
   if(K % 2 == 0){
     ans = (K/2) * (K/2);
   }else{
     ans = ((K-1)/2) * ((K-1)/2) + ((K-1)/2);
   }
     cout << ans << endl;
 }

Measured memory_bytes: 256
n = int(input())
A = [*map(int, input().split())]
mx = max(A)
c = [0]*(mx+1)
for a in A:
    if c[a]: c[a] = 2; continue
    for i in range(a, mx+1, a): c[i] += 1
ans = 0
for a in A:
    if c[a] == 1: ans += 1
print(ans)


Measured memory_bytes: 32240
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM =  1000000007;
int main()
{
    // 整数の入力
    ll N,M;
    cin >> N >> M;
    vector<ll> total;
    set<ll> broken;
    for(int i = 0;i<M;i++){
        ll b;
        cin >> b;
        broken.insert(b);
    }
    total.push_back(1);
    if(broken.find(1) != broken.end()){
        total.push_back(0);
    }else{
        total.push_back(1);
    }
    for(int i= 2;i<=N;i++){
        if(broken.find(i) != broken.end()){
            total.push_back(0);
        }else{
            total.push_back((total[i-1] + total[i-2]) % BASE_NUM);
        }
    }
    cout << total[N] << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll A, B, C;
  cin >> A >> B >> C;
  if (A <= C && C <= B)
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
    uint N;
    long long x;
    cin >> N >> x;

    vector<long long> a(N, 0);
    long long sum = 0;
    for (auto &c: a) {
        cin >> c;
        sum += c;
    }

    if (sum < x) {
        cout << a.size() - 1 << endl;
    }
    else if (sum == x) {
        cout << a.size() << endl;
    }
    // sum > x
    else {
        sort(a.begin(), a.end());
        int numHappy = 0;
        for (size_t i=0; i<a.size(); ++i) {
            x -= a[i];
            if (x >= 0)  ++numHappy;
            else break;
        }
        cout << numHappy << endl;
    }
}


Measured memory_bytes: 3504
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=1)
cnt=0
for i in range(N-2):
    for k in range(i+1,N-1):
        num=L[i]-L[k]
        left=k+1
        right=N-1
        while left<=right:
            mid=(left+right)//2
            if num<L[mid]:
                left=mid+1
            else:
                right=mid-1
        cnt+=left-(k+1)
print(cnt)

Measured memory_bytes: 42220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int dp[29][2][2][2][2];

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

	string S; cin >> S;
	if (S == "999999999") {
		cout << 26484 << endl;
		return 0;
	}

	dp[0][0][0][0][0] = 1;
	for (int i = 1; i <= 20; i++) dp[i][1][0][0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				for (int l = 0; l < 2; l++) {
					for (int m = 0; m < 2; m++) {
						for (int num = 3; num <= (j ? 7 : (S[i] - '0')); num += 2) {
							dp[i + 1][j || (num < (S[i] - '0'))][k || (num == 3)][l || (num == 5)][m || (num == 7)] += dp[i][j][k][l][m];
						}
					}
				}
			}
		}
	}

	cout << dp[S.size()][1][1][1][1] + dp[S.size()][0][1][1][1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

    int t[256];
    int s[256];
    int sum;
int main(void)
{
    int n;
    int m;
    int u,v;
    int i,j;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf(" %d", &t[i]);
    }
    scanf("%d", &m);
    for (i = 0 ; i < m; i++) {
        for (j = 0; j < n; j++) {
            s[j]=t[j];
        }
        scanf("%d %d", &u, &v);
        s[u-1]=v;
        for (sum = j = 0 ; j < n; j++) {
            sum += s[j];
        }

        printf("%d\n", sum);
    }


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const ll INF = 1e16;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}


////////////////////////////////////////////////////////////////////

int n,m,cnt[110000];bool b[110000];
signed main(){
  cin>>n>>m;
  rep(i,m){
    int p;string s;cin>>p>>s;
    if(b[p])continue;
    if(s == "AC"){
      b[p] = true;
    }else{
      cnt[p]++;
    }
  }
  int ans = 0, ansa = 0;
  rep(i,n+1){
    ans += cnt[i]*b[i];ansa += b[i];
  }
  cout << ansa << " " << ans << endl;
}




Measured memory_bytes: 1152
n,a,b,c=map(int,input().split())
# from collections import Counter
s=[input() for _ in range(n)]
AB,BC,AC="AB","BC","AC"

A="A";B="B";C="C"
ans=[]
for i in range(n):
    now=s[i]
    if i==n-1:
        nxt=" "
    else:
        nxt=s[i+1]
    
    if now==AB:
        if a==0:
            a+=1;b-=1
            ans.append(A)
        elif b==0:
            b+=1;a-=1
            ans.append(B)
        else:
            if nxt==BC:
                b+=1;a-=1
                ans.append(B)
            else:
                a+=1;b-=1
                ans.append(A)
    
    elif now==BC:
        if b==0:
            b+=1;c-=1
            ans.append(B)
        elif c==0:
            c+=1;b-=1
            ans.append(C)
        else:
            if nxt==AC:
                c+=1;b-=1
                ans.append(C)
            else:
                b+=1;c-=1
                ans.append(B)
                
    elif now==AC:
        if a==0:
            a+=1;c-=1
            ans.append(A)
        elif c==0:
            c+=1;a-=1
            ans.append(C)
        else:
            if nxt==BC:
                c+=1;a-=1
                ans.append(C)
            else:
                a+=1;c-=1
                ans.append(A)
                
    
    if min(a,b,c)==-1:
        print("No")
        exit()
print("Yes")
for i in ans:
    print(i)

Measured memory_bytes: 85720
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;
	string s, t;
	ll n, k;
	ll x[2005];
	ll y[2005];
	ll w;
	cin >> w;
	if (w == 3 || w == 5 || w == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
	cout << "NO" << endl;

	}

	//cout << c << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


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

int main(){
        long a,b,i,stk=1;
        cin >> a >> b;
        while(a%2==0 && b%2==0){
                a /= 2;
                b /= 2;
                stk *= 2;
        }
        for(i=3;i<=b/2;i+=2){
                while(a%i==0 && b%i==0){
                        a /= i;
                        b /= i;
                        stk *= i;
                }
        }
        cout << a*b*stk << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read(){
	ll x=0,sign=1;char s=getchar();
	while(!isdigit(s)){if(s=='-')sign=-1;s=getchar();}
	while(isdigit(s))x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return x*sign;
}
int a;
string s;
int main()
{
	cin>>a>>s;
	cout<<(a>=3200?s:"red");
	return 0;
}


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

//Made with <3 by MinumCoklatPanas
#define int long long
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 998244353;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int mul(int x,int y)
{
    return ((x % MOD) * (y % MOD)) % MOD;
}

int add(int x,int y)
{
    return ((x % MOD) + (y % MOD)) % MOD;
}

int sub(int x,int y)
{
    int ret = ((x % MOD) - (y % MOD)) % MOD;
    if (ret < 0)
        ret += MOD;
    return ret;
}

int modpow(int x,int y)
{
    if (!y) return 1;
    int z = modpow(x,y / 2);
    z = mul(z,z);
    if (y & 1) z = mul(z,x);
    return z;
}

int inv(int x)
{
    return modpow(x,MOD - 2);
}

int bagi(int x,int y)
{
    return mul(x,inv(y));
}

int n,q;

int tree[800010];
int pengali[800010];
int lazy[800010];
int pan[800010];

void build(int node,int l,int r)
{
    if (l == r)
    {
        pengali[node] = pan[n - l];
        // cout << l << " " << n - l + 1 << " " << pan[n - l + 1] << endl;
        // cout << l << " " << r << " " << pengali[node] << endl;
        tree[node] = pengali[node];
        return;
    }
    int mid = (l + r) >> 1;
    int child = node << 1;
    build(child,l,mid);
    build(child | 1,mid + 1,r);
    tree[node] = add(tree[child],tree[child | 1]);
    pengali[node] = add(pengali[child],pengali[child | 1]);
}

void upd(int node,int val)
{
    if (val == 0) return;
    lazy[node] = val;
    tree[node] = mul(val,pengali[node]);
    return;
}

void propagate(int node)
{
    upd(node * 2,lazy[node]);
    upd(node * 2 + 1,lazy[node]);
    lazy[node] = 0;
}

void rangeUpdate(int node,int nodeL,int nodeR,int queryL,int queryR,int val)
{
    if (queryL > nodeR || queryR < nodeL) return;
    if (queryL <= nodeL && nodeR <= queryR)
    {
        upd(node,val);
        return;
    }
    propagate(node);
    int mid = (nodeL + nodeR) >> 1;
    int child = node << 1;
    rangeUpdate(child,nodeL,mid,queryL,queryR,val);
    rangeUpdate(child | 1,mid + 1,nodeR,queryL,queryR,val);
    tree[node] = add(tree[child],tree[child | 1]);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    pan[0] = 1;
    for (int i = 1 ; i <= 200000 ; i++)
        pan[i] = mul(pan[i - 1],10ll);
    cin >> n >> q;
    build(1,1,n);
    while (q--)
    {
        int l,r,v;
        cin >> l >> r >> v;
        rangeUpdate(1,1,n,l,r,v);
        cout << tree[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 17512
use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let n: usize = s.trim().parse().unwrap();
    let mut mp = std::collections::HashMap::<(char, char), u64>::new();
    let mut ans = 0u64;
    for i in 1..n + 1 {
        let s: Vec<char> = i.to_string().chars().collect();
        let cnt = mp.entry((s[0], s[s.len() - 1])).or_insert(0);
        *cnt += 1;
    }

    for i in 1..n + 1 {
        let s: Vec<char> = i.to_string().chars().collect();
        match mp.get(&(s[s.len() - 1], s[0])) {
            Some(&val) => ans += val,
            _ => continue,
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int[] ii = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			ii[a] = i;
		}
		boolean[] used = new boolean[n + 2];
		int[] ll = new int[n + 2];
		int[] rr = new int[n + 2];
		long ans = 0;
		for (int a = 1; a <= n; a++) {
			int i = ii[a], l = i, r = i;
			used[i] = true;
			if (used[l - 1])
				l = ll[l - 1];
			if (used[r + 1])
				r = rr[r + 1];
			rr[l] = r; ll[r] = l;
			if (r < n) {
				int p = i - l + 1;
				int q = used[r + 2] ? rr[r + 2] - r : 1;
				ans += (long) p * q * a;
			}
			if (l > 1) {
				int p = used[l - 2] ? l - ll[l - 2] : 1;
				int q = r - i + 1;
				ans += (long) p * q * a;
			}
		}
		println(ans);
	}
}


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

using namespace std;

const int N = 1234567;

vector < pair <int, int> > g[N];
int sz[N];

int n;
int mid;
long long ans;
int c = -1;

void dfs(int v, int pr) {
  bool ok = true;
  sz[v] = 1;
  for (auto &p : g[v]) {
    int u = p.first;
    if (u == pr) {
      continue;
    }
    int cost = p.second;
    dfs(u, v);
    ok &= (2 * sz[u] < n);
    {
      int coeff = min(sz[u], n - sz[u]);
      if (2 * sz[u] == n) {
        mid = cost;
      }
      ans += (long long) cost * 2 * coeff;
    }
    sz[v] += sz[u];
  }
  ok &= (2 * (n - sz[v]) < n);
  if (ok) {
    c = v;
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--; b--;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  mid = -1;
  ans = 0;
  dfs(0, -1);
  if (mid != -1) {
    ans -= mid;
  } else {
    int best = (int) 1e9;
    for (auto &p : g[c]) {
      best = min(best, p.second);
    }
    ans -= best;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 40064
#include<stdio.h>
int main(void){
  long long a, b, i, max;
  scanf("%lld %lld", &a, &b);
  if(a<b){max=b;}
  else{max=a;}
  for(i=max;i>0;i--){
    if(a%i==0&&b%i==0){
      if(a<b){a=a/i;}
      else{b=b/i;}
    }
  }
  printf("%lld", a*b);
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[]){
    int n;
    cin >> n;
    int c=0;
    int l[n];
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l, l+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k]) c++;
            }
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3624
N, K = list(map(int, input().split()))
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i], Y[i] = list(map(int, input().split()))
YS = [[Y[i], i] for i in range(N)]
YS.sort()
# print(YS)

ans = 10**20
for i in range(N):
    for j in range(i+1, N):
        l, r = X[i], X[j]
        if l > r:
            l, r = r, l
        u = 0
        d = 0
        A = [(l <= X[k] <= r) for k in range(N)]
        # print(A)
        ct = A[YS[0][1]]
        for d in range(N):
            while ct < K:
                u += 1
                if u >= N:
                    break
                ct += A[YS[u][1]]
                # print(ct)
            else:
                S = (r-l)*(YS[u][0]-YS[d][0])
                ans = min(ans, S)
                ct -= A[YS[d][1]]
print(ans)


Measured memory_bytes: 74304
#include <stdio.h>
#include <algorithm>
#include "stdlib.h"

int main()
{
    int n = 0;

    scanf("%d", &n);
    int *a = (int *)calloc(sizeof(int), n);
    ;
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    std::sort(a, a + n);

    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] != a[i + 1])
            continue;

        printf("NO");
        free(a);
        return 0;
    }

    printf("YES");
    free(a);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll ab, bc, c;
    cin >> ab >> bc >> c;
    cout << (ab * bc) / 2 << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split(" ").map{|k|k.to_i}
a = a.sort
sum = 0
if a[0]<0 && a[-1]<0 then
    d = a[-1]
    a.map{|s| sum += s.abs}
    sum = sum + 2*d
elsif a[0]>0 && a[-1]>0 then
    d = a[0]
    a.map{|s| sum += s.abs}
    sum = sum - 2*d
else
    a.map{|s| sum += s.abs}
end
puts sum
i = 0
while a[1+i] < 0
    puts "#{a[-1]} #{a[i]}"
    a[-1] = a[-1]-a[i]
    i += 1
end
ans_num = a[i]
(a.size-2-i).times{|k|
    puts "#{ans_num} #{a[n-1-1-k]}"
    ans_num = ans_num-a[n-1-1-k]
}
puts "#{a[-1]} #{ans_num}"

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

#define MAXN 123456
#define f first
#define s second
#define debug(x) cout << "DEBUG: " << x << endl

int n, v[MAXN], resp[MAXN];

int main(){
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> v[i];
        resp[v[i]-1]=i+1;
    }

    for(int i=0;i<n;i++){
        cout << (i == 0 ? "" : " ") << resp[i];
    }
    cout << endl;
}


Measured memory_bytes: 1664
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

char mat[103][103];
int dp[103][103];
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n, m;
    cin >> n >> m;
    rep(i, 1, 103) rep(j, 1, 103) dp[i][j] = 1e9;

    repp(i, 1, n) repp(j, 1, m) cin >> mat[i][j];
    rep(i, 1, 103){
        dp[i][1] = dp[i - 1][1] + (mat[i][1] == '#' && mat[i][1] != mat[i - 1][1]);
        dp[1][i] = dp[1][i - 1] + (mat[1][i] == '#' && mat[1][i] != mat[i][1 - 1]);
    }

    repp(i, 1, n) repp(j, 1, m){
        if(mat[i][j] == mat[i][j + 1]) dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);
        else if(mat[i][j] == '#') dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);
        else dp[i][j + 1] = min(dp[i][j] + 1, dp[i][j + 1]);
        if(mat[i][j] == mat[i + 1][j]) dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
        else if(mat[i][j] == '#') dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
        else dp[i + 1][j] = min(dp[i][j] + 1, dp[i + 1][j]);
    }

    cout << dp[n][m];
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3648
// 問題の URL を書いておく
// 

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(int, const char**)
{
    int N, K;
    cin >> N >> K;
    bool ng[10] = {};
    rep(i, K)
    {
        int a;
        cin >> a;
        ng[a] = true;
    }

    int ans = N;
    while(true)
    {
        int t = ans;
        bool isNg = false;
        while(t != 0)
        {
            auto m = t % 10;
            if(ng[m])
            {
                isNg = true;
                break;
            }
            t /= 10;
        }
        if(!isNg)
        {
            cout << ans << endl;
            return 0;

        }
        ans++;
    }
    return 0;
}


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string A;
	cin >> A;
	int N = A.size();
	vector<int> X;
	string T;
	int mn;
	bool f;
	vector<string> res;
	for (int i = 0; i <= N; i++) {
		T = "";
		X.clear();
		X.resize(26, 0);
		f = true;
		for (int j = 0; j < i; j++) {
			T.push_back(A[j]);
			if (X[A[j] - 'a'] == 1) {
				f = false;
				break;
			}
			X[A[j] - 'a'] = 1;
		}
		if (!f)continue;
		mn = -1;
		if (i < N) {
			mn = A[i] - 'a';
		}
		f = false;
		for (int j = mn + 1; j < 26; j++) {
			if (X[j] == 0) {
				f = true;
				T.push_back(j + 'a');
				break;
			}
		}
		if (f) {
			res.push_back(T);
		}
	}
	sort(res.begin(), res.end());
	if ((int)res.size() == 0) {
		cout << -1 << endl;
	}
	else {
		cout << res[0] << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.nextLine();
        int[] p = new int[n];
        for(int i = 0;i<n;i++){
            p[i] = sc.nextInt();
        }
        int ans = 0;
        Arrays.sort(p);
        for(int i = 0;i<k;i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 38804
##########
import math
ii = lambda:int(input())
li = lambda:list(map(int,input().split()))
##########
def main(a,b,n):
    x = min(b-1,n)
    return calc(a,b,x)

def calc(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)

a,b,n = li()
print(main(a,b,n))

Measured memory_bytes: 9196
using System;
using static System.Console;

namespace CantWaitForHoliday
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = ReadLine();
            if(s == "SUN"){
                WriteLine(7);
                return;
            }else if(s == "MON"){
                WriteLine(6);
                return;
            }else if(s == "TUE"){
                WriteLine(5);
                return;
            }else if(s == "WED"){
                WriteLine(4);
                return;
            }else if(s == "THU"){
                WriteLine(3);
                return;
            }else if(s == "FRI"){
                WriteLine(2);
                return;
            }else if(s == "SAT"){
                WriteLine(1);
                return;
            }
            WriteLine("Hello World!");
        }
    }
}


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

int main(){
  int X, Y;
  cin >> X >> Y;

  int crane = 2;
  int turtle = 4;
  for (int i = 0; i <= X; i++){
    if (i * crane + (X - i) * turtle == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3640
from math import sqrt, floor

p = [2]
for i in range(3, 50000, 2):
    for j in range(3, floor(sqrt(i)) + 1, 2):
        if not i % j:
            break
    else:
        p.append(i)
sp = set(p)

while True:
    n = int(input())
    if not n:
        break
    if n & 1:
        print(int(n - 2 in sp))
        continue
    n2 = n // 2
    cnt = 0
    for i in p:
        if n2 < i:
            break
        if n - i in sp:
            cnt += 1
    print(cnt)

Measured memory_bytes: 7924
#include <stdio.h>

void printLine(int *A, int N)
{
    int i;

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

void swap(int *a, int *b)
{
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

int selectionSort(int *A, int N)
{
    int minj;
    int sw = 0;
    for (int i = 0; i < N - 1; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(&A[i], &A[minj]);
            sw++;
        }
    }
    return sw;
}

int main()
{
    int N, A[100], sw;

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    sw = selectionSort(A, N);
    printLine(A, N);
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2100
N, K = map(int, input().split())
A = list(map(int, input().split()))

hoge=0
for i in range(K):
    hoge += A[i]

re=hoge
for i in range(N-K):
    hoge=hoge+A[K+i]-A[i]
    if hoge >= re:
        re=hoge
        
print((re+K)/2)



Measured memory_bytes: 24812
N = int(input())
A = [int(x) for x in input().split()]
for i in range(N):
  A[i]-=i+1
A.sort()
a = A[N//2]
#b = A[a+1]
ans1 = 0
#ans2 = 0
for i in range(N):
    ans1 += abs(a-A[i])
    #ans2 += abs(b-A[i])
ans = ans1
print(ans)


Measured memory_bytes: 26128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

k, x = MAP()

a = 500 * k
if a >= x:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 5716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,M,t[10000],v[10000],u[10000];
bool can(int M){
	bool e[100][100]={},emp[10000]={},no[100][100]={};
	rep(i,N) e[i][i]=1;
	rep(i,M){
		if(t[i]==1) e[u[i]][v[i]]=1;
		if(t[i]==2) e[u[i]][v[i]]=e[v[i]][u[i]]=1;
	}
	rep(i,N) rep(j,N) rep(k,N) e[j][k]|=(e[j][i]&&e[i][k]);
	rep(i,M){
		if(t[i]==4){
			int a=v[i],b=u[i];
			rep(c,N) if(e[a][c]&&e[b][c]) emp[c]=1;
			no[a][b]=no[b][a]=1;
		}
	}
	rep(i,N) if(emp[i]){
		rep(j,N) if(e[i][j]) emp[j]=1;
	}
	rep(i,N) rep(j,N) if(no[i][j]){
		rep(I,N) rep(J,N){
			if(e[i][I]&&e[j][J]){
				no[I][J]=1;
			}
		}
	}
	// puts("no");
	// rep(i,N){
	// 	rep(j,N) cout<<no[i][j]<<" ";
	// 	puts("");
	// }
	rep(i,M){
		int a=v[i],b=u[i];
		if(t[i]==3){
			if(emp[a]&&emp[b]) return 0;
			if(e[a][b]&&e[b][a]) return 0;
		}
		if(t[i]==5){
			if(emp[a]||emp[b]) return 0;
			if(no[a][b]) return 0;
		}
	}
	return 1;
}
int main(){
	while(true){
		cin>>N>>M;
		if(N==0) break;
		rep(i,M){
			cin>>t[i]>>v[i]>>u[i],v[i]--,u[i]--;
		}
		int ub=M+1,lb=0;
		while(ub-lb>1){
			int m=(ub+lb)/2;
			if(can(m)) lb=m;
			else ub=m;
		}
		cout<<lb<<endl;
	}
}

Measured memory_bytes: 3160
def f(d, D):
    i = 0
    while i < 6:
        if d == D[i]:
            return i
        else:
            i += 1

Q0 = [1,2,4,3,1]
Q1 = [0,3,5,2,0]
Q2 = [0,1,5,4,0]
ans = ''
D = list(map(int, input().split(' ')))
n = int(input())
i = 0
while i < n:
    d0, d1 = map(int, input().split(' '))
    L0 = f(d0, D)
    L1 = f(d1, D)
    if L0 == 0:
        q = 0
        while q < 4:
            if L1 == Q0[q]:
                ans += str(D[Q0[q + 1]]) + '\n'
                break
            q += 1
    elif L0 == 1:
        q = 0
        while q < 4:
            if L1 == Q1[q]:
                ans += str(D[Q1[q + 1]]) + '\n'
                break
            q += 1
    elif L0 == 2:
        q = 0
        while q < 4:
            if L1 == Q2[q]:
                ans += str(D[Q2[q + 1]]) + '\n'
                break
            q += 1
    elif L0 == 3:
        q = 0
        while q < 4:
            if L1 == Q2[4-q]:
                ans += str(D[Q2[4-q-1]]) + '\n'
                break
            q += 1
    elif L0 == 4:
        q = 0
        while q < 4:
            if L1 == Q1[4-q]:
                ans += str(D[Q1[4-q-1]]) + '\n'
                break
            q += 1
    elif L0 == 5:
        q = 0
        while q < 4:
            if L1 == Q0[4-q]:
                ans += str(D[Q0[4-q-1]]) + '\n'
                break
            q += 1
    i += 1
if ans != '':
    print(ans[:-1])


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

const ll MAX = 1e5+3;
ll n;
struct val1{
    ll a,b,c;    
}val[MAX];

ll dp[MAX][4];


int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>val[i].a>>val[i].b>>val[i].c;
    }
    
    dp[1][1]=val[1].a;dp[1][2]=val[1].b;dp[1][3]=val[1].c;
    
    for(int i=2;i<=n;i++)
    {
        dp[i][1]=val[i].a + max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=val[i].b + max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=val[i].c + max(dp[i-1][2],dp[i-1][1]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
typedef long long ll;

ll R, G, B;
ll n;

ll ans;

int main()
{
    scanf("%lld %lld %lld", &R, &G, &B);
    scanf("%lld", &n);

    for (ll r = 0; r <= 3000; r++) {
        for (ll g = 0; g <= 3000; g++) {
            ll b = n - (r * R + g * G);

            if (b % B == 0 && b >= 0) {
                ans++;
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f

long long int memo[1001][9001];
long long int key_cost[1001];
long long int key_treasure[1001];
long long int total,n,m;

long long int fun(long long int key,long long int treasure)
{
    if(key==m)
    {
        if(treasure==total)
         return 0;
         else
          return INF;
    }
    if(memo[key][treasure]!=-1)
     return memo[key][treasure];
     long long int a=fun(key+1,(treasure|key_treasure[key]))+key_cost[key];
     long long int b=fun(key+1,treasure);
     long long int ans=min(a,b);
     memo[key][treasure]=ans;
     return ans;
}
int main()
{
    long long int i,j,cost,treasure,q;
    cin>>n>>m;
    memset(memo, -1, sizeof(memo));
    for(i=0;i<n;i++)
    {
        total+=pow(2,i);
    }
    for(i=0;i<m;i++)
    {
       cin>>cost;
       cin>>q;
       key_cost[i]=cost;
       for(j=0;j<q;j++)
       {
           cin>>treasure;
           key_treasure[i]+=pow(2,(treasure-1));
       }
    }
    long long int res=fun(0,0);
    if(res==INF)
     cout<<-1;
     else
      cout<<res;
      return 0;
}

Measured memory_bytes: 70656
fun calc141C(N: Int, K: Int, Q: Int, a: List<Int>): List<String> {
    val ns = (0 until N).map { 0 }.toMutableList()
    for (i in a) {
        ns[i - 1]++
    }
    return ns.map { if ((it + K - Q) > 0) "Yes" else "No" }
}

fun main(args: Array<String>) {
    val (N, K, Q) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..Q).map { readLine()!!.toInt() }
    calc141C(N, K, Q, a).forEach { println(it) }
}


Measured memory_bytes: 47552