akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
ab = [LIST() for _ in range(N-1)]
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

length = [len(x) for x in graph]
ans = max(length)

color = defaultdict(int)

q = deque([])
cnt = 1
for x in graph[0]:
	q.append((x, 0, cnt))
	cnt += 1

while q:
	n, previous, col = q.popleft()
	cnt = 1
	for x in graph[n]:
		if x == previous:
			color[(n, x)] = col
			color[(x, n)] = col
		else:
			if cnt == col:
				cnt += 1
			color[(n, x)] = cnt
			color[(x, n)] = cnt
			q.append((x, n, cnt))
			cnt += 1

print(ans)
for a,b in ab:
	print(color[(a-1, b-1)])


Measured memory_bytes: 72964
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}

function create2DArray(row, col, filler = 0) {
    return Array(row)
        .fill(filler)
        .map(() => Array(col).fill(filler));
}
// ---------------------------------------



function main() {
    let [r, c] = getArray(readline());
    let arr = [];
    const mod = 1e9+7;

    for (let i = 0; i < r; i++) {
        arr.push(readline().split('').map(x => x));
    }

    let dp = create2DArray(r, c, 0);

    dp[0][0] = 1;
    for (let i = 1; i < r; i++) {
        if(arr[i][0] === '#') {
            dp[i][0] = 0;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }

    for (let j = 1; j < c; j++) {
        if (arr[0][j] === '#') {
            dp[0][j] = 0;
        } else {
            dp[0][j] = dp[0][j-1];
        }
    }
    
    for (let i = 1; i < r; i++) {
        for (let j = 1; j < c; j++) {
            if(arr[i][j] === '#') {
                dp[i][j] = 0;
            } else {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    console.log(dp[r-1][c-1]);
}

Measured memory_bytes: 58388
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);

using UINT64 = unsigned long long;

#define NMAX 1010


int main(void){
    int n,k;
    cin >> n >> k;
    vector<UINT64> a;

    for(int i = 0; i < n; i++) {
        int j;
        cin >> j;
        a.emplace_back(j);
    }

    vector<UINT64> v;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= n-i;j++){
            UINT64 sum = accumulate(a.begin()+j, a.begin()+j+i,0ULL);
            v.emplace_back(sum);
        }

    }
    //for(auto itr = v.begin();itr != v.end(); itr++) cerr << *itr << endl;
    sort(v.rbegin(),v.rend());

    UINT64 ans = 0;

    for(int m = 40; m >= 0; m--){
        UINT64 t2 = 1ULL << m;
        int cnt = 0;
        int vs = v.size();
        for(int s = 0; s < vs ; s++){
            if (((ans + t2) & v[s]) == (ans + t2)) {
                cnt++;
                if (cnt == k){
                    ans += t2;
                    break;
                }
            }
        }
    }

    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 6268
#include <stdio.h>
#include <stdlib.h>
static int compare (int const *a, int const *b)
{
   return *a - *b;
}
int main() {
  int N,K,Q,temp;
  int score[100000];
  scanf(" %d %d %d",&N,&K,&Q);
  for (int i = 0; i < N; i++) {
    score[i]=K;
  }
  for (int i = 0; i < Q; i++) {
    scanf("%d",&temp);
    score[temp-1]++;
  }
  for (int i = 0; i <N; i++) {
    if (score[i]-Q<=0) {
      printf("No\n");
    }
    else printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 896
class DisjointSet 

public
	def initialize(size = nil)
		@rank = Array.new(size){0}
		@p = Array.new(size){0}
		if size 
			size.times do |i|
				@p[i] = i
			end
		end
	end

	def same(x, y)
		return findSet(x) == findSet(y)
	end

	def unite(x, y)
		link(findSet(x), findSet(y))
	end

private
	def link(x, y)
		if @rank[x] > @rank[y]
			@p[y] = x
		else
			@p[x] = y
			@rank[y] += 1 if @rank[x] == @rank[y]
		end
	end

	def findSet(x)
		@p[x] = findSet(@p[x]) unless x == @p[x] 
		return @p[x]
	end

end

 
n = gets.split.map(&:to_i)
tree = DisjointSet.new(n[0])
n[1].times do
	a = gets.split.map(&:to_i)
	tree.unite(a[0], a[1])
end

n = gets.to_i

n.times do
	a = gets.split.map(&:to_i)
	if tree.same(a[0], a[1])
		puts "yes"
	else
		puts "no"
	end
end

Measured memory_bytes: 10404
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  vector<vector<int>>s(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
       if(i<B&&j<A){s[i][j]=0;}
       else if(i<B&&j>=A){s[i][j]=1;}
       else if(i>=B&&j<A){s[i][j]=1;}
       else{s[i][j]=0;}
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
        cout<<s[i][j];
    }cout<<endl;
  }
  return 0;  
}

Measured memory_bytes: 7548
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

//解説AC
int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;
  cin >> n;
  vector<int> b(n), ans;
  REP(i, n) cin >> b[i];

  REP(i, n){
    if(i-b[i]+1 < 0){
      cout << -1 << endl;
      return 0;
    }
  }
  
  ROF(i, n-1, 0){
    ROF(j, i, 0){
      //除去可能ならば
      if(j+1 == b[j]){
	ans.push_back(b[j]);
	//j以降を左に詰める
	FOR(k, j, n-1) b[k] = b[k+1];
	break;
      }
    }
    //チェック
    REP(j, b.size()) cerr << b[j] << " ";
    cerr << endl;    
  }
  reverse(ans.begin(), ans.end());
  REP(i,n) cout << ans[i] << endl;
  
  return 0;
}

  /*
  REP(i, n){
    if(i-b[i]+1 < 0){
      cout << -1 << endl;
      return 0;
    }    
    if(b[i] != 1){
      int tmp = b[i];
      REP(j, tmp-1) b[i-j] = b[i-j-1];
      b[i-tmp+1] = tmp;
    }
    REP(j, n) cerr << b[j] << " ";
    cerr << endl;
  }
  
  ROF(i,n-1,0) cout << b[i] << endl;
  */


Measured memory_bytes: 256
#include <stdio.h>
int sum(int n ,int r, int d, int x) {
	if (n > 0) {
		int sum1 = r * sum(n - 1, r, d, x) - d;
		printf("%d\n", sum1);
		return sum1;
	}
	else {
		return x;
	}

}

int main() {
	int r, d,x;
	int n = 10;
	scanf("%d %d %d", &r, &d, &x);
	sum(n, r, d, x);
	
	
}

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

int main() {
  int d,n;
  cin>>d>>n;
  if(d==0){
    if(n==100)
      cout<<"101"<<endl;
    else
      cout<<n<<endl;
  }
  else if(d==1){
    if(n==100)
      cout<<"10100"<<endl;
    else
      cout<<100*n<<endl;
  }
  else
    if(n==100)
      cout<<"1010000"<<endl;
    else
      cout<<10000*n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
using lint = long long;

void top_bottom(int n, int &top, int &bottom)
{
    bottom = n % 10;
    while (n > 9)
    {
        n /= 10;
    }
    top = n;
}

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

    std::vector<std::vector<int>> nums(10, std::vector<int>(10, 0));

    int top, bottom;

    for (int i = 1; i <= n; ++i)
    {
        top_bottom(i, top, bottom);
        if (top == 0 || bottom == 0)
            continue;
        nums[top - 1][bottom - 1]++;
    }

    int ans = 0;

    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            ans = ans + nums[i - 1][j - 1] * nums[j - 1][i - 1];
        }
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
tasks=[]
for i in range(n):
    a,b = map(int, input().split())
    tasks.append([a, b])
tasks.sort(key=lambda x:x[1])

current_time = 0
for task in tasks:
    current_time+=task[0]
    if current_time>task[1]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 38048
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

int n,k;
int cnt[200001];
int ans = 0;

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a-1]++;
    }

    //vectorではない配列ではこの使い方ができる。
    //指定した範囲で0を抜いてソートできる。
    sort(cnt,cnt+n);
    
    for(int i = 0; i < n-k; i++){
        ans += cnt[i];
    }
    cout << ans << endl;
    return 0;
}


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

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right; 
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
		}else {
			insert ( t -> right , z);
		}
	
	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
		}else {
			insert ( t -> left , z);
		}
	}
};

void search ( NodePointer t, int tag){
	int flag = 0;
	while ( t != NULL){
		if ( t -> key == tag){flag = 1; break;}
		else if ( t -> key >= tag){
			t = t -> left;
		}else {
			t = t -> right;
		}
	}
	if (flag == 0 ){ printf("no\n");
	}else if (flag == 1){printf("yes\n");}
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};	

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int n;
	scanf("%d\n",&n);

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));
	
	char input [8];
	int k;
	
	for ( int i = 0; i  < n; i++){
		scanf("%s" ,&input);
		
		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);
			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}
			else {insert(tree , k);
			}
		}else if ( strcmp( input , "find") == 0 ){
			scanf("%d\n",&k);
			search( tree , k);
		}else {
			inorder(tree);
			printf("\n");
			
			preorder(tree);
			printf("\n");
		}
	}
	
	
	return 0;
}


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

using namespace std;

int main (void) {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for ( int i=0; i<N; i++ )
        cin >> A.at(i);
    vector<pair<int, int>> CB(M);   /* C, B の pair */
    int b, c;
    for ( int i=0; i<M; i++ ) {
        cin >> b >> c;
        CB.at(i) = make_pair(c, b);
    }

    /* A を小さい順にソート */
    sort(A.begin(), A.end());

    /* CB を大きい順にソート */
    sort(CB.begin(), CB.end(), greater<pair<int, int>>());

    /* A の小さい順から CB の値で置き換えていく */
    int a_idx = 0, cb_idx = 0, used_card = 0;
    while ( 1 ) {
        /* A か CB のどちらか使い切ったら終わり */
        if ( a_idx >= N || cb_idx >= M )
            break;
        /* A の要素が C 以上になったら終わり */
        if ( A.at(a_idx) >= CB.at(cb_idx).first )
            break;
        /* B 枚のカードを使い切ったら次の値に */
        if ( used_card == CB.at(cb_idx).second ) {
            used_card = 0;
            cb_idx++;
            continue;
        }
        /* カードを置き換える */
        A.at(a_idx) = CB.at(cb_idx).first;
        a_idx++;
        used_card++;
    }

    /* 置き換えたカードの合計を計算する */
    long long ans = 0;
    for ( int i=0; i<N; i++ )
        ans += A.at(i);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
using System;

namespace ConsoleApp39
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            string[] str = Console.ReadLine().Split(' ');
            n = int.Parse(str[0]);
            m = int.Parse(str[1]);
            if (n == m)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27496
import { createInterface } from 'readline';

const main = (lines: string[]) => {
  console.log(solve(lines));
};

export const solve = (lines: string[]): string => {
  const { N, K, Q, A } = parseLines(lines);
  let out = '';
  const n = +N;

  if (+K > +Q) {
    for (let i = 0; i < n; i++) {
      out += 'Yes\n';
    }
    return out.slice(0, -1);
  }

  const tgt = +Q - +K;

  const memo = A.reduce((acc, cur) => {
    if (!acc[cur]) {
      acc[cur] = 0;
    }
    ++acc[cur];

    return acc;
  }, {});

  for (let i = 0; i < n; i++) {
    out += memo[(i + 1).toString()] > tgt ? 'Yes\n' : 'No\n';
  }

  return out.slice(0, -1);
};

const parseLines = (lines: string[]) => {
  const [first, ...A] = lines;
  const [N, K, Q] = first.split(' ');
  const obj = { N, K, Q, A };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) {
    console.log(message, ...optionalParams);
  }
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines: string[] = [];
  createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


Measured memory_bytes: 32780
#include<cstdio>
#define mod 1000000007
#define N 611
int dp[N][N],A[N],B[N],G[N],cnt[N][N],pd[N];
int main()
{
	int n,k,nn,all,ans=0;
	scanf("%d%d",&n,&k);nn=n<<1;all=(n-k)<<1;
	for (int i=1;i<=k;++i) scanf("%d%d",&A[i],&B[i]),pd[A[i]]=B[i],pd[B[i]]=A[i];
	G[0]=1;for (int i=2;i<=nn;i+=2) G[i]=1ll*G[i-2]*(i-1)%mod;
//	printf("%d\n",pd[1]);
	for (int i=1;i<=nn;++i)
		for (int j=i;j<=nn;++j)
			cnt[i][j]=cnt[i][j-1]+(!pd[j]);
	for (int i=1;i<=nn;++i)
		for (int j=i+1;j<=nn;j+=2)
		{
			for (int k=i;k<=j;++k) if (pd[k]&&(pd[k]>j||pd[k]<i)) goto C;
			dp[i][j]=G[cnt[i][j]];
			for (int k=i+1;k<j;k+=2)
				dp[i][j]=(dp[i][j]-1ll*dp[i][k]*G[cnt[k+1][j]]%mod+mod)%mod;
			C:;
		}
	for (int i=1;i<=nn;++i)
		for (int j=i+1;j<=nn;j+=2) ans=(ans+1ll*dp[i][j]*G[all-cnt[i][j]]%mod)%mod;
	printf("%d",ans);//,printf("dp[%d][%d]=%d\n",i,j,dp[i][j])
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
int main(void)
{
    int s = 0;
    int n = 0;
    int sam;
    
    scanf("%d\n" ,&n);
    
    sam = n;
    
    
    while(n != 0)
    {
        s += n%10;
        n /= 10;
    }
    
    if(sam % s == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int a[200000]={0};
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int l[200010]={0},r[200010]={0};
  scanf("%lld",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    j = i+1+a[i];
    k = i+1-a[i];
    if(j>=1&&j<=n) l[j]++;
    if(k>=1&&k<=n) r[k]++;
  }
  
  for(i=1;i<=n;i++) {
    result += (ll)l[i]*(ll)r[i];
  }  
  printf("%lld",result);
  return 0;
}



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

int main(){
	int n;
	int ans=0;
	std::vector<int> aList;
	std::vector<int> numList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<n; i++){
		numList.push_back(aList[i]-1);
		numList.push_back(aList[i]);
		numList.push_back(aList[i]+1);
	}

	std::sort(numList.begin(), numList.end());

	int length=1;
	int cur=numList[0];

	for(int i=1; i<numList.size(); i++){
		if(cur!= numList[i]){
			if(ans<length)
				ans=length;
			length=0;
		}

		cur= numList[i];
		length++;
	}

	if(ans<length)
		ans=length;
	

	std::cout<<ans<<std::endl;

	return 0;
		
	
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ll A,B,N;
    cin>>A>>B>>N;

    if(B > N)
        cout<<(ll)floor((double)A*N/B) - A *(ll)floor((double)N/B)<<endl;
    else
        cout<<(ll)floor((double)A*(B-1)/B) - A *(ll)floor((double)(B-1)/B)<<endl;
   return 0;
}


Measured memory_bytes: 3684
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int in;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> in;
        if (i+1 != in)
        {
            cnt++;
        }
    }
    if (cnt == 2 || cnt == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N,K,a[200010],cnt[200010]={0};
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> a[i];
		cnt[a[i]-1]++;
	}
	int tmp = 0;
	for(int i=0; i<N; i++){
		if(cnt[i] > 0) tmp++;
	}
	int ans = N;
	if(K < tmp){
		sort(cnt,cnt+N);
		for(int i=N-1; i>N-1-K; i--){
				ans -= cnt[i];
		}
	}else ans = 0;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    long long int H,W,S;
    scanf("%lld",&H);
    scanf("%lld",&W);
    if(H ==1 || W==1){ printf("%d",1);
    return 0;
    }
    if(W%2==0){
            S=(W/2)*H;
    }
    else{
        if(H%2==0){
            S=W*H/2;
        }
        else{
            S=W*(H/2)+W/2+1;
        }
    }
    printf("%lld",S);
    return 0;
}

Measured memory_bytes: 128
n=int(input())

li=[]
for i in range(1,n+1):
    s=input().split()
    s.append(i)
    s[1]=int(s[1])*-1
    li.append(s)

#print(li)
lis = sorted(li)
#print(lis)

for i in range(0,n):
    print(lis[i][2])

Measured memory_bytes: 3060
#[derive(Debug, Clone, PartialEq)]
struct Point {
    x: i32,
    y: i32,
}
fn main() {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input).unwrap();
    let input = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect::<Vec<_>>();
    let s = Point {
        x: input[0],
        y: input[1],
    };
    let t = Point {
        x: input[2],
        y: input[3],
    };

    let mut route = String::new();

    for _ in s.x..t.x {
        route.push('R');
    }
    for _ in s.y..t.y {
        route.push('U');
    }
    for _ in s.x..t.x {
        route.push('L');
    }
    for _ in s.y..t.y {
        route.push('D');
    }

    // sまで戻ったので、1マスしたにずらして、1マス分外側の最短経路を進む
    route.push('D');

    // 1マスそと
    for _ in s.x..t.x + 1 {
        route.push('R');
    }
    for _ in s.y - 1..t.y {
        route.push('U');
    }
    // 1個左に行ってtに到着
    route.push('L');

    // そのまま左に行くとすでに通過した経路なので、1個上にずらす
    route.push('U');

    for _ in s.x..t.x + 1 {
        route.push('L');
    }
    for _ in s.y - 1..t.y {
        route.push('D');
    }

    route.push('R');
    println!("{}", route);
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::string> a(n), b(m);
  std::cin >> a >> b;

  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool flag = true;
      for (int k = 0; k < m && flag; k++) {
        for (int l = 0; l < m && flag; l++) {
          if (a[i + k][j + l] != b[k][l]) {
            flag = false;
          }
        }
      }
      if (flag) {
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>>a(n);
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    vector<double>distances;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            pair<int, int>city1 = a[i];
            pair<int, int>city2 = a[j];
            double d = pow(abs(city1.first - city2.first), 2) + pow(abs(city1.second - city2.second), 2);
            d = sqrt(d);
            distances.push_back(d);
            //cout << d << endl;
        }
    }
    
    double fact[10];
    fact[0] = 1;
    fact[1] = 1;
    for(int i= 2; i < 10; i++){
        fact[i] = i*fact[i-1];
        //cout << fact[i] << endl;
    }
    
    double total_distance = 0;
    for(auto d : distances){
        //cout << d << endl;
        //cout << fact[n-1] << endl;
        total_distance += 2*d*(double)fact[n-1];
    }
    total_distance/=fact[n];
    
    //cout << setprecision(12) << total_distance/fact[n] << endl;
    printf("%0.10lf\n", total_distance);
    
    
    
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;
ll DP[2][3][3], DP2[2][3][3];
string s;
int p;
bool d = true;
bool y[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int n = sz(s);
  {
    FOR(i, 0, n){
      y[s[i]-'a'] = true;
      p += s[i]-'a';
      if(i && s[i]==s[i-1]) d = false;
    }
    p %= 3;
    sort(y, y+3);
    if(!y[1]){
      cout << 1 << endl;
      return 0;
    }
    if(n==3){
      cout << (p ? 6+d : 3) << endl;
      return 0;
    }
  }
  DP[0][0][0] = 1;
  DP[0][1][1] = 1;
  DP[0][2][2] = 1;
  FOR(t, 1, n){
    Fill(DP2, 0ll);
    FOR(i, 0, 3)FOR(j, 0, 3)FOR(k, 0, 3){
      DP2[j==k][(i+k)%3][k] += DP[0][i][j];
      DP2[1][(i+k)%3][k] += DP[1][i][j];
    }
    swap(DP, DP2);
    FOR(i, 0, 2)FOR(j, 0, 3)FOR(k, 0, 3) DP[i][j][k] %= MOD;
  }
  ll ans = d;
  FOR(i, 0, 3) ans += DP[1][p][i];
  cout << ans % MOD << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
int main(){
  ll N;
  cin>>N;
  if(N%2==0){cout<<0<<"."<<5<<endl;}
  else{cout<<(long double)(N+1)/(long double)2/(long double)N<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int n,T;
  pair<int,int> c[110];
  cin >> n >> T;
  for(int i = 0; i < n; i++) 
    cin >> c[i].first >> c[i].second;
  
  sort(c,c+n);

  for(int i = 0; i < n; i++) {
    if(c[i].second <= T) {
      cout << c[i].first << endl;
      return 0;
    }
  } 
  cout << "TLE" << endl;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#define MAX 100005
typedef long long LL;

using namespace std;

int main()
{
	LL n;
	cin >> n;
	int a[100];
	int num = 0;
	char ch;
	while(n != 0)
	{
		int b = n % 26;
		a[num++] = b;
		n /= 26;
		if(b == 0 && n == 1)
		 	break;
		if(b == 0)
		{
			n--;
		} 
	}
	for(int i = num-1;i >= 0;i--)
	{
		if(a[i] == 0)
			cout << 'z';
		else
		{
			ch = a[i] + 'a'-1;
			cout << ch;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,c,d,e,f,g;
  int b[10][3][10]={};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c>>d>>e>>f;
    b[c][d][e]=f+b[c][d][e];
  }
  for(int i=1;i<=4;i++){
    for(int j=1;j<=3;j++){
      for(int k=1;k<=10;k++){
	cout<<" "<<b[i][j][k];
      }
      cout<<"\n";
    }
    if(i!=4){
      cout<<"####################\n";
    }
  }
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
ll A[10000];
int main() {
	ll N, M, X; cin >> N >> M >> X;
	ll a = 0, b = 0;
	rep(i, 0, M)
	{
		cin >> A[i];
		(X > A[i]) ? b++ : a++;
	}
	cout << min(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;

#define A first
#define B second
 
typedef long long ll;
constexpr int MOD = 1000000007;
 
template<typename T>
void print(const vector<T> &v, bool add_one = false, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
 
  for (int i = start; i < end; i++)
    cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

constexpr int MXLEN = 2e5 + 5;

vector<int> adj[MXLEN];
bool visited[MXLEN];
int cnt = 0;

void dfs(int v){
  visited[v] = true;
  cnt++;
  for(int u: adj[v]){
    if(!visited[u]) dfs(u);
  }
}
 
void solve() {
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for(int i = 1; i <= N; i++){
    if(!visited[i]) {
      dfs(i);
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  cout << ans;
}
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 20932
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    string c[2];
    cin >> c[1];
    cin >> c[0];
    int t=c[1][2];
    c[1][2] = c[1][0];
    c[1][0] = t;

    // cout << c[0] << endl << c[1] << endl;
    if(c[0]==c[1])cout << "YES" << endl;
    else cout << "NO" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	vector<LD> X(3),Y(3);
	for(int i=0;i<3;++i){
		cin>>X[i]>>Y[i];
	}
	vector<LD> hen(3);
	for(int i=0;i<3;++i){
		int a = i;
		int b = (i+1)%3;
		hen[i] = (X[a]-X[b])*(X[a]-X[b])+(Y[a]-Y[b])*(Y[a]-Y[b]);
		hen[i] = sqrt(hen[i]);
	}
	LD s=0;
	LD S=0;
	LD sum = (hen[0]+hen[1]+hen[2]);
	s= sum /2;
	S=s*(s-hen[0])*(s-hen[1])*(s-hen[2]);
	S = sqrt(S);

	LD r = S*2/(sum);
	LD MAX = max(max(hen[0],hen[1]),hen[2]);
	LD x = r*MAX/(MAX+r*2);
	cout << x << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 384
import numpy as np
import math as m

def main(**kwargs):
    if len(set([a, b, c])) == 2:
        r = "Yes"

    else:
        r = "No"

    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    a, b, c = cin

    cout = main(a=a, b=b, c=c)
    print(cout)

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

int main(){

  //initialization
  int N;
   
  //input
  cin >> N;

  //solver

  if     (N< 2)  cout <<  1 << "\n";
  else if(N< 4)  cout <<  2 << "\n";
  else if(N< 8)  cout <<  4 << "\n";
  else if(N< 16) cout <<  8 << "\n";
  else if(N< 32) cout << 16 << "\n";
  else if(N< 64) cout << 32 << "\n";
  else           cout << 64 << "\n";
  
}


Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

vector<int> v[700];
int c[700];
bool muri;

void dfs(int x, int& count1, int& count2){
	for(auto y:v[x]){
		if(c[y]==c[x]){
			muri=1;
		}
		if(c[y]==0){
			c[y]=-c[x];
			if(c[y]==1){
				count1++;
			}else{
				count2++;
			}
			dfs(y, count1, count2);
		}
	}
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> v1[700];
	for(int i=0; i<m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		v1[a].push_back(b);
		v1[b].push_back(a);
	}
	for(int i=0; i<n; i++){
		bool used[700]={};
		for(auto y:v1[i]){
			used[y]=1;
		}
		for(int j=0; j<n; j++){
			if(i==j) continue;
			if(!used[j]) v[i].push_back(j);
		}
	}
	vector<int> c1, c2;
	for(int i=0; i<n; i++){
		if(c[i]!=0) continue;
		c[i]=1;
		int ct1=1, ct2=0;
		dfs(i, ct1, ct2);
		if(muri){
			printf("%d\n", -1);
			return 0;
		}
		c1.push_back(ct1);
		c2.push_back(ct2);
	}
	bitset<701> bs;
	bs[0]=1;
	for(int i=0; i<c1.size(); i++){
		bs=((bs<<c1[i])|(bs<<c2[i]));
	}
	int ans;
	for(int i=n/2; i>=0; i--){
		if(bs[i]){
			ans=i*(i-1)/2+(n-i)*(n-i-1)/2;
			break;
		}
	}
	for(int i=n/2+1; i<=n; i++){
		if(bs[i]){
			ans=min(ans, i*(i-1)/2+(n-i)*(n-i-1)/2);
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++) cin >> a[i];
	int fmax=0;
	for(int i=0;i<N;i++) fmax+=a[i]-1;
	cout << fmax << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000000007;
int a[400001];
int res[400001];
signed main()
{
	int n;
	scanf("%lld",&n);
	n*=2;
	for(int i=1;i<=n;i++)
	{
		char c;
		cin>>c;
		if(c=='B')
			a[i]=0;
		else
			a[i]=1;
	}
	for(int i=1;i<=n;i++)
		if((a[i]+i-1)%2==0)
			res[i]=1;
		else
			res[i]=-1;
	int ans=1,tot=0;
	for(int i=1;i<=n;i++)
	{
		if(res[i]==-1)
		{
			ans=1ll*ans*tot%mod;
			tot--;
			if(tot<0){printf("0");return 0;}
		}
		else
			tot++;
	}
	if(tot!=0){printf("0");return 0;}
	int prod=1;
	for(int i=1;i<=n/2;i++)
		prod=1ll*prod*i%mod;
	printf("%lld",1ll*ans*prod%mod);
    return 0;
}

Measured memory_bytes: 5888
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define INF 100000000
int min(int a,int b){
	if(a<b){
		return a;
	}else{
		return b;
	}
}

int main(){
	while(1){
		int sum=0,ans,n,m,x;
		double p,a;
		cin>>n>>m>>p;
		if(n+m+p==0)break;
		for(int i=1;i<=n;i++){
			cin>>x;
			if(i==m){
				sum+=x*100;
				a=x;
			}else{
				sum+=x*100;
			}
		}
		if(a==0){
			cout<<'0'<<endl;
		}else{
			cout<<(int)((sum*(100-p)/100)/a)<<endl;
		}
	}
	return 0;
}	

Measured memory_bytes: 1228
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  vl A = {R, G, B};
  sort(ALL(A));

  REP(i, 3001) REP(j, 3001) {
    ll a = (N - (i * A[2]) - (j * A[1]));
    if (a >= 0 && a % A[0] == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

const int MAX_A = 55555;

bool is_prime(int n) {

    for (int i = 2; i <= int(sqrt(n)); i++) {
        if (n%i == 0) return false;
    }

    return true;
}

int main(void) {

    vector<int> rem1;
    for (int i = 2; i <= MAX_A; i++) {
        if (is_prime(i) && i%5 == 1) rem1.push_back(i);
    }

    int N; cin >> N;
    cout << rem1[0];
    for (int i = 1; i < N; i++) {
        cout << " " << rem1[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

template<class T> void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
template<class T> void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}



template<class T> void read(T& a) {
    std::cin>>a;
}
template<class T> void read(T& a, int sidx,  int eidx) {
    for(int i=sidx; i<eidx; i++)
        std::cin>>a[i];
}



using namespace std;
using namespace __gnu_pbds;

const int maxn=100005;


vector<int>pr;
bool mark[maxn];

void si()
{
    mem(mark,0);
    for(int i=4; i<maxn; i+=2) mark[i]=1;
    for(int i=3; i*i<maxn; i+=2)
    {
        if(!mark[i])
            for(int j=i*i; j<maxn; j+=2*i)
                mark[j]=1;
    }

    pr.pb(2);
    for(int i=3; i<maxn; i+=2)
        if(!mark[i])
            pr.pb(i);
}


void solve()
{
    ll n,m;
    read(n);
    read(m);
    ll ara[n+2];
    rep(i,0,n) cin>>ara[i];
    
    sort(ara,ara+n);
    
    ll ans=0;
    for(int i=0;i<m;i++)
    {
		ans+=(ara[i]);
	}
	
	cout<<ans<<endl;
	
}


int main()
{
    fast_cin;
    // si();

    //while(scanf("%d",&n)!=EOF)
//case
    {
		//cas=cas;
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


Measured memory_bytes: 3656
N = int(input())
a = [input() for i in range(N)]
a.sort()
b = [0] * N
flag = 1
cc = 0
bef = 132
c = 1
for i in range(N):
    if a[i] == bef:
        c = c + 1
    else:
        c = 1
    bef = a[i]
    b[i] = c
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
        
for i in range(N):
    if b[i] == max:
        print(a[i])




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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define MOD (1000000007)

void init();
void solve();

signed main()
{
	init();
	solve();
}

int H, W, K;
vector<vector<ll> > dp;

void init()
{
	cin >> H >> W >> K;
	dp.resize(H+1, vector<ll>(W, 0));
	dp[0][0] = 1;
}

void update(int r)
{
	rep(i, 1 << (W-1)) {
		if (i & (i >> 1)) continue;
		int bit = 1;
		rep(j, W) {
			if (bit & i) {
				dp[r][j] += dp[r-1][j+1];
				dp[r][j] %= MOD;
			} else if ((bit >> 1) & i) {
				dp[r][j] += dp[r-1][j-1];
				dp[r][j] %= MOD;
			} else {
				dp[r][j] += dp[r-1][j];
				dp[r][j] %= MOD;
			}
			bit <<= 1;
		}
	}
}

void solve()
{
	if (W == 1) {
		cout << 1 << endl;
		return;
	}
	reps(i, 1, H+1) {
		update(i);
	}
	cout << dp[H][K-1] << endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000
	


int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(N);
	
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	int now = 1;
	for(int i=0;i<N;i++){
		if(a[i]==now)now++;
	}
	
	now--;
	
	if(now==0){
		cout<<-1<<endl;
	}
	else{
		cout<<N-now<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

long long int dp[55][55][2510];

int main(){
	int n,a;
	int x[100];
	cin >> n >> a;

	for(int i=0; i<n; i++){
		cin >> x[i];
	}
	
	dp[0][0][0]=1;
	for(int i=1; i<=n; i++){
		for(int j=0; j<=i; j++){
			for(int k=0; k<2510; k++){
				if(j==0){
					if(k==0){
						dp[i][j][k]=1;
					}
					else{
						dp[i][j][k]=0;
					}
				}
				else{
					if(k>=x[i-1]){
						dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
					}
					else{
						dp[i][j][k]=dp[i-1][j][k];
					}
				}
			}
		}
	}

	long long int res=0;
	for(int j=1; j<=n; j++){
		res += dp[n][j][a*j];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 53504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), c = sc.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		int ans = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum = c;
			for (int j = 0; j < m; j++) {
				sum += sc.nextInt()*b[j];
			}
			if(sum>0) ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22868