akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
  int count[4][3][10]={};
  int n,i,b,f,r,v;

  cin >> n;
  for(i=1; i<=n; i++){
      cin >> b >> f >> r >> v;
      count[b-1][f-1][r-1] += v;
  }
  for(b=1; b<=4; b++){
      for(f=1; f<=3; f++){
          for(r=1; r<=10; r++){
              cout << " " << count[b-1][f-1][r-1];
          }
          cout << endl;
      }
      if(b<4)
      cout << "####################" << endl;
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    int a;
    cin>>a;
    
    map<string,int>mp;
    map<string, int>::iterator it ;
    //set<string>st;
    //std::vector<string>v;
     string s;
     int mx=0;
    for(int i=0;i<a;i++){
        
        cin>>s;
       //v.push_back(s);
       //st.insert(s);
       mp[s]++;
        mx=max(mx,mp[s]);
    }
       
    //cout<<mx;
        
       for (it = mp.begin(); it != mp.end(); ++it) {
           if(it->second==mx){
               cout<<it->first<<"\n";
           }
        } 
   
    return 0;
}


Measured memory_bytes: 25216
import copy

N = int(input())
A = list(map(int, input().split()))  # N+1
B = list(map(int, input().split()))

d_A = copy.deepcopy(A)

ans = 0

for i in range(N):

    if A[i] <= B[i]:
        B[i] -= A[i]
        A[i] = 0
    else:
        A[i] -= B[i]
        B[i] = 0

    if B[i] > 0 and A[i+1] > 0:
        A[i+1] -= min(B[i], A[i+1])


ans = sum([_a - a for a,_a in zip(A, d_A)])


print(ans)

Measured memory_bytes: 18896
#include<iostream>
#include<vector>
#include<set>

using namespace std;

int main () {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    vector<int> inv(n);
    set<int> s;
    for(int i = 0; i < n; i++) {
        s.insert(b[i]);
    }
    if (s.size() == n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
        cout << 1;
        for(int i = 1; i < n; i++) cout << " " << 1;
        cout << endl;
        if (s.find(a[0]) != s.end()) cout << 1;
        else cout << 2;
        for(int i = 1; i < n; i++) if (s.find(a[i]) != s.end()) cout << " " << 1;
        else cout << " " << 2;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 8640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(){
    int n,x;
    cin >> n >> x;
    int l[n];
    rep(i, n) cin >> l[i];
    int i = 0;
    int d = 0;
    while(d <= x){
        d += l[i];
        i++;
        if (i == n + 1)
            break;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
import sys
N,Y=map(int,input().split())
manMax=Y//10000
for i in range(manMax+1)[::-1]:
  res=Y-i*10000
  fiveMax=res//5000
  for j in range(fiveMax+1)[::-1]:
    ress=res-j*5000
    thou=N-i-j
    resss=ress-thou*1000
    if(resss==0):
      print(str(i)+" "+str(j)+" "+str(thou))
      sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		char[][] a = new char[H][W];
		boolean[] s = new boolean[H];
		for(int i = 0; i < H; i++) {
			String S = sc.next();
			a[i] = S.toCharArray();
			s[i] = S.contains("#");
		}
		int firsts = 0;
		for(int i = 0; i < H; i++) {
			if(s[i]) {
				firsts = i;
				break;
			}
		}
		int[][] ans = new int[H][W];
		int p = 1;
		for(int i = firsts; i < H; i++) {
			if(!s[i]) {
				for(int j = 0; j < W; j++)
					ans[i][j] = ans[i-1][j];
			}
			else {
				boolean first = true;
				for(int j = 0; j < W; j++) {
					if(a[i][j] == '.') {
						ans[i][j] = p;
					}
					else {
						if(first)
							first = false;
						else
							p++;
						ans[i][j] = p;
					}
				}
				p++;
			}
		}
		for(int i = 0; i < firsts; i++)
			for(int j = 0; j < W; j++)
				ans[i][j] = ans[firsts][j];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++)
				System.out.print(ans[i][j]+ " ");
			System.out.println();
		}

	}

}


Measured memory_bytes: 44404
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define ll long long
#define MST(vis,x) memset(vis,x,sizeof(vis))

using namespace std;
int main()
{
    int A,B,C,D,E,F;
    while(scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F)!=EOF)
    {
        double ans=0;
        int temp1,temp2;
        int tempa=30/A+1,tempb=30/B+1,tempc=3000/C+1,tempd=3000/D+1;
        for(int a=0;a<=tempa;a++)
        {
            for(int b=0;b<=tempb;b++)
            {
                for(int c=0;c<=tempc;c++)
                {
                    for(int d=0;d<=tempd;d++)
                    {
                        if(a==0&&b==0)break;
                        int w=A*a*100+B*b*100,t=c*C+d*D;
                        if(w+t>=100*A&&w+t<=F&&t*1.0/(w+t)<=E*1.0/(100+E))
                        {
                            if(ans<=t*1.0/(w+t))
                            {
                                ans=t*1.0/(w+t);
                                temp1=w;
                                temp2=t;
                            }

                        }
                        if(w+t>F||t*1.0/(w+t)>E*1.0/(100+E))
                        {
                            break;
                        }
                    }

                }
            }
        }
        printf("%d %d\n",temp1+temp2,temp2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    string S;
    int Q, rev = 0;
    cin >> S >> Q;
    deque<char> deq;
    REP (i, S.size()) deq.push_back(S[i]);
    REP (i, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev ^= 1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if ((rev == 0) ^ (f == 2)) deq.push_front(c);
            else deq.push_back(c);
        }
    }
    if (rev) reverse(deq.begin(), deq.end());
    REP (i, deq.size()) cout << deq[i];
    cout << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
int a,b,t,d;
char as[1000000000];
int main(){
    cin>>as;
    for(int i=0;i<strlen(as);i++){ b+=as[i]-'0'; }
    if(atoi(as)%b==0){ cout<<"Yes"<<endl;}
    else             { cout<<"No"<<endl; }
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
vector<vector<int>> g;
int low[55];
int pre[55];
int ans;

int dfs(int now, int from, int count) {
  pre[now] = count++;
  low[now] = pre[now];

  REP(i, g[now].size()) {
    int to = g[now][i];
    if(pre[to] == -1) {
      low[now] = min(low[now], dfs(to, now, count));
      if(pre[to] == low[to]) {
        ans++;
      }
    } else {
      if(from == to) continue;
      low[now] = min(low[now], low[to]);
    }
  }

  return low[now];
}

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

  cin >> n >> m;
  g.reserve(n + 1);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  fill(low, low + n + 1, -1);
  fill(pre, pre + n + 1, -1);

  ans = 0;
  dfs(1, -1, 0);

  cout << ans << endl;
}


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

int main(){
  int a,b,c,f = 0;
  cin >> a >> b >> c >> f;
  
  for( int x = a; x <= b; x++ ){
    if( c % x == 0 ) f++;
  }
  
  cout << f << endl;
    
    return 0;
}

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

bool lessThan(int h1, int w1, int h2, int w2) {
  int d1 = h1*h1 + w1*w1;
  int d2 = h2*h2 + w2*w2;
  if(d1 != d2) return d1 < d2;
  return h1 < h2;
}

int main() {
  for(int h, w; cin >> h >> w && (h|w);) {
    int c, d;
    c = d = 200;
    for(int a = 1; a <= 150; ++a) {
      for(int b = a+1; b <= 150; ++b) {
        if(lessThan(h, w, a, b) && lessThan(a, b, c, d)) {
          c = a;
          d = b;
        }
      }
    }
    cout << c << " " << d << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    N1 = str(N)[0:-1]
    N2 = str(N)[1:]
    if len(set(N1)) == 1 or len(set(N2)) == 1:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		
		long a[]=new long[100002];
		long sum=0;
		for(int i=0;i<n;i++) {
			int m=sc.nextInt();
			a[m]++;
			sum+=m;
		}
		
		int k=sc.nextInt();
		for(int i=0;i<k;i++) {
			int p=sc.nextInt();
			int q=sc.nextInt();
			long d=a[p];
			a[p]=0;
			sum-=p*d;
			
			long add=q*d;
			sum+=add;
			a[q]+=d;
			
			System.out.println(sum);
		}
	}
	
	
}

 


Measured memory_bytes: 58260
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1e9;
const ll LLINF = 1e16;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<n-2; i++){
        if(s.substr(i, 3) == "ABC") ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int  int64_t
#define all(a) (a).begin(), (a).end()

int32_t main(){ 
   ios::sync_with_stdio(false) ; 
   cin.tie(0) ;
   double d , t , s  ; 
   cin >> d >> t >> s ;
   double tm = d / s ;
   if(tm<=t){
      cout << "Yes" ; 
   }else{
      cout << "No";
   }
   cout << "\n" ; 
   
	return 0 ;
}

Measured memory_bytes: 3744
object Main extends App {
    val n = io.StdIn.readInt
    var as = io.StdIn.readLine.split(" ").map(_.toInt)

    var count = 0
    while (as.forall(_%2==0)) {
        as = as.map(_/2)
        count += 1
    }
    println(count)

}

Measured memory_bytes: 25532
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int abs(int p) {return (p > 0) ? p : -p;}

int n, x, y;
int a[4005];

int main()
{
    scanf("%d%d%d", &n, &x, &a[0]);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    printf("%d", max(abs(a[n] - a[n - 1]), abs(a[n] - a[0])));
    return 0;
}


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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-12;

using namespace std;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cout<<"ACL";
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,K,x;
 int total=0;
  cin >> N >> K;
  
  for(int i = 0;i<N;i++){
    cin >> x;
    if(x <= K-x){
     total += (x*2); 
    } else {
     total += ((K-x)*2);
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int a,b;cin>>a>>b;
  if (a<=8&&b<=8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAXN 300006
#define MOD 998244353
using namespace std;
long long a,b,k,fac[MAXN],inv[MAXN],ans,n;
long long ksm(long long a,long long m)
{
	if(m==0) return 1;
	long long nex=ksm(a,m/2);
	if(m%2==1) return ((nex*nex)%MOD*a)%MOD;
	return nex*nex%MOD;
}
void waiting()
{
	fac[0]=1;
	for(long long i=1;i<MAXN;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%MOD;
}
long long C(long long x,long long y)
{
	if(y<x) return 0;
	return ((fac[y]*inv[x])%MOD*inv[y-x])%MOD;
}
int main()
{
	waiting();
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(long long i=0;i<=n;i++)
	{
		if((k-i*a)%b==0&&k-i*a<=n*b&&k-i*a>=0)
		{
			ans=(ans+(C(i,n)*C((k-i*a)/b,n)%MOD))%MOD;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4864
# https://atcoder.jp/contests/abc117/tasks/abc117_d
=begin
3 7
1 6 3

14

4 9
7 4 0 3

46

1 0
1000000000000

1000000000000
=end
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

upper_bit = K.to_s(2)
zero_str = (0..40).to_a.each_with_object([]) { |i, obj| obj << '0' * i }.reverse
zero_fill_strA = A.map { |i| (t = i.to_s(2)) && "#{zero_str[t.size]}#{t}" }
zero_fill_upper_bit =  "#{zero_str[upper_bit.size]}#{upper_bit}"

one = '1'
beki_ary = (1..39).to_a.each_with_object([1]) { |i, obj| obj << (obj.last * 2)}.reverse
already_min = false

ans = 0
0.step(39) do |digest|
  ones = zero_fill_strA.count { |str| str[digest] == one }
  if ones * 2 >= N
    already_min = true if zero_fill_upper_bit[digest] == one
    ans += beki_ary[digest] * ones
  else
    if already_min || zero_fill_upper_bit[digest] == one
      ans += beki_ary[digest] * (N - ones)
    else
      ans += beki_ary[digest] * ones
    end
  end
end
p ans

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT ds(N);
  REP(i,N) cin>>ds[i];
  sort(ALL(ds));
  ds.erase(unique(ALL(ds)),ds.end());
  OUT(ds.size());

  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readln;
    auto xs = readints();

    int[int] m;
    foreach (x; xs) {
        m[x]++;
    }

    int[] cans;
    foreach (k, v; m) {
        if (v >= 4) {
            cans ~= k;
            cans ~= k;
        }
        else if (v >= 2) {
            cans ~= k;
        }
    }

    sort(cans);
    if (cans.length >= 2) {
        auto ans = cast(long) cans[$ - 2] * cans[$ - 1];
        writeln(ans);
    }
    else {
        writeln(0);
    }
}


Measured memory_bytes: 9780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
struct edge { int u, v, cost; };
int par[114514], rnk[114514];
edge es[114514];
bool comp(const edge&e1, const edge&e2) {
	return e1.cost<e2.cost;
}
void init(int n) {
	for (int i = 0; i<n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x]<rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}

}

int w(int a,int b) {
	int ans = 0;
	while (!(a%b)) {
		ans++;
		a /= b;
	}
	return ans;
}

signed main() {
	int d, n; cin >> d >> n;
	if (d == 0) {
		if (n == 100)cout << 101 << endl;
		else cout << n << endl;
	}
	if (d == 1) {
		if (n == 100)cout << 10100 << endl;
		else cout << n << "00" << endl;
	}
	if (d == 2) {
		if (n == 100)cout << 101 << "0000" << endl;
		else cout << n << "0000" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)

{
    int n, a, p;
    cin>>n;
    if(n%1000 == 0){
        cout<<"0\n";
    }
    else{
        a = n/1000;
        a++;
        p = a*1000;
        a = p-n;
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 3196
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n;
int a[N],b[N];
LL sa=0,sb=0;
int main(){
	n=read();
	For(i,1,n)
		a[i]=read(),sa+=a[i];
	For(i,1,n)
		b[i]=read(),sb+=b[i];
	LL sc=0;
	For(i,1,n)
		if (a[i]>b[i])
			sc+=a[i]-b[i];
		else if ((b[i]-a[i])%2)
			sc++;
	puts(sb-sa>=sc?"Yes":"No");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;
  
 for (int i = 0;; i++) {
   
     if (N<1000) {
      cout << 1000-N << endl;
      break; 
    }
    if (N==1000) {
      cout << 0 << endl;
      break; 
    }
   
   N=N-1000;
 }
}

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

int main()
{
  int N, K;
  int p[1000];
  
  cin >> N >> K;
  for (int i=0; i<N; i++)
  {
    cin >> p[i];
  }
  
  sort(p,p+N);
  
  int Total = 0;
  
  for (int i = 0; i < K; i++)
  {
    Total += p[i];
  }
  
  cout << Total << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define mo 1000000007
#define MAX 100004
#define fast_io ios::sync_with_stdio(false)

long long fact[MAX];


long long pow(int a, int b, int MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}
long long InverseEuler(int n, int MOD = mo)
{
    return pow(n,MOD-2,MOD);
}
ll nCr(int n, int r)
{
	if(n<r)
		return 0;
	ll temp = (1ll*((1ll*fact[n]*InverseEuler(fact[r], mo))%mo)*InverseEuler(fact[n-r],mo))%mo;
	return temp;
}
void pre()
{
	fact[0]=1;
	for(int i=1;i<MAX;i++)
		fact[i] = (1ll*fact[i-1]*i)%mo;
}
int a[MAX];
int main()
{
	pre();
	fast_io;
	int n;
	cin >> n;
	int d = 0;
	for(int i=1;i<=(n+1);i++)
	{
		int x;
		cin >> x;
		if(a[x])
		{
			d = i - a[x];
		}
		a[x] = i;
	}
	long long temp;
	for(int k=1;k<=(n+1);k++)
	{
		temp = ((nCr(n+1, k) - nCr(n - d, k - 1))%mo + mo)%mo;
		cout << temp << "\n"; 
	}
	return 0;
}

Measured memory_bytes: 2432
A = [0] * 5
for i in range(5):
  A[i] = int(input())
A.sort(reverse=True, key=lambda x: x % 10)
for i in range(5):
  if A[4] % 10 == 0:
    A = [A[4]] + A[:4]
  else:
    break
t = 0
for a in A[:4]:
  a += 9
  t += a - a % 10
print(t + A[4])

Measured memory_bytes: 3060
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b = map(int,input().split())
    ans = 0
    if a <= b:
        ans += a
    else:
        ans += a - 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s; cin>>s;
    int n=s.length();
    int cnt=0;
    for(int i=0,j=n-1; i<j; i++,j--){
        if(s[i]!=s[j])cnt++;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int N = 2e3 + 7;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int dp[N][N];
int ps[N][N];

vector<int> s;
vector<int> t;

int calc(int i, int j) {
	if (dp[i][j] == -1) {
		dp[i][j] = 0;
		for (int i1 = 0; i1 < i; i1++) {
			for (int j1 = 0; j1 < j; j1++) {
				if (s[i1] == t[j1]) {
					dp[i][j] = add(dp[i][j], calc(i1, j1));
				}
			}
		}
		dp[i][j]++;
	}
	return dp[i][j];
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = -1;
		}
	}
	int n, m;
	cin >> n >> m;
	s.resize(n);
	t.resize(m);
	for (auto &x : s) cin >> x;
	for (auto &x : t) cin >> x;
	int ans = 0;
	auto gt = [&](int i, int j) {
		if (i >= 0 && j >= 0) return ps[i][j];
		else return (int)0;
	};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				dp[i][j] = gt(i - 1, j - 1);
				dp[i][j] = add(dp[i][j], 1);
				ans = add(ans, dp[i][j]);
			} else {
				dp[i][j] = 0;
			}
			ps[i][j] = gt(i - 1, j) + gt(i, j - 1) - gt(i - 1, j - 1) + dp[i][j];
			ps[i][j] %= MOD;
			ps[i][j] += MOD;
			ps[i][j] %= MOD;	
		}
	}
	ans = add(ans, 1);
	cout << ans << endl;
}


Measured memory_bytes: 63232
N,X=map(int,input().split())  #S=2**(N+2)-3
                  #P=2**(N+1)-1
def solve(N,X):
    if X==0:
        return 0
    if N==0:
        return X
    if X<2**(N+1)-1:
        return solve(N-1,X-1)
    elif X==2**(N+1)-1:
        return 2**N
    elif X<2**(N+2)-3:
        return 2**N+solve(N-1,X-2**(N+1)+1)
    else:
        return 2**(N+1)-1

print(solve(N,X))


Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int a[110];
int score[110] = {};

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

	int n, m;
	cin >> n >> m;

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

	for(int i = 0; i < m; ++i){
		int miss = 0;
		for(int j = 0; j < n; ++j){
			int b;
			cin >> b;
			if(a[i] == b){
				++score[j];
			}
			else {
				++miss;
			}
		}
		score[a[i] - 1] += miss;
	}

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

	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  int a,b,c,d, S,E; //Start,End
  cin >> a >> b >> c >> d;
  if (a<c){
  	S = c;
  }else{
  	S = a;
  }

  if (b<d){
  	E = b;
  }else{
  	E = d;
  }


  if(S<E){
  	cout << E-S <<endl;
  }else{
  	cout << "0" << endl;
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int mod=998244353;
int vis[100000+9];
vector<int> v;
ll power(ll b,ll p){
  if(p==0){
    return 1;

  }
  if(p&1){
    return (b%mod*power((b%mod*(b%mod))%mod,p/2))%mod;
  }
  else{
    return power((b%mod*(b%mod))%mod,p/2)%mod;
  }
}
int main(){
    GO();
    int n;
    int node=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int no;
        cin>>no;
        vis[no]++;
        if(vis[no]==1)
         v.pb(no);

        if(no==0){
            node=i;
        }
    }

    if(!(vis[0]==1&&node==1)){
        cout<<"0\n";
        return 0;
    }
    sort(all(v));
    ll ans=1;
    for(int i=0;i<sz(v);i++){
        if(v[i]>=1&&vis[v[i]-1]==0){
            cout<<"0\n";
            return 0;
        }
       // cout<<vis[v[i]-1]<<" "<<vis[v[i]]<<endl;
        if(v[i]>1)
        ans=(ans*(1ll*power(vis[v[i]-1],vis[v[i]])))%mod;
    }
    cout<<ans<<endl;
}




































Measured memory_bytes: 1276
#include <iostream>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1,};
    if(a[x] == a[y]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main() {
    ll K=0,A=0,B=0;
    cin >> K >>A >>B;
    if(K*(B/K)<=B&&K*(B/K)>=A)
    cout << "OK";
    else
    cout << "NG";

}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main(){

    int b1, b2, b3;
    cin >> b1 >> b2 >> b3;

    if(b1 && b2 == 1){
        cout << "Open" << endl;
    }
    else if(b3 == 1){
        cout << "Open" << endl;
    }
    else{
        cout << "Close" << endl;
    }

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	set<char>st;
	set<char>::iterator it;
	string s;
	cin>>s;
	int l=s.length();
	st.insert(s.begin(),s.end());
	if(st.size()==26)
	{
		cout<<"None";
		return 0;
	}
	char c='a';
	for(it=st.begin();it!=st.end();it++)
	{
		if((*it)!=c)
		{
			cout<<c;
			return 0;
		}
		else
		c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		int[] numlist = new int[3];
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < numlist.length; i++) {
			numlist[i] = sc.nextInt();
		}
		Arrays.sort(numlist);
		for (int n = 0; n < numlist.length; n++) {
			if (n < numlist.length - 1) {
				System.out.print(numlist[n] + " ");
			} else if (n < numlist.length) {
				System.out.println(numlist[n]);
			}
		}
	}
}



Measured memory_bytes: 26140
#正解数で順位を決定
team=[]
point=[]
dic={}
while True:
    p,s=map(int, input().split(","))
    if p==s==0:
        break
    team.append([p,s])
    if s not in point:
        point.append(s)
        
point.sort(reverse=True)

#辞書(得点,順位)で作る
for i in range(len(point)):
    dic[point[i]]=i+1
    
while True:
    try:
        n=int(input())
    except EOFError:
        break
    print(dic[team[n-1][1]])
    



Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */
int s;
vector<bool> check(1001000);
vector<int> A;

bool checkAns(int a) {
    if(check[A[a + 1]] == true) {
        return true;
    } else {
       return false;
    }
}

int main() {
    cin >> s;
    check[s] = true;
    A.push_back(s);
    int cnt = 0;
    while(true){
        if(A[cnt] % 2 == 0) {
            A.push_back(A[cnt] / 2);
        } else {
            A.push_back(3 * A[cnt] + 1);
        }
        if(checkAns(cnt)) {
            cout << cnt + 2 << endl;
            return 0;
        } else {
            check[A[cnt + 1]] = true;
        }
        cnt++; 
    }

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vll s(100009),t(100009);
vll truth(100009);

int vec[]={2,5,5,4,5,6,3,7,6};
vint arr;
vint ans(100000);

int check(ll k){
    int counter=0;
    while(true){
        if(k==0)break;
        counter++;
        k/=2;
    }
    return counter;
}

int main(){
    ll n;
    ll k;
    cin>>n>>k;
    vll a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll maxa=a[n-1];

    ll num=max(check(k),check(maxa));
    ll ans=0;
    ll remain=k;

    //cout<<num<<endl;

    repr(i,num){
        int sum=0;
        rep(j,n){
            sum+=(a[j] & (1ll<<i))>>i;
            //cout<<sum<<endl;
        }
        if(sum<n-sum && 1ll<<i <= remain){
            //ans+=sum*(1ll<<i);
            remain-=1ll<<i;
            //cout<<"hh"<<endl;
            ans+=(ll)(n-sum) * 1ll<<i;
            //cout<<sum<<" "<<n-sum<<" "<<ans<<endl;          
        }
        else{
            //cout<<i<<endl;
            //ll add_num=(ll)1ll<<i;
            ans+=(ll)sum * 1ll<<i;
            //cout<<sum<<" "<<n-sum<<" "<<ans<<endl; 
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
	int ans;
	double a,b;
	while(1){
		scanf("%lf",&a);
		if(a >= 0 && a<=100){
			break;
		}
	}
	ans = (a / 2)+ 0.5;
	b = ans / a;
	printf("%lf",b);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
    char s[4];
    scanf("%s", s);
    int a=0, b=0;
    for (int i=0; i<3; ++i){
        if (s[i]=='A')
            ++a;
        else
            ++b;
    }
    if (a==2 || b==2)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int a, b, n;
	char op;
	while (cin >> a >> op >> b && op != '?') {
		switch (op) {
		case '+':
			n = a + b; break;
		case '-':
			n = a - b; break;
		case '/':
			n = a / b; break;
		case '*':
			n = a * b; break;
		}
		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> jikoku{0, 24}, d(n);
  REP(i, n) {
    cin >> d[i];
    if (d[i] == 0) {
      cout << 0 << '\n';
      return 0;
    }
  }
  sort(ALL(d));
  REP(i, n) {
    int index1 = distance(jikoku.begin(), lower_bound(ALL(jikoku), d[i])), index2 = distance(jikoku.begin(), lower_bound(ALL(jikoku), 24-d[i]));
    int sa1 = min(jikoku[index1]-d[i], d[i]-jikoku[index1-1]), sa2 = min(jikoku[index2]-(24-d[i]), (24-d[i])-jikoku[index2-1]);
    if (sa1 >= sa2) jikoku.push_back(d[i]);
    else jikoku.push_back(24-d[i]);
    sort(ALL(jikoku));
  }
  int ans = 12;
  REP(i, jikoku.size()-1) ans = min(ans, jikoku[i+1]-jikoku[i]);
  cout << ans << '\n';
  return 0;
}


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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

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

#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;
typedef vector<string> vs;

#define SZ(x) ((int)(x).size())

#define fill(x,y) memset(x,y,sizeof(x))

// with compile option -DLOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

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

#define pcnt __builtin_popcount
#define pcntll __builtin_popcountll

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    string s;
    cin >> s;
    int ret = INF;

    rep(SZ(s) - 2) {
        int val = stoi(s.substr(i, 3));
        int diff = abs(val - 753);
        if(diff < ret)
            ret = diff;
    }

    cout << ret << endl;
    
    return 0;
}



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

using namespace std;

int main(void) 
{
    vector<int> candys(3);
    for (auto& in : candys) {
        cin >> in;
    }
    sort(candys.begin(), candys.end());
    if (candys[0] + candys[1] == candys[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto A = readAs!(long[]);
	ulong res;
	long tmp;
	ulong[long] m;
	m[0] = 1;
	foreach(i; 0..N) {
		tmp += A[i];
		if(tmp in m) res += m[tmp];
		m[tmp]++;
	}
	writeln(res);
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main() {
    string st;
    cin >> st;
    vector<char> s(st.size());
    vector<char> r(st.size());
    for(int i = 0; i < s.size(); i++) {
        s.at(i) = st.at(i);
    }
    for(int i = 0; i < s.size(); i++) {
        r.at(i) = st.at(s.size() - 1 - i);
    }

    if(s != r) {
        cout << "No" << endl;
        return 0;
    }
    vector<char> a(st.size() / 2);
    vector<char> ar(st.size() / 2);
    for(int i = 0; i < s.size() / 2; i++) {
        a.at(i) = st.at(i);
    }
    for(int i = 0; i < s.size() / 2; i++) {
        ar.at(i) = st.at(s.size() / 2 - 1 - i);
    }
    if(a != ar) {
        cout << "No" << endl;
        return 0;
    }

    vector<char> b(st.size() / 2);
    vector<char> br(st.size() / 2);
    for(int i = 0; i < s.size() / 2; i++) {
        b.at(i) = r.at(i);
    }

    for(int i = 0; i < s.size() / 2; i++) {
        br.at(i) = r.at(s.size() / 2 - 1 - i);
    }
    if(b != br) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

int main(){
 int n;
 cin>>n;
  
 int k= n%10;
  
  if(k==3) cout<<"bon"<<endl;
  else if(k==0 || k==1 || k==6 || k==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  
return 0;
}



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

typedef pair<int,int> P;

const int INF = 1 << 28;
const int dx[] = {0, 1,-1, 1, 0,-1};
const int dy[] = {1, 0,-1, 1,-1, 0};

int main ()
{
    int t, n;
    while (cin >> t >> n, (n || t)) {
        int d[222][222];
        bool w[222][222];
        for (int i = 0; i < 222; i++) {
            for (int j = 0; j < 222; j++) {
                d[i][j] = INF;
                w[i][j] = true;
            }
        }

        for (int i = 0; i < n; i++) {
            int t1, t2;
            cin >> t1 >> t2;
            d[t1 + 60][t2 + 60] = -1;
        }

        int x, y;
        cin >> x >> y;
        d[x + 60][y + 60] = 0;
        w[x + 60][y + 60] = false;
        queue<P> q;
        q.push(P(x + 60, y + 60));

        int count = 1;
        while (q.size()) {
            P p = q.front();
            q.pop();

            for (int i = 0; i < 6; i++) {
                int nx = p.first + dx[i], ny = p.second + dy[i];
                if (0 <= nx && nx < 222 && 0 <= ny && ny < 222 && d[nx][ny] != -1) {
                    if (d[nx][ny] > d[p.first][p.second] + 1 && d[p.first][p.second] < t) {
                        if (w[nx][ny]) count++, w[nx][ny] = false;
                        q.push(P(nx,ny));
                        d[nx][ny] = d[p.first][p.second] + 1;
                    }
                }
            }
        }

        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1460
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<3;i++){
		if(s[i]=='R'){
			cnt++;
		}
	}
	if(cnt==2){
		if((s[0]=='R'&&s[1]=='R')||(s[2]=='R'&&s[1]=='R')){
			cout<<2<<"\n";
		}else{
			cout<<1<<"\n";
		}
	}else{
		cout<<cnt<<"\n";
	}
	return 0;
	}
	
	
	
	
	
	



Measured memory_bytes: 3652
from math import factorial
MOD = 10**9 + 7

# 階乗を用意
fact = [1] * (10**5 + 1)
for i in range(1, 10**5 + 1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD

def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    global fact
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = fact[n]
    b = fact[k]
    c = fact[n-k]
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p

def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = 0

# pos
for i in range(n-1):
    c = comb(n-1-i, k-1, MOD)
    ans += a[n-1-i] * c
    ans %= MOD
    ans -= a[i] * c
    ans %= MOD
print(ans)



Measured memory_bytes: 18520
#include <iostream>
#include <algorithm>
using namespace std;
int h,k;
int main() {
	cin>>h>>k;
	int a[h],b[(h-k+1)],c[(h-k+1)];
	
	for(int i=0;i<h;i++){
		cin>>a[i];
	}
	for(int i=0;i+k-1<h;i+=1){
		b[i]=a[i+k-1]-a[i]+abs(a[i]);
		c[i]=a[i+k-1]-a[i]+abs(a[i+k-1]);
	}
	//sort(b,&b[(h-k+1)*2]);
	sort(b,&b[(h-k+1)]);
	sort(c,&c[h-k+1]);
	//cout<<b[0]<<endl;
	//for(int i=0;i<(h-k+1);i++){
		cout<<min(b[0],c[0])<<endl;
	//}
	return 0;
}

Measured memory_bytes: 1024
import math

def A():
    x, a, b = [int(x) for x in input().split()]
    if abs(x-a) < abs(x-b):
        print('A')
    else:
        print('B')
def B():
    S = input()
    alphabet = [False for x in range(26)]
    for char in S:
        i = ord(char) - ord('a')
        alphabet[i] = True
    printed = False
    for i in range(len(alphabet)):
        if alphabet[i] == False:
            print(chr(ord('a')+i))
            printed = True
            break
    if printed == False:
        print("None")
def C():
    n = int(input())
    three = 0

A()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
//#include <search.h>
#include <algorithm>
//#include <vector>
using namespace std;
int main()
{
 char c;
 long long int a,b;
 cin>>a>>c>>b;
 if(c=='+') cout<<a+b;
 else cout<<a-b;

return 0;
}


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

int main() {
    vector<int> v;
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        int m;
        cin >> m;
        v.push_back(m);
    }

    sort(v.begin(), v.end());

    for(int i = 0; i < n-1; i++){
        if(v[i] == v[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1400
from itertools import combinations

# input
L, R = map(int, input().split())

# check
mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)

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

int main()
{
  int N;
  cin >> N;
  
  map<int, bool> d_count;
  rep(i, N)
  {
    int d;
    cin >> d;
    
    d_count[d] = true;
  }
  
  cout << d_count.size() << endl;
}


Measured memory_bytes: 256