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

public class AtCoderD
{
    static void Main()
    {
        string s = Console.ReadLine();
        int length = s.Length;
        int[] counts = new int[length];

        int countR = 0;
        int posR = -1;
        int countL = 0;
        int posL = -1;
        for (int i = 0; i < length; i++)
        {
            string c = s.Substring(i, 1);

            if ("R".Equals(c))
            {
                if (posL != -1)
                {
                    counts[posR] = (countR + 1) / 2 + countL / 2;
                    counts[posL] = countR / 2 + (countL + 1) / 2;
                    posR = -1;
                    posL = -1;
                    countR = 0;
                    countL = 0;
                }
                countR++;
            }
            else
            {
                if (posR == -1)
                {
                    posR = i - 1;
                    posL = i;
                }
                countL++;
                if (i == length - 1)
                {
                    counts[posR] = (countR + 1) / 2 + countL / 2;
                    counts[posL] = countR / 2 + (countL + 1) / 2;
                    posR = -1;
                    posL = -1;
                    countR = 0;
                    countL = 0;
                }
            }
        }

        Console.WriteLine(string.Join(" ", counts));
    }
}

Measured memory_bytes: 17244
N = int(input())
A = list(map(int, input().split()))
dct = dict(enumerate(A))
ad = sorted(dct.items(), key=lambda x:x[1])
ans = []
for i in ad:
    j = i[0] + 1
    ans.append(j)
a = map(str, ans)
b = ' '.join(a)
print(b)

Measured memory_bytes: 40124
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	char c;
	CIN(c);
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		COUT("vowel");
	} else COUT("consonant");
}


Measured memory_bytes: 256
// ABC177C - Sum of product of pairs

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

typedef unsigned long long int ull;
typedef long long int ll;

#define MOD 1000000007

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

	ull A[N];
	ull sum = 0;
	ull psum[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		sum %= MOD;
		psum[i] = sum;
	}

	ull ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ull temp = (sum - psum[i] + MOD)% MOD;
		ans += A[i] * temp;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


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

ll cnt[5];

int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main() {
  int n;
  cin >> n;
  string name[n];
  rep(i, n) cin >> name[i];

  rep(i, n) {
    char x = name[i][0];
    if (x == 'M') ++cnt[0];
    else if (x == 'A') ++cnt[1];
    else if (x == 'R') ++cnt[2];
    else if (x == 'C') ++cnt[3];
    else if (x == 'H') ++cnt[4];
  }

  ll ans = 0;
  for (int bit = (1<<3)-1 ;bit < (1<<5); bit = next_combination(bit)) {
    ll tmp = 1;
    for (int i = 0; i < 5; ++i) {
      if ((bit >> i) & 1) tmp *= cnt[i];
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


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


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x, y, tmp, i;
    for(i=0; ;i++){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0){
            break;
        }
        if(x > y){
            tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}

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

using namespace std;
using ll = long long;

class UF{
private:
    std::vector<long long> data; //data[i] : 頂点iの親
public:
    UF(int n){
        data.resize(n,-1);
    }
    //頂点iの親を返す
    int root(int i){
        if(data[i] < 0)return i;
        else return data[i] = root(data[i]);
    }
    //連結
    void unit(int i,int j){
        i = root(i);j = root(j);
        if(i != j){
            data[i] += data[j];
            data[j] = i;
        }
    }

    //頂点iの属する集合の頂点数
    int size(int i){
        i = root(i);
        return -data[i];
    }
};

int main()
{
    int n, k, l; cin >> n >> k >> l;
    UF train(n), load(n);
    for(int i = 0; i < k; i++) {
        int a, b; cin >> a >> b; a--, b--;
        train.unit(a, b);
    }
    for(int i = 0; i < l; i++) {
        int a, b; cin >> a >> b; a--, b--;
        load.unit(a, b);
    }
    map<pair<int,int>,int> mp;
    for(int i = 0; i < n; i++)mp[{train.root(i), load.root(i)}]++;
    for(int i = 0; i < n; i++)cout << mp[{train.root(i), load.root(i)}] << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(),t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

const int N = 3010;

struct edge{
	int next, to;
};

edge e[N << 1];
int n, first[N], e_cnt = 0, a[N];
bool state[N];

void addedge(int u, int v){
	e[++ e_cnt] = {first[u], v};
	first[u] = e_cnt;
	e[++ e_cnt] = {first[v], u};
	first[v] = e_cnt;
}

void dfs(int i, int fa){
	for (int j = first[i]; j; j = e[j].next){
		int x = e[j].to;
		if (x == fa){
			continue;
		}
		dfs(x, i);
		if (!state[x] && a[x] < a[i]){
			state[i] = true;
		}
	}
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
	}
	for (int i = 0, u, v; i < n - 1; ++ i){
		scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	for (int i = 1; i <= n; ++ i){
		memset(state, 0, sizeof(state));
		dfs(i, 0);
		if (state[i]){
			printf("%d ", i);
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(b/a<=c)
	{
		printf("%d",(b/a));
	}
	else if(b/a>=c)
	{
		printf("%d", c);
	}
	else
	{
		printf("0");
	}
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   int n;
   cin >>n;
   string s;
   cin >> s;
   int ans =0;
   int finalans=0;
   for(int i=0;i<n;i++){
      ans-=(s[i]=='D')-(s[i]=='I');
      finalans=max(ans,finalans);
   }
   cout << finalans;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int Gcnt=0;
    int ans = 0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='g'){
            if(Gcnt>0){
                Gcnt--;
                ans++;
            }else{
                Gcnt++;
            }
        }else{
            if(Gcnt>0){
                Gcnt--;
            }else{
                Gcnt++;
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		int[][] c = new int[H][W];
		int wCount = 0;
		int hCount = 0;
		for(int i=0;i<n;i++) {
			int aCount = 0;
			while(aCount<a[i]) {
				c[hCount][wCount] = i+1;
				aCount++;
				if(hCount%2==0) {
					wCount++;
					if(wCount==W) {
						wCount--;
						hCount++;
					}
				}
				else {
					wCount--;
					if(wCount==-1) {
						wCount++;
						hCount++;
					}
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				sb.append(c[i][j] + " ");
			}
			sb.append(ls);
		}
		System.out.println(sb.toString());
		in.close();

	}

}


Measured memory_bytes: 35744
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t) 
     

Measured memory_bytes: 3060
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
# それぞれの単語数をカウントしておく
# 全探索で組み合わせ数が分かるはず

N = int(sys.stdin.readline())

target = {"M":0,"A":0,"R":0,"C":0,"H":0}
cnt = 0
for i in range(N):
    s = list(sys.stdin.readline().rstrip())
    if s[0] in target.keys():
        target[s[0]] += 1

k = list(target.keys())
ans = 0
for i in range(3):
    for j in range(i + 1, 5):
        for h in range(j + 1, 5):
            ans += target[k[i]] * target[k[j]] * target[k[h]]

print(ans)

Measured memory_bytes: 68840
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), M = Reader.Int();
        var table = Reader.IntTable(M);
        var red = new bool[N];
        var num = Enu.Repeat(1, N).ToArray();
        red[0] = true;

        foreach (var t in table)
        {
            int a = t[0] - 1, b = t[1] - 1;
            num[a]--;
            num[b]++;
            if (red[a]) red[b] = true;
            if (num[a] == 0) red[a] = false;
        }

        Console.WriteLine(red.Count(b => b));
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 12720
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	int t=0;
	for(int i=1;i<=n;i++){
		for(int j=10;j<=m;j++){
			int x=j/10,y=j%10;
			if(x>=2&&y>=2&&x*y==i) t++;
		}
	}
	cout<<t<<endl;
}

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


n, m = map(int, input().split())
edges_from = [[] for _ in range(n)]
edges_to = [[] for _ in range(n)]

for _ in range(m):
    _from, to = map(lambda x: int(x)-1, input().split())
    edges_from[_from].append(to)

E_dist_to_goal = [0] * n
P_of_reaching = [0] * n
P_of_reaching[0] = 1

for v in range(n-2, -1, -1):
    routes = edges_from[v]
    for next_v in routes:
        E_dist_to_goal[v] += E_dist_to_goal[next_v] + 1
    E_dist_to_goal[v] /= len(routes)

for v in range(n-1):
    P_now = P_of_reaching[v]
    routes = edges_from[v]
    P_next = P_now / len(routes)
    for next_v in routes:
        P_of_reaching[next_v] += P_next

initial_ans = E_dist_to_goal[0]
short_cut = 0
for v in range(n-2):
    routes = edges_from[v]
    num_of_routes = len(routes)
    if num_of_routes == 1:
        continue
    not_cut_dist = E_dist_to_goal[v]
    longest_dist = max([E_dist_to_goal[next_v]+1 for next_v in routes])
    after_cut_dist = (not_cut_dist - longest_dist/num_of_routes) * num_of_routes / (num_of_routes-1)
    delta = (not_cut_dist - after_cut_dist) * P_of_reaching[v]
    short_cut = max(short_cut, delta)

ans = initial_ans - short_cut
print(ans)

Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18;
int n,T,a,b,p[200010];
long long td[200010],pm[2][2][200010],dp[2][200010],ans=INF;
void Add(long long*s,int x,long long v){
	while(x<=n)s[x]=min(s[x],v),x+=(x&-x);
}
long long Query(long long*s,int x){
	long long ret=INF;
	while(x)ret=min(ret,s[x]),x-=(x&-x);
	return ret;
}
int main(){
	scanf("%d%d%d%d",&n,&T,&a,&b);
	for(int i=1;i<=T;++i)scanf("%d",&p[i]),i>1?td[i]=td[i-1]+abs(p[i]-p[i-1]):0;
	for(int i=1;i<=n;++i)pm[0][0][i]=pm[0][1][i]=pm[1][0][i]=pm[1][1][i]=INF;
	dp[0][1]=abs(a-p[1]),dp[1][1]=abs(b-p[1]),ans=min(ans,min(dp[0][1]+td[T],dp[1][1]+td[T]));
	Add(pm[0][0],b,dp[0][1]-b),Add(pm[0][1],n-b+1,dp[0][1]+b);
	Add(pm[1][0],a,dp[1][1]-a),Add(pm[1][1],n-a+1,dp[1][1]+a);
	for(int i=2;i<=T;++i){
		dp[0][i]=min(Query(pm[0][0],p[i])+p[i]+td[i-1],Query(pm[0][1],n-p[i])-p[i]+td[i-1]);
		dp[1][i]=min(Query(pm[1][0],p[i])+p[i]+td[i-1],Query(pm[1][1],n-p[i])-p[i]+td[i-1]);
		Add(pm[0][0],p[i-1],dp[0][i]-td[i]-p[i-1]),Add(pm[0][1],n-p[i-1]+1,dp[0][i]-td[i]+p[i-1]);
		Add(pm[1][0],p[i-1],dp[1][i]-td[i]-p[i-1]),Add(pm[1][1],n-p[i-1]+1,dp[1][i]-td[i]+p[i-1]);
		ans=min(ans,min(dp[0][i]+td[T]-td[i],dp[1][i]+td[T]-td[i]));
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 11904
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   ll n,k;
   cin >> n >> k;
   
   cout << min(n % k, abs(n % k - k)) << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

    vector<ll> dp(n);
    dp.assign(n, INF);

    dp[0] = 0;

    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
        if (i > 1) {
            chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 4808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

	int n, l;
	cin >> n >> l;

	int eat;
	if (l <= 0 && l + n - 1 >= 0) {
		eat = 0;
	}
	else{
		if (abs(l) < abs(l + n - 1)) {
			eat = l;
		}
		else {
			eat = l + n - 1;
		}
	}

	int ans = (l + l + n - 1) * n / 2 - eat;

	cout << ans << endl;

	return 0;

}

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

using namespace std;

using ll = long long;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    vector<pair<int, int>> ud(n), du(n);
    ud[0] = make_pair(1, 0);
    du[0] = make_pair(-1, 0);
    for (int i = 1; i < n; ++i) {
        if (i % 2 == 0) {
            ud[i] = make_pair((i == n - 1 ? 1 : 2), i);   // up
            du[i] = make_pair((i == n - 1 ? -1 : -2), i); // down
        }
        else {
            ud[i] = make_pair((i == n - 1 ? -1 : -2), i); // down
            du[i] = make_pair((i == n - 1 ? 1 : 2), i);   // up
        }
    }
    sort(ud.begin(), ud.end());
    sort(du.begin(), du.end());

    ll sum_ud = 0, sum_du = 0;
    for (int i = 0; i < n; ++i) {
        sum_ud += ud[i].first * a[i];
        sum_du += du[i].first * a[i];
    }

    cout << max(sum_ud, sum_du) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
  string S;
  cin >> S;
  
  if(S[2]==S[3] && S[4]==S[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (A >= N % 500) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
#define INF 1000000001

int main()
{
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(U == S) A--;
    else if(U == T) B--;
    cout << A << " " << B << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define		CH		ch=(getchar())

inline		int		IN(){
	int x=0,f=1;char ch;
	for (CH;ch>'9'||ch<'0';CH) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';CH) (x*=10)+=ch-'0';
	return x*f;
}

int i,j,k,l,n,m;

int main(){
	scanf("%d",&n);
	printf("ABC%d",n);
}


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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n,k,q;
	cin >> n >> k >> q;
	vector<LL> points(n,k);
	vector<LL> ans(n,0);
	for (LL i = 0; i < q; i++){
		LL x;
		cin >> x;
		x--;
		ans[x]++;
	}
	for (LL i = 0; i < n; i++){
		points[i] -= q;
		points[i] += ans[i];
		if (points[i] <= 0)
			cout << "No\n";
		else
			cout << "Yes\n";
	}
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int n,q;
const int max_n = 2 * 1e5;
vector<vector<int>> tree(max_n + 1);
// int p[max_n + 1], x[max_n + 1];
vector<int> seen(max_n + 1, 0);
vector<int> score(max_n + 1, 0);

void dfs(int now, int sum){
  // cout << "now = " << now << "sum = " << sum << endl;

  for(auto next : tree[now]){
    if(seen[next] == 1) continue;
    seen[next] = 1;
    score[next] += sum;
    dfs(next, score[next]);
  }
  
  return;
}

int main(){
  cin >> n >> q;
  for(int i = 0; i < n - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  for(int i = 0; i < q; i++) {
    // cin >> p[i] >> x[i];?
    int p,x;
    cin >> p >> x;
    p --;
    score[p] += x;
  }
  
  // cout << "initial score" << endl;
  // for(int i = 0; i < q; i++) cout << score[i] << endl;

  seen[0] = 1;
  dfs(0, score[0]);

  for(int i = 0; i < n; i++){
    cout << score[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 25124
import itertools
import numpy as np

N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = np.sort(A)

positive = A[A>0]
negative = A[A<0]
zero = A[A==0]

l = -10**18
r = 10**18

while l + 1 < r:
    x = (l+r) // 2 # 中央位置
    cnt = 0
    if x >= 0:
        cnt += N * len(zero)
    
    # x//pos : 中央値/posのそれぞれの値
    cnt += A.searchsorted(x//positive, side="right").sum()
    cnt += (N - A.searchsorted(-(-x//negative), side="left")).sum()
    cnt -= np.count_nonzero(A * A <= x)
    cnt //= 2
 
    if cnt >= K:
        r = x
    else:
        l = x
print(r) 
 

Measured memory_bytes: 32244
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
l = [0]
ans = 0
for i in range(N):
    if l[-1] + 1 != A[i]:
        ans += 1
    else:
        l.append(A[i])
if l[-1] == 0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26268
S = list(map(int,list(input())))
N = len(S)
cmax = 0
for i in range(1,N):
    if S[i]!=S[cmax]:
        if cmax<=N-i:
            cmax = i
        else:
            cmax = max(cmax,N-cmax)
            break
cmax = max(cmax,N-cmax)
print(cmax)

Measured memory_bytes: 49392
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

void solve(long long N, std::string Str){
    //* left half record
    map< pair<string, string>, ll > rec;
    rep(S, 1<<N){
        string red, blue;
        rep(i, N){
            if(S >> i & 1){
                red.push_back(Str.at(i));
            }
            else{
                blue.push_back(Str.at(i));
            }
        }
        rec[make_pair(red, blue)]++;
    }
    ll cnt = 0;
    rep(S, 1<<N){
        string red, blue;
        rep(i, N){
            if(S >> i &1){
                red.push_back(Str.at(i+N));
            }
            else{
                blue.push_back(Str.at(i+N));
            }
        }
        reverse(red.begin(), red.end());
        reverse(blue.begin(), blue.end());

        if(rec.count(make_pair(blue, red)))
            cnt += rec[make_pair(blue, red)];

    }

    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 46080
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

bool check(int n)
{
	string s;
	for(;n;n/=10) s=char(n%10+'0')+s;
	For(i,0,sz(s)/2) if(s[i]!=s[sz(s)-i-1]) return false;
	return true;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	if(a>b) swap(a,b);
	if(a==1 && b==1) cout<<"1\n";
	else if(a==1) cout<<b-2<<"\n";
	else cout<<(a-2)*(b-2)<<"\n";
	return 0;
}















Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let opt = a.iter().filter(|&&x| x > 0).sum::<i64>();
    let w_sum = a[..K].iter().filter(|&&x| x < 0).sum::<i64>();
    let b_sum = a[..K].iter().filter(|&&x| x > 0).sum::<i64>();
    let (ans, _, _) = (K..N).fold((std::cmp::max(opt + w_sum, opt - b_sum), w_sum, b_sum),
        |(res, w_sum, b_sum), i|  {
            let w_sum_next = w_sum + std::cmp::min(0, a[i]) - std::cmp::min(0, a[i - K]);
            let b_sum_next = b_sum + std::cmp::max(0, a[i]) - std::cmp::max(0, a[i - K]);
            (
                *vec![res, opt + w_sum_next, opt - b_sum_next].iter().max().unwrap(),
                w_sum_next,
                b_sum_next
            )
        });

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

Measured memory_bytes: 8444
a, b =map(int, input().split())

for x in range(0,10**6):
    # print('---')
    # print(x)
    ax = (8*x)//100
    bx = (10*x)//100
    # print(ax,bx)
    if ax == a and bx == b:
        print(x)
        break
else:
    print(-1)

Measured memory_bytes: 63288
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  string str; cin >> str;
  int size;
  size = str.size();
  
  //compute
 
  //output
  if(str.at(size - 1) == 's'){
           cout << str + "e" + "s" << endl;
         }else{
           cout << str + "s" << endl;
         }
  
}

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

int main(){
	string chg = "abcdefghijklmnopqrstuvwxyz.?! ",s;
	while(cin >> s){
		if(s.length() % 2) {
			cout << "NA" << endl;
			continue;
		}
		string to = "";
		bool flag = true;
		for(int i = 0;i < s.length() / 2;i++){
			char a = s[i * 2],b = s[i * 2 + 1];
			if(a >= '1' && a <= '6' && b >= '1' && b <= '5'){
				int aa = a - '1',bb = b - '1';
				to += chg.substr(aa * 5 + bb,1);
			}
			else flag = false;
		}
		if(!flag) cout << "NA" << endl;
		else cout << to << endl;
	}
	return 0;
}

Measured memory_bytes: 2972
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def find(S, x):
    left = 0
    right = n

    while right - left >= 1:
        mid = (left + right)//2

        if S[mid] == x:
            return True 

        if S[mid] < x:
            left = mid + 1
        else:
            right = mid

    return False

n = int(input())
S = sorted(map(int,input().split()))
q = int(input())
T = map(int,input().split())

count = 0
for t in T:
    if find(S, t):
        count += 1
print(count)

Measured memory_bytes: 18592
//これ難しい～
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

int INF = 1e+9;
string s;
vector<int> A, B;
int dp[1000001][2];

int main() {
	int i, j;
	
	cin >> s;
	for (i = s.length() - 1; i >= 0; i--) if (s[i] != '0') break;
	for (; i >= 0; i--) { A.push_back(s[i] - '0'); }
	rep(i, A.size()) {
		if (i == 0) B.push_back(10 - A[i]);
		else B.push_back(9 - A[i]);
	}
	
	int n = A.size();
	rep(i, n) rep(j, 2) dp[i][j] = INF;
	
	dp[n - 1][0] = 0;
	dp[n - 1][1] = 1;
	
	for (i = n - 1; i > 0; i--) {
		chmin(dp[i - 1][0], dp[i][0] + A[i]);
		chmin(dp[i - 1][1], dp[i][0] + B[i] + 1);
		chmin(dp[i - 1][1], dp[i][1] + B[i]);
		chmin(dp[i - 1][0], dp[i][1] + A[i] + 1);
	}
	
	int ans = min(dp[0][0] + min(11 - A[0], A[0]), dp[0][1] + min(11 - B[0], B[0]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17016
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,x;
  ll ans = 0;
  cin >> N >> x;
  vector<int> a(N);
  FOR(i,0,N)cin >> a[i];
  FOR(i,0,N-1){
    if(a[i]+a[i+1] >= x){
      ans += min(a[i]+a[i+1]-x,a[i+1]);
      a[i+1] -= min(a[i]+a[i+1]-x,a[i+1]);
    }
    if(a[i]+a[i+1] >= x){
      ans += a[i]+a[i+1]-x;
      a[i] -= a[i]+a[i+1]-x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	ll a, b;
	cin >> a >> b;
	a--;

	ll ans=(((b+1)/2-(a+1)/2)%2==0?0:1);
	for (ll i = 2;; i *= 2) {
		if (b < i)break;
		bool flg[2];
		flg[0] = b % (i * 2) >= i;
		flg[1] = a % (i * 2) >= i;
		ll memo[2];
		memo[0] = (b % (i * 2) - i+1) % 2+2;
		memo[1] = (a % (i * 2) - i+1) % 2;
		if (((flg[0]?memo[0]:2)-(flg[1]?memo[1]:0))%2 == 1)ans += i;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "No" << endl;
  exit(0);
}
void yes() {
  cout << "Yes" << endl;
  exit(0);
}
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    mp[t]++;
  }
  int sz = mp.size();
  if (sz >= 3) err();
  int k = mp.rbegin()->first;
  if (k == n - 1 && sz == 1) yes();
  int one = 0;
  if (sz == 2) {
    if (next(mp.rbegin())->first != k - 1) err();
    one = next(mp.rbegin())->second;
  }
  int many = n - one;
  k -= one;
  if (k <= 0 || many / 2 < k) err();
  yes();
  return 0;
}

Measured memory_bytes: 4992
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

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


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long lint;
using namespace std;

int main()
{
	lint N,A[100010];
	lint n,front,back;
	vector<lint> ans1,ans2;
	lint sum1=0,sum2=0;
	
	cin >> N;
	n=N/2;
	if(N%2==0)n--;
	for(lint i=0;i<N;i++)
		cin >> A[i];
	sort(A,A+N);
	
	//ans1
	ans1.push_back(A[n]);
	front=0;
	back=N-1;
	for(lint i=0;i<n;i++)
	{
		ans1.push_back(A[front]);
		ans1.push_back(A[back]);
		front++;
		back--;
	}
	if(N%2==0)
		ans1.push_back(A[n+1]);
	
	//ans2
	ans2.push_back(A[n]);
	front=0;
	back=N-1;
	for(lint i=0;i<n;i++)
	{
		ans2.push_back(A[back]);
		ans2.push_back(A[front]);
		front++;
		back--;
	}
	if(N%2==0)
		ans2.push_back(A[n+1]);
	
	//prlint
	/*
	for(lint i=0;i<ans1.size();i++)
		cout << ans1[i] << " ";
	cout << endl;
	for(lint i=0;i<ans2.size();i++)
		cout << ans2[i] << " ";
	cout << endl;
	*/
	//ans
	for(lint i=0;i<ans1.size()-1;i++)
		sum1+=abs(ans1[i+1]-ans1[i]);
	for(lint i=0;i<ans2.size()-1;i++)
		sum2+=abs(ans2[i+1]-ans2[i]);
	
	cout << max(sum1,sum2) << endl;
}

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
  int S[13], H[13], C[13], D[13];
  for (int i = 0; i < 13; i++) {
    S[i] = 0;
    H[i] = 0;
    C[i] = 0;
    D[i] = 0;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    cin >> c >> x;
    if (c == 'S') S[x-1] += 1;
    if (c == 'H') H[x-1] += 1;
    if (c == 'C') C[x-1] += 1;
    if (c == 'D') D[x-1] += 1;
  }
  for (int i = 0; i < 13; i++)
    if (!S[i]) cout << "S " << i+1 << endl;
  for (int i = 0; i < 13; i++)
    if (!H[i]) cout << "H " << i+1 << endl;
  for (int i = 0; i < 13; i++)
    if (!C[i]) cout << "C " << i+1 << endl;
  for (int i = 0; i < 13; i++)
    if (!D[i]) cout << "D " << i+1 << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[n],i,flag=0;
  	cin>>n;
  	for(i=0;i<n;i++)
      cin>>a[i];
  	for(i=0;i<n;i++)
    {
      if(a[i]%2==0)
      {
        if(a[i]%3!=0 && a[i]%5!=0)
        {
          flag=1;
          break;
        }
      }
    }
  if(flag==0)
    cout<<"APPROVED";
  else
    cout<<"DENIED";
  	return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e4 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<string> vs(n);
	for (auto &s : vs) cin >> s;
	sort(vs.begin(), vs.end());
	for (auto &s : vs) printf(s.c_str());
	puts("");
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	cin >> S;

	S[5] = S[13] = ' ';
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    2019;
ll pre[N];
ll po(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1)
		res=res*x%mod;
		y>>=1;
		x=x*x%mod;
	}
	return res;
}
int main()
{  fast
string s;
cin>>s;
int n=s.size();
ll ans=0;
ll x=0;
for(int i=n-1;i>=0;i--)
{
	ll y=s[i]-'0';
	ll z=po(10,n-1-i)%mod;
	 z=z*y;
	z=(z+pre[i+1])%mod;
	pre[i]=z;
}

map<ll,ll> mp;
for(int i=0;i<=n;i++)
{
	if(mp[pre[i]])
	{
		ans+=mp[pre[i]];
	}
	mp[pre[i]]++;
}
cout<<ans;
}


Measured memory_bytes: 5340
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, C;
	cin >> A >> B >> C;

    if(A==B&&B==C) {
      cout<< 1;
    }
    else if(A==B||B==C||C==A){
      cout << 2;
    }
    else{
	  cout << 3;
    }

	return 0;
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=100023};
const int mod = 1e9+7;

il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if ( b&1 ) {
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }

ll fac[N],Invf[N];
il void init_fac(int n){
	n= min(n,mod-1);
	fac[0]= 1;
	rep(i,1,n) fac[i]=fac[i-1]*i%mod;
	Invf[n]= inv(fac[n]);
	rev_rep(i,n,1) Invf[i-1]=Invf[i]*i%mod;
}
il ll comp(ll n,ll m){
	if( n<m ) return 0;
	return fac[n]*Invf[m]%mod*Invf[n-m]%mod;
}

int a[N];

int main(){
	int n=ci(), k=ci();
	init_fac(n);
	rep(i,1,n) a[i]=ci();
	sort(a+1,a+n+1);
	ll ans=0;
	rep(i,k,n){
		ans= (ans+comp(i-1,k-1)*a[i])%mod;
	}
	rep(i,1,n-k+1){
		ans= (ans-comp(n-i,k-1)*a[i])%mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 2176
/*      Welcome to my Code      */

#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a
#define co(a)                   cout<<a
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define sr(a,n)                 sort(a,a+n)
#define rv(a,n)                 reverse(a,a+n)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;

using namespace std;

int main()
{
    fast;
    int x;
  cin>>x;
  if(x==0) cout<<1<<endl;
  if(x==1) cout<<0<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3640
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 19 04 2020

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define    pi    acos(-1.0)

void task()
{
    int r;
    float ans;

    scanf("%d", &r);

    ans = 2*pi*r;

    printf("%f\n", ans);
}

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

    //clock_t tStart = clock();

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    //printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);

    return 0;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	int t, h;
	t = h = 0;
	while (n--) {
		string ts, hs;
		cin >> ts >> hs;
		if (ts == hs) {
			t++;
			h++;
		} else if (ts > hs) {
			t += 3;
		} else {
			h += 3;
		}
	}
	cout << t << ' ' << h << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    FOR(i, L, R + 1){
        if (i % d == 0) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
def magicall(tiles,a,b):
    point = tiles[a][b]
    if point==".":return a,b
    elif point==">":tiles[a][b] = "0";return magicall(tiles,a,b+1)
    elif point=="<":tiles[a][b] = "0";return magicall(tiles,a,b-1)
    elif point=="^":tiles[a][b] = "0";return magicall(tiles,a-1,b)
    elif point=="v":tiles[a][b] = "0";return magicall(tiles,a+1,b)
    elif point=="0":return "LOOP"

while 1:
    H,W=map(int,input().split())
    if H==0:break
    tilis=[list(input()) for i in range(H)]
    answer = magicall(tilis,0,0)
    if type(answer)==tuple:
        print(answer[1],answer[0])
    else:print(answer)


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  int W[N];
  rep(i,N)
    cin>>W[i];
  int ans=10000000,S1=0;
  rep(i,N){
    int count=0,S2=0;
    S1+=W[i];
    for(int j=i+1;j<N;j++)
      S2+=W[j];
    count=abs(S1-S2);
    ans=min(ans,count);
  }
  cout<<ans<<endl;

  return 0;
}
  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
num = [int(a) for a in input().split()]

ans = 1000000
for i in range(1, n + 1):
    s1 = 0
    for j in range(i):
        s1 += num[j]

    tmp = abs(sum(num) - 2 * s1)
    if ans > tmp:
        ans = tmp
    else:
         break

print(ans)


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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=z;x>=y;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

void decrypt() {
	ll x;
	string n;
	x = 0;
	cin>>n;
	fl(i,0,n.length()) {
		x += n[i]-'0';
	}
	if(x%9==0) {
		cout<<"Yes"<<ln;
	}else {
		cout<<"No\n";
	}
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 3776