akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}


signed main(){
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A*N,B)<<endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

const int MAX = 300000;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
int a[MAX];
ll cnt = 0;

void merge(int a[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    rep(i, n1) L[i] = a[left + i];
    rep(i, n2) R[i] = a[mid + i];
    L[n1] = R[n2] = 1e9 + 5;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        if (L[i] <= R[j])
        {
            a[k] = L[i++];
        }
        else
        {
            a[k] = R[j++];
            cnt += n1 - i;
        }
    }
}

void mergesort(int a[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergesort(a, left, mid);
        mergesort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main()
{
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    mergesort(a, 0, n);

    OP(cnt);
    return 0;
}


Measured memory_bytes: 4656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, 0, N) {
        cin >> S[i];
    }
    int ans = 0;
    int a = 0, b = 0, ab = 0;
    REP(i, 0, N) {
        REP(j, 0, S[i].size() - 1) {
            if (S[i][j] == 'A' && S[i][j + 1] == 'B') {
                ans++;
            }
        }
        if (S[i][0] == 'B' && S[i].back() == 'A') {
            ab++;
        } else if (S[i][0] == 'B') {
            b++;
        } else if (S[i].back() == 'A') {
            a++;
        }
    }
    dump(a);
    dump(b);
    dump(ab);
    if (a == 0 && b == 0) {
        ans += max(ab - 1, 0);
    } else {
        if (a < b) {
            ans += a;
            b -= a;
            a = 0;
        } else {
            ans += b;
            a -= b;
            b = 0;
        }
        ans += min(a, ab);
        ans += min(b, ab);
        ab -= min(a, ab);
        ab -= min(b, ab);
        ans += ab;
    }

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,k,sum=0;
  cin>>n;
  string s="";
  while(n){
    n--;
    ll rem=n%26;
    s=char('a'+rem)+s;
    n=n/26;
  }
  cout<<s<<endl;

}


Measured memory_bytes: 3604
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
    for j in range(i, i+len(t)):
        if s[j] != "?" and s[j] != t[j-i]:
            break
    else:
        l.append(s[:i]+t+s[i+len(t):])
if len(l) == 0:
    print("UNRESTORABLE")
    exit()
l.sort()
print(l[0].replace("?", "a"))

Measured memory_bytes: 8912
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<=2;i++)
	{
		if(s[i]==t[i])
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

const int N = 3050;
int s[N][N];
int a[2][N][N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x, y; char c;
        cin >> x >> y >> c;
        if (c == 'B') y += k;
        x %= 2 * k;
        y %= 2 * k;
        s[x][y]++;
        s[x + k][y]--;
        s[x][y + k]--;
        s[x + k][y + k]++;
    }

    for (int i = 0; i < 3 * k; i++)
        for (int j = 0; j < 3 * k; ++j)
            s[i][j + 1] += s[i][j];

    for (int i = 0; i < 3 * k; i++)
        for (int j = 0; j < 3 * k; ++j)
            s[i + 1][j] += s[i][j];


    for (int i = 0; i < 3 * k; i++)
        for (int j = 0; j < 3 * k; ++j) {
            int p = (i / k + j / k) % 2;
            a[p][i % k][j % k] += s[i][j];
        }

    int res = 0;
    for (int p = 0; p < 2; ++p)
        for (int i = 0; i < k; ++i)
            for (int j = 0; j < k; ++j)
                res = max(res, a[p][i][j]);

    printf("%d\n", res);
}

Measured memory_bytes: 63104
n, a = map(int, input().split())
x = list(map(int, input().split()))
s = sum(x)
dp = [[0] * (s * n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    dp[i][x[i - 1]] = 1
    for j in range(1, s + 1):
        dp[i][j] += dp[i - 1][j]
    for j in range(s + 1, s * n + 1):
        dp[i][j] = dp[i - 1][max(0, j - s - x[i - 1])] + dp[i - 1][j]
ans = 0
for i in range(1, n + 1):
    if i * a > s:
        print(ans)
        exit()
    ans += dp[n][i * a + (i - 1) * s]
print(ans)

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    REP(i, s.size()) {
        cout << "x";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: i64,
    }

    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2240
N, K = map(int, input().split())
XY = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 10 ** 20
for xl in range(N):
    for xr in range(xl + 1, N):
        Ysub = sorted([y for x, y in XY[xl:xr + 1]])
        for i in range(xr - xl - K + 2):
            Yk = Ysub[i:i + K] + [XY[xr][1], XY[xl][1]]
            ans = min(ans, (XY[xr][0] - XY[xl][0]) * (max(Yk) - min(Yk)))

print(ans)


Measured memory_bytes: 43612
import numpy as np
from numba import njit


@njit('f8(i8,i8,i8,i8,f8[:,:,:])')
def get_expv(N, i, j, k, expv):
    result = 0.0
    if expv[i][j][k] != -1:
        return expv[i][j][k]
    nonlp = 1.0 - (N-i-j-k) / N
    result += 1
    if i != 0:
        result += get_expv(N, i-1, j, k, expv) * (i / N)
    if j != 0:
        result += get_expv(N, i+1, j-1, k, expv) * (j / N)
    if k != 0:
        result += get_expv(N, i, j+1, k-1, expv) * (k / N)
    result /= nonlp
    expv[i][j][k] = result
    return result

def main():
    N = int(input())

    sushi_count = {1:0, 2:0, 3:0}
    for a in map(int, input().split()):
        sushi_count[a] += 1
    sh = (N+1, N-sushi_count[1]+1, sushi_count[3]+1)
    expv = np.full(sh, -1.0)

    expv[0][0][0] = 0.0

    print(get_expv(N, sushi_count[1], sushi_count[2], sushi_count[3], expv))

if __name__ == '__main__':
    main()

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

int main(){
	int A,B,C;

	cin >> A >> B >> C;

	if(A==B && B == C){
		cout << "No";
	}
	else if(A != B && B != C && C != A){
		cout << "No";
	}
	else{
		cout << "Yes";
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=1e5+5;
int n,len,q,pos[N];
//int cnt_0,cnt_1,buk_0[N],buk_1[N];
bool stat[N];//0: clockwise, 1: counter

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("d.in","r",stdin);
#endif
	n=nxi(),len=nxi(),q=nxi();
	for(int i=1; i<=n; ++i){
		pos[i]=nxi(),stat[i]=nxi()-1;
	}
	int cyc=q/len,rest=q-cyc*len;
	lint dlt=0;
	for(int i=1; i<=n; ++i){
		if(stat[i]==0){
			dlt+=cyc;
			int tgt=pos[i]+rest;
			if(tgt>=len) ++dlt,tgt-=len;
			pos[i]=tgt;
		}
		else{
			dlt-=cyc;
			int tgt=pos[i]-rest;
			if(tgt<0) --dlt,tgt+=len;
			pos[i]=tgt;
		}
	}
	std::sort(pos+1,pos+n+1);
	dlt%=n;
	if(dlt<0) dlt+=n;
	for(int i=dlt+1; i<=n; ++i){
		printf("%d\n",pos[i]);
	}
	for(int i=1; i<=dlt; ++i){
		printf("%d\n",pos[i]);
	}
	return 0;
}

Measured memory_bytes: 1664
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int K, S, X, Y, ans=0;
	cin >> K >> S;
	for (X = 0; X <= K; ++X){
		for (Y = 0; Y <= K; ++Y){
			if (0 <= S - X - Y && S - X - Y <= K) 
				++ans;
		}
	}
	cout << ans << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = []
n.times do |i|
    line = gets.chomp
    s << line
end
ac,wa,tle,re = [],[],[],[]

s.each do |i|
    if i == "AC"
        ac << i
    elsif i == "WA"
        wa << i
    elsif i == "TLE"
        tle << i
    else
        re << i
    end
end

puts "AC x #{ac.size}"
puts "WA x #{wa.size}"
puts "TLE x #{tle.size}"
puts "RE x #{re.size}"

Measured memory_bytes: 23184
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<ll> dp(13);
  dp[0] = 1;

  rep(i, 0, n) {
    decltype(dp) next(13);
    rep(j, 0, 13) {
      if (s[i] == '?') {
        rep(k, 0, 10)(next[(j * 10 + k) % 13] += dp[j]) %= MOD;
      } else {
        int x = s[i] - '0';
        (next[(j * 10 + x) % 13] += dp[j]) %= MOD;
      }
    }
    dp = next;
  }

  cout << dp[5] << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;


ll factorial(int n)
{
    ll res = 1;
    rep(i, 1, n + 1)
        res = (res * (ll)i) % MOD;
    return res;
}

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

    ll ans;
    if (abs(n - m) > 1)
        ans = 0;
    else if (n == m)
        ans = (2ll * factorial(n) * factorial(m)) % MOD;
    else
        ans = (factorial(n) * factorial(m)) % MOD;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long dp[1145][1145];
char F[1145][1145];

int main() {
    int H,W;cin >> H >> W;
    for(int i = 0;i<H;i++){
        for(int j = 0;j < W;j++) cin >> F[i][j];
    }
    for(int i = 0;i<1145;i++){
        for(int j = 0;j<1145;j++) dp[i][j] = 0;
    }
    dp[0][0] = 1;

    for(int i = 0;i<=H;i++){
        for(int j = 0;j<=W;j++){
            if(F[i+1][j] == '.' && F[i][j] != '#'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(F[i][j+1] == '.' && F[i][j] != '#'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 11648
#include<cstdio>
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int MAXN = 2e5 + 10;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, a[MAXN];
main() {
	N = read();
	for(int i = 1; i <= N; i++) a[i] = read();
	int l = 1, sxor = 0, sum = 0, ans = 0;
	for(int i = 1; i <= N; i++) {
		sum += a[i]; sxor ^= a[i];
		while(sxor != sum && (l < i)) 
			sum -= a[l], sxor ^= a[l++];
		ans += i - l + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=101;
const ll INF=0x3f3f3f3f;
ll n,pos[MAX],r[MAX],g1[MAX],fin=-INF;
void track(ll x,ll d){
    ll p1=0,p2=0;
    if(x>n){
        fin=max(fin,d);
        return;
    }
    if(r[x]>=0) p1=1,p2=0;
    else if(x<=n/3) p1=1,p2=1;
    else if(x<=n/2){
        if(pos[2*x]||r[x]+r[2*x]<0) p1=0,p2=1;
        else p1=1,p2=0;
    }
    else p1=0,p2=1;
    if(p1) track(x+1,d);
    if(p2){
        for(ll i=x;i<=n;i+=x) {
            if(pos[i]==0) d-=r[i];
            pos[i]++;
        }
        track(x+1,d);
        for(ll i=x;i<=n;i+=x) pos[i]--;
    }
}
int main(){
    ll t=0;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++) scanf("%lld",&r[i]);
    for(ll i=1;i<=n;i++) t+=r[i];
    track(1,t);
    printf("%lld\n",fin);
}


Measured memory_bytes: 384
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-C: Stable Sort

#include <cstring>
#include <algorithm>
#include <iostream>

struct Card {
  char suit;
  unsigned int rank;
  bool operator<(const Card& rhs) const { return rank < rhs.rank; }
  bool operator!=(const Card& rhs) const { return rank != rhs.rank || suit != rhs.suit; }
};

std::ostream& operator<<(std::ostream& os, const Card& card)
{
  return os << card.suit << card.rank;
}

std::istream& operator>>(std::istream& is, Card& card)
{
  return is >> card.suit >> card.rank;
}

static void print_cards(const Card cards[], const unsigned int n)
{
  const char* sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void copy_cards(Card dst[], const Card src[], const unsigned int n)
{
  std::memcpy(dst, src, sizeof(dst[0])*n);
}

static bool is_equal_cards(const Card cards1[], const Card cards2[], const unsigned int n)
{
  for (auto i = 0u; i < n; ++i) {
    if (cards1[i] != cards2[i]) {
      return false;
    }
  }
  return true;
}

static void bubble_sort(Card cards[], const unsigned int n)
{
  for (auto j = 0u; j < n-1; ++j) {
    for (auto i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

static void selection_sort(Card cards[], const unsigned int n)
{
  for (auto i = 0u; i < n-1; ++i) {
    auto min_j = i;
    for (auto j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  Card cards1[n], cards2[n];
  for (auto i = 0u; i < n; ++i) {
    std::cin >> cards1[i];
  }
  copy_cards(cards2, cards1, n);
  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);

  if (is_equal_cards(cards1, cards2, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }
}

// eof

Measured memory_bytes: 3152
icase=0
if icase==0:
    h,w=map(int,input().split())
    a=[]
    s=["#"]*w
    st="".join(s)
    for i in range(h):
        ai=input()
        a.append(ai)
    print("#"+st+"#")
    for i in range(h):
        print("#"+a[i]+"#")
    print("#"+st+"#")
    

Measured memory_bytes: 3060
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

type Primes []bool

func NewPrimes(n int) Primes {
	m := n + 1
	p := make([]bool, m)
	for i := 3; i < m; i += 2 {
		p[i] = true
	}
	p[2] = true
	for i := 3; i*i < m; i += 2 {
		if !p[i] {
			continue
		}
		for j := i + i; j < m; j += i {
			p[j] = false
		}
	}

	return p
}

func (ps Primes) IsPrime(x int) bool {
	return ps[x]
}

func main() {
	defer stdout.Flush()
	p := NewPrimes(55555)
	m := make([][]int, 5)
	for i := 0; i <= 55555; i++ {
		if !p.IsPrime(i) {
			continue
		}
		rem := i % 5
		m[rem] = append(m[rem], i)
	}

	// readString() string
	// readInt() int
	// readIntSlice(n int) []int
	// readLengthAndSlice() []int

	n := readInt()
	sp := ""
	for i := 0; i < n; i++ {
		printf("%s%d", sp, m[1][i])
		sp = " "
	}
	println()
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    char a,b;
    cin >> a >> b;
    if(a == b)cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	string T = S;
	reverse(T.begin(), T.end());
	S += T;

	char mn = 'z';
	for (int i = 0; i < N; i++) {
		mn = min(mn, S[i]);
	}
	vector<string> res;
	for (int i = 0; i <= N; i++) {
		T = "";
		for (int j = 0; j < N; j++) {
			T.push_back(S[i + j]);
		}
		res.push_back(T);
	}
	if (K > 30) {
		K = 30;
	}

	if (K > 1) {
		for (int i = N; i < 2 * N; i++) {
			if (S[i] == mn && (i == 2 * N - 1 || S[i + 1] != mn)) {
				int j = i;
				for (;; j--) {
					if (j == -1 || S[j] != mn)break;
				}

				T = "";
				for (int k = 0; k < min(N, (i - j) << (K - 1)); k++) {
					T.push_back(mn);
				}
				for (; j >= 0; j--) {
					if (T.size() == N)break;
					T.push_back(S[j]);
					
				}
				if (T.size() == N) {
					res.push_back(T);
				}
			}
		}
	}
	sort(res.begin(), res.end());


	cout << res[0] << endl;
}

Measured memory_bytes: 52096
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int sum;
int main(void){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    sum = max({ a,b,c });
    rep(i, k) {
        sum *= 2;
    }
    cout << a + b + c - max({ a,b,c }) + sum << "\n";
    return 0;
}

Measured memory_bytes: 3620
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
a3=list(map(int, input().split()))
n=input()
b=[int(input())]
for i in range(int(n)-1):
    b.append(int(input()))


if b.count(a1[0])==1 and b.count(a1[1])==1 and b.count(a1[2])==1:
    print("Yes")
    exit()
if b.count(a2[0])==1 and b.count(a2[1])==1 and b.count(a2[2])==1:
    print("Yes")
    exit()
if b.count(a3[0])==1 and b.count(a3[1])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[0])==1 and b.count(a2[0])==1 and b.count(a3[0])==1:
    print("Yes")
    exit()
if b.count(a1[1])==1 and b.count(a2[1])==1 and b.count(a3[1])==1:
    print("Yes")
    exit()
if b.count(a1[2])==1 and b.count(a2[2])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[0])==1 and b.count(a2[1])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[2])==1 and b.count(a2[1])==1 and b.count(a3[0])==1:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3188
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();
       int x,y,z;
       x = a;
       a = b;
       y = b;
       b = x;
       z = c;
       a = z;
       c = y;
       System.out.println(a);
       System.out.println(b);
       System.out.println(c); 
    }
}

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

int n, K;
long long Ans = 0;

void Init()
{
	scanf("%d%d", &n, &K);
}

void Solve()
{
	for (int i = K + 1; i <= n; ++i) {
		Ans += max(0, (n % i) - K + 1);
		Ans += (n / i) * (i - K);
		if (K == 0) --Ans;
	}
	printf("%lld\n", Ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}


Measured memory_bytes: 256
import math
A,B,C,D,E,F = map(int, input().split())
result_noudo=None
result_satosui=None
result_sato=None

for a in range(math.floor(F/100*A)+1):
    for b in range(math.floor((F-100*A*a)/100*B)+1):
        for c in range(math.floor((F-100*A*a-100*B*b)/C)+1):
            for d in range(math.floor((F-100*a*A-100*b*B-C*c)/D)+1):
                sum_under=100*a*A+100*b*B+C*c+D*d
                if (a==0 and b==0) or (d==0 and c==0):
                    continue
                sum_top=C*c+D*d
                noudo=(100*sum_top)/sum_under
                if sum_under<=F and noudo<=(100*E)/(100+E) and (result_noudo==None or noudo>result_noudo):
                    result_noudo=noudo
                    result_satosui=sum_under
                    result_sato=sum_top
if result_noudo==None:
    result_satosui=100*A
    result_sato=0
print(str(result_satosui)+" "+str(result_sato))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string stri ;
  int c[11];
  int result = 0;
  int j = 0; 
  
  c[0] = 0 ;
  
  cin >> stri ;
  
  for (int i = 0; i < stri.size(); i++) {
    if ((stri.at(i) == 'A')||(stri.at(i) == 'C')||(stri.at(i) == 'G')||(stri.at(i) == 'T')){
      
    }else{
      j = j + 1;
      c[j] = i + 1;
    }
  }
  
  j = j + 1;
  c[j] = stri.size() + 1;
  
  for (int k = 0; k < j ; k++){
    if (result < c[k+1] -1 - c[k]){
      result = c[k+1] -1 - c[k];
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
function main(input) {
  var N = input[0]-0;
  var T = input[1].split(" ")[0]-0;
  var A = input[1].split(" ")[1]-0;
  var H = input[2].split(" ").map(v=>v-0);
  var ans = 0;
  var min = null;
  H.forEach((v,i)=>{
    var dis = Math.abs(A-(T-v*0.006));
    if(min===null || Math.abs(min) >= dis){
      min = dis;
      ans = i+1;
    }
  });
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7500
while data = gets do
	if data == nil
		break
	end
	
	nums = data.split().map(&:to_f)
	a = 1/(nums[0]*nums[4]-nums[1]*nums[3])
	x = (nums[4]*nums[2]-nums[1]*nums[5])*a
	y = (nums[0]*nums[5]-nums[3]*nums[2])*a
	
	puts sprintf("%.3f %.3f", x+0.0,y+0.0)
end

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int ans;
  int sum = A+B;
  if(sum%2==0){
    ans = sum/2;
    cout << ans << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
loop do
  w, h = gets.split.map(&:to_i)
  break if w + h == 0
  
  field = h.times.map {gets.split.map(&:to_i)}
  dp = Array.new(h) {Array.new(w, 0)}
  w.times {|x| dp[h - 1][x] = 1 if field[h - 1][x] != 1}
  
  (h - 2).downto(0) do |y|
    w.times do |x|
      case field[y][x]
      when 2
        if y + 2 == h
          dp[y][x] = 1
        else
          dp[y][x] = dp[y + 2][x]
        end
      when 0
        s = 0
        [-1, 0, 1].each do |dx|
          x1 = x + dx
          next if x1 < 0 || x1 == w
          next if dx.nonzero? && field[y + 1][x1] == 2
          s += dp[y + 1][x1]
        end
        dp[y][x] = s
      end
    end
  end
  
  puts dp[0].sum
end



Measured memory_bytes: 6908
n,t = map(int,input().split())
lstct = [list(map(int,input().split())) for i in range(n)]
ans = 1001

for lst in lstct:
    if lst[1] <= t:
        ans = min(ans,lst[0])
else:
    if ans == 1001:
        ans = "TLE"

print(ans)

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){

    int X;
    cin >> X;

    for(int i = X; i <= 100005; i++){
        if(IsPrime(i)){
            cout << i << endl;
            return 0;
        }

    }
    return 0;
}



Measured memory_bytes: 256
STR = "abcdefghij"
def dfs(n, depth, kind, s)
  if depth >= n
    puts s
    return
  end
  kind.times do |i|
    dfs(n, depth + 1, kind, s + STR[i])
  end
  dfs(n, depth + 1, kind + 1, s + STR[kind])
end

n = gets.to_i
dfs(n, 0, 0, "")


Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * Property Distribution
 */
public class Main {

	static char DISTRIBUTED = 0;
	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int h = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int w = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			// read in.
			int[][] prop = new int[h + 2][w + 2];
			for (int i = 1; i < h + 1; ++i) {
				line = br.readLine();
				for (int j = 1; j < w + 1; ++j) {
					prop[i][j] = line.charAt(j - 1);
				}
			}

			// solve
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();
			count = 0;
			for (int i = 1; i < h + 1; ++i) {
				for (int j = 1; j < w + 1; ++j) {
					if (prop[i][j] != DISTRIBUTED) {
						int fruit = prop[i][j];
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							distribute(prop, fruit);
						}
						++count;
					}
				}
			}
			// print
			System.out.println(count);
		}
	}

	static void distribute(int[][] prop, int fruit) {

		final int V[] = { 1, -1, 0, 0 };
		final int H[] = { 0, 0, 1, -1 };

		int x, y;
		x = xs.poll();
		y = ys.poll();

		if (prop[x][y] == fruit) {

			// prop[x][y] = DISTRIBUTED;
			prop[x][y] ^= prop[x][y];

			for (int i = 0; i < 4; ++i) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (prop[xv][yh] == fruit) {
					xs.offer(xv);
					ys.offer(yh);
				}
			}
		}
	}
}

Measured memory_bytes: 26212
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  if (N % (A + B) <= A)
    cout << N / (A + B) * A + N % (A + B) << endl;
  else
    cout << (N / (A + B) + 1) * A << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pii > vpi;
#define s(a) sort((a).begin(),(a).end())
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define forall(i,a,n) for(int i=a;i<=n;++i)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define sz(a) int((a).size())
#define all(c) (a).begin(),(a).end()
#define char2int(c) (c-'0')
#define IOS ios_base::sync_with_stdio(0);
#define printA(a,n) forall(i,0,n) cout<<a[i]<<(i==R?'\n':" ")
#define printV(a) printA(a,v.size())
#define MOD 1000000007
#define MAXN 100005

int a[MAXN];
int main(){
  int n,c,k;
  cin>>n>>c>>k;
  FOR(i,0,n) cin>>a[i];
  FOR(i,0,n) a[i]+=k;
  sort(a,a+n);
  int ans = 0;
  FOR(i,0,n){
    int newI = i,ctr=1;
    while(newI<n-1&&ctr<c&&a[i]+k>=a[i+ctr]){
      ctr++;
      newI++;
    }
    ans++;
    i=newI;
  }
  cout<<ans<<'\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef signed long long ll;
const char sp = ' ';


using namespace std;
static vector< pair<ll, ll> > robots_st, robots_en;

int main(void){
    ll dp[100009];
    MEMSET(dp, 0);
    ll N;
    cin>>N;
    
    ll end[100009];
    ll x, l;
    rep(i, N){
        cin>>x>>l;
        x+=1000000000;
        robots_st.push_back({x-l+1, i});
        robots_en.push_back({x+l, i});
    }
    sort(all(robots_st));
    sort(all(robots_en));
    ll endmark=0;
    rep(i, N){
        while(robots_en[endmark].first<robots_st[i].first){
            robots_en[endmark].first=i;
            endmark++;
        }
        //robots_st[i].first=i;
    }
    while(endmark<N){
        robots_en[endmark].first=N;
        endmark++;
    }
    rep(i, N){
        end[robots_en[i].second]=robots_en[i].first;
    }
    rep(i, N){
        //cout<<robots_st[i].first<<endl;
        dp[i+1]=max(dp[i+1], dp[i]);
        dp[end[robots_st[i].second]]=max(dp[end[robots_st[i].second]], dp[i]+(ll)1);
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 5092
#include <iostream>
#include <map>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

map<ll, ll> dp;
ll rec(ll N) {
    if (N < 0) return 0;
    if (N == 0) return 1;
    if (dp.count(N)) return dp[N];

    dp[N] = rec((N - 1) / 2);              // 奇数
    dp[N] += rec(N / 2);                   // 偶数 最下位が共に0
    if (N > 1) dp[N] += rec((N - 2) / 2);  // 偶数 最下位が共に1
    return dp[N] %= MOD;
}

int main() {
    ll N;
    cin >> N;
    cout << rec(N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,char>;

int main()
{
  string S,T;
  cin >> S >> T;
  map<char,char> mp;
  map<char,char> mp2;
  int flag=0;
  REP(i,T.size()){
    if(mp.count(T.at(i))>0){
      if(mp[T.at(i)]!=S.at(i)){
        flag = 1;
        break;
      }
    }
    mp[T.at(i)]=S.at(i);
  }
  REP(i,S.size()){
    if(mp2.count(S.at(i))>0){
      if(mp2[S.at(i)]!=T.at(i)){
        flag = 1;
        break;
      }
    }
    mp2[S.at(i)]=T.at(i);
  }


  if(flag==1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 776
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const string MINUSINF = "-";

typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

void chmax(string &a, string b)
{
    if (a == MINUSINF)
        a = b;
    else if (a.size() < b.size())
        a = b;
    else if (a.size() == b.size())
    {
        if (a < b)
            a = b;
    }
}

int match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

bool arr[10];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    int N, M;
    cin >> N >> M;
    vector<int> v;
    for (int i = 0; i < M; ++i)
    {
        int a;
        cin >> a;
        arr[a] = true;
        v.push_back(a);
    }

    string dp[10010];

    //dfs(N, "");

    for (int i = 0; i < N; ++i)
    {
        dp[i] = "-";
    }

    dp[0] = "";

    for (int i = 0; i <= N; ++i)
    {
        if (dp[i] == MINUSINF)
            continue;
        for (auto a : v)
            chmax(dp[i + match[a]], dp[i] + (char)('0' + a));
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 45056
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int c=0;
	for(int i=0;i<k;i++)
		c+=a[i];
	cout<<c<<endl;
	return 0;
}

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

using namespace std;

int main(){

  while(1){
    string game;
    cin>>game;

    string zer("0");
    if(game == zer){
      break;
    }

    int c = 0;
    int a_p = 0;
    int b_p = 0;
    for(char e : game){
      if(c == 0){
        c = 1;
      }
      else{
        if(e == 'A'){
          ++a_p;
        }
        else{
          ++b_p;
        }
      }
    }

    if(a_p > b_p){
      ++a_p;
    }
    else{
      ++b_p;
    }

    cout<<a_p<<" "<<b_p<<endl;
  }

  return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	int n, count = 1;
	cin >> n;
	int d [ n ];
	REP(i,n) cin >> d [ i ];
	sort ( d, d+n );
	REP(i,n-1) {
		if ( d [ i ] < d [ i+1 ] ) count ++;
	}
	cout << count << endl;
	
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 200050
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n, m, a[MAXN], b[MAXN];
int main() {
	read(n, m); int tot = 0;
	rep(i, 1, m) read(a[i]), tot += a[i] & 1;
	if(m == 1) {
		if(a[1] == 1) puts("1\n1\n1");
		else printf("%d\n2\n%d %d", a[1], a[1]-1, 1);
	}
	else {
		if(tot > 2) return 0 * puts("Impossible");
		else {
			rep(i, 2, m-1) if(a[i] & 1) (a[1] & 1) ? swap(a[m], a[i]) : swap(a[1], a[i]);
			int t = 0;
			if(a[1] > 1) b[++t] = a[1]-1;
			rep(i, 2, m-1) b[++t] = a[i];
			b[++t] = a[m]+1;
			rep(i, 1, m) cout << a[i] << ' '; puts("");
			cout << t << endl;
			rep(i, 1, t) cout << b[i] << ' ';
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)j; i<(int)n; i++) 
int main() {
  const int max=50;
  int n,m; cin>>n>>m;
  string a[max],b[max];
  rep(i,0,n) cin>>a[i];
  rep(i,0,m) cin>>b[i];
  bool exist=false;
  rep(ax,0,n-m+1){
    rep(ay,0,n-m+1){
      bool match=true;
      rep(by,0,m){
        if(a[by+ay].substr(ax,m)!=b[by]){
          match=false;
          break;
        }
      }
      if(match){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
  return 0;
}

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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



signed main() {
	ll N,X;
	cin>>N>>X;
	vector<ll> a(N+1,0);
	a[N]=X;
	rep(i,N){
		cin>>a[i];
	}
	sort(all(a));
	vector<ll> b(N,0);
	rep(i,N){
		b[i]=a[i+1]-a[i];
	}
	ll g=b[0];
	rep(i,N){
		g=gcd(g,b[i]);
	}
	p(g);
	return 0;
}


Measured memory_bytes: 1792
#A - 和風いろはちゃんイージー

#input A B C as list L
L = list(map(int,input().split()))

#5が2つ,7が1つなら並び替えて5-7-5にできる
if L.count(5) == 2 and L.count(7) == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int n;

int main(int argc, char const *argv[]) {
	cin>>n;
	map<char,int> x;
	for (char q = 'a'; q<='z'; ++q) x[q] = INF;

	rep(i,n) {
		map<char,int> mp;
		string s;
		cin>>s;
		int m = s.length();
		rep(j,m) mp[s[j]]++;
		for (char c = 'a'; c <= 'z'; ++c) {
			x[c] = min(x[c], mp[c]);
		}
	}

	string ans;

	for (auto &&e: x) {
		rep(i,e.second) ans.push_back(e.first);
	}

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


Measured memory_bytes: 256