akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

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

  cout << n - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,min,k:Integer;
  l:array of char;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Read(c);
    Read(x);
    Readln(y);

    count:=0;
    min:=(x+y-abs(x-y))div 2;

    if ((a+b)/2)>c then begin
      count:=2*c*min;
      x:=x-min;
      y:=y-min;
    end;

    if a<(2*c) then
      count:=count+a*x
    else
      count:=count+2*c*x;

    if b<(2*c) then
      count:=count+b*y
    else
      count:=count+2*c*y;


    Writeln(count);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	cout << (n*(n + 1)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> l;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        l.push_back(m);
    }
    sort(l.begin(),l.end());

    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int tmp=l.at(i)+l.at(j);
            for(int k=j+1;k<n;k++){
                if(l[k]>=tmp) break;
                if(l[j]<l[i]+l[k]) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
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; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;    
    }
    else{
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
A=[]*n
A[:]=map(int,input().split())
for i in range(n):
  A[i]=abs(A[i]-x)
if len(A)==1:
  print(A[0])
else:
  def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
      
  left=[0]*n
  right=[0]*n
  for i in range(1,n):
    left[i]=gcd(left[i-1],A[i-1])
    right[n-1-i]=gcd(right[n-i],A[n-i])
 
  ans=10**9
  for i,j in zip(left,right):
    ans=min(ans,gcd(i,j))
  print(ans)  

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fastin ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
ll ans,n,x,m,a[100010];
int p,last[100010];
int main(){
	cin>>n>>x>>m;
	a[++p]=x;
	last[x]=1;
	int zero=0;
	while(1){
		ll tmp=a[p]*a[p]%m;
		if(last[tmp]||tmp==0){
			if(!tmp)	zero=1;
			break;
		}
		++p;
		last[tmp]=p;
		a[p]=tmp;
	}
	if(n<=p){
		rep(i,1,n)	ans+=a[i];
		printf("%lld\n",ans);
	}
	else{
		if(zero){
			rep(i,1,p)	ans+=a[i];
			printf("%lld\n",ans);
		}
		else{
			ll bgn=a[p]*a[p]%m;
			ll sum=0;
			rep(i,last[bgn],p)	sum+=a[i];
			ll len=p-last[bgn]+1;
			rep(i,1,p)	ans+=a[i];
			n-=p;
			ans=ans+(n/len*sum);
			n%=len;
			rep(i,last[bgn],last[bgn]+n-1)	ans+=a[i];
			printf("%lld\n",ans);
		}
	}
	return 0;
}


Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  ll b=0;
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<a-2;i++){
    if((vec.at(i+1)<vec.at(i)&&vec.at(i+2)<vec.at(i+1))||(vec.at(i+1)>vec.at(i)&&vec.at(i+2)>vec.at(i+1))){
      b+=1;
    }
  }
  cout<<b<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int N; cin >> N;
    int hi = 0;
    for (int i = 0; i < N; i++)
    {
        int x; cin >> x;
        hi = max (hi, x);
        if (hi > x + 1)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int K=0;
    while(K*(K-1)/2<N){
        K++;
    }
    if(K*(K-1)!=2*N){
        cout << "No" << endl;
      	return 0;
    }
    cout << "Yes" << endl;
    cout << K << endl;
    vvl A(K-1,vl(K-1));
    ll now=1;
    rep(i,K-1){
        rep(j,K-1){
            if(i>=j){
                A[i][j]=now;
                now++;
            }
        }
    }
    rep(i,K){
        cout << K-1 << ' ';
        if(i==K-1){
            rep(j,K-1){
                cout << A[j][j] << (j==K-2?'\n':' ');
            }
        }
        else{
            ll nowj=0,nowi=i;
            rep(j,K-1){
                cout << A[nowi][nowj] << (j==K-2?'\n':' ');
                if(j<i){
                    nowj++;
                }
                else{
                    nowi++;
                }
            }
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
map<string,int>mp;
map<string,int>:: iterator it;
int main()
{
    int i,j,t,n,a,b,c;
    string s;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";


return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,m,x,ans=0;
    vector<lli> vec,def;
    lli i,j;
    cin>>n>>m;
    rep(i,0,m){
        cin>>x;
        vec.push_back(x);
    }
    if(n<m){
        sort(vec.begin(),vec.end());
        rep(i,1,vec.size()){
            def.push_back(vec[i]-vec[i-1]);
            ans+=vec[i]-vec[i-1];
        }
        sort(def.begin(),def.end(),greater<>());
//        rep(i,0,vec.size()){
//            cout<<vec[i]<<" ";
//        }
//        cout<<endl;
//        rep(i,0,def.size()){
//            cout<<def[i]<<" ";
//        }
//        cout<<endl;
        rep(i,0,n-1){
            ans-=def[i];
        }
    }
    cout<<ans<<endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

ll f(ll n, ll x)
{
    if(n >= 0) return n / x + 1;
    else return 0;
}

void solve()
{
    ll a, b, x; cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    long N;
    cin >> N;
    string ans = "";
    long n = N;
    if(n == 0){
        cout << "0" << endl;
        return 0;
    }
    long base = 1;
    while(n != 0){
        //printf("base = %d\tn = %d\n",base, n);
        if(n % (2*abs(base)) == 0){
            ans += "0";
        }else{
            ans += "1";
            n -= base;
        }

        base *= -2;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

diff = N-M

if diff==0:
    flag = True
    for i in range(M):
        for j in range(M):
            if B[i][j] != A[i][j]:
                flag = False
                break

        if flag==False:
            break
        
    if flag:
        print('Yes')
        exit()

else:
    for di in range(diff):
        for dj in range(diff):
            flag = True
            for i in range(M):
                for j in range(M):
                    if B[i][j] != A[i+di][j+dj]:
                        flag = False
                        break

                if flag==False:
                    break
                
            if flag:
                print('Yes')
                exit()

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,mn,sum;
int main(){
	ll a[3];
	for(int i=0; i<3; i++){
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES";
	else cout<<"NO";
} 

Measured memory_bytes: 504
n, a, b = map(int, input().split())
M = 10**9 + 7
total = pow(2, n, M)

def comb(n, k, p):
    if k > n-k:
        return comb(n, n-k, p)
    num, den = 1, 1
    for i in range(k):
        num = num * (n-i) % p
        den = den * (i+1) % p
    return num * pow(den, p-2, p) % p

print((total - 1 - comb(n,a,M) - comb(n,b,M)) % M)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, d;
  cin >> n >> d;
  vector<vector<ll>> x(n, vector<ll>(d));
  REP(i, n)
  {
    REP(j, d)
    {
      cin >> x[i][j];
    }
  }
  ll res = 0;
  REP(i, n)
  {
    for (ll j = i + 1; j < n; j++)
    {
      ll sum = 0;
      REP(h, d)
      {
        sum += (x[i][h] - x[j][h]) * (x[i][h] - x[j][h]);
      }
      REP(k, 127)
      {
        if (sum == k * k)
          res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC053_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if(x >= 1200)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
from collections import Counter

S = input()
N = len(S)
dp = [[0]*N for _ in range(20)]

for i, s in enumerate(S):
    dp[0][i] = i-1 if s == 'L' else i+1

for k in range(19):
    for i in range(N):
        dp[k+1][i] = dp[k][dp[k][i]]

C = Counter(dp[-1])
print(*[C[i] for i in range(N)])


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int a,b,n;
   cin>>a>>b>>n;
   if(n<b)
   cout<<floor((a*n)/b)<<endl;
   else
   cout<<floor((a*(b-1))/b)<<endl;
   return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint a, b, c;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c;
	if(c-(a+b) < 0){
		cout << "No" << endl;
		return 0;
	}
	if(4*a*b < (c-(a+b))*(c-(a+b))) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
a, b = list(map(int, input().split()))

if 0 < a:
    ans = 'Positive'
elif b < 0:
    if (b - a + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
else:
    ans = 'Zero'
    
print(ans)

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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=(m); (i)<(ll)(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin,(a).end

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll x; cin >> x;
  ll j = 0;
  while(1){
    if(5*pow(j,4)-10*pow(j,3)+10*pow(j,2)-5*j+1 > x) break;
    ++j;
  }
  ll a = j, b = j-1;
  while(1){
    ll now = pow(a,5) - pow(b,5);
    if(now == x){
      cout << a << " " << b << endl;
      return 0;
    }
    if(now > x) --a;
    else if(now < x) --b;
  }
  
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += 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; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s;cin>>s;
	int k;cin>>k;
	vi a(s.size(),0);
	int sum=0;
	rep(i,s.size()){
		if(s[i]=='a')a[i]=0;
		else a[i]=26-(s[i]-'a');
		sum+=a[i];
	}
	if(sum>k){
		rep(i,s.size()){
			if(a[i]<=k){
				s[i]='a';
				k-=a[i];
			}
		}
        s[s.size()-1]=char(s[s.size()-1]+k);
        if(s[s.size()-1]>='{')s[s.size()-1]=char(s[s.size()-1]-26);
	}
	else{
		k-=sum;
		k=k%26;
		rep(i,s.size())s[i]='a';
		s[s.size()-1]=char(s[s.size()-1]+k);
        if(s[s.size()-1]>='{')s[s.size()-1]=char(s[s.size()-1]-26);
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll x = 0;
    for(int i = 1; i <= n; ++i){
        ll p;
        cin >> p;
        x += (ll)(p != i);
    }
    if(x <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=2e5+5,inf=1e18+5,lg=15;
ll n,k,a[maxn],v;
bool  mark[maxn],b;
vector <ll> door;
vector <ll> gd;
vector <ll> gd2;
vector <ll> adj[maxn];
void dfs(int u){
	mark[u]=1;
	gd2.push_back(u);
	if(mark[adj[u][0]]){
		v=adj[u][0];
		b=1;
	}
	else if(!b){
		dfs(adj[u][0]);
	}
}
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
		adj[i].push_back(a[i]);
	}
	dfs(0);
	b=0;
	for(int i:gd2){
		if(i==v)b=1;
		if(b){
			if(i==v&&door.size()>0)break;
			door.push_back(i);
			continue;
		}
		gd.push_back(i);
	}
	if(k<gd.size()){
		cout<<gd[k]+1;
		return 0;
	}
	else{
		k-=(gd.size());
		k=k%(door.size());
		cout<<door[k]+1;
	}
}


Measured memory_bytes: 29804
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K;
    cin >> N >> K;
    int m = ((N-1)*(N-2))/2;
    if(m < K){
        pr(-1);
        return 0;
    }

    vector<pii> ans;
    Rep(i,2,N+1){
        ans.pb({1,i});
    }
    if(m==K){
        //終了
        pr(ans.size());
        for(auto&& a:ans) pr(a.fi, a.se);
        return 0;
    }

    Rep(i,2,N){
        Rep(j,i+1,N+1){
            ans.pb({i,j});
            m--;
            if(m==K){
                //終了
                pr(ans.size());
                for(auto&& a:ans) pr(a.fi, a.se);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3620
def main():
	A, B, C, X, Y = map(int, input().split())
	max_num_c = max(X, Y)*2

	ans = A*X+B*Y
	for num_c in range(0, max_num_c+1, 2):
		num_a = max(0, X-num_c//2)
		num_b = max(0, Y-num_c//2)
		current = A*num_a+B*num_b+C*num_c
		ans = min(ans, current)

	print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  long long int N,M;
  cin>>N>>M;
  
  priority_queue<int, vector<int>, greater<int> > pq;
  for(int i=0; i<N; i++){
    int a;
    cin>>a;
    pq.push(a);
  }
  
  vector<pair<int, int>> v(M);
  
  for(int i=0; i<M; i++){
    int b, c;
    cin>>b>>c;
    v[i].first =c;
    v[i].second =b;
  }
  
  sort(v.begin(), v.end(), greater<pair<int, int>>());
  
  for(int i=0; i<M; i++){
    if(pq.top()<v[i].first){
      for(int j=0; j<v[i].second; j++){
        if(pq.top()<v[i].first){
        pq.pop();
        pq.push(v[i].first);
        }
        else break;
      }
    }
  }
  
  long long int ws=0;
  while(!pq.empty()){
    ws +=pq.top();
    pq.pop();
  }
  
  cout<<ws<<endl;
}



Measured memory_bytes: 1528
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(ALL(A), greater<ll>());

  bool flag = false;
  ll edge[2], cnt = 0;
  REP(i, N) {
    if (A[i] == A[i + 1]) {
      edge[cnt] = A[i];
      cnt++;
      i++;
    }
    if (cnt == 2) {
      flag = true;
      break;
    }
  }
  if (flag) cout << edge[0] * edge[1] << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 1024
S = list(input())
if len(S) == 1:
  print(int("".join(S)))
  exit()
l = []
for i in range(2*len(S) - 1):
    if i % 2 == 0:
        l.append(S[int(i/2)])
    elif i % 2 == 1:
        l.append("")
L_1 = []
L_2 = []
L_1.append(l)
def saiki(list_1,list_2,t): # 1 <= t = 2k-1 <= len(S) - 2
    for e in list_1:
        for b in [0,1]:
            if b == 0:
                list_2.append(e)
            elif t > len(e) - 1:
                print("error: t = {}, len(e) - 1 = {}".format(t,len(e) - 1))
            elif b == 1:
                e_copy = e[:]
                e_copy[t] = "+"
                list_2.append(e_copy)
    list_1.clear()
    if t < len(l) - 2:
        return saiki(list_2,list_1,t+2)
    else:
        return list_2
result = saiki(L_1,L_2,1)    
ans = 0
for e in result:
    ans += eval("".join(e))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#define MAX_N 1e5
using namespace std;
int n, a,b,c;
char aAns[(int)MAX_N] = {};
string aInp[(int)MAX_N];
 
bool checkAllPos(int* cArr){
    for(int i =0 ; i < 3 ; ++i){
        if(cArr[i] < 0) return false;
    }
    return true;
}

void incArr(int* cArr, int lhs, int rhs, int incLhs){
    cArr[lhs] += incLhs;
    cArr[rhs] -= incLhs;
}
 
bool sol(int ptr,int* cArr){
    if(ptr == n){
        return true;
    }
    int lhs = aInp[ptr][0]-'A';
    int rhs = aInp[ptr][1]-'A';
 
    incArr(cArr, lhs, rhs, 1);
    aAns[ptr]=aInp[ptr][0];
    if(checkAllPos(cArr) && sol(ptr+1,cArr)) return true;
 
    incArr(cArr, lhs, rhs, -2);
    aAns[ptr]=aInp[ptr][1];
    if(checkAllPos(cArr) && sol(ptr+1,cArr)) return true;
    incArr(cArr, lhs, rhs, 1);
    aAns[ptr]='-';
    return false;
}
 
int main(){
    cin >> n >> a >> b >> c;
    for(int i = 0 ; i < n ; ++i){
        cin >> aInp[i];
    }
    int arr[3] = {a,b,c};
    if(sol(0,arr)){
        cout << "Yes\n";
        for(int i = 0; i < n ; ++i){
            cout << aAns[i] << "\n";
        }
    }
    else{
        cout << "No\n";
    }
 
    return 0;
}

Measured memory_bytes: 14676
using System;
using System.Collections.Generic;

namespace abc134_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var a = CIn.ReadIntArray(n);

      var lMax = new int[n + 1];
      var rMax = new int[n + 1];

      for (var i = 1; i <= n; i++)
      {
        lMax[i] = Math.Max(lMax[i - 1], a[i - 1]);
      }

      for (var i = n - 1; i >= 0; i--)
      {
        rMax[i] = Math.Max(rMax[i + 1], a[i]);
      }

      for (var i = 0; i < n; i++)
      {
        Console.WriteLine(Math.Max(lMax[i], rMax[i + 1]));
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 18880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vi a(n+1);
  rep(i,n){
    cin >> a[i+1];
  }
  ll count = 1;
  ll x = 1;
  bool ans = true;
  while (count <=100005){
    if(a[x]==2){
      print(count);
      ans = false;
      break;
    }
    else{
      x = a[x];
      count++;
    }
  }
  if(ans){
    print(-1);
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n,m; cin >> n >> m;
    vvl G(n, vl(n,inf));
    vpl v(m);
    rep(i,n) G[i][i] = 0;
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        v[i].first = a;
        v[i].second = b;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    ll ans = 0;
    rep(l,m){
        vvl g = G;
        ll a = v[l].first;
        ll b = v[l].second;
        g[a][b] = inf;
        g[b][a] = inf;
        rep(k,n){
            rep(i,n){
                rep(j,n) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
        bool flag = false;
        rep(i,n){
            rep(j,n){
                if(g[i][j] == inf){
                    ans++;
                    flag = true;
                    break;
                }
            }
            if(flag) break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int N;
std::set<std::string> st;
int main() {
	std::cin>>N;
	for(int i=0;i<N;i++){
		std::string s;
		std::cin>>s;
		st.insert(s);
	}
	std::cout<<st.size()<<std::endl;
	return 0;
}

Measured memory_bytes: 19236
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e16;  
using  p = pair<int,int>;
using  v = vector<int>;

int main(){
   int n;
   cin >> n;
   auto a = vector<ll>(n,0);
   ll y = 0;
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      y+=a[i];
   }
   ll x = 0;
   ll _min = INF;
   for (int i = 0; i < n-1; i++)
   {
      x+=a[i]*2;
      _min = min(_min,abs(x-y));
   }
   cout << _min;
}
  
  

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
  int n,x[100],i,j,flag=0,tmp,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  flag=1; 
    while(flag){
      flag=0;
      for(j=1;j<=n-1;j++){
	if(x[j]<x[j-1]){
	    tmp=x[j];
	    x[j]=x[j-1];
	    x[j-1]=tmp;
	    cnt++;
	    flag=1;
	}
      }
    }
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",x[i]);
  }
  printf("\n%d\n",cnt);
  return 0;
}

  



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

int main()
{
	int n, q, time[100000], flag = 1, now = 0;
	char name[100000][15];
	cin >> n >> q;
	for (int i = 0; i < n; i++)
		cin >> name[i] >> time[i];
	while (flag)
	{
		flag = 0;
		for (int i = 0; i < n; i++)
			if (time[i])
			{
				flag++;
				if (time[i] <= q)
				{
					now += time[i];
					time[i] = 0;
					cout << name[i] << " " << now << endl;
				}
				else
				{
					time[i] -= q;
					now += q;
				}
			}
	}

	return 0;
}


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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if (a == b && b == c && c == a) {
    cout << 1 << endl;
  }
  else if (a != b && b != c && c != a) {
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}


Measured memory_bytes: 3556
from collections import deque
import copy


h, w = map(int,input().split())
li = [["#"] * (w+2)]
li += [["#"] + list(input()) + ["#"] for _ in range(h)]
li += [["#"] * (w+2)]

ans = 0

for i in range(h+2):
    for j in range(w+2):
        if li[i][j] == ".":
            li[i][j] = -1

for i in range(h+2):
    for j in range(w+2):
        if li[i][j] == "#":
            continue
        meiro = copy.deepcopy(li)
        d = deque([(i,j)])
        meiro[i][j] = 0

        while len(d) != 0:
            s,t = d.popleft()
            step = meiro[s][t]
            if meiro[s+1][t] == -1:
                meiro[s+1][t] = step + 1
                d.append((s+1,t))
            if meiro[s-1][t] == -1:
                meiro[s-1][t] = step + 1
                d.append((s-1,t))
            if meiro[s][t+1] == -1:
                meiro[s][t+1] = step + 1
                d.append((s,t+1))
            if meiro[s][t-1] == -1:
                meiro[s][t-1] = step + 1
                d.append((s,t-1))
            ans = max(ans,step)

print(ans)

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

using namespace std;

#define int long long
int n,K;
signed main(){
	cin >> n >> K;
	int cnt1 = n / K;
	int ans = cnt1 * cnt1 * cnt1;
	if(~K & 1){
		int cnt2 = cnt1;
		if(cnt2 * K + (K >> 1) <= n)cnt2++;
		ans += cnt2 * cnt2 * cnt2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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;
}

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

  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  sort(all(v));
  int n = v.back();
  int r = (n % 2 == 0 ? n / 2 : (n + 1) / 2);

  dump(n, r);

  if (binary_search(all(v), r)) {
    cout << n << " " << r << endl;
    return 0;
  }

  auto small = prev(lower_bound(all(v), r));

  auto big = upper_bound(all(v), r);

  dump(*small, *big);

  if (*big == n) {
    cout << n << " " << *small << endl;
    return 0;
  }

  if (abs(*small - r) < abs(*big - r)) {
    cout << n << " " << *small << endl;
  } else
    cout << n << " " << *big << endl;

  return 0;
}


Measured memory_bytes: 640
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

string s;

int main() {
    fast_io; cout_precision;
    cin >> s;
    s[5] = ' ', s[13] = ' ';
    cout << s << endl;
}

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

int n;

int main(){
    scanf("%d", &n);
    bool ok=false;
    for(int i = 0; i<= n/4; i++){
        if((n-4*i)%7==0) {
            ok = true;
            break;
        }
    }
    if(ok) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        if(s.equals("AAA") || s.equals("BBB")){
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

    }
}


Measured memory_bytes: 22996
// inputに入力データ全体が入る      ha
function Main(input) {             //   hma1080提出作品
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")
 
 n = Number(tmp0[0])
    var tmp1 = input[1].split(" ")
    var L=[];total=0;
    for(var i = 0; i < n;i++){
        var r = Number(tmp1[i]);
        total+=r;
         L[i]=r;
        }
         L.sort();
         function compareFunc(a, b) {
            return a - b;
          }
          
          L.sort(compareFunc);
       //   console.log(L);

        
        if(total-L[n-1]>L[n-1]){console.log('Yes');}
        else{console.log('No');}
       
      
    }
  
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

Measured memory_bytes: 256
import math

string = input()
a = int(string.split()[0])
b = int(string.split()[1])

if int(100 * (a + 1) / 8) <= 10 * b:
    print(-1)
elif math.ceil(100 * a / 8) < 10 * b:
    print(10 * b)
elif math.ceil(100 * a / 8) < 10 * (b + 1):
    print(math.ceil(100 * a / 8))
else:
    print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll cnt[10][10];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int t = i, dgt = 1;
        while (t / 10) {
            t /= 10;
            dgt++;
        }
        int x = pow(10, dgt - 1);
        cnt[i / x][i % 10]++;
    }
    ll ans = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int i,a;
  scanf("%d",&a);
  for(i=1;i<=a;i++){
    if(i%3==0)printf(" %d",i);
    else if(i%10==3||i/10==3||i/10%10==3||i/100%10==3||i/1000%10==3)printf(" %d",i);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
<?php


fscanf(STDIN, "%d%d", $n, $m);

$list = explode(" ", trim(fgets(STDIN)));

rsort($list);
$list[0] = intdiv($list[0],2);
$m--;
if($n == 1){
    while($m--){
        $list[0] = intdiv($list[0],2);
    }
    echo $list[0];
    exit;
}

while($m){
    $i = 1;
    while($list[0] < $list[$i]){
        $list[$i] = intdiv($list[$i], 2);
        $m--;
        if($m == 0){
            break 2;
        }
        $i++;
    }
    rsort($list);
    $list[0] = intdiv($list[0], 2);
    $m--;
}

echo array_sum($list);

Measured memory_bytes: 14840
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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;}

typedef long long LL;
typedef pair<int, int> PII;

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

int main(void){
  double a, b, h, m;
  static const double pi = 3.141592653589793;
  cin >> a >> b >> h >> m;

  double delta = (pi * (60 * h - 11 * m)) / 360;

  double result = sqrt(b*b + a*a - 2 * a *b * cos(delta));
  cout << fixed << setprecision(15) << result << endl;

  return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<ll>a(n);
  vector<ll>s(n+1);
  ll ans = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i]; 
    a[i]--;
    s[i+1] = (s[i] + a[i]) % k;  
  }
  map<ll,ll>mp; 
  for (int i = 0; i <= n; i++){
    if (i - k >= 0)
      mp[s[i-k]]--;
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 15872
s = input()
a = [0 for i in range(26)]
for i in s:
	b = ord(i) - ord("a")
	a[b] += 1
for i in range(26):
	if a[i] == 0:
		x = chr(ord("a")+i)
		s += x
		print (s)
		exit()
a = [0 for i in range(26)]
for i,j in enumerate(reversed(s)):
	b = ord(j) - ord("a")
	a[b] += 1
	if i == 0: continue
	for k in range(b+1,26):
		if a[k] == 1:
			x = chr(ord("a")+k)
			ans = s[:(26-i)-1] + x
			print (ans)
			exit()
print (-1)

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

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        List<int> numlist = new List<int>();
        int pos = 0; 
        for (int i = 1; i < inpt.Length; i++) {
            if(inpt[i-1] != inpt[i]) {
                numlist.Add(i - 1 - pos + 1);
                pos = i;
            }
        }
        numlist.Add(inpt.Length-pos);
        int ans = GetAns(numlist, numlist.OrderBy(a => a).ToList(), inpt.Length);
        if(ans < 0) {
            ans = GetAns2(numlist, inpt.Length);
        }
        Console.WriteLine(ans);
    }

    private int GetAns2(List<int> inpt, int total) {
        int min = inpt.Min();
        int max = inpt.Max();
        int ans = total/2;
        if(total%2>0) {
            ans++;
        }
        int cnt = inpt.First();
        for (int i = 1; i < inpt.Count-1; i++) {
            if(cnt>=ans) {
                ans = total - cnt;
                break;
            } else if(cnt+inpt[i]>=ans) {
                ans = Math.Min(cnt + inpt[i], total - cnt);
                break;
            }
            cnt += inpt[i];
        }
        return ans;

    }
    private int GetAns(List<int> inpt, List<int> ord, int total) {
        if(inpt.Count == 1) {
            return inpt[0];
        }
        if(inpt.Count == 2) {
            return ord.Last();
        }
        return -1;
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




101



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 14048
S = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A+B+C+D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7")
elif A+B+C-D == 7:
     print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7")
elif A+B-C+D == 7:
     print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7")
elif A+B-C-D == 7:
     print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7")
elif A-B+C+D == 7:
     print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7")
elif A-B+C-D == 7:
     print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7")
elif A-B-C+D == 7:
     print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7")
elif A-B-C-D == 7:
     print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7")


Measured memory_bytes: 38384