akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAX = 300005;
bool isPrime[MAX];
vector<int> mt;
void makePrime(){
  for (int i = 6; i < MAX; i++){
    isPrime[i] = true;
  }
  for (int i = 2; i < MAX; i++){
    if(isPrime[i] && (i % 7 == 6 || i % 7 == 1)){
      mt.push_back(i);
      for (int j = 2 * i; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
  return;
}
int main()
{
  int n;
  makePrime();
  int len = mt.size();
  while(cin>>n,n!=1) {
    set<int> SET;
    for(int i = 0; i < len; i++) {
      if(n % mt[i] == 0) {
        SET.insert(mt[i]);
      }
    }
    cout << n << ":";
    for(auto s : SET) {
      cout << " " << s;
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> vvc;
  vvc=vector<vector<char>>(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>vvc.at(i).at(j);
    }
  }
  int j=0;
  for(int i=0;i<H;i++){
    do{cout<<vvc.at(i).at(j);
       j++;
    }while(j<W);
    j=0; cout<<endl;
     do{cout<<vvc.at(i).at(j);
       j++;
    }while(j<W);
    j=0; cout<<endl;
  }
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 345678;
int k, dist[123456];

int dijkstra()
{
    priority_queue<pii>q; //sum, rem
    memset( dist, 125, sizeof dist );
    for( int i = 1; i <= 9; i++ )
    {
        q.push( mp(-i,i) );
        dist[i] = i;
    }

    while( !q.empty() )
    {
        pii a = q.top();
        q.pop();
        int r = a.yy, s = dist[a.yy];
        //if( r == 0 ) return s;
        for( int i = 0; i < 10; i++ )
        {
            int tr = (r*10 + i)%k;
            if( dist[tr] > s + i )
            {
                dist[tr] = s+i;
                q.push( mp( -dist[tr], tr ) );
            }
        }
    }
    return dist[0];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    cin >> k;
    cout << dijkstra() << endl;
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ok=0;
    for (int i=0;i<N;++i){
        int a; cin >> a;
        ok|=(a&1);
    }
    cout << (ok?"first":"second") << '\n';
}

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

#define ll long long int
//#define PI acos(1.0)

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

ll ar[500009],br[500009],cr[500009];
map<ll,ll>mp,mp1;
vector<ll>v;
string s,d;

int main()
{
   // ll a,b,c,i,j,k,x,y,z,f,g,h;

    double q,r;

    cin>>q;

    r=(2.0*q*3.1416);

    cout<<fixed<<setprecision(6)<<r<<endl;
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int S[2040],T[2040];
    const int MEM=2040;
    int dp[MEM][MEM]={},sum[MEM][MEM]={};
    cin >> N >> M;
    REP(i,N){
        cin >> S[i];
    }
    REP(i,M){
        cin >> T[i];
    }
    REP(i,N){
        REP(j,M){
            if(i!=0){
                sum[i][j]+=sum[i-1][j];
                sum[i][j]%=MOD;
            }
            if(j!=0){
                sum[i][j]+=sum[i][j-1];
                sum[i][j]%=MOD;
            }
            if(i!=0 && j!=0){
                sum[i][j]-=sum[i-1][j-1];
                sum[i][j]+=MOD;
                sum[i][j]%=MOD;
            }
            dp[i][j]+=sum[i-1][j-1];
            dp[i][j]+=1;
            dp[i][j]%=MOD;
            if(S[i]!=T[j]){
                dp[i][j]=0;
            }
            sum[i][j]+=dp[i][j];
            sum[i][j]%=MOD;
        }
    }
    /*REP(i,N){
        REP(j,M){
            cout << dp[i][j] << " ";
        }cout << endl;
    }cout << endl;
    REP(i,N){
        REP(j,M){
            cout << sum[i][j] << " ";
        }cout << endl;
    }*/
    cout << (sum[N-1][M-1]+1)%MOD << endl;
    return 0;
}



Measured memory_bytes: 65280
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println( solve(N) );
    }

    private static long solve(int N) {
        // primes under 31
        int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
        Map<Integer, Integer> primeCounts = new HashMap<>();

        for (int n = 2; n <= N; n++) {
            int remain = n;
            for (int p : primes) {
                Result result = countFactor(remain, p);
                if( result.cnt > 0 ) {
                    incrementPrime(p, result.cnt, primeCounts);
                    remain = result.remain;
                }
            }

            if( remain != 1 ) {
                incrementPrime(remain, 1, primeCounts);
            }
        }

        // 各素数の組み合わせ
        long ans = 1;
        for (Integer cnt : primeCounts.values()) {
            ans = (ans * (cnt + 1)) % MOD;
        }
        return ans;
    }

    private static Result countFactor(int n, int f) {
        int cnt = 0;
        while(true) {
            if( n % f == 0 ) {
                n = n / f;
                cnt++;
            } else {
                break;
            }
        }
        return new Result(cnt, n);
    }

    private static void incrementPrime(int p, int cnt, Map<Integer, Integer> countPrimes) {
        if( countPrimes.containsKey(p) ) {
            countPrimes.put(p, countPrimes.get(p) + cnt);
        } else {
            countPrimes.put(p, cnt);
        }
    }

    private static class Result {
        private final int cnt;
        private final int remain;

        public Result(int cnt, int remain) {
            this.cnt = cnt;
            this.remain = remain;
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
const int maxn=205;
int n,m;
int a[maxn][maxn],sum[maxn][maxn];
int f[maxn][maxn][maxn][15];
inline bool ok(int l,int r,int u,int d)
{
	int s=sum[d][r]-sum[d][l-1]-sum[u-1][r]+sum[u-1][l-1];
	return (s==0)||(s==(d-u+1)*(r-l+1));
}
inline void init()
{
	for(int i=1;i<=n;++i)
		for(int l=1;l<=m;++l)
			for(int r=l;r<=m;++r)
			{
				int U=i-1,D=n,mid;
				while(U<D)
				{
					mid=(U+D+1)>>1;
					if(ok(l,r,i,mid))
						U=mid;
					else
						D=mid-1;
				}
				f[i][l][r][0]=U;
			}
}
inline void solve()
{
	int now=1;
	while(f[1][1][m][now-1]!=n)
	{
		for(int i=1;i<=n;++i)
			for(int l=1;l<=m;++l)
				for(int r=l;r<=m;++r)
				{
					if(f[i][l][r][now-1]==n)
					{
						f[i][l][r][now]=n;
						continue;
					}
					f[i][l][r][now]=f[f[i][l][r][now-1]+1][l][r][now-1];
					if(f[i][l][r][now]==n)
						continue;
					int g=0,last=-1;
					for(int mid=l;mid<=r-1;++mid)
					{
						int x=f[i][l][mid][now-1];
						int y=f[i][mid+1][r][now-1];
						g=max(g,min(x,y));
						if(g<last)
							break;
						last=g;
					}
/*					int pL=l,pR=r-1,mid,g=0;
					while(pL<=pR)
					{
						mid=(pL+pR)>>1;
						int x=f[i][l][mid][now-1];
						int y=f[i][mid+1][r][now-1];
						g=max(g,min(x,y));
						if(x<y)
							pR=mid-1;
						else
							pL=mid+1;
					}
					*/
					f[i][l][r][now]=max(f[i][l][r][now],g);
				}
		++now; 
	}
	cout<<now-1<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			char ch;
			cin>>ch;
			if(ch=='#')
				a[i][j]=1;
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j];
		}
	init();
	solve();
	return 0;
}


Measured memory_bytes: 314976
-- ABC107 B
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (h:w:_) <- fmap (map read . words) getLine :: IO [Int]
  am <- replicateM h getLine :: IO [[Char]]
  putStrLn . unlines $ solve h w am

solve :: Int -> Int -> [[Char]] -> [[Char]]
solve h w am = [[a!(i,j) | j <- IntSet.elems ws] | i <- IntSet.elems hs]
  where
    a :: Array (Int, Int) Char
    a = listArray ((1,1), (h, w)) $ join am
    (hs,ws) = foldr f (IntSet.empty, IntSet.empty) [(i,j) | i<-[1..h], j<-[1..w]]
    f (i,j) (x,y) = if a!(i,j) == '#'
                    then (IntSet.insert i x, IntSet.insert j y)
                    else (x, y)


Measured memory_bytes: 2556
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp=[float("inf")]*n
dp[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,abs(n-i))):
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[j+i]))
print(dp[-1])

Measured memory_bytes: 55136
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    int arr[t];
    for(int i=0; i<t; i++){
        cin>>arr[i];
    }
    int counter=0;
    for(int i=1; i<t-1; i++){
        if(arr[i]>min(arr[i-1], arr[i+1]) && arr[i]<max(arr[i-1], arr[i+1])) counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    while(n!=0)
    {
        if(n%10==7)
        {
            cout<<"Yes";
            return;
        }
        n/=10;
    }
    cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  vector<int> q(n);  
  
  rep(i,n){
  cin>>p[i];
  }
  rep(i,n){
  cin>>q[i]; 
  }
  
  auto r = p;
  sort(all(r));
  
  int a,b;
  int cnt=0;
  do{
  cnt++;
  bool pr=true;
  rep(i,n){
    if(p[i]!=r[i]) pr=false;
  }
  if(pr) a=cnt;
  
  bool qr=true;
  rep(i,n){
    if(q[i]!=r[i]) qr=false;
  }
  if(qr) b=cnt; 
    
  }while (np(all(r)));
  
  cout << abs(a-b) << endl;
  
}

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

int main() {
  	int k;
	cin >> k;
  	int total = 0;
  	for(int a=1;a<=k;a++) {
    	for (int b=1;b<=k;b++) {
        	for(int c=1;c<=k;c++) {
            	total += gcd(gcd(a, b),c);
            }
        }
    }
  	cout << total << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
ll MOD = 1'000'000'007;
int N,K;

ll solve(){

	vector<ll> cnt(N+2);

	rp(i, 0, (N+1)){
		cnt[i+1] += cnt[i] + i;
	}

	// puts("---");//
	// cout<<N<<" "<<K<<"\n";//
	// puts("---");//
	// rp(i,0,N+2){
	// 	cout<<i<<" "<<cnt[i]<<"\n";
	// }
	// puts("---");//

	ll ans = 0;

	rp(k, K, (N+1)+1){
		ll mn = 0;
		ll mx = 0;
		mn = cnt[k];
		mx = cnt[N+1] - cnt[N+1-k];
		// cout<<"N "<<N<<" k "<<k<<" mn "<<mn<<" mx "<<mx<<"\n";//

		ans += mx - mn + 1;
		ans %= MOD;

	}

	return ans;
}

int main(){
	cin>>N>>K;
	cout<< solve() <<endl;
}


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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int C=0;
  int D=0;
  int E=0;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin >> P[i];
    if(P[i]<=A){
      C++;
    }
    else if(P[i]>A&&P[i]<=B){
      D++;
    }
    else{
      E++;
    }
  }
  cout << min(min(C,D),E) << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x;
    cin >> x;
    if(x == 7 || x == 5 | x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main() {
	int N, M, C, A, sum = 0, count = 0;
	int *B;
	cin >> N >> M >> C;
	B = new int[M];
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int j = 0; j < N; j++) {
		sum = 0;
		for (int i = 0; i < M; i++) {
			cin >> A;
			sum += A * B[i];
		}
		sum += C;
		if (sum > 0) count++;
	}
	cout << count << endl;
	delete[] B;
	return 0;
}

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 pair <int,int> P;

int main() {
  ll h,w;
  cin>>h>>w;
  ll ans=1e18;
  for (int i=1; i<=h; i++) {
    ll s1=i*w;
    ll s2=(h-i)*(w/2);
    ll s3=h*w-s1-s2;
    ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
  }
  ans=min(ans,((h+3-1)/3)*w-(h/3)*w);
  swap(h,w);
  for (int i=1; i<=h; i++) {
    ll s1=i*w;
    ll s2=(h-i)*(w/2);
    ll s3=h*w-s1-s2;
    ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
  }
  ans=min(ans,((h+3-1)/3)*w-(h/3)*w);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

for i in range(1, M + 1):
    if i % 2 == 1:
        j = (i - 1) // 2
        print(1 + j, M + 1 - j)
    else:
        j = (i - 2) // 2
        print(M + 2 + j, 2 * M + 1 - j)


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

#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;


const int MAX_H=10000;
const int MAX_N=1000;

int a,b,last;



int main()
{

    cin>>a>>b;
    last=ceil(max(a/0.08+13,b/0.1+11));
    //cout<<last<<endl;

    rep(i,last)
    {
        //cout<<floor(i*0.08)<<endl;
        if(floor(i*0.08)==a and floor(i*0.1)==b){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
    return 0;

}




Measured memory_bytes: 768
#%%
a, b = map(int, input().split())
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

#la = prime_factorize(a)
#lb = prime_factorize(b)
#print(la, lb)

c = fractions.gcd(a, b)
lc = prime_factorize(c)
#print(c, lc)

ans = list(set(lc))
ans = len(ans) + 1
print(ans)

Measured memory_bytes: 5176
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = In[0];
            int x = In[1];
            int t = In[2];
            int k;
            if (n % x == 0)
            {
                k = n / x;
            }
            else
            {
                k = n / x + 1;
            }
            Console.WriteLine(t * k);
        }
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var ans = new List<int>();
            for (int i = a.Count() - 1; i >= 0; i -= 2) ans.Add(a[i]);
            for (int i = a.Count() % 2 == 0 ? 0 : 1; i < ans.Count; i += 2) ans.Add(a[i]);
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}

Measured memory_bytes: 49592
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
double lx[100];
double ly[100];
double rx[100];
double ry[100];
double EPS=1e-9;
vector<pair<double,double> > v;
double ABS(double a){return max(a,-a);}
double calc(double a,double b){
	return -4.9*b*b+a*b;
}
int main(){
	int a;
	double b,c,d;
	scanf("%d%lf%lf%lf",&a,&b,&c,&d);
	for(int i=0;i<a;i++)scanf("%lf%lf%lf%lf",lx+i,ly+i,rx+i,ry+i);
	v.push_back(make_pair(c,d));
	for(int i=0;i<a;i++){
		rx[i]=min(rx[i],c);
		//v.push_back(make_pair(lx[i],ly[i]));
		v.push_back(make_pair(lx[i],ry[i]));
		//v.push_back(make_pair(min(rx[i],c),ly[i]));
		v.push_back(make_pair(rx[i],ry[i]));
	}
	for(int i=0;i<v.size();i++){
		int x=v[i].first;
		int y=v[i].second;
		double D=(9.8*y-b*b)*(9.8*y-b*b)-9.8*9.8*(x*x+y*y);
		if(D>-EPS)D=max(D,0.0);
		if(D<0)continue;
		double t,t2,vx,vy;
		bool ok;
		t2=(((double)b*b-9.8*y)+sqrt(D))*2/9.8/9.8;
		if(t2>-EPS)t2=max(t2,0.0);
		if(t2<0)continue;
		t=sqrt(t2);
		vx=(double)x/t;
		vy=sqrt((double)b*b-vx*vx);
		ok=true;
		if(vx-EPS>b)ok=false;
		double hg=calc(vy,(double)c/vx);
		for(int j=0;j<a;j++){
			if(lx[j]>=c-EPS)continue;
			if(ABS(rx[j]-c)<EPS&&d<=ry[j]&&ly[j]<=hg)ok=false;
			double p=calc(vy,(double)lx[j]/vx);
			double q=calc(vy,(double)rx[j]/vx);
			if(ly[j]<p-EPS&&p+EPS<ry[j])ok=false;
			if(ly[j]<q-EPS&&q+EPS<ry[j])ok=false;
			if(q+EPS<ry[j]&&ry[j]+EPS<p)ok=false;
			if(p+EPS<ly[j]&&ly[j]+EPS<q)ok=false;
			
			if(p+EPS<ry[j]&&ry[j]+EPS<q)ok=false;
			if(q+EPS<ly[j]&&ly[j]+EPS<p)ok=false;
			double th=calc(vy,vy/9.8);
		//	if(th-EPS>ly[j]){
				if(EPS+lx[j]<vx*vy/9.8&&vx*vy/9.8+EPS<rx[j]&&th>ly[j]+EPS&&ly[j]+EPS>calc(vy,lx[j]/vx)){
					ok=false;
				}
		//	}
			
		}
		if(hg<(double)d-EPS)ok=false;
		if(ok&&ABS(vx)>EPS){
			//printf("%f %f\n",vx,vy);
			printf("Yes\n");return 0;
		}
		t2=(((double)b*b-9.8*y)-sqrt(D))*2/9.8/9.8;
		if(t2>-EPS)t2=max(t2,0.0);
		if(t2<0)continue;
		t=sqrt(t2);
		vx=(double)x/t;
		vy=sqrt((double)b*b-vx*vx);
		ok=true;
		if(vx-EPS>b)ok=false;
		hg=calc(vy,(double)c/vx);
		for(int j=0;j<a;j++){
			if(lx[j]>=c-EPS)continue;
			if(ABS(rx[j]-c)<EPS&&d<=ry[j]&&ly[j]<=hg)ok=false;
			double p=calc(vy,(double)lx[j]/vx);
			double q=calc(vy,(double)rx[j]/vx);
			if(ly[j]<p-EPS&&p+EPS<ry[j])ok=false;
			if(ly[j]<q-EPS&&q+EPS<ry[j])ok=false;
			if(q+EPS<ry[j]&&ry[j]+EPS<p)ok=false;
			if(p+EPS<ly[j]&&ly[j]+EPS<q)ok=false;
			
			if(p+EPS<ry[j]&&ry[j]+EPS<q)ok=false;
			if(q+EPS<ly[j]&&ly[j]+EPS<p)ok=false;
			double th=calc(vy,vy/9.8);
		//	if(th-EPS>ly[j]){
				if(EPS+lx[j]<vx*vy/9.8&&vx*vy/9.8+EPS<rx[j]&&th>ly[j]+EPS&&ly[j]+EPS>calc(vy,lx[j]/vx)){
					ok=false;
				}
		//	}
			
		}
		if(hg<(double)d-EPS)ok=false;
		if(ok&&ABS(vx)>EPS){
			//printf("%f %f\n",vx,vy);
			printf("Yes\n");return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<vector<ll>> dp(101, vector<ll>(100001, 0));
//dp.at(i).at(j)は始めのi個まで使って重さがj以下になる最大価値

int main(){
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  rep(i, N){
    cin >> w.at(i) >> v.at(i);
  }
  rep(i, N){
    rep(j, W+1){
      if(j >= w.at(i)){
        dp.at(i+1).at(j) = max(dp.at(i).at(j), dp.at(i).at(j-w.at(i))+v.at(i));
      }
      else{
        dp.at(i+1).at(j) = dp.at(i).at(j);
      }
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 80256
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n");
    const N = Number(input[0]);
    const a = input[1].split(" ").map(n => Number(n));

    let tmp = 0;
    for (let i = 0; i < N; i++) {
        tmp += a[i];
    }
    const avr = tmp / N;
    let ans = 0;
    for (let i = 1; i < N; i++) {
        if (Math.abs(a[i] - avr) < Math.abs(a[ans] - avr)) {
            ans = i;
        }
    }
    console.log(ans);
}

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


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
using namespace std;
int a[201];
int main()
{
	int N,ans=0;
	cin>>N;
	for(int i=1;i<=2*N;i++)cin>>a[i];
	sort(a+1,a+2*N+1);
	for(int i=1;i<=2*N;i+=2)ans+=a[i];
	cout<<ans<<endl;
	return 0;
} 

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

void Main()
{
    int h, w, m;
    cin >> h >> w >> m;
    vector<pair<int,int>> sh(h), sw(w);
    map<pair<int, int>, int> ss;
    for (int i = 0; i < h; i++) sh[i].second = i;
    for (int i = 0; i < w; i++) sw[i].second = i;
    for (int i = 0; i < m; i++)
    {
        int y, x;
        cin >> y >> x;
        y--; x--;
        sh[y].first++;
        sw[x].first++;
        ss[make_pair(y,x)] = 1;
    }
    sort(sh.rbegin(), sh.rend());
    sort(sw.rbegin(), sw.rend());
    
    for (auto i: sh)
    {
        if(i.first != sh[0].first) break;
        for (auto j: sw)
        {
            if(j.first != sw[0].first) break;
            if(ss.count(make_pair(i.second, j.second)) == 0){
                cout << sh[0].first+sw[0].first << endl;
                return;
            }
        }
    }
        
    cout << sh[0].first+sw[0].first-1 << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 26692
N = int(input())
S = "abcdefghij"
ans = [""]
for k in range(N):
    n = []
    for e in ans:
        for f in S[:len(set(str(x) for x in e))+1]:
            n.append(e+f)
    ans = n
ans = sorted(ans)
for e in ans:
    print(e)


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

int main(){
  int K, X;
  cin >> K >> X;
  int m, M;
  m = X - K + 1;
  M = X + K - 1;
  for(int i = m; i < M; i++) cout << i << " ";
  cout << M << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a;
  string s;
 cin >> a;
  if(a < 1200){
    s = "ABC";
  }else if(a < 2800){
    s = "ARC";
  }else{
    s = "AGC";
  }
  cout << s;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

h,w,m= map(int, input().split())
g= [list(map(int, input().split())) for i in range(m)]
d=defaultdict(int)

x=[[0,i] for i in range(w)]
y=[[0,j] for j in range(h)]

for j,i in g:
    i-=1
    j-=1
    x[i][0]+=1
    y[j][0]+=1
    d[(j,i)]+=1


x.sort(reverse=True)
y.sort(reverse=True)
ans=0

for i in range(w):
    if i!=0 and x[i][0]<x[i-1][0]:
        break
    for j in range(h):
        if j==0 or y[j][0]==y[j-1][0]:
            if d[(y[j][1]),(x[i][1])] == 1:
                ans = x[i][0] + y[j][0] - 1
            else:
                ans = x[i][0] + y[j][0]
                print(ans)
                exit()
        else:
            break
print(ans)


Measured memory_bytes: 230548
def func(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-i-1]:
            return False
    return True
s = input()
N = len(s)
s2 = s[:N//2]
s3 = s[N//2+1:]
if func(s) and func(s2) and func(s3):
    print("Yes")
else:
    print("No")

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

int main() {
  int A,B;
  int ans ;
 // abcba が5桁の回文数となる。
  cin >> A >> B;
  
  for (int a = 1;a < 10 ;a++){
    for (int b = 0;b < 10;b++){
      for (int c = 0;c < 10;c++){
        int x = 10001 * a + 1010 * b + 100 * c ;
        if (A <= x && x <= B ){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    VI x(N); REP(i,N) cin >> x[i];

    VL kai(N+1,1); REP(i,N) kai[i+1] = kai[i]*(i+1)%MOD;

    ll ans = 1;
    int t = 0;
    VI v;
    REP(i,N){
        v.push_back(i);
        if(2*t+1 <= x[i]){
            t++;
        }
        else{
            (ans *= v.size()) %= MOD;
            v.pop_back();
        }
    }

    (ans *= kai[v.size()]) %= MOD;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 2044
/*
 * main.c
 *
 *  Created on: 2019/05/11
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char s[10001][11] = {0};

int main()
{
    int N = 0;
    int i = 0, lastA = 0, topB = 0, topBlastA = 0;
    int j = 0, ans = 0;
    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        scanf("%s", &s[i][0]);
        int len = strlen(s[i]);
        if((s[i][0] == 'B') && (s[i][len-1] == 'A')) {
            topBlastA++;
        } else  if(s[i][len-1] == 'A') {
            lastA++;
        } else if(s[i][0] == 'B') {
            topB++;
        }
    }
    //printf("%d %d %d\n", topBlastA, topB, lastA);
    for(i = 0; i < N; i++) {
        int len = strlen(s[i]);
        for(j = 0; j < len-1; j++) {
            if((s[i][j] == 'A') && (s[i][j+1] == 'B')) {
                //printf("ab\n");
                ans++;
            }
        }
    }
    if(topBlastA != 0) {
        if(topBlastA != 1) {
            ans += (topBlastA - 1);
            topBlastA = 1;
        }
        if(topB != 0) {
            ans++;
            topB--;
        }
        if(lastA != 0) {
            ans++;
            lastA--;
        }
    }
    if((lastA != 0) && (topB != 0)) {
        if(lastA > topB) {
            ans += topB;
        } else {
            ans += lastA;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {   ;
            long n = long.Parse(Console.ReadLine());
            long ans = 0;
            for (long i=1; ; i++)
            {
                if (n / i - 1 < i + 1) break;
                if (n % i == 0) ans += n / i - 1;
            }
            
            Console.WriteLine(ans);

            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

typedef long long ll;
ll N;
multiset<ll> C;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    auto it = C.lower_bound(a);
    if (it != C.begin()) C.erase(prev(it));
    C.insert(a);
  }
  cout << C.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
n = int(input()) - 1

k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(k[n])

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int countMul4 = 0;
        int countEven = 0;
        int countOdd = 0;
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (num % 4 == 0) {
                countMul4++;
            } else if (num % 2 == 0) {
                countEven++;
            } else {
                countOdd++;
            }
        }
        if(countOdd <= countMul4) {
            System.out.println("Yes");
        } else if (n % 2 != 0 && n / 2 == countMul4) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 47644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string a; cin >>a;
    string b; cin >>b;

    if (a[0] == b[2] && a[2] == b[0] && a[1] == b[1]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    } 
    return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        (n,x,m):(i64,i64,i64),
    };
    let mut n = n;
    let mut x = x;

    let mut id = vec![-1 as i64; m as usize];
    let mut len: i64 = 0;
    let mut total: i64 = 0;
    let mut a = vec![];

    while id[x as usize] == -1 {
        a.push(x);
        id[x as usize] = len;
        len += 1;
        total += x;
        x = x * x % m;
    }

    let c = len - id[x as usize];
    let mut s: i64 = 0;
    for i in 0..c {
        s += a[(len - i - 1) as usize];
    }

    let mut ans = 0;
    if n <= len {
        for i in 0..n {
            ans += a[i as usize];
        }
    } else {
        ans += total;
        n -= len;
        ans += s * (n / c);
        n %= c;
        for i in 0..n {
            ans += a[(id[x as usize] + i) as usize];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3164
import sys
sys.setrecursionlimit(10**7)
N = int(input())
a = [[] for _ in range(N)]
ans = [0]*N
for _ in range(N-1):
  u, v, w = map(int, input().split())
  a[u-1].append([v-1, w])
  a[v-1].append([u-1, w])
def calc(u, b):
  for v, w in a[u]:
    if not b == v:
      ans[v]=(ans[u] + w)%2
      calc(v, u)
calc(0, -1)
for i in ans:
  if i % 2 == 0:
    print(0)
  else:
    print(1)

Measured memory_bytes: 85212
while True:
    try:
        N = int(input())
        A = [int(input()) for _ in range(N)]
        B = sorted(A)
        max1 = B[-1]
        max2 = B[-2]
        for _ in A:
            if _ == max1:
                print(max2)
            else:
                print(max1)
    except:
        break

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

int n,m,L;
int k[2010];
i64 s[100100]; 
i64 dp[2010][2010];
constexpr i64 inf=1e18;

i64 calc(int a,int b) {
    if(a<b) swap(a,b);
    return (s[a+1]-s[b])/L;
}

int main() {
    cin>>n>>m>>L;
    for(int i=0; i<n; ++i) {
        cin>>k[i];
        k[i]--;
    }
    sort(k,k+n);
    for(int i=0; i<m; ++i) {
        cin>>s[i+1];
        s[i+1]+=s[i];
    }
    dp[0][0]=0;
    for(int i=0; i+1<n; ++i) {
        fill(begin(dp[i+1]),end(dp[i+1]),inf);
        for(int j=0; j<=i; ++j) {
            i64 now=dp[i][j];
            dp[i+1][j]=min(dp[i+1][j],now+calc(k[i],k[i+1]));
            dp[i+1][i]=min(dp[i+1][i],now+calc(k[j],k[i+1]));
        }
    }
    i64 ans=inf;
    for(int i=0; i<n; ++i) {
        ans=min(ans,dp[n-1][i]+calc(k[n-1],k[i]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 35340
N=int(input())

from collections import Counter

ans=[]
d={}
cnt=0
for i in range(N):
    s=list(input())
    s=sorted(s)
    
    s= ''.join(s)

    if s in d:
        d[s]+=1
    else:
        d[s]=1

total=0

for _,value in d.items():
    if value==1:
        continue
    else:
        total +=value*(value-1)/2

print(int(total))

Measured memory_bytes: 18200
I1 = input().split()
X, Y = int(I1[0]), int(I1[1])
a = int(Y-2*X)
b = int(4*X-Y)
if a % 2 == 0 and b % 2 == 0 and a >= 0 and b >= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int x;
	cin>>x;

	int ans=1;
	ll a=x;
	while(a%360>0){
		a+=x;
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3600
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(int, input().split()))

# okは4の倍数
ok = 0
# ngは4の倍数でもexcpでもない数
ng = 0
# excpはそのグループ内のペアに限って4の倍数になれる数
excp = 0
for i in range(N):
    if aN[i] % 4 == 0:
        ok += 1
    elif (aN[i] + 2) % 4 == 0:
        excp += 1
    else:
        ng += 1

# excpは全部1箇所にまとめてng1つ扱い
if excp > 0:
    ng += 1

# 外をngで囲まれてもいいので、okが1個少なくてもYes
if ok + 1 >= ng:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include <iostream>

using namespace std;

const int nMax = 51;

int continueJudge(int stones[], int nAll) {
  int flag = 99;

  for(int i=0; i<nAll; i++) {
    if(flag==99 && stones[i]>0) {
      flag = i;
    }
    else if(flag!=99 && stones[i]>0) {
      return 99;
    }
  }

  return flag; // 継続ならば99を返す
}

void printArray(int array[], int n) {
  for(int i=0; i<n; i++) {
    cout<<"array["<<i<<"] = "<<array[i]<<endl;
  }
  cout<<endl;
}

int main() {

  int n, p;
  int stones[nMax];

  while(cin>>n>>p && n!=0 && p!=0) {
    for(int i=0; i<n; i++) {
      stones[i] = 0;
    }

    int flag = 99;
    int i = 0;
    while(flag == 99) {
      if(p > 0) {
	stones[i]++;
	p--;
	if(p == 0) {
	  flag = continueJudge(stones, n);
	}
      }
      else { // p == 0
	p += stones[i];
	stones[i] = 0;
      }
      i++;
      if(i == n) {
	i = 0;
      }
      //printArray(stones, n);
    }
    cout<<flag<<endl;
  }
  
}

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

int main() {
  string temp;
  int AC,WA,TLE,RE,N;
  AC = 0;
  WA = 0;
  TLE = 0;
  RE = 0;
  cin >> N;
  for(int i = 0; N > i;i++) {
    cin >> temp;
    if(temp == "AC") {
      AC++;
    }
    if(temp == "TLE") {
      TLE++;
    }
    if(temp == "WA") {
      WA++;
    }
    if(temp == "RE") {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var count = 0;

            for(var i=0; i<=N; i++)
            {
                if (i % 2 != 0 && yakusuu(i) == 8)
                    count++;
            }
            Console.WriteLine(count);
        }

        static int yakusuu(int n)
        {
            var sss = 0;
            for(var i=1; i<=n; i++)
            {
                if (n % i == 0)
                    sss++;
            }
            return sss;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, L;
	cin >> N >> L;

	vector<string> S(N);

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

	sort(all(S));

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

	return 0;
}

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

int num[1005];
void div(int n);

int main(){
    int n; cin >> n;
    for(int i = 1; i <= 100; i++){
        num[i] = 0;
    }
    for(int i = 1; i <= n; i++){
        div(i);
    }
    ll ans = 1;
    for(int i = 2; i <= n; i++){
        if(num[i] > 0) ans = (ans*(num[i]+1))%mod;
    }
    cout << ans << endl;
    return 0;
}

void div(int n){
    int w  = n;
    for(int i = 2; i <= n; i++){
        while(n%i == 0){
            num[i]++;
            n/=i;
        }
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
#define adde(x, y) { e[++z].v = y; e[z].nxt = h[x]; h[x] = &e[z]; }
#define addrev(u, v) { adde(u, v); adde(v, u); }
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define FO(x) { freopen("#x.in", "r", stdin); freopen("#x.out", "w", stdout); }
inline int read() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x >= 0
{
	if(x < 10)
	{
		putchar(x + '0');
		return ;
	}
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 200100
int n, m;
int a[maxn];
ul s[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	ul Ans = LLONG_MAX;
	for(int i = 1; i <= n; i ++)
		s[i] = s[i - 1] + a[i];
	for(int i = 1; i <= n; i ++)
	{
		ul res = (ul)i * m;
		int cur = n - 2 * i;
		cur = max(cur, 0);
		res += 5 * (s[n] - s[cur]);
		for(int j = 7; cur; j += 2)
		{
			int tmp = cur - i;
			tmp = max(tmp, 0);
			res += j * (s[cur] - s[tmp]);
			cur = tmp;
		}
		Ans = min(Ans, res);
	}
	Ans += (ul)n * m;
	cout << Ans << endl;
	return 0;
}


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

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v(a >= mod ? a % mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<1000000007>;
mint dp[2][100010];
int main() {
    int N, K; cin >> N >> K;

    vector<int> d;
    for(int i=1; i*i<=N; i++) {
        d.push_back(i);
        d.push_back(N/i);
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    int A = d.size();
    vector<int> rng;
    rng.push_back(1);
    for(int i=1; i<A; i++) {
        rng.push_back(d[i] - d[i-1]);
    }

    dp[0][0] = mint(1);
    for(int i=0; i<K; i++) {
        int cur = i % 2, nxt = 1 - cur;
        for(int j=0; j<A; j++) {
            dp[nxt][0  ] += dp[cur][j] * rng[j];
            dp[nxt][A-j] -= dp[cur][j] * rng[j];
        }
        for(int j=0; j<=A; j++) {
            dp[nxt][j+1] += dp[nxt][j];
            dp[cur][j  ] = mint(0);
        }
    }

    mint ans = 0;
    for(int i=0; i<A; i++) ans += dp[K%2][i] * rng[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2428
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())

    if n == 0:
        print('0')
        exit()

    a = 0
    for i in range(1, 40, 2):
        a -= 2**i
    b = n - a
    res = []
    for i in range(40):
        if i%2 == 0:
            if (b>>i) & 1:
                res.append('1')
            else:
                res.append('0')
        else:
            if (b>>i) & 1:
                res.append('0')
            else:
                res.append('1')

    res = res[::-1]
    for i in range(40):
        if res[i] == '1':
            print(''.join(res[i:]))
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 38436
#include<bits/stdc++.h>
using namespace std;
const int N=5010,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int mul(int x,int y){return (long long)x*y%p;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
void update(int &x,int v){x+=v;if (x>=p) x-=p;}
vector<int> e[N];
int n,size[N],big[N],root;
void getroot(int x,int fa){
	size[x]=1;
	for (auto v:e[x])
	if (v!=fa){
		getroot(v,x);
		size[x]+=size[v];
		big[x]=max(big[x],size[v]);
	}
	if (size[x]*2>=n&&big[x]*2<=n) root=x;
}
int dp[N],fac[N],ifac[N],K[N],f[2][N],*a=f[0],*b=f[1];
int main()
{
	scanf("%d",&n);
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=mul(fac[i-1],i);
	ifac[n]=power(fac[n],p-2);
	for (int i=n;i;i--) ifac[i-1]=mul(ifac[i],i);
	for (int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	getroot(1,0);
	getroot(root,0);
	a[0]=1;
	int dp_size=1;
	for (auto v:e[root]){
		for (int i=0;i<=dp_size;i++) b[i]=0;
		int s=size[v];
		for (int i=0;i<=dp_size;i++)
		for (int j=0;j<=s;j++){
			int k=mul(fac[s],ifac[s-j]);
			k=mul(mul(k,k),ifac[j]);
			update(b[i+j],mul(a[i],k));
		}
		swap(a,b);
		dp_size+=s;
	}
	int ans=0;
	for (int i=0;i<=n;i++) update(ans,mul(i&1?p-1:1,mul(a[i],fac[n-i])));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
class BIT:
    def __init__(self,n):
        self.n = n
        self.tree = [0]*(n+1)

    def sum(self,x):
        sum = 0
        while(x>0):
            sum+=self.tree[x]
            x-=x&(-x)
        return sum

    def update(self,x,k):
        while(x<=self.n):
            self.tree[x]+=k
            x+=x&(-x)

    def build(self,a):
        for i in range(len(a)):
            k = a[i]
            x = i+1
            while(x<=self.n):
                self.tree[x]+=k
                x+=x&(-x)
class Query:
    def __init__(self, r,l, idx):
        self.l = l
        self.r = r
        self.idx = idx

def solve(case):
    n,q = map(int,input().split())
    c = list(map(int,input().split()))
    query = []
    for i in range(q):
        l,r = map(int,input().split())
        query.append(Query(r,l,i))

    query.sort(key = lambda x:x.r)
    bit = BIT(n)
    lastvis = [-1]*(n+1)
    ind = 0
    ans = [0]*q
    for i in range(n):
        if(lastvis[c[i]] != -1):
            bit.update(lastvis[c[i]]+1,-1)

        lastvis[c[i]] = i
        bit.update(i+1,1)
        while(ind<q and query[ind].r == i+1):
            ans[query[ind].idx] = (bit.sum(i+1) - bit.sum(query[ind].l-1))
            ind+=1

    # print('\n'.join(str(ans[i]) for i in range(len(ans))))
    for i in range(q):
        print(ans[i])
solve(1)


Measured memory_bytes: 239620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  for(int i = 1; i < 2 * N; i++) {
    if(0 <= i * 1.08 - N && i * 1.08 - N < 1) {
      cout << i << endl;
      break;
    }
    if(i == 2 * N - 1) {
      cout << ":(" << endl;
    }
  }
}

Measured memory_bytes: 3592