akhauriyash/Code-Regression huggingface dataset:
// ABC087_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll X, N, M;
    cin >> X >> N >> M;
    
    // calculation
    cout << (X-N)%M << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int N,M,K;
    cin >> N >> M >> K;
    REP(i,N+1){
        REP(j,M+1){
           // cout << i << " " << j << " " << i*M+j*N-2*i*j << " " << K <<endl;
            if(i*M+j*N-2*i*j==K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
	return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

string zero(ll a){
  string t=to_string(a);
  while(t.size()<6){
    t='0'+t;
  }
  return t;
}

int main(){

  ll n,m;
  cin >> n >> m;
  ll p[m],y[m];
  mat G;
  for(ll i=0;i<m;i++){
    cin >> p[i] >> y[i];
    G.push_back({y[i],p[i],i});
  }
  sort(G.begin(),G.end());

  ll city[n+1]={};//i番目の県に市がいくつあるか
  vector<string> ans(m);
  for(ll i=0;i<m;i++){
    ll a=city[G[i][1]]+1;
    city[G[i][1]]++;
    string t=zero(G[i][1])+zero(a);
    ans[G[i][2]]=t;
  }

  for(ll i=0;i<m;i++)cout << ans[i] << endl;

}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = Convert.ToInt32(Console.ReadLine());
            long[] A = Console.ReadLine().Split().Select(i => Convert.ToInt64(i)).ToArray();
            long[] B = Console.ReadLine().Split().Select(i => Convert.ToInt64(i)).ToArray();
            long ans = 0L;
            for (var i = 0; i < N; i++)
            {
                // i街の勇者がi街しか倒せない時
                if (B[i] <= A[i])
                {
                    A[i] -= B[i];
                    ans += B[i];
                }
                else
                {
                    // とりあえずi街のモンスターは倒しておく
                    B[i] -= A[i];
                    ans += A[i];
                    // i + 1街も全滅できるかどうか
                    if (B[i] < A[i + 1])
                    {
                        ans += B[i];
                        A[i + 1] -= B[i];
                    }
                    else
                    {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 36060
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d", &a,&b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define loop(i,a,b) for(int i=a;i<b;i++)
    #define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
    #define vi vector<int>
    #define si set<int>
    #define pii pair <int, int>
    #define sii set<pii>
    #define vii vector<pii>
    #define mii map <int, int>
    #define pb push_back
    #define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    //Constants
    const int MOD = 1000000007; /* 1e9 + 7*/
    const int MAXN = 1000005; /*1e6 +5 */
     
    int spf[1000009]; // stores the smallest prime factor of a number
     
    void sieve()
    {
    spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
     
        for (int i=3; i*i<MAXN; i++)
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    
     
    /* Iterative Function to calculate (x^y)%p in O(log y) */
    int power(int x,  int y, int p)
    {
        int res = 1;     // Initialize result
        x = x % p; // Update x if it is more than or
                    // equal to p 
        if (x == 0) return 0; // In case x is divisible by p;     
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if (y & 1)
                res = (res*x) % p;     
            // y must be even now
            y = y>>1; // y = y/2
            x = (x*x) % p;
        }
        return res;
    }
    
     
    void solve(int caseNumber)
    {
		// cout<<"Case "<<caseNumber<<": "endl;
		string s;cin>>s;
		//sort(s.begin(),s.end());
		int c=0, maxm=-1;
		loop(i,0,3)
		{
			if(s[i]=='R')
			c++;
			else
			{
				maxm=max(maxm,c);
				c=0;
			}
		}
		if(c!=0)
		maxm=max(maxm,c);
		cout<<maxm<<endl;    
    }

     
    int32_t main()
    {
        faster;
        /*sieve();*/
       // compute();
      // int t;cin>>t;
     int t=1;
        for(int ii=1;ii<=t;ii++)
        {
            solve(ii);
        }
     
     
        return 0;
    }


Measured memory_bytes: 3620
def main():
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    for _ in range(min(K, 50)):
        B = [0] * (N + 1)
        for j in range(N):
            d = A[j]
            B[max(j - d, 0)] += 1
            B[min(j + d, N - 1) + 1] -= 1
        for i in range(N):
            B[i + 1] += B[i]
        A = B
    print(*A[:-1])


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 171984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main (){
	int a, b, c, d, e;

	std::cin >> a >> b >> c >> d >> e;

	int ans = 0;

	if (a % 10 != 0 && b % 10 != 0 && a % 10 < b % 10) {
		std::swap(a, b);
	}
	else if (b % 10 == 0) {
		std::swap(a, b);
	}

	if (b % 10 != 0 && c % 10 != 0 && b % 10 < c % 10) {
		std::swap(b, c);
	}
	else if (c % 10 == 0) {
		std::swap(b, c);
	}

	if (c % 10 != 0 && d % 10 != 0 && c % 10 < d % 10) {
		std::swap(c, d);
	}
	else if (d % 10 == 0) {
		std::swap(c, d);
	}

	if (d % 10 != 0 && e % 10 != 0 && d % 10 < e % 10) {
		std::swap(d, e);
	}
	else if (e % 10 == 0) {
		std::swap(d, e);
	}

	ans += a + (10 - (a % 10 != 0 ? a % 10 : 10)); 
	ans += b + (10 - (b % 10 != 0 ? b % 10 : 10)); 
	ans += c + (10 - (c % 10 != 0 ? c % 10 : 10)); 
	ans += d + (10 - (d % 10 != 0 ? d % 10 : 10)); 
	ans += e;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
min = 753 - 111
s =gets
(s.size-3).times do |i|
  num = s[i].to_i*100 + s[i+1].to_i*10 +s[i+2].to_i
  if (num - 753).abs < min
    min = (num-753).abs
  end
end
puts min


Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    map<char, int> counter;
    counter['a'] = counter['b'] = counter['c'] = 0;
    for (auto ch : s)
    {
        counter[ch]++;
    }
    vector<int> vs;
    for (auto kv : counter)
    {
        vs.push_back(kv.second);
    }
    sort(vs.begin(), vs.end());
    cout << (vs[2] - vs[0] <= 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main(void){
    int d,i;
    long long int a;
    while(scanf("%d",&d)!=EOF){
        a=0;
        for(i=1; i<(600/d); i++){
            a+=(d*d*d*i*i);
        }
        printf("%lld\n",a);
    }
    return 0;
}

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


int dp[3001][3001];

string getlcs(string& a,string& b,int len)
{
	int i,j;
	i=0;
	j=0;
	string lcs="";
	while(len>0)
	{
		if(a[i]==b[j])
		{
			lcs+=a[i];
			len--;
			i++;
			j++;
		}
		else
		{
			if(dp[i][j+1]>dp[i+1][j])
			{
				j++;
			}
			else
			{
				i++;
			}
		}

	}
	return(lcs);
}
int getlen(string& a,string& b,int i,int j)
{
   if(i>=a.length()||j>=b.length())
   {
   	return(0);
   }
   if(dp[i][j]!=-1)
   {
   	return(dp[i][j]);
   }
   if(a[i]==b[j])
   {
   	return(dp[i][j]=1+getlen(a,b,i+1,j+1));
   }
   else
   {
   	return(dp[i][j]=max(getlen(a,b,i+1,j),getlen(a,b,i,j+1)));
   }
}

string solve(string &a,string &b)
{
	int len=getlen(a,b,0,0);
	return(getlcs(a,b,len));
}
int main()
{
	string a,b;
	cin>>a>>b;
	int i,j;
	for(i=0;i<=3000;i++)
	{
		for(j=0;j<=3000;j++)
		{
			dp[i][j]=-1;
		}
	}
	cout<<solve(a,b);
}

Measured memory_bytes: 36088
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)
cnt = 0
for i in dic:
    #print(i)
    #print(dic[i])
    if i>dic[i]:
        cnt += dic[i]
    else:
        cnt += dic[i]-i
print(cnt)

Measured memory_bytes: 17784
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint mod = 1e+9 + 7;
lint h, w, k;

bool isvalid(bitset<8> b) {
    for (int i = 0; i < w - 2; i++) {
        if (b[i] == 1 && b[i + 1] == 1) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> h >> w >> k;
    vector<vector<lint>> dp(h + 1, vector<lint>(w, 0));
    dp[0][0] = 1;
    //高さiのところを見る
    for (int i = 0; i < h; i++) {
        //貼り方全部見る
        for (int j = 0; j < (1 << (w - 1)); j++) {
            bitset<8> b(j);
            if (!isvalid(b)) continue;
            for (int k = 0; k < w; k++) {
                if (k - 1 >= 0 && b[k - 1]) {
                    dp[i + 1][k - 1] += dp[i][k];
                    dp[i + 1][k - 1] %= mod;
                } else if (k + 1 < w && b[k]) {
                    dp[i + 1][k + 1] += dp[i][k];
                    dp[i + 1][k + 1] %= mod;
                } else {
                    dp[i + 1][k] += dp[i][k];
                    dp[i + 1][k] %= mod;
                }
            }
        }
    }
    cout << dp[h][k - 1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <set>
#include <algorithm>
#include <iostream>
#include <string>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,q,l,r;
  int a[LIMIT2]={0};
  char s[LIMIT2]="",c;
  std::set<ll> t[30];
  
  scanf("%lld",&n);
  scanf("%s",s);
  rep(i,n){
    t[s[i]-'a'].insert(i+1);
  }
  scanf("%lld",&q);
  rep(i,q){
    scanf("%lld",&j);
    if(j==1){
      scanf("%lld %c",&j,&c);
      if(s[j-1]==c) continue;
      t[s[j-1]-'a'].erase(j);
      t[c-'a'].insert(j);
      s[j-1]=c;
    }else{
      scanf("%lld %lld",&l,&r);
      result=0;
      for(j=0;j<26;j++){
        if(t[j].lower_bound(l)!=t[j].end() && *t[j].lower_bound(l)<=r) result++;
      }
      printf("%lld\n",result);
    }
  }
  
  return 0;
}



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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

int solve(int X) {
//     for (int t=1, last=0; ; ++t) {
//         int mx = last+t;
//         if (X <= mx) return t;
//         last = mx;
//     }
    // X <= t(t+1)/2
    // t^2 + t >= 2X
    // (t + 1/2) >= 2X - 1/4
    // t>0なので
    // t >= √(2X - 1/4) - 1/2
    double tmin = sqrt(X*2 - 0.25) - 0.5;
    return (int)ceil(tmin);
}

int main() {
    int X; cin >> X;
    cout << solve(X) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <limits>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using ll=long long;
using pl  = pair<ll,ll>;
using pii  = pair<int,int>;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

const int MAX = 2000003;

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

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

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

ll X[1000007],Y[1000007];

int main(){
  COMinit();
  ll A,B,C,D,ans=0;
  cin >> A >> C >> B >> D;
  cout << (COM(B+D+2,B+1)-COM(A+D+1,A)-COM(B+C+1,C)+COM(A+C,C)+3*MOD)%MOD << endl;;
}

Measured memory_bytes: 48384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int x, t;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> x >> t;
	cout << max(x-t, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int N;
int R[100];
int solve(int m){
	int res=0;
	int mul=1;
	for(int i=0;i<6;i++){
		res=max(res,(m/mul)*(m%mul));
		mul*=10;
	}
	return res;
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		map<int,int>M;
		scanf("%d",&R[i]);
		if(R[i]<10){
			printf("0\n");
			goto aaa;
		}
		M[R[i]]++;
		while(true){
			R[i]=solve(R[i]);
			if(R[i]<10){
				break;
			}
			M[R[i]]++;
			if(M[R[i]]==2){
				printf("-1\n");
				goto aaa;	
			}
		}
		printf("%d\n",M.size());
		aaa:;
	}
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names+1, ',');
    cout.write(names, comma - names) << " = " << arg1 <<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif

const int N = 200005;
const LL MOD = 998244353;

LL bit[N];
void update(int idx,LL val){
    while(idx < N){
        bit[idx] += val;
        idx += (idx&-idx);
    }
}
LL query(int idx){
    LL ret = 0;
    while(idx > 0){
        ret += bit[idx];
        idx -= (idx&-idx);
    }
    return ret;
}
pii ara[N];
LL dp[N];
int n , k;
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n >> k;
    FOR(i,1,k)cin >> ara[i].ff >> ara[i].ss;

    dp[n] = 1;
    update(n,1);

    for(int i = n - 1;i >= 1;i--){
        for(int j = 1;j <= k;j++){
            int l = i + ara[j].ff;
            int r = i + ara[j].ss;
            if(l > n)continue;
            r = min(r,n);
            LL ways = query(r) - query(l - 1);
            dp[i] += ways;
            dp[i] = (dp[i] + MOD) % MOD;
        }
        update(i,dp[i]);
//        debug(i,dp[i]);
    }
    cout << dp[1] << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (long double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}



Measured memory_bytes: 6744
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String,Integer> count = new HashMap<>();

        for (int i = 0; i < n ; i++) {
            String s = sc.next();
            count.put(s,1);
        }

        final int sum = count.values().stream().mapToInt(Integer::intValue).sum();
        if(sum==3){
            System.out.print("Three");
        }else if (sum==4){
            System.out.print("Four");
        }
    }
}

Measured memory_bytes: 26708
def main():
    n, m = map(int, input().strip().split())
    target = [0, 0, 0]
    stored = [False, False, False]
    logic_err = [False, False, False]
    for i in range(m):
        s, c = map(int, input().strip().split())
        tmp = c * 10**(n-s)
        if (stored[s-1]==True) and (target[s-1]!=tmp):
            logic_err[s-1] = True
        elif (tmp==0) and (n>1) and (s==1):
            logic_err[s-1] = True
        else:
            target[s-1] = tmp
            stored[s-1] = True

    if sum(x==True for x in logic_err)>0:
        print(-1)
    else:
        if stored[0]==False:
            if n>1:
                target[0] = 10**(n-1)

        print(sum(target))

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    // int t; cin>>t;
    // while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if((a<0 && b<0 && c<0 && d>=0) || (a<0 && b>=0 && c<0 && d<0)){
            ll x=a*c;
            ll y=b*c;
            ll z=d*a;
            ll t=d*b;
            ll ans = 0;
            if(ans<x)
            ans=x;
            if(ans<y)
            ans=y;
            if(ans<z)
            ans=z;
            if(ans<t)
            ans=t;
            cout<<ans;
        }else{
            ll x=a*c;
            ll y=b*c;
            ll z=d*a;
            ll t=d*b;
            ll ans;
            if(x<y)
            ans=y;
            else ans=x;
            
            if(ans<z)
            ans=z;
            if(ans<t)
            ans=t;
            cout<<ans;
        }
    // }
}

Measured memory_bytes: 3620
module degit_operation

   interface extract_degit
      module procedure extract_degit_4, extract_degit_8
   end interface

   interface num_of_degits
      module procedure num_of_degits_4, num_of_degits_8
   end interface

contains

   function extract_degit_4(num, degit)
      ! 引数numのdegit桁目の数字を取り出す関数
      implicit none
      integer, intent(in) :: num, degit
      integer :: extract_degit_4

      ! 引数numは正の整数を想定
      extract_degit_4 = mod(num,10**(degit)) / 10**(degit-1)
   end function extract_degit_4

   function extract_degit_8(num, degit)
      ! 引数numのdegit桁目の数字を取り出す関数
      implicit none
      integer(8), intent(in) :: num
      integer, intent(in) :: degit
      integer :: extract_degit_8

      ! 引数numは正の整数を想定
      extract_degit_8 = mod(num,10**(degit)) / 10**(degit-1)
   end function extract_degit_8


   function num_of_degits_4(input)
      ! 引数inputの桁数を返す関数
      implicit none
      integer, intent(in) :: input
      integer :: num_of_degits_4, degit, num

      degit = 0
      num = input
      do while (num .ne. 0)
         num = num / 10
         degit = degit + 1
      enddo

      num_of_degits_4 = degit
   end function num_of_degits_4

   function num_of_degits_8(input)
      ! 引数inputの桁数を返す関数
      implicit none
      integer(8), intent(in) :: input
      integer :: num_of_degits_8, degit, num

      degit = 0
      num = input
      do while (num .ne. 0)
         num = num / 10
         degit = degit + 1
      enddo

      num_of_degits_8 = degit
   end function num_of_degits_8

end module degit_operation

program abc162a
   use degit_operation
   implicit none
   integer :: N, i

   read(*,*) N

   do i = 1, 3
      if (extract_degit(N,i) == 7) then
         print *, 'Yes'
         stop
      end if
   end do

   print *, 'No'



end program abc162a


Measured memory_bytes: 2924
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){
	int N;
    vector<int> V;
    cin>>N;
    int t;
    int odd,even;
    odd = 0; even = 0;
    for(int i=0;i<N;i++){
        cin >> t;
        if(t%2 == 1){
            odd++;
        }else{
            even++;
        }
        //V.push_back(t);
    }

    if(odd  != 0){
        cout<<"first"<<endl;
    }else{
        cout<<"second"<<endl;
    }
	
	
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	string s;
	cin >> s;
	if (s == "ABC")puts("ARC");
	else {
		puts("ABC");
	}
	return 0;
}


Measured memory_bytes: 3640
from collections import defaultdict
class DisjointSet:
    def __init__(self, size):
        self.rank = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]
        
N, M = map(int, input().split())
P = list(map(int, input().split()))
ds = DisjointSet(N)
p_dict = defaultdict(list)
i_dict = defaultdict(list)

for m in range(M):
    x, y = map(int, input().split())
    ds.unite(x-1, y-1)
# print(ds.p)
for i in range(N):
    dsp = ds.findSet(i)
    p_dict[dsp] += [P[i]]
    i_dict[dsp] += [i+1]
ans = 0
for key in p_dict.keys():
    ans += len(set(p_dict[key]) & set(i_dict[key]))
    # print(key, ans)
print(ans)

Measured memory_bytes: 139988
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

const int N = 100000;
const int M = 11;

double dp[N][M] , data[N+1] , ans[N],sum;
int n;

int main(void){
  data[0] = 1.0;
  loop(i,1,M+1)data[i] = data[i-1] * 0.5;
  fill(dp[0],dp[N],0.0);
  dp[0][0] = 1.0;
  rep(i,N){
    rep(j,M){
      if(dp[i][j] > 0.0){
	sum += dp[i][j] * data[j];
	dp[i+1][0] += dp[i][j] * (1.0 - data[j]);
	dp[i+1][j+1] += dp[i][j] * data[j];
      }
    }
    ans[i] = sum;
  }
  while(cin>>n,n)printf("%.3f\n",ans[n-1]);
  return 0;
}

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

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

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b,c,d;cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;

  return 0;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vector<int> dp(100000,0);
    //6*p or 9*p dp[値]
    rep(i,n+1){
        dp[i]=i;
    }
    int b=6; int q=9;
    for(int i=0;i<=n+1;i++){
        if(i>=b*6)b*=6;
        if(i>=q*9)q*=9;
        if(i<6) dp[i]=i;
        else if(i<9) dp[i]=min(dp[i-1]+1,dp[i-b]+1);
        else dp[i] = min({dp[i-1]+1,dp[i-b]+1,dp[i-q]+1});
    }
    
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 3716
n = int(raw_input())
a = map(int,raw_input().split())

a.sort()
m = max(a)
a.remove(m)

d = 99999999999
now = -1
if m%2 == 1:
  z = (m+1)/2
  for x in a:
    if d > abs(x - z):
      now = x
      d = abs(x - z)
  print m,now
else:
  z = m/2
  for x in a:
    if x<=z:
      if d > abs(z-x):
        now = x
        d = abs(x-z)
    else:
      if d > abs(x-z-1):
        now = x
        d = abs(x-z-1)
  print m,now


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans = a[0];
  int i = 1;
  int i2 = 1;
  while(i < n-1){
    ans += a[i2]*2;
    i += 2;
    if(i==n) ans -= a[i2];
    i2 ++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
// #define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  set<int> st;
 
  int N;
  cin >> N;
  
  REP(i, N) {
    int d;
    cin >> d;
    st.insert(d);
  }
  
  cout << st.size();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N, vector<int> H) {
  for (int i = N - 1; i > 0; i--) {
    if (H[i - 1] <= H[i]) {
      continue;
    } else if (H[i - 1] - H[i] == 1) {
      H[i - 1] -= 1;
    } else {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
}

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve(N, H);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int N;
    cin >> N;
    int W[N];
    for(int i=0;i<N;i++)cin >> W[i];
    int sum = 0;
    int dis = 1000000;
    for(int i=0;i<N;i++){
        sum += W[i];
        int a = accumulate(W+i+1,W+N,0);
        if(abs(sum-a) < dis)dis = abs(sum-a);
    }
    cout << dis <<endl;


}


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

int main(){
	int mi=1001,ma=-1;
	int x;
	scanf("%d",&x);
	for(int i=0;i<x;i++){
		int n;
		scanf("%d",&n);
		mi=min(mi,n);
		ma=max(ma,n);
	}
	printf("%d\n",ma-mi);
}

Measured memory_bytes: 256
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]

x, y = A[0]
for a, b in A[1:]:
    m = max(-(-x // a), -(-y // b))
    x = a * m
    y = b * m
    #print(x, y)
        
print(x + y)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            Dictionary<string, int> dicInp = new Dictionary<string, int>();
            for (int i = 0; i < iN; i++)
            {
                char[] sOne = System.Console.ReadLine().Trim().ToCharArray();
                Array.Sort(sOne);
                string s2 = new String(sOne);
                if (dicInp.ContainsKey(s2)) { dicInp[s2] += 1; }
                else { dicInp.Add(s2, 1); }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long iOut = 0;
            foreach (int iVul in dicInp.Values)
            {
                if (iVul > 1)
                {
                    iOut += ((long)iVul * (long)(iVul - 1L)) / 2L;
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int main() {
	int n; cin >> n;
	int p[n];
	for (int i = 0; i < n; i++) cin >> p[i];

	int ans = 0;
	for (int i = 1; i <= n - 2; i++) {
		if ((p[i] < p[i + 1] && p[i] > p[i - 1]) || (p[i] > p[i + 1] && p[i] < p[i - 1])) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(solve(a, b));
    }
  }

  public static String solve(int a, int b) {
    int c = a * b;  
    return c % 2 == 0 ? "No" : "Yes";
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n,m,x; cin >> n >> m >> x;
  vector<int> C(n);
  vector<vector<int>> A(n, vector<int>(m));
  rep(i, n) {
    cin >> C[i];
    rep(j, m) {
      cin >> A[i][j];
    }
  }

  int ans = INT_MAX;

  for(int bit = 1; bit < (1<<n); ++bit) {
    vector<int> points(m, 0);
    int money = 0;

    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) {
        money += C[i];
        rep(j, A[i].size()) {
          points[j] += A[i][j];
        }
      }
    }

    bool ok = 1;
    rep(j, m) {
      if(points[j] < x) {
        ok = 0;
        break;
      }
    }

    if(ok) {
      chmin(ans, money);
    }
  }

  if(ans == INT_MAX) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
<?php
$N=(int)fgets(STDIN);
$Ab=$As=explode(' ',trim(fgets(STDIN)));
 
for($i=0;$i<$N;$i++)
  for($j=$N-1;$i<$j;$j--)
    if($Ab[$j][1]<$Ab[$j-1][1])
      list($Ab[$j],$Ab[$j-1])=[$Ab[$j-1],$Ab[$j]];
 
for($i=0;$i<$N;$i++){
  for($mini=$j=$i;$j<$N;$j++)
    if($As[$j][1]<$As[$mini][1]) $mini=$j;
  if($i!=$mini) list($As[$i],$As[$mini])=[$As[$mini],$As[$i]];
}
 
$diff=0;
for($i=0;$i<$N;$i++){
  if($Ab[$i]!=$As[$i]){$diff=1;break;}
}
 
$sAb=implode(' ',$Ab);
echo $sAb,PHP_EOL,'Stable',PHP_EOL;
if($diff) echo implode(' ',$As),PHP_EOL,'Not stable',PHP_EOL;
else echo $sAb,PHP_EOL,'Stable',PHP_EOL;

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

using namespace std;

#define N 2025

void times(char a, int n) {
	while(n--) {
		cout << a;
	}
}

int main() {
	int x, y;
	int ax, ay;

	cin >> x >> y;
	cin >> ax >> ay;

	times('R', ax-x);
	times('U', ay-y);
	times('L', ax-x);
	times('D', ay-y);

	cout << 'D';
	times('R', ax-x + 1);
	times('U', ay-y + 1);
	cout << 'L';

	cout << 'U';
	times('L', ax-x+1);
	times('D', ay-y+1);
	cout << 'R' << endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())

if x == 1 or x == 2*n-1:
  print("No")

elif n == 2:
  print("Yes")
  for i in range(1, 4):
    print(i)

else:
  if x == 2:
    ans = [3, 1, 2, 4]
  else:
    ans = [x-1, x, x+1, x-2]
  key = []
  for i in range(1, 2*n):
    if i in ans:
      continue
    key.append(i)
  ans = key[:len(key)//2] + ans + key[len(key)//2:]
  
  print("Yes")
  for a in ans:
    print(a)

Measured memory_bytes: 19816
#include<stdio.h>
int S[10000000],n;


int twosearch(int k){
  int left=0,right=n, mid;

  while(left<right){
    mid=(left+right)/2;
    if(k==S[mid])return 1;
    if(k>S[mid])left=mid+1;
    else if(k<S[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q, key, sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(twosearch(key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}







Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  
  int N;
  int a[100];
  int ans = 0;
  cin >> N;
  REP(i, N){
    cin >> a[i];
  }
  REP(i, N-1){
    if(a[i] == a[i+1]){
      ans++;
      a[i+1] = N + ans;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

LL gcd(LL a, LL b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return gcd(b, a%b);
}

LL lcm(LL a, LL b){
    return a*b/gcd(a,b);
}

int main(){
    fastcin();

    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.14159265358979
#define coutdb cout<<fixed<<setprecision(30)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

struct BIT{
  // 1-indexed BIT
// private:
public:
  int N; vector<int> bit;
// public:
  BIT(vector<int> vec){
    N = vec.size();
    bit.assign(N+1, 0);
    copy(vec.begin(), vec.end(), bit.begin()+1);
  }
  void add(int a, int w){
    for(int x = a; x <= N; x += x & -x)
      bit[x] += w;
  }
  int sum(int a){ // prefix sum
    int res = 0;
    for(int x = a; x > 0; x -= x & -x)
      res += bit[x];
    return res;
  }
};

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

  int N, Q; cin >> N >> Q;
  BIT tree(vector<int>(N, 0));
  REP(_, Q){
    int com, x, y; cin >> com >> x >> y;
    if(com == 0){
      tree.add(x, y);
    } else {
      cout << tree.sum(y) - tree.sum(x-1) << endl;
    }
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >>D;

  if( A+B == C+D ){
    cout << "Balanced" << endl;
  }
  else if ( A+B < C+D ){
    cout << "Right" << endl;
  }
  else if ( A+B > C+D ){
    cout << " Left " << endl;
  }

}

Measured memory_bytes: 256
A, B, C = map(int, input().split())

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    print(0)
else:
    a = abs((A // 2) * B * C - ((A + 1) // 2) * B * C)
    b = abs(A * (B // 2) * C - A * ((B + 1) // 2) * C)
    c = abs(A * B * (C // 2) - A * B * ((C + 1) // 2))
    print(min(a, b, c))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main()
{
	cin>>n;
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		f|=f<<x;
		sum+=x;
	}
	for(int i=(sum+1)/2;i<=sum;i++)
	{
		if(f[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359

int main(){
  int n,k;
  cin>>n>>k;
  int count=0;
  while(n>0){
    n/=k;
    count++;
  }
  cout<<count<<endl;
}

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

using namespace std;
using LL = long long;
using VI = vector<int>;
using PI = pair<int, int>;

struct Dice {
	Dice() {}
	~Dice() {}

	void get() {
		for (int i = 0; i < 6; i++) {
			cin >> d[i];
		}
	}
	void roll(char c) {
		int t = d[0];
		switch (c) {
		case 'N':
			d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = t;
			break;
		case 'S':
			d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = t;
			break;
		case 'W':
			d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = t;
			break;
		case 'E':
			d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = t;
			break;
		default:
			break;
		}
	}
	int top() { return d[0]; }
	int d[6];
};

int main() {
	Dice d;
	d.get();
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		d.roll(s[i]);
	}
	cout << d.top() << endl;
	return 0;
}



Measured memory_bytes: 3184
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    acc = [0] * (N+1)
    for _ in range(M):
        left, right = map(int, input().split())
        acc[left-1] += 1
        acc[right] -= 1

    cnt = 0
    for a in accumulate(acc):
        if a == M:
            cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3956