akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	string s;
	int k;
	cin >> s >> k;
	int cnt=0;
	rep(i,s.size()-1){
		if(s[i]==s[i+1])
			cnt++;
	}
	//全ての文字が同じの時だけ例外
	if(cnt==s.size()-1){
		cout << s.size()*k/2 <<endl;
		return 0;
	}
	string three = s+s+s;
	string two = s+s;
	ll n1 = 0;
	rep(i,three.size()-1){
		if(three[i]==three[i+1]) {
			n1++;
			i++;
		}
	}
	ll n2 = 0;
	rep(i,two.size()-1){
		if(two[i]==two[i+1]) {
			n2++;
			i++;
		}
	}
	ll ans = n2+(k-2)*(n1-n2);
	cout << ans << endl;
		return 0;
}


Measured memory_bytes: 256
from numba import jit


@jit
def solve(X, Y, Z):
    while X >= 0:
        if 2 * X + 4 * Z == Y:
            return True
        elif 2 * X + 4 * Z < Y:
            X -= 1
            Z += 1
        else:
            return False
    return False


def main():
    X, Y = map(int, input().split())
    Z = 0

    if solve(X, Y, Z):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 108480
#include <stdio.h>

#define abs(a)	(a >= 0 ? a : -a)
int main() {
	long long a, b, c, x;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &x);
	if (x & 0x01) {			//奇数回
		long long aa, bb, cc;
		aa = a;
		bb = b;
		cc = c;
		a = bb + cc;
		b = aa + cc;
		c = aa + bb;
	}
	if (abs(a - b) > 1000000000000000000) {
		printf("Unfair");
	}
	else {
		printf("%lld", a - b);
	}
	return 0;
}

Measured memory_bytes: 128
r, c = map(int, input().strip().split())
l = [[0 for j in range(c+1)] for i in range(r+1)]
for i in range(r):
    l[i] = list(map(int, input().strip().split()))
    l[i].append(sum(l[i][0:c]))
    l[r] = [l[r][j] + l[i][j] for j in range(c+1)]
    print(' '.join(map(str,l[i])))
print(' '.join(map(str,l[r])))

Measured memory_bytes: 7756
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, n, count_r, count_b;
	char *s;

	scanf("%d", &n);

	if ((s = (char *)malloc(sizeof(char) * (n + 1))) == NULL)
		return 1;

	scanf("%s", s);

	for (i = 0, count_r = 0, count_b = 0; i < n; i++) {
		if (s[i] == 'R')
			count_r++;
		else
			count_b++;
	}

	if (count_r > count_b)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
using namespace std;

class Stack {
private:
  int top_;
  int* arr_;

public:
  Stack(const int& size) : top_(0) {
    arr_ = new int[size];
  };

  ~Stack() {
    delete[] arr_;
  }

  void push(int s) {
    if (is_full()) {
      assert("Stack is full.");
    }
    top_++;
    arr_[top_] = s;
  }

  int pop() {
    if (is_empty()) {
      assert("Stack is empty.");
    }
    int s = arr_[top_];
    top_--;
    return s;
  }

  bool is_empty() {
    return top_ == 0 ? true : false;
  }

  bool is_full() {
    return top_ == sizeof(arr_) * sizeof(int) ? true : false;
  }
};

int main() {
  const int BUF_SIZE = 256;
  string buf[BUF_SIZE];
  for(int i = 0; i < BUF_SIZE; i++) {
    buf[i] = "null";
  }
  for(int i = 0; i < BUF_SIZE; i++) {
    cin >> buf[i];
  }

  Stack stk(BUF_SIZE);
  for(int i = 0; buf[i] != "null"; i++) {
    string str = buf[i];
    try {
      int n = stoi(str);
      stk.push(n);
    } catch (std::invalid_argument &e) {
      int x = stk.pop();
      int y = stk.pop();
      if (str == "+") {
        stk.push(x + y);
      } else if (str == "-") {
        stk.push(y - x);
      } else if (str == "*") {
        stk.push(x * y);
      }
    }
  }

  cout << stk.pop() << endl;
}



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

int main(void) {
	int N; cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}

	sort(s.begin(), s.end());

	int res = 1;
	for (int i = 0; i < N - 1; i++) {
		if (s[i] != s[i + 1]) res++;
	}
	cout << res << endl;

	return 0;
}


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

int main(){
    int k;
    while(cin >> k, k != 0){
        int sum = 0;
        for(int i=0; i<(k*(k-1)/2); ++i){
            int tmp;
            cin >> tmp;
            sum += tmp;
        }
        cout << sum / (k-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(pow(10, 6))

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

def main():
  a, b, c, d = map(int, input().split())
  divc = b//c - (a-1)//c
  divd = b//d - (a-1)//d
  abgcd = gcd(c, d)
  maxcd = (max(c, d) // abgcd) * min(c, d)
  print(b-a+1-divc-divd+(b//maxcd - (a-1)//maxcd))


if __name__ == '__main__':
  main()


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

using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
int a[100005],o[100005],p[100005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		o[i]=__gcd(o[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		p[i]=__gcd(p[i+1],a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,gcd(o[i-1],p[i+1]));
	}
	cout<<ans;
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w, n;
  cin >> h >> w >> n;

  ll m = max(h,w);
  ll ans;
  if(n%m==0) ans = n/m;
  else ans = n/m + 1;
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

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

    vector<int> coins = {25, 10, 5, 1};

    int ans = 0;
    for (int i = 0; i < coins.size() && n ; i++) {
        ans += n / coins[i];
        n %= coins[i];
    }

    cout << ans << '\n';

}



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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

int check(string s){

  int n=s.size();

  for(int i=0;i<n;i++){
    for(int j=i+2;j<n;j++){
      if(s[i]!='B') continue;
      if(s[j]!='B') continue;
      int lose=1;
      for(int k=i+1;k<j;k++)
        if(s[k]!='W') lose=0;
      if(lose) return -1;
    }
  }

  int res=0;
  for(int i=0;i<n;i++){
    for(int j=i+2;j<n;j++){
      if(s[i]!='W') continue;
      if(s[j]!='W') continue;
      int win=1;
      for(int k=i+1;k<j;k++)
        if(s[k]!='B') win=0;
      if(win) chmax(res,j-i-1);
    }
  }
  //cout<<s<<":"<<res<<endl;
  return res;
}

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

  int n;
  string s;
  cin>>n>>s;

  int ans=0;

  for(int i=0;i<n;i++){
    if(s[i]!='.') continue;
    string t=s;
    t[i]='W';
    chmax(ans,check(t));
  }

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



Measured memory_bytes: 3216
a=2,3,5
def f(n):
 if(m:=s.get(n))is None:s[n]=(m:=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip(a,b)for k in(n//p,0--n//p)]))
 return m
for _ in[0]*int(input()):n,*b,d=map(int,input().split());s={0:0,1:d};print(f(n))

Measured memory_bytes: 11036
#include <iostream>
#include <algorithm>
#include <vector>

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

    while(true){
        int h, w;
        std::cin >> h >> w;
        if(h==0 && w==0) break;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                std::cout << (((i+j)%2==0)?"#":".");
            }
            std::cout << "\n";
        }
        std::cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3136
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n,k = invr()
    a = inlt()
    for i in range(len(a)):
        if i >= k:
            if a[i] > a[i - k]:
                qw = "Yes"
            else:
                qw = "No"
            print(qw)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 91384
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    ans = 3 ** N
    o = 1
    for a in A_list:
        if a % 2 == 0:
            o *= 2
        else:
            o *= 1
    print(ans - o)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
ll n,k;
ll a[N];
bool chk(ll x){
    ll cuts=0;
    for(ll i=0;i<n;i++){
        ll y = a[i];
        if(a[i]!=x)
            cuts+=(a[i]/(x));
    }
    if(cuts<=k)
        return true;
    else return false;
}
void solve()
{
    cin>>n>>k;
    ll mx=-1;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    ll lo=1,hi= mx;
    ll ans =mx;
    while(lo<=hi){
        ll mid = (lo+hi)/2;
        if(chk(mid)){
            ans=min(ans,mid);
            hi=mid-1;
        }
        else lo=mid+1;
    }
    cout<<ans <<"\n";
}
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ll Solve(const vector<ll>& A, bool fromFront)
{
    const int N = A.size();
    vector<ll> B(N * 2, -1);
    int aFront, aBack;
    if (fromFront)
    {
        B[N] = A[0];
        aFront = 1;
        aBack = N - 1;
    }
    else
    {
        B[N] = A[N - 1];
        aFront = 0;
        aBack = N - 2;
    }

    int bLeft = N;
    int bRight = N;

    rep(i, 0, N - 1)
    {
        const bool isBack = (i / 2) % 2 == (fromFront ? 0 : 1);

        // Left
        if (i % 2 == 0)
        {
            --bLeft;
            if (isBack) B[bLeft] = A[aBack--];
            else B[bLeft] = A[aFront++];
        }
        // Right
        else
        {
            ++bRight;
            if (isBack) B[bRight] = A[aBack--];
            else B[bRight] = A[aFront++];
        }
    }

    ll sum = 0;
    rep(i, bLeft, bRight)
    {
        sum += abs(B[i + 1] - B[i]);
    }

    return sum;
}

void _main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(A.begin(), A.end());

    const ll a = Solve(A, true);
    const ll b = Solve(A, false);
    cout << max(a, b) << endl;
}


Measured memory_bytes: 2660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,m; cin>>n>>m;
    long long x[m]; rep(i,m) cin>>x[i];
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    sort(x,x+m);
    vector<long long> diff;
    long long ans=0;
    for(int i=1;i<m;i++){
        diff.push_back(x[i]-x[i-1]);
        ans+=x[i]-x[i-1];
    }
    sort(all(diff)); reverse(all(diff));
    for(int i=0;i<n-1;i++){
        ans-=diff[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
# ABC097B - Exponential
x = int(input())
lst = []

for i in range(1, 32):
    for j in range(2, 10):
        if i ** j == x:
            print(x)
            exit()
        elif i ** j < x and i ** j not in lst:
            lst.append(i ** j)
        elif i ** j > x:
            break
            
lst.append(x)
lst = sorted(lst)

print(lst[lst.index(x) - 1])

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  map<char, ll> amap;
  vector<char> arr;
  for(int i=0;i<S.size();++i) {
    if(amap[S[i]]==0) arr.push_back(S[i]);
    amap[S[i]]++;
  }
  ll ans = 1;
  for(int i=0;i<arr.size();++i) {
    ans *= amap[arr[i]]+1;
    ans %= mod;
  }
  cout<<(ans-1+mod)%mod<<endl;
}



Measured memory_bytes: 3744
from math import ceil
A,B,C,D,E,F = map(int,input().split())
W,S = [],[0]
for i in range(ceil(F/A)):
    for j in range(ceil(F/B)):
        w = 100*A*i+100*B*j
        if w <= F and 0 < w and w not in W:
            W.append(w)
for i in range(ceil(F/C)):
    for j in range(ceil(F/D)):
        s = C*i+D*j
        if s <= F and 0 < s and s not in S:
            S.append(s)
Ans1,Ans2,r = 0,0,-1
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            Ans1,Ans2,r = wi+si,si,si/wi
print(Ans1,Ans2)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int min_o(int h[],int n){
    int a=0,b=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        if(i%2==0){
            a=min(a+abs(h[i]-h[i-2]),b+abs(h[i-1]-h[i]));
            // cout<<a<<" "<<i<<endl;
        } 
        else{
            b=min(b+abs(h[i]-h[i-2]),a+abs(h[i-1]-h[i]));
            // cout<<b<<" "<<i<<endl;
        } 
    }
    if(n%2==0) return b;
    else return a;
    // if(n==1) return abs(h[n]-h[n-1]);
    // else if(n==0) return 0;
    // else return min(abs(h[n-2]-h[n])+min_o(h,n-2),abs(h[n-1]-h[n])+min_o(h,n-1));
}
int main() {
    int n;cin>>n;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    cout<<min_o(h,n);
	return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=100005;

int main()
{
    IO;
    int a,b;
    cin >> a >> b;
    cout<<a-1+(b>=a)<<endl;
    re 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n, x; cin >> n >> x;
    vector<int> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis));
    int ans = 0;
    REP(i, 0, n){
        x -= lis[i];
        ans++;
        if(x < 0){
            ans--;
            x = 0;
            break;
        }
    }
    if(x == 0)
        cout << ans << endl;
    else
        cout << ans-1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
 
#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
 
using namespace std;
 
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;
 
const ll mod =  998244353;

/* 
ll nop = 100;
vi primes(nop,1);
 
void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/
 
ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}
 
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}
 
ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}
 
ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    vi a(n);
    inp_arr(a,n);
    int ans = 0;
    for0(i,n) ans ^= a[i];
    for0(i,n) {
        cout<<(ans^a[i])<<" ";
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3984
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
const int mod = 1000000007;

int gcd(int a, int b){
    if(a < b) swap(a, b);
    int r = a%b;
    while(r != 0){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}
int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}

int main(){
    int n; cin >> n;
    int ans; cin >> ans;;
    for (int i = 0; i < n -1 ; i++) {
        int k; cin >> k;
        ans = lcm(ans, k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3088
from collections import Counter
# Counterについては↓
# https://qiita.com/JunJun0706/items/9d1befb90a823c466c32#%E6%9C%80%E9%A0%BB%E5%80%A4
n = int(input())
v = list(map(int, input().split()))

o = []
e = []

for i in range(n):
    # 奇遇が逆なの注意
    if i%2 == 1:
        e.append(v[i])
    else:
        o.append(v[i])

o = Counter(o)
e = Counter(e)
#  print(o)
#  print(e)
#  print(len(e))
#  print(o.most_common(1))
#  print(o.most_common(2))
#  print(e.most_common(1))
#  print(e.most_common(2))

if o.most_common(1)[0][0] != e.most_common(1)[0][0]:
    #  ans += (n/2 - o.most_common(1)[0][1]) + (n/2 - e.most_common(1)[0][1])
    ans = n - o.most_common(1)[0][1] - e.most_common(1)[0][1]
elif len(o) == 1 and len(e) == 1:
    # 例3のパターン
    ans = n/2
else:
    # 1 1 1 2 パターン
    # 1 1 2 1 パターン
    #  temp1 = (n/2 - o.most_common(2)[0][1]) + (n/2 - e.most_common(1)[0][1])
    try:
        temp1 = n - o.most_common(2)[1][1] - e.most_common(1)[0][1]
    except:
        temp1 = 10**6
    try:
        temp2 = n - o.most_common(1)[0][1] - e.most_common(2)[1][1]
    except:
        temp2 = 10**6
    ans = min(temp1, temp2)

print(int(ans))


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

using namespace std;



void solver() {
    string s; 
    cin >> s;
    
    int n = s.size();
    int ans = 0;

    for(int i = 0; i < n; ++i) {
        if (s[i] == 'S') continue;
        int j = i;
        int cnt = 0;
        while(j < n && s[j] == 'R') {
            ++j;
            ++cnt;
        }

        i = j - 1;
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

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


int main() {
  	int N,M;
  	cin>>N>>M;
  	vector<pair<int,bool>> ball(N);
  	rep(i,N) {
      	ball.at(i).first=1;
      	ball.at(i).second=false;
    }
 	ball.at(0)={1,true};
  	
  	rep(i,M){
     	int x,y;
      	cin>>x>>y;
      	x--;y--;
      	if(ball.at(x).second) ball.at(y).second=true;
      	if(ball.at(x).first==1 && ball.at(x).second) ball.at(x).second=false;
      	ball.at(x).first--;
      	ball.at(y).first++;
      	
    }
  	int count=0;
  	rep(i,N) count+=ball.at(i).second;
  	
  	cout<<count<<endl;
}

Measured memory_bytes: 3972
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
//dp[i]:前i个位置染完的最小花费
//dp[0] = 0, dp[others] = INF
//if(a[i] == b[i]) dp[i] = dp[i-1]
//else dp[i] = min{dp[j] + cost(j+1, i)|max(0, i-k) <= j < i}
//cost(x, y):ceil((sum[i]-sum[j+1])/2)+1=(sum[i]-sum[j+1]+1)/2+1
//dp[i]=min{(2*dp[j]-sum[j+1]+sum[i]+3)/2|max(0, i-k) <= j < i}
//f[j] = 2*dp[j] - sum[j+1]//用长度为k的单调队列维护
//dp[i]=min{(f[j]+sum[i]+3)/2}
//f[i] = 2*dp[i]-sum[i+1]入队
const int maxn =  5e5 + 10;
const int INF = 0x3f3f3f3f;
int n, k;
char s[maxn], t[maxn];
int sum[maxn];
int dp[maxn];
struct Queue {
    struct Node {
        int pos, val;
    }node[maxn];
    int l, r;
    void init() { l = 1, r = 0; }
    void update(int pos, int val) {
        while (l <= r && val < node[r].val) r--;
        node[++r] = Node{pos, val};
        while (l <= r && node[r].pos - node[l].pos >= k) l++;
    }
    int query() {
        if (l > r) return INF;
        return node[l].val;
    }
}que;
int main() {
    scanf("%d%d", &n, &k);
    scanf("%s%s", s+1, t+1);
    sum[0] = 0, t[0] = '#';
    for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + (t[i] != t[i-1]);
    dp[0] = 0;
    que.init();
    que.update(0, 2*dp[0]-sum[1]);
    for (int i = 1; i <= n; i++) {
        dp[i] = INF;
        if (s[i] == t[i]) dp[i] = dp[i-1];
        else {
            //cout << i << ":" << que.query() << endl;
            dp[i] = min(dp[i], (que.query()+sum[i]+3)/2);
        }
        que.update(i, 2*dp[i]-sum[i+1]);
        //cout << dp[i] << "test" << endl;
    }
    printf("%d\n", dp[n]);
    return 0;
}



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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}

	ll ans = 0;
	rep(i, n)
	{
		if (a[a[i]-1] == i + 1 && i + 1 < a[i])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int A[N];
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }    
    int cnt = 0;
    for(int i=0; i<N; i++){
        if (4 * M * A[i] >= sum) cnt ++;
    }
    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m;
ll s, c[55], d[55], dis[55][2600];
struct node{
    int to, next;
    ll w, cost;
}e[5555];
int tot = 0, head[55];

void add(int u, int v, ll w, ll c){
    e[tot].to = v;
    e[tot].w = w;
    e[tot].cost = c;
    e[tot].next = head[u];
    head[u] = tot++;
}

void dij(ll s){
    queue<pair<int, ll> > q;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 2500; j++) dis[i][j] = inf;
    }
    dis[1][s] = 0;
    q.push({1, s});
    while (q.size()){
        int cur = q.front().first;
        ll w = q.front().second;
        q.pop();
        for (int i = head[cur]; ~i; i = e[i].next){
            int v = e[i].to;
            ll a = e[i].w, b = e[i].cost;
            if (w >= b && dis[v][w-b]>dis[cur][w]+a){
                dis[v][w-b]=dis[cur][w]+a;
                q.push({v,w-b});
            }
        }
        if (dis[cur][min(w+c[cur], (ll)2500)] > dis[cur][w]+d[cur]){
            dis[cur][min(w+c[cur], (ll)2500)]=dis[cur][w]+d[cur];
            q.push({cur, min(w+c[cur], (ll)2500)});
        }
    }
}

int main(){
    scanf("%d %d %lld", &n, &m, &s);
    s = min(s, (ll)2500);
    for (int i = 0; i <= n; i++) head[i] = -1;
    for (int i = 0; i < m; i++){
        int u,v;
        ll a, b;
        scanf("%d%d%lld%lld", &u, &v, &a, &b);
        add(u, v, b, a);
        add(v, u, b, a);
    }
    for (int i = 1; i <= n; i++){
        scanf("%lld%lld", &c[i], &d[i]);
    }
    dij(s);
    for (int i =2; i <= n; i++){
        ll ans = inf;
        for (int j = 0; j <=2500; j++) ans = min(ans, dis[i][j]);
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 5352
Sa = list(input())
Sb = list(input())
Sc = list(input())
d = Sa[0]
for i in range(300):
  if d == "a":
    d = Sa.pop(0)
  elif d == "b":
    d = Sb.pop(0)
  else:
    d = Sc.pop(0)
  if Sa == [] and d == "a":
    print("A")
    break
  elif Sb == [] and d == "b":
    print("B")
    break
  elif Sc == [] and d == "c":
    print("C")
    break

Measured memory_bytes: 3064
def resolve():
    li = list(map(int,input().split()))
    N = int(li[0])
    A = int(li[1])
    anum = 0
    B = int(li[2])
    bnum = 0
    string = list(input())

    for i in range(N):
        if anum + bnum < A+B :
            if string[i] == "a":
                anum = anum + 1
                print("Yes")
            elif string[i] == "b" and bnum < B  :
                bnum = bnum + 1
                print("Yes")
            else:
                print("No")
        else:
            print("No") 
resolve()

Measured memory_bytes: 4712
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        int sz = 0;
        int y = b;
        while(y > 0 ){
            y /= 10;
            sz ++;
        }
        a = b + a *(int)Math.pow(10,sz);
        if((int)Math.sqrt(a) * (int)Math.sqrt(a) == a) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22992
N, Y = gets.split.map(&:to_i)

def errputs
  puts "-1 -1 -1"
end

if N*10000 < Y or N*1000 > Y
  errputs
  exit
else
  0.upto(Y/10000) do |n10k|
    y1 = Y - 10000*n10k
    0.upto(y1/5000) do |n5k|
      y2 = y1 - 5000*n5k
      n1k = y2/1000
      if n10k + n5k + n1k == N
        puts "#{n10k} #{n5k} #{n1k}"
        exit
      end
      break if n10k + n5k > N
    end
  end
end
errputs

Measured memory_bytes: 1788
def is_month(number):
    if 0 < number < 13:
        return True
    return False


s = input()
if len(s) != 4:
    print("NA")
elif not s.isdecimal():
    print("NA")
else:
    before = int(s[0:2])
    after = int(s[2:])
    is_before_month = 0  # 0:月出ない, 1:月，2:月出ない
    is_after_month = 0
    if is_month(before):
        is_before_month = 1
    if is_month(after):
        is_after_month = 1
    # 月でないときは西暦．
    if is_before_month == 0:
        if is_after_month == 0:
            # 両方月出ない
            print("NA")
        else:
            print("YYMM")
    else:
        if is_after_month == 1:
            # 両方月の可能性がある
            print("AMBIGUOUS")
        else:
            print("MMYY")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace Robots_Arms
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<Job> jobs = new List<Job>();
            String input;
            String[] splitted;
            int X, L;
            for(int i = 0; i < N; i++)
            {
                input = Console.ReadLine();
                splitted = input.Split(' ');
                X = int.Parse(splitted[0]);
                L = int.Parse(splitted[1]);
                jobs.Add(new Job(Math.Max(0, X - L), X + L));
            }
            jobs.Sort((a, b) => a.t - b.t);
            int endTime = 0;
            int count=0;
            for(int i = 0; i < N; i++)
            {
                if (jobs[i].s >= endTime)
                {
                    count++;
                    endTime = jobs[i].t;
                }
            }
            Console.WriteLine(count);
        }
    }
    class Job
    {
        public int s;
        public int t;
        public Job(int S,int T)
        {
            s = S;
            t = T;
        }
    }
}


Measured memory_bytes: 19136
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int ab, bc, ca;
   cin >> ab >> bc >> ca;
   cout << ab* bc * 0.5 << endl;

   return 0;
}

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

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;

int main()
{
	lld n;
	lld a[MAXN] = {0};

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

	lld updown = 0;  //1->増加 2 ->減少
	lld sol = 1;

	int i = 0;

	while(i != n-1)
	{
		if (a[i] == a[i+1])
		{
			i++;
			continue;
		}

		if (a[i+1] > a[i])
		{
			if (updown == 2)
			{
				i++;
				sol++;
				//cout << " num = " << a[i] << endl;
				updown = 0;
			}else
			{
				i++;
				updown = 1;
			}
		}else
		{
			if (updown == 1)
			{
				i++;
				sol++;
				//cout << " num = " << a[i] << endl;
				updown = 0;
			}else
			{
				i++;
				updown = 2;
			}
		}
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>a>>b>>k;
    	string s[a];
    	for(int i=0;i<a;i++)
    		cin>>s[i];
    	ll ans = 0;
    	for(int i=0;i<=(1<<a)-1;i++)
    	{
    		for(int j=0;j<=(1<<b)-1;j++)
    		{
    			ll sum = 0;
    			for(int i1=0;i1<a;i1++)
    			{
    				for(int j1=0;j1<b;j1++)
    				{
    					if(((i>>i1)&1)==0&&((j>>j1)&1)==0&&s[i1][j1]=='#')
    						sum++;
    				}
    			}
    			if(sum==k)
    				ans++;
    		}
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
ans = 0

for i1 in range(1, m+1):
    for i2 in range(i1, m+1):
        for i3 in range(i2, m+1):
            for i4 in range(i3, m+1):
                for i5 in range(i4, m+1):
                    for i6 in range(i5, m+1):
                        for i7 in range(i6, m+1):
                            for i8 in range(i7, m+1):
                                for i9 in range(i8, m+1):
                                    for i10 in range(i9, m+1):
                                        arr = [i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        tmp = 0
                                        for a, b, c, d in abcd:
                                            if arr[b - 1] - arr[a - 1] == c:
                                                tmp+=d
                                        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<string> a(n);
    vi b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
    }
    vi f(n);
    REP(i,n){
        int k=-1;
        REP(j,n){
            if(f[j]){
                continue;
            }
            if(k==-1){
                k=j;
            }else{
                if(a[j]<a[k]||(a[j]==a[k]&&b[j]>b[k])){
                    k=j;
                }
            }
        }
        cout<<k+1<<endl;
        f[k]=true;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  int64_t a=0;
  int b=0;
  for(int i=0;i<n;i++){
     b++;
    if(b%3!=0&&b%5!=0){
      a+=b;
    }
  }
  cout<<a;
}


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

int main()
{
	int n, r, card[51], temp[51];
	while (cin >> n >> r, n || r){

		//初期化
		for (int i = 0; i < n; i++){
			card[i] = n - i;
		}

		//入力と操作
		for (int i = 0; i < r; i++){
			int p, c;
			cin >> p >> c;

			//tempにコピー
			for (int i = 0; i < p - 1 + c; i++)
				temp[i] = card[i];

			//上からc個
			for (int i = 0; i < c; i++){
				card[i] = temp[p - 1 + i];
			}

			//上からp個
			for (int i = 0; i < p - 1; i++){
				card[c + i] = temp[i];
			}
		}

		//出力
		cout << card[0]<<endl;
	}
	return 0;
}

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



int find(vector<vector<int>>& nodes, vector<int> footprint, int here, int n) {
	for (int i = 0; i < footprint.size(); i++) {
		if (here == footprint.at(i)) { return 0; }
	}
	footprint.push_back(here);
	if (footprint.size() == n) { return 1; }
	int ret = 0;
	for (int i = 0; i < nodes.at(here).size(); i++) {
		ret += find(nodes, footprint, nodes.at(here).at(i), n);
	}
	return ret;

}

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

	vector<vector<int>> nodes(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		nodes.at(a-1).push_back(b-1);
		nodes.at(b-1).push_back(a-1);
	}

	int ans = 0;
	vector<int> footprint;
	ans = find(nodes, footprint, 0, n);
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3584
N = int(input())
dic = {}
for _ in range(N):
    name = input()
    if name not in dic.keys():
        dic[name] = 1
    else:
        dic[name] += 1
max_num = 0
box = []
for v in dic.values():
    if v > max_num:
        max_num = v 
for k, v in dic.items():
    if max_num == v:
        box.append(k)
box = sorted(box)
for con in box:
    print(con)


Measured memory_bytes: 33112
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N, M = mi()
a = li()
all_a = float(sum(a)) /(4.0*M)

A = sorted(a, reverse = True)[:M]

for a in A:
    if a < all_a:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long
ll gcd(ll a, ll b){
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b){
	return a*b / gcd(a, b);
}
int main()
{
	ll a, b;
	while (cin >> a >> b){
		cout << gcd(a, b) << " " << lcm(a, b) << "\n";
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N * N * N << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String s;
		int m,h;
		StringBuilder sb;
        while(true){
    		s=in.next();
    		if(s.equals("-")) break;
            m=in.nextInt();
    		sb=new StringBuilder(s);
            for(int i=0;i<m;i++){
                h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0,h);
            }
            System.out.println(sb);
        }
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll A,B;

ll solve(ll a, ll b){
	ll ret;
	ll t = 1;
	for (int i = 1;i < 50;i++){
		//cout << t << endl;
		ll pa = (a/(t*2))*t;
		if(ll((a/t))%2 == 1) pa += a - (a/t)*t +1;
		ll pb = ll(b/(t*2))*t;
		if(ll(b/t)%2 == 1) pb += b - (b/t)*t +1;
		cout << "";
		if(ll(pb-pa)%2 == 1) ret += t;
		t *= ll(2);
	}

	return ret;
}

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

	cin >> A >> B;

	cout << solve(A-1,B) << endl;

	return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll>x(n+1);
    for(ll i=0;i<n;i++)cin>>x[i];
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        ans+=min((x[i+1]-x[i])*a,b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
/* package codechef; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
 class Main
{
    
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		for(int i =0;i<k;i++) {
		    System.out.print("ACL");
		}
		
	
	}
}

Measured memory_bytes: 35552