akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) " [" << (#X) << " = " << (X) << "] "

const ll mod = 1e9 + 7;
ll n;
vector<vector<ll> > mult(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	vector<vector<ll> > ret(n, vector<ll>(n));
	for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) for(ll k = 0; k < n; k++) {
		(ret[i][k] += a[i][j] * b[j][k]) %= mod;
	}
	return ret;
}
vector<vector<ll> > fastexp(vector<vector<ll> > &m, ll k) {
	vector<vector<ll> > ret(n, vector<ll>(n));
	if(k == 0) {
		for(ll i = 0; i < n; i++) ret[i][i] = 1;
		return ret;
	}
	ret = fastexp(m, k / 2);
	ret = mult(ret, ret);
	return (k % 2) ? mult(ret, m) : ret;

}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll k; cin >> n >> k;
	vector<vector<ll> > m(n, vector<ll>(n));
	for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) cin >> m[i][j];
	m = fastexp(m, k);
	ll ans = 0;
	for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) (ans += m[i][j]) %= mod;
	cout << ans << '\n';
}

Measured memory_bytes: 1664
#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

n, q = map(int, input().split())

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)

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

int main () {
  string s;
  cin  >> s;
  vector<int>cnt(2,0);
  
  for(int i=0;i<s.size();i++){
    cnt[s[i]-'0']++;
  }
  
  int ans=min(cnt[0],cnt[1])*2;
  
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>

int main(void){
  int n,k,in,m=-1;
  cin>>n>>k;
  vi a(100);
  rep(i,k){
    cin>>in;
    a[--in]++;
    m = max(m,in);
  }
//  cout<<m+1<<endl;
  int s = m+1;
  if(a[m]>=2){
    cout<<0<<endl;
    return 0;
  }
  rep(i,100)if(i != s-1&&a[i]){
    m -= (i+1) * a[i];
//    cout<<a[i]<<" "<<i+1<<endl;
  }
  cout<<(m>=0?m:0)<<endl;
}

Measured memory_bytes: 384
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i64,
        K: i64,
        Hs: [i64; N],
    }

    // 足場dp_cost[i] : 足場(i+1)に到達するのに必要な最小のコスト
    let mut dp_cost = vec![0i64; N as usize];

    // 1つずつ決めていこう
    for n in 1..N {
        let mut min = std::i64::MAX;
        for before in (n - K)..n {
            if before < 0 {
                continue;
            }

            let cand = dp_cost[before as usize] + (Hs[n as usize] - Hs[before as usize]).abs();
            min = std::cmp::min(min, cand);
        }
        dp_cost[n as usize] = min;
    }

    let ans = dp_cost[N as usize - 1];
    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string n;
    string s = "ABC";

    cin >> n;

    cout << s + n << endl;

    return 0;
}


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

int main() {
  int N,D;
  cin >> N >> D;
  int X[N][D];
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      double su=0;
      for(int p=0;p<D;p++){
        su+=(X[i][p]-X[j][p])*(X[i][p]-X[j][p]);
      }
      double an=pow(su,0.5);
      int a=an;
      if(abs(a-an)<0.0000001)sum++;
    }
  }
  cout << sum;
}






Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  string S, T;
  cin >> S >> T;
  int N = (int)S.size();
  bool* check = new bool[26];
  for(int i = 0; i <26; i++){
    check[i] = false;
  }
  for(int i = 0; i < N; i++){
    char c = S[i];
    if(S[i] == T[i]){
      continue;
        
    }
    if(check[S[i]-'a']){
        continue;
        
    }
    check[S[i]-'a'] = true;
    char altc = T[i];
    for(int j = i+1; j < N; j++){
      if(S[j] == c && T[j] != altc){
          cout << "No" << endl;
          return 0;
          
      }
      if(T[j] == altc && S[j] != c){
          cout << "No" << endl;
          return 0;
          
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 776
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int x[110];
int y[110];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<a;i++){
		scanf("%d",x+i);
	}
	for(int i=0;i<b;i++)scanf("%d",y+i);
	for(int i=-100;i<=100;i++){
		bool ok=true;
		if(c>=i||i>d)ok=false;
		for(int j=0;j<a;j++)if(x[j]>=i)ok=false;
		for(int j=0;j<b;j++)if(y[j]<i)ok=false;
		if(ok){
			printf("No War\n");return 0;
		}
	}
	printf("War\n");
}

Measured memory_bytes: 128
import sys
MM = 998244353
n, = map(int, input().split())
xs = list(map(int, input().split()))
mm = max(xs)
cc = [0] * n
if xs[0] != 0:
    print(0)
    sys.exit()
for x in xs:
    cc[x] += 1
for i in range(mm+1):
    if cc[i] == 0:
        print(0)
        sys.exit()
if cc[0] != 1:
    print(0)
    sys.exit()
r = 1
for i in range(mm):
    r = (r * pow(cc[i], cc[i+1])) % MM
print(r)






Measured memory_bytes: 53124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>

using namespace std;

#define LLI long long int

struct mypair{
    int idx;
    int key;
    mypair(int i,int k):idx(i),key(k){

    }
    bool operator<( const mypair& right ) const {
        return key < right.key;
    }

};

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

    int n;
    cin >> n;
    vector<mypair> vec;

    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        vec.push_back(mypair(i,k));
    }

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

    int maxl = 1;
    int tmpl = 1;
    int preidx = vec[0].idx;

    for(int i = 1; i < n; i++){
        if(preidx < vec[i].idx){
            tmpl++;
            preidx = vec[i].idx;
        }else{
            if(maxl < tmpl){
                maxl = tmpl;
            }
            tmpl = 1;
            preidx = vec[i].idx;
        }
    }

    if(maxl < tmpl){
        maxl = tmpl;
    }

    cout << (n-maxl) << endl;

    return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String A = br.readLine();
		String B = br.readLine();
		String C = br.readLine();
		
		int Ai = 0;
		int Bi = 0;
		int Ci = 0;
		
		int Al = A.length();
		int Bl = B.length();
		int Cl = C.length();
		
		char turn = A.charAt(Ai++);
		while(true){
			if(turn == 'a'){
				if(Ai == Al){
					System.out.println('A');
					break;
				}
				turn = A.charAt(Ai++);
			} else if(turn == 'b'){
				if(Bi == Bl){
					System.out.println('B');
					break;
				}
				turn = B.charAt(Bi++);
			} else if(turn == 'c'){
				if(Ci == Cl){
					System.out.println('C');
					break;
				}
				turn = C.charAt(Ci++);
			}
		}
		
	}
}


Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod  1000000007
#define vect vector<long long int>
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define binsrch binary_search
int main() 
{sevensins
ll t,i,j,k,m,l,n;
    
    cin>>n;
    
    ll a[n-1],sum=0;
    multiset<ll> s;
    
    for(i=0;i<n-1;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    for(i=1;i<=n;i++)
    {
        cout<<s.count(i)<<"\n";
    }
    

return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b; cin>>a>>b;
  if(a>=13) cout<<b<<endl;
  else if(a>=6) cout<<b/2<<endl;
  else cout<<0<<endl;
  
}

Measured memory_bytes: 3636
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int n,q;

void solve(){
    int ary[110];
    memset(ary,0,sizeof(ary));

    rep(i,n) {
        int a,m;
        cin>>m;
        rep(j,m){
            cin>>a;
            ary[a]++;
        }
    }
    int ans=0;
    int max=0;

    rep(i,110) {
        if(ary[i] >= q&&max<ary[i]) {
            ans=i;
            max=ary[i];
        }
    }
    cout<<ans<<endl;
}

int main() {

    while(cin>>n>>q) {
        if(!(n+q)) return 0;

        solve();
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;cin>>n;
	int a[n+1]={0};
	for(int i=1;i<n;i++)
	{
		cin>>m;
		a[m-1]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

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

    ll k, a, b;
    cin >> k >> a >> b;

    ll res = 1 + k;
    if (a + 1 <= k) {
        k -= (a + 1);
        res = max(res, b);
        if (k % 2 == 0) {
            res = max(res, (k / 2 + 1) * b - k / 2 * a);
        }
        else {
            --k;
            res = max(res, (k / 2 + 1) * b - k / 2 * a + 1);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a,b,p;
int main()
{
    cin>>a>>b;
    if(a<=0&&b>=0)
    {
        cout<<"Zero";
        return 0;
    }
    if(a>0) p=0;
    else p=(b+1-a)%2;
    if(p) cout<<"Negative";
    else cout<<"Positive";
    return 0;
}


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

int solve(long double d,long double ra,long double rb){
  if(ra+rb<d){
    return 0;
  }else if(ra+d<rb){
    return -2;
  }else if(rb+d<ra){
    return 2;
  }else{
    return 1;
  }
  assert(0);
  return -100;
}



int main(){
  long double xa,xb,ya,yb,ra,rb;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    cout<<solve(sqrt(pow(ya-yb,2)+pow(xa-xb,2)),ra,rb)<<endl;
  }
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    int n = s.size();
    int ans = 0;
    rep(i,0,n){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll n, x, m;
    cin >> n >> x >> m;

    // generate the sequence until a cycle is found 
    // profit?

    ll curr = x;
    ll ans = 0;
    vector<bool> vis(m + 1);
    vector<ll> s; // stack
    vector<ll> repeated;
    int cnt = 1; // current term
    while(cnt <= n) {
        if(!vis[curr]) {
            vis[curr] = true;
            s.pb(curr);
            ans += curr;
            curr = curr * curr % m; 
        } else {
            while(s.back() != curr) {
                repeated.pb(s.back());
                s.pop_back();
            }
            repeated.pb(s.back());
            break;
        }
        cnt++;
    }
    cnt--;
    reverse(all(repeated));

    n -= cnt;
    // for the remainder find the cycle
    if(n > 0) {
        ll cyclen = repeated.size();
        ll times = n / cyclen;
        ll ex = n % cyclen;
        for(int i = 0; i < repeated.size(); i++) {
            ans += repeated[i] * times;
            if(i < ex) {
                ans += repeated[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

long long max(long long a, long long b)
{
    if(a > b)return a;
    return b;
}
long long min(long long a, long long b)
{
    if(a < b)return a;
    return b;
}
int main()
{
    int n;
    cin>>n;
    long long a[n+1],b;
    long long ans=0;
    for(int i=0;i<n+1;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        cin>>b;
        ans += min(b,a[i]);
        b-=a[i];
        if(b>0)
        {
            ans += min(b,a[i+1]);
            a[i+1] = max(0,a[i+1]-b);
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int main()
{ 
    string s;
    cin>>s;
    if(s=="SUN"){cout<<7<<endl;}
    if(s=="MON"){cout<<6<<endl;}
    if(s=="TUE"){cout<<5<<endl;}
    if(s=="WED"){cout<<4<<endl;}
    if(s=="THU"){cout<<3<<endl;}
    if(s=="FRI"){cout<<2<<endl;}
    if(s=="SAT"){cout<<1<<endl;}
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
  int n,x;
  cin >> n >> x;
  int a[n],i,mina=x,ret=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    x-=a[i];
    mina=min(mina,a[i]);
    ret++;
  }
  ret+=x/mina;
  cout << ret << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) {
        cin >> c[i][j];
    }

    vint a(3), b(3);
    a[0] = 0;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    rep(i, 3) rep(j, 3) {
        if (c[i][j] != (a[i] + b[j])) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;


int main(){
    int N;
    cin >> N;
    bool ans=0;
    for(int i=0;i<9;i++){
     for(int j=0;j<9;j++){
         if(N==(i+1)*(j+1)){ans=1;}
     ;}
    ;}
    if(ans==0){cout<<"No"<<endl;}
    else cout<<"Yes"<<endl;
return 0;


}  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;
using namespace std;
using ll = long long;

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s == u) a--;
  else b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 3624
function Main(input) {
	var s = input.trim();
	var sum = 0;
	for(var i=0;i<s.length;i++){
		sum+=Number(s[i]);
	}
	if(Number(s) % sum == 0){
		console.log('Yes');
	} else {
		console.log('No');
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

using ll = long long;

ll cost(ll a, ll b, ll c)
{
  ll ma = max(a, max(b, c));
  ll mi = min(a, min(b, c));
  return ma - mi;
}

ll calc()
{
  ll H, W;
  cin >> H >> W;
  ll res = min(H, W);
  if (H % 3 == 0 || W % 3 == 0) return 0;
  ll h = H + 1;
  while (--h) {
    ll a = W * h;
    ll b = H * W - a;
    ll c = W / 2 * (H - h);
    ll d = W * (H - h) - c;
    res = min(res, cost(a, c, d));
  }
  ll w = W + 1;
  while (--w) {
    ll a = H * w;
    ll b = H * W - a;
    ll c = H / 2 * (W - w);
    ll d = H * (W - w) - c;
    res = min(res, cost(a, c, d));
  }
  return res;
}

int main()
{
  cout << calc() << endl;
}

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

using namespace std;

const int maxn = 100100;

int n,a[maxn];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    ll sum=0;
    a[-1]=0; a[0]=0;
    a[n+1] = a[n];
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]);
  //  cout<<sum<<endl;
    for (int i=1;i<=n;i++) cout<<sum-abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1])<<endl;
}


Measured memory_bytes: 1664
module Main (main) where

import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [x,a,b] <- readInts
  print . showAnswer $ solve (x,a,b)

type Input  = (Int, Int, Int)
type Output = Bool

solve :: Input -> Output
solve (x,a,b) = (xa < xb)
  where
    xa = abs (x-a)
    xb = abs (x-b)

showAnswer :: Output -> Answer
showAnswer = AB

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | AB Bool

instance Show Answer where
  show (YesNo b) = if b then "Yes" else "No"
  show (AB b)    = if b then "A"   else "B"

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main(){
  int yy , mm,dd;
  char w,w1;
  cin >> yy >> w >> mm >> w1 >> dd;
  if(mm > 4)
    cout << "TBD" << endl;
  else 
    cout << "Heisei" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

class Nums{
    public:
        int a, b, c;
    Nums(int _a,int _b, int _c){
        a = _a;
        b = _b;
        c = _c;
    }
    bool operator <(const Nums &other) const{
        return a < other.a;
    }
};

int main ()
{
    int X,Y,Z;
    int K;
    cin>>X>>Y>>Z;
    cin>>K;
    vector<ll> A(X),B(Y),C(Z);
    for(int i = 0; i < X; i++)  cin>>A[i];
    for(int i = 0; i < Y; i++)  cin>>B[i];
    for(int i = 0; i < Z; i++)  cin>>C[i];
    sort(A.begin(),A.end(),greater<ll>());
    sort(B.begin(),B.end(),greater<ll>());
    sort(C.begin(),C.end(),greater<ll>());
    priority_queue <pair<ll,Nums>>pq;
    pq.push(make_pair(A[0]+B[0]+C[0],Nums(0,0,0)));
    set<ll> s;
    s.insert(0);
    vector<ll> ans;
    while(ans.size()<K){
        auto v = pq.top();pq.pop();
        ans.push_back(v.first);
        if(v.second.a != X-1){
            int a = v.second.a + 1;
            int b = v.second.b;
            int c = v.second.c;
            //hashをつくり重複を管理
            int hash = (a<<20) + (b<<10) + c;
            if(s.find(hash) == s.end()){
                s.insert(hash);
                pq.push(make_pair(A[a]+B[b]+C[c],Nums(a,b,c)));
            }
        }
         if(v.second.b != Y-1){
            int a = v.second.a ;
            int b = v.second.b + 1;
            int c = v.second.c;
            //hashをつくり重複を管理
            int hash = (a<<20) + (b<<10) + c;
            if(s.find(hash) == s.end()){
                s.insert(hash);
                pq.push(make_pair(A[a]+B[b]+C[c],Nums(a,b,c)));
            }
        }
         if(v.second.c != Z-1){
            int a = v.second.a;
            int b = v.second.b;
            int c = v.second.c + 1;
            //hashをつくり重複を管理
            int hash = (a<<20) + (b<<10) + c;
            if(s.find(hash) == s.end()){
                s.insert(hash);
                pq.push(make_pair(A[a]+B[b]+C[c],Nums(a,b,c)));
            }
        }
    }
    //sort(ans.begin(),ans.end(),greater<ll>());
    REP(i,K){
        cout<<ans[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int r, d, x;
  cin >> r >> d >> x;
  
  rep(_,10) {
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque
from collections import Counter
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
t = [[-1]*W for _ in range(H)]
q = deque([[0,0]])
t[0][0] = 0
while len(q) > 0:
  qq = q.popleft()
  dh = [-1,0,1,0]
  dw = [0,1,0,-1]
  for i in range(4):
    h = qq[0] + dh[i]
    w = qq[1] + dw[i]
    if 0 <= h < H and 0 <= w < W:
      if s[h][w] == "#" or t[h][w] != -1: continue
      t[h][w] = t[qq[0]][qq[1]] + 1
      q.append([h,w])

X = 0
for i in range(H):
  c = Counter(s[i])
  X += c["."]
if t[H-1][W-1] == -1:
  print(-1)
else:
  print(X-1-t[H-1][W-1])

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

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)
const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
#define MAX_N (int)2e5+20
typedef long long ll;
using namespace std;

string s,t;
string ans;
int main(){
    cin >> s >> t;
    per(i,s.size()-t.size()+1,0){
        bool check = true;
        ans = s;
        rep(j,0,t.size()){
            if(ans[i+j] == '?') ans[i+j] = t[j];
            else if(ans[i+j] != t[j]){
                check = false;
                break;
            }
        }
        if(check){
            rep(k,0,s.size()){
                if(ans[k] == '?') ans[k] = 'a';
            }
            cout << ans << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1ll << 60);
const auto MOD = static_cast<ll>(1e9 + 7);
const auto NIL = -1;

/************* Utils *************/
struct Node {
    ll parent, left, right;
};

vector<Node> Tree;
vector<ll> Depth;

void setDepth(ll u, ll p) {
    Depth[u] = p;
    if (Tree[u].right != NIL) {
        setDepth(Tree[u].right, p);
    }
    if (Tree[u].left != NIL) {
        setDepth(Tree[u].left, p + 1);
    }
}

void printChildren(ll u) {
    ll c = Tree[u].left;
    bool first = true;
    cout << "[";
    while (c != NIL) {
        if (first) {
            cout << c;
            first = false;
        }
        else {
            cout << ", " << c;
        }
        c = Tree[c].right;
    }
    cout << "]";
}

/*********** Variables ***********/
ll N, ROOT;

/*********** Functions ***********/
bool init() {
    cin >> N;
    Tree.resize(N, Node{NIL, NIL, NIL});
    Depth.resize(N);
    for (ll i = 0; i < N; i++) {
        ll id, k, c, l; cin >> id >> k;
        for (ll j = 0; j < k; j++) {
            cin >> c;
            if (j == 0) {
                Tree[id].left = c;
            }
            else {
                Tree[l].right = c;
            }
            l = c;
            Tree[c].parent = id;
        }
    }
    return true;
}

void solve() {
    for (ll i = 0; i < N; i++) {
        if (Tree[i].parent == NIL) {
            ROOT = i;
            break;
        }
    }
    setDepth(ROOT, 0);
}

void output() {
    for (ll i = 0; i < N; i++) {
        cout << "node " << i << ": ";
        cout << "parent = " << Tree[i].parent << ", ";
        cout << "depth = " << Depth[i] << ", ";
        if (Tree[i].parent == NIL) {
            cout << "root, ";
        }
        else if (Tree[i].left == NIL) {
            cout << "leaf, ";
        }
        else {
            cout << "internal node, ";
        }
        printChildren(i);
        cout << endl;
    }
}

int main() {
    init();
    solve();
    output();
    return 0;
}


Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	if(s[2]==s[3] && s[4]==s[5]) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
mod = 10**9+7
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = list(input())
n.reverse()
nnn = len(n)
di = 1
dp = [0 for i in range(13)]
d = [0 for i in range(13)]

if n[0] == '?':
	for i in range(10):
		d[i] = 1
else:
	d[int(n[0])] = 1

for i in range(1,nnn):
	dp = [0 for i in range(13)]
	di *= 10
	di %= 13
	if n[i] == "?":
		for j in range(10):
			j = j * di
			j %= 13
			for kk in range(13):
				dp[(j + kk)%13] += d[kk]
				dp[(j + kk)%13] %= mod
	else:
		k = int(n[i])
		k = k * di
		k %= 13
		for kk in range(13):
			dp[(k + kk)%13] += d[kk]
			dp[(k + kk)%13] %= mod
	d = dp[:]
print(d[5]%mod)













Measured memory_bytes: 49540
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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


int main(void) {
    set<int> s;
    int a, b, c;

    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    if (((int) s.size()) == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Attack Survival
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long K = sc.nextLong();
            int Q = sc.nextInt();

            int[] P = new int[N];
            for (int i = 0; i < Q; i++) {
                int n = sc.nextInt() - 1;
                P[n]++;
            }

            StringBuilder ans = new StringBuilder();

            for (int i = 0; i < N; i++) {
                if (K - Q + P[i] > 0) {
                    ans.append("Yes");
                } else {
                    ans.append("No");
                }
                ans.append("\n");
            }

            System.out.print(ans.toString());
        }
    }

}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll cnt=0;
    ll len=s.size();
    rep(i,0,len){
        cnt=cnt+(int)s[i]-48;
        //cout << int(s[i]) ENDL;
    }

    //cout << cnt ENDL;
    if(cnt%9==0) cout << "Yes" ENDL;
    //else if(cnt==0) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 6096
n,m=map(int,input().split())
ab=[]
cd=[]
for i in range(n):
    l=list(map(int,input().split()))
    ab.append(l)
for i in range(m):
    l=list(map(int,input().split()))
    cd.append(l)

for i in range(n):
    p=m
    r=100000000000000000
    for j in range(m):
        if r>abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
            r=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            p=j+1
        elif r==abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
            if p>j+1:
                p=j+1
    print(p)


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
using namespace std;

int main(){
    FAST;
    int n,l;cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
}




Measured memory_bytes: 3596
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod 1e9+7
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define mp make_pair

int main()
{
    ll n;
    in(n);
    map<ll,ll> m;
    for(ll i=0;i<n;i++) {
        ll a;in(a);
        m[a-1]=i;
    }
    for(auto it=m.begin();it!=m.end();it++)
    cout<<it->second+1<<" ";
    
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,K;
ll pos[200005];
ll neg[200005];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;
ll p1=0;
ll n1=0;
rep(i,N){
    ll a;
    cin>>a;
    if(a>=0){
        pos[p1++]=a;
    }
    else{
        neg[n1++]=-a;
    }
}
sort(pos,pos+p1);
sort(neg,neg+n1);
if(N==K){
    ll ans=1;
    rep(i,p1) ans=ans*pos[i]%mod;
    rep(i,n1) ans=ans*(mod-neg[i])%mod;
    cout<<ans<<endl;
    exit(0);
}
if(K%2==1&&n1==N){
    ll ans=1;
    rep(i,K) ans=ans*(mod-neg[i])%mod;
    cout<<ans<<endl;
    exit(0);   
}
ll ans=1;
while(K){
    if(K>=2&&n1>=2&&(p1<=1||(p1>=2&&neg[n1-1]*neg[n1-2]>=pos[p1-1]*pos[p1-2]))){
        ans=ans*neg[--n1]%mod;
        ans=ans*neg[--n1]%mod;
        K-=2;
    }
    else{
        ans=ans*pos[--p1]%mod;
        K--;
    }
}
cout<<ans<<endl;


}
    


Measured memory_bytes: 5152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    fo(i,1,10){
        if(n%i == 0){
            if(n/i <= 9) return cout << "Yes",0;
        }
    }
    cout << "No";

    return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll q=max(d,c),r=min(c,d);
  while(q%r!=0){
    ll temp=q;
    q=r;
    r=temp%r;
  }
  ll l=c*d/r;
  ll ca,cb,da,db,la,lb;
  ca=(a-1)/c;cb=b/c;da=(a-1)/d;db=b/d;la=(a-1)/l;lb=b/l;
  cout<<b-a+1-(cb-ca)-(db-da)+(lb-la)<<endl;
  return 0;
}


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



// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  char a;
  cin >> a;

  if('A' <= a && a <= 'Z') cout << 'A' << endl;
  if('a' <= a && a <= 'z') cout << 'a' << endl;


    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (auto &&i : p) scanf("%d", &i);
    for (auto &&j : q) scanf("%d", &j);
    for (auto &&k : r) scanf("%d", &k);
    sort(p.begin(),p.end(), greater<>());
    sort(q.begin(),q.end(), greater<>());
    sort(r.begin(),r.end(), greater<>());
    ll S = 0;
    GPQ<int> Q;
    for (int i = 0; i < x; ++i) {
        S += p[i];
        Q.emplace(p[i]);
    }
    for (int i = 0; i < y; ++i) {
        S += q[i];
        Q.emplace(q[i]);
    }
    ll ans = S;
    for (int i = 0; i < min(c, x+y); ++i) {
        S -= Q.top(); Q.pop();
        S += r[i];
        ans = max(ans, S);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2552
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
}

Measured memory_bytes: 21716
fn main() {
    let mode = "a";
    if mode == "a" {
        a::answer();
    }
}

mod a {
    use std;
    use std::io::Read;

    pub fn answer() {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();

        let mut ite = buf.split_whitespace();
        let a = ite.next().unwrap().parse::<i32>().unwrap();
        let b = ite.next().unwrap().parse::<i32>().unwrap();

        let res = calc(a, b);
        println!("{}", res);
    }
    fn calc(a: i32, b: i32) -> i32 {
        let tasu = a + b;
        let hiku = a - b;
        let kakeru = a * b;
        std::cmp::max(tasu, std::cmp::max(hiku, kakeru))
    }

    #[cfg(test)]
    mod tests {
        use super::*;
        #[test]
        fn test1() {
            assert_eq!(calc(-13, 3), -10);
        }
        #[test]
        fn test2() {
            assert_eq!(calc(1, -33), 34);
        }
        #[test]
        fn test3() {
            assert_eq!(calc(13, 3), 39);
        }
    }

}


Measured memory_bytes: 4352