akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long p = sc.NextLong();

        List<long> div = new List<long>();
        for (long i = 2; i * i <= p; i++)
        {
            while (p % i == 0)
            {
                div.Add(i);
                p = p / i;
            }
        }
        div.Add(p);

        Dictionary<long, long> dic = new Dictionary<long, long>();
        foreach (var d in div)
        {
            if (dic.ContainsKey(d))
            {
                dic[d]++;
            }
            else
            {
                dic.Add(d, 1);
            }
        }

        long answer = 1;

        foreach (var item in dic)
        {
            answer *= (long)Math.Pow(item.Key, item.Value / n);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27876
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>

using namespace std;

const int NMAX = 1e5 + 11;

int  n, abc[NMAX][3], mem[NMAX][3];
bool vis[NMAX][3];

// i : current pos, p : prev option
int dp(int i, int p)
{
    int &ans = mem[i][p];

    if (i == n)
        return 0;
    if (vis[i][p])
        return mem[i][p];
    vis[i][p] = true;

    ans = INT_MIN;
    for (int j = 0; j < 3; ++j)
    {
        if (j == p)
            continue;
        ans = max(ans, dp(i + 1, j) + abc[i][j]);
    }

    return ans;
}

int main(void)
{
    cin >> n;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> abc[i][j];

    cout << dp(0, -1) << endl;

    return 0;
}


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
using namespace std;
int a[150];
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> a[i];
    sort(a,a+n);
    cout << a[n-1] - a[0] << endl;
    return 0;
}


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

int main() 
{ 
    
    vector< pair <int,int> > vect; 
    int n,t;
    cin>>n; 
    for (int i=0; i<n; i++) 
    {
        cin>>t;
        vect.push_back( make_pair(t,i) ); 
    }
    

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

   
    for (int i=0; i<n; i++) 
    { 
       cout<<vect[i].second+1<<" "; 
    } 

    return 0; 
} 



Measured memory_bytes: 1780
# 1以上N以下の異なる整数を、差が1の整数をともに選ばないようにK個選ぶことができるか判定する関数
# @param n
# @param k
# @return canGet
def canGetK(n, k)
  mirginNum = (n - 1) / 2
  canGet = (mirginNum + 1) >= k ? 'YES' : 'NO'
end

if __FILE__ == $0
  input = gets.chomp
  n,k = input.split(' ').first.to_i, input.split(' ').last.to_i
  puts canGetK(n, k)
end

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

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
	dice(int top,int front,int right,int left,int back,int bottom) {
		id[TOP] = top; id[FRONT] = front; id[RIGHT] = right;
		id[LEFT] = left; id[BACK] = back; id[BOTTOM] = bottom;
	}
	int& operator[] (FACE f) { return id[f]; }
	const int& operator[] (FACE f) const { return id[f]; }
	bool operator==(const dice &b) const {
		const dice &a = *this;
		return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
			a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
			 a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
	}
	void roll_north() { roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_south() { roll(TOP, BACK, BOTTOM, FRONT); }
	void roll_east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_right() { roll(FRONT, LEFT, BACK, RIGHT); }
	void roll_left() { roll(FRONT, RIGHT, BACK, LEFT); }
	void all_rolls(set<long long> &s){
		for (int k = 0; k < 6; (k&1?roll_east():roll_north()),++k)
			for (int i = 0; i < 4; roll_right(), ++i)
				s.insert(((long long)id[TOP]<<40) | ((long long)id[FRONT]<<32) | (id[RIGHT]<<24) | (id[LEFT]<<16) | (id[BACK]<<8) | (id[BOTTOM]<<0));
	}
private:
	void roll(FACE a, FACE b, FACE c, FACE d){
		int tmp = id[a];
		id[a] = id[b]; id[b] = id[c];
		id[c] = id[d]; id[d] = tmp;
	}
	int id[6];
};

int main(){
	int n,d[6];
	cin>>n;
	int i,j;
	set<long long>s;
	for(i=0;i<n;i++){
		for(j=0;j<6;j++)cin>>d[j];
		long long x=((long long)d[0]<<40) | ((long long)d[1]<<32) | (d[2]<<24) | (d[3]<<16) | (d[4]<<8) | (d[5]<<0);
		if(s.find(x)!=s.end()){
			cout<<"No"<<endl;
			return 0;
		}else{
			dice di(d[0],d[1],d[2],d[3],d[4],d[5]);
			di.all_rolls(s);
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 1304
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????
//????????????a????????????
double norm(Vector a){
    return a.x * a.x + a.y * a.y;
}
//????????????a,b?????????
double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

//??????s(p1p2)???????????????p????°???±
Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}


int main(){
    
    int x0, y0, x1, y1, x2, y2;
    
    int q;
    
    cin >> x0 >> y0 >> x1 >> y1;
    cin >> q;
    
    Segment s = {Point(x0, y0), Point(x1, y1)};
    
    for (int i = 0; i < q; i++) {
        cin >> x2 >> y2;
        Point p2 = Point(x2, y2);
        
        Point ans = project(s, p2);
        
        printf("%.8lf %.8lf\n", ans.x, ans.y);
    }
    
    
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define MAX 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 11<<20
using namespace std;

int n;
vector<pair<int,int> > adj[MAX];

void dijkstra(){
	priority_queue<pair<int,int> > pq;
	int color[MAX];
	int d[MAX];
	for(int i = 0;i < n;i++){
		d[i] = INF;
		color[i] = WHITE;
	}

	d[0] = 0;
	pq.push(make_pair(0,0));
	color[0] = GRAY;

	while(!pq.empty()){
		pair<int,int> f = pq.top();
		pq.pop();
		int u = f.second;
		color[u] = BLACK;

		if(d[u] < f.first * (-1)) continue;

		for(int j = 0;j < adj[u].size();j++){
			int v = adj[u][j].first;
			if(color[v] == BLACK)continue;
			if(d[v] > d[u] + adj[u][j].second){
				d[v] = d[u] + adj[u][j].second;
				pq.push(make_pair(d[v]*(-1),v));
				color[v] = GRAY;
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(d[i] == INF)cout << i << " " << -1 <<endl;
		else cout << i << " " << d[i] << endl;
	}
}

int main(){
	int u,k,v,c;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> v >> c;
			adj[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();

	return 0;
}

Measured memory_bytes: 6304
#import <stdio.h>

const int MAX = 101;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();

	int n,p;
	scanf("%d %d",&n,&p);
	int a = 0;
	int b = 0;
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		x%2==0 ? a++ : b++;
	}
	long long A = 1;
	long long B = 0;
	for(int i=0;i<a;i++) A*=2;
	for(int k=p;k<=b;k+=2) B+=COM(b,k);
	printf("%lld\n",A*B);
}

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

public class Main {
	
	public static int shrink(String s, char x){
		if(s.replaceAll(x+"","").equals("")) return 0;
		int L = s.length();
		String next = "";
		for(int i=1;i<L;i++){
			if(s.charAt(i-1)==x || s.charAt(i)==x) next = next+x;
			else next = next + "0";
		}
		return shrink(next,x)+1;
	}
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        final int INF = 1_000_000;
        int ans = INF;
        
        for(char x='a';x<='z';x++){
        	ans = Math.min(ans,shrink(s,x));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 44244
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B; cin >> A >> B;
    int res = A+B;
    if(res>=24) res-=24;
    pr(res);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, N);
    vector<int> a(N);

    rep(i, N) {
        input(a[i]);
    }

    int cnt = 0;
    int now = 1;
    rep(i, N) {
        if (a[i] == now) {
            ++now;
        } else {
            ++cnt;
        }
    }

    if (cnt >= N) {
        print(-1);
    } else {
        print(cnt);
    }

    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

# 17:36-18:18 give up => kaisetu
# -18:46 - 18:52 chudan
# -20:21


def main():
    S = input() + "0"
    # S = "1" * 10**5 + "0"
    N = len(S)
    S = list(map(int, S))

    q = 2019

    res = [0] * N
    num = 0
    p = 1
    pow_memo = {0: (10**0) % q}
    for i in range(N-2, -1, -1):
        pow_memo[p] = (pow_memo[p-1] * 10) % q
        num = (num + (S[i] % q) * pow_memo[p]) % q
        res[i] = num
        p += 1

    cnt = [0] * q
    for r in res:
        cnt[r] += 1

    ans = 0
    for c in cnt:
        ans += c * (c-1) // 2

    return ans


print(main())


Measured memory_bytes: 43276
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string  s; 
    cin >> s ; 
    int  len=sz(s),ans=0; 
    if (len==1) ans=s[0]-'0';
    else {
        bool ok=false;
        for (int i=1;i<len;i++)
            if (s[i] < '9') ok=true;
        if (ok) {
            for (int i=0;i<len;i++){
                if (i==0) ans += s[i]-'1';
                else ans += 9;
            }
        }
        else {
            for (int i=0;i<len;i++) ans += s[i]-'0';
        }
    }
    cout << ans << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3544
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

mod = 1000000007
n = ni()
s1 = list(ns())
s2 = list(ns())
a = []

for i in range(n):
    if s1[i] == s2[i]:
        a.append(0)
    elif i > 0 and s1[i-1] == s1[i] and s2[i-1] == s2[i]:
        a.append(1)

ans = 3 if a[0] == 0 else 6
for j in range(1,len(a)):
    if a[j] == 0:
        if a[j-1] == 0:
            ans*=2
        else:
            ans*=1
    else:
        if a[j-1] == 0:
            ans*=2
        else:
            ans*=3
    ans%=mod

print(ans%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  ll x = in();
  ll y = in();
  int ans = 0;
  while(x<=y){
    ++ans;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
	return (0);
}


Measured memory_bytes: 3620
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B=B[::-1]

AA=[A[0]]
BB=[B[0]]

for i in range(1,N):
  AA.append(AA[i-1]+A[i])
  BB.append(BB[i-1]+B[i])
BB=BB[::-1]

CC=[]
for i in range(N):
  CC.append(AA[i]+BB[i])
  
print(max(CC))

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

int main()
{
    string s; cin >> s;
    int len = s.length();
//    cout << "len = " << len << endl;
    int pattern = len-1;
    ll ans = 0;
    for (int i = 0; i < (1<<pattern); ++i) {
        ll tmp = 0;
        ll index = 0;
        ll stx = 0;
        string st;
//        cout << "i = " << i << endl;
        for (int j = 0; j < pattern; ++j) {
            st.push_back(s[index]);
            index++;
            if ((i >> j) & 0x01) {
//                cout << "st = " << st << endl;
                tmp += stol(st);
                st.clear();
            }
        }
        st.push_back(s[index]);
        tmp += stol(st);
        ans += tmp;
    }
    cout << ans << endl;

}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)

using namespace std;

typedef pair<int,int> ii;

struct Data{
  int number,hit,blow;
  Data(int number=IINF,int hit=IINF,int blow=IINF):number(number),hit(hit),blow(blow){}
};

int N;
int divi[] = {1,10,100,1000};

vector<int> compute(vector<Data> info){
  vector<int> res;
  rep(fir,10){
    rep(sec,10){
      if( fir == sec ) continue;
      rep(thr,10){
	if( thr == fir || thr == sec ) continue;
	rep(fou,10){
	  if( fir == fou || sec == fou || thr == fou ) continue;
	  int number = fir * 1000 + sec * 100 + thr * 10 + fou;
	  bool check = true;
	  rep(i,info.size()){
	    int hit = 0, blow = 0;
	    bool exist[10];
	    rep(k,10)exist[k] = false;
	    exist[fir] = exist[sec] = exist[thr] = exist[fou] = true;
	    rep(j,4){
	      int digit_1 = floor(number / divi[j]), digit_2 = floor(info[i].number / divi[j]);
	      digit_1 %= 10, digit_2 %= 10;
	      if( digit_1 == digit_2 )  hit++;
	      else if( exist[digit_2] ) blow++;
	    }
	    if( !( hit == info[i].hit && blow == info[i].blow ) ) {
	      check = false;
	      break;
	    }
	  }
	  if( check ){
	    res.push_back(number);
	  }
	}
      }
    }
  }
  return res;
}

bool computer(vector<int> vec){
  int len = vec.size();
  rep(fir,10){
    rep(sec,10){
      if( sec == fir ) continue;
      rep(thr,10){
	if( thr == fir || thr == sec ) continue;
	rep(fou,10){
	  if( fou == fir || fou == sec || fou == thr ) continue;
	  set<ii> checker;
	  int number = fir * 1000 + sec * 100 + thr * 10 + fou;
	  rep(i,len){
	    ii score = ii(0,0);
	    bool exist[10];
	    rep(j,10)exist[j] = false;

	    rep(j,4){
	      int digit_2 = floor( vec[i] / divi[j] );
	      digit_2 %= 10;
	      exist[digit_2] = true;
	    }

	    rep(j,4){
	      int digit_1 = floor( number / divi[j] ), digit_2 = floor( vec[i] / divi[j] );
	      digit_1 %= 10, digit_2 %= 10;
	      if( digit_1 == digit_2 ) score.first++;
	      else if( exist[digit_1] ) score.second++;
	    }

	    checker.insert(score);

	  }
	  if( (int)checker.size() == len ){
	    printf("%d%d%d%d\n",fir,sec,thr,fou);
	    return true;
	  }
	}
      }
    }
  }
  return false;
}

int main(){
  while(cin>>N,N){
    vector<Data> info(N);
    rep(i,N)cin >> info[i].number >> info[i].hit >> info[i].blow;
    vector<int> tmp = compute(info);
    if( tmp.size() == 1 ){
      cout << string(4-(int)(log10(tmp[0])+1),'0') << tmp[0] << endl;
      continue;
    }
    if( tmp.empty()){
      puts("????");
      continue;
    }
    if(!computer(tmp))cout << string(4,'?') << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int i=0;i<=10000;i++)
	{
		if(i*a%b==c)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
def calc(r, str = "")
  return str if str.length > 4
  a = r * 2
  b = a.to_i
  str += b.to_s
  c = a - b
  if c.zero?
    return str
  else
    calc(c, str)
  end
end


until (n = gets.to_f.rationalize) < 0
  integer_part = n.to_i
  decimal_part = n - integer_part
  
  result = "NA"
  str = integer_part.to_s(2)
  if str.length <= 8
    str = str.rjust(8, "0")
    tmp = calc(decimal_part)
    if tmp.length <= 4
      result = str + "." + tmp.ljust(4, "0")
    end
  end
  
  puts result
end


Measured memory_bytes: 6952
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MOD=1e9+7;
int n;
int sum[30];
char s[100005];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		sum[s[i]-'a']++;
	}
	long long ans=1;
	for(int i=0;i<26;i++)
	{
		ans=(ans*(sum[i]+1))%MOD;
	}
	ans--;
	ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}

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

static const int mod = 1e9 + 7;

long long modPow(long long a, long long b){
  if(b == 0) return 1;
  
  if(b & 0b1) return a*modPow(a, b-1) % mod;

  return modPow(a*a % mod, b/2) % mod;
}


long long modComb(long long a, int b){
  if(a-b < b) return modComb(a, a-b);

  long long A = a, B = 1;
  long long As = 1, Bs = 1;
  for(int i = b; i > 0; --i){
    As = As * A % mod;
    Bs = Bs * B % mod;
    --A;
    ++B;
  }

  return As * modPow(Bs, 1e9+7-2) % mod;
}


signed main(){
  int n, m;

  cin >> n >> m;

  for(int i=2; i*i <= m; ){
    if(m % i == 0){
      m /= i;
      ++divider[i];
    }else ++i;
  }
  if(m != 1) ++divider[m];

  long long ans = 1;
  for(auto x : divider){
    ans = ans * modComb(n-1 + x.second, x.second) % mod;
  }

  cout << ans << endl;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = ni();
        }
        long ans = 0;
        if(a[0] !=0){
            out.println(-1);
            return;
        }
        for (int i = N-1; i >=1; i--) {
            if(a[i] > a[i-1] + 1){
                out.println(-1);
                return;
            }else if(a[i] > a[i-1]){
                ans += 1;
            }else if(a[i] == a[i-1]){
                ans += a[i];
            }else{
                ans += a[i];
            }
        }

        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

class AOJ {
  static void Main(string[] args)
  {
    string s;
    int[] x = new int[101];
    int max;

    while ((s = Console.ReadLine()) != null)
      x[int.Parse(s)]++;

    max = x.Max();

    for (int i = 1; i < 101; i++) {
      if (max == x[i])
        Console.WriteLine(i);
    }
  }
}

Measured memory_bytes: 9568
#include <iostream>
using namespace std;
#define ll long long 
#define vvll vector<vector<long long>>
#define vll vector<long long>
#define fri(i,n) for(int i=0;i<n;i++)
#define fri1(i,n) for(int i=n-1;i>=0;i--)
#define map map<ll,ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ump unordered_map<long long ,long long>
#define ub upper_bound
#define bsearch binary_search

int main() 
{
    fast
    int k;
    string str="ACL",ans="";
    cin>>k;
    fri(i,k)
    {
        ans=ans+str;
    }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

ll check(ll x, ll y) {
    ll ans = LINF;
    if (x >= 3) {
        for (int i = 1; i <= x - 2; i++) {
            ll a = i * y;
            ll b = ((x - i) / 2) * y;
            ll c = ((x - i) - (x - i) / 2) * y;

            ll d = min(a, min(b, c));
            ll e = max(a, max(b, c));
            ans = min(ans, e - d);
        }
    }

    for (int i = 1; i <= x - 1; i++) {
        ll a = i * y;
        ll b = (x - i) * (y / 2);
        ll c = (x - i) * ( y - (y / 2));

        ll d = min(a, min(b, c));
        ll e = max(a, max(b, c));
        ans = min(ans, e - d);
    }

    return ans;
}

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

    cout << min(check(H, W), check(W, H)) << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

ll F(ll x){
  if (x%2) return ((x+1)/2)%2;
  else return x^(x/2)%2;
}

int main(){
  ll A, B; cin >> A >> B;
  ll ans = F(A-1) ^ F(B);
  cout << ans << endl;
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(){
    int n;
    int a1, a2, a3, a4;
    cin >> n;
    a1 = n / 1000;
    a2 = n / 100 - a1*10;
    a3 = n / 10 - a1*100 - a2*10;
    a4 = n % 10;
    
    if(a1 == a2 && a2 == a3)    {cout << "Yes\n";   return 0;}
    if(a2==a3 && a3 == a4)  {cout << "Yes\n";   return 0;}
    cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {

	int n, x; cin >> n >> x;

	vector<int>diff(n);

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

		diff[i] = abs(buf - x);
	}


	ll d = diff[0];
	for (int i = 1; i < n; i++) {
		d = GCD(d, diff[i]);
	}

	cout << d << endl;

	return 0;
}

Measured memory_bytes: 768
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    R,G,B,n=map(int,input().split())
    ans=0
    for r in range(n//R+1):
        for g in range((n-r*R)//G+1):
            if (n-r*R-g*G)%B==0:
                ans+=1
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MaxN = 2e6,MOD = 1e9+7;
#define x1 x1926
#define y1 y0817
int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
int fac[MaxN+1],ifac[MaxN+1];

inline LL fastpow(LL a,LL p) {
    LL ret=1;
    while (p) {
        if (p&1) ret=ret*a%MOD;
        p>>=1;a=a*a%MOD;
    }
    return ret;
}
inline LL inv(const LL& x) {return fastpow(x,MOD-2);}
//inline LL C(const int& n,const int& m) {return (LL)fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;}
inline LL paths(const int& x,const int& y) {return (LL)fac[x+y+2]*ifac[x+1]%MOD*ifac[y+1]%MOD;}
LL solve(int x3,int y3,int x4,int y4) {
	return (paths(x3-x1,y3-y1)-paths(x3-x1,y3-y2)-paths(x3-x2,y3-y1)+paths(x3-x2,y3-y2))*(paths(x6-x4,y6-y4)-paths(x5-x4,y6-y4)-paths(x6-x4,y5-y4)+paths(x5-x4,y5-y4))%MOD;
}
int main() {
    scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
    scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
    fac[1]=ifac[1]=1;
    for (int i=2;i<=MaxN;++i) fac[i]=(LL)fac[i-1]*i%MOD;
    ifac[MaxN]=inv(fac[MaxN]);
    for (int i=MaxN-1;i>=1;--i) ifac[i]=(LL)ifac[i+1]*(i+1)%MOD;
    x2++,y2++,x5--,y5--;
    LL ans=0;
    for (int i=x3;i<=x4;i++) ans+=solve(i,y4,i,y4+1)*(y4+i+1)%MOD-solve(i,y3-1,i,y3)*(y3+i)%MOD;
	for (int i=y3;i<=y4;i++) ans+=solve(x4,i,x4+1,i)*(x4+i+1)%MOD-solve(x3-1,i,x3,i)*(x3+i)%MOD;
    ans=ans%MOD+MOD;
    ans%=MOD;
    printf("%lld\n",ans);
    return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

#define PI 3.14159265358979323846
#define N 100000
#define MOD 1000000007

int n;
set<string> si;
void print_all(string &s, int in, int ch)
{
	if (in == n)
		si.insert(s);
	else
	{
		for (int i = 0; i < ch + 1; ++i)
		{
			s[in] = 'a' + i;
			if (i == ch)
			{
				print_all(s, in + 1, ch + 1);
			}
			else	
				print_all(s, in + 1, ch);
		}
	}
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;

	string s;
	s.resize(n);

	print_all(s, 0, 0);
	// cout << si.size() << "\n";
	for (auto e : si)
		cout << e << "\n";
	return 0;
}

Measured memory_bytes: 12416
from itertools import product
from math import ceil

d, g = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(d)]

min_count = 10 ** 10
for use in product(range(2), repeat=d):
    count = 0
    total = 0
    for i in range(d):
        if use[i]:
            total += (i + 1) * 100 * PC[i][0] + PC[i][1]
            count += PC[i][0]
    if total >= g:
        if count < min_count:
            min_count = count
    else:
        for i in range(d):
            if use[i]:
                continue
            if total + (i + 1) * 100 * (PC[i][0] - 1) >= g:
                tmp_count = count + ceil((g - total) // 100 / (i + 1))
                if tmp_count < min_count:
                    min_count = tmp_count

print(min_count)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
vector<int>v[51];int dep[51];int f[51][6];
vector<int>dfs;
inline void Pretreatment(int u,int fa){
	dep[u]=dep[fa]+1;f[u][0]=fa;
	rep(i,1,5)f[u][i]=f[f[u][i-1]][i-1];
	rep(i,0,(int)v[u].size()-1){
		int nop=v[u][i];
		if(nop==fa)continue;
		Pretreatment(nop,u); 
	}
	dfs.push_back(u);
	return;
}
inline int LCA(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	rep2(i,5,0){
		if(dep[f[x][i]]>=dep[y])x=f[x][i];
		if(x==y)return x;
	}
	rep2(i,5,0){if(f[x][i]!=f[y][i]){x=f[x][i];y=f[y][i];}}
	return f[x][0];
}

long long powe[51];int co[21][2];int dif[51];bool vis[51];
inline int lowbit(int x){return x&(-x);}

int main(){
	int n;read(n);
	rep(i,1,n-1){
		int ai,bi;read(ai);read(bi);
		v[ai].push_back(bi);v[bi].push_back(ai);
	}
	Pretreatment(1,0);
	int m;read(m);
	rep(i,1,m){read(co[i][0]);read(co[i][1]);}
	
	powe[0]=1;
	rep(i,1,n)powe[i]=powe[i-1]*2;
	long long ret=0;
	rep(i,1,(1<<m)-1){
		memset(dif,0,sizeof(dif));memset(vis,0,sizeof(vis));
		
		int cnt=0;int x=i;
		while(x){
			int t=lowbit(x);int p=log2(t)+1;int q=LCA(co[p][0],co[p][1]);
			dif[co[p][0]]++;dif[co[p][1]]++;dif[q]-=2;
			x-=t;cnt++;
		}
		
		long long num=powe[n-1];
		rep(i,0,(int)dfs.size()-1){
			int u=dfs[i];
			rep(j,0,(int)v[u].size()-1){
				int nop=v[u][j];
				if(vis[nop])dif[u]+=dif[nop]; 
			}
			if(dif[u])num/=2;
			vis[u]=1;
		}
		if(cnt%2==0)num=-num;
		ret+=num;
	}
	write(powe[n-1]-ret);
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int dp[k+1];
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++){
		dp[a[i]]=1;
	}
	for(int i=1;i<=k;i++){
		if(dp[i]==-1){
			for(int j=0;j<n;j++){
				if(i>=a[j]){
				if(dp[i-a[j]]==0){
					dp[i]=1;
					break;
				}
				}
			}
			dp[i]=(dp[i]==1)?1:0;
		}
		//cout<<dp[i]<<endl;
	}
	if(dp[k])cout<<"First";
	else cout<<"Second";
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int[] a = new int[3];

        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }

        int sum = 0;
        int max = 0;

        for (int i = 0; i < 3; i++) {
            sum += a[i];

            if (a[i] > max) {
                max = a[i];
            }
        }

        System.out.println(sum - max);
    }
}

Measured memory_bytes: 21716
// HE WHO TRAVELS THE FASTEST, TRAVELS ALONE
#include <bits/stdc++.h>
#include <stack>
using namespace std;
#define ORIGAMI ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define INF 1e18LL
#define ll long long int

vector<ll> adj[100000];
vector<bool> vis(100000,false);
ll mod = 998244353;

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

ll po(ll a,ll b)
{
	ll mod = 100;
	a%=mod;
	b%=mod;
	ll res=1;
	while(b>0)
	{
		if(b&1)
			res = (res * a) % mod;
		a = a * a % mod;
		b/=2;
	}
	return res;
}

void dfs(ll x)
{
	vis[x] = true;
	cout<<x<<" ";
	for(auto u:adj[x])
	{
		if(!vis[u])
			dfs(u);
	}
}

bool isprime(ll x)
{
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
			return false;
	}
	return true;
}

bool solve(ll x)
{
	ll s=1;
	for(int i=x/2;i>1;i--)
	{
		if(x%i==0)
		{
			s+=i;
		}
	}
	if(s==x)
		return true;
	return false;

}


int main()
{
	ORIGAMI
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	vector<string> s;
	ll n,l;
	cin>>n>>l;
	while(n--)
	{
		string a;
		cin>>a;
		s.pb(a);
	}
	sort(s.begin(),s.end());
	for(auto x:s)
		cout<<x;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    ll hc = m / 2, gcc = 0;
    gcc += min(hc, n);
    m -= gcc * 2;
    gcc += m / 4;
    cout << gcc << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(void) {
    int a,b;
    cin >> a >> b;
    cout << (((a+b)%2==0)?((a+b)/2):((a+b)/2+1));
    return 0;
}


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

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

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,x;cin>>n>>x;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  if(a[0]>=x){
    res+=a[0]-x;
    a[0]=x;
  }
  for(i=1;i<n;i++){
    if(a[i]+a[i-1]>=x){
      res+=a[i]+a[i-1]-x;
      a[i]=x-a[i-1];
    }
  }
  cout<<res<<endl;
  


  return 0;
}

Measured memory_bytes: 1024
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int N, K;
    string s;
    cin >> N >> K >> s;

    vector<ll> v;
    ll num__continuous = 0;
    char count_ch = '1';

    REP(i, s.length()){
        if (s[i] == count_ch) {
            num__continuous++;
        } else {
            v.emplace_back(num__continuous);
            num__continuous = 1;
            count_ch = s[i];
        }
    }

    if (num__continuous != 0) v.push_back(num__continuous);
    if (v.size() % 2 == 0) v.push_back(0);

    ll ans = 0;
    int num_cnt = 2*K+1;

    for (int i = 0; i < v.size(); i+=2) {

        ll cnt = 0;

        int left = i;
        int right = min(i + num_cnt, (int)v.size());
        for (int j = left; j < right; j++)
        {
            cnt += v[j];
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;


    return 0;

}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
vector<pair<ll,ll>> ans;

int f(int x, int y, int z){
    if(y==3){
        ans.push_back(make_pair(1,3));
        ans.push_back(make_pair(2,3));
        return 0;
    }
    if(x+y==z){
        ans.push_back(make_pair(x,x+1));
        ans.push_back(make_pair(x,x+2));
        ans.push_back(make_pair(y,y-1));
        ans.push_back(make_pair(y,y-2));
        return 0;
    }
    if(x==1 && y%2==1){
        for(int i=1;i<y;i++){
            ans.push_back(make_pair(y,i));
        }
        f(1,y-1,z-y);
        return 0;
    }
    for(int i=x+1;i<y;i++){
        ans.push_back(make_pair(x,i));
        ans.push_back(make_pair(y,i));
    }
    f(x+1,y-1,z-x-y);
    return 0;
}

int main(){
    ll n ; cin >> n;
    f(1,n,n*(n-1)/2 - (n%2==0));
    ll m = ans.size();
    cout << m << endl;
    rep(i,m){
        cout << ans.at(i).first << " " << ans.at(i).second << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n, t;
    cin >> n >> t;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    map<ll, ll> sa;
    ll nmin = INF, nmax = 0;
    rep(i, n)
    {
        if (nmax <= A[i])
        {
            nmax = A[i];
            sa[nmax - nmin]++;
        }
        if (nmin >= A[i])
        {
            nmin = A[i];
            nmax = A[i];
        }
    }
    
    auto it=sa.end();
    it--;
    cout << it->second << endl;
}

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


void solve(long long a, long long b){
    if(a == b){
        for(int i = 0;i < a;i++){
            cout<<a;
        }
        cout<<endl;
    }else{
        int m = max(a, b);
        int n = min(a, b);
        for(int i = 0;i < m;i++){
            cout<<n;
        }
        cout<<endl;
    }
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
ABC = list(map(int, input().split()))

ABC.sort()

# まずABCの最小値と2番目に小さい値を同じ値になるように操作する
# 偶奇が一致していない場合、まずABCの最小値と最大値に1を足す
ans = 0
if ABC[0]%2 != ABC[1]%2:
    ans += 1
    ABC[0] += 1
    ABC[2] += 1

ans += (ABC[1]-ABC[0])//2

# 最大値以外の2つの値を最大値と一致するまで1増加させて終了
ans += ABC[2] - ABC[1]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    repl(i, 1, n) {
        if(a[i] >= a[i-1]) continue;
        ans += a[i-1]-a[i];
        a[i]=a[i-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
ll max_val = 1e5;
int main(){
	ios::sync_with_stdio();
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	double tmp;
	vector<double> v;
	for(int i=0;i<n;i++){
        cin>>tmp;
        v.pb(tmp);
	}
	double dp[n+1][n+1];
	memset(dp,0.0,sizeof(dp));
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1-v[i-1]);
            else
                dp[i][j]=dp[i-1][j-1]*v[i-1]+dp[i-1][j]*(1-v[i-1]);
        }
	}
	double ans = 0.0;
	for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(9)<<ans<<endl;
  	return 0;
}


Measured memory_bytes: 74052
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10000)

S = input()

for i in range(len(S)):
    if i <= len(S) -2:
        if S[i] == S[i+1]:
            print("{} {}".format(i+1,i+2))
            break
    if i <= len(S) -3:
        if S[i] == S[i+2]:
            print("{} {}".format(i+1, i+3))
            break
else:
    print("-1 -1")

Measured memory_bytes: 3188