akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


void solve()
{
    map<int,int> mp;

    for(int i = 1; i <= 5; i++){
        int val;
        cin >> val;
        mp[val] = 1;
    }

    int ans;
    for(int i = 1; i <= 5; i++){
        if(mp[i] == 0) {ans = i; break;}
    }
    
    cout << ans << "\n";
}


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave; 
    
    int tc = 1;
    //cin >> tc;
    while(tc--) solve();

    return 0;
}

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

int main()
{
    int n;
    double ans;
    cin>>n;
    if(n%2==0){
        ans=0.5000000000;
      cout <<ans<< endl;
    }else{
      ans = (n+1);
      cout << fixed<<setprecision(10)<<ans/(2*n)<< endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N,M = map(int,input().split())
    edge =[[] for _ in range(N)]
    for _ in range(M):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)

    S,T = map(int,input().split())
    q = deque()
    go = [[False for _ in range(3)] for _ in range(N)]
    q.append((S-1,0,1))
    while q:
        now,step,d = q.popleft()
        if step == 3:
            if now == T-1:
                print(d)
                exit()
            step = 0
            d += 1
        if go[now][step]:
            continue
        go[now][step] = True
        for fol in edge[now]:
            q.append((fol,step+1,d))

    print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 30188
#include <iostream>
using namespace std;
int main()
{
	struct POINT {int x, y;} p;
	int w, h, i, j, c;
	char f[100][100];
	bool b;
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0) break;
		p.x = p.y = 0;
		b = false;
		c = 0;
		for (i = 0; i < w; i++)
			for (j = 0; j < h; j++)
				cin >> f[i][j];
		while (c <= w*h)
		{
			switch (f[p.y][p.x])
			{
			case '>':
				p.x++;
				break;
			case '^':
				p.y--;
				break;
			case '<':
				p.x--;
				break;
			case 'v':
				p.y++;
				break;
			default:
				cout << p.x << " " << p.y << endl;
				b = true;
				break;
			}
			if (b) break;
			c++;
		}
		if (!b) cout << "LOOP" << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
const int maxn = 105;
int a[maxn][maxn];
int dp[maxn][maxn];
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 1; i <= 2; i++)
    {
        for (int j = 1; j <= n; j++){
             scanf("%d",&a[i][j]);
        }
    }
    for (int i = 1; i <= 2; i++){
         for (int j = 1; j <= n; j++){
             dp[i][j] = a[i][j] + max(dp[i - 1][j],dp[i][j - 1]);
         }
    }
    printf("%d\n",dp[2][n]);
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}


void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int setBit( int mask , int pos ){
 return mask = mask | ( 1 << ( pos - 1 ) ) ;
}

int clearBit( int mask , int pos ){
  int b = mask & ( 1 << ( pos - 1 ) ) ;
  return mask ^ b ;
}

int getBit( int mask , int pos ){
 return ( mask & ( 1 << ( pos - 1 ) ) ) ? 1 : 0 ;
}

int bitCnt( int mask ){
if( !mask ) return 0 ;
return ( mask % 2 ? 1 : 0 ) + bitCnt( mask / 2 ) ;
}

int n ;
const int N = 1e5 + 4 ;
int frq_a[ N ] , frq_b[ N ] ;
vector < int > a ;

int fin( int b , bool x ){
int mx = -Int_max ;
forn( int , i , 1 , N )
  if( i != b ){
    mx = max( x ? frq_a[ i ] : frq_b[ i ] , mx ) ;
  }
  return n / 2 - mx ;
}

int main(){

   cin >> n ;
   a.resize( n ) ;
   forn( int , i , 0 , n ){
      cin >> a[ i ] ;
   }

   for( int i = 0 ; i < n ; i += 2 ){
     frq_a[ a[ i ] ]++ ;
   }

   for( int i = 1 ; i < n ; i += 2 ){
     frq_b[ a[ i ] ]++ ;
   }

   int mx_a , mx_b , c , d ;
   mx_a = mx_b = -Int_max ;
   forn( int , i , 1 , N ){
       if( mx_a < frq_a[ i ] ){
         mx_a = max( mx_a , frq_a[ i ] ) ;
         c = i ;
       }

       if( mx_b < frq_b[ i ] ){
         mx_b = max( mx_b , frq_b[ i ] ) ;
         d = i ;
       }
   }


   int aa = n / 2 - mx_a , bb = n / 2 - mx_b ;
   if( d != c ){
     cout << aa + bb ;
     return 0 ;
   }

   cout << min( fin( c , 1 ) + aa , fin( d , 0 ) + bb ) ;




   return 0 ;
}


Measured memory_bytes: 1408
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli  long long int
#define pb push_back
#define INT_MIN -1000000007
#define ld long double
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
   {lli a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;

       

    }

























Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d%d", &a, &b);

    int ans;
    if(a <= 5){
        ans = 0;
    }else if(a <= 12){
        ans = b/2;
    }else{
        ans = b;
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <string>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
int main() 
{
	int m;
	cin>>m;
	for(int i=0;i<m;i++)
	{
		set<string> ans;
		string temp;
		cin>>temp;
		for(int j=1;j<temp.size();j++)
		{
			string a=temp.substr(0,j);
			string b=temp.substr(j,temp.size());
			ans.insert(a+b);
			ans.insert(b+a);
			reverse(a.begin(),a.end());
			ans.insert(a+b);
			ans.insert(b+a);
			reverse(a.begin(),a.end());
			reverse(b.begin(),b.end());
			ans.insert(a+b);
			ans.insert(b+a);
			reverse(a.begin(),a.end());
			ans.insert(a+b);
			ans.insert(b+a);
		}
		cout<<ans.size()<<endl;
	}
}

Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[105];
int main()
{
	long long ans=999999999,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int j=a[1];j<=a[n];j++)
	{
		sum=0;
		for(int k=1;k<=n;k++)
		{
			sum+=(a[k]-j)*(a[k]-j);
		}
		if(sum<ans)	ans=sum;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int rick[256];

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	
	ini(n);
	vi morty;
	int tmp = 0;
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
		tmp+=x;
	}
	tmp*=2;
	int tmp1 =0;
	for(int i = 1;i<n-1;i+=2){
		tmp1+=morty[i];
	}
	tmp1*=4;
	tmp-=tmp1;
	tmp/=2;
	cout<<tmp<<" ";
	FOR(i,0,n-1){
		tmp = morty[i]*2-tmp;
		cout<<tmp<<" ";		
	}












	return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define NMAX (int)(2e5+4)
#define all(x) x.begin(),x.end()
#define rep(i, l, r) for(ll i = l; i < r; ++i)
#define rev(i, r, l) for(int i = r - 1; i >= l; --i)
#define ft first
#define sd second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

ll n,ans;
map <ll, bool> used;

int main(){
    cin>>n;
    ans=1;
    for(ll i=2;i*i<=n;++i)
        if(n%i == 0){
            ll x=i;
            while(x < n)
                x*=i;
            if(x == n){
                ans+=!used[i];
                used[i]=1;
            }
            // *****
            x=n;
            while(x%i == 0)
                x/=i;
            if(x%i == 1){
                ans+=!used[i];
                used[i]=1;
            }
            x=n;
            while(x%(n/i) == 0)
                x/=(n/i);
            if(x%(n/i) == 1){
                ans+=!used[n/i];
                used[n/i]=1;
            }
        }
    if(n > 2)
        ++ans;
    for(ll i=2;i*i<=(n-1);++i)
        if((n-1)%i == 0){
            ans+=!used[i];
            used[i]=1;
            ans+=!used[n/i];
            used[n/i]=1;
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define W 0
#define H 1
#define x 2
#define y 3
#define r 4

int GetNumEqual( int *pNum , int min , int max );
void ComparisonNum( int *pNum );

int main( void )
{
    int max = 100;
    int min;
    
    int getNum[5] = {};
    
    for( int i = 0 ; i < 5 ; i++ )
    {
        if( i == W || i == H || i == r )
        {
            min = 0;
        }
        else
        {
            min = -100;
        }
        
        if( -1 == GetNumEqual( getNum + i , min , max ) )
        {
            return 0;
        }
    }
    
    ComparisonNum( getNum );
    
    return 0;
}

int GetNumEqual( int *pNum , int min , int max )
{
    int getNum;
    
    scanf( "%d" , &getNum );
    
    if( ( getNum >= min ) && ( getNum <= max ) )
    {
        *pNum = getNum;
        return 0;
    }
    return -1;
}

void ComparisonNum( int *pNum )
{
    if( *( pNum + x ) - *( pNum + r ) < 0 )
    {
        printf( "No\n" );
        return;
    }
    if( *( pNum + y ) - *( pNum + r ) < 0 )
    {
        printf( "No\n" );
        return;
    }
    
    if( *( pNum + x ) + *( pNum + r ) <= *( pNum + W ) )
    {
        if( *( pNum + y ) + *( pNum + r ) <= *( pNum + H ) )
        {
            printf( "Yes\n" );
            return;
        }
    }
    printf( "No\n" );
}

Measured memory_bytes: 1812
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int[] a = { 0, 0, 0, 0, 0 };
        Scanner scan = new Scanner(System.in);
        if (scan.hasNextInt()) {
            for (int i = 0; i < a.length; i++) {
                a[i] = scan.nextInt();
            }
        }
        int sum = 0;

        if (a[0] + a[1] <= a[2] * 2) {
            sum = a[0] * a[3] + a[1] * a[4];
        } else {
            if (a[3] >= a[4]) {
                sum = a[4] * 2 * a[2];
                sum = sum + (a[3] - a[4]) * a[0];
            } else {
                sum = a[3] * 2 * a[2];
                sum = sum + (a[4] - a[3]) * a[1];
            }

        }
        int sum1 = 0;
        if (a[3] >= a[4]) {
            sum1 = a[3] * a[2] * 2;
        }
        if (a[3] < a[4]) {
            sum1 = a[4] * a[2] * 2;
        }
        if (sum > sum1) {
            sum = sum1;
        }
        System.out.println(sum);
        scan.close();
    }
}

Measured memory_bytes: 21844
/* B */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX 100000

int A[N_MAX];

int comp(const void *a, const void *b)
{
    long long v1 = *((long long *)a);
    long long v2 = *((long long *)b);

    if (v1 > v2) {
      return 1;
    } else if (v1 < v2) {
      return -1;
    } else {
      return 0;
    }
}

int main(void)
{
    int H, N;
    int i;
    int sum = 0;
    int flag = 0;

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

    qsort(A, N, sizeof(int), comp);

    for (i = 0; i < N; i++) {
        sum += A[i];
        if (sum >= H) {
            flag = 1;
            break;
        }
    }
    if (flag == 1) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 892
S=input()

o=['-','+']
for h in o:
    for i in o:
        for j in o:
            if 7 == eval(S[0]+h+S[1]+i+S[2]+j+S[3]):
                print(S[0]+h+S[1]+i+S[2]+j+S[3]+"=7")
                exit()

Measured memory_bytes: 9112
S = list(map(int,(input())))
N = len(S)
pa = [None]*N
pb = [None]*N

for i in range(N):
    if i%2 == 0:
        pa[i] = 0
    else:
        pa[i] = 1

for i in range(N):
    if i%2 == 0:
        pb[i] = 1
    else:
        pb[i] = 0

ca = 0
cb = 0
for i in range(N):
    ca += abs(pa[i] - S[i])
    cb += abs(pb[i] - S[i])

print(min(ca,cb))

Measured memory_bytes: 45020
def main():
    a,b,c = map(int,input().split())
    if a%2==0 or b%2==0 or c%2==0 :
        print(0)
    else:
        ori = [a,b,c]
        ori = sorted(ori,reverse=True)
        print(ori[1]*ori[2])
        




if __name__ == '__main__':
    main()

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

using i64 = long long;

int dp[3][100005]={0};
int h[3][100005]={0};

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

    for(int i=1;i<=n;++i){
        for(int j=0;j<3;++j){
            dp[j][i] = h[j][i] + max(dp[(j+1)%3][i-1], dp[(j+2)%3][i-1]);
        }
    }

    cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    int a; cin >> a;
    long long sum = 0;
    repeat(i, 1, a+1)
        if(i%3 && i%5) sum += i;
    cout << sum;


    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 5000;
const int mo = 1e9 + 7;

int n;
vector<int> G[N + 5];
int dp[N + 5][N + 5], sz[N + 5], fac[N + 5];

void init() {
    fac[0] = 1;
    for(int i = 1; i <= N; ++i) if(i % 2 == 0) fac[i] = ll(i-1) * fac[i-2] % mo;
}

void add(int &x, int y) {
    (x += y) >= mo ? x -= mo : 0;
}

void dfs(int u, int f = 0) {
    sz[u] = 1;
    dp[u][1] = 1;

    for(auto v : G[u]) if(v != f) {
        dfs(v, u);

        static int tmp[N + 5];
        for(int x = 0; x <= sz[v] + sz[u]; ++x) tmp[x] = 0;
        for(int i = 0; i <= sz[u]; ++i) {
            for(int j = 0; j <= sz[v]; ++j) {
                add(tmp[i + j], (ll) dp[u][i] * dp[v][j] % mo);
            }
        }
        for(int x = 0; x <= sz[v] + sz[u]; ++x) dp[u][x] = tmp[x];
        sz[u] += sz[v];
    }
    for(int i = 2; i <= sz[u]; ++i) {
        add(dp[u][0], mo - ((ll) dp[u][i] * fac[i] % mo));
    }
    
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    init();
    read(n);
    for(int i = 1; i < n; ++i) {
        static int x, y;
        read(x), read(y);
        G[x].pb(y), G[y].pb(x);
    }

    dfs(1);
    printf("%d\n", mo - dp[1][0]);

    return 0;
}


Measured memory_bytes: 97408
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
        String[] aList = new String[n];
        String[] bList = new String[m];
      
        for (int i = 0; i < n; i++) {
          aList[i] = sc.next();
        }
        for (int i = 0; i < m; i++) {
          bList[i] = sc.next();
        }
        String ans = "No";
        hLoop: for (int h = 0; h < (n - m + 1); h++) {
          wLoop: for (int w = 0; w < (n - m + 1); w++){
             if (!aList[h].substring(w, w + m).equals(bList[0])) {
               continue wLoop;
             }
             int candidate = h;
             for (int index = 0; index < m; index++) {
               if (!aList[candidate].substring(w, w + m).equals(bList[index])) {
                 continue wLoop;
               }
               candidate++;
               if (index == m - 1) {
                 ans = "Yes";
                 break hLoop;
               }
             }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

int n;
vector<string> s;
int ans;

int main(){
	cin >> n;
	for(int i=0; i<n; ++i){
		string tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	for(int i=0; i<n; ++i){
		bool f = true;
		for(int j=0; j<n; ++j)
			for(int k=0; k<n; ++k)
				if(s[j][k] != s[(k-i+n)%n][(j+i+n)%n])
					f = false;
		if(f) ans += n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
a = int(input())
b = list(map(int, input().split()))
c = 0
for i in range(2, a):
    if b[i] > b[i-1] > b[i-2]:
        c += 1
    elif b[i] < b[i-1] < b[i-2]:
        c += 1
print(c)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int main(){
    int n,cnt;
    cnt=1;
    char s[101];
 

    scanf("%d %s",&n,s);
    if(n%2==0){
        cnt =0;
        
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+(n/2)]){
                
                cnt =1;
            }
        
    }

    }

    if(cnt==1){
        printf("No");
    }else{
        printf("Yes");
    }


    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

// main() { UnionFind uf(N); }
struct UnionFind
{
    vector<int> par; //par[i]:= iの親の番号
    vector<int> siz; //siz[i]:= iの属する連結成分の大きさ
    UnionFind(int N) {
        par.resize(N);
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
        siz.resize(N,1);
    }

    int root(int x){ // xが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }

    bool unite (int x, int y) { // xとyの木を併合
        x = root(x); y = root(y);
        if (x == y) return false;
 
        if (siz[x] < siz[y]) swap(x, y); // merge technique 小を大にくっつける
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    int size(int x) { // xの属する木の大きさを得る
        return siz[root(x)];
    }
};



int main()
{
    int n,m; cin >> n >> m;
    UnionFind uf(n);

    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int res = 0;
    rep(i,n) {
        chmax(res, uf.size(i));
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4744
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=30;
    int H,W;
    char grid[MAXN][MAXN];
    int vis[MAXN][MAXN];
    int len[MAXN][MAXN];
    int xdir[4]={0,0,1,-1}
        ,ydir[4]={1,-1,0,0};
    bool legal(int r,int c){
        return r>=1&&r<=H&&c>=1&&c<=W
        &&vis[r][c]==false&&grid[r][c]=='.';
    }
    int bfs(int r,int c){
        memset(vis,0,sizeof(vis));
        queue<pair<int,int>>q;
        q.push({r,c});
        len[r][c]=0;
        int maxl=0;
        while(!q.empty()){
            pair<int,int>t=q.front();
            q.pop();
            int r=t.first,c=t.second;
            if(vis[r][c])continue;
            vis[r][c]=true;
            for(int u=0;u<4;u++){
                int nr=r+ydir[u],nc=c+xdir[u];
                if(!legal(nr,nc))continue;
                len[nr][nc]=len[r][c]+1;
                q.push({nr,nc});
                maxl=max(maxl,len[nr][nc]);
            }
        }
        return maxl;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>H>>W;
        for(int u=1;u<=H;u++)
            cin>>grid[u]+1;
        int ans=0;
        for(int u=1;u<=H;u++){
            for(int v=1;v<=W;v++){
                if(grid[u][v]=='.')
                ans=max(ans,bfs(u,v));
            }
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

namespace ABC
{

    class ABC170
    {
        static Char alpha;

        static void Main(String[] args)
        {
            string result = "a";
            alpha = Console.ReadLine().ToCharArray()[0];

            if (Char.IsUpper(alpha))
            {
                result = "A";
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 25792
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int q = nint();
        for (int i = 0; i < q; i++) {
            String a = nstr();
            String b = nstr();
            so.println(lcsLength(a, b));
        }
    }
    
    private static int lcsLength(String a, String b) {
        int lenA = a.length();
        int lenB = b.length();
        int[][] c = new int[lenA+1][lenB+1];
        for (int iA = 1; iA <= lenA; iA++) {
            for (int iB = 1; iB <= lenB; iB++) {
                if (a.charAt(iA-1) == b.charAt(iB-1)) {
                    c[iA][iB] = c[iA-1][iB-1] + 1;
                } else {
                    c[iA][iB] = Math.max(c[iA-1][iB], c[iA][iB-1]);
                }
            }
        }
        return  c[lenA][lenB];
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}



Measured memory_bytes: 64716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct T{
  ll sum;
  int i,j;
};

bool compare_T(const T & l, const T & r){
  if(l.sum==r.sum) return l.j > r.j;
  return l.sum > r.sum;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N; ll M;cin >> N >> M;
  vector<ll> v(N);
  rep(i,N)cin >> v[i];
  sort(all(v));

  //増える幸福度がX以上になる数．
  auto f = [&](ll X){
    ll ret = 0;
    rep(i,N){
      ret += max(0,(int) (v.end() - lower_bound(all(v),X-v[i])));
    }
    return ret;
  };

  ll l = 0, r = 2*1e5+10;
  while(r-l>1){
    ll m = (r+l)/2;
    if(f(m) >= M) l = m;
    else r = m;
  }

  vector<ll> w(N+1,0);
  rep(i,N) w[i+1] = w[i]+v[i];
  ll sum = 0;
  rep(i,N){
    int j = (int)(lower_bound(all(v), l-v[i]) - v.begin());
    sum += w[N] - w[j] + v[i]*(N-j);
  }
  sum -= (f(l)-M)*l;
  cout << sum << endl;
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int l,k;
ll dp[111][2];

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

	cin>>l>>k;
	dp[0][1]=1;
	REP(i,l) {
		REP(j,2) {
			if(dp[i][j]) {
				if(j) dp[i+k][j^1]+=dp[i][j];
				dp[i+1][j^1]+=dp[i][j];
			}
		}
	}
	ll ans=0;
	FOR(i,1,l+1) ans+=dp[i][0];
	cout<<ans<<endl;

	return 0;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int x, y, z[13] = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };

int main() {
	cin >> x >> y;
	
	cout << (z[x] == z[y] ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ull = unsigned long long;

int main() {

    int n;
    ull k;

    cin >> n >> k;

    vector<int> v(n);

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

    vector<int> root;
    vector<int> done(n, -1);

    int index = 0;
    ull count = 0;
    while(done[index] == -1) {
        done[index] = count++;
        root.push_back(index);
        index = v[index];

    }

    ull loopCount = count - done[index];
    /*
    cout << "count = " << count << endl;
    cout << "loopCount = " << loopCount << endl;
    cout << k - index << endl;
    cout << index + (k - index) % loopCount;
    */
    if(k < count)
        cout << root[k] + 1 << endl;
    else {
        ull a = count - loopCount;
        cout << root[a + (k - a)%loopCount] + 1 << endl;
    }
    return 0;


}

Measured memory_bytes: 5816
from sys import stdin

n,l = [int(x) for x in stdin.readline().rstrip().split()]
aji_arr = []
total = 0

for i in range(1,n+1):
    aji = l+i-1
    total += aji
    
    if(i == 1):
        aji_min = abs(aji)
        del_aji = aji
    elif(aji_min >= abs(aji)):
        aji_min = abs(aji)
        del_aji = aji
total = total - del_aji
print(total)




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

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	rep(i,s.length()) {
		char t = s[i] + n;
		if (t > 'Z') t -= 26;
		cout << t;
	}

	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int P,Q;
int N;
vector<int>A[1111],B[1111];

bitset<300>G[300];
bool used[1111];

void add(int a,int b){
    G[a][b]=1;
    G[a]|=G[b];
    rep(i,300)if(G[i][a])G[i]|=G[a];
}

void solve(){
    G[P][Q]=1;

    while(true){
        bool f=false;
        rep(i,N){
            if(used[i])continue;
            bool latte=false;
            rep(j,A[i].size()){
                if(G[A[i][j]][B[i][j]])latte=true;
            }
            if(!latte)continue;
            f=true;

            rep(j,A[i].size())add(A[i][j],B[i][j]);
            used[i]=true;
            break;
        }
        if(!f)break;
    }

    rep(i,300)if(G[i][i]){
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;

}

signed main(){
    string p,q;
    cin>>p>>q>>N;

    vector<string>lis;
    lis.pb(p);lis.pb(q);

    vector<vector<string>>X(N),Y(N);
    rep(i,N){
        int m;cin>>m;
        while(m--){
            string s,t;
            cin>>s>>t;
            X[i].pb(s);
            Y[i].pb(t);
            lis.pb(s);lis.pb(t);
        }
    }

    sort(all(lis));lis.erase(unique(all(lis)),lis.end());

    P=lower_bound(all(lis),p)-lis.begin();
    Q=lower_bound(all(lis),q)-lis.begin();

    rep(i,N){
        rep(j,X[i].size()){
            A[i].pb(lower_bound(all(lis),X[i][j])-lis.begin());
            B[i].pb(lower_bound(all(lis),Y[i][j])-lis.begin());
        }
    }

    solve();
    return 0;
}

Measured memory_bytes: 18704
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
    cout << fixed << setprecision(10);
    int N,R;
    cin >> N>>R;
    if (N < 10) {
        cout << R + 100 * (10 - N);
    }
    else {
        cout << R;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i=0,j=0,max=0;
	char str[11];
	scanf("%s",str);
	for(i=0;i<11;i++){
		if(str[i]=='A'||str[i]=='T'||str[i]=='G'||str[i]=='C'){
			j++;
			if(max<j){
			max=j;
			}
		}else{
			j=0;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,k,ans=0;cin>>n>>k;
    for(int i=0,x;i<n;i++){
    	cin>>x;
    	ans+=min(2*x,2*(k-x));
    }
    cout<<ans;
}
    

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public final static double MAX_T = 1000000;
	public final static double MIN_T = 0;
	public static int s = 0;

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long k = in.nextLong();
			if (k == 0) {
				out.println("2");
				out.println("0 0");
				return;
			}
			if (k == 1) {
				out.println("2");
				out.println("2 0");
				return;
			}
			if (k <= 50) {
				out.println(k);
				for (int i = 0; i < k - 1; i++) {
					out.print(k + " ");
				}
				out.println(k);
				return;
			}
			out.println("50");
			long[] arr = new long[50];
			for (int i = 0; i < 50; i++) {
				arr[i] = 49;
			}
			long mod = k % 50;
			for (int i = 0; i < mod; i++) {
				arr[i] += 50;
				for (int j = 0; j < 50; j++) {
					if (j != i) {
						arr[j]--;
					}
				}
			}
			long k50 = (k - mod) / 50;
			for (int i = 0; i < 50; i++) {
				arr[i] += k50;
			}
			for (int i = 0; i < 49; i++) {
				out.print(arr[i] + " ");
			}
			out.println(arr[49]);

		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long a,b,c,d;
int gcd(int x,int y){
    while(y){
        int t=y;
        y=x%y,x=t;
    }
    return x;
}
int main(){
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    long long C=b/c-a/c+(a%c==0);
    long long D=b/d-a/d+(a%d==0);
    long long lcm=1LL*c*d/gcd(c,d);
    long long CD=b/lcm-a/lcm+(a%lcm==0);
    printf("%lld\n",b-a+1-C-D+CD);
    return 0;
}

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

using namespace std;

int main(){
    int a,b;
    string s;
    cin>>a>>s>>b;
    if (s=="+") {
        cout<<a+b<<endl;
    }else{
        cout<<a-b<<endl;
    }
    return 0;
}

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

int main() {
	// your code goes here
     int n;
     cin>>n;
     
          string str;
          cin>>str;
          if(n%2==1 || n==1){
               cout<<"No"<<endl;
          }else{
          
          bool flag=false;
          for(int i=0,j=n/2;i<n/2,j<n;i++,j++){
               if(str[i]!=str[j]){
                    flag=true;
                    break;
               }
          }

          if(flag){
               cout<<"No"<<endl;
          }else{
               cout<<"Yes"<<endl;
          }
     }
     
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int INF = 1e8;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;

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

int n, k;
bool used[MAXN];
bool check(int x){
    string s = to_string(x);
    for (int j = 0; j < s.length(); j++){
        if (used[s[j] - '0']) return false;
    }
    return true;
}
void solve(){
        cin >> n >> k;
        for (int i = 1; i <= k; i++){
            int x;
            cin >> x;
            used[x] = true;
        }
    for (int i = n; i <= n * 10; i++){
        if (check(i)){
            cout << i << endl;
            return;
        }
    }
}

int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(7);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int m = o[1];
            var a = new int[n];
            var b = new int[n];
            for(int i=0;i<n;++i)
            {
                o = ReadAndParseIntArr();
                a[i] = o[0];
                b[i] = o[1];
            }
            var c = new int[m];
            var d = new int[m];
            for(int i=0;i<m;++i)
            {
                o = ReadAndParseIntArr();
                c[i] = o[0];
                d[i] = o[1];
            }

            for(int i=0;i<n;++i)
            {
                int minDist = int.MaxValue;
                int minIdx = int.MaxValue;
                int pa = a[i];
                int pb = b[i];
                for(int j=0;j<m;++j)
                {
                    int dist = Math.Abs(pa - c[j]) + Math.Abs(pb - d[j]);
                    if( dist < minDist)
                    {
                        minDist = dist;
                        minIdx = j;
                    }
                }
                Console.WriteLine(minIdx + 1);
            }
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
int sum(string s)
{
    int x=0,sz=s.size();
    loop(i,0,sz)x+=(s[i]-'0');
    return x;
}
/*
struct node
{
int data;
node *link;
};
typedef node* nodeptr;
void head_insert(nodeptr& head,int x)
{
    nodeptr tmp;
    tmp=new node;
    tmp->data=x;
    tmp->link=head;
    head=tmp;
}
nodeptr search(nodeptr head,int x)
{
    nodeptr cur=head;
    if(cur ==  nullptr)return cur;
    while(cur->data!=x&&cur->link!=nullptr)
    {
        cur=cur->link;
    }
    if(cur->data==x)return cur;
    else return nullptr;
}
void show(nodeptr head)
{
    nodeptr cur=head;
    if(cur==nullptr)return;
   // cout<<head->data<<" ";
    while(cur->link!=nullptr){
        cout<<cur->data<<" ";
        cur=cur->link;
    }
    cout<<endl;
}
*/

int main()
{
    mego
int n,k,x;
vector<int> v;
cin>>n>>k;
loop(i,0,n)
{
    cin>>x;
    v.pb(x);
}
sort(v.begin(),v.end());
int ans=0;
loop(i,0,k)ans+=v[i];
cout<<ans;
  return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    long long N , K;
    cin >> N >> K;
    long long A[N];
    for(long long i = 0 ; i < N ;i++)cin >> A[i];
    sort(A,A+N);
    long long left = -LLONG_MAX/2;
    long long right = LLONG_MAX/2;
    while(left+1 < right){
        long long mid = (left+right)/2;
        // 積がmid以下であるものをカウントする
        long long cnt=0;
        for(long long i = 0 ; i < N; i++){
            if(A[i]<0){
                long long l=-1;
                long long r=N;
                while(l+1<r){
                    long long m = (l+r)/2;
                    if(A[m]*A[i]<=mid){
                        r=m;
                    }
                    else{
                        l=m;
                    }
                }
                //cout << A[i] << "......" << N-r << endl;
                cnt += N-r;
                if(A[i]*A[i]<mid) cnt--;
            }
            else if(A[i]==0){
                if(mid>=0){
                    cnt +=N-1;
                    //cout << A[i] << "......" << N-1 << endl;
                }
            }
            else{
                // mid/A[i] 以下のものをカウントする
                long long l=-1;
                long long r=N;
                while(l+1<r){
                    long long m = (l+r)/2;
                    if(A[m]*A[i]<=mid){
                        l=m;
                    }
                    else{
                        r=m;
                    }
                }
                //cout << A[i] << "...... "<< l+1 << endl;
                cnt += l+1;
                if(A[i]*A[i]<mid) cnt--;
            }
        }
        //cout <<mid <<"..." <<cnt << endl;
        cnt /=2;
        if(cnt >= K){
            right = mid;
        }
        else{
            left = mid;
        }
    }
    cout << right << endl;

    return 0;
}


Measured memory_bytes: 1792