akhauriyash/Code-Regression huggingface dataset:
using System;

public class Cnt
{
    public int count { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map = new int[h, w];
            var sx = 0; var sy = 0;
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                    if (s[j] == '#') map[i, j] = 2;
                    else if (s[j] == '@') { sx = i; sy = j; }
            }
            var cnt = new Cnt();
            goDfs(map, sx, sy, dx, dy ,cnt);
            Console.WriteLine(cnt.count);
        }
    }
    public static void goDfs (int[,] map, int x, int y, int[] dx, int[] dy ,Cnt cnt)
    {
        var h = map.GetLength(0);
        var w = map.GetLength(1);
        map[x, y] = 1;
        cnt.count++;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];  var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == 0) goDfs(map, nx, ny, dx, dy ,cnt);
        }
    }
}

Measured memory_bytes: 9192
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int t = 1;
    int count = 0;
    while (t < b) {
      count++;
      t = t - 1 + a;
    }
    pw.println(count);
  }
}


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

vector<pair<ll, ll>> ab;

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

    rep(i, N) {
        int a, b;
        cin >> a >> b;
        ab.emplace_back(a, b);
    }
    sort(ab.begin(), ab.end());

    priority_queue<ll> que;
    ll ans = 0;
    int cur = 0;
    for (int i=1; i<=M; ++i) {
        while (cur < N) {
            if (ab[cur].first <= i) {
                que.push(ab[cur++].second);
            }
            else break;
        }
        if (que.size()) {
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int N,M;
vector<int> A;
int main(){
    cin >>  N >> M;
    REP(i,M){
        int a;
        cin >> a;
        A.push_back(a);
    }
    int day = accumulate(ALL(A),0);
    if(N >= day){cout << N - day << endl;}
    else{cout << -1 << endl;}
}

Measured memory_bytes: 3744
// AOJ 1240: Unreliable Message
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char msg[2][30]; int w;

int main()
{
	int t, k1, k2, i;
	char ord[7], *s, *p, *q;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s%s", ord, msg[0]);
		w = strlen(msg[0]); msg[1][w] = 0; s = ord + strlen(ord)-1;
		for (k1 = 0, k2 = 1; s >= ord; s--, k1 = k2, k2 = !k2) {
			p = msg[k1], q = msg[k2];
			if (*s == 'A') {
				q += w;	while (*p) *--q = *p++;
			} else if (*s == 'C') {
				*(q+w-1) = *p++; while (*p) *q++ = *p++;
			} else if (*s == 'E') {
				i = w/2; q += i; if (w & 1) q++;
				while(i-- > 0) *q++ = *p++;
				q = msg[k2]; if (w & 1) *(q+w/2) = *p++;
				while(*p) *q++ = *p++;
			} else if (*s == 'J') {
				*q++ = *(p+w-1); while (*p) *q++ = *p++;
				*(q-1) = 0;
			} else if (*s == 'M') {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '9') *q = '0'; else *q = (*p)+1;
					} else *q = *p;
					p++, q++;
				}
			} else {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '0') *q = '9'; else *q = (*p)-1;
					} else *q = *p;
					p++, q++;
				}
			}
		}
		puts(msg[k1]);
	}
 	return 0;
}

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

#define MOD 1000000007

int main()
{
    long long n, m;
    cin >> n >> m;

    vector<long long> x(n);
    vector<long long> diff_x(n, 0);
    for (long long i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (long long i = 1; i < n; i++)
    {
        diff_x[i] = (x[i] - x[i - 1]) % MOD;
    }

    vector<long long> y(m);
    vector<long long> diff_y(m, 0);
    for (long long i = 0; i < m; i++)
    {
        cin >> y[i];
    }
    for (long long i = 1; i < m; i++)
    {
        diff_y[i] = (y[i] - y[i - 1]) % MOD;
    }

    long long sum_x = 0;
    long long pattern, square;
    for (long long i = 1; i < n; i++)
    {
        pattern = i * (n - i);
        square = diff_x[i];
        sum_x += pattern * square;
        sum_x %= MOD;
    }

    long long sum_y = 0;
    for (long long i = 1; i < m; i++)
    {
        pattern = i * (m - i);
        square = diff_y[i];
        sum_y += pattern * square;
        sum_y %= MOD;
    }
    cout << sum_x * sum_y % MOD << endl;
}


Measured memory_bytes: 3328
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s, t;
	cin >> H >> W >> s >> t;
	vector<string>field(H);
	for (int i = 0; i < H; i++) {
		cin >> field[i];
	}
	vector<vector<bool>>edge(26, vector<bool>(26));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (field[i][j] == '-') {
				int a, b;
				for (int k = 0;; k--) {
					if (field[i][j + k] >= 'A'&&field[i][j + k] <= 'Z') {
						a = field[i][j + k] - 'A';
						break;
					}
				}
				for (int k = 0;; k++) {
					if (field[i][j + k] >= 'A'&&field[i][j + k] <= 'Z') {
						b = field[i][j + k] - 'A';
						break;
					}
				}
				edge[a][b] = true;
				edge[b][a] = true;
			}
			else if (field[i][j] == '|') {
				int a, b;
				for (int k = 0;; k--) {
					if (field[i + k][j] >= 'A'&&field[i + k][j] <= 'Z') {
						a = field[i + k][j] - 'A';
						break;
					}
				}
				for (int k = 0;; k++) {
					if (field[i + k][j] >= 'A'&&field[i + k][j] <= 'Z') {
						b = field[i + k][j] - 'A';
						break;
					}
				}
				edge[a][b] = true;
				edge[b][a] = true;
			}
		}
	}
	int st = s[0] - 'A';
	int gl = t[0] - 'A';
	vector<int>dis(26, MOD);
	dis[st] = 0;
	queue<int>Q;
	Q.push(st);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (int i = 0; i < 26; i++) {
			if (edge[cn][i]) {
				if (dis[cn] + 1 < dis[i]) {
					dis[i] = dis[cn] + 1;
					Q.push(i);
				}
			}
		}
	}
	cout << dis[gl] << endl;
	return 0;
}


Measured memory_bytes: 3256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int n;cin>>n;
    int ret=0;
    rep(i,0,n){
        int a;
        cin>>a;
        for(int j=31;j>0;--j){
            if(a%(1<<j)==0){
                ret+=j;
                break;
            }
        }
    }
    cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int a,b ;
char x[2],y[2] ;

int main(void){
    
    scanf ("%s%s",x,y) ;
    
    if ( x[0]=='A' ){
        a = 10 ;
    } else if ( x[0]=='B' ){
        a = 11 ;
    } else if ( x[0]=='C' ){
        a = 12 ;
    } else if ( x[0]=='D' ){
        a = 13 ;
    } else if ( x[0]=='E' ){
        a = 14 ;
    } else if ( x[0]=='F' ){
        a = 15;
    } else {
    }
    
    if ( y[0]=='A' ){
        b = 10 ;
    } else if ( y[0]=='B' ){
        b = 11 ;
    } else if ( y[0]=='C' ){
        b = 12 ;
    } else if ( y[0]=='D' ){
        b = 13 ;
    } else if ( y[0]=='E' ){
        b = 14 ;
    } else if ( y[0]=='F' ){
        b = 15;
    } else {
    }
    
    if ( a<b ){
        printf ("<\n") ;
    } else if (a==b) {
        printf ("=\n") ;
    } else if ( a>b ){
        printf (">\n") ;
    } else{
    }
    
    return 0 ;
    
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);
		int a = getInt(sc);
		int b = getInt(sc);

		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (checkSumRange(i, a, b)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	private static boolean checkSumRange(int i, int a, int b) {
		String[] digits = String.valueOf(i).split("");
		int sum = 0;
		for (String digit : digits) {
			sum += Integer.parseInt(digit);
		}

		if (sum < a || sum > b) {
			return false;
		} else {
			return true;
		}

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


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

struct Card{
  char suit;
  int value;
};


int main(){
  struct Card C1[36],C2[36];
  int n,i,j,tmp1,flag=0,mini,mini2,y=0;
  char x; /*null*/
  char tmp2;
  
  scanf("%d%c", &n, &x);
  for (i=0;i<n;i++){
    scanf("%c%d%c", &C1[i].suit, &C1[i].value, &x);
  }
  
  /*ばぶる*/
  
  for(i=0;i<n;i++){
    C2[i].suit=C1[i].suit;
    C2[i].value=C1[i].value;
  }
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(C1[j].value<C1[j-1].value){
	tmp1=C1[j].value;
	C1[j].value=C1[j-1].value;
	C1[j-1].value=tmp1;
	tmp2=C1[j].suit;
	C1[j].suit=C1[j-1].suit;
	C1[j-1].suit=tmp2;

      }
    }
  }
  for(i=0;i<n;i++){
    printf("%c%d",C1[i].suit,C1[i].value);
    if(i<n-1) printf(" ");
    else if(i==n-1) printf("\n");
  }
 
 printf("Stable\n");

  
  /*せれくしょん*/
  
  
  for(i=0;i<n;i++){
    mini=i;
    for(j=i;j<=n-1;j++){
      if(C2[j].value<C2[mini].value){
	mini=j;
	flag=1;    
      }
    }
    if(flag==1){
    tmp1=C2[i].value;
    C2[i].value=C2[mini].value;
    C2[mini].value=tmp1; 
    
    tmp2=C2[i].suit;
    C2[i].suit=C2[mini].suit;
    C2[mini].suit=tmp2;
    mini2=C2[i+1].suit;
    }
  }
  
  for(i=0;i<n;i++){
    printf("%c%d",C2[i].suit,C2[i].value);
 if(i<n-1) printf(" ");
 else if(i==n-1) printf("\n");
 if(C1[i].suit!=C2[i].suit) y=1;

  }
if(y==1) printf("Not stable\n");
 else printf("Stable\n");
  
  return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
int main(){
int N,k,i;
  scanf("%d %d",&N,&k);
  int h[N],a1,a2;
  a1=0;
 for(i=1;i<=N;++i){
   scanf("%d",&h[i]);
     if(h[i]>=k){
       a2=a1+1;
       a1=a2;
       }
       }
       printf("%d\n",a1);
}


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

int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0; i<n+1; i++){
		for(int j=0; j<m+1; j++){
			if(m*i+n*j-i*j*2==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void max2(int x, int y){
  if(x>y)
    printf("%d\n", x);
  else
    printf("%d\n", y);
}

void max3(int x, int y, int z){
  if(x>y)
    max2(x, z);
  else
    max2(y, z);
}

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

  int x = a+b;
  int y = a-b;
  int z = a*b;

  max3(x, y, z);

  return 0;
}


Measured memory_bytes: 128
N = int(input())
*A, = map(int, input().split())
A.sort(reverse=True)

def solve():
    cnt = 0
    ans = 0
    for i in range(N):
        c = 2 if i else 1
        for j in range(c):
            if cnt<N-1:
                ans += A[i]
            else:
                return ans
            cnt += 1
print(solve())

Measured memory_bytes: 31752
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
char m[100][100];
int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool f = true;
	for (int i = 0; i < s.size(); i++)f &= ((i == a) == (s[i] == '-'));
	printf(f ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int N, i, j, sum =0;
    int A[100050]={0};
    scanf("%d", &N);
    for(i=1;i<N+1;i++)
        scanf ("%d", &A[i]);
    for(i = 1;i <= N; i++)
        sum+=abs(A[i]-A[i-1]);
    sum+=abs(A[N]-A[0]);
    for(i=1;i<=N;i++)
        printf("%d\n",sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]));
    return 0;
}

Measured memory_bytes: 1536
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	string s,t;
	cin>>s>>t;
	if(t.size()==s.size()+1&&t.substr(0,s.size())==s)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3644
def main():
    n, d = map(int, input().split())
    inlis = list()
    tmp = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d ** 2:
            tmp += 1
    
    print(tmp)


if __name__ == "__main__":
    main()

Measured memory_bytes: 74324
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int y = 1;
	for (int i = 1; i <= x; i++)y *= i;
	return y;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}
int two(int x) {
	int cnt = 0;
	if (x == 0)return 1;
	while (x > 1) {
		x /= 2;
		cnt++;
	}
	return cnt;
}
int combi(int x, int y) {
	int cnt = 1;
	for (int i = x; x - i < y; i--)cnt *= i;
	return cnt / kai(y);
}
/*Library End!*/
int ss[30], tt[30];
signed main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size()+1; i++)ss[s[i]-'a']++;
	for (int i = 0; i < t.size()+1; i++)tt[t[i]-'a']++;
	sort(ss, ss + 27);
	sort(tt, tt + 27);
	for (int i = 1; i <= 26; i++) {
		if (ss[i] != tt[i]) {
			cout << "No" << endl;
			goto end;
		}
	}
	cout << "Yes" << endl;
end:;
	system("PAUSE");
	return 0;
}



Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		VI A(N);
		REP(i, N) cin>>A[i];
		sort(ALL(A));
		ll ans=0;
		REP(i, K) ans+=A[i];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3192
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var H = one[1];
  var W = one[2];
  var output = 0;
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    if(tmp[0] >= H && tmp[1] >= W){
       output++;
    }
  }
  myout(output);
}

Measured memory_bytes: 7740
N=int(input())
C=[0]*N
S=[0]*N
F=[0]*N

for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())

def calc(n):
    t=0
    for i in range(n,N-1):
        if(t<S[i]):
            t=S[i]
        if(t%F[i]!=0):
            t+=(F[i]-t%F[i])
        t+=C[i]
    print(t)


for i in range(N):
    calc(i)

Measured memory_bytes: 41656
n,a,b=map(int,input().split())
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
p=10**9+7
ans=(power_func(2,n,p)-1-combination(n,a,mod=10**9+7)-combination(n,b,mod=10**9+7))%p
print(ans)

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


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int m = a[1];
		int[][] e = new int[m][];
		for(int i=0; i<m; i++) {
			e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
			e[i] = e[i].Concat(new int[] { i }).ToArray();
		}

		Array.Sort(e,(x,y)=>((x[0]==y[0])?(x[1]-y[1]):(x[0]-y[0])));

		string[] ss = new string[m];
		int[] ccnt = new int[a[0]+1];
		for(int i=0; i<m; i++) {
			ccnt[e[i][0]]++;
			ss[e[i][2]] = String.Format("{0:D6}{1:D6}", e[i][0], ccnt[e[i][0]]);
		}

		for(int i=0; i<m; i++) Console.WriteLine(ss[i]);

//		string ans = e[1][1].ToString();

//		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 31988
import sys

n, y = map(int, input().split())

count = 0
for i in range(2001):
    for j in range(2001):
        k = n - i - j
        if k >= 0:
            sum = 10000*i + 5000*j + 1000*k
            if sum == y:
                print(i, j, k)
                sys.exit()
print('-1 -1 -1')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    long long int ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout << ans;
}

Measured memory_bytes: 5080
import sys
def input():
    return sys.stdin.readline()[:-1]

H,N = map(int,input().split(' '))

A = [None]*N
B = [None]*N
for i in range(N):
    a,b = list(map(int, input().split()))
    A[i] = a
    B[i] = b

INF = float('inf')
dp = [INF]*(H+1)
dp[H] = 0

for i in range(N):
    a = A[i]
    b = B[i]
    for j in range(H,0,-1):
        aft = j - a
        if aft<=0:
            dp[0] = min(dp[0],dp[j]+b)
        else:
            dp[aft] = min(dp[aft],dp[j]+b)
print(dp[0])

Measured memory_bytes: 51676
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b)
{
    long long int *A = (long long int *)a;
    long long int *B = (long long int *)b;
    if (*A > *B)return -1;
    if (*A < *B)return 1;
    return 0;
}
int main()
{
    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    int i;
    long long int a[1003], b[1003], c[1003];
    for (i = 0; i < x; i++)
        scanf("%lld", &a[i]);
    for (i = 0; i < y; i++)
        scanf("%lld", &b[i]);
    for (i = 0; i < z; i++)
        scanf("%lld", &c[i]);
    int n = 0, j;
    long long int p[1000006];
    for (i = 0; i < x; i++)
    {
        for (j = 0; j < y; j++)
        {
            p[n] = a[i] + b[j];
            n++;
        }
    }
    qsort(p, n, sizeof(long long int), asc);
    long long int q[3000006];
    n = 0;
    for (i = 0; i < k; i++)
    {
        for (j = 0; j < z; j++)
        {
            q[n] = p[i] + c[j];
            n++;
        }
    }
    qsort(q, n, sizeof(long long int), asc);
    for (i = 0; i < k; i++)
        printf("%lld\n", q[i]);
    return 0;
}

Measured memory_bytes: 54920
#include <iostream>

using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a%2||b%2||c%2){
        cout << 0 << endl;
    }else if(a==b&&b==c){
        cout << -1 << endl;
    }else{
        long res = 0;
        while(!(a%2)&&!(b%2)&&!(c%2)){
            long aa = (b+c)/2;
            long bb = (a+c)/2;
            long cc = (a+b)/2;
            a = aa;
            b = bb;
            c = cc;
            res++;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    ll ans=0,i=1;
    while(true){
        //sl(ans,i)
        if(ans>=N){
            cout<<i-1;break;
        }
        ans+=i;
        i++;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int c[100005];
int n, q, l, r, cnt;
string s;
int main() {
	cin >> n >> q;
	cin >> s;
	for(int i = 1; i < n; i++) {
		if(s[i] == 'C' && s[i - 1] == 'A')	c[i] = ++cnt;
		else	c[i] = cnt;
	}
	while(q--) {
		cin >> l >> r;
		cout << c[r - 1] - c[l - 1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1408
A, B, C, X = [int(input()) for _ in range(4)]

count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X == 500 * a + 100 * b + 50 * c:
                count += 1
print(count)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2,s3;
cin>>s1>>s2>>s3;
int t1,t2,t3;
t1=t2=t3=0;
int l1 = s1.length();
int l2 = s2.length();
int l3 = s3.length();
int nt = 1;
while(true)
{
	if ( nt == 1 )
	{
		if (t1 == l1)
		{
			cout<<'A';
			break;
		}
		
		if ( char(s1[t1]) == 'a')
		{
			nt = 1;
		}
		if ( char(s1[t1]) == 'b')
		{
			nt = 2;
		}
		if ( char(s1[t1]) == 'c')
		{
			nt = 3;
		}	
		t1++;
	}
	if ( nt == 2 )
	{

		if (t2 == l2)
		{
			cout<<'B';	
			break;
		}

		if (char(s2[t2]) == 'a')
		{
			nt = 1;
		}
		if (char(s2[t2]) == 'b')
		{
			nt = 2;
		}
		if (char(s2[t2]) == 'c')
		{
			nt = 3;
		}
			t2++;
	}
	if ( nt == 3 )
	{
		if (t3 == l3)
		{
			cout<<'C';
			break;
		}

		if ( char(s3[t3]) == 'a')
		{
			nt = 1;
		}
		if (char(s3[t3]) == 'b')
		{
			nt = 2;	
		}
		if (char(s3[t3]) == 'c')
		{
			nt = 3 ;
		}
			t3++;
	}	
}
return 0;	
}

Measured memory_bytes: 256
#define M 100
char m[M][M],s[M][M][M],r[M],*z;
cmp(char *p,char *q){
  int r=0;
  for(;*p=='0';p++);
  for(;*q=='0';q++);
  if(r=strlen(p)-strlen(q))return r;
  return strcmp(p,q);
}
main(w,h,i,j,k,l){
  for(;scanf("%d%d",&w,&h),w;puts(z)){
    memset(m,0xff,sizeof(m));
    memset(s,0,sizeof(s));
	memset(r,0,sizeof(r));
    for(j=1;j<=h;j++)scanf("%s",m[j]+1);
    for(i=1;i<=w+1;i++)for(j=1;j<=h;j++)if(m[j][i]<'0'||'9'<m[j][i])m[j][i]=-1;
    for(k=1;k<M;k++){
      for(j=i=k;i<=w;i++){
        if(m[j][i]==-1)continue;
		if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
		else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
		if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
      }
      for(j=i=k;j<=h;j++){
        if(m[j][i]==-1)continue;
		if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
		else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
		if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
      }
    }
    for(z=r;*z=='0';z++);
  }
return 0;}

Measured memory_bytes: 0
x, y = map(int,input().split())

# 鶴をp羽とする

p = 0

for p in range(x+1):
  if 2*p + 4*(x-p) - y == 0:
    p=x+5
    break
  else:
    x=x


if p==x+5:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
n, m, l = [int(arg) for arg in input().split()]
a = [[int(arg) for arg in input().split()] for _ in range(n)]
b = [[int(arg) for arg in input().split()] for _ in range(m)]
c = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        c[i][j] = sum([a[i][k] * b[k][j] for k in range(m)])

for i in range(n):
    print(' '.join([str(j) for j in c[i]]))



Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<lint> A(N+1);
    REP(i, N+1) cin >> A[i];
    vector<lint> B(N);
    REP(i, N) cin >> B[i];
    lint ans = 0;
    REP(i, N) {
        if(A[i] < B[i]) {
            ans += A[i];
            B[i] -= A[i];
            if(A[i+1] < B[i]) {
                ans += A[i+1];
                A[i+1] = 0;
            } else {
                ans += B[i];
                A[i+1] -= B[i];

            }
        } else {
            ans += B[i];
        }
    }
    cout << ans << endl;
}

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

signed main()
{
  int N;
  while (cin >> N, N) {
    if (!(N % 1111)) cout << ("NA");
    else {
      int cnt = 0;
      while (N != 6174) {
        int n[4], L = 0, S = 0;
        for (int i = 0; i < 4; i++) {
          n[i] = N % 10;
          N /= 10;
        }
        sort(n, n + 4);
        for (int i = 0; i < 4; i++) {
          L = L * 10 + n[3 - i];
          S = S * 10 + n[i];
        }
        cnt += 1;
        N = L - S;
      }
      cout << cnt;
    }
    cout << "\n";
  }

  return (0);
}

Measured memory_bytes: 3020
#include<stdint.h>
#include<stdbool.h>
#include<limits.h>
#include<inttypes.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdint.h>
#include<stdbool.h>
int main(){
  int n,k;
  scanf("%d", &n);
  int *x = (int *)calloc(n, sizeof(int));
  scanf("%d\n" ,&k);
  char buff[400] = {0};
  fgets(buff, 401, stdin);
  x[0] = atoi(strtok(buff, " "));
  for(int i =1; i < n; ++i)
	  x[i] = atoi(strtok(NULL, " "));
  int answer = 0;
  for(int i = 0; i < n; ++i)
	  answer += 2*x[i] < 2*abs(x[i]-k)? 2*x[i] : 2*abs(x[i]-k);
  printf("%d", answer);
  free(x);
  return 0;
}


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

int main()
{
	vector<int> num(26);
	string w;
	cin >> w;
	for (int i = 0; i < w.size(); i++) {
		num[w[i] - 'a']++;
	}
	bool res = true;
	for (int i = 0; i < 26; i++) {
		if (num[i] & 1) {
			res = false;
			break;
		}
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int x;
	cin>>x;
	cout<<(x/500)*1000+(x%500/5)*5<<endl;
	return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};



#define pb push_back
#define F first
#define S second
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define gap ' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

 int main()
 { ll n,i;
 cin>>n;
 int A[n+5],B[n+5];
 for(i=0;i<n;i++)
 {
    cin>>A[i];
    cin>>B[i];
 }
 bool ok=0;
 for(i=0;i<=(n-3);i++)
 {
     if(A[i]==B[i])
     {
         if(A[i+1]==B[i+1])
         {
            if(A[i+2]==B[i+2])
            {
                ok=1;
                break;


            }
         }
     }
 }

 if(ok==1)cout<<"Yes"<<endl;
 else
    cout<<"No"<<endl;




 return 0;


}


///Thanking you by Roxy






Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,k,s;
vector<int> a;
int main(){
    cin>>n>>k>>s;
    if(s==1000000000){
        for(int i=1;i<=k;i++) cout<<s<<" ";
        for(int i=k+1;i<=n;i++) cout<<s-1<<" ";
        cout<<endl;
        return 0;
    }
    for(int i=1;i<=k;i++) cout<<s<<" ";
    for(int i=k+1;i<=n;i++) cout<<s+1<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
    #include<map>
    #include<deque>
    #include<algorithm>
    #include<string>
    #include<cctype>
    using namespace std;
    #define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
    #define Rep(i,n) REP(i,0,n)
    typedef long long ll;
     
     
    string s[3];
     
    int main(){
        cin>>s[0]>>s[1]>>s[2];
        char next='a';
        while(1){
            if(next=='a'){
                if(s[0].size()>=1)next=s[0][0];
                else {next='A'; break;}
                s[0].erase(s[0].begin());
            }
            if(next=='b'){
                if(s[1].size()>=1)next=s[1][0];
                else {next='B'; break;}
                s[1].erase(s[1].begin());
            }
            if(next=='c'){
                if(s[2].size()>=1)next=s[2][0];
                else {next='C'; break;}
                s[2].erase(s[2].begin());
            }
        }
        cout<<next<<endl;

        return 0;
    }

Measured memory_bytes: 256
#include<stdio.h> 

int main(void){
int N, A, B;
scanf("%d %d %d", &N, &A, &B);

int ans  = 0;
for (int i = 1; i <= N; i++) {
int sum = i/10000 + (i/1000)%10+(i/100)%10+(i/10)%10+ i%10;
  if(sum >= A && sum <= B) ans += i;
}

printf("%d", ans);

return 0;

}

Measured memory_bytes: 128
import itertools

l, r = map(int, input().split())

if l // 2019 != r // 2019:
    print(0)
else:
    min_value = 2 * 10 ** 9
    for i in itertools.permutations(range(l, r + 1), 2):
        ixj = i[0] * i[1]
        min_value = min(min_value, ixj % 2019)
    print(min_value)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 1e5+5;
int n,u,v,k,ans[N];
vector<pair<int,int> > G[N];
il add_edge(int u,int v,int dis){
	G[u].push_back(make_pair(v,dis));
	G[v].push_back(make_pair(u,dis));
}
il DFS(int u,int fa){
	for(auto _:G[u]){
		int v=_.first,k=_.second;
		if(v==fa) continue;
		if(!k) ans[v]=ans[u];
		else ans[v]=ans[u]^1;
		DFS(v,u);
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<n;++i){
		read(u),read(v),read(k);
		add_edge(u,v,k%2);
	}
	DFS(1,0);
	for(ri i=1;i<=n;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 7552
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int x[1003][1003], H, W, dp[1003][1003][2];
int range(int a, int b, int c, int d) {
	return x[a - 1][b - 1] + x[c][d] - x[a - 1][d] - x[c][b - 1];
}
int solve(int p, int q, int r) {
	if (dp[p][q][r] >= (-1LL << 30))return dp[p][q][r];
	if (p == H + 1 || q == W + 1)return 0;
	int r1 = -2e9, r2 = -2e9;
	r1 = solve(p + 1, q, r ^ 1);
	r1 += range(p, q, p, W);
	r2 = solve(p, q + 1, r ^ 1);
	r2 -= range(p, q, H, q);
	if (r == 0) { dp[p][q][r] = max(r1, r2); return max(r1, r2); }
	if (r == 1) { dp[p][q][r] = min(r1, r2); return min(r1, r2); }
}
int main() {
	cin >> W >> H; for (int i = 0; i <= H + 1; i++) { for (int j = 0; j <= W + 1; j++) { dp[i][j][0] = -2e9; dp[i][j][1] = -2e9; } }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)cin >> x[i][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)x[i][j] += x[i - 1][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)x[i][j] += x[i][j - 1]; }
	cout << abs(solve(1, 1, 0)) << endl;
	return 0;
}

Measured memory_bytes: 15008
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int ary[] = new int[n+1];
    ary[0] = 0;
    int d = 0;
    int cnt = 0;
    for(int c = 1;c<=n;c++){
      d += sc.nextInt();
      ary[c] = d;
    }
    for(int c = 0;c<=n;c++){
      if(ary[c]<=x)cnt++;
    }
    System.out.println(cnt);
  } 
}

Measured memory_bytes: 23636
H, W = list(map(int,input().split(' ')))
ar = []
for i in range(H):
  w = list(input())
  #print(set(w))
  if set(w) != {'.'}:
    ar.append(w)
    
#print(ar)  

import numpy as np
ar2 = np.array(ar)
ar2_T = ar2.T
ar = []
for i in ar2_T:
#  print(set(i))
  if set(i) != {'.'}:
    ar.append(i)

ar_T = np.array(ar).T
for i in ar_T:
  print(''.join(i))

Measured memory_bytes: 12428
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    char[] A = sc.next().toCharArray();
    char[] B = sc.next().toCharArray();
    char[] C = sc.next().toCharArray();
    int cnt = 0;
    for(int i=0; i<N; i++){
      if(A[i]==B[i] && A[i]==C[i]){
        ;
      }else if(A[i]!=B[i] && A[i]!=C[i] && B[i]!=C[i]){
        cnt += 2;
      }else{
        cnt++;
      }
    }
    System.out.print(cnt);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int solve(long long a, long long b, long long c, long long d, long long e, long long k){
    if(e-a > k) { cout << ":(" << endl;     return 0;}
    cout << "Yay!" << endl;
}

int main(){

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    long long e;
    scanf("%lld",&e);
    long long k;
    scanf("%lld",&k);
    solve(a, b, c, d, e, k);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
long long x,y,n,m,i,j,ans;
int k,tot;
int a[N],b[N],ver[N],nxt[N],head[N],edge[N]; 
void add(int x,int y,int w)
{
	ver[++tot]=y,edge[tot]=w,nxt[tot]=head[x],head[x]=tot;
}
int main()
{
	tot=1;
	scanf("%lld%lld",&n,&m);
	ans=2019;
	for(long long i=n;i<=min(n+2019,m);i++)
	{
		for(long long j=n;j<=min(n+2019,m);j++)
		{
			if(i!=j)
			{
				ans=min(ans,(i*j)%2019);
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  string s;
  cin >> n >> s;
  vector<int> c(26,1);
  long long ans=1;
  for(int i=0;i<n;i++){
    c[s[i]-'a']++;
  }
  for(int i=0;i<26;i++){
    ans*=c[i];
    ans%=1000000007;
  }
  cout << (ans-1)%1000000007 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



void solve() {
    string s; cin >> s;
    cout << (s >= "a" ? "a" : "A") << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	char s;
	cin >> s;

	int num = s - 'a';

	if (num >= 0){
		cout << 'a' << "\n";
	} else {
		cout << 'A' << "\n";		
	}



	return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int X=int.Parse(Console.ReadLine());
      if(X>=30){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
    }
    
  }

}


Measured memory_bytes: 27480
def swap(a, b, k):
    if k % 2 == 0:
        if a % 2 == 1:
            a -= 1
        return a/2, b+a/2
    if b % 2 == 1:
        b -= 1
    return int(a+b/2), int(b/2)


if __name__ == '__main__':
    a, b, k = list(map(int, input().split()))
    for i in range(k):
        a,b = swap(a,b,i)
    print(int(a), int(b))


Measured memory_bytes: 3060
//Swapping Bibs
#include <iostream>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int A[N], a;
    for(int i = 0; i < N; i++) cin >> A[i];

    for(int k = 1; k < M + 1; k++) {
        int i = 0;
        while(i != N - 1) {
            if(A[i] % k > A[i + 1] % k) swap(A[i], A[i + 1]);
            i++;
        }
    }

    for(int i = 0; i < N; i++) cout << A[i] << endl;
}


Measured memory_bytes: 3120