akhauriyash/Code-Regression huggingface dataset:
/**    ~* BISMILLAHIR RAHMANIR RAHIM *~    **/

#include <bits/stdc++.h>

using namespace std;

typedef long long intl;

const int MX = 1123456;
intl n, a[MX], b[MX], c[MX];

int main()
{
  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  cin>>n;
  for(int i=1; i<=n; i++) {
    cin>>a[i];
    b[i] = abs(a[i]-a[i-1]);
  }
  b[n+1] = abs(a[n+1]-a[n]);
  for(int i=1; i<=n+1; i++) {
    c[i] = c[i-1] + b[i];
  }
  for(int i=1; i<=n; i++) {
    intl res = c[i-1];
    res += (c[n+1]-c[i+1]);
    res += abs(a[i+1]-a[i-1]);
    cout<<res<<endl;
  }
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> ans(N);
    int A;
    for (int i = 1; i <= N; i++)
    {
        cin >> A;
        ans[A - 1] = i;
    }
    rep(i, N)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  string S;
  cin>>S;
  int X = 0;
  if (S[0]=='+') X++; else X--;
  if (S[1]=='+') X++; else X--;
  if (S[2]=='+') X++; else X--;
  if (S[3]=='+') X++; else X--;
  cout<<X<<endl;
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> x(N), y(N);
  for(int i=0;i<N;i++) {
    cin >> x[i];
    y[i]=x[i];
  }
  sort(x.begin(), x.end());
  for(int i=0;i<N;i++) {
    if(y[i]<=x[N/2-1]) cout << x[N/2] << endl;
    else cout << x[N/2-1] << endl;
  }
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif

typedef std::pair<int, int> IntPair;


//static void ABC120D_DecayedBridges();
static void ABC118B_FoodsLovedByEveryone();


#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC118B_FoodsLovedByEveryone();

	fflush(stdout);
	return 0;
}
#endif

static void ABC118B_FoodsLovedByEveryone()
{
	int N, M;
	scanf(" %d %d", &N, &M);

	int K, like;
	char survey[30] = { 0 };
	for (int i = 0; i < N; i++) {
		scanf(" %d", &K);

		for (int j = 0; j < K; j++) {
			scanf(" %d", &like);
			survey[like - 1]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (survey[i] == N) {
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k, s;
int ans;

void func(int cnt, int sum, int pre){
  if(cnt == k){
    if(sum == s) ans++;
    return;
  }
  if(cnt > k) return;
  for(int i = pre-1; i > 0; i--){
    func(cnt+1, sum + i, i);
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin >> n >> k >> s, n | k | s){
    ans = 0;
    func(0, 0, n+1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll N,M;
  cin>>N>>M;
  
  if(N==1 && M==1) cout<<1<<endl;
  else if(N==1 && M>1) cout<<M-2<<endl;
  else if(N>1 && M==1) cout<<N-2<<endl;
  else cout<<(N-2)*(M-2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
  int N, M, tmpA, tmpB, tmpC;
  cin >> N >> M;
  
  vector<int> A;
  for (int i=0; i<N; i++) {
    cin >> tmpA;
    A.push_back(tmpA);
  }
  vector<int> B, C;
  std::sort(A.begin(), A.end()); // 1, 2, 3...
  
  for (int j=0; j<M;  j++) {
    cin >> tmpB >> tmpC;
    B.push_back(tmpB);
    C.push_back(tmpC);
  }
  priority_queue<pair<int, int>> q; // 大きい順に出てくるque, １つ目の要素の大小が優先
  
  rep(i, N) {
    q.push(make_pair(A[i], 1));
  }
  rep(i, M){
    q.push(make_pair(C[i], B[i])); // CiをBi個
  }
  
  long long ans = 0;
  rep(i, N) {
    auto p = q.top();
    q.pop();
    
    ans += p.first; // first element in the pair
    if(p.second>1) {
      p.second--;
      q.push(p);
    }
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 200005, MAXM = 3003, Mod = 1000000007 , MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    vector<int> arr(6);
    for (int i = 0; i < 6; ++i) {
        cin >> arr[i];
    }

    for (int i = 5; i > 0; --i) {
        for (int j = i - 1; j >= 0; --j) {
            if (arr[i] - arr[j] > arr.back()) {
                cout << ":(\n";
                return 0;
            }
        }
    }

    cout << "Yay!\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector< PII > teams( n );
		REP( i, 0, n )
		{
			int c;
			VI times( 8 );
			cin >> c;
			FOR( t, times )
			{
				cin >> t;
			}

			int total = 0;
			for ( int j = 0; j < 8; j += 2 )
			{
				total += times[j] * 60 + times[ j + 1 ];
			}

			teams[i] = MP( total, c );
		}
		sort( ALL( teams ) );

		cout << teams[0].snd << endl;
		cout << teams[1].snd << endl;
		cout << teams[ n - 2 ].snd << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
class Book:
    def __init__(self, no, name, value):
        self.no = no
        self.name = name
        self.value = value

book = []
n = int(input())
for i in range(n):
    s, p = input().split()
    book.append(Book(i, s, int(p)))

book = sorted(book, key=lambda b: b.value, reverse=True)
book = sorted(book, key=lambda b: b.name)
for b in book:
    print(b.no+1)


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  string S;
  map<string, ll> cnt;
  rep(i, N){
    cin >> S;

    cnt[S]++;
  }

  ll num = -1;
  
  for(auto it = cnt.begin(); it != cnt.end(); it++)
    num = max(num, it->second);

  set<string> strs;

  for(auto it = cnt.begin(); it != cnt.end(); it++){
    if(it->second == num)
      strs.insert(it->first);
  }

  for(auto it = strs.begin(); it != strs.end(); it++)
    cout << (*it) << "\n";
  
  return 0;
}


Measured memory_bytes: 34792
#include <stdio.h>

int main()
{   int a,b,c,ans;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=1;;i++){
        int q=a/2;
        int w=b/2;
        int e=c/2;
        if(a==b&&b==c&&a!=0&&a%2==0){
        ans=-1;
        break;

        }
        if(a%2!=0||b%2!=0||c%2!=0){
        ans=0;
        break;

        }

        if(i>2000){

          ans=-1;
            break;

        }
        if((q+w)%2!=0){
            ans=i;
            break;
        }
        if((q+e)%2!=0){
            ans=i;
            break;
        }


    if((w+e)%2!=0){
            ans=i;
            break;
        }
        a=e+w;
        b=q+e;
        c=q+w;


        }
        printf("%d",ans);

    return 0;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Tsundoku | diff Tsundoku.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Tsundoku.cpp && ./a.out

/*

 6/27/2020

 5:03-5:19, 5:51-6:00 WA
 6:05 AC

 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N],K;
int N,M;

void solve() {
  int j=M;
  LL sumb=accumulate(B,B+M,0LL);
  int res=0;
  LL suma=0;
  REPE(i,N) {
    while(suma+sumb>K&&j>0) sumb-=B[j-1],--j;
    if(suma+sumb<=K) SMAX(res,i+j);
    if(i<N)suma+=A[i];
  }
  cout<<res<<endl;
}

void solve_ac() {
  vector<LL> cum(M+1,0);
  REP(i,M)cum[i+1]=cum[i]+B[i];
  LL cur=0;
  //dumpc(cum);
  int res=0;
  REPE(i,N) if(cur<=K) {
    LL rem=K-cur;
    assert(rem>=0);
    int j=upper_bound(ALL(cum),rem)-cum.begin();
    //dump(i,j,cur,rem);
    SMAX(res,i+j-1);
    if(i<N)cur+=A[i];
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M>>K;
  REP(i,N) cin>>A[i];
  REP(i,M) cin>>B[i];
  solve();

  return 0;
}


Measured memory_bytes: 6776
<?php
  fscanf(STDIN, "%d", $n);
  $a = $n % 10;
  if ($a==2 or $a==4 or $a==5 or $a==7 or $a==9) {
  	echo "hon";
  } elseif ($a==3) {
  	echo "bon";
  } else {
  	echo "pon";
  }
?>

Measured memory_bytes: 16056
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int X;
    cin >> X;
    cout << 10-(X/200) << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

void selectionSort(long long A[],long long N){
long long i, j, k, min, temp;
    for (i = 0; i < N - 1; i++) {
        min = A[i];                
        k = i;                        
        for (j = i + 1; j < N; j++) {
            if (A[j] < min) { 
                min = A[j];
                k = j;
            }
        } 
        temp = A[i];
        A[i] = A[k];
        A[k] = temp;
    }
}

int main(){
long long int N,M,x,y,point[8];
long long int  b[1000],d[1000],p[1000],A[1000],B[1000],C[1000],D[1000],E[1000],F[1000],G[1000],H[1000];


scanf("%lld %lld ",&N,&M);

for(int i = 0;i < N; i++){
    scanf("%lld %lld %lld",&b[i],&d[i],&p[i]);
    A[i] = b[i] + d[i] + p[i];
    B[i] = b[i] + d[i] - p[i];
    C[i] = b[i] - d[i] + p[i];
    D[i] = -b[i] + d[i] + p[i];
    E[i] = -b[i] - d[i] + p[i];
    F[i] = -b[i] + d[i] - p[i];
    G[i] = b[i] - d[i] - p[i];
    H[i] = -b[i] - d[i] - p[i];
}
selectionSort(A,N);
selectionSort(B,N);
selectionSort(C,N);
selectionSort(D,N);
selectionSort(E,N);
selectionSort(F,N);
selectionSort(G,N);
selectionSort(H,N);

for(int i=1;i<=M;i++){
point[0]=point[0]+A[N-i];
point[1]=point[1]+B[N-i];
point[2]=point[2]+C[N-i];
point[3]=point[3]+D[N-i];
point[4]=point[4]+E[N-i];
point[5]=point[5]+F[N-i];
point[6]=point[6]+G[N-i];
point[7]=point[7]+H[N-i];
}
selectionSort(point,8);
printf("%lld\n",point[7]);
return 0;
}

Measured memory_bytes: 256
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("%s = %s\n", #x, to_string(x).data())
string to_string (string s) { return "\"" + s + "\""; }
template<typename T> string to_string (vector<T>);
template<typename U, typename V> string to_string (pair<U, V> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template<typename T> string to_string (vector<T> v) {
	string res = "["; for (int i = 0; i < (int)v.size() - 1; i++) res += to_string(v[i]) + ", ";
	if (!v.empty()) res += to_string(v.back());	res += "]"; return res; }

const int N = 100010;
char s[N];
int n, k;

int solve() {
	int z = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'L' && s[i - 1] == 'L') z++;
		else if (s[i] == 'R' && s[i + 1] == 'R') z++;
	
	int inv = 1;
	for (int i = 2; i <= n; i++) if (s[i] != s[i - 1]) inv++;
	if (k >= inv / 2) return n - 1;
	return z + 2 * k;
}

int main () { 
#ifdef XVENOM
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &k);
	scanf("%s", s + 1);
	s[0] = 0;
	printf("%d\n", solve());
}

Measured memory_bytes: 384
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, m = M()
h_list = LI()
ans_list = [1] * n
for _ in range(m):
    a, b = M()
    if h_list[a-1] < h_list[b-1]:
        ans_list[a-1] = 0
    elif h_list[a-1] == h_list[b-1]:
        ans_list[a-1] = 0
        ans_list[b-1] = 0
    else:
        ans_list[b-1] = 0
print(sum(ans_list))

Measured memory_bytes: 93712
//Dragon_warrior7(IITK)
//#pragma GCC optimize("O0") 
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll>
#define rub cerr << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(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 modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
inline void read(vector<ll> &v);
inline ll max(ll a,ll b);
inline ll min(ll a,ll b);
inline ll gcd(ll a ,ll b);
void storepowers(int n,vector<int> &a);
#define debug 0
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{if(debug)cout<<"Case #"<<test<<':'<<'\n';
cin>>a>>b>>n;
if(a==1 || b==1)
{
    cout<<0;
    return ;
}
if(a==b)
{
    cout<<min(b-1,n);
    return ;
}
            ll mi=min(b-1,n);
            ll calc=(a*mi)/b;
            calc-=a*(mi/b);
            cout<<calc;




if(debug)cout<<'\n';
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
 	//cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}
void storepowers(int n,vector<int> &a)
{
    a.resize(n+1);
    a[0]=1;
    for(int i=1;i<=n;i++)
    a[i]=a[i-1]*2;
    return ;
}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
inline void read(vector<ll> &v)
{for (int i = 0; i < v.size(); i++)cin>>v[i];}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

//約数の列挙
vector<ll> divisor(ll n) {
	vector<ll> res;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}

signed main() {
	ll n;
	ll ans = 0;

	cin >> n;

	vector<ll> v = divisor(n);

	REP(i, v.size()) {
		if (v[i] == 1) {
			continue;
		}

		if (floor(n / (v[i] - 1)) == n / v[i]) {
			ans += v[i] - 1;
		}
	}

	cout << ans << endl;
}

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

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

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    ll N,K;
    cin>>N>>K;
    ll ans = 0;
    for(ll i = K; i <= N+1; i++){
        ans=(ans+(i*(2LL*N-i+1)-i*(i-1))/2LL+1LL)%mod;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    char str;
    int rank;

    int S[13],H[13],C[13],D[13];

    for(int i=1; i<=13; i++)
        S[i]=H[i]=C[i]=D[i]=0;

    for(int i=1; i<=n; i++)
    {
        cin>>str>>rank;

        if(str=='S')
        {
            S[rank]=1;
        }

        else if(str=='H')
        {
            H[rank]=1;
        }

        else if(str=='C')
        {
            C[rank]=1;
        }

        else if(str=='D')
        {
            D[rank]=1;
        }

    }

    for(int i=1; i<=13; i++)
    {
        if(S[i]==0)
        {
            cout<<"S"<<" "<<i<<"\n";
        }
    }

    for(int i=1; i<=13; i++)
    {

        if(H[i]==0)
        {
            cout<<"H"<<" "<<i<<"\n";
        }
    }


   for(int i=1; i<=13; i++)
    {

        if(C[i]==0)
        {
           cout<<"C"<<" "<<i<<"\n";
        }

    }

    for(int i=1; i<=13; i++)
    {

        if(D[i]==0)
        {
           cout<<"D"<<" "<<i<<"\n";
        }
    }


  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define debug(x) std::cerr<<"L: "<<__LINE__<<" f("<<__FUNCTION__<<") Var: "<<#x<<" Val: "<<x<<"\n";
typedef long long ll;

ll n, ns[200005], sum[200005], s, b, c, d, e, ans = 1e15 + 7;

bool check(ll x, ll y, int i) {
	if (abs((x + ns[i]) - (y - ns[i])) < abs(x - y))
		return 1;
	return 0;
}

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

	for (int i = 0; i < n; ++i) {
		std::cin >> ns[i];
		s += ns[i];
		sum[i] = s;
	}

	int j = 0, k = 2;
	for (int i = 1; i < n - 2; i++) {
		b = sum[j];
		c = sum[i] - sum[j];
		d = sum[k] - sum[i];
		e = sum[n - 1] - sum[k];
		while (check(b, c, j + 1) && j + 1 < i) {
			j++;
			b = sum[j];
			c = sum[i] - sum[j];
		}
		while (check(d, e, k + 1) && k + 1 < n - 1) {
			k++;
			d = sum[k] - sum[i];
			e = sum[n - 1] - sum[k];
		}
		ans = std::min(ans, std::max({b, c, d, e}) - std::min({b, c, d, e}));
	}

	std::cout << ans;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    rep(i, K)
        sum += l[i];

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double db;
const int INF = 0x7fffffff;
const int maxn = 5e4 + 10;
int main()
{
	int x;
	cin >> x;
	if (x == 1)printf("1");
	for (int i = x; i >= 1; i--)
	{
		for (int j = 2; j <= 32; j++)
		{
			for (int k = 2; k <= 10; k++)
			{
				if (pow(j, k)>i)break;
				if (pow(j, k) == i)
				{
					printf("%d", i);
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int K;

    private class P implements Comparable<P> {
        int m;
        long c;

        public P(int m,long c) {
            this.m = m;
            this.c = c;
        }

        public int compareTo(P p) {
            return Long.compare(this.c,p.c);
        }
    }

    private void solve() {
        K = nextInt();

        PriorityQueue<P> pq = new PriorityQueue<>();
        pq.add(new P(1,1));

        long[] min = new long[K];
        Arrays.fill(min,Long.MAX_VALUE / 2);

        long ans = Long.MAX_VALUE;
        while(pq.size() > 0) {

            P p = pq.poll();

            if (min[p.m] <= p.c) {
                continue;
            }

            min[p.m] = p.c;
            if (p.m == 0) {
                ans = Math.min(ans,p.c);
            }

            pq.add(new P((p.m + 1) % K,p.c + 1));
            pq.add(new P((p.m * 10) % K,p.c));
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 31348
using System;
class Program
{
  static void Main()
  {
    int[] lines ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    var num=int.Parse(Console.ReadLine());
    Console.WriteLine(lines[num-1]);
    
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

int main()
{
    ll n, m, x;
    cin >> n >> m >> x;
    vector<vector<ll>> d(n, vector<ll>(m + 1, 0));
    repi(i, n, 0)
    {
        repi(j, m + 1, 0)
        {
            cin >> d[i][j];
        }
    }
    ll ans = INF;
    repb(bit, n, 0)
    {
        vector<ll> data(m + 1, 0);
        repi(i, n, 0)
        {
            if (bit & (1 << i))
            {
                repi(j, m + 1, 0)
                {
                    data[j] += d[i][j];
                }
            }
        }
        bool ok = true;
        repi(i, m + 1, 1)
        {
            if (data[i] < x)
                ok = false;
        }
        if (ok)
            ans = min(ans, data[0]);
    }
    if (ans == INF)
        ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

int main() {
    int n_AC = 0;
    int n_WA = 0;
    int n_TLE = 0;
    int n_RE = 0;

    int N;
    std::cin >> N;
    for (size_t i = 0; i < N; i++) {
        std::string S;
        std::cin >> S;
        if (S == "AC")
            n_AC++;
        else if (S == "WA")
            n_WA++;
        else if (S == "TLE")
            n_TLE++;
        else if (S == "RE")
            n_RE++;
        else
            std::cerr << "invalid input" << std::endl;
    }
    std::cout << "AC x " << n_AC << std::endl;
    std::cout << "WA x " << n_WA << std::endl;
    std::cout << "TLE x " << n_TLE << std::endl;
    std::cout << "RE x " << n_RE << std::endl;
}

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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int[] arr = inputval();
        int A, B;
        String S;
        A = arr[0];
        B = arr[1];
        S = br.readLine().trim();
        String str = "No";

        for (int i = 0; i < A + B + 1; i++) {
            if (i == A) {
                if (S.charAt(i) != '-') break;
            }else{
                if(!('0' <= S.charAt(i) && S.charAt(i) <= '9')) break;
            }
            if(i==A+B) str = "Yes";
        }
        System.out.println(str);
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
// 最大公約数を求める関数gcd
long long gcd(long long x,long long y){
long long r;
    while((r= x % y)!=0){x=y; y=r;}
    return y;
}
// 最小公倍数を求める関数lcm
long long lcm(long long x,long long y){return (x/gcd(x,y)*y);}
 
int main(){
  long long N,ans;
  cin >> N;
  vector<long long> T(N);
  for(int i=0;i<N;i++){cin >> T[i];}
  ans=T[0];
  for(int i=1;i<N;i++){
    ans=lcm(ans,T[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 

int main(void) {
  int n;
  cin >> n;
  ll a[n];
  ll a_sum = 0;
  rep (i, n) {
    cin >> a[i];
    a[i] -= i + 1;
  }

  sort(a, a + n);

  int m1 = a[n / 2], m2 = a[n / 2 + 1], m3 = a[n / 2 - 1];

  ll sum1 = 0, sum2 = 0, sum3 = 0;

  rep (i, n) sum1 += abs(a[i] - m1);
  rep (i, n) sum2 += abs(a[i] - m2);
  rep (i, n) sum3 += abs(a[i] - m3);
  cout << min({sum1, sum2, sum3}) << endl;
  return 0;
}
  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int t;
	cin>>t;
	int a,b;
	cin>>a>>b;
	for(int i=2;i<t;i++){
		int sum;
		cin>>sum;
		n^=sum;
	}
	int ans=(a+b-n)/2;
	if(ans<0||ans>a||(ans&n)||(a+b-n)%2==1){
		cout<<"-1"<<endl;
		return 0;
	}
	for(int i=56;i>=0;i--){
		if(n>>i&1LL){
			if(ans+(1LL<<i)<=a){
				ans+=(1LL<<i);
			}
		}
	}
	if(ans==0){
		cout<<"-1"<<endl;
		return 0;
	}else{
		cout<<a-ans<<endl;
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

ll modpower(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpower(a, mod - 2, mod);
}

ll calc(int x, int y) {
    ll res = 1;
    FOR (i, x - y + 1, x + 1) {
        res *= i;
        res %= MOD;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    int a, b;
    cin >> n >> a >> b;
    ll res = (modpower(2, n, MOD) - 1) % MOD;
    ll x = calc(n, a);
    FOR (i, 1, a + 1) {
        x *= modinv(i, MOD);
        x %= MOD;
    }
    ll y = calc(n, b);
    FOR (i, 1, b + 1) {
        y *= modinv(i, MOD);
        y %= MOD;
    }
    res -= x;
    if (res < 0) res += MOD;
    res -= y;
    if (res < 0) res += MOD;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e10;

ll ans = INF;
 
void calc(ll s1, ll s2, ll s3) {

    if(s1 > 0 && s2 > 0 && s3 > 0) {

        ll maxS = max({s1, s2, s3});
        ll minS = min({s1, s2, s3});

        ll now = maxS - minS;

        ans = min(ans, now);
    }
}

int main() {
    ll h, w, s1, s2, s3, a, b;
    cin >> h >> w;

    rep(i, h) {

        a = (h-i)/2;
        b = h-(i+a);

        s1 = i*w;
        s2 = a*w;
        s3 = b*w;

        calc(s1, s2, s3);
    }

    rep(i, h) {
        
        a = w/2;
        b = w-a;

        s1 = i*w;
        s2 = a*(h-i);
        s3 = b*(h-i);

        calc(s1, s2, s3);
    }

    rep(j, w) {

        a = (w-j)/2;
        b = w-(j+a);

        s1 = j*h;
        s2 = a*h;
        s3 = b*h;

        calc(s1, s2, s3);
    }

    rep(j, w) {

        a = h/2;
        b = h-a;

        s1 = j*h;
        s2 = a*(w-j);
        s3 = b*(w-j);

        calc(s1, s2, s3);
    }

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

Measured memory_bytes: 256
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int retMax(int a, int b, int c) {
    if (b <= a && c <= a) {
        return a;
    }
    if (a <= b && c <= b) {
        return b;
    }
    if (a <= c && b <= c) {
        return c;
    }
    return 0;
}

int main() {
    int A, B;
    cin >> A >> B;
    cout << retMax(A+B, A-B, A*B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    // input
    int n;
    cin >> n;
    int x[n], y[n], h[n];
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
        // if h[i] is bigger than 0, i group will be the 0 group
        if(h[i] > 0){
            swap(x[0], x[i]);
            swap(y[0], y[i]);
            swap(h[0], h[i]);
        }
    }

    bool checker;
    rep(cx, 101){
        rep(cy, 101){
            // brute-force attack of (cx, cy)
            // ch is the center height
            // che starts with the maximum height
            int ch = h[0] + abs(x[0] - cx) + abs(y[0] - cy);
            checker = true;
            rep(i, n){
                // if ch meets the condition, the (cx, cy, ch) is the answer
                if( max( ch - abs( x[i] - cx ) - abs( y[i] - cy ), 0) != h[i]){
                    checker = false;
                }
            }
            if(checker){
                cout << cx << " "<< cy << " " << ch << endl;
                return 0;
            }
        }
    }



    return 0;
}


Measured memory_bytes: 256
abcd = input()

import itertools

for op in itertools.product(["+", "-"], repeat=3):
    sm = int(abcd[0])
    for i in range(3):
        if op[i] == "+":
            sm += int(abcd[i+1])
        else:
            sm -= int(abcd[i+1])
    if sm == 7:
        break

ans = str(abcd[0])
for i in range(3):
    ans += op[i] + abcd[i+1]
ans += "=7"
print(ans)


Measured memory_bytes: 3188
n=int(input())
dp=[]
for i in range(n):
  l=list(map(int,input().split()))
  dp.append(l)
for i in range(1,n):
  for j in range(3):
  	dp[i][(j%3)]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) 
print(max(dp[n-1]))

Measured memory_bytes: 30260
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])

time = 0
ans = 'Yes'
for i in range(n):
    time += ab[i][0]
    if time > ab[i][1]:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 90072
#include <bits/stdc++.h>
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;

int fac[600005], ifac[600005];
int comb(int n, int m)
{
	return n < m ? 0 : 1LL * fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int n, m, l, r;
int f(int x)
{
	return (comb(r - x + n, n) - comb(l - 1 - x + n, n) + MOD) % MOD;
}

int main()
{
	fac[0] = 1;
	rep1(i, 600000) fac[i] = 1LL * fac[i - 1] * i % MOD;
	rep1(i, 600000) ifac[i] = i == 1 ? 1 : MOD - 1LL * ifac[MOD % i] * (MOD / i) % MOD;
	ifac[0] = 1;
	rep1(i, 600000) ifac[i] = 1LL * ifac[i - 1] * ifac[i] % MOD;
	
	scanf("%d%d%d%d", &n, &m, &l, &r);
	m = n - m;
  
	int ans = 0;
	rep1(x, r) for(int j = 0; j <= m && 1LL * (n - m + j) * x <= r; j ++)
	if(j & 1) ans = (ans - 1LL * comb(m, j) * comb(n, m) % MOD * f((n - m + j) * x) % MOD + MOD) % MOD; 
	else ans = (ans + 1LL * comb(m, j) * comb(n, m) % MOD * f((n - m + j) * x)) % MOD;
	
	rep1(x, r) for(int j = 0; j <= m && 1LL * (n - m) * (x + 1) + 1LL * j * x <= r; j ++)
	if(j & 1) ans = (ans + 1LL * comb(m, j) * comb(n, m) % MOD * f((n - m) * (x + 1) + j * x)) % MOD; 
	else ans = (ans - 1LL * comb(m, j) * comb(n, m) % MOD * f((n - m) * (x + 1) + j * x) % MOD + MOD) % MOD;
	
	ans = (f(0) - ans + MOD) % MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define all(c)  c.begin(), c.end()
#define vi vector<int>
#define vll vector<ll>
#define vp vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 998244353
#define MAX LLONG_MAX
using namespace std;
/*vll a[200001];
vll lev(200001,0),num(200001);
void dfs(ll s, ll e) {
    num[s]=1;
    lev[s]=lev[e]+1;
     for (auto u : a[s])
        {
            if (u == e)
                continue;
        dfs(u, s);
        num[s]+=num[u];
        }
     }
     */
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k=0,n;
string s,t;
cin>>s>>t;
rep(i,0,s.size())
if(s[i]!=t[i])
{
    k++;
    break;
}
if(k)
    cout<<"No";
else
    cout<<"Yes";
return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    if(x+y<=n)cout<<min(x,y)<<" "<<0<<endl;
    else cout<<min(x,y)<<" "<<max(x,y)+min(x,y)-n<<endl;
}

Measured memory_bytes: 256
# ABC 128, B - guidebook
from operator import itemgetter

n = int(input())

X = []
for i in range(n):
    tmp = input().split(' ')
    X.append((i+1, tmp[0], -int(tmp[1])))
X.sort(key=itemgetter(1, 2))

for i in range(n):
    print(X[i][0])


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

int main()
{
    ll N; cin >> N;
    vector<ll> L(N, 0);
    rep(i,N) {
        ll tmp; cin >> tmp;
        L[i] = tmp;
    }
    ll ans = 0;
    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            for (int k = j+1; k < N; ++k) {
//                cout << "i = " << i << ",j = " << j << ",k = " << k << endl;
                if (L[i] == L[j] || L[j] == L[k] || L[i] == L[k]) continue;
                vector<ll> v;
                v.push_back(L[i]);
                v.push_back(L[j]);
                v.push_back(L[k]);
                sort(v.begin(), v.end());
//                cout << v[0] << " " << v[1] << " " << v[2] << endl;
                if (v[2] < (v[0] + v[1])) ans++;

            }
        }
    }

    cout << ans << endl;



}


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

int main()
{
	int N, a[100];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a, a + N);
	reverse(a, a + N);

	int A = 0, B = 0;

	for (int i = 1; i <= N; i++) {
		if (i % 2 == 0)B += a[i - 1];
		else A += a[i - 1];
	}

	cout << A - B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int a, b, c;
  set<int> s;
  scanf("%d%d%d", &a, &b, &c);
  s.insert(a);
  s.insert(b);
  s.insert(c);
  printf("%d\n", s.size());
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(long long i = 0; i < (n); i++)
using ll = long long;
using namespace std;

ll mod_mul(ll a, ll b, ll mod)
{
    return a % mod * (b % mod) % mod;
}

ll mod_pow(ll a, ll b, ll mod)
{
    if(b == 0) return 1;
    else if(b % 2 == 0){
        return mod_pow(mod_mul(a, a, mod), b/2, mod);
    } else{
        return mod_mul(a, mod_pow(a, b-1, mod), mod);
    }
}

ll mod_div(ll a, ll b, ll mod)
{
    return a % mod * mod_pow(b, mod - 2, mod) % mod;
}

int main()
{
    const ll mod = 1e9+7;
    ll x, y;
    cin >> x >> y;
    ll z = max(x,y);
    vector<ll>mod_facto(z+1);
    mod_facto[0] = 1;
    for(ll i = 1; i <= z; i++){
        mod_facto[i] = mod_mul(i, mod_facto[i - 1], mod);
    }
    rep(i,z){
        ll n = x, m = y, a = i, b = 0;
        n -= i;
        m -= 2 * i;
        if(n % 2 == 0){ 
            b = n / 2;
            n %= 2;
        }
        if(b == m && n == 0){
            cout << mod_div(mod_facto[a + b], mod_mul(mod_facto[a], mod_facto[b], mod), mod) << endl;
            return 0;
        }
        n = x;
        n -= i;
        if(m <= 0 || n <= 0) break; 
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 11132
from collections import deque
N = int(input())
A = list(map(int, input().split()))
plus = 0
minus = 0
for i in range(N):
    if A[i] >= 0:
        plus += 1
    else:
        minus += 1
bb = deque(sorted(A))
x = [0]*(N-1)
y = [0]*(N-1)
for i in range(N-1):
    if len(bb) == 2:
        l = bb.popleft()
        r = bb.pop()
        if l > r:
            ret = l-r
            x[i] = l
            y[i] = r
        else:
            ret = r - l
            x[i] = r
            y[i] = l
    else:
        l = bb.popleft()
        r = bb.pop()

        if plus > minus:
            ret = l - r
            x[i] = l
            y[i] = r
            plus -= 1
        else:
            ret = r - l
            x[i] = r
            y[i] = l
            minus -= 1
    if ret > 0:
        bb.append(ret)
    else:
        bb.appendleft(ret)
print(bb.pop())
for i in range(N-1):
    print(x[i], y[i])

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

int main() {
double N,K;
  cin >> N >> K;
  double a;
  vector<double> retu(N);
  for(int i = 0; i < N; i++){
  	cin >> a;
    retu[i] = a+1;
  }
  double mm = 0;
  for(int i = 0; i < K; i++){
  	mm += retu[i];
  }
  //これでmmはまずi = 0からK個の期待値の和
  vector<double> kitai(N);
  kitai[0] = mm;
  for(int i = 0; i < N-K; i++){
  	kitai[i+1] = kitai[i] - retu[i] + retu[i+K];
    mm = max(mm, kitai[i+1]);
  }


  cout << fixed << setprecision(8) << mm/2 << endl;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans (n);
    int count = 0;
    for(int rl=0; rl<2; rl++){
        for(int i=0; i<n; i++){
            if(s.at(i) == 'R') count++;
            else{
                ans.at(i) += count/2;
                ans.at(i-1) += (count+1)/2;
                count = 0;
            }
        }
        reverse(s.begin(),s.end());
        reverse(ans.begin(),ans.end());
      
        for(int i=0; i<n; i++){
            if(s.at(i) == 'L') s.at(i) = 'R';
            else s.at(i) = 'L';
        }
    }
  
    for(int a : ans){
        cout << a << endl;
    }
}


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

int main() {
  int N, A;
  cin >> N;
  
  int min = 33;
  for (int i = 0; i < N; i++) {
    int n = 0;
    cin >> A;
    for (int j = 0; j < 31; j++) {
      if (A % 2 == 0) {
        n = n + 1;
        A = A / 2;
      }
      else
        break;
    }
    if (n < min)
      min = n;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int k ,x;
    cin >> k >> x;
    if (500*k >= x){
         cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < n; ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long

template<typename T, typename U>
inline auto cmn (T& a, U b) {if (a > b) {a = b; return true;} return false;}
template<typename T, typename U>
inline auto cmx (T& a, U b) {if (a < b) {a = b; return true;} return false;}

constexpr int max = 16;
constexpr int Max = 1 << max;
int a[max][max];
lint whole[Max];
lint ans[Max];
int  ckd[Max];

int n;

auto at(int bs, int i)
{
  return (bs >> i) & 1;
}

auto cal(int bs)
{
  if (ckd[bs]) return ans[bs];
  auto& ret = ans[bs];
  assert(ret == 0);
  for (int i = 0; i < n; i++)
  {
    if (!at(bs, i)) continue;
    for (int j = i + 1; j < n; j++)
    {
      if (!at(bs, j)) continue;
      ret += a[i][j];
    }
  }
  whole[bs] = ret;
  for (int cs = bs; cs > 0; cs--)
  {
    cs &= bs;
    if (cs == 0) break;
    assert((bs & cs) == cs);
    auto ds = bs ^ cs;
    cmx(ret, whole[cs] + cal(ds));
    if (cs == 0) break;
  }
  ckd[bs] = true;
  return ret;
}


int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::cin >> n;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      std::cin >> a[i][j];
    }
  }
  std::cout << cal((1 << n) - 1) << std::endl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
map< pair<int,int>  , int>m;
int main() {
    
    int x,y;
    cin>>x>>y;
    m[{x,y}]++;
    m[{y,x}]++;
    cin>>x>>y;
    m[{x,y}]++;
    m[{y,x}]++;
    cin>>x>>y;
    m[{x,y}]++;
    m[{y,x}]++;
    
	int a[] = {1,2,3,4};
	string ans = "NO";
	do {
	    if(m[{a[2], a[1]}] && m[{a[3], a[2]}] && m[{a[0], a[3]}]) {
	        ans = "YES";
	        break;
	    }
	} while(next_permutation(a, a+4));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256