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

int main (){
  int N, X;
  cin >> N >> X;
  vector<int> L (N);

  for(auto &Li: L) cin >> Li;

  int bounces = 1;
  int currentCoordinate = 0;
  for(int i = 0; currentCoordinate + L[i] <= X && i < L.size(); i++) {
    currentCoordinate += L[i];
    bounces++;
  }

  cout << bounces << endl;
  return 0;
}

Measured memory_bytes: 256
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var cu500 = ToInt32(ReadLine());
        var cu100 = ToInt32(ReadLine());
        var cu50 = ToInt32(ReadLine());
        var price = ToInt32(ReadLine());
        var result = 0;
        for(var i = 0; i <= cu500; i++)
        {
            if (500 * i > price) break;
            for(var j = 0; j <= cu100; j++)
            {
                if (500 * i + 100 * j > price) break;
                var h = price - (500 * i + 100 * j);
                if (h / 50 <= cu50) result++;
            }
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 13268
#include <iostream>

bool evenNumber(int);

int main(){

    int a,b,c;
    int cnt=0;

    std::cin >> a >> b >> c;

    while(evenNumber(a) && evenNumber(b) && evenNumber(c)){
        cnt++;

        int _a = (b+c)/2;
        int _b = (a+c)/2;
        int _c = (a+b)/2;

        a=_a;b=_b;c=_c;

		//無限ループ防止
		if (cnt > 10000) { cnt = -1; break; }

    }

    std::cout << cnt ;

}

bool evenNumber(int _input) {
	if (_input % 2 == 0) {
		return true;
	}
	return false;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> even(100002, 0);
    vector<int> odd(100002, 0);
    REP(i, n)
    {
        cin >> v.at(i);
        if (i % 2 == 0)
            even.at(v.at(i))++;
        else
            odd.at(v.at(i))++;
    }

    vector<pair<int, int>> even_pair, odd_pair;
    FOR(i, 1, 100002)
    {
        even_pair.pb(make_pair(even.at(i), i));
        odd_pair.pb(make_pair(odd.at(i), i));
    }
    sort(even_pair.begin(), even_pair.end());
    reverse(even_pair.begin(), even_pair.end());
    sort(odd_pair.begin(), odd_pair.end());
    reverse(odd_pair.begin(), odd_pair.end());

    if (even_pair.at(0).second != odd_pair.at(0).second)
        cout << n - even_pair.at(0).first - odd_pair.at(0).first;
    else
        cout << n - max(even_pair.at(1).first + odd_pair.at(0).first, even_pair.at(0).first + odd_pair.at(1).first);
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}


// minimizq sum(v_i * x_i) subjetc to sum(w_i * x_i)<=W; where x_i>=0
int knapsack_unb(int n,vi &v,vi &w,int W) {
    vi dp(W+1,INF);
    dp[0]=0;
    for (int i=1; i<=W; ++i)
        for (int j=0; j<n; ++j) {
            if (w[j] <= i)
                dp[i] = min(dp[i], dp[i - w[j]] + v[j]);
            else{
                dp[i] = min(dp[i],v[j]);
            }
        }

    return dp[W];
}

int main() {
    READ(0);
    int h,n;cin>>h>>n;
    vi x(n),w(n);
    FOR(i,n) cin>>x[i]>>w[i];
    cout << knapsack_unb(n,w,x,h);

}



Measured memory_bytes: 256
n = int(input())
a,b,c = 1,1,1
for i in range(n):
  a *= 10
  b *= 9
  c *= 8
  a %= 10** 9 + 7
  b %= 10** 9 + 7
  c %= 10** 9 + 7
print((a - 2 * b +c)%(10** 9 + 7))

Measured memory_bytes: 9008
n = int(input()) + 1
s = '?' + input()
q = int(input())
k = list(map(int,input().split()))

p_d = []
cnt_m = [0]*n
cnt_c = [0]*n

for i,si in enumerate(s[1:],1):
    cnt_m[i] = cnt_m[i-1]
    cnt_c[i] = cnt_c[i-1]
    if(si=='D'):
        p_d.append(i)
    elif(si=='M'):
        cnt_m[i] += 1
    elif(si=='C'):
        cnt_c[i] += 1

left_c = [0]*n
for i in range(1,n):
    left_c[i] = left_c[i-1]
    if(s[i]=='M'):
        left_c[i] += cnt_c[i]

# print(cnt_m)
# print(cnt_c)
# print(left_c)

ans = []
for ki in k:
    tmp = 0
    for di in p_d:
        x = cnt_m[min(di+ki-1,n-1)] - cnt_m[di-1]
        y = cnt_c[min(di+ki-1,n-1)]
        tmp += x*y - left_c[min(di+ki-1,n-1)] + left_c[di-1]
    ans.append(tmp)

print('\n'.join(map(str,ans)))

Measured memory_bytes: 217132
#include <bits/stdc++.h>
using namespace std;
long long int n,dp[100002];
long long int h[100002];
long long int solve(long long int index)
{
    if(index==n-1)
    return 0;
    if(index==n-2)
    return abs(h[index]-h[n-1]);
    if(dp[index]!=-1)
    return dp[index];
    return dp[index]=min(solve(index+1)+abs(h[index+1]-h[index]),solve(index+2)+abs(h[index+2]-h[index]));
}
int main()
{
    long long int i,j,k,x,y,z;
    cin>>n;
    for(i=0;i<n;i++)cin>>h[i];
    for(i=0;i<=100000;i++)dp[i]=-1;
    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long L[86];
  L[0]=2;
  L[1]=1;
  if(N>1){
    for(int i=2;i<N+1;i++) L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s[1000000];
int a[1000000][3], score[1000000], cnt;
int n;
int main() {
	while (true) {
		cin >> n;
		if (!n) { break; }
		if (cnt) { cout << endl; }
		cnt++;
		for (int i = 0; i < n; i++) {
			cin >> s[i] >> a[i][0] >> a[i][1] >> a[i][2];
			score[i] = a[i][0] * 3 + a[i][2];
		}
		for (int j = 100000; j >= 0; j--) {
			for (int k = 0; k < n; k++) {
				if (score[k] == j) {
					cout << s[k] << ',' << score[k] << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 12356
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
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

sys.setrecursionlimit(10000)


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()


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


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def slv2(A, B, C, D):
    if A < B:
        return 'No'

    if D < B:
        return 'No'

    if C >= B:
        return 'Yes'

    g = gcd(B, D)
    if B - g + (A % g) > C:
        return 'No'

    return 'Yes'


@mt
def slv(T, Q):
    a = []
    for q in Q:
        a.append(slv2(*q))

    return '\n'.join(a)


def main():

    T = read_int()
    Q = [read_int_n() for _ in range(T)]
    print(slv(T, Q))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6084
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

long long ans[105];

long long gcd(long long a,long long b){
    if (a > b){
        long long temp = a;
        a = b;
        b = temp;
    }
    while(b%a!=0){
        long long temp = b%a;
        b = a;
        a = temp;
    }
    return a;

}

long long tic(long long a ,long long b){
    long long temp = gcd(a,b);
    long long result = temp*(a/temp)*(b/temp);
    return result;
}

int main(){
    int T;
    scanf("%d",&T);
    for(int i = 0;i < T;i++){
        scanf("%lld",&ans[i]);
    }
    sort(ans,ans+T);
    if (T==1){
        printf("%lld",ans[0]);
        return 0;
    }
    long long result = tic(ans[0],ans[1]);
    for (int i = 2; i < T;i++){
        result = tic(result,ans[i]);
    }
    printf("%lld",result);
    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
y = [int(input()) for i in range(n)]
y.sort()
c = 0
for i in range(n):
  if c < x:
    c +=y[i]
  elif c > x:
    print(i-1)
    exit()
d = sum(y)
print(((x-d)//y[0])+n)
  

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> v(h, "@");
  for (int i = 0; i < h; i++)
  {
    cin >> v[i];
  }

  for (int i = 0; i < h; i++)
  {
    bool flag = true;
    for (int j = 0; j < w; j++)
    {
      if(v[i][j] == '#') flag = false;
    }
    if(flag)
    {
      v.erase(v.begin() + i);
      i--;
      h--;
    }
  }

  for (int i = 0; i < w; i++)
  {
    bool flag = true;
    for (int j = 0; j < h; j++)
    {
      if(v[j][i] == '#') flag = false;
    }
    if(flag)
    {
      for (int j = 0; j < h; j++)
      {
        v[j].erase(v[j].begin() + i);
      }
      i--;
      w--;
    }
  }

  for (int i = 0; i < h; i++)
  {
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int [] h = new int [10000];
    int [] w = new int [10000];
    int m = 0;
    for(int i=0;;i++){
      int H = sc.nextInt();
      int W = sc.nextInt();
      h[i] = H;
      w[i] = W;
      if(H == 0 && W == 0) break;
      m++;
    }
    for(int l=0;l<m;l++){
      for(int j=0;j<h[l];j++){
        for(int k=0;k<w[l];k++){
          System.out.printf("#");
        }
        System.out.printf("\n");
      }
      System.out.printf("\n");
    }
  }
}



Measured memory_bytes: 59872
#include<bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mk make_pair 
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;
const int MAX_V = 201;

int main(){

	int n;
	cin>>n;
	set<string>s;
	for(int i=0;i<n;i++){
		string st;
		cin>>st;
		s.insert(st);
	}
	cout<<s.size()<<"\n";
	
}

Measured memory_bytes: 19148
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, ans = 0; cin >> n >> m;
	vector<int> h(n);
	vector<int> ok(n, 1);
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 0; i < m; i++)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		if(h[a] <= h[b]) ok[a] = 0;
		if(h[b] <= h[a]) ok[b] = 0;
	}
	for(int i = 0; i < n; i++) if(ok[i]) ans++;
	cout << ans;

	return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

void print(vector<ll> v) {
	for (ll i = 0; i < v.size(); i++)
	{
		cout << ' ' << v[i];
	}
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n), b, c;

	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (ll i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			b.push_back(a[i]);
		else
			c.push_back(a[i]);
	}

	if (n % 2 == 0) {
		reverse(c.begin(), c.end());
		cout << c[0];
		c.erase(c.begin());
		print(c);
		print(b);
	}
	else {
		reverse(b.begin(), b.end());
		cout << b[0];
		b.erase(b.begin());
		print(b);
		print(c);
	}
	cout << endl;
}

Measured memory_bytes: 6108
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

#include <math.h>
/*
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
ll M;

int main(){
    cin >> N >> M;
    int s[M];
    int c[M];
    int keta[N+10]={};
    int keta_max=0;

    bool flag;
    flag=true;
    rep(ni,11){
        keta[ni] =10;
    }
    rep(mi,M){
        cin >> s[mi];
        cin >> c[mi];
        if(keta[s[mi]]<10){
            if(keta[s[mi]]!=c[mi]){

                flag=false;
            }
        }else{
            keta[s[mi]]=c[mi];
            keta_max=max(keta_max,s[mi]);
        }
    }
    if(flag){
        if(keta[1]>0 || N==1){
            ll value=0;
            for( int ni = 1 ; ni <=N ; ni++ ){
                value=value*10;
                //cout << keta[ni] << endl;
                if(keta[ni]<10){
                    value+=keta[ni];
                }
            }
            if(N>1 && keta[1]==10){
                value = value + pow(10,N-1);
            }
            cout << value << endl;
        }else{
            cout << -1 << endl;
        }
    }else{
        cout << -1 << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

int cnt_str(string needle, string haystack)
{
    int cnt = 0;
    for (int i = 0; i + needle.size() <= haystack.size(); i++) {
        if (haystack.substr(i, needle.size()) == needle) {
            cnt++;
        }
    }

    return cnt;
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    int b_hoge_a_cnt = 0;
    int hoge_a_cnt = 0;
    int b_hoge_cnt = 0;

    int cnt = 0;
    string tmp;
    rep(i, n) {
        cin >> tmp;
        if (tmp[0] == 'B' && tmp[tmp.size() - 1] == 'A') {
            b_hoge_a_cnt++;
        } else if (tmp[0] == 'B') {
            b_hoge_cnt++;
        } else if (tmp[tmp.size() - 1] == 'A') {
            hoge_a_cnt++;
        }

        cnt += cnt_str("AB", tmp);
    }

    if (b_hoge_a_cnt > 0) {
        cnt += b_hoge_a_cnt - 1;
        if (b_hoge_cnt > 0) {
            cnt++;
            b_hoge_cnt--;
        }
        if (hoge_a_cnt > 0) {
            cnt++;
            hoge_a_cnt--;
        }
    }

    cnt += min(hoge_a_cnt, b_hoge_cnt);

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int h, w;
	static char[][] board;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		h = in.nextInt();
		w = in.nextInt();
		int sy = in.nextInt() - 1;
		int sx = in.nextInt() - 1;
		int ey = in.nextInt() - 1;
		int ex = in.nextInt() - 1;

		board = new char[w][h];
		for (int y = 0; y < h; y++) {
			String line = in.next();
			for (int x = 0; x < w; x++) {
				board[x][y] = line.charAt(x);
			}
		}

		ArrayDeque<Integer> xs = new ArrayDeque<Integer>();
		ArrayDeque<Integer> ys = new ArrayDeque<Integer>();
		int[][] dist = new int[w][h];
		for (int x = 0; x < w; x++) {
			Arrays.fill(dist[x], 1000000);
		}
		dist[sx][sy] = 0;
		
		xs.add(sx);
		ys.add(sy);

		int[] dirx0 = { -1, 1, 0, 0 };
		int[] diry0 = { 0, 0, -1, 1 };
		while (!xs.isEmpty()) {
			int cx = xs.remove(), cy = ys.remove();
			
			for (int i = 0; i < 4; i++) {
				int nx = cx + dirx0[i], ny = cy + diry0[i];
				if (!isLegal(nx, ny))
					continue;
				if (dist[nx][ny] > dist[cx][cy]) {
					dist[nx][ny] = dist[cx][cy];
					xs.addFirst(nx);
					ys.addFirst(ny);
				}
			}
			for (int dx = -2; dx <= 2; dx++) {
				for (int dy = -2; dy <= 2; dy++) {
					int nx = cx + dx, ny = cy + dy;
					if (!isLegal(nx, ny))
						continue;
					if (dist[nx][ny] > dist[cx][cy] + 1) {
						dist[nx][ny] = dist[cx][cy] + 1;
						xs.addLast(nx);
						ys.addLast(ny);
					}
				}
			}
		}
		System.out.println(dist[ex][ey] >= 1000000 ? -1 : dist[ex][ey]);
		in.close();
	}

	static boolean isLegal(int x, int y) {
		return x >= 0 && x < w && y >= 0 && y < h && board[x][y] == '.';
	}
}


Measured memory_bytes: 65284
d , g = map(int,input().split())
poi = [tuple(map(int,input().split())) for i in range(d)]
ans = 10**5
for i in range(2**d):
    cou = 0
    ten = 0
    for j in range(d):
        if i >> j & 1 == 1:
            cou += poi[j][0]
            ten += poi[j][1] + (j+1)*100*poi[j][0]
    for j in reversed(range(d)):
        if ten >= g:
            break
        if i >> j & 1 != 1:
            if g - ten > (j+1)*100*(poi[j][0]-1):
                cou += poi[j][0] - 1
                ten += (j+1)*100*(poi[j][0]-1)
            elif g - ten <= (j+1)*100*(poi[j][0]-1):
                cou -= (ten-g)//((j+1)*100)
                ten = g
                break
    if ten >= g:
        ans = min(ans,cou)
print(ans)

Measured memory_bytes: 73620
fun main() {
    var n = nextLong()
    println(buildString {
        while (n > 0) {
            append('a' + ((n - 1) % 26).toInt())
            if (n % 26 == 0L) {
                n -= 1
            }
            n /= 26
        }
    }.reversed())
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()

Measured memory_bytes: 37608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int K, T;
	int a;
	scanf("%d %d", &K, &T);
	int ans = 0;
	for(int i = 0; i < T; i++){
		scanf("%d", &a);
		ans += max(0, a - (K - a) - 1);
	}
	printf("%d\n", ans);
	return 0;
}


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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var points = new Tuple<double, double>[n];
            for (var i = 0; i < n; i++)
            {
                var xy = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
                points[i] = new Tuple<double, double>(xy[0], xy[1]);
            }
            var sum = 0.0;
            var all = (double)PermutationCount(n, n);
            foreach (var point in Permutation(points, points.Length))
            {
                for (var i = 0; i < point.Count() - 1; i++)
                {
                    var dx = point.ElementAt(i).Item1 - point.ElementAt(i + 1).Item1;
                    var dy = point.ElementAt(i).Item2 - point.ElementAt(i + 1).Item2;
                    sum += Math.Sqrt(dx * dx + dy * dy);
                }
            }
            Console.WriteLine(sum / all);
        }

        static long PermutationCount(int n, int k)
        {
            if (n < k) throw new ArgumentException();
            long result = n;
            for (var i = 1; i < k; i++)
                result *= (n - i);
            return result;
        }

        static IEnumerable<IEnumerable<T>> Permutation<T>(IEnumerable<T> items, int k)
        {
            if (k == 1)
            {
                foreach (var next in items)
                    yield return new T[] { next };
                yield break;
            }
            foreach (var item in items)
            {
                var fixedItems = new T[] { item };
                var exceptedItems = items.Except(fixedItems);
                foreach (var next in Permutation(exceptedItems, k - 1))
                    yield return fixedItems.Concat(next).ToArray();
            }
        }
    }
}


Measured memory_bytes: 21488
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int X;
  cin>>X;
  cout<<X*360/__gcd(X,360)/X<<endl;
 return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int x,a,b; cin>>x>>a>>b;
	x -= a;
	cout<<x%b<<endl;
	return 0;
}

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

using namespace std;

int main(){
  int n, k[110],p[110];
  cin >> n;

for(int i=0;i<n;i++) cin >> k[i] >> p[i];

for(int m=0;m<n;m++){
  if(k[m] % p[m] ==0){
    cout << p[m]<< endl;
    }else{
     cout << (k[m] % p[m]) << endl;
    }
  }
  return 0;
}




Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int sum[100010];
int main() {
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    for(int i=1;i<=n;++i){
        int k=i-1;
        if(k+1<n&&s[k]=='A'&&s[k+1]=='C'){
            sum[i]=1;
        }
        sum[i]+=sum[i-1];
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1]-(r<n&&s[r-1]=='A'&&s[r]=='C'?1:0))<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

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

	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	int L[n];
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i) {
		if (A[i] > L[length - 1]) {
			L[length++] = A[i];
		} else {
			int left = 0;
			int right = length;
			while (left < right) {
				int mid = (left + right) / 2;
				if (L[mid] >= A[i]) {
					right = mid;
				} else {
					left = mid + 1;
				}
			}
			L[right] = A[i];
		}
	}
	cout << length << endl;

	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll r,d,x; cin>>r>>d>>x;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  //cout<<<<endl;
  buf=x;
  for(i=0;i<10;i++){
    buf=buf*r-d;
    cout<<buf<<endl;
  }
  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int d,t,s;
    cin >> d >> t >> s;
    double time = (double)d/s;
    if(time > (double)t) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>

using namespace std;

int main(){
  int H,N,W,A,L,n;
  scanf ("%d%d%d",&H,&W,&N);
  if (H > W){
  L = H;
  }else{
  L = W;
  }
   
  if (N % L == 0){
  n = N / L;
  }
  else{
  n = N / L + 1;
  }
  
  printf("%d\n",n);
  return 0;
}
  
  

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

using namespace std;

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

    int cntM = 0;
    int ans = 1;
    for (int i = 1; i <= N; ++i) {
        int tmp = i, cnt = 0;
        while (tmp % 2 == 0) {
            tmp /= 2;
            cnt++;
        }
        if(cntM < cnt){
            cntM = cnt;
            ans = i;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,M,K;
        cin>>N>>M>>K;
        vector<ll> ar(N),br(M);
        cn(ar,N);cn(br,M);
        for(ll i=1;i<N;i++)
            ar[i]+=ar[i-1];
        for(ll i=1;i<M;i++)
            br[i]+=br[i-1];
        ll ans=lower_bound(all(br),K+1)-br.begin();
        for(ll i=0;i<N;i++){
            if(ar[i]>K)
                break;
            ll idx=lower_bound(all(br),K-ar[i])-br.begin();
            if(idx<M&&br[idx]==K-ar[i])
                idx++;
            ans=max(ans,i+1+idx);
        }   
        cout<<ans<<endl;
    }
}

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

using namespace std;

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

string s;
int mn[300][300];
int mx[300][300];

int MAX(int l, int r);
int MIN(int l, int r);


int MAX(int l, int r){
	if(mx[l][r]!=-INF) return mx[l][r];
	int &ret = mx[l][r];
	while(s[l] == '('){
		l++;
	}
	while(s[r] == ')'){
		r--;
	}
	if(l==r&&isdigit(s[l])){
		return ret = s[l]-'0';
	}
	if(s[l+1]==')') return ret;
	if(s[r-1]=='(') return ret;
	int lim = l-1;
	int cnt = 0;
	for(int i=r; i>=l; i--){
		cnt += isdigit(s[i]);
		if(cnt==2){
			lim = i;
			break;
		}
	}
	cnt = 0;
	reep(i,l,r+1){
		cnt += isdigit(s[i]);
		if(s[i]=='+'){
			// if(s[i-1]==')'&&cnt<2) continue;
			// if(s[i+1]=='('&&lim<i) continue;
			// if(l==i-2&&s[i-1]==')'&&isdigit(s[i-2])) continue;
			// if(i+2==r&&s[i+1]=='('&&isdigit(s[i+2])) continue;
			ret = max(ret, MAX(l,i-1)+MAX(i+1, r));
			if(l==3&&r==20){
				// cout<<ret<<" "<<MAX(l,i-1)<<" + "<<MIN(i+1, r)<<endl;
			}
		}
		if(s[i]=='-'){
			// if(s[i-1]==')'&&cnt<2) continue;
			// if(s[i+1]=='('&&lim<i) continue;
			// if(l==i-2&&s[i-1]==')'&&isdigit(s[i-2])) continue;
			// if(i+2==r&&s[i+1]=='('&&isdigit(s[i+2])) continue;
			ret = max(ret, MAX(l,i-1)-MIN(i+1, r));
			if(l==3&&r==20){
				// cout<<ret<<" "<<MAX(l,i-1)<<" - "<<MIN(i+1, r)<<endl;
			}
		}
	}
	// cout<<"MAX "<<s.substr(l,r-l+1)<<" "<<ret<<endl;
	return ret;
}

int MIN(int l, int r){
	if(mn[l][r]!=INF) return mn[l][r];
	int &ret = mn[l][r];
	while(s[l] == '('){
		l++;
	}
	while(s[r] == ')'){
		r--;
	}
	if(l==r&&isdigit(s[l])){
		return ret = s[l]-'0';
	}
	if(s[l+1]==')') return ret;
	if(s[r-1]=='(') return ret;
	int lim = l-1;
	int cnt = 0;
	for(int i=r; i>=l; i--){
		cnt += isdigit(s[i]);
		if(cnt==2){
			lim = i;
			break;
		}
	}
	cnt = 0;
	reep(i,l,r+1){
		cnt += isdigit(s[i]);
		if(s[i]=='+'){
			// if(s[i-1]==')'&&cnt<2) continue;
			// if(s[i+1]=='('&&lim<i) continue;
			// if(l==i-2&&s[i-1]==')'&&isdigit(s[i-2])) continue;
			// if(i+2==r&&s[i+1]=='('&&isdigit(s[i+2])) continue;
			ret = min(ret, MIN(l,i-1)+MIN(i+1, r));
			if(l==3&&r==18){
				// cout<<ret<<" "<<MIN(l,i-1)<<" + "<<MIN(i+1, r)<<endl;
			}
		}
		if(s[i]=='-'){
			// if(s[i-1]==')'&&cnt<2) continue;
			// if(s[i+1]=='('&&lim<i) continue;
			// if(l==i-2&&s[i-1]==')'&&isdigit(s[i-2])) continue;
			// if(i+2==r&&s[i+1]=='('&&isdigit(s[i+2])) continue;
			ret = min(ret, MIN(l,i-1)-MAX(i+1, r));
			if(l==3&&r==18){
				// cout<<ret<<" "<<MIN(l,i-1)<<" - "<<MAX(i+1, r)<<endl;
			}
		}
	}
	// cout<<"MIN "<<s.substr(l,r-l+1)<<" "<<ret<<endl;
	return ret;
}

int main(){
	cin>>s;
	rep(i,300){
		rep(j,300){
			mx[i][j] = -INF;
			mn[i][j] = INF;
		}
	}
	cout<<MAX(0,s.size()-1)<<endl;
}

Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
 
 
int main() {
	int n,s[105];
	int ans=0;
	int x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		ans+=s[i];
	}
	sort(s,s+n);
	/*for(int i=0;i<n;i++){
		cout<<s[i]<<endl;
	}*/
	//cout<<ans<<endl;
	x=ans;
	//cout<<x<<endl;
	if(ans%10==0){
		int i=0;
		while(true){
			//cout<<x-s[i]<<endl;
			if((x-s[i])%10!=0){
				x=x-s[i];
				break;
			}
			if(i==n-1){
				x=0;
				break;
			}
			i++;
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(void)
{
    int towns_count;
    vector<int> x_pos;
    vector<int> y_pos;

    cin >> towns_count;

    for(int i = 0; i < towns_count; i++){
        int x;
        int y;
        cin >> x >> y;
        x_pos.push_back(x);
        y_pos.push_back(y);
    }

    vector<int> indexes(towns_count);
    iota(indexes.begin(), indexes.end(), 0);
    double length_sum = 0;
    do{
        for(int dest = 1; dest < towns_count; dest++){
            long long double_x = pow(x_pos[indexes[dest]] - x_pos[indexes[dest - 1]], 2);
            long long double_y = pow(y_pos[indexes[dest]] - y_pos[indexes[dest - 1]], 2);
            length_sum += sqrt(double_x + double_y);
        }
    }while(next_permutation(indexes.begin(), indexes.end()));

    int divisor = 1;
    for(int i = 2; i <= towns_count; i++){
        divisor *= i; 
    }

    cout << setprecision(10) << length_sum / divisor << endl;

    return 0;
}

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

int main()
{
  // 入力
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> data(N);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    for (int j = 0; j < A; j++)
    {
      int x, y;
      cin >> x >> y;
      x--;
      data.at(i).push_back(make_pair(x, y));
    }
  }

  int M = 0;
  // 正直者の組み合わせを全探索
  // O((2^N)N^2)のアルゴリズム
  for (int i = 0; i < (1 << N); i++)
  {
    bool ok = true;
    for (int j = 0; j < N; j++)
    {
      if (!(i & (1 << j)))
      {
        continue;
      }
      for (int k = 0; k < data.at(j).size(); k++)
      {
        if (int(bool(i & (1 << data.at(j).at(k).first))) ^ data.at(j).at(k).second)
        {
          ok = false;
        }
      }
    }
    if (ok)
    {
      M = max(M, __builtin_popcount(i));
    }
  }
  cout << M << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    string S;
    cin >> S;
    int ans = 0;

    int l = 0, r = S.length() - 1;

    while (r - l >= 1)
    {
        if (S[r] == S[l])
        {
            r--;
            l++;
        }
        else if (S[r] == 'x')
        {
            ans++;
            r--;
        }
        else if (S[l] == 'x')
        {
            ans++;
            l++;
        }
        else
        {
            cout << -1 << endl;
            return;
        }
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N, M;
vector<ll> v(100010, 0);

int main(void){
	
	scanf("%d %d", &N, &M);
	
	v[0] = 1;
	for(int i = 1; i <= 100000; ++i) v[i] = (v[i - 1] * i) % MOD;
	
	if(abs(N - M) > 1) printf("0\n");
	else{
	    if(N == M) printf("%lld\n", (v[N] * v[M] * 2) % MOD);
	    else printf("%lld\n", (v[N] * v[M]) % MOD);
	}
	
    return 0;
}


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

long long int n, a, b;

void solve(){
    long long tot = a + b;
    if (tot <= 0){
        cout << "0\n";
        return;
    }
    long long ans = (n / tot) * a + min(n % tot, a);
    cout << ans << "\n";
    return;
}


int main(){
   	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n >> a >> b){
        solve();
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
  int L, R, d, count = 0;
  cin >> L >> R >> d;
  for (int i = L; i < R+1; i++){
    if (fmod(i,d) == 0){
      count += 1;
    }
  }
  cout << count << endl;
  return 0;
}

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

char s[100010];

int main(void) {
	int count = 0, j = 0, start = -1, end = -1;
	cin.tie(0);
	cin >> s;
	if (s[0] == s[1]) {
		start = 1;
		end = 2;
	} else {
		for (int i = 1; i < strlen(s)-1; i++) {
			if(s[i] == s[i+1]) {
				start = i+1;
				end = i + 2;
				break;
			} else if (s[i-1] == s[i+1] && s[i] != s[i+1]) {
				start = i;
				end = i+2;
				break;
			}
		}
	}

	cout << start << " " << end << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, T, c, t;
    cin >> N >> T;
    int ans = 100000;
    REP(i, N) {
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == 100000) cout << "TLE" << endl;
    else               cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int i,j,a,b,c,ans=0;

int main(){
	while(scanf("%d %d",&a,&b)!=EOF){
		c=a+b;
		while(c!=0)c=c/10,ans++;
		printf("%d\n",ans);ans=0;
	}

return 0;
} 

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        
        int N = Integer.parseInt(st.nextToken());
        int n=N;
        int L = Integer.parseInt(st.nextToken());
        String[] arr = new String[N];
        int k=0;
        while(N--!=0){
            arr[k++] = br.readLine();
        }
        Arrays.sort(arr);
        String ans="";
        for(int i=0; i<n; i++){
            ans+=arr[i];
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define LOOP(i,n) for(int i=0;i<(n);i++)

int main(void){
	int n, l;

	cin >> n >> l;

	int t = (n - 1) * n / 2 + l * n;
	int tn = l + n - 1;
	if (l <= 0){
		if (tn < 0){
			t -= tn;
		}
	}
	else{
		t -= l;
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 256
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(3)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    n, m, x = IO_for_Contest.read_n_int(3)
    a = IO_for_Contest.read_n_int(m)
    cost = [0] * (n + 1)
    for e in a:
        cost[e] = 1
    left = sum(cost[0:x])
    right = sum(cost[x:len(cost)])
    print(min(left, right))

if __name__ == '__main__':
    # doctest.testmod()
    solve()

Measured memory_bytes: 8168
#include<stdio.h>
int main(void)
{
	int a,b,i;
	
	scanf("%d%d",&a,&b);
	i=a+b;
	
	if(i%2==0){
		printf("\n%d\n\n",i/2);
	}else{
		printf("\n%d\n\n",(i+1)/2);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string a;
int ans;
int main()
{
	cin>>a;
	for(int i=1;i<a.length();i++)
		if(a[i]!=a[i-1])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

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

    char k;
    cin >> k;

    int i(k);
    i++;

    char result{ static_cast<char>(i) };
    cout << result;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#define black 1
#define white 0
#define gray -1

int d[101];
int f[101];
int color[101];
int adj[101][101];
int TIME=0;

void dfs(void);
void visit(int);
int n;

int main(){
  scanf("%d",&n);
  int i,j;
  int u,k,v;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
    }
  }

  dfs();

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}

void dfs(){
  int u;
  for(u=1;u<=n;u++){
    if(color[u]==white)
      visit(u);
  }
}

void visit(int u){
  int v;
  color[u]=gray;
  TIME++;
  d[u]=TIME;
  for(v=1;v<=n;v++){
    if(adj[u][v]==1){ 
    if(color[v]==white)
      visit(v);
    }
  }
  color[u]=black;
  f[u]=++TIME;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int M = sc.nextInt();
      int[] A = new int[M];
      for(int i = 0; i < M; i++){
        A[i] = sc.nextInt();
      }
      
      // 宿題日の合計を算出
      int homework = 0;
      for(int i = 0; i < M; i++){
        homework += A[i];
      }
      
      // 遊び日数の算出
      int play = -1;
      if(homework <= N){
        play = N - homework;
      }
      
      // 出力
      System.out.println(play);
    }
    
}

Measured memory_bytes: 46220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int K;
int A[100010];
ll mx;

bool check1(ll m) {
  for (int i = 0; i < K; i++) {
    m = (m/A[i])*A[i];
  }
  return m >= 2;
}

bool check2(ll m) {
  for (int i = 0; i < K; i++) {
    m = (m/A[i])*A[i];
  }
  return m <= 2;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> K;
  for (int i = 0; i < K; i++ ) {
    cin >> A[i];
    mx = max(mx, (ll)A[i]);
  }
  ll lb, ub;
  ll ok, ng;
  ng = 0, ok = 2+K*mx+1;
  while (ok-ng>1) {
    ll m = (ok+ng)/2;
    if (check1(m)) ok = m;
    else ng = m;
  }
  lb = ok;
  ok = 0, ng = 2+K*mx+1;
  while (ng-ok>1) {
    ll m = (ok+ng)/2;
    if (check2(m)) ok = m;
    else ng = m;
  }
  ub = ok;
  if (lb <= ub) cout << lb << " " << ub << endl;
  else cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
     
    using namespace std;
     
    using ll = long long;
     
    constexpr char endl('\n');
     
    #define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
    #define REP(i,n) FOR(i,0,n)
    #define INF 100000000000ULL
     
     
     
    int main()
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
        
        string s;
        cin >> s;
        bool l = false;
        REP(i, 3) {
            if (s.at(i) == '7') {
                l = true;
                break;
            }
        }
        if (l) {
            cout << "Yes" << ::endl;
        }
        else {
            cout << "No" << ::endl;
        }
     
        return 0;
    }

Measured memory_bytes: 3648
n = int(input())
total_live_in = [[[0 for _ in range(10) ] for _ in range(3)] for _ in range(4)]
for _ in range(n):
    b, f, r, v = map(int,input().split())
    total_live_in[b-1][f-1][r-1] += v

for i, block in enumerate(total_live_in):
    if i > 0:
        print("#" * 20)
    for floor in block:
        print(" " + " ".join(map(str,floor)))


Measured memory_bytes: 5612
#include <stdio.h>
#define SWAP(X,Y)(X^=Y,Y^=X,X^=Y)
void
ssort (int *array, int i, int j)
{
  int t;
  if (array[i] < array[j])
    SWAP (array[i], array[j]);
  if ((j - i + 1) >= 3)
    {
      t = (j - i + 1) / 3;

      ssort (array, i, j - t);
      ssort (array, i + t, j);
      ssort (array, i, j - t);
    }
}

int
main (void)
{
  int x[5];
  int i;
  scanf ("%d%d%d%d%d", x, x + 1, x + 2, x + 3, x + 4);
  ssort (x, 0, 4);
  for (i = 0; i <= 3; i++)
    printf ("%d ", x[i]);
  printf("%d\n",x[i]);
  return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vll sum(n+1);
    repr(i, n) sum[i] = (sum[i+1] + a[i]) % MOD;
    ll ans = 0;
    rep(i, n-1) ans = (ans + sum[i+1] * a[i] % MOD) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5616
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N,M int
	fmt.Scan(&N,&M)
	var A string
	if sc.Scan() {
        A = sc.Text()
	}
	var total int
	for _,i := range strings.Fields(A) {
		num,_ := strconv.Atoi(i)
		total += num
	}
	if N - total >= 0{
		fmt.Println(N - total)
	} else {
		fmt.Println(-1)
	}

}

Measured memory_bytes: 2164