akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 2000005;
const int MM = 1000000007;

ll F[MX], I[MX], FI[MX];

ll C(ll x, ll y){
	if( x < y ) return 0;
	return F[x] * FI[y] % MM * FI[x-y] % MM;
}

ll solve(int sx, int sy, int px, int py, int qx, int qy, int ex, int ey)
{
	ll ans = 0;
	for(int i = px; i <= qx; i++){
		ans = (ans + MM - C(i-sx + py-sy-1, i-sx) * C(ex-i + ey-py, ex-i) % MM * (i-sx+py-sy) % MM);
	}
	for(int i = px; i <= qx; i++){
		ans = (ans + C(i-sx + qy-sy, i-sx) * C(ex-i + ey-qy-1, ex-i) % MM * (i-sx+qy+1-sy) % MM);
	}

	for(int i = py; i <= qy; i++){
		ans = (ans + MM - C(i-sy + px-sx-1, i-sy) * C(ey-i + ex-px, ey-i) % MM * (i-sy+px-sx) % MM);
	}
	for(int i = py; i <= qy; i++){
		ans = (ans + C(i-sy + qx-sx, i-sy) * C(ey-i + ex-qx-1, ey-i) % MM * (i-sy+qx+1-sx) % MM);
	}
	return ans % MM;
}

int main()
{
	F[0] = FI[0] = 1; I[1] = 1;
	for(int i = 2; i < MX; i++) I[i] = (MM - MM/i) * I[MM%i] % MM;
	for(int i = 1; i < MX; i++){
		F[i] = F[i-1] * i % MM;
		FI[i] = FI[i-1] * I[i] % MM;
	}

	int X[7], Y[7];
	for(int i = 1; i <= 6; i++) scanf("%d", X+i);
	for(int i = 1; i <= 6; i++) scanf("%d", Y+i);
	int sx[4] = {X[1]-1, X[1]-1, X[2], X[2]};
	int sy[4] = {Y[1]-1, Y[2], Y[1]-1, Y[2]};
	int sp[4] = {1, -1, -1, 1};
	
	int ex[4] = {X[6]+1, X[6]+1, X[5], X[5]};
	int ey[4] = {Y[6]+1, Y[5], Y[6]+1, Y[5]};
	int ep[4] = {1, -1, -1, 1};

	ll ans = 0;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			ans = (ans + MM + sp[i] * ep[j] * solve(sx[i], sy[i], X[3], Y[3], X[4], Y[4], ex[j], ey[j])) % MM;
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define node first
#define weight second
#define MOD 1000000007
typedef pair <int, int> ii;

int cost(int a, int b)
{
	return (max(a,b) - min(a,b));
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n, k;
	cin >> n >> k;
	int height[n+5], dp[n+5] = {(1LL<<62)};
	for(int i = 1; i <= n; i++)
	{
		cin >> height[i];
		dp[i] = (1LL<<62);
	}
	dp[1] = 0;
	for(int i = 2; i <= n; i++)
		for(int j = 1; j <= k && (i-j) >= 0; j++)
			dp[i] = min(dp[i], cost(height[i], height[i-j]) + dp[i-j]);
	cout << dp[n];
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int partition(vector<pair<char, int> >& v, int p, int r)
{
  int val = v[r].second;
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (v[j].second <= val) {
      ++i;
      swap(v[i], v[j]);
    }
  }
  swap(v[i + 1], v[r]);
  return i + 1;
}

void quickSort(vector<pair<char, int> >& v, int l, int r)
{
  if (l >= r) { return; }
  int q = partition(v, l, r);
  quickSort(v, l, q - 1);
  quickSort(v, q + 1, r);
}

static bool cmp(const pair<char, int>& p1, const pair<char, int>& p2)
{
  return p1.second < p2.second;
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<pair<char, int> > v(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, " %c %d", &v[i].first, &v[i].second);
  }
  vector<pair<char, int> > u(v);
  stable_sort(u.begin(), u.end(), cmp);
  quickSort(v, 0, n - 1);
  fprintf(stdout, "%s\n", u == v ? "Stable" : "Not stable");
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, "%c %d\n", v[i].first, v[i].second);
  }
  return 0;
}

Measured memory_bytes: 3380
#include<iostream>
#include<string>
using namespace std;
int N_MAX = 300;
int main()
{
  int n,i,j,b,ii,jj,res=0;
  bool f;
  string s[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> s[i];
  for(b=0;b<n;b++){
    f=false;
    for(i=0;i<n;i++){
      ii=i-b;
      if(ii<0) ii+=n;
      for(j=0;j<n;j++){
        jj=j+b;
        if(jj>=n) jj-=n;
        if(jj<=i) continue;
        if(s[i][j]!=s[jj][ii]){
          f=true;
          break;
        }
      }
      if(f) break;
    }
    if(!f) res++;
  }
  res*=n;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
lin = list(accumulate(li))
point = 1
for i in range(n-1):
    if lin[i]*2 >= li[i+1]:
        point += 1
    else:
        point = 1
print(point)

Measured memory_bytes: 14428
n,m=map(int,input().split())
mat=[]
for i in range(10):
    mat.append([int(i) for i in input().split()])

for k in range(10):
    for i in range(10):
        for j in range(10):
            mat[i][j]=min(mat[i][j],mat[i][k]+mat[k][j])
            #mat[j][i]=mat[i][j]
a=[]

ans=0
for i in range(n):
    l=[int(x) for x in input().split()]
    for z in l:
        if z!=-1 and z!=1:
           # print(z)
            ans+=mat[z][1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
	INCANT;
	int n, res = 0, l, r, mid;
	int a[2222] = {};
	cin>>n;
	rep(i, n) {
    	cin>>a[i];
	}
	sort(a, a + n);
	rep(i, n) {
		rep(j, i + 1, n) {
			l = j, r = n;
			while(r - l > 1) {
				mid = (l + r) / 2;
				if(a[mid] < a[i] + a[j] && a[i] < a[j] + a[mid] && a[j] < a[mid] + a[i]) {
					l = mid;
				} else {
					r = mid;
				}
			}
			res += l - j;
		}
	}
	cout<<res<<endl;
}


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

using namespace std;

int ban[10][5];

int turn(int score)
{
	int cpban[10][5];
	bool f=false;
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<5;j++)
			cpban[i][j]=ban[i][j];
	}

	//消滅
	for(int i=0;i<10;i++)
	{
		int j=0;
		while(j<5)
		{
			if(ban[i][j]==0)
			{
				j++;
				continue;
			}else{
				int tmp=ban[i][j];
				int cnt=1;
				j++;
				while(j<5 && ban[i][j]==tmp)
				{
					cnt++;
					j++;
				}
				if(cnt>=3)
				{
					f=true;
					score+=cnt*tmp;
					for(int k=j-cnt;k<j;k++)
						ban[i][k]=0;
				}
			}
		}	
	}

	if(!f)
		return score;
	//落下
	for(int c=0;c<10;c++)
	{
		for(int j=0;j<5;j++)
		{
			for(int i=9;i>-1;i--)
			{
				if(ban[i][j]==0 && ban[i+1][j]>0)
				{
					ban[i][j]=ban[i+1][j];
					ban[i+1][j]=0;
				}
			}
		}
	}
	return turn(score);
}

int main()
{
	while(1)
	{
		fill(ban[0],ban[10],0);
		int h;
		cin>>h;
		if(h==0)
			break;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<5;j++)
			{
				int t;
				cin>>t;
				ban[h-i-1][j]=t;
			}
		}

		int ans=turn(0);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    char c[2][3];
    REP(i, 2){
        REP(j, 3){
            cin >> c[i][j];
        }
    }

    string ans;
    bool isitti = true;
    REP(i,3){
        if(c[0][i] != c[1][2-i]){
            isitti = false;
        }
    }

    if(isitti) ans = "YES";
    else ans = "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> time(N);
    vector<int> x(N);
    vector<int> y(N);

    time[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i < N; i++)
    {
        cin >> time[i] >> x[i] >> y[i];
    }

    int turn;
    int diff_x;
    int diff_y;
    int dis;
    for (int i = 0; i < N - 1; i++)
    {
        turn = time[i + 1] - time[i];
        diff_x = abs(x[i + 1] - x[i]);
        diff_y = abs(y[i + 1] - y[i]);
        dis = diff_x + diff_y;
        // printf("turn = %d, dis = %d\n", turn, dis);

        if (turn < dis)
        {
            cout << "No" << endl;
            return (0);
        }
        else
        {
            if (turn % 2 == 0)
            {
                if (dis % 2 == 0)
                {
                    // even & even
                    // possbile
                    continue;
                }
                else
                {
                    // even & odd
                    cout << "No" << endl;
                    return (0);
                }
            }
            else
            {
                if (dis % 2 == 0)
                {
                    // odd & even
                    cout << "No" << endl;
                    return (0);
                }
                else
                {
                    // odd & odd
                    // possible
                    continue;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return (0);
}

Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AMultiplication1 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a, b; cin >> a >> b;
      cout << a*b << endl;
    }
};

signed main() {
  AMultiplication1 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

int main()
{
  int N, T[100000];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> T[i];
  int p = *max_element(T, T + N);
  vector< int > divisor;
  for(int i = 1; i * i <= p; i++) {
    if(p % i == 0) {
      divisor.push_back(i);
      if(i * i != p) divisor.push_back(p / i);
    }
  }
  sort(begin(divisor), end(divisor));
  int ret = 0;
  for(int i = 0; i < N; i++) {
    ret += *lower_bound(begin(divisor), end(divisor), T[i]) - T[i];
  }
  cout << ret << endl;
}

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

int main(int argc, char *argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;


    const int MAX_VAL = 1e5;
    vector<vector<int>> counts(2, vector<int>(MAX_VAL + 1, 0));
    vector<vector<int>> numbers(2);

    for(int i = 0; i < n; ++i) {
        int x; cin >> x;

        counts[i % 2][x]++;
        numbers[i % 2].push_back(x);
    }

    for(int i = 0; i < 2; ++i) {
        sort(numbers[i].begin(), numbers[i].end());
        numbers[i].erase(unique(numbers[i].begin(), numbers[i].end()), numbers[i].end());

        sort(numbers[i].begin(), numbers[i].end(), [&](int x1, int x2) { 
                return counts[i][x1] > counts[i][x2]; 
        });
    }

    int minCost = INT_MAX;
    for(int x : numbers[0]) {
        int curr = n/2 - counts[0][x];

        int i = 0;
        while(i < numbers[1].size() && numbers[1][i] == x) ++i;

        curr += n/2;

        if(i != numbers[1].size()) {
            curr -= counts[1][numbers[1][i]];
        }

        minCost = min(curr, minCost);
    }

    cout << minCost << '\n';
}


Measured memory_bytes: 1784
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<stack>
using namespace std;
int main(){
    while(1){
        int n,m,i,j,ans=0;
        cin >> n >> m;
        vector<int> p(n);
        if(n==0&&m==0)  break;
        for(i=0;i<n;i++){
            cin >> p[i];
        }
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(p[i]+p[j]<=m&&ans<p[i]+p[j])   ans = p[i]+p[j];
            }
        }
        if(ans==0)  cout << "NONE"<< endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
n = int(input())
s = input()

w = 0
e = s.count('E')
ans = s.count('E')
for i in range(n):
  if i:
    if s[i - 1] == 'W':
      w += 1
  if s[i] == 'E':
    e -= 1
  ans = min(ans,w + e)
    
print(ans)

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int arr[N], n;
typedef long long LL;
LL h[N];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        scanf("%d",&arr[i]);
        h[arr[i]]++;
    }
    LL sol = 0;
    for(int i = 1; i < N; i++){
        sol += (h[i]*(h[i]-1))/(LL)2;
    }
    for(int i = 1; i <= n; i++){
        sol -= h[arr[i]]*(h[arr[i]]-1)/(LL)2;
        sol += (h[arr[i]]-1)*(h[arr[i]]-2)/(LL)2;
        printf("%lld\n",sol);
        sol -= (h[arr[i]]-1)*(h[arr[i]]-2)/(LL)2;
        sol += h[arr[i]]*(h[arr[i]]-1)/(LL)2;
    }
    return 0;
}


Measured memory_bytes: 3968
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	s1, s2 := makeString(len(s))
	fmt.Println(compareString(s, s1, s2))
}

func makeString(n int) (string, string) {
	var s string
	for i := 0; i < (n-1)/2; i++ {
		s += "01"
	}
	if n%2 == 0 {
		return s + "01", "1" + s + "0"
	}

	return s + "0", "1" + s
}

func compareString(s, s1, s2 string) int {
	r := []rune(s)
	r1 := []rune(s1)
	r2 := []rune(s2)
	var cou1, cou2 int
	for i := range r {
		if r[i] != r1[i] {
			cou1++
		}
		if r[i] != r2[i] {
			cou2++
		}
	}
	if cou1 <= cou2 {
		return cou1
	} else {
		return cou2
	}
}


Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    int y=1;
    while(true){
        if(y*(y-1)/2<n){
            if(n<=y*(y+1)/2)break;
        }
        y++;
    }
    int x=y*(y+1)/2-n;
    for(int i=1;i<=y;i++){
        if(i==x)continue;
        else cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,l;
  cin >> n;
  int f[60010];
  l=sqrt(n);
  l/=1;
  for(int i=1;i<=l;i++){
    for(int ii=i;ii<=l;ii++){
      for(int iii=ii;iii<=l;iii++){
        m=i*i+ii*ii+iii*iii+i*ii+ii*iii+iii*i;
        if(i==ii){
          if(ii==iii){
            f[m]++;
          }else{
            f[m]+=3;
          }
        }else if(ii==iii){
          f[m]+=3;
        }else{
          f[m]+=6;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<< f[i+1] << endl;
  }
}

Measured memory_bytes: 3808
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    X, Y, A, B, C = map(int, input().split())
    p = sorted(list(map(int, input().split())), reverse=True)
    q = sorted(list(map(int, input().split())), reverse=True)
    r = sorted(list(map(int, input().split())))

    ans = []
    ans += p[:X]
    ans += q[:Y]
    ans.sort(reverse=True)

    #print(ans, r)

    cl = 0
    while len(ans) and len(r):
        if ans[-1] < r[-1]:
            cl += r[-1]
            ans.pop(-1)
            r.pop(-1)
        else:
            break

    #print(ans, cl)
    print(sum(ans) + cl)


if __name__ == '__main__':
    solve()


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w;
  string s ;
  cin >> h >> w;
  rep(i,h){
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int a[N];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	ll ans=0;
	for(int i=0;i<n-k;i++) {
		ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
		List<Integer> nums = new ArrayList<>();
		for(int i=0; i<n; i++) {
			nums.add(sc.nextInt());
		}
		
		OptionalInt min = nums.stream().mapToInt(num -> num.intValue()).min();
		OptionalInt max = nums.stream().mapToInt(num -> num.intValue()).max();
		
		System.out.println(Math.abs(max.getAsInt() - min.getAsInt()));
		
		sc.close();
	}
}


Measured memory_bytes: 28880
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		String[] mark = new String[size];
		int[] rank = new int[size];
		Boolean flag = false;
		for(int i = 0; i < size; i++){
			mark[i] = sc.next();
			rank[i] = sc.nextInt();
		}
		for(int i = 1; i < 14; i++){
			for(int j = 0; j < size; j++){
				if(mark[j].equals("S") && rank[j] == i)
						flag = true;
			}
			if(flag == false){
				System.out.println("S " + i);
			}
			flag = false;
		}
		for(int i = 1; i < 14; i++){
			for(int j = 0; j < size; j++){
				if(mark[j].equals("H") && rank[j] == i)
						flag = true;
			}
			if(flag == false){
				System.out.println("H " + i);
			}
			flag = false;
		}
		for(int i = 1; i < 14; i++){
			for(int j = 0; j < size; j++){
				if(mark[j].equals("C") && rank[j] == i)
						flag = true;
			}
			if(flag == false){
				System.out.println("C " + i);
			}
			flag = false;
		}
		for(int i = 1; i < 14; i++){
			for(int j = 0; j < size; j++){
				if(mark[j].equals("D") && rank[j] == i)
						flag = true;
			}
			if(flag == false){
				System.out.println("D " + i);
			}
			flag = false;
		}
	}
}

Measured memory_bytes: 18180
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int count = 0;
    int current = Inf;
    vector<int> d(n);
    rep(i, n) {
      cin >> d[i];
    }
    sort(d.begin(), d.end(), greater<int>());
    rep(i, n) {
      if (current > d[i]) {
        count++;
        current = d[i];
      }
    }
    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

#input = sys.stdin.readline

########################################
count = defaultdict(int)
count = {"AC" : 0 , "WA" : 0, "TLE" : 0, "RE" : 0}
for ii in range(int(input())):
	
	s = input()
	count[s]+=1
print("AC x",count["AC"])
print("WA x",count["WA"])
print("TLE x",count["TLE"])
print("RE x",count["RE"])








Measured memory_bytes: 74572
#include<bits/stdc++.h>
using namespace std;
inline __int128 read()
{
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
 
inline void write(__int128 x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
int main(){
	long double a;
	long double c;
	cin>>a>>c;
	cout<<(long long)floor(a*c);
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<int>edge[1000005];
int dist[1000005];
int deg[1000005];
queue<int>que;
void dfs(int v){
	if(dist[v] >= 0) return ;
	dist[v] = 0;
	rep(i,edge[v].size()){
		dfs(edge[v][i]);
		dist[v] = max(dist[v],dist[edge[v][i]]+1);
	}
	return;
}
int main(){
	cin >> n;
	rep(i,n){
		vector<int>vi;
		rep(j,n-1){
			int a; scanf("%d",&a);
			int x = i, y = a-1;
			if(x > y) swap(x,y);
			vi.pb(x*1000+y);
		}
		for(int i=1;i<vi.size();i++) {edge[vi[i-1]].pb(vi[i]);deg[vi[i]] += 1;}
	}
	rep(i,1000005) if(deg[i] == 0) que.push(i);
	while(!que.empty()){
		int q = que.front(); que.pop();
		rep(i,edge[q].size()){
			int to = edge[q][i];
			deg[to]--; if(deg[to] == 0) que.push(to);
		}
	}
	rep(i,1000005) if(deg[i] != 0) {puts("-1"); return 0;}
	memset(dist,-1,sizeof(dist));
	rep(i,1000005) dfs(i);
	int ans = 0;
	rep(i,1000005) ans = max(ans,dist[i]+1);
	cout << ans << endl;\
}


Measured memory_bytes: 49192
#include "bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
//#define int long long
//#define error freopen("error.txt","w",stderr);
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long int
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
#define mod 1000000007
#define N 1000000000
int in(){
int n;cin>>n; 
return n;}
void _do_(){
int n=in();
	string s=to_string(n);
	bool yes=false;
	repo(i,begin(s),end(s))if(*i=='7'){yes=true;break;}
	if(yes)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;


}
signed main(){
fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> count(N + 1);
	map<int,int> ma;
	count.at(0) = 0;
	for(int i = 0;i < N;i++) {
		count.at(i + 1) = count.at(i) + vec.at(i);
	}
	for(int i = 0;i < N + 1;i++) {
		ma[count.at(i)]++;
	}
	int answer = 0;
	for(auto x : ma) {
		auto value = x.second;
		answer += value * (value - 1) / 2;
	}
	cout << answer << endl;
}

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main
{
	static int[][] map = new int[8][8];
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n=scanner.nextInt();
		for(int m=0; m<n; m++)
		{
			for(int i=0; i<8; i++)
			{
				String input = scanner.next();
				for(int j=0; j<8; j++)
				{		
					map[i][j] = Integer.parseInt(input.substring(j, j+1));
				}
			}
			
			int x = scanner.nextInt() - 1;
			int y = scanner.nextInt() - 1;
			map[y][x] = 2;
			
			boolean is_chain = false;
			do
			{
				is_chain = false;
				for(int i=0; i<8; i++)
				{
					for(int j=0; j<8; j++)
					{
						if(map[i][j] == 2)
						{
							is_chain = true;
							setBom(i, j);
							map[i][j] = 0;
						}
					}
				}
			}while(is_chain);
			
			System.out.println("Data "+(m+1)+":");
			for(int i=0; i<8; i++)
			{
				for(int j=0; j<8; j++)
				{
					System.out.printf("%1$d%2$s", map[i][j], j<7?"":"\n");
				}
			}
		}
	}
	
	static void setBom(int y, int x)
	{
		for(int i=-3; i<=3; i++)
		{
			if(0<=x+i && x+i<8)
			{
				if(map[y][x+i] == 1)
				{
					map[y][x+i] = 2;
				}
			}
			
			if(0<=y+i && y+i<8)
			{
				if(map[y+i][x] == 1)
				{
					map[y+i][x] = 2;
				}
			}
		}
	}
}

Measured memory_bytes: 28656
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

using namespace std;
typedef pair<int, int> P;

int main() {
	FAST;
	int n;
	cin >> n;

	int ans=0;
	rep(i,2,n+1) {
		if (i%2 == 0) continue;
		int cnt=0;
		rep(j,1,i+1) {
			if (i % j == 0) {
				cnt++;
			}
		}
		if (cnt == 8) {
			ans += 1;
		}
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = K; i < N; i++){
    if(A.at(i-K) < A.at(i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 4056
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long double ldb;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const int MAXT = 2e7 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM], beg[MAXM];
set<int> idx[MAXN];
int ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

struct Oper
{
	int pos,x;
}oper[MAXT];
int tcnt = 0;

int recalc(register int pos, register int x)
{
	register int old = p[pos];
	if(old == x) return ans;
	
	oper[++tcnt] = (Oper){pos,x};
	
	register int res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	register int nxt = *it;
	register int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos) + a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos) + a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int mx = -inf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			int res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	for(int i=1; i<=m; ++i) beg[i] = p[i];
	
	init();
	
	static int pp[MAXM];
	static int qq[MAXM];
	
	for(int i=1; i<=m; ++i) pp[i] = i;
	for(int i=1; i<=n; ++i) qq[i] = i;
	
	const ldb Delta = 0.97;
	ldb Temp = 1000000;
	
	int mxans = ans, mxi = 0;
	
	int T = 400;
	while(T--)
	{
		random_shuffle(pp+1,pp+m+1);
		
		for(int i=1; i<=m; ++i)
		{
			random_shuffle(qq+1,qq+n+1);
			for(int j=1; j<=n; ++j)
			{
				int pos = pp[i];
				int x = qq[j];
				
				int old = p[pos];
				int res = recalc(pos, x);
				
				if(res > ans || (ans-res)/Temp > (ldb)rand()/RAND_MAX)
				{
					if(res > mxans) mxans = res, mxi = tcnt;
					ans = res;
				}
				else recalc(pos, old);
				
				Temp *= Delta;
			}
		}
	}
	
	for(int i=1; i<=m; ++i) p[i] = beg[i];
	for(int i=1; i<=mxi; ++i)
		p[oper[i].pos] = oper[i].x;
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

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

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

string s,t;
int solve(){
    int ans=0;
    rep(i,s.size()){
        if(s[i] != t[i]){
            ans++;
        }
    }
    return ans;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> s >> t){
        int ans = 0;
        cout << solve() << endl;
        //cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	using P = pair<ll,ll>;
	V<P> v(N);
	rep(i,N) cin >> v[i].sc >> v[i].fs;
	sort(all(v));
	ll t = 0;
	rep(i,N){
		if(t + v[i].sc > v[i].fs){
			cout << "No" << endl;
			return 0;
		}
		t += v[i].sc;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3456
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    mod = 10**9+7
    S = input()[::-1]
    amari = 1
    dp = [[0]*13 for i in range(len(S))]
    if S[0] == '?':
        for j in range(10):
            dp[0][j] = 1
    else:
        dp[0][int(S[0])] = 1

    for i in range(1, len(S)):
        amari = 10*amari % 13
        if S[i] == '?':
            for j in range(13):
                for si in range(10):
                    dp[i][(j+amari*si) % 13] += dp[i-1][j]
                    dp[i][(j+amari*si) % 13] %= mod

        else:
            for j in range(13):
                dp[i][(j+amari*int(S[i])) % 13] = dp[i-1][j]

    print(dp[len(S)-1][5])


if __name__ == '__main__':
    main()

Measured memory_bytes: 88952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  string str;
  cin >> str;
  if (str == "++++") {
    s=4;
  }else if(str == "-+++") {
    s=2;
  }else if(str == "+-++") {
    s=2;
  }else if(str == "++-+") {
    s=2;
  }else if(str == "+++-") {
    s=2;
  }else if(str == "--++") {
    s=0;
  }else if(str == "-+-+") {
    s=0;
  }else if(str == "-++-") {
    s=0;
  }else if(str == "+--+") {
    s=0;
  }else if(str == "+-+-") {
    s=0;
  }else if(str == "++--") {
    s=0;
  }else if(str == "+---") {
    s=-2;
  }else if(str == "-+--") {
    s=-2;
  }else if(str == "--+-") {
    s=-2;
  }else if(str == "---+") {
    s=-2;
  }else if(str == "----") {
    s=-4;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */
int main(){
	int r;
	cin>>r;
	if(r<1200) cout<<"ABC"<<endl;
	else if(r>=2800) cout<<"AGC"<<endl;
	else cout<<"ARC"<<endl;
	return 0;		
}

Measured memory_bytes: 764
#include <stdio.h>

int main(){
  int ans = 0;
  int N;
  scanf("%d\n",&N);
  int H[N];
  for(int a = 0; a < N - 1; a ++){
    scanf("%d ",&H[a]);
  }
  scanf("%d",&H[N - 1]);

  for(int i = 0; i < N; i ++){
    int flag = 1;
    for(int j = 0; j < i; j ++){
      if(H[i] < H[j]){
        flag = 0;
      }
    }
    if(flag == 1){
      ans ++;
    }
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }

    reverse(all(vec));

    ll r = 0;
    ll ans = (-1) * INF;
    rep(i, n){
        if(i == 0){
            r = vec[i];
            continue;
        }
        ans = max(ans, r - vec[i]);
        if(r < vec[i]){
            r = vec[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4372
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

a = raw_input()
a = a.split()
a = map(int,a)

gnum = 0
for i in range(n):
    if a[i]%2 == 0:
        gnum += 1

ans = 3**n - 2**gnum

print ans


Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        if (x < 4)
        {
            Console.WriteLine(1);
            return;
        }
        int m = (int)Math.Sqrt(x);
        int max = 0;
        for (int i = m; i > 1; i--)
        {
            int p = 2;
            int l = i;
            while (l <= x)
            {
                if (l * i > x) break;
                l *= i;
                p++;
            }
            if (l > max) max = l;
        }

        Console.WriteLine(max);
    }
}


class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int main(){
  int N;
  string u;
  double x;
  double ans = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> x >> u;
    
    if (u == "BTC"){
      ans += x * 380000;
    }else{
      ans += x;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/12/ALDS1_12_B
# プリムのアルゴリズムと似ているが、求めているものが異なる(MSTの経路は必ずしも任意の点と点をつなぐ最小経路とはならない)。
# 次手の候補となるリストDの更新の仕方がprimとは異なる

INF = 10**6 + 1

# load datas
N = int(input())
M = [[INF] * N for _ in range(N)]  # 隣接行列
for _ in range(N):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        node = tmp[0]
        for i, t in enumerate(tmp[2:]):
            if i % 2 == 0:
                idx = t
            else:
                M[node][idx] = t


def dijkstra(adj_mat: list, s: int):
    Color = [0] * N  # 0:未訪問 1:訪問経験あり 2:訪問済み(そこまでの最短経路は確定済み)
    D = [INF] * N  # 本のdと同じ 始点からの距離を記録する
    P = [None] * N  # 本のpと同じ 最短経路木における親を記録する

    # スタートとするノードについて初期化
    D[s] = 0  # スタートまでの距離は必ず0
    P[s] = None  # 親がない(ROOTである)ことを示す

    while True:
        # 最短経路候補の中で一番コストの少ないノードを選ぶ、あとその時のコストも
        min_cost = INF
        for i in range(N):
            if Color[i] != 2 and D[i] < min_cost:
                # 訪問済みでなく、最小コストを更新したら
                min_cost = D[i]
                u = i
        # uには次に確定するノードが入っている

        if min_cost == INF:
            # これ以上辺がない or すべて訪問済みなら
            break

        Color[u] = 2  # uは訪問済み これから最短経路木に突っ込む作業をする

        # 以下のforではsからの最短経路木にuを追加したときの更新、uまわりで次の最短経路になる候補の更新をしている
        for v in range(N):
            if Color[v] != 2 and adj_mat[u][v] != INF:
                # 訪問済みでなく、u→vへの経路が存在するならば
                if D[u] + adj_mat[u][v] < D[v]:  # ココがprimと異なる点である
                    # 今までのs→vへの距離の候補(D[v])よりも、
                    # 新しいuを用いた経路(D[u] + M[u][v]はs→u→vの距離を示す)のほうが小さければ更新する
                    D[v] = D[u] + adj_mat[u][v]  # u周りにおける最短経路の候補の更新
                    P[v] = u  # sからの最短経路木の更新
                    Color[v] = 1  # 訪問経験ありに更新(この処理に関しては意味はない)

    return D, P


D, P = dijkstra(M, 0)

for i in range(N):
    print(i, D[i])



Measured memory_bytes: 5812
using System;

namespace ABC167B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            var k = int.Parse(input[3]);

            var result = 0;
            if (k > 0)
            {
                if (a > 0 && a <= k)
                {
                    result = result + a * 1;
                    k = k - a;
                }
                else if (a > k)
                {
                    result = result + k * 1;
                    k = 0;
                }
            }

            if (k > 0)
            {
                if (b > 0 && b <= k)
                {
                    k = k - b;
                }
                else if (b > k)
                {
                    k = 0;
                }
            }

            if (k > 0)
            {
                if (c > 0 && c <= k)
                {
                    result = result + (c * (-1));
                    k = k - c;
                }
                else if (c > k)
                {
                    result = result + k * (-1);
                    k = 0;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 17704
while(n,m=gets.split.map(&:to_i))!=[0,0]do
r,p,a=[],[],[]
n.times{r.<<gets.gsub("?",".").split}
m.times{p<<gets.split}
p.each{|p|r.reverse.each{|r|if/#{r[1]}/=~p[0]&&p[1]=~/#{r[2]}/
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

Measured memory_bytes: 9476
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int Nmasu = int.Parse(Console.ReadLine());
            int[] Htakasa = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] ans = new int[Nmasu];
            int cnt = 0;
            for(int i = 1; i < Nmasu; i++)
            {
                if(Htakasa[i] <= Htakasa[i - 1])
                {
                    ans[i] = ans[i - 1] + 1;
                }
                else
                {
                    ans[i] = 0;
                }
            }
            Console.WriteLine(ans.Max());
        }
    }
}

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

using namespace std;

int main(void)
{
	int n,m,x,t;
	vector <int> a;

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

	cin >> n >> m >> x;

	for(int i=0;i<m;i++)
	{
		cin >> t;
		a.push_back(t);
	}

	int c1=0,c2=0;

	for(int i=0;i<m;i++)
	{
		if(a[i]<x)
		{
			c1++;
		}
		else if(a[i]>x)
		{
			c2++;
		}
	}

	cout << min(c1,c2) << '\n';
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
void fail() { cout << -1 << endl; exit(0); }

typedef pair<int, int> pii; typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9+7;
constexpr int MAX = 50050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1; constexpr int INF = 1e9 + 1;
//const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int N, K; cin >> N >> K;

	vector<int>v(N);

	REP(i, N)cin >> v[i];
	VSORT(v);
	ll ans = 0;
	REP(i, K)ans += v[i];
	print(ans);
}





signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//mt.seed((int)(time(0)));
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 3672