akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MODS 100005
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define ld long double
#define bigint int64_t
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define pb push_back
#define test ll t;read(t);while(t--)
#define pll pair<ll,ll>
#define vvll vector<vector<ll>>
#define fst first
#define scd second
#define ins insert
#define line "\n"

#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define forr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))

template <typename T>
void read(T &x){
    cin >> x;
}
template <typename T , typename T0>
void read(T &x,T0 &y){
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x,T0 &y,T1 &z){
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x,T0 &y,T1 &z,T2 &w){
    cin >> x >> y >> z >> w;
}

template <typename T , typename T0>
void read(pair< T , T0 > &p){
    cin >> p.fst >>p.scd;
}

template <typename T>
void read(vector< T > &oneD,ll n){
    forn(i,n)
    {
        ll x;
        read(x);
        oneD.push_back(x);
    }
}

template <typename T>
void read(T oneD[] , ll n){
    for(ll i=0;i<n;i++){
        read(oneD[i]);
    }
}

template <typename T>
void write(T &x){

    cout << x << " ";
}

template <typename T , typename T0>
void write(T &x,T0 &y){
    cout << x << " " << y << "\n";
}

template <typename T , typename T0 , typename T1>
void write(T &x,T0 &y,T1 &z){
    cout << x << " " << y << " " << z << "\n";
}

template <typename T , typename T0 , typename T1 , typename T2>
void write(T &x,T0 &y,T1 &z,T2 &w){
    cout << x << " " << y << " " << z << " " << w << "\n";
}

template <typename T , typename T0>
void write(pair< T , T0 > &p){
    write(p.fst);
    write(p.scd);
    cout << line;
}

template <typename T>
void write(vector< T > &oneD,ll n){
    for(ll i=0;i<n;i++){
        cout<<oneD[i]<<" ";
    }
    cout << line;
}

template <typename T>
void write(T oneD[] ,int n){
    for(ll i=0;i<n;i++){
        write(oneD[i]);
    }
    cout <<line;
}

template <typename T , typename T0>
void write(map< T , T0 > &mpp){
    for(auto it : mpp){
        write(it.fst);
        cout << ": ";
        write(it.scd);
        cout << "\n";
    }
    cout<<line;
}
void write(vvll rc,ll n,ll m)
{
	forn(i,n)
	{
		forn(j,m)
		{
			cout<<rc[i][j]<<" ";
		}
		cout<<line;
	}
}
ll minl(ll a,ll b)
{
	return (a<b)?a:b;
}
void solve()
{
    ll n;
    vll c;
    read(n);
    read(c,n);
    vll memo;
    memo.pb(0);
    memo.pb(abs(c[0]-c[1]));
    for(ll i=2;i<n;i++)
    {
    	memo.pb(minl(abs(c[i]-c[i-1])+memo[i-1],abs(c[i]-c[i-2])+memo[i-2]));
    }
    cout<<memo[n-1];
}
int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
//*******************************************************//
solve();

return 0;
}




Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());//交换
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';//镜面对称
        else if(a[i]=='d') a[i]='b';//请注意,else一定要加,不然就白做了
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";//判断
    else cout<<"No";
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int count = 0;
	while (count != k) {
		if (a % 2 == 1) {
			a = a - 1;
			b += a / 2;
			a = a / 2;
			count++;
		}
		else {
			b += a / 2;
			a = a / 2;
			count++;
		}
		if (count == k)break;
		if (b % 2 == 1) {
			b = b - 1;
			a += b / 2;
			b = b / 2;
			count++;

		}
		else {
			a += b / 2;
			b = b / 2;
			count++;

		}
		
	}
	cout << a <<" "<< b << endl;
}








Measured memory_bytes: 256
s = input()
even = ["L","U","D"]
odd = ["R","U","D"]
f=True
for i in range(len(s)):
    if i%2==1:
        if s[i] not in even:
            f = False
    if i%2==0:
        if s[i] not in odd:
            f=False
if f:
    print("Yes")
else:
    print("No")

  


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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.length()-1;i++){
    for(int j=i+1;j<s.length();j++){
      if(s[i] == s[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  
  cout << "yes" << endl;

}

Measured memory_bytes: 256
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
  print(1)
elif x2 == 0:
  print(2)  
elif x3 == 0:
  print(3)
elif x4 == 0:
  print(4)
else:
  print(5)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
int main(){
    //freopen("t.txt","w",stdout);
    int cc=10000;
    printf("30844\n");
    printf("+ 0 1 4\n");
    printf("< 3 4 5\n");  //a[5]=1
    printf("+ 0 5 10\n"); //a[10]=a[0]+1
    printf("+ 1 5 11\n"); //a[11]=a[1]+1
    printf("+ 3 5 100\n");
    for (int i=1;i<30;i++) printf("+ %d %d %d\n",100+i-1,100+i-1,100+i); //a[100+i]=2^i
    for (int i=29;i>=0;i--){ //a[1000..1029] = A
        printf("+ %d %d %d\n",20,100+i,++cc);
        printf("< %d %d %d\n",cc,10,1000+i);
        printf("+ %d %d %d\n",3,1000+i,500); //a[500]=a[1000+i]
        for (int j=0;j<i;j++) printf("+ %d %d %d\n",500+j,500+j,500+j+1); //a[500+i]=a[500]*(2^i)
        printf("+ %d %d %d\n",20,500+i,20); //a[20]+=a[500]*(2^i)
    }
    for (int i=29;i>=0;i--){ //a[1100..1129] = B
        printf("+ %d %d %d\n",21,100+i,++cc);
        printf("< %d %d %d\n",cc,11,1100+i);
        printf("+ %d %d %d\n",3,1100+i,500); //a[500]=a[1000+i]
        for (int j=0;j<i;j++) printf("+ %d %d %d\n",500+j,500+j,500+j+1); //a[500+i]=a[500]*(2^i)
        printf("+ %d %d %d\n",21,500+i,21); //a[20]+=a[500]*(2^i)
    }
    for (int i=0;i<30;i++)
    for (int j=0;j<30;j++){
        printf("< %d %d %d\n",1000+i,1100+j,600);
        printf("< %d %d %d\n",3,1100+j,700);
        printf("< %d %d %d\n",600,700,800);
        for (int k=0;k<i+j;k++) printf("+ %d %d %d\n",800+k,800+k,800+k+1);
        printf("+ %d %d %d\n",2,800+i+j,2);
    }
    return 0;
}


Measured memory_bytes: 3708
#!/usr/bin/env python3
#ABC113 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

h,w,K = map(int,input().split())
if w == 1:
    print(1)
    quit()
dp = [[0]*(w) for _ in range(h+1)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        x,y,z = 0,0,0
        for k in range(2**(w-1)):
            b = [0]*(w-1)
            for l in range(w-1):
                if (k>>l) & 1:
                    if b[l-1] == 1:
                        break
                    b[l] = 1
            else:
                if j > 0 and j < w-1:
                    if b[j-1] == 1 and b[j] == 0:
                        x += 1
                    elif b[j-1] == 0 and b[j] == 0:
                        y += 1
                    elif b[j-1] == 0 and b[j] == 1:
                        z += 1
                elif j == 0:
                    if b[j] == 0:
                        y += 1
                    elif b[j] == 1:
                        z += 1
                elif j == w-1:
                    if b[j-1] == 0:
                        y += 1
                    elif b[j-1] == 1:
                        x += 1
        if j > 0:
            dp[i+1][j-1] += x*dp[i][j]
            dp[i+1][j-1] %= mod
        if j + 1 < w:
            dp[i+1][j+1] += z*dp[i][j]
            dp[i+1][j+1] %= mod
        dp[i+1][j] += y*dp[i][j]
        dp[i+1][j] %= mod
print(dp[-1][K-1])


Measured memory_bytes: 47596
#include<stdio.h>

int main(){
    int a[5][4][11];
    int i, j, k, l;
    int n, b, f, r, v;
    
    scanf("%d", &n);
    for(i = 1; i <= 4; i++){
        for(j = 1; j <= 3; j++){
            for(k = 1; k <= 10; k++){
                a[i][j][k] = 0;
            }
        }
    }
    
    for(l = 0; l < n; l++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b][f][r] += v;
    }
    
    for(i = 1; i <= 4; i++){
        for(j = 1; j <= 3; j++){
            for(k = 1; k <= 10; k++){
                if(a[i][j][k] == 0){
                    printf(" 0");
                }else{
                     printf(" %d", a[i][j][k]);
                }
            }
            printf("\n");
        }
        if(i != 4){
            printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        300005
#define mod         998244353  
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b,i;
    cin>>n>>a>>b;
    for(i=a;i<=b;i++){
        if(i%n==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<int, string>> results(m);
  int penalty = 0;
  vector<int> ac_flg(105000);
  vector<int> wa_flg(105000);
  int correct = 0;
  int a; string b;
  rep(i, m) {
      cin >> a >> b;
      results.at(i).first = a;
      results.at(i).second = b;
      if (ac_flg.at(a))
      {
          /* code */
          continue;
      }
      
      if (results.at(i).second == "WA")
      {
          /* code */
          wa_flg.at(a)++;
      }
      else if (results.at(i).second == "AC")
      {
          /* code */
          correct++;
          penalty += wa_flg.at(a);
          ac_flg.at(a) = 1;
      }
  }

  
  cout << correct << " " << penalty << endl;
  return 0;
}

Measured memory_bytes: 7296
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	string s, p; cin >> s >> p;
	int S = s.length(), P = p.length();
	for (int i = 0; i < S; i++)
		for (int j = 0; j <= P; j++)
			if (j == P) {
				cout << "Yes" << endl;
				return 0;
			}
			else if (s[(i + j) % S] != p[j]) break;
	cout << "No" << endl;
}

Measured memory_bytes: 1184
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    str s;
    cin >> s;
    bool a=true;
    f(i,1,s.size()+1)
    {
      if((i&1)&&(s[i-1]=='R'||s[i-1]=='U'||s[i-1]=='D'))
        continue;
       if((i%2==0)&&(s[i-1]=='L'||s[i-1]=='U'||s[i-1]=='D'))
        continue;
      else
      {
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

vector<vector<ll>> PartitionNumber(ll n,ll k){
	vector<vector<ll>> dp(n+1,vector<ll>(k+1));
	dp[0][0] = 1;
	for(int i = 0; i <= n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i - j >= 0) dp[i][j] = dp[i][j - 1] + dp[i - j][j];
			else dp[i][j] = dp[i][j - 1];
			dp[i][j] %= atcoder_mod;
		}
	}
	return dp;
}
ll BallBoxCombination12(ll n,ll k){
	if(n-k<0) return 0;
	auto T = PartitionNumber(n-k,k);
	return T[n-k][k];
}

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

	ll N=in<ll>(),K=in<ll>();
	
	ll ans = BallBoxCombination12(N,K);
	out(ans);
	return 0;
}



Measured memory_bytes: 4256
from math import sqrt

i = input().split()
a = int(i[0])
b = int(i[1])
c = int(i[2])

d = (c - b - a) > 0
e = (c - b - a) ** 2 > 4 * a * b

if d and e:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def Hershad(n):
    if n == 0:
        return 0
    return n % 10 + Hershad(n // 10)


N = int(readline())
print('Yes' if N % Hershad(N) == 0 else 'No')


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    vector<ll> a(3);
    REP(i,3){
        cin >> a[i];
    }
    int temp = 1;
    REP(i,3){
        temp *= a[i]%2;
    }
    ll res = 0;
    if(temp==0){
        res = 0;
    }else{
        SORT(a);
        res = a[0]*a[1];
    }
    put(res);
    return 0;
}


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

int f(int n)
{
  if (n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}

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

  vector<int> a;
  a.push_back(s);
  for (int i = 0; i < 1000000; i++)
  {
    a.push_back(f(a[a.size()-1]));
  }

  int m = 1000000;
  for (int i = 0; m > i; i++)
  {
    for (int j = i + 1; j < 1000000; j++)
    {
      if (a[i] == a[j])
      {
        if (j < m)
        {
          m = j + 1;
          break;
        }
      }
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 6512
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	c := getNextInt(scanner)
	k := getNextInt(scanner)
	tt := make([]int, n)

	for i := 0; i < n; i++ {
		tt[i] = getNextInt(scanner)
	}
	sort.Ints(tt)
	var ans int64
	ans = 1
	prev := 0
	for i := 0; i < n; i++ {
		for i-prev == c || tt[i]-tt[prev] > k {
			ans++
			prev = i
		}
	}

	fmt.Println(ans)
	writer.Flush()
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin >> x;
    map<int, int> a;
    for (int q = -5000; q <= 5000; q++){
        a[(int)pow(q, 5)] = q;
    }
    for (int q = -5000; q <= 5000; q++){
        if (a.find((int)pow(q, 5)-x) != a.end()){
            int w = (int)pow(q, 5)-x;
            cout << q << ' ' << a[w] << endl;
            return 0;
        }
    }
    return 0;
}


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

int count(const string &S){
    int res=0;
    for(int i = 0; i +1 < S.size();++i){
        if(S[i]=='A'&&S[i+1]=='B')++res;
    }
    return res;
}

int N;
vector<string> S;

long long solve(){
    long long res = 0;
    for(int i = 0; i < N ;i++)res += count(S[i]);
    
    int a = 0 , b = 0 , c = 0;
    for(int i = 0; i < N ; ++i){
        if(S[i][0]=='B'&&S[i].back()=='A')++a;
        else if (S[i].back()=='A')++b;
        else if (S[i][0]=='B')++c;
    }
    long long add = 0;
    if(b+c==0)add = max(0,a-1);
    else add = a+min(b,c);
    
    res += add;
    return res;
    
}

int main(){
    while(cin >> N){
        S.resize(N);
        for(int i = 0; i < N ;i++)cin >>S[i];
        cout << solve()<<endl;
        
    }
    
}









Measured memory_bytes: 768
#include <stdio.h>
 
int main()
{
    int n, S[10000], q, T[500], i, j, k;
    int same = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &S[i]);

    scanf("%d", &q);
    for (i = 0; i < q; i++)
        scanf("%d", &T[i]);
   
    for (i = 0; i < n; i++) {
        for (k = i - 1; k >= 0; k--) {
            if (S[k] == S[i]) {
                i += 1;
                k = i - 1;
            }
        }
        for (j = 0; j < q; j++) {
            for (k = j - 1; k >= 0; k--) {
                if (T[k] == T[j]) {
                    j += 1;
                    k = j - 1;
                }
            }
            if (T[j] == S[i]) {
                same += 1;
            }
        }
    }

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

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> sides; 
    for (int i = 0; i < N; i++){
        int element;
        cin >> element;
        sides.push_back(element);
    }
    sort(sides.begin(), sides.end());
    int vec_size = sides.size();
    int longest = sides[vec_size - 1];
    int sum = 0;
    for (int i = 0; i < N - 1; i++){
        sum += sides[i];
    }
    if (sum > longest){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

//bfsして大きい辺から割り当てていくとよい
//結局cの最大値以外は採用できる。
//大きい値からグラフを作っていくことを考えると
// 既にできているグラフの点はすでに今考えている値より大きい値をもつ
// どこにつなげてもそのつなげる辺はその値を採用できる。
// しかし最初の一番大きいのだけは採用できない
int n;
vector<vector<int>> g;
vector<ll> c;
ll sum;
int main(){
    cin>>n;
    g.resize(n);c.resize(n);
    rep(i,n-1){
        int a,b;cin>>a>>b;a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n){
        cin>>c[i];sum+=c[i];
    }
    sort(ALL(c),greater<ll>());

    vector<ll> ans(n);
    vector<bool> checked(n,false);
    queue<int> q;
    q.push(0);
    int idx=0;
    while(!q.empty()){
        int now=q.front();q.pop();
        ans[now]=c[idx];idx++;
        checked[now]=true;

        for(auto x:g[now]){
            if(checked[x]) continue;
            q.push(x);
        }
    }

    cout<<sum-c[0]<<endl;
    rep(i,n-1) cout<<ans[i]<<' ';
    cout<<ans[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int N;
//下からi桁目まで決めていて、上に繰り上がりを要求するかどうか
ll dp[1001005][2];
void debug(){
    rep(i,N+1){
        rep(j,2){
            cerr<<dp[i][j]<<" ";
        }
        cerr<<endl;
    }
    cerr<<endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    reverse(all(S));
    S += "0";
    N = S.size();
    rep(i,N+1)rep(j,2)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,N){
        int d = S[i] - '0';
        rep(j,2){
            if(j)d++;
            for(int k = 0; k < 10; k++){
                if(k >= d){
                    chmin(dp[i+1][0], dp[i][j] + k + (k - d));
                }
                else{
                    chmin(dp[i+1][1], dp[i][j] + k + 10 + k - d);
                }
            }
        }
    }
    //debug();
    cout << min(dp[N][0], dp[N][1])<<endl;
}

Measured memory_bytes: 17052
class BIT():
	def __init__(self, N):
		self.bit = [0] * (N + 1)
		self.N = N

	def add(self, a, w):
		x = a
		while x <= self.N:
			self.bit[x] += w
			x += x & (- x)

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


MAX_N = 10 ** 5
SQRT_MN = 318
isp = [1] * (MAX_N + 1)
p_list = []
isp[0] = isp[1] = 0
for i in range(2, SQRT_MN + 1):
	if isp[i] == 0:
		continue
	p_list.append(i)
	for prod in range(2, MAX_N // i + 1):
		isp[i * prod] = 0

bit = BIT(MAX_N)
for p in range(3, MAX_N + 1):
	if isp[p] and isp[(p + 1) // 2]:
		bit.add(p, 1)

Q = int(input())
for i in range(Q):
	l, r = map(int, input().split())
	print(bit.sum(r) - bit.sum(l - 1))


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

int main(){

    long long int K, N;
    cin >> K >> N;
    long long int houses[N];
    for(int i=0; i<N; i++) cin >> houses[i];

    long long int answer=houses[N-1]-houses[0];
    
    for(int i=1; i<N; i++){
        long long int x = 
        answer = min(answer,K-houses[i]+houses[i-1]);    
    }

    cout << answer << "\n";

    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int h,n;cin >> h>>n;
  vint a(n);vin(a);
  if(h>accumulate(all(a),0))cout << "No" << endl;
  else cout << "Yes" << endl;

}


Measured memory_bytes: 640
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> a(n);
		REP(i, n) cin >> a[i];
		vector<int> ans(n);
		RREP(i, n) {
			int p = i;
			int sum = 0;
			while(p < n) {
				sum += ans[p];
				p += i+1;
			}
			ans[i] = (sum + a[i]) % 2;
		}
		int m = 0;
		REP(i, n) {
			if(ans[i] == 1) {
				m++;
			}
		}
		cout << m << endl;
		REP(i, n) {
			if(ans[i] == 1) {
				cout << i + 1 << ' ';
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    // Your code here!
    int Nin,Hit,Sin[100001],For,Cou;
    
    scanf("%d%d",&Nin,&Hit);
    
    for(For=0;For<Nin;For++)
        scanf("%d",&Sin[For]);
    
    Cou = 0;    
    for(For=0;For<Nin;For++)
        if(Sin[For]>=Hit)
            Cou++;
    
    printf("%d",Cou);
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  int N;
  scanf("%d", &N);
  int A[N];
  for (int i=0; i<N; i++) {
    scanf("%d", &A[i]);
  }
  int ans = A[0];
  for (int i=1; i<N; i++) {
    ans = gcd(A[i], ans);
  }
  printf("%d\n", ans);
}


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

class Program
{
    static void Main(string[] args)
    {
        var line1 = Console.ReadLine()
            .Split(' ')
            .Select(n => long.Parse(n))
            .ToList();
        var N = line1[0];
        var K = line1[1];

        var minN = N;

        if (N > K)
        {
            var x = (N / K) * K;
            N -= x;
        }
        for (int i = 0; i < 100; i++)
        {
            if (N > K)
            {
                // Console.WriteLine($"{i:0000} : N={N} K={K}");
                N = N - K;
            }
            else
            {
                N = K - N;
            }

            if (N < minN)
            {
                minN = N;
                if (minN == 0) break;
            }
            // Console.WriteLine($" => N={N}");
        }

        Console.WriteLine(minN);
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = 1e9 + 7;

int main() {
	ll n, m; cin >> n >> m;

	ll ans = 1900 * m + (n - m) * 100;
	ans *= pow(2, m);

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

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int c = 0;
	char a[4];

	cin >> a;
	roop(i, 0, 3) {
		if (a[i] == '1')c++;
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9+7;
//const ll mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0; 
int main(){
	//freopen("in.txt","r",stdin);
	double n;
	cin>>n;
	const double pi = acos(-1);
	printf("%.4lf\n" , 2*pi*n);
	return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

int main() {
	string s;
	int i,n;
	cin >> s;
	n = 0;
	while (s[n] != '\0') {
		n++;
	}
	i = 0;
	while (s[i] == 'B') {
		s[i] ='2';
		i++;
	}
	int j;
	for (j = i; j < n; j++) {
		if (s[j] == 'B') { 
			int x;
			x = j-1;
			while (s[x] == '2') {
				x--;
			}
			s[j] = '2'; s[x] = '2'; }
	}

cout<<endl;
	for (j = 0; j < n; j++) {
		if (s[j] != '2')cout << s[j];
	}
	cout << endl;

	return 0;
}


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


int main(){

    long X;
    cin >> X;

    long num500,num5;
    num500 = X / 500;
    num5 = (X%500)/5;
    cout << num500*1000+num5*5 << endl;

    return 0;
}


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

int main() {
  string s;
  cin>>s;

  bool ans = true;
  int len = s.size();

  for(int i=0; i<len/2; i++) {
    if(s[i]!=s[len-i-1]) ans=false;
  }

  if(len!=3) {
    for(int i=0; i<len/2; i++) {
      if(s[i]!=s[len/2-i-1]) ans=false;
    }
  }

  reverse(s.begin(), s.end());

  if(len!=3) {
    for(int i=0; i<len/2; i++) {
      if(s[i]!=s[len/2-i-1]) ans=false;
    }
  }



  // for(int i=(len+3)/2-1; i<len; i++) {
  //   if(s[i]!=s[len+3-i]) ans=false;
  // }

  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
tmp = []
count = 0
for i in range(A,B+1):
    tmp.append(i)
for j in range(len(tmp)):
    flag = 1
    if len(str(tmp[j]))%2 == 0:
        for k in range(int(len(str(tmp[j]))/2)):
            if str(tmp[j])[k] != str(tmp[j])[-k-1]:
                flag = 0
                break
    else:
        for l in range(int(len(str(tmp[j]))//2)):
            if str(tmp[j])[l] != str(tmp[j])[-l-1]:
                flag = 0
                break
    if flag == 1:
        count += 1
print(count)

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

l, r = -1, N
while r - l > 1:
    m = (l + r) // 2
    S = m*(1 + m) // 2

    if S >= N:
        r = m
    else:
        l = m

X = r * (1 + r) // 2 - N
if X == 0:
    print(*list(range(1, r+1)), sep="\n")
else:
    print(*list(range(1, X)) + list(range(X+1, r+1)), sep="\n")


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10**9)

N = int(input())
A = list(map(int,input()))
X = 2 in A

while len(A) > 1:
    if len(A) % 2 == 1:
        for i in range(len(A)-1):
            A[i] = abs(A[i]-A[i+1])
        A.pop()
    B = []
    for i in range(len(A)//2):
        B.append(abs(A[i*2]-A[i*2+1]))
    A = B[:]

if X:
    A[0] %= 2
print(A[0])


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

#define MAX_N 201
#define MAX_R 1001
#define INF 1<<28

int land[MAX_N][MAX_N];  // 陸路のみを使った最短経路長
int sea[MAX_N][MAX_N];   // 海路のみを使った最短経路長

int z[MAX_R];

int N, M;
int R;

bool init() {
    cin >> N >> M;
    if (N == 0 && M == 0) return false;

    for (int i = 1; i <= N; i++) 
        for (int j = 1; j <= N; j++) {
            if (i == j) {
                land[i][j] = 0;
                sea[i][j] = 0;
            } else {
                land[i][j] = INF;
                sea[i][j] = INF;
            }
        }

    for (int i = 0; i < M; i++) {
        int x, y, t; char c;
        cin >> x >> y >> t >> c;
        if (c == 'L') {
            land[x][y] = t;
            land[y][x] = t;
        } else {
            sea[x][y] = t;
            sea[y][x] = t;
        }
    }

//    for (int i = 1; i <= N; i++) {
//        for (int j = 1; j <= N; j++) {
//            cout << land[i][j] << ' ';
//        }
//        cout << endl;
//    }

    for (int k = 1; k <= N; k++) 
        for (int i = 1; i <= N; i++) 
            for (int j = 1; j <= N; j++) {
                land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
                sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);
            }

    cin >> R;
    for (int i = 0; i < R; i++) 
        cin >> z[i];

    return true;
}

int main() {
    while (init()) {
        int dp[R][N+1]; // dp[p][q] -- p番目まで集配, 町qに船
        for (int i = 0; i < R; i++) for (int j = 0; j <= N; j++) dp[i][j] = INF;
        dp[0][z[0]] = 0;
        for (int i = 1; i < R; i++) {
            // 陸路のみで移動
            for (int j = 1; j <= N; j++) {
                if (dp[i-1][j] != INF) {
                    dp[i][j] = dp[i-1][j] + land[z[i-1]][z[i]];
                } 
            }
            // 海路を使用
            //
            // jまで船にのるため戻り, 船でkに行く.
            // その後陸路でz[i]に向かう.
            for (int j = 1; j <= N; j++) {
                for (int k = 1; k <= N; k++) {
                    dp[i][k] = 
                        min(dp[i][k], 
                            dp[i-1][j] + land[z[i-1]][j] + sea[j][k] + land[k][z[i]]);
                }
            }
        }

//        for (int i = 1; i <= N; i++) {
//            for (int j = 1; j <= N; j++) {
//                cout << land[i][j] << ' ';
//            }
//            cout << endl;
//        }

//        for (int i = 0; i < R; i++) {
//            for (int j = 1; j <= N; j++) {
//                cout << dp[i][j] << ' ';
//            }
//            cout << endl;
//        }

        int min_time = INF;
        for (int i = 1; i <= N; i++) {
            min_time = min(min_time, dp[R-1][i]);
        }
        cout << min_time << endl;
    }
}

Measured memory_bytes: 2260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int N,a,count=0;
    cin>>N;
    map<int,int> A;
    for(int i=0;i<N;i++){
        cin>>a;
        if(A[a]==0) A[a]++;
        else A[a]--;
    }
    for(auto itr =A.begin();itr!=A.end();itr++){
        if(itr->second==1){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 4864
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


# 約数列挙 0(√N)
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N = in_n()

    yaku = make_divisors(N)
    yaku.remove(1)

    ans = 0
    for x in yaku:
        tn = N
        while tn % x == 0:
            tn /= x
        if tn % x == 1:
            ans += 1

    yaku = make_divisors(N - 1)
    yaku.remove(1)
    ans += len(yaku)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9604
#include<stdio.h>
int main(void){
    int X;
    scanf("%d",&X);
    if(X==1||X==8||X==15||X==22||X==29){
        printf("fri\n");
    }else if(X==2||X==9||X==16||X==23||X==30){
        printf("sat\n");
    }else if(X==3||X==10||X==17||X==24){
        printf("sun\n");
    }else if(X==4||X==11||X==18||X==25){
        printf("mon\n");
    }else if(X==5||X==12||X==19||X==26){
        printf("tue\n");
    }else if(X==6||X==13||X==20||X==27){
        printf("wed\n");
    }else if(X==7||X==14||X==21||X==28){
        printf("thu\n");
    }
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <stdio.h>
using namespace std;

struct Str {
	char s[105];
}str[100];

int cmp(const void *a, const void *b) {
	const struct Str *p1 = (const struct Str*)a;
	const struct Str *p2 = (const struct Str*)b;
	return strcmp(p1->s, p2->s);

}

int main() {
	int n, l;
	cin >> n >> l;
	getchar();
	for (int i = 0; i < n; i++){
        scanf("%s",str[i].s);
        getchar();
	}
	qsort(str, n, sizeof(Str), cmp);
	for (int i = 0; i < n; i++) printf("%s",str[i].s);
	return 0;
}


Measured memory_bytes: 256
N=int(input())
import copy
def warshall_floyd(N):
  d=[list(map(int,input().split())) for i in range(N)]
  D=copy.deepcopy(d)
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  if d==D:
    return d
  else:
    return -1
  
E=warshall_floyd(N)
if E==-1:
  print(-1)
  exit()
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      if E[i][j]!=0 and E[i][k]!=0 and E[k][j]!=0:
        if E[i][j]==E[i][k]+E[k][j]:
          E[i][j]=0       
ans=0
for i in range(N):
  ans+=sum(E[i]) 
print(ans//2)

Measured memory_bytes: 76452
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

 
    
    
int main()
{
   long int n=0,r=0,g=0,b=0,sum=0,dis=0;
   string s;
   cin>>n>>s;
   /*for ( int i = 0; i < n; i++)
   {
     switch ((int)s[i])
      {
      case 82:
        r++;
        break;
      case 71:
          g++;
        break;
      case 66:
          b++;
        break;
     }
   }*/
   for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
        }
        else if(s[i]=='G'){
            g++;
        }
        else{
            b++;
        }
    }
     sum=r*g*b;
     for (int i=0;i<n;i++)
     {
       for (int loop=1;i+2*loop<n;loop++)
       { 
         if ((int)s[i]+(int)s[i+loop]+(int)s[i+2*loop]==219)
         {
             sum--;
         }
       }
     }
   
   cout<<sum<<endl;
  
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>

#include <string>

using namespace std;

int main()

{

  ios::sync_with_stdio(false);

  cin.tie(0);

  cout.tie(0);

  string str, s;

  cin >> str >> s;

  int strl = str.size();

  int tl = s.size();

  int res = 1000;

  for (int i = 0; i < strl - tl + 1; i++)

  {

    int cnt = tl;

    for (int j = 0; j < tl; j++)

    {

      if (str[i + j] == s[j])

        cnt--;

    }

    res = min(res, cnt);

  }

  cout << res << endl;

  return 0;

}

Measured memory_bytes: 3120
# include<bits/stdc++.h>
using namespace std;
 
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  
  for(int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  int ans = 0;
  for(int i = 0; i < K;i++) {
    ans += P.at(i);
  }
  int tt = ans;
  for(int i = K; i < N; i++) {
    tt = tt + P.at(i)-P.at(i-K);
    ans = max(ans,tt);
  }
  double z = ((double)ans + (double)K) /2;
  cout << fixed << setprecision(12) << z << endl;
}

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

int main(void) {
  string S;
  cin >> S;

  vector<ll> cnt(2, 0);
  REP(i, 0, S.length()) {
    cnt[S[i] - '0']++;
  }

  cout << min(cnt[0], cnt[1]) * 2 << endl;
}

Measured memory_bytes: 512
n = int(input())
s = list(input())
l_ins = 0
l = 0
r = 0
for i in range(n):
    if s[i] == "(":
        l += 1
    else:
        r += 1
    l_ins = max(l_ins, r-l)
r_ins = 0
l = 0
r = 0
for i in range(n-1, -1, -1):
    if s[i] == "(":
        l += 1
    else:
        r += 1
    r_ins = max(r_ins, l-r)
ar = ["("]*l_ins + s + [")"]*r_ins
print("".join(ar))




Measured memory_bytes: 38384
huge = 10**9+7
n,m = map(int,input().split())
a = [0,1]
b = []
now = 0
for _ in range(m):
  b.append(int(input()))
b.append(n+1)
for i in range(1,n+1):
  if b[now] == i:
    tmp = 0
    now += 1
  else:
    tmp = a[-2] + a[-1]
  a.append(tmp % huge)
print(a[-1])

Measured memory_bytes: 7828
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int A, B;
    A = H1 * 60 + M1;
    B = H2 * 60 + M2;
    cout << B - A - K << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return m[n]=(n*fact(n-1))%mod;
//}
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n){
        n/=k;cnt++;
    }
    cout<<cnt;
}
signed main(){
    boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	string s; cin >> s;
	int cnta = 0;
	int cntb = 0;
	REP(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '0')cnta++;
			else cntb++;
		}
		else {
			if (s[i] == '1')cnta++;
			else cntb++;
		}
	}
	print(min(cnta, cntb));



	return 0;
}


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

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

  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    int min_idx = i;
    for (int j = i + 1; j < N; j++) {
      if (A[j] < A[min_idx]) {
        min_idx = j;
      }
    }
    if (min_idx == i) continue;
    int v = A[i];
    A[i] = A[min_idx];
    A[min_idx] = v;
    cnt++;
  }
  
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << "\n" << cnt << endl;

  return 0;
}


Measured memory_bytes: 3092
'use strict'

function main(input) {

  let n = Number(input);
  let ans = 'No';

  while (n >= 0) {
    if (n % 7 === 0) {
      ans = 'Yes';
      break;
    }
    n -= 4;
  }

  console.log(ans);
}

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


Measured memory_bytes: 11468