akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    ll n,r;
    cin >> n >> r;
    ll ans;
    if(n<10) ans=r+100*(10-n);
    else ans=r;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool hw[50][50]={0};
int ch[50][50];
int H,W;
/*int solve(int x,int y,int co){
  int a=2501,b=2501,c=2501,d=2501;
  if(ch[x][y]<co){
  return 2501;
  }
  ch[x][y]=co;
  //  hw[x][y]++;
  if(x==H-1 && y==W-1){
  return co+1;
  }
  if(x>0&&hw[x-1][y]==0)a = solve(x-1,y,co+1);
    
  if(x<H-1&&hw[x+1][y]==0)b = solve(x+1,y,co+1);
  if(y>0&&hw[x][y-1]==0)c = solve(x,y-1,co+1);
  if(y<W-1&&hw[x][y+1]==0)d = solve(x,y+1,co+1);
  a = min(a,b);
  c = min(c,d);
  return min(a,c);
  }*/
int nsolve(int lx[],int ly[],int k,int co){
  int i,a[2500],b[2500],count=0;
  for(i=0;i<k;i++){
    if(lx[i]==H-1&&ly[i]==W-1)return co+1;
  }
  for(i=0;i<k;i++){
    if(lx[i]>0&&hw[lx[i]-1][ly[i]]==0){
      hw[lx[i]-1][ly[i]]++;
      a[count]=lx[i]-1;
      b[count]=ly[i];
      count++;
    }
    if(lx[i]<H-1&&hw[lx[i]+1][ly[i]]==0){
      hw[lx[i]+1][ly[i]]++;
      a[count]=lx[i]+1;
      b[count]=ly[i];
      count++;
    }
    if(ly[i]>0&&hw[lx[i]][ly[i]-1]==0){
      hw[lx[i]][ly[i]-1]++;
      a[count]=lx[i];
      b[count]=ly[i]-1;
      count++;
    }
    if(ly[i]<W-1&&hw[lx[i]][ly[i]+1]==0){
      hw[lx[i]][ly[i]+1]++;
      a[count]=lx[i];
      b[count]=ly[i]+1;
      count++;
    }
  }
  if(count==0)return 2501;
  //  for(i=0;i<count;i++)printf("%d,%d,%d,%d\n",a[i],b[i],count,co);
  return nsolve(a,b,count,co+1);
}
  

int main(){
  //count;black
  int i,j,count=0;
  int a[2500],v[1],u[1];
  int ans=2501;
  scanf("%d%d",&H,&W);
  for(i=0;i<H;i++){
    for(j=0;j<=W;j++){
      a[W*i+j] = getchar();
      if(a[W*i+j]=='#'&&j!=0) {
	hw[i][j-1]++;
	count++;
      }
    }
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      ch[i][j]=2501;
    }
  }
  v[0]=0;
  u[0]=0;
  if(hw[0][0]==0) ans = nsolve(v,u,1,0);
  if(ans == 2501)printf("-1\n");
  else printf("%d\n",H*W-count-ans);
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
L = list(map(int, input().split()))

OKs = 0
import itertools
for c in itertools.combinations(L, 3):
  if len(set(c))==3:
    c = sorted(list(c))
    c1, c2 = c[2], c[:2]
    if sum(c2) > c1:
      OKs += 1

print(OKs)

Measured memory_bytes: 9208
N, K = map(int,input().split())
As = list(map(int, input().split()))
P = 10**9 + 7

memo = [0]*N
tmp = [0]*(2002)
sm = [0]*(2002)

for i in range(N):
  for j in range(As[i]+1,2001):
    memo[i] += tmp[j]
  tmp[As[i]] += 1
  
for i in range(2000, 0, -1):
  sm[i] += sm[i+1] + tmp[i]
  
rlt = 0

for i in range(N):
  rlt += (K*(K-1)*sm[As[i]+1]//2 + K*memo[i]) % P
  rlt %= P
  
print(rlt)

Measured memory_bytes: 70188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, C; string S;
int dp[201010];
vector<int> pre[201010];
bool vis[201010];
vector<int> dpt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> C >> S;

	rep(i, 0, N + 1) dp[i] = -inf;
	dp[0] = 0;
	rep(i, 0, N) {
		if (chmax(dp[i + 1], dp[i])) pre[i + 1].clear();
		if (dp[i + 1] == dp[i]) pre[i + 1].push_back(i);

		if (S[i] == 'o') {
			if (chmax(dp[min(N, i + 1 + C)], dp[i] + 1)) pre[min(N, i + 1 + C)].clear();
			if (dp[min(N, i + 1 + C)] == dp[i] + 1) pre[min(N, i + 1 + C)].push_back(i);
		}
	}
	
	if (K < dp[N]) return;

	queue<int> que;

	vis[N] = true;
	que.push(N);

	while (!que.empty()) {
		int cu = que.front(); que.pop();
		fore(to, pre[cu]) {
			if (!vis[to]) {
				vis[to] = true;
				que.push(to);
			}

			if (dp[cu] == dp[to] + 1) {
				dpt[dp[to]].push_back(to + 1);
			}
		}
	}

	vector<int> ans;
	rep(i, 0, K) if (dpt[i].size() == 1) ans.push_back(dpt[i][0]);
	sort(all(ans));
	fore(a, ans) printf("%d\n", a);
}







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

using namespace std;
typedef pair<double, int> P;

int main(void) {
  vector<P> v[3], loser;
  for (int i = 0; i < 3; i++) {
    v[i].resize(8);
    for (int j = 0; j < 8; j++) {
      cin >> v[i][j].second >> v[i][j].first;
    }
    sort(v[i].begin(), v[i].end());

    for (int j = 0; j < 2; j++) {
      printf("%d %.2f\n", v[i][j].second, v[i][j].first);
    }

    for (int j = 2; j < 8; j++) {
      loser.push_back(v[i][j]);
    }
  }

  sort(loser.begin(), loser.end());

  for (int i = 0; i < 2; i++) {
    printf("%d %.2f\n", loser[i].second, loser[i].first);
  }

  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int X, A;
	cin >> X >> A;
	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int h,w; cin >> h >>w;
    char c[w];
    rep(i,h){
        rep(j,w){
            cin >> c[j];
            cout << c[j];
        }
        cout << "\n";
        rep(j,w){
            cout << c[j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
ans = 0
X = [0] * (N+2)
for i in range(N)[::-1]:
    if S[i:i+2] == "BC":
        X[i] = X[i+2] + 1
    elif S[i] == "A":
        X[i] = X[i+1]
        ans += X[i]
    else:
        X[i] = 0

print(ans)

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

int main()
{
    int l, m, n;

    while( cin >> l )
    {
        if( l == 0 )
            break;
        
        int sum = 0, cnt = 0;
        for( int i = 0; i < 12; i++ )
        {
            cin >> m >> n;
            
            if( l <= sum );
            else
            {
                sum += ( m - n );
                cnt++;
            }
        }
        if( cnt == 12 && sum < l )
            cout << "NA" << endl;
        else
            cout << cnt << endl;
    }

    return 0;
}


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

using namespace std;

#define AC return 0

typedef long long ll;

map<string, bool> dic;

int main() {
	int t;
	string od, ch;
	scanf("%d", &t);
	while (t--) {
		cin >> od >> ch;
		if (od[0] == 'i') dic[ch] = true;
		else {
			if (dic[ch]) printf("yes\n");
			else printf("no\n");
		}
	}
}


Measured memory_bytes: 52612
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);

    if(a<b)
    {
        printf("a < b\n");
    }
    if (a>b)
    {
        printf("a > b\n");
    }
    if(a==b)
    {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0; ll sum = 0;
    REP(i,n) {
        if (a[i] != 0) sum += a[i];
        else ans += sum/2, sum = 0;
    }
    ans += sum/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main() {
    string S;
    cin >> S;
    string s1 = S.substr(0, 2);
    string s2 = S.substr(2, 2);
    bool flag1 = false;
    bool flag2 = false;
    if(s1 > "00" && s1 <= "12") flag1 = true;
    if(s2 > "00" && s2 <= "12") flag2 = true;
    if(flag1 && flag2) cout << "AMBIGUOUS" << endl;
    else if(!flag1 && flag2) cout << "YYMM" << endl;
    else if(!flag1 && !flag2) cout << "NA" << endl;
    else cout << "MMYY" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define MAGIC cin.tie(NULL); ios_base::sync_with_stdio(false)
#define endl '\n'
//#define ll long long
#define mod (1000000007)
//#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
//#define MCONS 2001
//#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

int gcd(int a, int b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl
int dx[]{0, 1, 0, -1};
int dy[]{1, 0, -1, 0};

const int NCONS = 100001;
//const int MCONS = 101;

vector<Point> vec;
int N;
double acc;

double dist(Point a, Point b)
{
    auto temp = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
    return sqrt(temp);
}

void dfs(int step)
{
    if(step >= N)
    {
        double temp = 0;
        for(int i = 0; i < vec.size() - 1; i++)
        {
            temp += dist(vec[i], vec[i+1]);
        }
        acc += temp;
        return;
    }
    
    for(int i = step; i < N; i++)
    {
        swap(vec[step], vec[i]);
        dfs(step + 1);
        swap(vec[step], vec[i]);
    }
}

int32_t main()
{
 //   MAGIC;
    cin >> N;
    int cnt = 1;
    for(int i = 1; i <= N; i++) cnt *= i;
    for(int i = 0; i < N; i++)
    {
        int x, y; cin >> x >> y; vec.push_back(Point{x, y});
    }
    
    dfs(0);
    
    printf("%.9lf", acc / cnt);
    
    return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []B = new int[N];
		for(int i = 0; i < N; i++) {
			B[i] = scan.nextInt() - i - 1;
		}
		scan.close();
		if(N == 1) {
			System.out.println(0);
			System.exit(0);
		}
		Arrays.sort(B);
		long sum = 0;
		long min = 10000000000000000L;
		int k[] = {B[0] - 1,B[N/2], B[N/2 + 1],B[N - 1] + 1};
		for(int i = 0; i < 4; i++) {
			sum = 0;
			for(int j = 0; j < N; j++) {
				sum += abs(k[i], B[j]);
			}
			if(min > sum) {
				min = sum;
			}
		}
		System.out.println(min);

	}
	static int abs(int a, int b) {
		if(a > b) {
			return a - b;
		}else {
			return b - a;
		}
	}
}

Measured memory_bytes: 89056
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
int n;int a[210000];
signed main(){
  cin>>n;
  if(n % 2 == 1){
    cout << 0 << endl;return 0;
  }
  int m = n;
  int cnt5 = 0;m = n/2;
  while(m > 0){
    cnt5 += m/5;m /= 5;
  }
  cout << cnt5 << 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 num = sc.nextInt();

		// ???????????????
		int[][] bld = new int[15][10];

		// ?????????????????°??????????????????lft:?????????????????????rgt:?????????????????????
		int cnt;
		int lft;
		int rgt;

		for (cnt = 0; cnt < num; cnt++) {

			int rdg = sc.nextInt();
			int flr = sc.nextInt();
			int odr = sc.nextInt();
			int man = sc.nextInt();

			lft = (rdg - 1) * 4 + flr - 1;
			rgt = odr - 1;

			bld[lft][rgt] += man;

		}

		for (lft = 0; lft <= 14; lft++) {

			if (lft == 3 || lft == 7 || lft == 11) {

				System.out.println("####################");

			} else {

				for (rgt = 0; rgt <= 9; rgt++) {

					switch (rgt) {

					case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
						System.out.print(" " + bld[lft][rgt]);
						break;

					case 9:
						System.out.println(" " + bld[lft][rgt]);
						break;

					}
				}
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 29864
input_lines = []
while l = gets do
  input_lines << l.chomp
end

state = []
input_lines.each do |l|
  state << l.split('')
end

# nの人に対応する数字を返す
def c(n)
  if n == 'A'
    0
  elsif n == 'B'
    1
  else
    2
  end
end

# nの人が終わっているかを返す
def end?(state, n)
  i = c(n)
  return state[i].length.zero?
end

# 副作用あり。次の人を返す
def turn(state, n)
  i = c(n)
  trashed = state[i].delete_at(0)
  if trashed == 'a'
    return 'A'
  elsif trashed == 'b'
    return 'B'
  else
    return 'C'
  end
end

n = 'A'
loop do
  n = turn(state, n)
  break if end?(state, n)
end
puts n


Measured memory_bytes: 1788
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;ll t[n],d[n];
    vector<pair<ll,ll>> v;
    rep(i,n){
        cin>>t[i]>>d[i];
        v.push_back({d[i],t[i]});
    }



    sort(v.rbegin(),v.rend());
    ll sum=0;ll kind=0;
    ll ans=0;

    priority_queue<ll,vector<ll>,greater<ll>> q;

   set<ll> kk;
    vector<ll> c;
    rep(i,k){
        sum+=v[i].first;
        auto itr=kk.find(v[i].second);
        if(itr!=kk.end()){
            //c.push_back(v[i].first);
           // cout<<v[i].first<<endl;
            q.push(v[i].first);
        }else {
           // cout<<v[i].second<<endl;
            kk.insert(v[i].second);
        }
    }

    kind=(ll)kk.size();
    ans=sum+(kind*kind);

    for(int i=k;i<n;i++){
        ll t=v[i].second,d=v[i].first;
        auto itr=kk.find(t);
        if(itr!=kk.end()){//見つかった
        }else{//見つからない
            if(!q.empty()&&kk.size()<k) {
                kk.insert(t);
                ll h = q.top();
                q.pop();
                sum = sum - h;
                sum += d;
            }
        }

        ll x=ll(kk.size());
        ans=max(ans,sum+x*x);

    }



   cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(ll i=(a);i<=(b);i++)
#define repi(i,n) fori(i,0,(n)-1)
#define forr(i,a,b) for(ll i=(b);i>=(a);i--)
#define repr(i,n) forr(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
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;}

#define N 3000
double p[N];
double dp[N+1][N+1];
void solve(){
    ll n;cin>>n;
    repi(i,n)cin>>p[i];
    dp[0][0]=1;
    fori(i,1,n){
        fori(j,0,i){
            dp[i][j]=dp[i-1][j]*(1-p[i-1]);
            if(j>0)dp[i][j]+=dp[i-1][j-1]*p[i-1];
        }
    }
    double ans=0;
    repi(i,n+1){
        if(i*2>n)ans+=dp[n][i];
    }
    cout.precision(10);
    cout<<ans<<endl;
}

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


Measured memory_bytes: 68992
input = STDIN.read.split("\n")

N = input[0].to_i
A = input[1]
B = input[2]
C = input[3]

cnt = 0

for i in 0..(N - 1)
    a = A[i]
    b = B[i]
    c = C[i]
    if a == b && b == c && a == c
        next
    end

    if a != b && b != c && a != c
        cnt = cnt + 2
        next
    end
    cnt = cnt + 1
end

puts cnt

Measured memory_bytes: 1788
//03
#include<iostream>
#include<cctype>
#include<string>

using namespace std;

int main(){
  for(string s;getline(cin,s);){
    int r1=0,r2=0;
    char r3=0;
    for(int i=0;i<s.size();i++){
      char c=s[i];
      if(isdigit(c)){
	r2=r2*10+c-'0';
	if(r2>=10000){
	  cout<<'E';
	  break;
	}
      }else{
	if(r3==0){
	  r1=r2;
	}else if(r3=='+'){
	  r1+=r2;
	}else if(r3=='-'){
	  r1-=r2;
	}else{
	  r1*=r2;
	}
	r2=0;
	if(r1<0||r1>=10000){
	  cout<<'E';
	  break;
	}
	r3=c;
	if(c=='='){
	  cout<<r1;
	  break;
	}
      }
    }
    cout<<endl;
  }
  return 0;
}
	

Measured memory_bytes: 1176
package main

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

type Sl []string

var (
	N, L int
	s    Sl
)

func (sl Sl) Len() int {
	return len(sl)
}

func (sl Sl) Less(i, j int) bool {
	return sl[i] < sl[j]
}

func (sl Sl) Swap(i, j int) {
	sl[i], sl[j] = sl[j], sl[i]
}

func readVariables() {
	N, L = nextInt(), nextInt()
	s = make([]string, N)
	for i := 0; i < N; i++ {
		s[i] = nextStr()
	}
}

func main() {
	readVariables()
	sort.Sort(s)
	// fmt.Println(s)
	for i := 0; i < N; i++ {
		fmt.Print(s[i])
	}
	fmt.Println()
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f;
int dist[maxn];
int k;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>k;
  memset(dist, inf, sizeof dist);
  dist[1] = 1;
  deque<int> qq;
  qq.push_back(1);
  while (qq.size()) {
    int at = qq.front(); qq.pop_front();
    if (dist[(at*10)%k] > dist[at]) {
      dist[(at*10)%k] = dist[at];
      qq.push_front((at*10)%k);
    }
    if (dist[(at+1)%k] > dist[at]+1) {
      dist[(at+1)%k] = dist[at]+1;
      qq.push_back((at+1)%k);
    }
  }

  cout<<dist[0]<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

main(){
	int i,n,q,t;
	string name;
queue<pair<string,int>> Q;
	cin >> n>>q;
	for(i=0;i<n;i++){
	cin >> name>>t;
		Q.push(make_pair(name,t));
	}
	pair<string,int> ans;
	int at=0;
	while(!Q.empty()){
		ans=Q.front();
		Q.pop();
		at+=min(ans.second,q);
		if(ans.second>q){
		ans.second-=q;
			
			Q.push(ans);
		}
		else{
		
			cout << ans.first<<" "<<at<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 6296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = "Yes" ;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)!=S.charAt(S.length()-1-i)) {
				ans = "No";
			}
		}
		for(int i=0;i<(S.length()-1)/2;i++) {
			if(S.charAt(i)!=S.charAt((S.length()-1)/2-1-i)) {
				ans = "No";
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  ll F[N][10];
  rep(i,N) {
rep(j,10) {
cin >>F[i][j];
}
  }
  
  
  
  
  ll P[N][11];
  rep(i,N) {
rep(j,11) {
cin >>P[i][j];
}
  }
  
  
  ll ans=-INF;
  for (int bit = 1; bit < (1<<10); ++bit) {
  //ll bit=32;
    ll pro=0;
    vl vec(N);
    rep(i,N) {
vec.at(i)=0;
    }

    
 rep(i,10) {
if (bit & (1 << i)) {
  
  rep(k,N) {
    if(F[k][i]==1) {
      vec.at(k)++;
    }
  }
  //cout<<vec.at(1)<<"Ba"<<endl;
  
  
}
 }
  rep(m,N) {
    pro+= P[m][vec.at(m)];
  }
  
  
  

  //cout<<"A"<<pro<<"BB"<<bit<<endl;
  if(bit==1) {
    ans=pro;
    pro=0;
  }
    else {
    ans=max(ans,pro);
      pro=0;
    }
    
    
    if(ans==0) {
//cout<<99<<" "<<bit<<endl;
    }
    
    }//forisend
    
    
    cout<<ans<<endl;
    }
    
    
  
  
  
  

Measured memory_bytes: 256
function main() {
  input.forEach(function(str) {
    var
    num = str.split(' ').map(parseFloat);
    if(num.length !== 4 || str.indexOf('0 0 0 0') === 0) return;
    console.log(expr(num));
  });
}

var
op = ['+','-','*']
ex = ['(@%@)%(@%@)','@%(@%@)%@','@%@%@%@', '(@%(@%@))%@'];
function format(txt,a,b){
 var
 i,j = i = 0;
 return txt.replace(/@/g,function(){
  return a[i++];
 }).replace(/%/g,function(){
  return b[j++];
 });
}
function perm(xs) {
 var
 x, i, len = xs.length,
 ret = [];
 if(len === 0) return [[]];
 for(i = 0; i < len; i++){
  x = xs.shift();
  ret = ret.concat(perm(xs).map(function(ys){
   return (ys.unshift(x), ys);
  }));
  xs.push(x);
 }
 return ret;
}
function expr(src){
 var
 i,j,k,m,n,r;
 src = perm(src); 
 for(i = 0; i < 24; i++)for(j = 0; j < 3; j++)for(k = 0; k < 3; k++)for(m = 0; m < 3; m++)for(n = 0; n < 4; n++){
  r = format(ex[n],src[i],[op[j],op[k],op[m]]);
      if(eval(r) === 10) return r;
 }
 return 0;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 17984
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;

const int MAX_N=1e3+3;

int A[MAX_N][MAX_N];
int cnt[MAX_N];
set<int> used;
int main(){
	int n,m;
	cin>>n>>m;
	rep(i,n)rep(j,m)cin>>A[i][j];
	int ans=INF;
	rep(i,m){
		fill(cnt,cnt+MAX_N,0);
		int ma=0;
		int id=0;
		rep(j,n){
			rep(k,m){
				if(used.find(A[j][k])==used.end()){
					cnt[A[j][k]]++;
					if(ma<cnt[A[j][k]]){
						ma=cnt[A[j][k]];
						id=A[j][k];
					}
					break;
				}
			}
		}
		ans=min(ma,ans);
		used.insert(id);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1408
MOD=10**9+7

def com(n,k,mod):
    res=1
    tmp=1
    for i in range(1,k+1):
        res=res*(n-i+1)%mod
        tmp=tmp*i%mod
    a=pow(tmp,mod-2,mod)
    return res*a%mod

N,M,K=map(int,input().split())
C=com(N*M-2,K-2,MOD)

X,Y=0,0
for d in range(1,N):
    X=(X+((N-d)*M**2*d))%MOD
for d in range(1,M):
    Y=(Y+((M-d)*N**2*d))%MOD
print((X+Y)*C%MOD)

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

int main(){
    int N ,W;
    cin >> N >> W;
    int v[N+1],w[N+1],dp[N+1][W+1];
    
    for(int i=1 ; i <= N ; i++){
        cin >> v[i] >> w[i];
    }
    for(int i = 0; i <= W; i++){
        dp[0][i] = 0;
    }
    for (int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
    
}


Measured memory_bytes: 7032
#include<cstdio>
#include<vector>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=1e5+9;
int n,m,a[N],b[N],_[N],u,v,fa[N],t,d[N];
vector<int>e[N];
ll f[N],sz[N];
bool p[N];
ll min(ll x,ll y) {return x<y?x:y;}
ll max(ll x,ll y) {return x>y?x:y;}
bool cmp(int x,int y) {return a[x]<a[y];}
int gef(int x) {return fa[x]?fa[x]=gef(fa[x]):x;}
int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%d%d",a+i,b+i), a[_[i]=i]=max(a[i]-b[i],0), sz[i]=b[i];
	fo(i,1,m) scanf("%d%d",&u,&v), e[u].push_back(v), e[v].push_back(u);
	sort(_+1,_+n+1,cmp);
	fo(i,1,n)
	{
		int x=_[i]; p[x]=1,t=0;
		for(int y:e[x]) if(p[y]&&gef(x)!=gef(y)) {fa[v=gef(y)]=x; sz[x]+=sz[d[++t]=v];}
		f[x]=sz[x]+a[x];
		for(int y;y=d[t];t--) f[x]=min(f[x],sz[x]-sz[y]+max(a[x],f[y]));
	}
	printf("%lld",f[gef(1)]);
}

Measured memory_bytes: 12008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,sum;
	cin>>A>>B;
	if(A<=5)
	{
		sum=0;
	}
	else if(A>=6&&A<=12)
	{
		sum=B/2;
	}
	else if(A>=13)
	{
		sum=B;
		
	}
	cout<<sum<<endl;
	return 0;
}


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

// ll A, B, C;
// scanf("%ld %ld %ld", &A, &B, &C);
// printf("%ld %ld %ld", A, B, C);

int main()
{

    ll N, M, A[1000], count;
    double tmp, total;
    scanf("%ld %ld", &N, &M);
    total = 0;
    rep(i, N){
        scanf("%ld", &A[i]);
        total += A[i];
    };

    count = 0;

    tmp=total/(4*M);

    rep(i, N){
        if(A[i]>=tmp) {
            count = count+1;
        };
    };

    if(M<=count){
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 256
s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef deque<int> di;
typedef pair<int,int> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)
int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll n,sum=0;
    cin>>n;
    ll a[n];
    FOR(i,0,n)
    cin>>a[i];
    FOR(i,1,n)
    {
        if(a[i-1]>a[i])
        {
            sum+=abs(a[i-1]-a[i]);
            a[i]+=abs(a[i-1]-a[i]);
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 5120
n,k=map(int,input().split())
ans=[]
for i in range(n):
    ans.append(i+1)
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(len(a)):
        if a[j] in ans:
            ans.remove(a[j])
print(len(ans))


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

namespace Tasks
{
    public class D
    {
        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 NT = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, T) = (NT[0], NT[1]);
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var B = new int[N];
            var max = A[N - 1];
            var answer = 0;
            for (var i = N - 2; i >= 0; i--)
            {
                if (A[i] > max) max = A[i];
                B[i] = max;
            }

            var maxDiff = 0;
            for (var i = 0; i < A.Length - 1; i++)
            {
                var diff = B[i] - A[i];
                if (diff == maxDiff) answer++;
                else if (diff > maxDiff)
                {
                    maxDiff = diff;
                    answer = 1;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 38512
import heapq
n,m=map(int,input().split())
c=[[] for i in range(m+1)]
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        c[a].append(-b)
d=[]
heapq.heapify(d)
ans=0
for i in range(1,m+1):
    for j in range(len(c[i])):
        heapq.heappush(d,c[i][j])
    if d!=[]:
        ans+=heapq.heappop(d) 
print(-ans)   

Measured memory_bytes: 17604
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


bool solve() {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) {
        return false;
    }

    vector<ll> C(M), x(N + 1);

    rep(i, 0, M) cin >> C[i];
    rep(i, 1, N + 1) cin >> x[i];

    vector<vector<ll> > dp(N + 1, vector<ll>(256, INFl));
    dp[0][128] = 0;

    rep(i, 0, N) {
//            ll bef = dp[i + 1][j];
        rep(j, 0, M) {
            rep(k, 0, 256) {
//                dp[i + 1][k] = min(dp[i + 1][k], dp[i][k] + (ll) round(pow(x[i + 1] - k, 2)));
                ll nexk = max(0LL, min(k + C[j], 255LL));
                ll next = dp[i][k] + (ll) round(pow((nexk - x[i + 1]), 2));
                dp[i + 1][nexk] = min(dp[i + 1][nexk], next);
            }
        }
    }

    ll ans = INFl;
    rep(i, 0, 256) {
        ans = min(ans, dp[N][i]);
    }

    cout << ans << endl;


    return true;
}

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

    while (solve()) {

    }


    return 0;
}



Measured memory_bytes: 44008
N = int(input())
S = [input() for x in range(N)]
S.sort()

T = [[S[0]]]
for i in S[1:N]:
  if i == T[-1][-1]:
    T[-1].append(i)
  else:
    T.append([i])
T.sort(key=lambda x: len(x))
U = []

for i in T[::-1]:
  if len(i) == len(T[-1]):
    U.append(i[0])
  else:
    break

U.sort()
for x in U:
  print(x)


Measured memory_bytes: 42020
#include <bits/stdc++.h>
#define  f(i,n)             for(int i=0; i<(n); i++)
#define  ff(i,j,n)          for(int i=int(j);i<=int(n);++i)
#define  ps(x)              cout<<(#x)<<endl
#define  pb(x)              push_back(x);
#define  in(x)              int x; cin>>x
#define  lin(x)             ll x; cin>>x
#define  d(x)               cout<<x<<"\n"
#define  endl               "\n"
#define  newl               cout<<"\n"
#define  all(v)             (v).begin(), (v).end()
#define  vprint(vec)        for(int I=0;I<(vec).size();I++)cout<<vec[I]<<" ";cout<<endl
#define  deb(x)             cerr<<"\n"<<(#x)<<" is "<<(x)<<endl
//#define  cerr               if(0)cerr
typedef  long long          ll;
const int mod = 1000000007;

using namespace std;

void solve() {
    int n = 5;
    int a[n],ans;
    f(i,n) {
        cin>>a[i];
        if(!a[i]) ans = i+1;
    }

    d(ans);

}


int main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
        solve();
}


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

void solve() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i < N; ++i) {
        int j = N - i;
        if(i < j) ++ans;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int V[101][10001];
int v[101],w[101];
int main()
{
    int N,W;
    cin>>N>>W;
    
    for(int i=1;i<N+1;i++)
    {
        cin>>v[i]>>w[i];
    }
    
    for(int i=0;i<101;i++)
        V[i][0]=0;
    for(int i=0;i<10001;i++)
        V[0][i]=0;
    
    for(int i=1;i<N+1;i++)
    {
        for(int j=1;j<W+1;j++)
        {
            if(w[i]>j)
                V[i][j]=V[i-1][j];
            else
            {
                //V[i][j]=max(v[i]+V[i-1][j-w[i]],V[i-1][j]);
                V[i][j]=max(max(v[i]+V[i-1][j-w[i]],V[i-1][j]),v[i]+V[i][j-w[i]]);
            }

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

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

#pragma optimize("O3")

int V[5+(1<<18)];
int W[5+(1<<18)];

int dp[5+(1<<11)][100005];

const int INF = 1012345678;

int S, K;

int rec(int v, int L_rem, int bonus_value){
    if(L_rem < 0){
        return -INF;
    }else if(v < (1<<K)){
        return bonus_value + dp[v][L_rem];
    }

    return max(rec(v>>1, L_rem, bonus_value), rec(v>>1, L_rem-W[v], bonus_value+V[v]));
}


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

    for(int i = 1; i <= N; i ++){
        scanf("%d%d", &V[i], &W[i]);
    }

    int Q;
    scanf("%d", &Q);
    K = log2(N*32)/2;

    //printf("1<<K=%d\n", 1<<K);

    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= (1<<K); i ++){
        for(int j = 0; j <= 100000; j ++){
            int temp = dp[i>>1][j];
            if(j >= W[i]){
                temp = max(temp, V[i]+dp[i>>1][j-W[i]]);
            }
            dp[i][j] = temp;
        }
    }

    while(Q --){
        int v, L;
        scanf("%d%d", &v, &L);
        printf("%d\n", rec(v, L, 0));
    }

    return 0;
}


Measured memory_bytes: 807876
s=list(input())
maximum=0#黒字ならok.緑字になったりしたらint object is not callableが発生しかねない。
temp=0
k=0
for i in range(len(s)):
    sets=set(s[i])
    if sets.issubset(set("ATGC")):
        k=k+1
        if k>=maximum:
            maximum=k
    else:
        k=0
print(maximum)

Measured memory_bytes: 3060
a, b = map(int, input().split())

if a == 1 and b == 1:
    print("Draw")
    exit()
elif a == 1:
    print("Alice")
    exit()
elif b == 1:
    print("Bob")
    exit()

if a == b:
    print("Draw")
elif a > b:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 61752
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int field[1000][1000];
signed main(){
	int h,w,d;
	cin>>h>>w>>d;
	string st = "RYGB";
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int wa = i+j;
			int sa = i-j+w;
			if( ( wa % (2*d) ) >= d ) field[i][j] ++;
			if( ( sa % (2 * d)) >= d ) field[i][j] += 2;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<st[field[i][j]];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 4608
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; ++i){
			a[i] = scn.nextInt();
		}
      	int count = 1;
      	for(int i=0; i<a.length; ++i){
			if(a[i]==count) count++;
		}
      	int ans = n+1-count;
      	if(ans == n){
      		System.out.println("-1");
        }else{
          System.out.println(ans);
        }
	}
}


Measured memory_bytes: 60560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Integer> primes = prime(N);
        long answer = 1;
        for (int prime : primes) {
            int count = 0;
            for (int i = Math.max(2,prime); i <= N; i++) {
                int t = i;
                while (t % prime == 0) {
                    t /= prime;
                    count += 1;
                }
            }
            answer = answer * (count+1) % 1000000007;
        }
        System.out.println(answer);
    }
    public static List<Integer> prime(int N) {
        int limit = (int) Math.ceil(Math.sqrt(N));
        boolean[] d = new boolean[N+1];
        d[0] = false;
        d[1] = false;
        List<Integer> result = new ArrayList<>();
        for (int i = 2; i <= limit; i++) {
            if (d[i]) {
                continue;
            }
            result.add(i);
            d[i] = true;
            for (int j = 1; j * i <=  N; j++) {
                d[i * j] = true;
            }
        }
        for (int i = 2; i <= N; i++) {
            if (!d[i]) {
                result.add(i);
            }
        }
        return result;
    }
}


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

int main()
{
    size_t H, W;
    cin >> H >> W;

    vector<size_t> A(H);
    vector<size_t> B(H);
    for (size_t i = 0; i < H; i++)
    {
        cin >> A[i] >> B[i];
    }

    set<pair<size_t, size_t>> goal_start;
    set<pair<int, size_t>> ans;
    for (size_t i = 1; i <= W; i++)
    {
        goal_start.insert(make_pair(i, i));
        ans.insert(make_pair(0, i));
    }

    for (size_t i = 0; i < H; i++)
    {
        size_t start = 0;
        size_t right = 0;
        for (
            set<pair<size_t, size_t>>::iterator itr = goal_start.lower_bound(make_pair(A[i], 0));
            itr != goal_start.end() && itr->first <= B[i];
            itr = goal_start.erase(itr))
        {
            size_t goal = itr->first;
            start = itr->second;

            ans.erase(make_pair(goal - start, goal));
            right = max(right, start);
        }
        if (start > 0 && B[i] < W)
        {
            goal_start.insert(make_pair(B[i] + 1, right));
            ans.insert(make_pair(B[i] + 1 - right, B[i] + 1));
        }

        if (ans.empty())
        {
            cout << -1 << endl;
        }
        else
        {
            cout << i + 1 + ans.begin()->first << endl;
        }
    }
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int m = sc.nextInt();

        long ans = 0;
        for (int i = 1; i < n; i++) {
            ans += n - i;
        }

        for (int i = 1; i < m; i++) {
            ans += m - i;
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 20564
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
void push(int);
int pop(void);
 
/*?????¨?????°*/
int top,S[100];
 
int main()
{
  
  int top,x,y,z;
  char s[100];
 
 
  top=0;
  while(scanf("%s",s) != EOF){
 
    if(s[0] == '+'){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if(s[0] == '-'){
      y = pop();
      x = pop();
      push(x-y);
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }
    else{ 
      z = atoi(s);
      push(z);
    }
  }
 
  printf("%d\n",pop());
  return 0;
}
 
/*??°????????\??????*/
void push(int x)
{
  S[++top] = x;
}
/*??°??????????????????*/
int pop()
{
 
  top--;
 
  return S[top+1];
}

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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, t;
  cin >> a >> b >> t;
  vector <int> arr(t + 1, 0);
  for (int i = a; i <= t; i += a) arr[i] = 1;
  cout << b * count(all(arr), 1) << endl;
  return (0);
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = input()
    for i in range(len(n)):
        if n[i]=='9':
            print('Yes')
            return
    print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

// WARN : use H with larger N
/// --- Modulo Factorial {{{ ///
template < int N, int mod = (int) 1e9 + 7 >
struct Factorial {
  constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = 0;
    return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  constexpr ll modinv(ll a) {
    ll x = 0, y = 0;
    extgcd(a, mod, x, y);
    return (x + mod) % mod;
  }
  int arr[N + 1], inv[N + 1];
  ll operator[](int i) const { return arr[i]; }
#if !defined(DEBUG)
  constexpr
#endif
    Factorial()
    : arr(), inv() {
      arr[0] = 1;
      for(int i = 1; i <= N; i++) {
        arr[i] = (ll) i * arr[i - 1] % mod;
      }
      inv[N] = modinv(arr[N]);
      for(int i = N - 1; i >= 0; i--) {
        inv[i] = (ll)(i + 1) * inv[i + 1] % mod;
      }
    }
  ll C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (ll) arr[n] * inv[r] % mod * inv[n - r] % mod;
  }
  ll H(int n, int r) const { return C(n + r - 1, r); }
};
/// }}}--- ///

const int N = 30;
Factorial < N, mod > fact;

int h, w, k;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> h >> w >> k;
  
  vector<ll> x(w + 1); // x[i] := when there's i vertical-lines, how many ways to make pairs?
  // O(W^2)
  for(int i = 0; i <= w; i++) {
    for(int j = 0; j * 2 <= i; j++) { // make j pairs
      // C(i - j, j)
      x[i] += fact.C(i - j, j);
    }
    x[i] %= mod;
  }
  
  vector<ll> dp(w);
  dp[0] = 1;

  vector<ll> dp2(w);
  // O(WH)
  for(int i = 0; i < h; i++) {
    dp2.assign(w, 0);
    for(int a = 0; a < w; a++) { // before
      // no. of RIGHT-side free vertical-lines = w - 1 - a
      // no. of LEFT-side  free vertical-lines = a
      // after = a
      dp2[a] += dp[a] * x[w - 1 - a] % mod * x[a] % mod;
      // after = a - 1
      if(a - 1 >= 0) dp2[a-1] += dp[a] * x[w - 1 - a] % mod * x[a - 1] % mod;
      // after = a + 1
      if(a + 1 < w) dp2[a+1] += dp[a] * x[w - 1 - a - 1] % mod * x[a] % mod;
    }
    for(auto &e : dp2) e %= mod;
    swap(dp, dp2);
  }

  // dp[k-1]

  cout << dp[k-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256