akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(String).chars().collect::<Vec<_>>();
    println!("{}", if n[0] == '9' || n[1] == '9' { "Yes" } else { "No" });
}

Measured memory_bytes: 2100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 100000;

int N, a[MAXN+5], uni[MAXN+5];
LL cnt, dp[2*MAXN+5];

bool check(int x) {
    int zero = N;
    LL res = 0, sum = 0;
    fill(dp, dp + 2 * N + 1, 0);
    for (int i = 0; i < N; i++) {
        dp[zero]++;
        if (a[i] <= x) {
            sum += dp[zero];
            zero--;
        }
        else {
            zero++;
            sum -= dp[zero];
        }
        res += sum;
    }
    return res >= cnt / 2 + 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin >> N;
    cnt = (LL)N * (N - 1) / 2 + N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        uni[i] = a[i];
    }

    sort(uni, uni + N);
    int M = unique(uni, uni + N) - uni, l = 0, r = M - 1, ans = -1;
    while (l <= r) {
        int m = (l + r) >> 1;
        if (check(uni[m])) {
            ans = m;
            r = m - 1;
        }
        else {
            l = m + 1;
        }
    }

    cout << uni[ans] << '\n';
}


Measured memory_bytes: 2560
import math
from itertools import permutations

cache = {}

def distance(p1, p2):
    dist = cache.get((p1, p2))
    if dist is not None:
        return dist
    x1, y1 = p1
    x2, y2 = p2
    dist = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    cache[(p1, p2)] = dist
    return dist

n = int(input())
t = []

for _ in range(n):
    x, y = map(int, input().split())
    t.append((x, y))

count = 0
total_dist = 0
for p in permutations(t, len(t)):
    count += 1
    dist = 0
    for i in range(len(t) - 1):
        dist += distance(p[i], p[i + 1])
    total_dist += dist

print(total_dist / count)




Measured memory_bytes: 3064
N=int(input())
L=list(map(int,input().split()))
L.sort()
P=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i]+L[j]>L[k] and len(set([L[i],L[j],L[k]]))==3:
        P+=1
print(P)


Measured memory_bytes: 68148
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int N,K;
	cin >> N >> K;
	int ans = K;

	REP(i, N - 1)ans *= (K - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

vector<int> v[100005];
int dp[100005];
int dfs(int z){
	int &ans=dp[z];
	if(ans!=-1)return ans;
	// ans=0;
	for(int x:v[z]){
		ans=max(ans,dfs(x));
	}
	ans++;
	return ans;
}
void solve(){
	mem1(dp);
	int n,m;
	cin>>n>>m;
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	int ans=0;
	rep(i,1,n+1){
		ans=max(ans,dfs(i));
	}
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main() {
	int h,w;
//	scanf("%d %d",&h,&w);
	cin>>h>>w;
	char str[1001][1001]= {'\0'};
	int i,j;
	fflush(stdin);
	for(i=1; i<=h; i++) {
		for(j=1; j<=w; j++) {
//			scanf("%c",str[i][j]);
			cin>>str[i][j];
		}

	}
//	for(i=1; i<=h; i++) {
//		gets(str[i]);
//	}
	for(i=1; i<=h; i++) {
		for(j=1; j<=w; j++) {
			printf("%c",str[i][j]);
		}
//		printf("%s",str[i]);
		printf("\n");
		for(j=1; j<=w; j++) {
			printf("%c",str[i][j]);
		}
//		printf("%s",str[i]);
		printf("\n");
	}
//	double temp;
//	for(i=1; i<=h; i++) {
//		gets(str[i]);
//	}
//	for(i=1; i<=h*2-1; i++) {
//		for(j=0; j<w; j++) {
//			temp=floor((i+1)/2);
//			int a=(int)temp;
//			printf("%c",str[a][j]);
//		}
//		printf("\n");
//	}
//	for(j=0; j<w; j++) {
//		temp=floor((i+1)/2);
//		int a=(int)temp;
//		printf("%c",str[a][j]);
//	}
}

Measured memory_bytes: 1280
n = int(input())
a = list(map(int, input().split()))
maxn = 1
ncont = 0
for i in a:
    if i == 1:
        ncont += 1
        if ncont+1 > maxn:
            maxn = ncont+1
    else:
        ncont = 0
print(maxn)
        


Measured memory_bytes: 5592
--     d = 0.(3)
--   10d = 3.(3)
--    9d = 3

--     d =    5.2(143)
-- 1000d = 5214.3(143)

ans l =
  let a = takeWhile (/= '(') l
      b = takeWhile (/= ')') $ drop 1 $ dropWhile (/= '(') l
      s = length b
      p = length $ drop 1 $ dropWhile (/= '.') a
      a'= read $ filter (/= '.') a
      b'= read $ filter (/= '.') (a++b)
      n = if a' == b'
          then a'
          else b' - a'
      d = if a' == b'
          then 10^p
          else 10^(s+p) - 10^p
      g = gcd n d
  in
    (n `div` g, d `div` g)

main = do
  l <- getLine
  let (n,d) = ans l
  putStrLn $ (show n)++"/"++(show d)

Measured memory_bytes: 3668
def main():
    x, y, z = map(int, input().split())
    x -= 2*z

    i, cnt = 0, 0
    while (1):
        if i%2 == 0:
            x -= y
            if x < 0:
                break
            cnt += 1
        else:
            x -= z
            if x < 0:
                break
        i += 1
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int w;
    int v;
} thing_t;

int sort(const void *a, const void *b){
    if ( ((thing_t*)a)->w - ((thing_t*)b)->w >0 ) {
        return 1;
    }
    if ( ((thing_t*)a)->w - ((thing_t*)b)->w <0 ) {
        return -1;
    }
    if ( ((thing_t*)a)->w - ((thing_t*)b)->w ==0 ) {
        if ( ((thing_t*)a)->v - ((thing_t*)b)->v >=0 ) {
            return -1;
        }
        if ( ((thing_t*)a)->v - ((thing_t*)b)->v <0 ) {
            return 1;
        }
    }
    return 0;
}

int main(void){
    int n,w,ans=0;
    scanf("%d%d",&n,&w);
    thing_t t[n];
    for (int i=0; i<n; i++){
        scanf("%d%d",&t[i].w,&t[i].v);
    }
    qsort (t,n,sizeof(thing_t),sort); 
    
    for (int i=0; i<=w/t[0].w; i++){
        for (int j=0; j<=(w-i*(t[0].w))/((t[0].w)+1); j++){
            for (int k=0; k<=(w-i*(t[0].w)-j*((t[0].w)+1))/((t[0].w)+2); k++){
                for (int l=0; l<=(w-i*(t[0].w)-j*((t[0].w)+1)-k*((t[0].w)+2))/((t[0].w)+3); l++){
                    
                    int tmp=0,tmpw=0,count1=0,count2=0,count3=0, count4=0;
                    for (int m=0; m<n; m++){
                        if (t[m].w==t[0].w && count1<i){
                            tmp+=t[m].v;
                            tmpw+=t[m].w;
                            count1++;
                        }
                        if (t[m].w==(t[0].w)+1 && count2<j){
                            tmp+=t[m].v;
                            tmpw+=t[m].w;
                            count2++;
                        }
                        if (t[m].w==(t[0].w)+2 && count3<k){
                            tmp+=t[m].v;
                            tmpw+=t[m].w;
                            count3++;
                        }
                        if (t[m].w==(t[0].w)+3 && count4<l){
                            tmp+=t[m].v;
                            tmpw+=t[m].w;
                            count4++;
                        }
                    }
                    if (tmpw<=w){
                        if (ans<tmp){
                            ans=tmp;
                        }
                    }
                    
                    
                }
            }
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
n = gets.strip.to_i

result = []

if n.zero?
  p 0
  exit
end

if n.odd?
  result.push 1
  n -= 1
else
  result.push 0
end

until n==1 || n==-1
  n = -1 * (n / 2)
  if n.odd?
    result.push(1)
  else
    result.push(0)
  end
#  p [n, result]
end

result.push(1) if n==-1

puts result.reverse.join('')



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(), greater<int>());
	int dif = 1e9 + 10;
	for(int i = 0; i <= n - k; i++) {
		dif = min(dif, h[i] - h[i + k - 1]);
	}
	cout << dif << endl;
	return 0;	
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int main() {
  int a, b, c, r = 0, e = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) == 3) {
    if (a*a + b*b == c*c) r++;
    if (a == b) e++;
  }
  printf("%d\n%d\n", r, e);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
    int K, N, A[200005], X;

    cin >> K >> N;
    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }

    int box1, box2;
    box1 = A[0] + (K - A[N - 1]);

    for(int i = 0; i < N - 1; i ++){
        box2 = A[i + 1] - A[i];
        if(box1 < box2)box1 = box2;
    }

    cout << K - box1 << endl;

    return 0;
}

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

const ll INF = 1LL << 60;

ll N, W;
vector<ll> w, v;

// i: 何個目
// j: 重さ
// = 価値
ll dp[110][(int)1e5 + 10];  

int main() {
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    rep(i, N) cin >> w[i] >> v[i];

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= W; j++) {
            // 選ばない
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j + w[i] > W) continue;
            // 選ぶ
            dp[i + 1][j + w[i]] = max(dp[i][j + w[i]], dp[i][j] + v[i]);
            // cout << i << " from: " << j << " to: " << j + w[i] << " " << dp[j + w[i]] << endl;
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 81716
A, B, C, D, E, F = map(int, input().split())

water_cand = []
for i in range(F):
    for j in range(F):
        tmp = 100 * A * i + 100 * B * j
        if tmp > F:
            break
        water_cand.append(tmp)

ws_cand = []
for x in water_cand:
    for i in range(F-x+1):
        for j in range(F-x+1):
            tmp = C * i + D * j
            if x + tmp > F:
                break
            if x + tmp == 0:
                ws_cand.append((x, tmp))
                continue
            if (tmp / (x+tmp)) <= (E / (100+E)):
                ws_cand.append((x, tmp))
if len(ws_cand) == 1 and ws_cand[0] == (0, 0):
    print(0, 0)
    exit()
ws_cand.remove((0, 0))
ans = max(ws_cand, key=lambda x: x[1] / (x[0]+x[1]))
print(ans[0]+ans[1], ans[1])

Measured memory_bytes: 63532
#include<cstdio>//AT2665
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

int n,a,b,c,d,delta,whole;

double nxt,half=0.5,maxhalf,lft;

int main(){
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    nxt+=c+d;
    nxt/=2;
    half=nxt-c;
    maxhalf=half*(n-1);
    delta=abs(a-b);
    if(delta>(n-1)*nxt+maxhalf){
        printf("NO\n");
        return 0;
    }
    whole=(int)(delta/nxt);
    lft=delta-nxt*whole;
    if(n&1){//n%2==1
        if(whole&1){
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    else{//n%2==0
        if(whole&1){
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class Dijkstra {
public:
  struct edge { ll v, dist; };

  struct state {
    ll v, cost;
    bool operator>(const state s) const { return cost > s.cost; }
  };

  const ll INF = (1LL << 60);
  ll N;
  vector< vector<edge> > E;

  Dijkstra(ll n): N(n), E(n) {}

  void add_directed_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
  }

  void add_undirected_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
    E[v].push_back((edge) { u, d });
  }

  vector<ll> shortest_path(ll S) {
    vector<ll> dp(E.size(), INF);
    priority_queue<state, vector<state>, greater<state> > q;
    q.push((state) { S, 0 });
    while(!q.empty()) {
      ll v = q.top().v, cost = q.top().cost;
      q.pop();
      if(dp[v] <= cost) continue;
      dp[v] = cost;
      REP(i, 0, E[v].size()) {
        ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
        if(dp[nv] > ncost) q.push((state) { nv, ncost });
      }
    }
    return dp;
  }
};

int main(void) {
  ll N, M, S, T;
  cin >> N >> M >> S >> T; S--; T--;
  Dijkstra dijkS(N);
  Dijkstra dijkT(N);
  REP(i, 0, M) {
    ll U, V, A, B; cin >> U >> V >> A >> B; U--; V--;
    dijkS.add_undirected_edge(U, V, A);
    dijkT.add_undirected_edge(U, V, B);
  }

  vector<ll> distS = dijkS.shortest_path(S);
  vector<ll> distT = dijkT.shortest_path(T);

  vector<ll> ans(N);
  ll x = 0;
  for(ll i = N - 1; i >= 0; i--) {
    x = max(x, 1000000000000000LL - (distS[i] + distT[i]));
    ans[i] = x;
  }
  REP(i, 0, N) cout << ans[i] << endl;
}

Measured memory_bytes: 19000
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
    	int ans=360/__gcd(360, n);
    	printf("%d\n",ans);
    }
  return 0;
}




Measured memory_bytes: 3760
#include <cstdio>
int main()
{
	int heap[250];

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

	int len = 1;
	int j = 0;
	int k = 0;
	while (k < n) {
		printf("node %d: key = %d, ", k + 1, heap[k]);
		int l = k - j - len / 2 + j / 2;
		if (l >= 0  && k != l)
			printf("parent key = %d, ", heap[l]);
		l = k + len + j;
		if (l < n)
			printf("left key = %d, ", heap[l]);
		l = k + len + j + 1;
		if (l < n)
			printf("right key = %d, ", heap[l]);			
		printf("\n");
		++k;
		++j;
		if (j >= len) {
			len *= 2;
			j = 0;
		}
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {

    int a,b,t;
    cin>>a>>b>>t;
    cout<<b*((int)(t+0.5)/a)<<endl;


    return 0;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var s = input[0];
  var N = parseInt(input[1]);
  var sList = new Array(s.length);
  var conv = "abcdefghijklmnopqrstuvwxyz".split("");
  var convList = {};
  for(var i = 0; i < conv.length; i++){
    convList[conv[i]] = i;
  }
  //Nの許す限り、左側の文字からaにしていく。s[i] + Nの一部 = 26(conv26番目)
  //ただしs[i]が0ならスルー
  //Nが不足してs[i]を0にできないなら次の文字へ
  //Nが少なくなってどの文字もs[i]を0にできないなら右端の文字だけNだけ進める
  //右端についた時点でNが余り過ぎてたら右端の文字だけ「Nの残り % 26」だけ進める
  for(var i = 0; i < s.length; i++){
  	sList[i] = convList[s.slice(i,i+1)];
  }
  for(var i = 0; i < s.length; i++){
    if(sList[i] == 0 && i != s.length - 1){
       continue;
    }
    if(i == s.length - 1){
       sList[i] = (sList[i] + N) % 26;
      continue;
    }
    if(N == 0){
       break;
    }else if(N < (26 - sList[i])){
      continue;
    }else{
      var add = 26 - sList[i];
      sList[i] = (sList[i] + add) % 26;
      N -= add;
    }
    //myout(sList[i]);
  }
  var output = "";
  for(var i = 0; i < s.length; i++){
    output += conv[sList[i]];
  }
  myout(output);
}

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


Measured memory_bytes: 16056
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cassert>
#include <queue>
#include <map>
using namespace std;
#define range(a) a.begin(),a.end()

int N, M, arr[305][305];
int No[305];
int solve() {
	int ret = N;
	for (int c = M; c;) {
		for (int j = 1; j <= M; ++j) {
			if (No[j] != -1) {
				No[j] = 0;
			}
		}
		for (int i = 1; i <= N; ++i) {
			for (int j = 1; j <= M; ++j) {
				if (No[arr[i][j]] != -1) {
					No[arr[i][j]]++;
					break;
				}
			}
		}
		int x = 0;
		for (int j = 1; j <= M; ++j) {
			if (No[j] != -1) x = max(x, No[j]);
		}
		ret = min(x, ret);
		for (int j = 1; j <= M; ++j) {
			if (No[j] == x) {
				No[j] = -1;
				c--;
			}
		}
	}
	return ret;
}
int main() {
	scanf("%d%d", &N, &M);
	for (register int i = 1; i <= N; ++i) {
		for (register int j = 1; j <= M; ++j) {
			scanf("%d", &arr[i][j]);
		}
	}
	printf("%d", solve());
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n,d;
LL x,y;
int cnt[1000][1000];
int counter[3][2001][2001];

LL nums(int sp,int x,int y,int z,int w){
  return counter[sp][z][w]+counter[sp][x][y]-counter[sp][x][w]-counter[sp][z][y];
}

bool test(LL len){
  LL a = len/d+1;
  int b = (int)(len%d)+1;
  
  LL mask[3] = {a*a,a*(a-1),(a-1)*(a-1)};
  REP(sp,3){
    REP(i,2*d){
      REP(j,2*d){
	if(cnt[i%d][j%d] > mask[sp])
	  counter[sp][i][j]=1;
	else
	  counter[sp][i][j]=0;
	if(i>0)counter[sp][i][j]+=counter[sp][i-1][j];
	if(j>0)counter[sp][i][j]+=counter[sp][i][j-1];
	if(i>0&&j>0)counter[sp][i][j]-=counter[sp][i-1][j-1];
      }
    }
  }
  /*
  REP(i,2*d){
    REP(j,2*d){
      cerr<<counter[1][i][j]<<" ";
    }
    cerr<<endl;
  }
  REP(i,2*d){
    REP(j,2*d){
      cerr<<counter[2][i][j]<<" ";
    }
    cerr<<endl;
  }
  */
  
  REP(i,d){
    REP(j,d){
      if(nums(0,i,j,i+b,j+b)>0)continue;
      if(nums(1,i+b,j,i+d,j+b)>0)continue;
      if(nums(1,i,j+b,i+b,j+d)>0)continue;
      if(nums(2,i+b,j+b,i+d,j+d)==0){
	return true;
      }
    }
  }
  return false;
}

int solve(){
  LL lb=1,ub=n*d;
  LL mid;
  while(lb<ub){
    mid = (lb+ub)/2;
    if(test(mid)){
      ub=mid;
    }else{
      lb=mid+1;
    }
  }
  return lb;
}

int main(){
  cin>>n>>d;
  REP(i,d){
    REP(j,d)
      cnt[i][j]=0;
  }
  REP(i,n){
    scanf("%d%d",&x,&y);
    cnt[x%d][y%d]+=1;
  }

  cout<<solve()<<endl;
  return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> count(n);
  int a,b;
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    count.at(a-1)++;
    count.at(b-1)++;
  }
  for(int i=0; i<n;i++) {
    cout << count.at(i) << endl;
  }
}

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

int main(void){
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m];
  //a入力開始
  for (int d=0; d<n; d++) {
    for (int e=0; e<m; e++) {
      cin >> a[d][e];
    }
  }
  //a入力終了
  //b入力開始
  for (int c=0; c<m; c++) {
    cin >> b[c];
  }
  //b入力終了
  //出力開始
  int t;
  for (int i=0; i<n; i++) {
    t = 0;
    for (int j=0; j<m; j++) {
      t += a[i][j] * b[j];
    }
    cout << t << endl;
  }
  //出力終了
}



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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    for(int i = a; i < b+1; i++){
        if(c % i == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    double co=0;
    for(int i=1;i<=a;i++){
        double c=1.0/a;
        int d=i;
        while(d<b){
            d*=2;
            c/=2;
        }
        co+=c;
    }
    printf("%.12f",co);
}


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

int main() {
  int n;
  cin >> n;
  
  vector<long long> a(3 * n);
  rep(i, 3 * n) cin >> a[i];

  sort(a.begin(), a.end(), greater<long long>());

  long long ans = 0;
  for (int i = 0; i < 2 * n - 1; i += 2) 
    ans += a[i + 1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
n, m = map(int, input().split())
C = sorted(tuple(map(int, input().split())))

dp = list(range(0, n+1))
for i in range(m):
    c = C[i]
    ndp = [50000] * (n+1)
    for j in range(n+1):
        if j < c:
            ndp[j] = dp[j]
        else:
            ndp[j] = min(dp[j], ndp[j-c] + 1)
    dp = ndp
print(ndp[-1])



Measured memory_bytes: 9416
N, M = map(int, input().split())
U = [[] for _ in range(N + 1)]

for _ in range(M):
    a, b = map(int, input().split())
    U[a].append(b)
    U[b].append(a)

for i in range(1, N + 1):
    print(len(U[i]))


Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-

s = input()
if len(s) == 0:
    print('No')
    exit()


for i, letter in enumerate(s):
    if i % 2 == 0:
        if letter != 'h':
            print('No')
            exit()
    elif i % 2 != 0:
        if letter != 'i':
            print('No')
            exit()

if len(s) % 2 == 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38256
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

res = a[0]
cnt = 0
i = 1
for _ in range(n-2):
    res += a[i]
    cnt += 1
    if cnt == 2:
        i += 1
        cnt = 0
print(res)

Measured memory_bytes: 94208
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class CTraveling
    {
        public static void Main(string[] args)
        {
            new CTraveling().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            // 初期状態をt[0], x[0], y[0]とすることで便利になります
            var t = new int[N + 1];
            var x = new int[N + 1];
            var y = new int[N + 1];
            y[0] = x[0] = y[0] = 0;
            for (int i = 1; i <= N; ++i)
            {
                t[i] = cin.ReadInt;
                x[i] = cin.ReadInt;
                y[i] = cin.ReadInt;
            }

            var flag = true;
            for (int i = 0; i < N; ++i)
            {
                var time = t[i + 1] - t[i];
                var dist = Abs(x[i + 1] - x[i]) + Abs(y[i + 1] - y[i]);
                if (time < dist) flag = false;
                if (Abs(time - dist) % 2 != 0) flag = false;
            }

            if (flag) WriteLine("Yes");
            else WriteLine("No");
        }
    }
}
public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}

Measured memory_bytes: 17424
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

  /* code */


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int l[n];
  for(int i=0;i<n;i++)
  {
    cin>>l[i];
  }
  int ctr=0;

  for(int i=1;i<n-1;i++)
  {
    vector<int> q;
    q.push_back(l[i-1]);q.push_back(l[i]);
    q.push_back(l[i+1]);
    sort(q.begin(),q.end());
    if(q[1]==l[i])
    {
      //cout<<l[i]<<'
      ctr++;
    }

    q.clear();
  }
  cout<<ctr<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define int ll

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

#define uniq(v) (v).erase(unique(ALL((v))), (v).end());

// area of (0, 0)(a, b)(c, d)
double area(double a, double b, double c, double d){
    return abs(a * d - b * c) / 2.0;
}

const int PREC = 10;
#define coutf(val) cout << fixed << setprecision(PREC) << (val) << endl;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make4(int, W, H, x, y);

    double ans_area = 1.0 * W * H / 2.0;
    cout << fixed << setprecision(PREC) << (ans_area);

    if (x * 2 == W && y * 2 == H) {
        cout << " 1" << endl;
    } else {
        cout << " 0" << endl;
    }
}


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    int B[N-1];
    rep(i, N-1) cin >> B[i];
    int C[N];
    for(int i = 0; i < N; i++){
        if(i == 0){
            C[0] = B[0];
            continue;
        }
        if(i == N-1){
            C[N-1] = B[N-2];
            break;
        }
        C[i] = min(B[i-1], B[i]);
    }
    int sum = 0;
    rep(i, N){
        sum += C[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int N,i,min,profit,temp;
    scanf("%d",&N);
    scanf("%d",&temp);
    scanf("%d",&profit);
    min=temp;
    if (min>profit) min=profit;
    profit-=temp;
    for (i=0; i<N-2; i++) {
        scanf("%d",&temp);
        if (temp-min>profit) profit=temp-min;
        if (temp<min) min=temp;
    }
    printf("%d\n",profit);
    return 0;
}

Measured memory_bytes: 596
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function root(uf::Array{Int,1},x);s=x;while uf[s]>0;s=uf[s];end;s;end
function same(uf::Array{Int,1},x,y);root(uf,x)==root(uf,y)?true:false;end
function unite(uf::Array{Int,1},x,y);l=root(uf,x);r=root(uf,y);if l<r;uf[l]+=uf[r];uf[r]=l;elseif l>r;uf[r]+=uf[l];uf[l]=r;end;end

function main()
	n,m = readline() |> split |> parseMap
	if m%2==1
		println(-1)
	else
	e = zeros(Int,2,m)
	for i in 1:m
		e[:,i] = readline() |> split |> parseMap
	end
	uf = -ones(Int,n)
	vst = zeros(Int,m)
	g = [Int[] for i in 1:n]
	for i in 1:m
		if !same(uf,e[1,i],e[2,i])
			unite(uf,e[1,i],e[2,i])
			push!(g[e[1,i]],e[2,i])
			push!(g[e[2,i]],e[1,i])
			vst[i]=1
		end
	end
	t = -ones(Int,n)
	stack = Int[1]
	t[1] = 0
	while !isempty(stack)
		now = shift!(stack)
		for i in 1:length(g[now])
			if t[g[now][i]]<0
				t[g[now][i]] = now
				push!(stack,g[now][i])
			end
		end
	end
	d = zeros(Int,n)
	for i in 1:m
		if vst[i]==0
			println(e[1,i], " ",e[2,i])
			d[e[1,i]] += 1
		end
	end
	vt = zeros(Int,n)
	for i in 2:n
		vt[t[i]] += 1
	end
	stack = Int[]
	for i in 1:n
		if vt[i] == 0
			push!(stack,i)
		end
	end
	while !isempty(stack)
		now = shift!(stack)
		if now != 1
			if d[now]%2==1
				println(now, " ",t[now])
				d[now] += 1
			else
				println(t[now], " ",now)
				d[t[now]] += 1
			end
			vt[t[now]] -= 1
			if vt[t[now]] == 0
				push!(stack, t[now])
			end
		end
	end
	end
end

main()

Measured memory_bytes: 225628
x1,y1,x2,y2=map(int,input().split())
ans=[]
for i in range(y2-y1):
  ans.append('U')
for i in range(x2-x1):
  ans.append('R')
for i in range(y2-y1):
  ans.append('D')
for i in range(x2-x1):
  ans.append('L')
ans.append('L')
for i in range(y2-y1+1):
  ans.append('U')
for i in range(x2-x1+1):
  ans.append('R')
ans.append('D')
ans.append('R')
for i in range(y2-y1+1):
  ans.append('D')
for i in range(x2-x1+1):
  ans.append('L')
ans.append('U')
print(''.join(ans))

Measured memory_bytes: 67532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;

ll dp[21][1<<22];

ll ways(vector<vector<ll>>&v,ll state,ll i){
	if(i==v.size())
		return 1;
		
	if(dp[i][state]==-1){
		ll ans=0;
		for(ll j=0;j<v.size();j++){
			if(v[i][j] && (state>>j)&1){
				state=state^(1<<j);
				ans=(ans+ways(v,state,i+1))%M;
				state=state^(1<<j);			
			}
		}	
		dp[i][state]= ans;
	}
	return dp[i][state];
}

int main(){
 ll n;
 cin>>n;
 vector<vector<ll>> v(n,vector<ll>(n));
 for(ll i=0;i<n;i++){
 	for(ll j=0;j<n;j++){
 		cin>>v[i][j];	
	}
 }
 memset(dp, -1, sizeof(dp));
 ll state=(1<<n)-1;
 cout<<ways(v,state,0)<<endl;
 return 0;
}

Measured memory_bytes: 691736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cmath>
#include<fstream>

int main(){
	std::string S;

	std::cin >> S;

	int m=stoi(S.substr(5,2));

	if(m<=4) std::cout << "Heisei" << std::endl;
	else std::cout << "TBD" << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int X, N;
    cin >> X >> N;
    vector<bool> used(111, false);
    rep(i, N){
        int p; cin >> p;
        used[p] = true; 
    }
    int ans = inf;
    rep(i, 111){
        if(!used[i]) chmin(ans, abs(X-i));
    }
    rep(i, 111){
        if(!used[i] && abs(X-i) == ans){
            cout << i << endl;
            break;
        }
    }
}

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

int main(){
   string s,a;
   cin >> s;
   int sum = 0;
   while(cin >> a){
       for (int i=0; i<a.size(); i++){
            if (a[i]<97){
                a[i]=a[i]+32;
            }
        }
        if (a == s){
            sum++;
       }
   }
   cout << sum << endl;
}


Measured memory_bytes: 3140
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int k = Integer.parseInt(temp[1]);
		int q = Integer.parseInt(temp[2]);

		int[] mList = new int[n];
		Arrays.fill(mList, k - q);

		for(int i = 0; i < q; i++) {

			int winner = Integer.parseInt(scanner.nextLine());

			mList[winner - 1]++;

		}

		for(int i = 0; i < n; i++) {

			if(mList[i] > 0) {

				System.out.println("Yes");

			}else {
				System.out.println("No");
			}
		}



	}

}


Measured memory_bytes: 96200
k, a, b = map(int, input().split())
if a+2 >= b:
	print(k+1)
else:
	if k <= a-1:
		print(k+1)
	elif (k-a-1)%2 == 0:
		print(a + (b-a) * ((k-a+1) // 2))
	else:
		print(a+1 + (b-a) * ((k-a) // 2))

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

const int MAX = 200000;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	
	int64_t sum = 0, ans = 0;
	for (int l = 0, r = 0;r < N;) {
		if ((sum ^ A[r]) == sum + A[r]) { // lからrまでの範囲で条件を満たす
			sum += A[r];
			r ++;
			if (r >= N) ans += ((int64_t)r - l) * (r - l + 1) / 2; // これが最後なら、そこまでの全ての可能性足しておく
		} else {
			ans += r - l; // lからr-1までは条件を満たしていたので
			sum -= A[l]; // 次はl+1からrまでを満たすか調べる
			l ++;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

A_iからA_jが条件を満たすならA_iからA_(j-1)も条件を満たす
また、A_iからA_jが条件を満たさないならどの部分集合も条件を満たさない
ということで、尺取り法
*/

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

using namespace std;
string s1, s2, s3;

int main()
{
	while (cin >> s1 >> s2 >> s3)
	{
		if (s1[s1.length() - 1] == s2[0] && s2[s2.length() - 1] == s3[0])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
//	system("pause");
	return 0;
}

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

int main() {
    int H,W;
    cin >> H >> W;
    string s[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cin >> s[i][j];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j] != "snuke") continue;
            cout << char(j + 'A') << i+1 << endl;
        }
    }

 }

Measured memory_bytes: 256
# 30分ぐらい？で溶けた！計算量は直感だよりだったが。
# → エラトステネスの篩 に相当する実装らしい。

# リスト内の倍数・約数関係を判定し、カウントする。
# 二重ループで判定するとTLEになるため、小さい値の可能な倍数を計算して保存するようにした。
# メモを set() ではなく 配列 で実装するテスト

n=int(input())
a=list(map(int,input().split()))
a.sort()

# 小さい側から処理する。a[i]について、10**6 以下のすべての倍数をset()として持つ。
# ただし、set内に存在しない==初出の約数のみ倍数計算をしてカウントする。
# 例えば、2,6,... となった場合、(6の倍数セットは2の倍数セットの下位集合となるため計算不要)

s=[False]*(10**6+1)
cnt=0
for i,aa in enumerate(a):
  if s[aa]:
    continue

  # 同値が複数ある場合、カウントしない。
  if i+1 == len(a) or aa != a[i+1]:
    cnt+=1
  for i in range(1,10**6+1):
    ma=aa*i
    if ma > 10**6:
      break
    s[ma]=True

print(cnt)
    


Measured memory_bytes: 32056
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		List<String> list=new ArrayList<String>();
		for(int i=0;i!=a;i++) {
			String str=scan.next();
			list.add(str);
		}
		Collections.sort(list);
		for(int i=0;i!=list.size();i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  int N, K, S;
  cin >> N >> K >> S;

  rep(i, K) {
    if (i) cout << " ";
    cout << S;
  }
  rep(i, N-K) {
    if (S == 1000000000)
      cout << " " << 1;
    else
      cout << " " << 1000000000;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll x,y;

int main() {
    cin >> x >> y;
    if(abs(x-y)<=1){
      put("Brown");
     }else{
       put("Alice");
     }
    return 0;
}


Measured memory_bytes: 256
p=10**9+7
N=int(input())
S=input()

d={}
alphabet_s=[chr(i) for i in range(97,97+26)]
for c in alphabet_s:
    d[c]=0

for c in S:
    d[c]+=1

ans=1
for c in alphabet_s:
    ans=(ans*(d[c]+1))%p

# 空文字列を引く
ans-=1

print(ans)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll n, a, b, r;
  ll ans = 0;
  cin >> n >> a >> b;
  r = n % (a + b);
  ans += n / (a + b) * a;
  if (r <= a)
    ans += r;
  else
    ans += a;
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    int64_t a, b, k;
    in >> a, b, k;

    if (a >= k) {
        out(a - k, b);
    } else if (a + b >= k) {
        out(0, b - (k - a));
    } else {
        out(0, 0);
    }
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n,i,j,s,t,m=0;
  static bool a[200010];
  static bool b[200010];

  cin>>n;
  for(i=1;i<=n;i++){
    cin>>a[i];
  }
  
  for(i=n;i>0;i--){
    t=n/i;
    s=0;
    for(j=1;j<t;j++){
      if(b[i+j*i])s++;
    }
    
    if(a[i]){
      if(s%2)b[i]=0;
      else b[i]=1,m++;
    }
    else{
      if(s%2)b[i]=1,m++;
      else b[i]=0;
    }
    
  }

  cout<<m<<endl;
  for(i=1;i<=n;i++){
    if(b[i])cout<<i<<endl;
  }

	return 0;
}

Measured memory_bytes: 1408