akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

vector<vector<int> > g;
vector<int> top_sort;

int used[100500];
void dfs(int v) {
    if (used[v])
        return;
    used[v] = 1;
    for (int to : g[v])
        dfs(to);
    top_sort.pb(v);
}
int dp[100500];
int ans[100500];

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    g.resize(n);
    forn(i, n + m - 1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
    }
    forn(i, n)
        dfs(i);
    reverse(all(top_sort));
    for (int v : top_sort) {
        int d = dp[v] + 1;
        for (int to : g[v]) {
            dp[to] = max(dp[to], d);
        }
    }
    forn(i, n)
        ans[i] = -1;
    forn(v, n) {
        for (int to : g[v]) {
            if (dp[v] + 1 == dp[to])
                ans[to] = v;
        }
    }
    forn(i, n)
        cout << ans[i] + 1 << '\n';


    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
  int main() {
   
    int h,w;
    cin >> h >> w;
    string s[h+1];
    rep (i,h){
      cin >> s[i];
    }

    rep(i,h){
      //int cnt = 0;
      rep (j,w){
        if (s[i][j]=='.'){
          s[i][j]='0';
			    for (int dx = -1; dx <= 1; ++dx){
				    for (int dy = -1; dy <= 1; ++dy){
					    int nx = i+dx,ny = j+dy;
					    if(0<=nx&&nx<h&&0<=ny&&ny<w){
						    if(s[nx][ny]=='#')s[i][j]++;
					    }
				    }
			    }
        }
      }
    }

    rep (i,h){
      
        cout << s[i]<< endl;
    }
}




Measured memory_bytes: 3604
#!/usr/bin/perl
use Data::Dumper;

# 引数取り込み
my @a = split( / /, <STDIN> );
my $b = $a[0] % 10;

if ( $b == 1 or $b == 6 or $b == 8 or $b == 0 ) {
    print "pon";
}
elsif ( $b == 3 ) {
    print "bon";
}
else {
    print "hon";
}

1;

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

using namespace std;

#define ll long long
#define vi vector<int>
#define mkp make_pair
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[mxn];
int n, m, k;
string s;

ll pow(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void read(){
    cin >> s;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
}

void solve(){
    if(s.find('7') != string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    //init();
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    int sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> p[i];
        sum += p[i];
    }
    sort(p,p + n);
    sum -= p[n - 1];
    p[n - 1] = p[n - 1] / 2;
    sum += p[n - 1];
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<deque>
#include<queue>
#include<list>
#include<bitset>
#include<map>
#include<stack>

using namespace std;

#define             read(Mo_Ham) freopen(Mo_Ham,"r",stdin)
#define             write(Mo_Ham) freopen(Mo_Ham,"w",stdout)

#define             Hamo_Rabi ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define             all(v) 			((v).begin()), ((v).end())
#define             ll long long int
#define             fff(i,a,b) for (int i = a; i >= b; i--) 
#define             ff(i,a,b) for (int i = a; i < b; i++) 
#define             endl "\n"

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int a[26];
int main()
{
	Hamo_Rabi;
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define sc second


int main() {
	string s;
	int a = 0, b = 0, c = 0;
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'a')a++;
		else if (s[i] == 'b')b++;
		else c++;
	}
	if (a == b) {
		if (c == a - 1 || c == a || c == a + 1)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else if (a == c) {
		if (b == a - 1 || b == a + 1)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else if (c == b) {
		if (a == c - 1 || a == c + 1)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
loop do
    nums = gets.split.map(&:to_i)
    break if nums[0] == 0

    catch(:ok) do
        [:*, :+, :-].repeated_combination(3) do |ops|
            (nums + ops).permutation(7) do |polish|
                stack = []
                begin
                    until polish.empty?
                        x = polish.pop
                        if x.class == Symbol
                            v2, e2 = stack.pop || raise
                            v1, e1 = stack.pop || raise
                            v3 = v1.send(x, v2)
                            e3 = "(#{e1}#{x}#{e2})"
                            stack << [v3, e3]
                        else
                            stack << [x, x.to_s]
                        end
                    end
                    if stack[0][0] == 10
                        puts stack[0][1]
                        throw :ok
                    end
                rescue
                end
            end
        end
        p 0
    end
end

Measured memory_bytes: 9608
#include<stdio.h>
int main(void){
int a,b,c,x,y,z;
scanf("%d%d%d", &a, &b, &c);

if(a>b){
  x = a;
  a = b;
  b = x;}
if(b>c){
  y = b;
  b = c;
  c = y;}
if(a>b){
  z = a;
  a = b;
  b = z;}
 
printf("%d %d %d\n", a, b, c);

return 0;

} 
  

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

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

	int ans = 0;
	for (int i = 1; i <= n - 2; i++)
	{
		vector<int> left(26);
		vector<int> right(26);
		for (int j = 0; j < i; j++)
		{
			left[s[j] - 'a']++;
		}
		for (int j = i; j < n; j++)
		{
			right[s[j] - 'a']++;
		}

		int count = 0;
		for (int j = 0; j < 26; j++)
		{
			if (0 < left[j] && 0 < right[j])
			{
				count++;
			}
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<string> vec(N);

    string s;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        
        vec.at(i)=s;
    }

    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    
    cout << vec.size() << endl;
}

Measured memory_bytes: 9544
#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() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>

int main() {
	int max=INT_MIN,min=INT_MAX, temp, n;
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &temp);
		if (max < temp-min) {
			max = temp-min;
		}
		if(min > temp) {
			min = temp;
		}
	}

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



Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI (6.28318530718/2.0)
#define ft first
#define sec second
#define ll long long
#define pb push_back
using namespace std;
ll n,dp[1000001][4];
int main()
{
	cin >> n;
	dp[1][0]=dp[1][1]=1; dp[1][2]=8;
	for(int i=2; i<=n; i++)
	{
		dp[i][0]=((dp[i-1][0]*9)%MOD+dp[i-1][2])%MOD;
		dp[i][1]=((dp[i-1][1]*9)%MOD+dp[i-1][2])%MOD;
		dp[i][2]=(dp[i-1][2]*8)%MOD;
		dp[i][3]=(((dp[i-1][3]*10)%MOD+dp[i-1][0])%MOD+dp[i-1][1])%MOD;
	}
	cout << dp[n][3];
}

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

// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000010
#define MOD 1000000007
#define INF 1e9+10
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define maxof(a) *max_element(all(a))
#define minof(a) *min_element(all(a))
typedef long long ll;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.out", "w", stdout);

	int n;
	cin >> n;
	int a[n];
	for (int i=0; i<n; ++i) cin >>a[i];
	int c=0;
	for (int i=0;i<n;i+=2) c+= a[i]%2;
	cout << c;


	cout << endl;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  if(s.back()==s.front()) {
    if(s.size()%2==0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
  } else {
    if(s.size()%2==0) {
      cout << "Second" << endl;
    } else {
      cout << "First" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
#define LEN 100005

struct pp{
    char name[100];
    int t;
};
struct pp Q[LEN];
int head, tail, n;

void enqueue(struct pp x){
       Q[tail] = x;
       tail = (tail + 1)%LEN;
   }

struct pp dequeue(){
    struct pp x = Q[head];
    head = (head+1)%LEN;
    return x;
}
int main() 
{
   cin >> n;
   int q,t_sum=0;
   cin >> q;

    struct pp A[n+10];

    for(int i=0;i<n;i++){
        cin >> A[i].name >> A[i].t;
    }
    for(int i=0;i<n;i++){
        enqueue(A[i]);
    }
while(head != tail){
    if(Q[head].t > q){
        Q[head].t -= q;
        enqueue(dequeue());
        t_sum += q;
    }
    else
    {
        t_sum += Q[head].t;
        cout << Q[head].name << " " << t_sum << endl;
      	dequeue();
    }
    
}

}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;

int N;
Graph G;
vector<ll> res;

void bfs(ll v) {

    queue<vector<ll>> que;
    que.push({v,-1,0});

    while(que.size()) {
        auto p = que.front();
        que.pop();

        if (p[1]!=-1) {
            res[p[0]] = res[p[1]] + p[2];
        }
        else {
            res[p[0]] = 0;
        }
        
        for (auto e:G[p[0]]) {
            if (res[e.first]==-1) que.push({e.first, p[0], e.second});
        }
    }
}

int main(){
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i=0; i<N-1; i++) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    res.assign(N,-1);

    int Q,K;
    cin >> Q >> K;
    K--;

    bfs(K);

    rep(i,Q) {
        int x,y;
        cin >> x >> y;
        x--,y--;
        cout << res[x] + res[y]   << endl;
    }
}

Measured memory_bytes: 13552
# 3 8 3   n l t
# 0 1     x w
# 3 2
# 6 1

n, l, t = gets.split.map(&:to_i)

array_x = []
array_w = []
n.times do 
  x_temp, w_temp = gets.split.map(&:to_i)
  array_x << x_temp
  array_w << w_temp
end

def round_once_plus(array)
  array << array[0]
  array.shift
end

def round_once_minus(array)
  array.unshift(array.last)
  array.pop
end

array_position = []
count_over = 0

array_x.each_with_index do |x, i|
  if array_w[i] == 1
    array_position << (x + t) % l
    count_over += (x + t) / l
  else # array_w[i] == 2
    array_position << (x - t) % l
    count_over += (x - t) / l
  end
end

array_position.sort!

if count_over > 0
  count_over %= n
  count_over.times do
    round_once_plus(array_position)
  end
elsif count_over < 0
  count_over = count_over.abs
  count_over %= n
  count_over.times do
    round_once_minus(array_position)
  end
end

puts array_position


Measured memory_bytes: 17960
main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    let matA = mat 5000 (a - 1) '#' '.'
    let matB = mat 5000 (b - 1) '.' '#'
    putStrLn "100 100"
    putStrLn $ reverse matA
    putStrLn matB

mat :: Int -> Int -> Char -> Char -> String
mat 0 _ _ _ = []
mat pos n c1 c2
    | (mod pos 100) == 0 && pos /= 5000 = '\n' : c1 : mat (pos - 1) n c1 c2
    | even (div pos 100) && odd pos && n /= 0 = c2 : mat (pos - 1) (n - 1) c1 c2
    | otherwise                                = c1 : mat (pos - 1) n c1 c2
    


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b) << endl;
  return 0;
}

Measured memory_bytes: 256
// Vivek Rai
// Blazer_007
#include <bits/stdc++.h>
#define fastio 		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp(i,j)     make_pair(i,j)
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define loop(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solution(){
	int n;
	cin>>n;
	vi h(n);
	loop(i,0,n)cin>>h[i];
	
	vi dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	loop(i,2,n){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

signed main(){
    fastio;
    int t=1;
//    cin>>t;
    for(int i=1;i<=t;i++){
    	//cout<<"Case #"<<i<<":";
    	solution();
	} 
    return 0;
}       


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    if(n==2){
        cout<<(abs(A[1]-A[0]));
        return 0;
    }
    vector<int> temp(n,0);
    temp[n-2] = abs(A[n-1]-A[n-2]);
    for(int i=n-3;i>=0;i--){
        temp[i] = min((abs(A[i]-A[i+1])+temp[i+1]),(abs(A[i]-A[i+2])+temp[i+2]));
    }
    cout<<temp[0];
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  string s;
  cin >> s;
  if (s == "AAA"){
    cout << "No" << endl; 
  } else if (s=="BBB"){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	if (a[0]+a[1]==a[2]) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
 #include<string>
 using namespace std;
 
 int main()
 {
 	int a,b;
 	while(cin>>a>>b)
 	{
 	    int cnt=0;
 		for(int i=a;i<=b;i++)
 		{
 			int m=i/10000;
 			int n=i%10;
 			int p=(i/1000)%10;
 			int q=(i/10)%10;
 			if((m==n)&&(p==q)) cnt++;
		 }
		 cout<<cnt<<endl;
	 }
 	return 0;
 }

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

#define repr(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=a, i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=n; i>=0; --i)

#define printline(str) cout << str << "\n"

#define lint long long

template<class T,std::size_t N>
void printArray(T (&arr)[N], string del = {','}){
  cout << arr[0];
  repr(i, 1, N){
    cout << del << arr[i];
  }
  cout << "\n";
}

template<size_t nDigits, int mod>
struct Mod{
  int surplus[nDigits][10];
  constexpr Mod():surplus(){
    surplus[0][0]=0;
    surplus[0][1]=1%mod;
    for( size_t i = 0; i < 10; ++i){
      surplus[0][i] = i%mod;
    }
    for(size_t i = 1; i < nDigits; ++i){
      surplus[i][0] = 0;
      surplus[i][1] = (10*surplus[i-1][1])%mod;
      for( size_t j = 2; j < 10; ++j){
        surplus[i][j] = (j*surplus[i][1])%mod;
      }
    }
  }
};

constexpr auto numMod13 = Mod<100000, 13>();

constexpr int maxInt = 1000000000 + 7;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  //int numS[100000];
  int N = S.size();

  lint dp[13] = {0};
  lint nextDp[13] = {0};
  int base = 1;

  dp[0] = 1;

  rep(i, N){
    if( S[N-1-i] == '?'){
      rep(j,10){
        rep(k,13){
          nextDp[ (numMod13.surplus[i][j] + k)%13 ] += dp[k];
          nextDp[ (numMod13.surplus[i][j] + k)%13 ] %= maxInt;
        }
      }

    }else{
      int j = (int)(S[N-1-i] - '0');
      rep(k, 13){
        nextDp[ (numMod13.surplus[i][j] + k)%13 ] += dp[k];
        nextDp[ (numMod13.surplus[i][j] + k)%13 ] %= maxInt;
      }
    }
    base = (10*base)%13;
    rep(k,13){
      dp[k] = nextDp[k];
      nextDp[k] = 0;
    }
  }
  printline(dp[5]);
}

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

const int INF = 1e9;

int main(void) {
    int N,M;
    cin>>N>>M;
    int mi = -INF;
    int ma = INF;
    for (int i = 1; i <= M; i++) {
        int L,R;
        cin>>L>>R;
        if (mi <= L) mi = L;
        if (ma >= R) ma = R;
    }
    if (ma - mi >= 0) cout << ma - mi + 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        List<Long> list = new ArrayList<Long>();
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
 
        for(int i = 0 ; i < 5; i++) {
            list.add(scan.nextLong());
        }
        long min = Collections.min(list);
        
        long ans = 0;
        if(n % min == 0){
            ans = (n / min) + 4;
        } else {
            ans = (n / min) + 5;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
	public static void main (String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		long x = in.nextLong();
		long y = in.nextLong();
 
		
			int len = 1;
			x += x;
			while(x <= y) {
				++len;
				x += x;
			}
 
			System.out.println(len);
		
 
 	}
 
}

Measured memory_bytes: 23764
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int n = nextInt();
        int r = 0;
        nextLine();
        for (int i = 1; i <= n; i++) {
            int a = nextInt();
            if (i % 2 == 1 && a % 2 == 1) {
                r ++;
            }
        }
        System.out.println(r);
    }



    public static void println(Object o) {
        System.out.println(o);
    }

    public static void print(Object o) {
        System.out.print(o);
    }

    public static void printf(String format, Object... o) {
        System.out.printf(format, o);
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static void nextLine() {
        scanner.nextLine();
    }

    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }

    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];

    public static void combinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    public static long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

Measured memory_bytes: 29416
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        String line = readLine();
        StringTokenizer st = new StringTokenizer(line, " ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());

        if (a > b ) {
        	System.out.println(String.valueOf(a-1));
        } else {
        	System.out.println(String.valueOf(a));
        }
    }

    private static String readLine() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return br.readLine();
    }
}

Measured memory_bytes: 20820
s = list(input())
ans = len(s)
for c in s:
    dist = 0
    dists = []
    for d in s:
        if c != d:
            dist += 1
        else:
            dists.append(dist)
            dist = 0
    ans = min(ans, max(dists + [dist]))
print(ans)

Measured memory_bytes: 3060
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define int long long
using namespace std;

map <string,int> has;
long long ans;
char a[15];
signed main(void)
{
	int N;
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%s",a);
		sort(a,a+10);
//		putchar('\n');
//		for(int j=1;j<=10;j++)
//		{
//			printf("%c",a[j]);
//		}
		has[a]++;
		ans+=has[a]*(has[a]-1)/2;
		ans-=(has[a]-1)*(has[a]-2)/2;
//		printf("%d\n",has[a]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11136
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B, C, D;

  for (;;) {
    C -= B;
    if (C <= 0)return "Yes";
    A -= D;
    if (A <= 0)return "No";
  }

}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
int main()
{
	char c;
	cin>>c;
	if('A'<=c && c<='Z')
	{
		printf("A\n");
	}
	else
	{
		printf("a\n");
	}
}

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

int main(){
  string s;
  cin >>s;
  reverse(s.begin(),s.end());
  while(1){
    if(s.size()==0){
      cout <<"YES" <<endl;
      break;
    }
  else if(s[0]=='m'&&s[1]=='a'&&s[2]=='e'&&s[3]=='r'&&s[4]=='d'){
    s.erase(s.begin(),s.begin()+5);
  }
  else if(s[0]=='e'&&s[1]=='s'&&s[2]=='a'&&s[3]=='r'&&s[4]=='e'){
    s.erase(s.begin(),s.begin()+5);
  }
  else if(s[0]=='r'&&s[1]=='e'&&s[2]=='s'&&s[3]=='a'&&s[4]=='r'&&s[5]=='e'){
    s.erase(s.begin(),s.begin()+6);
  }
  else if(s[0]=='r'&&s[1]=='e'&&s[2]=='m'&&s[3]=='a'&&s[4]=='e'&&s[5]=='r'&&s[6]=='d'){
    s.erase(s.begin(),s.begin()+7);
  }
  else {
    cout << "NO" <<endl;
    break;
  }
  }
}

Measured memory_bytes: 512
#include<stdio.h>
int main (){
	int l, r, d, i;
	int count = 0;
	scanf ("%d %d %d", &l, &r, &d);	
	
	for (i = l; i <= r; i++){
		if (i % d == 0){
			count++;
		}
	}
	printf ("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1704
N = gets.to_i
G = Array.new(N + 1){[]}
(N - 1).times{|i| a, b = gets.split.map(&:to_i); G[a] << [b, i]; G[b] << [a, i]}
M = gets.to_i
UVs = M.times.map{gets.split.map(&:to_i)}

def dfs(s, g)
  st = [[s, nil]]
  d = []; d[s] = true
  while !st.empty?
    u, _ = st.last
    return st.map(&:last).compact.inject(0){|s, i| s + (1<<i)} if u == g
    if t = G[u].find{|v, _| d[v].nil?}
      d[t[0]] = true
      st << t
    else
      st.pop
    end
  end
end

as = UVs.map{|u, v| dfs(u, v)}
res = (1 .. M).inject(0) do |r, n|
  val = as.combination(n).inject(0) do |v, a|
    b = a.inject(:|).to_s(2).count('1')
    v + (1 << (N - 1 - b))
  end
  n.odd? ? r + val : r - val
end
puts (1 << (N - 1)) - res

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1, 0), b(m+1, 0);
    rep(i,n){
        cin >> a[i+1];
        a[i+1]+=a[i];
    }
    rep(i,m){
        cin >> b[i+1];
        b[i+1] += b[i];
    }
    int j = m;
    int ans = 0;
    for(int i = 0; i <= n; ++i){
        while(j > 0 && a[i]+b[j] > k){
        j--;
        
        }
        if(a[i]+b[j]<=k){
            ans= max(ans, i+j);
        }

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

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

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

const long long INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  long long h[100100];

  for (int i = 0; i < n; i++) cin >> h[i];

  long long dp[100100];
  for (int i = 0; i < 100100; i++) dp[i] = INF;
  dp[0] = 0;

  for (int i = 0; i < n; i++)
    for (int j = 1; j <= k; j++) {
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	string S; cin >> S;
	bool n,w,s,e;
	n = w = s = e = false;
	rep(i,S.size()) {
		if (S[i] == 'N') n = true;
		if (S[i] == 'W') w = true;
		if (S[i] == 'S') s = true;
		if (S[i] == 'E') e = true;
	}
	cout <<  ((!(n ^ s) && !(w ^ e)) ? "Yes" : "No") << endl;
}




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

int main()
{
    int t, d, l, a;

    while( cin >> t >> d >> l )
    {
        if( t + d + l == 0 )
            break;

        vector<int> v;
        for( int i = 0; i < t; i++ )
        {
            cin >> a;
            if( v.empty() && a >= l )
            {
                v.push_back( i + 1 );
                v.push_back( i + 1 + d );                
            }
            else if( a >= l && v[v.size()-1] < i + 1 )
            {
                v.push_back( i + 1 );
                v.push_back( i  + 1 + d );
            }
            else if( a >= l )
            {
                v.pop_back();
                v.push_back( i + 1 + d );
            }
        }

        if( !v.empty() )
        {
            if( v[v.size()-1] > t )
                v[v.size()-1] = t;

            if( v[v.size()-2] == t )
            {
                v.pop_back();
                v.pop_back();
            }
        }

        int sum = 0;
        for( int i = 0; i < v.size(); i += 2 )
            sum += v[i+1] - v[i];

        cout << sum << endl;

        v.clear();
    }

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) //15桁まで表示
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui,ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};
const ll mod = 1000000007;
const double PI = acos(-1.0);
int c[1010101];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  Sort(a);
  for (int k:a){
    if (c[k]){c[k]=2;continue;}
    for(int i=k;i<1010101;i+=k) c[i]++;
  }
  int ans=0;
  for(int i:a){
    if (c[i]==1)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8012
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose:
   Date   : 27/08/2020
   Stay Focused!
*/

#include "bits/stdc++.h"
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n)    memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)

#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void sync() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);
}
void timeTaken() {
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

int32_t main() {
  sync();
  dip(float, d);
  dip(float, t);
  dip(float, s);
  float v = d / t;
  if (v > s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int n,a;
  string x,y;
  x = "Yes";
  y = "No";
  cin >> n >> a;
  if (n%500 > a){
    cout << y << endl;
  }
  else {
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int num = n%10;

	if(num == 3){
		cout << "bon" << endl;
	}else if(num == 0 || num == 1){
		cout << "pon" << endl;
	}else if(num == 6 || num == 8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    rep(i, 0, s.size()){
        if(i == a){
            if(s[i] != '-') ans = false;
        }else{
            if(!('0' <= s[i] && s[i] <= '9')) ans = false;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,m,x,y,f[100010]={},cnt[100010],ans=0;
  scanf("%d %d",&n,&m);
  f[1]=1;
  for(int i=1;i<=n;i++)
    cnt[i]=1;
  for(int i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(f[x]==1)
      f[y]=1;
    if(cnt[x]==1)
      f[x]=0;
    cnt[x]--;
    cnt[y]++;
  }
  for(int i=1;i<=n;i++)
    ans+=f[i];
  printf("%d\n",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    string s ;
    cin >>s;
    vector<string> w={"Sunny","Cloudy","Rainy","Sunny"};
    rep(i,3){
        if (s == w[i]) cout << w[i+1]<< endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>=10 || b>=10)
    {
      System.out.println("-1");
    } else {
      System.out.println(a*b);
    }
}
}


Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        int c = 0;
        int d = 1;
        for (int i = 1; i <= N; i++) {
            int tmp = nextInt(r);
            if (tmp == d) {
                d++;
            } else {
                c++;
            }
        }
        if (c == N) c = -1;
        System.out.println(c);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }
}


Measured memory_bytes: 64436
#include <bits/stdc++.h>
#define maxn 401000
using namespace std;

int A[maxn];
char s[maxn];
int st, n, m, o;
int main() {
	scanf("%d %d",&n,&m);
	scanf("%s",s + 1);
	for (int i = 1; i <= n; i++) A[i] = s[i] - 'A';
	int st = 0;
	while (st < n && m) {
		if (A[st + 1] == o) {
			A[st + 1] ^= 1;
			m--;
			continue;			
		}
		o ^= 1; st++;
		A[st + n] = o;
		m--;
	}
	if (!m) {
		for (int i = 1; i <= n; i++)
			if (A[st + i] == o) putchar('A');
			else putchar('B');
	} else {
		if (A[st + 1] == (o ^ ((n & 1) & (m & 1)))) putchar('A');
		else putchar('B');
		//o ^= ((n & 1) & (m & 1));
		for (int i = 2; i <= n; i++)
			if (A[st + i] == o) putchar('A');
			else putchar('B');
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 2176
N = int(input())
P_list = list(map(int,input().split()))
P_sorted_list = sorted(P_list)
cnt = 0
for i in range(0,N):
    if P_list[i] != P_sorted_list[i]:
        cnt += 1

if cnt == 2 or cnt == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	int a,b,i,j;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==b && a==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2044
#include<iostream>
#include<memory.h>
#include<stdio.h>
using namespace std;
char name[1000][1000];
int n,m;

int main(){
    while(cin>>n>>m && (n+m)!=0){
        long long japan[10000];
        long long japan2[10000];
        long long a,b;

        for(int i=1;i<=n;i++){
        scanf("%s",name[i]);
        cin>>a>>b;
        japan[i] = b;
        japan2[i] = b-a;
        }


        long long query;
        for(int i=1;i<=m;i++){
            cin>>query;
            int temp = 0;
            for(int i=1;i<=n;i++){
                if(query <= japan[i] && query >japan2[i]){
                    cout<<name[i]<<" "<<( query - japan2[i]) <<endl;
                    temp = 1;
                    break;
                }
            }
            if(temp == 0){cout<<"Unknown"<<endl;}
        }



    }


    return 0;

}

Measured memory_bytes: 2200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  p[0] /= 2;
  int ans = 0;
  for (int i = 0; i < n; i++) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	in := inputSlice()
	n := parseInt(in[0])
	k := parseInt(in[1])
	slice := inputSlicelnInt(n)
	sort.Sort(sort.IntSlice(slice))
	min := 1000000000
	last := n - k + 1
	var sml, lrg, diff int
	for i := 0; i < last; i++ {
		sml = slice[i]
		lrg = slice[i+k-1]
		diff = lrg - sml
		if diff < min {
			min = diff
		}
	}
	fmt.Print(min)
	// fmt.Printf("type: %T, value: %v\n", n, n)
	// fmt.Printf("type: %T, value: %v\n", m, m)
	// fmt.Println(m)
}

func input() string {
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}

func inputSlice() []string {
	sc.Scan()
	return strings.Split(strings.TrimSpace(sc.Text()), " ")
}

func inputSlicelnStr(n int) []string {
	slice := make([]string, 0, n)
	for i := 0; i < n; i++ {
		in := input()
		slice = append(slice, in)
	}
	return slice
}
func inputSlicelnInt(n int) []int {
	slice := make([]int, 0, n)
	for i := 0; i < n; i++ {
		in := input()
		slice = append(slice, parseInt(in))
	}
	return slice
}

func parseInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}


Measured memory_bytes: 3072
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
digit = 26
now = 26
c = 1
while now < N:
    digit *= 26
    now += digit
    c += 1
now = now - digit
N = N - now -1
ans = ''
for i in range(c):
    ans += chr(97+N%26)
    N //= 26

print(ans[::-1])


Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC target("avx2")
#pragma GCC optimize("-O3")
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define INF 1e18
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1743;
const ll gd = 2000001;
const ll gd_o = 1000001;
//const ll p = 31;
const ll MD=1e6 + 3;
int rnd(int x) { return mrand() % x;}
ll fastpow(ll a, ll n) {ll res=1;while(n){if(n&1)res*=a;a*=a;n>>=1;}return res;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll nok(ll a,ll b){ return (a * b / gcd(a, b));}


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    freopen("msched.in", "r", stdin);
//    freopen("msched.out", "w", stdout);
    ll n, ans = 0;
    cin >> n;
    for (int a = 1; a <= n; a++)
        for (int b = 1; b <= n; b++)
            for (int c = 1; c <= n; c++) ans += __gcd(__gcd(a, b), c);
    cout << ans;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>

using namespace std;

struct UF {
    vector<int> a;
    vector<int> size;
    
    UF(int n) {
        a.assign(n, 0);
        size.assign(n, 1);
        for (int i = 0; i < n; i++) {
            a[i] = i;
        }
    }
    
    int root(int u)  {
        int parent = u;
        while (a[parent] != parent) {
            parent = a[parent];
        }
        return parent;
    }
    
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    
    void unite(int u, int v) {
        int i = root(u);
        int j = root(v);
        if (i != j) {
            if (size[i] > size[j]) {
                a[j] = i;
                size[i] += size[j];
            }
            else {
                a[i] = j;
                size[j] += size[i];
            }
        }
    }  
};

int main() {
    int n, q;
    cin >> n >> q;
    UF uf = UF(n + 1);
    for (int i = 0; i < q; i++) {
        int cmd, u, v;
        cin >> cmd >> u >> v;
        if (cmd == 0) {
            uf.unite(u, v);
        }
        else {
            cout << (uf.same(u, v) ? 1 : 0) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int i,N,A[100],con=0,j,tmp,flag ;
  //入力
  scanf("%d",&N);
  if(N >= 1 && N <= 100){
    for (i = 0; i < N; i++){ //printf("k");
    scanf("%d",&A[i]); 
  }
  }
 flag = 1;
  while(flag ){
    flag = 0;
    for ( j = N-1; j >= 1; j--){
      if(A[j] < A[j-1]){
	tmp = A[j];
        A[j] = A[j-1];
	A[j-1] = tmp; 
      flag = 1;
	con++;
      }
   
    }
    }
    //出力
   for (i = 0; i < N-1; i++){  
     printf("%d ",A[i]);
  }
   printf("%d\n",A[N-1]);


   printf("%d\n",con);
 
   
  return 0;
}

Measured memory_bytes: 600