akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
intvec A;
ll ans;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	for(int i=1; i<N; i++) {
		if(A[i-1]-A[i]>0) {
			ans+=A[i-1]-A[i];
			A[i]=A[i-1];
		}
	}
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3992
N = int(input())
A = list(map(int,input().split()))
flag = 1
count = 0

while flag:
    flag = 0
    for i in range(N-1,0,-1):
        if A[i] < A[i-1]:
          tmp = A[i]
          A[i] = A[i-1]
          A[i-1] = tmp
          flag = 1
          count += 1
print(' '.join([str(a) for a in A])) 
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    int flag = 1;
    int n = s.size();
    if(n % 2 == 1)flag = 0;

    rep(i,n){
        if(i % 2 == 0){
            if(s[i] != 'h')flag = 0;
        }else{
            if(s[i] != 'i')flag = 0;
        }
    }
    
    if(flag)yn;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;
//バケツソート
int main(void)
{
	int N;
	long long int K;
	
	std::cin >> N >> K;
	
	std::vector<long long int> cnt(100001, 0);

	for(int i = 0; i < N; ++i)
	{
		int a, b;
		std::cin >> a >> b;
		cnt[a] += b;
	}
	
	for(int i = 1; i <= 100000; ++i)
	{
		if( cnt[i] >= K )
		{
			std::cout << i << std::endl;
			break;
		}
		
		K -= cnt[i];
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	vector<ll> ans(n);

	ll dx[4]={1,1,-1,-1};
	ll dy[4]={1,-1,1,-1};//最初の二匹がどちらの動物か(オオカミ-1　羊1)

	bool can=false;
	rep(i,4){//最初の二匹を事前に決めておくと、残りは、オオカミか羊かが勝手に決まっていく->最後に、0の動物と、n-1の動物の証言が正しいならok 正しくないなら矛盾あり
		ans[0]=dx[i];
		ans[1]=dy[i];

		for(ll j=1;j<n-1;j++){
			if(s[j]=='o' && ans[j]==1 || s[j]=='x' && ans[j]==-1){//羊がoといっている または　オオカミがxといっている　なら
				ans[j+1]=1*ans[j-1];//jに隣り合うのは同じ動物
			}else if(s[j]=='o' && ans[j]==-1 || s[j]=='x' && ans[j]==1){//オオカミがoといっている または　羊がxといっている　なら
				ans[j+1]=-1*ans[j-1];//jに隣り合うのは違う動物
			}
		}

		if(((s[0]=='o' && (ans[0]==1 && ans[1]==ans[n-1] || ans[0]==-1 && ans[1]!=ans[n-1]))//s[0]がoのとき
		||  (s[0]=='x' && (ans[0]==1 && ans[1]!=ans[n-1] || ans[0]==-1 && ans[1]==ans[n-1])))//s[0]が×のとき
		&& ((s[n-1]=='o' && (ans[n-1]==1 && ans[0]==ans[n-2] || ans[n-1]==-1 && ans[0]!=ans[n-2]))//s[n-1]がoのとき
		||  (s[n-1]=='x' && (ans[n-1]==1 && ans[0]!=ans[n-2] || ans[n-1]==-1 && ans[0]==ans[n-2])))//s[n-1]がxのとき
		){//0番とn-1番の証言が一致するか
			can=true;
			break;
		}
	}

	if(can){
		rep(i,n){
			if(ans[i]==1){
				cout<<'S';
			}else{
				cout<<'W';
			}
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}

	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (((a + b) >= c) ? ("Yes") : ("No")) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
int a[100005],dp[100003];
int n;
int mincost(int x)
{
	if(dp[x]!=-1)
		return dp[x];
	if(x==n)
	{
		dp[x]=0;
		return dp[x];
	}
	if(x==n-1)
	{
		if(dp[x]==-1)
		dp[x]= abs(a[n]-a[n-1]);
		return dp[x];
	}
	dp[x]=min(mincost(x+1)+abs(a[x+1]-a[x]),mincost(x+2)+abs(a[x+2]-a[x]));
	return dp[x];
}
int main()
{
	cin>>n;
	for (int i = 1; i <=n; ++i)
	cin>>a[i];
	for (int i = 0; i < 100002; ++i)
	dp[i]=-1;
	cout<<mincost(1)<<'\n';
 }

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ )
    for ( int j = N - 1; j >= i; j-- )
      if ( A[j].value < A[j - 1].value )
        swap(A[j], A[j - 1]);
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ )
      if ( A[j].value < A[minj].value ) minj = j;
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

// バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i  = 0; i < N; i++ )
    if ( C1[i].suit != C2[i].suit ) return false;
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ )
    cin >> C1[i].suit >> C1[i].value;

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) )
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, p;
  cin >> a >> p;
  cout << (a*3+p)/2 << newl;
  return 0;
}

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

const long long MOD = 1000000007;

vector<pair<ll, ll>> div_cnt(ll N)
{
    vector<pair<ll, ll>> prime;
    for (long long A = 2; A * A <= N; A++)
    {
        if (N % A != 0)
            continue;
        ll exp = 0;
        while (N % A == 0)
        {
            exp++;
            N = N / A;
        }
        prime.push_back({A, exp});
    }

    if (N != 1)
    {
        prime.push_back({N, 1});
    }

    return prime;
}

void solve(long long N)
{
    cout << fixed << setprecision(10);
    //素数の数識別
    map<int,ll> num;
    for(long long i=1; i<=N; i++)
    {
        for(auto u : div_cnt(i)) //{{a1,e1},{a2,e2},{a3,e3},{..}}
            num[u.first] += u.second; //u.first,整数
    }
    
    ll cnt=1;
    
    for(auto s : num)
    {
        cnt *= (s.second + 1);
        cnt %= MOD;
    }

    cout << cnt << endl;

    /*long long cnt = 1;
    for (long long  i = N; i > 0; i--)
    {
        const auto &prime = div_cnt(i);
        for (auto s : prime)
        {
            cnt = (cnt * (s.second + 1)%MOD) %MOD;
        }
    }

    cout << cnt << endl;
    //vector<pair<ll, ll>> prime = div_cnt(Factorial_N);
    */

    /*
    long long Factorial_N = 1;
    long long cnt = 1;
    for (long long  i = N; i > 0; i--)
    {
        Factorial_N *= i;
    }
    //vector<pair<ll, ll>> prime = div_cnt(Factorial_N);

    const auto &prime = div_cnt(Factorial_N);
    for (auto s : prime)
    {
        cnt *= (s.second + 1);
        cnt %= MOD;
        //    cnt++;
        //個数は(e1+1)(e2+1)…(eK+1)個
    }
    cout << cnt << endl;*/
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
d=dict(zip([chr(97+i) for i in range(26)],[1]*26))
mod=10**9+7
for i in s:
  d[i]+=1
ans=1
for i in d.values():
  ans*=i
  ans%=mod
print((ans-1)%mod)

Measured memory_bytes: 73064
N, Q = map(int, input().split())
tree = [[] for i in range(N)]
for i in range(N-1):
    ai, bi = map(int, input().split())
    ai -= 1
    bi -= 1
    tree[ai].append(bi)
point = [0] * N
for j in range(Q):
    pi, xi = map(int, input().split())
    pi -= 1
    point[pi] += xi

answer = [0] * N
queue = []
counter = 0
queue.append((0, 0))
while True:
    if counter == len(queue):
        break
    node, p = queue[counter]
    counter += 1


    answer[node] = p + point[node]
    for t in tree[node]:
        queue.append((t, answer[node]))

print(' '.join(map(str,answer)))

Measured memory_bytes: 79216
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll N;
    ll A[5];
    cin >> N;
    REP(i, 5) cin >> A[i];

    ll minA = min({A[0], A[1], A[2], A[3], A[4]});
    ll nGroups = (N + minA - 1) / minA;

    cout << (nGroups - 1) + 5 << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main{
    def main(args: Array[String]){
        var a = StdIn.readLine().split(" ").map(_.toInt)
        
        println(yukuriddo(a(0), a(1)))
    }
    
    def yukuriddo(a: Int, b: Int): Int = {
        
        if(b != 0){
            yukuriddo(b, a % b)
        }else{
        a
        }
        
        
    }
}


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

using std::vector;

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<int> c(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> c[i];
  }

  int score = 0;

  for (int i = 0; i < n; ++i) {
    score += b[a[i] - 1];
    if (i > 0 && a[i - 1] == a[i] - 1) {
      score += c[a[i - 1] - 1];
    }
  }

  cout << score;
  
  return 0;
}


Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,x]=i2()
y=i2()
y.append(x)
y.sort()
def gcd(a,b):
  while b:
    if a<b:
        c=b
        b=a
        a=c
    if b:a%=b
  return a
z=y[1]-y[0]
for i in range(1,n):
 z=gcd(y[i+1]-y[i],z)
print(z)

Measured memory_bytes: 62576
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    if(a>12){
        printf("%d\n", b);
    }else if(a>5){
        printf("%d\n", b/2);
    }else{
        printf("%d\n", 0);
    }
    return 0;
}

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

typedef long long ll;

int main(){
    ll N; cin >> N;
    vector<int> s;
    
    if(N==0) s.push_back(0);
    
    while(N!=0){
        //cout << N%(2) << endl;
        if((N%2)==-1){
            N--;
            s.push_back(1);
            //cout << 1 << endl;
        }
        else{
            s.push_back(N%2);
            //cout << N%2 << endl;
        }
        N /= (-2);
        //cout <<" "<< N << endl;
    }
    reverse(s.begin(),s.end());
    for(int i=0; i<s.size(); i++){
        cout << s[i];
    }
    cout << endl;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }
    string t1,t2;
    for(int i=0;i<n/2;i++){
        t1+=s.at(i);
    }
    for(int i=n/2;i<n;i++){
        t2+=s.at(i);
    }
    if(t1==t2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
int n;
  cin>>n;
  cout<<(n*800)-((n/15)*200)<<endl;

  return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define lf long float
#define pb push_back
 
using namespace std; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    set<ll> days; 
    map<ll,priority_queue<ll> > mm;
    priority_queue<ll> x;
    for(int i = 0 ; i < n ; i++)
    {
        ll t1,t2;
        cin>>t1>>t2;
        days.insert(t1);
        mm[t1].push(t2);
    }
    ll ans = 0;
    for(int i = m-1 ; i >= 0 ; i--)
    {
        if(days.find(m-i) != days.end())
        {
            while(mm[m-i].size())
            {
                ll temp = mm[m-i].top();
                mm[m-i].pop();
                x.push(temp);
            }
        }
        if(x.size())
        {   
            ll temp = x.top();
            x.pop();
            ans += temp;
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll r=sz(s)-1;
  ll l=0;
  ll ans=0;
  while(r>l){
    if(s[r]==s[l]){
      r--;
      l++;
    }
    else if(s[r]!='x'&&s[l]!='x'){
      COUT(-1);
      return 0;
    }
    else if(s[l]!='x'){
     r--;
     ans++;
   }
    else{
      ans++;
      l++;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[3005][3005];
signed main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 1; i <= N; i++) {
        for(int j = 0; i+j <= N; j++) {
            int k = i+j;
            if((N-i)%2 == 0) {
                dp[j][k] = max(dp[j+1][k]+a[j],dp[j][k-1]+a[k-1]);
            }
            else {
                dp[j][k] = min(dp[j+1][k]-a[j],dp[j][k-1]-a[k-1]);
            }
        }
    }
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 49808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();

        List<string> W = new List<string>(N);

        bool flag = true;

        string word = cin.next();

        for (int i = 1; i < N; ++i)
        {
            W.Add(word);

            string wordPrev = word;

            word = cin.next();

            if (W.Contains(word) ||
                wordPrev[wordPrev.Length - 1] != word[0])
            {
                flag = false;
                break;
            }
        }

        WriteLine(flag ? "Yes" : "No");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 != m2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
     int  n,i,j;
     double sum=0;
     char str[1000];
     double x[1000];  
      scanf("%d ",&n);
       
      
      for(i=0;i<n;i++){
          scanf("%lf ",&x[i]);
          scanf("%s ",&str[i]);
         }

       for(i=0;i<n;i++){
         if(str[i]=='B'){
          x[i]=x[i]*380000;
          }
           sum+=x[i];           
         }
 
    printf("%f",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
vector<int> d(10000);
int A[10000][10000];
int main() {
 int N, K;
 cin >> N >> K;
 
 for(int i = 0; i < K; i++) {
   cin >> d[i];
   for(int j = 0; j < d[i]; j++) {
     cin >> A[i][j];
   }
 }
  ll sum = 0;
  vector<int> b(N);
 for(int i = 0; i < K; i++) {
   
   for(int j = 0; j < d[i]; j++) {
     b[A[i][j] - 1] += 1;
   }
 }

 for(int i = 0; i < N; i++) {
   if(b[i] == 0) sum++; 
 }



 cout << sum;
 return 0;
}



Measured memory_bytes: 4076
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	sort(ALL(a));
	int max, min;
	ll sum = 0;
	min = a[0];
	max = a[n-1];
	REP(i, n) sum += a[i];
	cout<<min<<" "<<max<<" "<<sum<<endl;
}

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

const int MAXN = 1E5+2;
const int INF = 1E6+2;

int n, m;
string s;

int f[MAXN];
deque<int> Q;

void pushFront(int i){
	while(!Q.empty() && f[i] < f[Q.front()]){
		Q.pop_front();
	}
	Q.push_front(i);
}

void printAns(int i){
	if(i==n) return;
	for(int cur = 1; cur <= m; ++cur){
		if(f[i+cur] == f[i]-1){
			cout << cur << " ";
			printAns(i+cur);
			return;
		}
	}
}

signed main(){
	cin >> n >> m >> s;
	f[n] = 0;
	pushFront(n);
	for(int i= n-1; i>=0; --i){
		while(!Q.empty() && Q.back() > i+m) Q.pop_back();
		if(s[i] == '1') f[i] = INF;
		else f[i] = 1 + f[Q.back()];
		pushFront(i);
	}
	if(f[0] >= INF){
		cout << -1;
		return 0;
	}
	printAns(0);
}

Measured memory_bytes: 1024
require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# get adjuscent list
graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << b
  r_graph[b] << a
end

# build from_1 from_n
def reachable(s, g)
  q=[s]
  visited = Set.new(q)
  until q.empty?
    from = q.shift
    g[from].each do |to|
      next if visited.include?(to)
      visited.add(to)
      q.push(to)
    end
  end

  visited
end

from_1 = reachable(1, graph)
from_n = reachable(n, r_graph)
av = from_1 & from_n
edges=abc.select {|a, b, c| av.include?(a) && av.include?(b) }

#p av
#p edges

# b-f method
updated = false
INF= 10**12
dist = Array.new(n+1, INF)
dist[1]=0
n.times do
  updated = false
  edges.each do |a, b, c|
    next if dist[a]==INF || dist[b] <= dist[a] + c

    dist[b] = dist[a] + c
    updated = true
  end
  break unless updated
end

if updated
  p -1
  exit
end

# answer
p [0, -dist[n]].max




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

using namespace std;

int main() {
    int N;
    int W;
    cin >> N;
    cin >> W;
    long long int dp[N][W+1]={};
    
    int w;
    int v;
    cin >> w;
    cin >> dp[0][w];
    
    for(int i=0; i<N-1; i++){
        cin >> w;
        cin >> v;
        for(int j=0; j<W+1; j++){
            dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
            if(j+w<=W){
                dp[i+1][j+w]=max(dp[i+1][j+w], dp[i][j]+v);
            }
        }
        
    }
    
    for(int j=0; j<W; j++){
        dp[N-1][j+1]=max(dp[N-1][j+1], dp[N-1][j]);
    }
    
    cout << dp[N-1][W] << endl;

    return 0;
}

Measured memory_bytes: 78336
#!/usr/bin/env python
# coding: utf-8

# In[1]:


from math import gcd


# In[2]:


N = int(input())
A = list(map(int, input().split()))


# In[3]:


def gcd(a,b):
    if a>b:
        a,b = b,a
    while a > 0:
        a,b = b%a,a
    return b

def isPrime(x):
    for i in range(2, int(x**0.5)+1):
        if x%i == 0:
            return False
    return True

def div_primes(x):
    ret = {}
    for i in range(2, int(x**0.5)+1):
        tmp = 0
        while x%i == 0:
            tmp += 1
            x //= i
        if tmp > 0:
            ret[i] = tmp
    if x > 1:
        ret[x] = 1
    return ret


# In[9]:


g = A[0]
for i in range(1,N):
    g = gcd(g,A[i])
if g > 1:
    print("not coprime")
else:
    mylist = [True for _ in range(10**6+1)]
    mylist[0] = mylist[1] = False
    primes = {}
    for i in range(2, len(mylist)):
        if mylist[i]:
            primes[i] = 0
            for j in range(i*2, len(mylist), i):
                mylist[j] = False
    flag = True
    for a in A:
        if a in primes:
            if primes[a] == 0:
                primes[a] = 1
            else:
                flag = False
                break
        else:
            divs = div_primes(a)
            for k in divs.keys():
                if primes[k] == 0:
                    primes[k] = 1
                else:
                    flag = False
                    break
            else:
                continue
            break
    if flag:
        print("pairwise coprime")
    else:
        print("setwise coprime")


# In[ ]:






Measured memory_bytes: 132716
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define U (LL)0
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<pair<LL,LL>,LL> v;
map<pair<LL,LL>,pair<LL,LL> >x;
map<LL,LL>w;
V< pair<LL,LL> >u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>m>>n;
    for(i=0;i<n;i++)
    {
        cin>>m>>o;
        u.PSB({m,o});
        v[{o,m}]=1;
    }
    for(map<pair<LL,LL>,LL> :: iterator it=v.B; it!=v.E; it++)
    {
        p=it->FI.SE;
        q=it->FI.FI;
        k=w[p]+1;
        w[p]++;
        x[ {p,q}]= {p,k};
    }
    for(i=0;i<n;i++)
    {
        p=x[{u[i].FI,u[i].SE}].FI;
        q=x[{u[i].FI,u[i].SE}].SE;
        s=0;
        k=p;
        while(k)
        {
            s++;
            k/=10;
        }
        t=0;
        k=q;
        while(k)
        {
            t++;
            k/=10;
        }
        for(j=0;j<6-s;j++)
        {
            cout<<0;
        }
        cout<<p;
         for(j=0;j<6-t;j++)
        {
            cout<<0;
        }
        cout<<q<<endl;
    }

    return 0;

}


Measured memory_bytes: 23408
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2e5+5;

int main(){
	int N,Q;
	cin>>N>>Q;
	char s[MAX],t[MAX],d[MAX];
	s[0]='0',s[N+1]='0';
	rep1(i,N)cin>>s[i];
	rep1(i,Q)cin>>t[i]>>d[i];
	int x=0,y=N+1;
	for(int i=Q;i>=1;i--){
		if(s[x+1]==t[i]&&d[i]=='L')x++;
		if(s[x]==t[i]&&d[i]=='R')x--;
		if(s[y-1]==t[i]&&d[i]=='R')y--;
		if(s[y]==t[i]&&d[i]=='L')y++;
	}
	cout<<max(0, y-x-1)<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
long long N;
long long hoge[5];
cin>>N>>hoge[0]>>hoge[1]>>hoge[2]>>hoge[3]>>hoge[4];
long long m=1000000000000001;
for(int i=0;i<5;i++){
    if (hoge[i]<m) m=hoge[i];
}
long long a;
a=(N-1)/m;
cout<<5+a<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

void sort_dic(std::vector<std::string>& strings);
bool lt(std::string a, std::string b);
void swap(std::string& a, std::string& b);
int main()
{
    int N, L;
    std::vector<std::string> words;
    std::cin >> N >> L;
    words.resize(N);
    for(std::string& word : words){
        std::cin >> word;
    }
    sort_dic(words);
    std::string join = "";
    for(std::string s : words){
        join = join + s;
    }
    std::cout << join << '\n';
    return 0;
}
bool lt(std::string a, std::string b)
{
    int size = a.size();
    for(int i = 0; i < size; i++){
        if(a[i] < b[i]) return true;
        else if(b[i] < a[i]) return false;
    }
    return false;
}
void sort_dic(std::vector<std::string>& strings)
{
    int size = strings.size();
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(lt(strings[j], strings[i])) swap(strings[i], strings[j]);
        }
    }
}

void swap(std::string& a, std::string& b)
{
    std::string tmp = a;
    a = b;
    b = tmp;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int A,B,K;
  cin>>A>>B>>K;
  vector<int>vec;
 
  //compute
  for(int i=min(A,B);0<i;i--){
    if(A%i==0 && B%i==0){
    vec.push_back(i);
    }
    else{
      continue;
    }    
  }

  //output
  cout<<vec[K-1]<<endl;  
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

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

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  int main(){
      lint N,K,S;
      cin>>N>>K>>S;
      lint v=1;
      lint c=S-1;
      if(N==K){
      rep(i,N){
          cout<<S<<" ";
      }
    return 0;
      }
      if(S==1){
          rep(i,K){
              cout<<S<<" ";
          }
          rep(j,N-K){
              cout<<1000000<<" ";
          }
          return 0;
      }
      rep(i,K+1){
          if((i+1)%2==1)cout<<v<<" ";
          else cout<<c<<" ";
      }
        lint x=N-K-1;
        lint y=1e8-2;
        rep(i,x){
            cout<<y<<" ";
        }

  }
  

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

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

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename ARR, typename U> void fill_all(ARR& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T>auto&operator<<(ostream&s,const unordered_set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const unordered_map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

signed main()
{
   int x, y; cin >> x >> y;

   if (x % y == 0) {
      cout << -1 << endl;
   } else {
      cout << x << endl;
   }

   return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    a.sort()
    
    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()

    print(cur)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88820
#include<bits/stdc++.h>
using namespace std;
int book[12];
bool judje(int x)
{
    while(x)
    {
        if(book[x%10]) return false;
        x/=10;
    }
    return true;
}
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    int n,k,t;cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        cin>>t;
        book[t]++;
    }
    for(int i=n;i<100000;i++)
    {
        if(judje(i))
        {
            cout<<i<<endl;
            return 0;
        }

    }

}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a ==b&&b == c)
	{
		cout << "No" << endl;
	}
	else if (a == b)
	{
		cout << "Yes" << endl;
	}
	else if (a == c)
	{
		cout << "Yes" << endl;
	}
	else if (b == c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
N,L = map(int, input().split())

apple_1 = L
apple_2 = L+N-1

if apple_1*apple_2<=0:
    apple_min=0
elif apple_1<=0 and apple_2<=0:
    apple_min=apple_2
else:
    apple_min=apple_1

sum=0
for i in range(N):
    sum+=L+i
sum-=apple_min
print(sum)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int alice, bob;
    cin >> alice >> bob;
    if (alice == bob){
        cout << "Draw";
    }
    else if (alice == 1 and bob != 1){
        cout << "Alice";
    }
    else if(alice != 1 and bob == 1){
        cout << "Bob";
    }
    else if (alice > bob){
        cout << "Alice";
    }
    else{
        cout << "Bob";
    }
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main() {
  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a*n,b);
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n + 1);
	rep1(i, sqrt(1e4)) {
		rep1(j, sqrt(1e4)) {
			rep1(k, sqrt(1e4)) {
				if (i * i + j * j + k * k + i * j + j * k + k * i <= n)++a[i * i + j * j + k * k + i * j + j * k + k * i];
			}
		}
	}

	rep(i, n)printf("%d\n", a[i + 1]);

	Please AC;
}

Measured memory_bytes: 3784
def solve():
    A = list(map(int,input().split()))
    for i in range(3):
        if sum(x==A[i] for x in A) == 1 or sum(x==A[i] for x in A) == 3:
            continue
        elif sum(x==A[i] for x in A) ==2:
            print("Yes")
            return
    print("No")

solve()

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

int main(){
	string s, t;
	cin >> s;
	cin >> t;
	int N = s.size(), M = t.size(), i;
	vector<char> S(N), T(M);
	for(i = 0; i < N; i++){
		S[i] = s[i];
	}
	for(i = 0; i < M; i++){
		T[i] = t[i];
	}
	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	for(i = 0; i < M; i++){
		if(i < M - i - 1){
			swap(T[i], T[M - i - 1]);
		}
	}
	for(i = 0; i < M; i++){
		if(i == N){
			printf("Yes\n");
			return 0;
		}
		if(S[i] < T[i]){
			printf("Yes\n");
			return 0;
		}
		if(S[i] > T[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N,C,K=map(int,input().split(' '))
T=sorted([int(input()) for i in range(N)])
pas = 1
last_bus=T[0]+K
ans = 1
for i in T[1:]:
    if i <= last_bus and pas < C:
        pas += 1
    else:
        ans += 1
        pas = 1
        last_bus = i+K
print(ans)

Measured memory_bytes: 8252
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s == "ABC"){
		cout<<"ARC";
	}	
	else{
		cout<<"ABC";
	}
	return 0;
}

Measured memory_bytes: 3656
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 200005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;




    int main() {
        fast();
        int n;
        cin>>n;
        ll sum=0;
        frr(n)
        {
            if((i%3)!=0 && (i%5)!=0)sum+=i;
        }
        cout<<sum<<endl;

    }


Measured memory_bytes: 3636
import sys
import math

ct= 0
def insertion_sort(a, n, g):
    global ct
    for j in range(0,n-g):
        v = a[j+g]
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v

n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 701
g = [x for x in [1,4,10,23,57,132,301,701] if x <= n]
while True:
    b = math.floor(2.25*b)
    if b > n:
        break
    g.append(b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")

Measured memory_bytes: 118520
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 2005
using namespace std;
const int mod = 1e9+7;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n;
int f[N<<1][N<<1];
int a[N<<1][N<<1];
int fac[N<<2], inv[N<<2];

void upd(int &x, int y){ x += y; if(x >= mod) x -= mod; }

int quick_mod(int x, int y){
	int res = 1; x %= mod;
	for(; y ; y >>= 1, x = 1LL * x * x % mod)
		if(y & 1) res = 1LL * res * x % mod;
	return res;
}

int C(int x, int y){ return x < y ? 0 : 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod; }

int main(){
	int ans = 0;
	fac[0] = 1;
	for(int i = 1; i < (N << 2); i++) fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[(N << 2) - 1] = quick_mod(fac[(N << 2) - 1], mod - 2);
	for(int i = (N << 2) - 1; i ; i--) inv[i - 1] = 1LL * inv[i] * i % mod;
	n = read();
	for(int i = 1; i <= n; i++){
		int A = read(), B = read();
		upd(a[A + N][B + N], 1);
		upd(f[N - A][N - B], 1);
		upd(ans, mod - C(A + A + B + B, A + A));
	}
	for(int i = 0; i < (N << 1); i++)
		for(int j = 0; j < (N << 1); j++){
			upd(ans, 1LL * a[i][j] * f[i][j] % mod);
			if(i + 1 < (N << 1)) upd(f[i + 1][j], f[i][j]);
			if(j + 1 < (N << 1)) upd(f[i][j + 1], f[i][j]);
		}
	ans = 1LL * ans * 500000004 % mod;
	printf("%d\n", ans);
}


Measured memory_bytes: 95232
#include<iostream>
#include<algorithm>
using namespace std;
int n, k, i, ii, jj, sum, sol, nr;
int v[55], w[55];
int main(){
    cin>> n >> k;
    for(i = 1; i <= n; i++){
        cin>> v[i];
    }
    for(ii = 0; ii <= n; ii++){
        for(jj = n + 1; jj > ii; jj--){
            if(ii + n - jj + 1 > k){
                continue;
            }
            nr = sum = 0;
            for(i = 1; i <= ii; i++){
                w[++nr] = v[i];
                sum += v[i];
            }
            for(i = jj; i <= n; i++){
                w[++nr] = v[i];
                sum += v[i];
            }
            sort(w + 1, w + nr + 1);
            for(i = 1; i <= nr && i <= k - ii - n + jj - 1; i++){
                if(w[i] > 0){
                    break;
                }
                sum -= w[i];
            }
            sol = max(sol, sum);
        }
    }
    cout<< sol;
}


Measured memory_bytes: 256