akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i != (b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int maxn = 500;

int H, W, A[maxn][maxn];

struct T {
	int a, b, c, d;

	T(int _a, int _b, int _c, int _d) : a(_a), b(_b), c(_c), d(_d) {}
};

vector<T> ans;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> H >> W;

	REP(y, H) REP(x, W) {
		cin >> A[y][x];
	}

	int x = 0, y = 0;
	bool toRight = true;
	// follow the route.

	while (y < H) {
		int oldx = x, oldy = y;

		if (x == 0 && !toRight) {
			y++;
			toRight = true;
		} else if (x == W - 1 && toRight) {
			y++;
			toRight = false;
		} else {
			x += (toRight ? 1 : -1);
		}

		if (y < H && A[oldy][oldx] % 2 == 1) {
			// move one away!
			ans.eb(oldy + 1, oldx + 1, y + 1, x + 1);
			A[y][x]++;
		}
	}

	cout << (int) ans.size() << endl;
	for (T t : ans)
		cout << t.a << " " << t.b << " " << t.c << " " << t.d << endl;

	return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	int H[20];
	rep(i,N)cin>>H[i];
	
	int ans=0;
	rep(i,N){
		bool ok=true;
		rep(j,i)if(H[j]>H[i])ok=false;
		if(ok)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int n,d,c;
int main() {
	cin>>n>>s;
	for(int i=0;i<s.size();i++){if(s[i]=='(')c++;else c--;d=min(c,d);}
	for(int i=0;i<-d;i++)cout<<'(';cout<<s;
	for(int i=0;i<c-d;i++)cout<<')';
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0){
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

    
    

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

int main() {
  long long a,b,X,ans,g;
  cin>>a>>b>>X;
  if(a!=0){
  ans=b/X-(a-1)/X;
  }
  else {
    ans=b/X+1;
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(){
    long long n;
    cin>>n;
    long double a[n],ans=0;
    f(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    f2(i,n-1,1){
        ans+=a[i]/pow(2,n-i);
    }
    ans+=a[0]/pow(2,n-1);
    cout<<fixed<<setprecision(5)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int t = gcd(A, gcd(B, C));
    cout << (gcd(A/t, B/t) == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d)cout<<"Yes"<<endl;
    else {
        if(abs(a-b)>d)cout<<"No"<<endl;
        else {
            if(abs(b-c)<=d)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
         }
     }
 }
        

Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest115-A
#  https://beta.atcoder.jp/contests/abc115/tasks/abc115_a

def christmasCheck(inputInt) :

	ans =""
	if inputInt == 25:
		ans = "Christmas"
	elif inputInt == 24:
		ans = "Christmas Eve"
	elif inputInt == 23:
		ans = "Christmas Eve Eve"
	elif inputInt == 22:
		ans = "Christmas Eve Eve Eve"

	return ans


if __name__ == '__main__':

	inputInt = int(input())
	ans=christmasCheck(inputInt)
	print(ans)


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`



				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	//https://atcoder.jp/contests/abc165/tasks/abc165_f
	//https://www.dropbox.com/sh/nx3tnilzqz7df8a/AAA0887IQFx5BcrZcrpRD7uga/ABC165/F?dl=0&subfolder_nav_tracking=1

	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()

	ans := 0

	for ai := 0; ai <= a; ai++ {
		if x >= ai*500 {
			for bi := 0; bi <= b; bi++ {
				if x-(500*ai+100*bi) >= 0 && x-(500*ai+100*bi) <= 50*c {
					ans++
				}
			}
		}
	}

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
n=int(input())
l=list(map(int,input().split()))
t=sum(l)
y=0
x=[0]*(10**5+1)
for i in range(n):
    x[l[i]-1]+=1
r=int(input())
for i in range(r):
    a,b=map(int,input().split())
    if(x[a-1]>0):
       x[b-1]+=x[a-1]
       print(t+b*x[a-1]-a*x[a-1])
       t=t+b*x[a-1]-a*x[a-1]
       x[a-1]=0
    else:
        print(t)

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

#define INF 2147483647

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) std::cin >> A.at(i);
  int left, right;
  int time = INF;
  for (int i = 0; i < N-K+1; i++)
  {
    left = std::min(0, A.at(i)), right = std::max(0, A.at(i+K-1));
    if (right * left < 0) time = std::min(time, std::min(right - 2*left, 2*right - left));
    else time = std::min(time, std::abs(right - left));
  }
  std::cout << time << std::endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int _x, _y, x, y;
			_x = parseInt(line.substring(0, line.indexOf(' ')));
			_y = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((_x | _y) == 0) break;

			if (_x >= _y) {
				x = _x;
				y = _y;
			} else {
				x = _y;
				y = _x;
			}

			int m, step = 0, gcd;
			while (true) {
				m = x % y;
				x = y;
				y = m;
				step++;
				if (y == 0) {
					gcd = x;
					break;
				}
			}
			System.out.println(gcd + " " + step);
		}
	}
}

Measured memory_bytes: 21216
import java.util.Scanner;

public class Main {

	static final int INF = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h][w];
		for(int i = 0 ; i < h ; i++) {
			s[i] = sc.next().toCharArray();
		}
		int[] dx = {1, 1, 1, 0, 0, -1, -1, -1};
		int[] dy = {1, 0, -1, 1, -1, 1, 0, -1};
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				if(s[i][j] == '.') {
					int cnt = 0;
					for(int k = 0 ; k < 8 ; k++) {
						int nx = i + dx[k];
						int ny = j + dy[k];
						if(0 <= nx && nx <= h - 1 && 0 <= ny && ny <= w - 1 && s[nx][ny] == '#') {
							cnt++;
						}
					}
					s[i][j] = (char)(cnt + '0');
				}
			}
		}
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				System.out.print(s[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 24404
#include<iostream>

using namespace std;

int main() {
  int n, m;
  int A[100][100], B[100], X[100];

  cin >> n >> m;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> A[i][j];

  for (int j = 0; j < m; j++)
    cin >> B[j];

  for (int i = 0; i < n; i++)
    X[i] = 0;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      X[i] += A[i][j] * B[j];

  for (int i = 0; i < n; i++)
    cout << X[i] << endl;

  return 0;
}



Measured memory_bytes: 3136
package main

import (
	"fmt"
)

func main() {
	var n,k,d,num int
	fmt.Scan(&n,&k)
	
	sunukes := make(map[int]bool,n+1)
	
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			fmt.Scan(&num)
			sunukes[num] = true
		}
	}
	
	cnt := 0
	for i := 1; i <= n; i++ {
		if !sunukes[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 2400
#include<bits/stdc++.h>
using namespace std;
#define N 2000010
int n,a[N],m,q[N],h,t,f[N],p,s;
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		scanf("%d",&a[i]);
		if(i>2)s+=a[i];
	}
	cin>>m;
	h=1e6+5;
	t=h-1;
	for(int i=0;i<=1e6;i++)q[++t]=i;
	for(int i=3;i<n;i++){
		int p=h+a[i];
		for(int j=h+1;j<=p;j++){
			h--;
			q[h]=q[j];
		}
	}
	for(int i=h;i<=h+1e6;i++)
		f[i-h]=q[i];
	while(m--){
		cin>>p;
		if(p>=s)cout<<p-s+a[1]-a[2]<<'\n';
		else cout<<f[p]+a[1]-a[2]<<'\n';
	}
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	if(N==M){
		for(int i=0;i<N;i++){
			cout << N;
		}
    }
	else if(N>M){
		for(int j=0;j<N;j++){
			cout << M;
		}
	}
	else{
		for(int k=0;k<M;k++){
			cout << N;
		}
	}
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = n;
        int d = 0;
        while (k != 0) {
            k /= 10;
            d++;
        }
        int ans = 0;
        int x = 1;
        for (int i = 0; i < d - 1; i++) {
            if (i % 2 == 0) {
                ans += 9 * x;
            }
            x *= 10;
        }
        if (d % 2 == 0) {
            System.out.println(ans);
        } else {
            ans += n - x + 1;
            System.out.println(ans);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22484
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;

double w[2][44];
double s[44];
int r;
int n;
int x1,x2,h;
double nkr;
double a[3];

main(){
  while(cin >> r >> n,r||n){
    nkr=-1;
    for(int i=0;i<2;i++)for(int j=0;j<44;j++) w[i][j]=0;

    for(int i=0;i<n;i++){
      cin >> x1 >> x2 >> h;

      if(w[0][x2+20]<h || w[0][x2+20]==0) w[0][x2+20]=h;
      if(w[1][x1+20]<h || w[1][x1+20]==0) w[1][x1+20]=h;
      for(int j=x1+21;j<x2+20;j++){
	if(w[0][j]<h || w[0][j]==0) w[0][j]=h;
	if(w[1][j]<h || w[1][j]==0) w[1][j]=h;
      }

    }
    
    nkr=w[1][20-r]+r;
    for(int i=r*(-1)+1;i<r;i++){
      s[i+20]=sqrt(r*r-i*i)-r;
      if(w[0][i+20]-s[i+20]<nkr) nkr=w[0][i+20]-s[i+20];
      if(w[1][i+20]-s[i+20]<nkr) nkr=w[1][i+20]-s[i+20];
    }
    if(w[0][20+r]+r<nkr) nkr=w[0][20+r]+r;

    

    printf("%.4f\n",nkr);
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>

int main() {
  using namespace std;
  string str;
  cin >> str;
  int p = 0;
  for(int i = 0; i < 3; i++) {
    if(str[i] == 'o') {
      p++;
    }
  }
  cout << 700 + 100 * p << endl;
  return 0;
}  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
 
int main() {
	int N,M;
	cin >> N >> M;
	ll a,b,c;
	vector<ll> ta[8]; //taを8個 (8)じゃダメ
	vector<int> x={ 1, 1, 1, 1,-1,-1,-1,-1};
	vector<int> y={ 1,-1, 1,-1, 1,-1, 1,-1};
	vector<int> z={ 1, 1,-1,-1, 1, 1,-1,-1};
	REP(i,N){
		cin >> a >> b >> c;
		REP(j,8) ta[j].push_back(a*x[j]+b*y[j]+c*z[j]);
	}
	REP(i,8) sort(ta[i].begin(), ta[i].end());
	ll ans=0,mac=0;
	REP(i,8){
		REP(j,M){
			ans+=ta[i][N-j-1];
		}
		mac=max(mac,ans);
		ans=0;
	}
	cout << mac << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        if(n>=3200){
            cout<<s<<endl;
        }
        else{
            cout<<"red"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    int a=N/1000,b=(N/100)%10,c=(N/10)%10,d=N%10;

    if (b == c){
	if ((a == b) || (d == b)){
	    cout << "Yes" << endl;
	    return 0;
	}
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int S=stdIn.nextInt();
		int A[]=new int[N];
		for(int i=0;i<N;i++){
			if(i<K)
				A[i]=S;
			else
				if(S==1000000000)
					A[i]=999999999;
				else
					A[i]=1000000000;
			System.out.println(A[i]);
		}
	}
}


Measured memory_bytes: 42932
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const int INF_INT = 1 << 25;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
const int loose = 0;
const int tight = 1;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n, m;
	cin >> n >> m;
	Array s(n), t(m);
	REP(i, n) cin >> s[i];
	REP(i, m) cin >> t[i];
	
	Matrix dp(n + 1, Array(m + 1, 0));
	Matrix sum(n + 1, Array(m + 1, 0));

	REP(i, n) {
		REP(j, m) {
			if (s[i] == t[j]) (dp[i + 1][j + 1] = sum[i][j] + 1) %= MOD;
			(sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] + MOD - sum[i][j] + dp[i + 1][j + 1]) %= MOD;
		}
	}
	cout << (sum[n][m] + 1) % MOD << endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 62976
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int M;
    cin >> M;
    cout << (24 - M) + 24 << endl;

    return 0;

}

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

int main() {
    ll n,a,b;
    cin >> a >> b;
    ll ans = 0;
    for(ll i = a;i<=b;i++){
        string s = to_string(i);
        string l = s;
        reverse(ALL(s)); 
        if(s==l) ans++;
    }
    cout << ans << endl;
    
}

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

int A[50];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A+N);
  int sum = 0;
  for (int i = 0; i < N-1; i++) sum += A[i];
  cout << ( A[N-1] < sum ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, K);
    CINS(ll, V, N);

    int minNK = min(N, K);
    int ans = 0;

    for (int i = 0; i <= minNK; i++) {
        for (int j = 0; j <= i; j++) {
            vector<int> V2(i);
            for (int k = 0; k < j; k++) {
                V2[k] = -1 * V[k];
            }
            for (int k = 0; k < i-j; k++) {
                V2[j+k] = -1 * V[N-1-k];
            }
            sort(V2.begin(), V2.end());

            int temp = 0;
            for (int k = 0; k < i; k++) {
                if ( V2[k] > 0 && k >= i-(K-i) ) {
                    break;
                }
                temp += V2[k];
            }
            ans = max(ans, -1 * temp);
        }
    }

    cout << ans << "\n";
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long a = l[0], b = l[1], c = l[2];

            if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Min(a * b, b * c), a * c));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> q(n);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        p--;

        q[p] = i;
    }

    ll r = 0;
    set<int> st;
    for (int j = n - 1; j >= 0; j--) {
        int i = q[j];
        auto i0 = st.lower_bound(i), i1 = i0;

        int x[4];
        x[1] = i0 == st.begin() ? -1 : *--i0;
        x[0] = i0 == st.begin() ? -1 : *--i0;
        x[2] = i1 == st.end() ? n : *i1++;
        x[3] = i1 == st.end() ? n : *i1;

        r += (ll)j * (x[1] - x[0]) * (x[2] - i);
        r += (ll)j * (x[3] - x[2]) * (i - x[1]);

        st.insert(i);
    }

    r += (ll)n * (n - 1) / 2;
    cout << r << endl;

    return 0;
}

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

signed main(){
    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    tx-=sx;ty-=sy;
    sx=sy=0;
    string ans;
    rep(i,ty)ans.push_back('U');
    rep(i,tx)ans.push_back('R');
    rep(i,ty)ans.push_back('D');
    rep(i,tx)ans.push_back('L');
    ans.push_back('L');
    rep(i,ty+1)ans.push_back('U');
    rep(i,tx+1)ans.push_back('R');
    ans.push_back('D');
    ans.push_back('R');
    rep(i,ty+1)ans.push_back('D');
    rep(i,tx+1)ans.push_back('L');
    ans.push_back('U');
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    if 1 <= A <= 9 and 1 <= B <= 9:
        return A * B
    return -1

def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62572
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define sort(p) sort(p.begin(),p.end())
#define rsort(p) sort(p.rbegin(),p.rend())
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 998244353;
const ll N = 1e5 + 7;
const ld pi = 3.14159265358979; 

void solve() {
    char ch;
    cin>>ch;
    if(ch>='a' && ch<='z') cout<<"a";
    else cout<<"A";
    return ;
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3648
x,y=[int(_) for _ in input().split()]

def a():
  if y<x:
    return 10000000000
  return y-x
def ba():
  if -x>y:
    return 10000000000
  return y+x+1

def ab():
  if x>-y:
    return 100000000000
  return -x-y+1
def bab():
  if x<y:
    return 10000000000
  return x-y+2
ans=min(a(),ba(),bab(),ab())
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    private static void print(int a, int b, int c, int d, int i, int j, int k) {
        StringJoiner sj = new StringJoiner("");
        sj.add(String.valueOf(a));
        if (i == 0) {
            sj.add("+");
        } else {
            sj.add("-");
        }
        sj.add(String.valueOf(b));
        if (j == 0) {
            sj.add("+");
        } else {
            sj.add("-");
        }
        sj.add(String.valueOf(c));
        if (k == 0) {
            sj.add("+");
        } else {
            sj.add("-");
        }
        sj.add(String.valueOf(d));
        sj.add("=7");
        System.out.println(sj.toString());
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");
        int a = Integer.parseInt(n[0]);
        int b = Integer.parseInt(n[1]);
        int c = Integer.parseInt(n[2]);
        int d = Integer.parseInt(n[3]);

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    int sum = 0;
                    if (i == 0) {
                        sum = a + b;
                    } else {
                        sum = a - b;
                    }
                    if (j == 0) {
                        sum += c;
                    } else {
                        sum -= c;
                    }
                    if (k == 0) {
                        sum += d;
                    } else {
                        sum -= d;
                    }
                    if (sum == 7) {
                        print(a, b, c, d, i, j, k);
                        return;

                    }
                }
            }
        }
    }

}


Measured memory_bytes: 23892
class Bits:
    def __init__(self):
        self.bits = 0
        self.mask = 2**64 - 1

    def test(self,k):
        return self.bits & (1<<k) != 0

    def set(self, k):
        self.bits |= 1<<k

    def clear(self, k):
        self.bits &= ~(1<<k) & self.mask

    def flip(self, k):
        if self.test(k):
            self.clear(k)
        else:
            self.set(k)

    def all(self):
        return self.bits == self.mask

    def any(self):
        return self.bits != 0

    def none(self):
        return self.bits == 0

    def count(self):
        c = 0
        for i in range(64):
            if self.test(i):
                c += 1
        return(c)

    def val(self):
        return(self.bits)

    def __str__(self):
        return format(self.bits, "064b")

n = int(input())
b = Bits()

for _ in range(n):
    c, k = [int(x) for x in (input() + " 0").split()][:2]
    #print(c, k)

    if  c == 0:
        if b.test(k):
            print(1)
        else:
            print(0)
    elif c == 1:
        b.set(k)
    elif c == 2:
        b.clear(k)
    elif c == 3:
        b.flip(k)
    elif c == 4:
        if b.all():
            print(1)
        else:
            print(0)
    elif c == 5:
        if b.any():
            print(1)
        else:
            print(0)
    elif c == 6:
        if b.none():
            print(1)
        else:
            print(0)
    elif c == 7:
        print( b.count())
    else:
        print( b.val() )

    #print( b )



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("数字统计.in","r",stdin);
    //freopen("数字统计.out","w",stdout);
    int n,m;
    cin>>n>>m;
    string a[101];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<a[i];
    }
    return 0;
}

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

s="0"
def dfs(s):
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(c) >0 for c in "753") else 0
    for c in "753":
        ret += dfs(s+c)
    return ret

print(dfs("0"))

Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        ReaderC.init(System.in);
        int n = ReaderC.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i < a.length; i++) a[i] = ReaderC.nextInt();
        int[] next = new int[a.length];
        int[] cancelled = new int[a.length];
        int sum = 0;

        for (int i = 1; i < a.length; i++) {
            next[i] = Math.abs(a[i] - a[i - 1]);
            sum += next[i];
            cancelled[i] = Math.abs((i + 1 < a.length ? a[i + 1] : 0) - a[i - 1]);
        }

        next[0] = Math.abs(a[a.length - 1]);
        sum += next[0];

        for (int i = 1; i < a.length; i++) {
            int ans = sum + cancelled[i] - (i < a.length - 1 ? next[i + 1] : next[0]) - next[i];
            System.out.println(ans);
        }
    }
}

/**
 * Reader class based on the article at "https://www.cpe.ku.ac.th/~jim/java-io.html"
 */
class ReaderC {
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    //    Get a whole line.
    static String line() throws IOException {
        return reader.readLine();
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}



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

namespace _0055
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string gh = Console.ReadLine();
                if (gh == null) { break; }
               double a = double.Parse(gh);
                double ans = a;
                for (int i = 2; i <= 10; i++)
                {
                    if (i % 2 == 0)
                    {
                        a *= 2;
                   
                    }
                    else
                    {
                        a =(double)a/3;

                    }ans += a;
                }
                Console.WriteLine(ans);
            }
        }
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	string S;
	while(cin>>S){
		auto SS=split_naive(S,',');
		vector<int> C(5);
		map<int,int> M;
		REP(i,5){
			sscanf(SS[i].c_str(),"%d",&C[i]);
			M[C[i]]++;
		}
		sort(ALL(C));
		
		int two=0,three=0,four=0;
		for(auto& x:M){
			if(x.second==2) two++;
			else if(x.second==3) three++;
			else if(x.second==4) four++;
		}
		if(four){
			out("four card");
		}
		else if(three){
			if(two){
				out("full house");
			}
			else{
				out("three card");
			}
		}
		else if(two){
			if(two==2){
				out("two pair");
			}
			else{
				out("one pair");
			}
		}
		else{
			bool straight = true;
			if(C[0]==1){
				if(C[1]==2 || C[1]==10){
					for(int i=1;i<4;i++){
						if(C[i+1]!=C[i]+1){
							straight = false;
							break;
						}
					}
				}
				else{
					straight = false;
				}
			}
			else{
				REP(i,4){
					if(C[i+1]!=C[i]+1){
						straight = false;
						break;
					}
				}
			}
			if(straight){
				out("straight");
			}
			else{
				out("null");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3196
X, N = map(int, input("").split(" "))
p = list(map(int,input().split()))
p.sort()
q = [i+1 for i in range(-2*X,2*X)]

ans = 0
diff = 100

for i in q:
    if (abs(X - i) < diff and (not i in p)):
        ans = i
        diff = abs(X-i)
print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  ull a, b, x, ans = 0;
  cin>>a>>b>>x;

  ans = b/x-(a-1)/x;
  if (!a) ans = b/x+1;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
n = int(input())
result = ''
for j in range(1, n + 1):
    i = j
    if i % 3 == 0:
        result += f' {i}'
    elif i % 10 == 3:
        result += f' {i}'
    else:
        while True:
            i = i // 10
            if i == 0:
                break
            elif i % 10 == 3:
                result += f' {j}'
                break
print(result)



Measured memory_bytes: 5640
from operator import itemgetter

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

def multisort(target_list, specs):
    for key, reverse in reversed(specs):
        target_list.sort(key=key, reverse=reverse)
    return target_list

temp_list = multisort(temp_list, ((itemgetter(1), False), (itemgetter(2), True)))

for i in range(n):
    print(temp_list[i][0])

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] cards = new int[3][N];
		int[] score = new int[N];
		for(int i = 0; i < N; i++) for(int j = 0; j < 3; j++) {
			cards[j][i] = sc.nextInt();
		}
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					if(j !=k && cards[i][j] == cards[i][k]) break;
					else if(k == N-1) score[j] += cards[i][j];
				}
			}
		}
		for(int i = 0; i < N; i++) System.out.println(score[i]);
	}
}

Measured memory_bytes: 20820
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 400100;

int n, v, p;
long long m, a[N];
vector <long long> c;

bool check(int mid) {
	c.clear();
	int cnt = 0;
	long long x = a[mid] + m;
	long long v2 = v;
	for (int i = 0; i < n; i++) {
		if (i == mid) {
			v2--;
			continue;
		}
		if (a[i] > x) {
			v2--;
			cnt++;
			continue;
		}
		if (x - a[i] >= m) {
			v2--;
			continue;
		}
		c.push_back(x - a[i]);
	}
	if (cnt >= p) {
		return false;
	}
	v2 -= (p - cnt - 1);
	if (v2 <= 0) {
		return true;
	}
	long long r = v2 * m;
	for (int i = p - cnt - 1; i < c.size() && i < c.size(); i++) {
		r -= c[i];
	}
	return r <= 0;
}

int main() {

	scanf("%d %lld %d %d", &n, &m, &v, &p);

	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	sort(a, a + n);
	reverse(a, a + n);

	int low = 0;
	int high = n - 1;

	while (low <= high) {
		int mid = (low + high) / 2;
		if (check(mid)) {
			low = mid + 1;
		} else {
			high = mid - 1;
		}
	}

	printf("%d\n", low);

	return 0;

}

Measured memory_bytes: 2168
use std::str::FromStr;
use std::fmt::Debug;
use std::io::stdin as S;

fn read_input<T>() -> Vec<T>
where T: FromStr,<T as FromStr>::Err: Debug {
    let mut input = String::new();
    S().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main(){
    let n: Vec<i32> = read_input();
    let n = n[0];
    let mut a: Vec<i64> = read_input();

    for (i,x) in a.iter_mut().enumerate(){
        *x -= i as i64 + 1;
    }
    a.sort();

    let b = a[(n as usize/2)];

    let ans: i64 = a.iter().fold(0,|sum,x| sum + (x-b).abs());
    println!("{}",ans);
}




Measured memory_bytes: 10492
int main(){
	int i = 0;
	int j = 0;
	int n = 0;
	char str[100000] = {};
	int sum = 0;
	
	scanf("%d",&n);
	scanf("%s",str);
	
	for(i = 0;i < n;i++){
		if(i == 0){
			sum = 1;
		}else{
			if(str[i - 1] != str[i]){
				sum++;
			}
		}
	}
	
	printf("%d",sum);

}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))

cnt=[0,0]#2,4の倍数の個数
for i in a:
    if i%4==0:
        cnt[1]+=1
    elif i%2==0:
        cnt[0]+=1

ans=n-cnt[0]-cnt[1]+1 if cnt[0]!=0 else n-cnt[1]
print('Yes' if ans<=cnt[1]+1 else 'No')

Measured memory_bytes: 14224
#include<iostream>
#include<string>
using namespace std;
const long long INF = 1000000007;
int main () {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string fi = "abcdefghijklmnopqrstuvwxyz";
  long long ans[26];
  for (int i = 0; i < 26; i ++) ans[i] = 1;
  for (int i = 0; i < N; i ++) {
    int j = 0;
    while(S[i] != fi[j]) j ++;
    ans[j] ++;
    //cout << j << ' ';
  }
  //cout << endl;
  long long jun = ans[0];
  //cout << ans[0] << endl;
  for (int i = 1; i < 26; i ++) {
    jun *= ans[i];
    jun = jun % INF;
    //cout << ans[i] << endl;
  }
  cout << jun - 1 << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
using LL = long long;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);

	map<int, int> v;
	int x, u;
	while (k--)
	{
		scanf("%d", &u);
		for (int i = 1; i <= u; ++i)
		{
			scanf("%d", &x);
			++v[x];
		}
	
	}
	LL res = 0;
	for (int i = 1; i <= n; ++i)
		if (v[i] == 0)
			++res;
	printf("%lld\n", res);
	
	return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += p[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#方針
#二つの0の間隔を測定する。ついでにその間の最小値も保持しておく。
n = gets.to_i
flw = gets.chomp.split(' ').map(&:to_i).push(0).unshift(0)
i = 0
min = 1
zero_flag = 1
count = 0
ans = 0
l = 0
while flw.sum != 0
  while i < flw.size
    if flw[i] == 0
      if zero_flag == 0#0でない数から0に移った場合。
        r = i - 1
        flw[l..r] = flw[l..r].map! {|num| num - min}
        ans += min
      end
      zero_flag = 1
    else
      if zero_flag == 1#直前が0だった場合
        min = 1
        l = i
      end
      if flw[i] < min
        min = flw[i]
      end
      zero_flag = 0
    end
    i += 1
  end
  i = 0
end
puts ans

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

int main() {
int x, y;
while(true) {
cin >> x >> y;
if(x == 0 && y == 0) {
break;
}
if(x>y) {
cout << y << " " << x << endl;
}
else {
cout << x << " " << y << endl;
}
}
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const int MAX = 510000;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];
//階乗の計算
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i%MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//係数計算
long long COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
	long long N, K; cin >> N >> K;
	COMinit();
	for (int i = 1; i <= K; i++) {
		cout << COM(N - K + 1, i)*COM(K - 1, i - 1)%MOD << endl;
	}
}





Measured memory_bytes: 12160
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "c");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();

    long ok = a.reduce!(max), ng = -1;
    while (abs(ok - ng) > 1)
    {
        long cntCut(long len)
        {
            return len > 0 ? a.map!(x => (x + len - 1) / len - 1).sum() : INF;
        }

        auto mid = (ok + ng) / 2;
        // writefln("mid = %s, counts = %s", mid, cntCut(mid));
        if (cntCut(mid) <= k)
            ok = mid;
        else
            ng = mid;
    }
    ok.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
        ios_base:: sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int a, b;
        cin >> a >> b;
        for(int i = 0; i < max(a, b); i++)
                cout << min(a, b);
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long n,k,ans;
    cin>>n>>k;
  	ans=n%k;
  	if(k==1)ans=0;
    else while(2*ans>k){
        ans=min(ans, abs(ans-k));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const N = Number(input.shift());
  const A = input.map(row => row.split(' ').map(str => Number(str)));
  let result = 0;

  for(let j = 0; j < N; j++){
      let count = 0;
      for(let k = 0 ; k <= j; k++){
          count += A[0][k];
      }
      for(let k = j ; k < N; k++){
          count += A[1][k];
      }
      if(result < count) result = count;
  }
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
package main

import (
	"fmt"
)

func main(){
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if y >= r && y <= h - r && x >= r && x <= w - r {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}	
}


Measured memory_bytes: 1180
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info_max{
	Info_max(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_max &arg) const{
			return point < arg.point;
	};
	int point,id;
};

struct Info_min{
	Info_min(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_min &arg) const{
			return point > arg.point;
	};
	int point,id;
};

 int main(){

	 int N,M,max_points[10001],point,num,tmp,forced_points[10001],maximum,minimum;
	 /*priority_queue<Info_max> MAX;
	 priority_queue<Info_min> MIN;*/
	 while(true){
		 scanf("%d %d",&N,&M);
		 if(N == 0 && M == 0)break;

		 for(int i = 1; i <= N; i++){
			 max_points[i] = 0;
			 forced_points[i] = 0;
		 }

		 for(int loop = 0; loop < M; loop++){
			 scanf("%d %d",&point,&num);
			 if(num == 1){
				 scanf("%d",&tmp);
				 forced_points[tmp] += point;
				 max_points[tmp] += point;
			 }else{ //num > 1
				 for(int i = 0; i < num; i++){
					 scanf("%d",&tmp);
					 max_points[tmp] += point;
				 }
			 }
		 }

		 /*while(!MAX.empty())MAX.pop();
		 while(!MIN.empty())MIN.pop();*/

		 priority_queue<Info_max> MAX;
		 priority_queue<Info_min> MIN;

		 for(int i = 1; i <= N; i++){
			 MAX.push(Info_max(max_points[i],i));
			 MIN.push(Info_min(forced_points[i],i));
		 }

		 if(MAX.top().id != MIN.top().id){
			 printf("%d\n",MAX.top().point-MIN.top().point+1);
		 }else{
			 maximum = MAX.top().point;
			 MAX.pop();
			 minimum = MIN.top().point;
			 MIN.pop();
			 printf("%d\n",max(maximum-MIN.top().point,MAX.top().point-minimum)+1);
		 }
	 }

	 return 0;
}

Measured memory_bytes: 2948