akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	FOR(i,1,1e8){
		ll now=i*a;
		if(now%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

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

using namespace std;

int main()
{
    long long sum1=0,n;
    cin>>n;
    map<long long,long long> m1;
    for(long long i1=0;i1<n;i1++){
        long long d1;
        cin>>d1;
        sum1+=d1;
        if(m1.find(d1)==m1.end()){
            m1.insert(make_pair(d1,1));
        }
        else{
            m1[d1]++;
        }
    }
    long long q;
    cin>>q;
    for(long long i1=0;i1<q;i1++){
        long long bi,ci;
        cin>>bi>>ci;
        //cout<<sum1<<" ";
        sum1=sum1-m1[bi]*bi;
        //cout<<sum1<<" ";
        //cout<<m1[bi]<<"---"<<m1[ci]<<" ";
        m1[ci]=m1[ci]+m1[bi];
        sum1+=ci*m1[bi];
        m1[bi]=0;
        cout<<sum1<<"\n";
    }
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, n, x, y;
  string s, t, u;
  cin >> a >> b;
   if (b == a)
    pr("Draw");
    else if (a == 1)
    pr("Alice");
  else if (b == 1)
    pr("Bob");

  else if (a > b)
    pr("Alice");

  else if (a < b)
    pr("Bob");

  return 0;
}

Measured memory_bytes: 3652
/* C - Sum of product of pairs */

#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, mod = 1000000007;
  long long sum = 0, ans = 0;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
    sum %= mod;
  }
  for(int i = 0; i < N; i++){
    sum -= A.at(i);
    if(sum < 0) sum += mod;
    ans += A.at(i) * sum;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4784
#include <stdio.h> //depth first search
#include <stdlib.h>
  
#define WHITE 0  
#define GRAY 1    
#define BLACK 2   
  
char Adj[100][100]; 
int n, d[100],f[100],color[100],time;         
  
 
 
void visit( int u )
{
  short v;
  
  color[u] = GRAY;    
  d[u] = ++time;  
    
  for( v = 0 ; v < n ; v++ )
    {
      if( Adj[u][v] == 1 && color[v] == WHITE )
	{
	  visit( v );                             
	}
    }
  
  color[u] = BLACK;
  f[u] = ++time;
  
  return;
  
}
 
void dfs()
{
  short i;
    
  for( i = 0 ; i < n ; i++ ) {
    if( color[i] == WHITE ) {
      visit( i );
    }
  }
  return;
}
  
  
  
main()
{
  
  int i, j,u, k, v;
  
  scanf( "%d",&n );
    
  for( i = 0 ; i < n ; i++ )
    {
      for( j = 0 ; j < n ; j++ )
	{
	  Adj[i][j] = 0;
	}
    }
  
    
  for( i = 0 ; i < n ; i++ )
    {
      scanf( "%d%d", &u,&k );
      
      for( j = 0  ; j < k; j++ )
	{
	  scanf( "%d",&v );
	  Adj[u-1][v-1] = 1;
	}
      
    }
  
  dfs();
    
  for( i=0; i<n; i++ )
    {
      printf("%d %d %d\n", i+1, d[i], f[i] );
    }
 
  return 0;
  
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int n,m;
    int ans =-inf;
    map<string,int> mp;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    rep(i,m){
        string s;
        cin>>s;
        mp[s]--;
    }
    for(auto &p:mp){
        ans=max(ans,p.second);
    }
    if(ans>=0) cout << ans <<endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){
  int A,B;
  cin>>A>>B;
  	if(A >= 13){
      cout<<B<<endl;
  	} else if(A >= 6 && A<= 12){
  	  cout<<B/2<<endl;
  	} else if(A <= 5){
  	  cout<<0<<endl;
  	}
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   ll n; cin>>n;
   int x,m; cin>>x>>m;
   if(n<=10101010){
      ll res=0; int cur=x;
      while(n){
         res+=cur;
         cur=(1LL*cur*cur)%m; n--;
      }
      cout<<res<<endl; return 0;
   }
   map<int,int> rs; int idx=0,cur=x,eq=-1;
   while(1){
      if(rs.count(cur)){
         eq=cur; break;
      }
      rs[cur]=idx;
      cur=(1LL*cur*cur)%m; idx++;
   }
   ll res=0;
   if(cur==0){
      cur=x;
      goto fail;
   }
   if((int)rs.size()<=n){
      for(auto& add:rs)res+=add.first;
      n-=rs.size(); cur=eq; idx=0;
      rs.clear();
      while(1){
         if(rs.count(cur))break;
         rs[cur]=idx++; cur=(1LL*cur*cur)%m;
      }
      ll cir=0;
      for(auto& add:rs)cir+=add.first;
      res+=cir*(n/(int)rs.size()); n%=rs.size();
   }
   else cur=x;
   fail:;
   while(n){
      res+=cur;
      cur=(1LL*cur*cur)%m; n--;
      if(cur==0)break;
   }
   cout<<res<<endl;
   return 0;
}


Measured memory_bytes: 5928
def main():
    n = int(input())
    a = list(map(lambda i:int(i)-1, input().split(" ")))
    d = {}
    for i in range(n):
        d[i]=0
    for i in range(n-1):
        d[a[i]] += 1
    for i in range(n):
        print(d[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 38844
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,q,x,y,AC[100001];
	AC[0]=0;
	string s;
	cin>>n>>q>>s;
	for(int i=1;i<n;i++)
	AC[i]=AC[i-1]+(s[i]=='C'&&s[i-1]=='A');
	while(q--){
		cin>>x>>y;
		cout<<AC[max(x,y)-1]-AC[min(x,y)-1]<<endl;
	}
    return 0;
}


Measured memory_bytes: 4080
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        return x != p.x ? x < p.x : y < p.y ;
    }

};

double norm(Point p){
    return p.x * p.x + p.y * p.y;
}

double v_abs(Point p){
    return sqrt(norm(p));
}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

bool clockwise(Point p0, Point p1, Point p2){
    Vector a = p1 - p0, b = p2 - p0;
    if(cross(a, b) < -EPS) return true;
    else return false;
}

int main(){
    int N;
    scanf("%d", &N);
    vector<Point> G, U, L;
    rep(i, N){
        Point p;
        scanf("%lf%lf", &p.x, &p.y);
        G.push_back(p);
    }
    sort(all(G));

    U.push_back(G[0]);
    U.push_back(G[1]);
    L.push_back(G[N-1]);
    L.push_back(G[N-2]);

    for(int i = 2; i < N; i++){
        for(int j = U.size() - 1; j > 0; j--){
            if(clockwise(G[i], U[j], U[j - 1])) U.pop_back();
            else break;
        }
        U.push_back(G[i]);
    }

    for(int i = N - 3; i >= 0; i--){
        for(int j = L.size() - 1; j > 0; j--){
            if(clockwise(G[i], L[j], L[j - 1])) L.pop_back();
            else break;
        }
        L.push_back(G[i]);
    }

    reverse(all(L));
    for(int i = U.size() - 2; i > 0; i--){
        L.push_back(U[i]);
    }

    int tmp = 0;
    for(int i = 1; i < L.size(); i++){
        if(L[i].y < L[tmp].y) tmp = i;
        else if(L[i].y == L[tmp].y && L[i].x < L[tmp].x) tmp = i;
    }

    int Ls = L.size();
    printf("%d\n", Ls);
    for(int i = 0; i < Ls; i++){
        Point p0 = L[(tmp + i) % Ls];
        printf("%d %d\n", int(p0.x), int(p0.y));
    }

}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

int ctoi(char c){
    return c-'0';
}



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

    if(a.size()>b.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(b.size()>a.size()){
        cout << "LESS" << endl;
        return 0;
    }

    for(int i=0;i<a.size();i++){
        int x = ctoi(a[i]);
        int y = ctoi(b[i]);
        if(x>y){
            cout << "GREATER" << endl;
            return 0;
        }

        if(y>x){
            cout << "LESS" << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;
}

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

int main() {
    ll n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    n *= 2;

    vector<ll> check;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            check.emplace_back(i);
            if (n / i != i) check.emplace_back(n / i);
        }
    }

    ll ans = n - 1;
    for (int i = 0; i < (int)check.size(); i++) {
        ll x = check[i], y = n / x;
        auto change = crt({0ll, y - 1}, {x, y});
        if (change.second != 0 && change.first < ans) ans = change.first;
    }

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

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int x; cin >> x;
    print(8 - (x - 400) / 200);

    return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int totaltaxi = N *A;
    if(totaltaxi>B){
        cout << B << endl;
    }else{
        cout << totaltaxi << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll x[5]; rep(i,5) cin >> x[i];
  ll result = 0; while (x[result]) result++;
  result++;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r, lef;};
struct Node T[MAX]; 

void print(int u){

  int i=T[u].p, depth = 0;
  while(i != NIL){
    i = T[i].p;
    depth++;
  }
  if(depth == 0){
    printf("node %d: parent = %d, depth = %d, root, ",u, T[u].p, depth );
  }else if(T[u].l == NIL){
    printf("node %d: parent = %d, depth = %d, leaf, ",u, T[u].p, depth);
  }else{
    printf("node %d: parent = %d, depth = %d, internal node, ", u, T[u].p, depth);
  }
  
  i = T[u].l;
  printf("[");
  if(i != NIL) printf("%d", i);
  while (i != -1) {
    i = T[i].r;
    if(i != NIL)printf(", %d", i);
  }
  printf("]\n");
}

int main(){
  int i, j, temp1, temp2, temp3, temp4, n;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &temp2, &temp1);
    for ( j = 0; j < temp1; j++ ){
      scanf("%d", &temp3);
      T[temp3].p = temp2;

      if(j == 0){
	T[temp2].l = temp3;
      }else if(j > 0){
	T[temp4].r = temp3;
      }
      temp4 = temp3;
    }
  }  
  
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 2176
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY


#====UnionFindTree====
class UnionFindTree
    attr_accessor:parent,:size,:rank,:group
    def initialize(n)
        @parent=Array.new(n){|idx| idx}
        @rank=Array.new(n,0)
        @size=Array.new(n,1)
    end

    def find(x)
        return x if @parent[x]==x
        @parent[x]=find(@parent[x])
        return @parent[x]
    end

    def union(x,y)
        par_x=find(x)
        par_y=find(y)
        return if par_x==par_y
        if @rank[par_x]<@rank[par_y]
            @parent[par_x]=par_y
            @size[par_y]+=@size[par_x]
        else
            @parent[par_y]=par_x
            @size[par_x]+=@size[par_y]
            @rank[par_x]+=1 if @rank[par_x]==@rank[par_y]
        end
    end

    def same?(x,y)
        return find(x)==find(y)
    end

    def get_size(x)
        return @size[find(x)]
    end
    def make_groups()
      n=@parent.size
      @group=Array.new(n,[])
      @parent.each_with_index do|child,i|
        @group[i]<< child 
      end
    end
end
N,Q=get_i
uft=UnionFindTree.new(N)
Q.times do|i|
  t,u,v=get_i
  if t.zero?
      uft.union(u,v)
  else
      puts yn_judge(uft.same?(u,v),1,0)
  end
end

Measured memory_bytes: 18724
#include <iostream>

#include <string>


using namespace std;



int main(){
    while(true){
         string str;
        cin>>str;
        if(str=="-"){
            break;
        }
        int num;
        cin>>num;
        
        while(num){
            int n;
            cin>>n;
            string str1="";
            for(int i=n;i!=str.size();++i){
                str1+=str[i];
            }
            for(int i=0;i!=n;++i){
                str1+=str[i];
            }
            str=str1;
            --num;
                
        }
        cout<<str<<endl;
    }
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n,i,temp,maxi;
    maxi=0;
    cin >> h >> n;
    for(i=0;i<n;i++)
    {
        cin >> temp;
        maxi+=temp;
    }
    //cout << maxi;
    if(maxi>=h)
        cout << "Yes";
    else
        cout << "No";
//    cout << ceil(h*1.0/a);
}


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

// THINK: INT vs LONG LONG?

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

	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll ans = max({a * c, a * d, b * c, b * d});
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)//不用绕，使出吃奶的劲儿都到不了
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)//如果最优路径与时间的积偶不一，一定到不了
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)//同理
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");//因为如果No就都return 0了，所以剩下一定是Yes。
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}
ll N,A,B;
vector<ll> v;
bool sat(ll m){
  ll C = A-B;
  vector<ll> w(N);
  rep(i,N) w[i] = v[i] - m*B;
  rep(i,N){
    if(w[i]<0)continue;
    m -= w[i]/C;
    if(w[i]%C != 0)--m;
  }
  return m>=0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> A >> B;
  v = vector<ll>(N);
  rep(i,N)cin >> v[i];
  sort(all(v),greater<ll>());
  ll l = 0, r = v[0];
  while(r-l>1){
    ll m = (r+l)/2;
    if(sat(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
import math
import collections

def main():
    N = int(input())
    S = input()

    c = collections.Counter(S)
    c = c['R'] * c['G'] * c['B']

    count = 0
    for i in range(N):
        for j in range(i+1, N):
            k = 2*j-i
            if k < N:
                if (S[i] != S[j]) and (S[j] != S[k]) and (S[i] != S[k]):
                    count += 1

    print(c - count)

    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 9420
#include <cstdio>
#include <cmath>
using namespace std;
constexpr double pi = 3.141592653589793;
const double cos_60 = cos(pi / 3.0), sin_60 = sin(pi / 3.0);

struct Point
{
    double x, y;
};

void koch(int d, Point p_1, Point p_2)
{
    if (d == 0)
    {
        return;
    }

    Point s, t, u;
    s.x = p_1.x * 2.0 / 3.0 + p_2.x / 3.0;
    s.y = p_1.y * 2.0 / 3.0 + p_2.y / 3.0;
    t.x = p_1.x / 3.0 + p_2.x * 2.0 / 3.0;
    t.y = p_1.y / 3.0 + p_2.y * 2.0 / 3.0;
    u.x = (t.x - s.x) * cos_60 - (t.y - s.y) * sin_60 + s.x;
    u.y = (t.x - s.x) * sin_60 + (t.y - s.y) * cos_60 + s.y;
    koch(d - 1, p_1, s);
    printf("%lf %lf\n", s.x, s.y);
    koch(d - 1, s, u);
    printf("%lf %lf\n", u.x, u.y);
    koch(d - 1, u, t);
    printf("%lf %lf\n", t.x, t.y);
    koch(d - 1, t, p_2);
}

int main()
{
    int n;
    scanf("%d", &n);
    Point p_1, p_2;
    p_1.x = 0.0;
    p_1.y = 0.0;
    p_2.x = 100.0;
    p_2.y = 0.0;

    printf("%lf %lf\n", p_1.x, p_1.y);
    koch(n, p_1, p_2);
    printf("%lf %lf\n", p_2.x, p_2.y);
    return 0;
}


Measured memory_bytes: 2724
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<=n;i++)
using namespace std;
int main(){
    long long A,B,C,X,Y,price=__LONG_LONG_MAX__;
    cin>>A>>B>>C>>X>>Y;
    REP(i,100000){
        long long tmp = i*(2*C)+max((long long)0,(X-i))*A+max((long long)0,(Y-i))*B;
        price = min(price,tmp);
    }
    cout<<price<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long N, Y;
    long long a, b, c;
    bool flag =true;
    cin >> N >> Y;
    for (long long i = 0; i <= N; i++) {
        for (long long j = 0; j <= N - i; j++) {
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
                cout << i <<" "<< j <<" "<< N - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 <<" "<< -1 <<" "<< -1 << endl;
}

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

int func( int *ball, int n, int cur, stack<int> b, stack<int> c){
    int ball_cur = ball[cur];
    int count=0;
    
    if(cur == n){
        return 1;
    }    
    if(b.empty() || b.top() < ball_cur ){
        b.push(ball_cur);
        count+=func(ball, n, cur+1, b, c);
        b.pop();
    }
    if(c.empty() || c.top() < ball_cur ){
        c.push(ball_cur);
        count+=func(ball, n, cur+1, b, c);
        c.pop();
    }
    return count;    
}

int main(){
    int n;
    int ball[10];
    stack<int> stk_b,stk_c;
    
    cin>>n;
    for(int i=0;i<n;++i){
        for(int j=0;j<10;++j){
            cin>>ball[j];
        }
        cout << (func(ball, 10, 0, stk_b, stk_c)?"YES":"NO") << endl;
        
    }
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>

#define FastIO 						\
		ios::sync_with_stdio(0); 	\
		cin.tie(NULL); 				\
		cout.tie(NULL);

using namespace std;

typedef long long ll;

int sim(string a, string b) {
	int r = a.length();
	for (int i = 0; i < a.length(); i++) {
		if (a[i] == b[i]) {
			r--;
		}
	}
	return r;
}

void solve() {
	string a, b;
	cin >> a >> b;
	vector<string> v;
	for (int i = 0; i <= a.length() - b.length(); i++) {
		v.push_back(a.substr(i, b.length()));
	}
	int mn = sim(v[0], b);
	for (int i = 1; i < v.size(); i++) {
		int mnsm = sim(v[i], b);
		if (mnsm < mn) {
			mn = mnsm;
		}
	}
	cout << mn << "\n";
}

int main() {
	// FastIO;
	int n = 1;
	// cin >> n;
	while (n--) {
		solve();
	}
}


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


int main()
{
    int a;
    cin >> a;

    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;

ll Ep(int x, int y){
  if(y == 1) return x;
  ll r = Ep(x,y/2);
  if(y%2 == 1) return r *r%MOD *x%MOD;
  else return r *r%MOD;
}

int main(){
  int n, x;
  cin >> n;
  cin >> x;
  if(x != 0){
    cout << 0 << endl;
    return 0;
  }
  map<int, int> mp;
  for(int i=1; i<n; ++i){
    cin >> x;
    if(x == 0){
      cout << 0 << endl;
      return 0;
    }
    ++mp[x];
  }
  ll ans = 1;
  for(auto p: mp){
    if(p.first == 1) continue;
    ans *= Ep(mp[p.first-1], p.second);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8248
#include<iostream>
    using namespace std;
    int toa(char c){
     if(c=='a') return 0;
     return ('z'-c+1);
    }
    int main(void){
    int i,k;
    string s,res="";
    cin >> s;
    cin >> k;
    for(i=0;i<s.length()-1;i++){
    if(toa(s[i])<=k){
    res+="a";
    k-=toa(s[i]);
    }else{
    res+=s[i];
    }
    }
    k%=26;
    if(k>'z'-s[i]) k-=26;
    res+=s[i]+k;
    cout << res;
    return 0;
    }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
vector<pair<int,ll> > g[100005];
int n, x[100005], y[100005], ind[100005];
bool cmp(int i, int j) {
	return x[i]!=x[j]?x[i]<x[j]:y[i]<y[j];
}
ll calc(int i, int j) {
	if (i<1||j>n) return 0;
	return min(abs(x[ind[i]]-x[ind[j]]),abs(y[ind[i]]-y[ind[j]]));
}
vector<pair<ll,pii> > edge;
int par[100005];
int find(int x) {
	return (x==par[x]?x:par[x]=find(par[x]));
}
void merge(int x, int y) {
	x=find(x), y=find(y);
	par[y]=x;
}
ll mst() {
	rep(i,1,n) par[i]=i;
	ll ans=0;
	rep(i,1,n) rep(j,0,(int)g[i].size()-1) edge.pb(mp(g[i][j].second,mp(i,g[i][j].first)));
	sort(edge.begin(),edge.end());
	rep(i,0,(int)edge.size()-1) {
		int x=edge[i].second.first, y=edge[i].second.second;
		if (find(x)==find(y)) continue;
		merge(x,y);
		ans+=edge[i].first;
	}
	return ans;
}
int main() {
	n=readint();
	rep(i,1,n) x[i]=readint(),y[i]=readint(),ind[i]=i;
	sort(ind+1,ind+1+n,cmp);
	rep(i,1,n-1) {
		g[ind[i]].pb(mp(ind[i+1],calc(i,i+1)));
		g[ind[i+1]].pb(mp(ind[i],calc(i,i+1)));
	}
	rep(i,1,n) swap(x[ind[i]],y[ind[i]]);
	sort(ind+1,ind+1+n,cmp);
	rep(i,1,n-1) {
		g[ind[i]].pb(mp(ind[i+1],calc(i,i+1)));
		g[ind[i+1]].pb(mp(ind[i],calc(i,i+1)));
	}
	ll ans=mst();
	printll(ans);
	return 0;
}


Measured memory_bytes: 23404
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <algorithm>
// #include "./Debug.h"

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());

	const int n = s[0], d = s[1];

	int ans = 0, buf = 0;

	buf = d * 2 + 1;

	ans = n / buf;
	if (0 != n % buf) {
		ans++;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

void solve() {
	ll x, k, d; cin >> x >> k >> d;
	x=abs(x); {
		ll t = x/d;
		if (t >= k) {
			cout << x-k*d << '\n';
			return;
		}
		x -= t*d;
		k -= t;
		if (k % 2==0) {
			cout << x << '\n';
		} else {
			cout << abs(x-d) << '\n';
		}
//		return;
	}
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

const int Nmax = 1e5 + 1;
bool OK,OK1;
int N,st,dr,nr,Min_curent;
int a[Nmax];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];
    while(!OK1)
    {
        OK = false,OK1 = true;
        for(int i = 1; i <= N && !OK; ++i)
            if(a[i] > 0)
            {
                Min_curent = 101;
                st = dr = i;
                while(a[dr] > 0)
                    Min_curent = min(Min_curent,a[dr]),++dr;
                for(int j = st; j <= dr; ++j)
                    a[j] -= Min_curent;
                OK = true;
                nr += Min_curent,OK1 = false;
            }
    }
    cout << nr;
    return 0;
}


Measured memory_bytes: 256
#声が届く距離?
#bigvalue=val1,smallvalue=val2
def hearing_voice?(val1,val2,d)
  return hearing_voice?(val2,val1,d) if val1 < val2 
  
  if val1 - val2 <= d
    return true      
  else
    return false
  end
end

# main #hash化
key   = [:a, :b, :c, :d]
value = gets.split(' ').map(&:to_i)
keyvalue = [key, value].transpose
point = Hash[*keyvalue.flatten]

#A to C
if hearing_voice?(point[:c],point[:a],point[:d]) 
    puts "Yes"
# A to B to C
elsif hearing_voice?(point[:a],point[:b],point[:d]) && hearing_voice?(point[:b],point[:c],point[:d])
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import java.util.Scanner;
import java.lang.Math;

class Main{
	public static void main(String[] arg){
	
		
		
		Scanner sc = new Scanner(System.in);
		double x1,y1,x2,y2;
		 x1=sc.nextDouble();
		 y1=sc.nextDouble();
		 x2=sc.nextDouble();
		 y2=sc.nextDouble();
		 
		double num=Math.sqrt(Math.abs((x1-x2)*(x1-x2))+Math.abs((y1-y2)*(y1-y2)));
	  
		System.out.printf("%.8f",num);
}
}


Measured memory_bytes: 28160
S = input()
count1 = 0
count2 = 0
for i in range(3):
    for j in range(i+1, 4):
        if S[i] == S[j]:
            count1 += 1
for i in range(3):
    if S[i] == S[i+1]:
        count2 += 1

if count1 == 2 and count2 != 4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
    vector<pair<int,int>> hoge;
    int a,b;
    cin >> a >> b;
    hoge.push_back(make_pair(a,b));
    int n;
    cin >> n;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        hoge.push_back(make_pair(a,b));
    }
    sort(hoge.begin(),hoge.end());
    for(int i = 1;i < n+1;++i){
        if(hoge[i-1].second > hoge[i].first){
            cout << "1" << endl;
            return 0;
        }
    }
    cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
	long long a,b;
    long double h, m, c, result;
  	scanf("%lld",&a);
  	scanf("%lld",&b);
  	scanf("%Lf",&h);
  	scanf("%Lf",&m);
  	
    c=h*30.0+m*0.5-m*6.0;
    if(c<0) c*=-1;

  	if(c>180.0) c=360.0-c;
    result = a*a+b*b-2*a*b*cosl(c*M_PI/180.0);
    result = sqrtl(result);
  	printf("%.12Lf",result);
  		
  return 0;
}

Measured memory_bytes: 2532
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; ll k; cin>>n>>k;
    int p[5050];
    ll c[5050];
    for(int i=0; i<n; i++){
        cin>>p[i];
        p[i]--;
    }
    for(int i=0; i<n; i++){
        cin>>c[i];
    }
    bool used[5050]={};
    ll ans=-1e10;
    for(int i=0; i<n; i++){
        if(used[i]) continue;
        vector<ll> v;
        int x=i;
        while(!used[x]){
            used[x]=1;
            v.push_back(c[x]);
            x=p[x];
        }
        int m=v.size();
        vector<ll> s(m+1);
        for(int j=0; j<m; j++) s[j+1]=s[j]+v[j];
        ll s0=max(0ll, s[m]);
        for(int j=0; j<=m; j++){
            for(int l=0; l<=j; l++){
                ll len=j-l;
                if(len>0 && len<=k){
                    ans=max(ans, s[j]-s[l]+(k-len)/m*s0);
                }
                len=m-len;
                if(len>0 && len<=k){
                    ans=max(ans, s[m]-(s[j]-s[l])+(k-len)/m*s0);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=0;
    cin >> n;
    string s;
    map<string,int> m;
    for (int i=0;i<n;i++){
        cin >> s;
        m[s]++;
    }
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> s;
        m[s]--;
    }
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        ans=max(ans,itr->second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int count = 0;
    bool flag = true;
    for (int i = 2; count < n; i++)
    {
        flag = true;
        for (int j = 2; j < i / 2; j++)
        {
            if (i % j == 0)
            {
                flag = false;
                break;
            }
        }
        if (flag && i % 5 == 1)
        {
            printf("%d%c", i, count == n - 1 ? '\n' : ' ');
            count += 1;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-5;
//const long long INF=(LL)(1e9)*(LL)(1e9);
const int INF=1e9*2;
 
template<class T>
void chmin(T& a, const T& b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T& b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	REP(i,q)
		t*=p;
	return t;
}

//print for container
/*
template<typename T, typename U = typename T::iterator>
void print(const T container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}*/

template<typename Head>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


int main()
{
	int n,z,w;
	cin>>n>>z>>w;
	VI a(n+2);
	REP(i,n)
		cin>>a[i];
	a[n]=z;
	a[n+1]=w;
	vector<VI> memo(n+2,VI(2,-1));
	function<int(int,int)> dp=[&](int x, int p)
	{
		if(memo[x][p]!=-1) return memo[x][p];
		int mx=p==0?0:INF;
		FOR(i,x+1,n-1)
		{
			if(p==0)
				chmax(mx, dp(i, 1-p));
			else
				chmin(mx, dp(i, 1-p));
		}
		if(p==0)
			chmax(mx, abs(a[n-1]-a[x]));
		else
			chmin(mx, abs(a[n-1]-a[x]));
		//print(x,c,p,mx);

		return memo[x][p]=mx;
	};
	int mx=0;
	FOR(i,0,n)
	{
		chmax(mx, dp(i, 1));
	}
	chmax(mx, abs(a[n-1]-a[n+1]));
	cout<<mx<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
map<string, set<int> > mp;

int f(string s) {
    //cerr << s << endl;
    if(s.size() == 1) return s[0] - '0';
    return 10 * f(s.substr(0, s.size() - 1)) + s.back() - '0';
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    while(m--) {
        string s;
        cin >> s;
        int l, u;
        cin >> l >> u;
        for(int i = l; i <= u; i++) mp[s].insert(i);
    }
    string NEWVAL;
    for(int i = 1; i <= 21; i++) NEWVAL.push_back('A');
    int n;
    cin >> n;
    stack<string> sta;
    while(n--) {
        string s;
        cin >> s;
        NEWVAL[0]++;
        if(s == "+" || s == "-" || s == "*" || s == "/") {
            string a = sta.top();
            sta.pop();
            string b = sta.top();
            sta.pop();
            for(auto itr = mp[a].begin(); itr != mp[a].end(); itr++) {
                for(auto itr2 = mp[b].begin(); itr2 != mp[b].end(); itr2++) {
                    if(s == "/" && *itr == 0) {
                        cout << "error" << endl;
                        return 0;
                    }
                    if(s == "+") mp[NEWVAL].insert((*itr2 + *itr) % 256);
                    if(s == "-") mp[NEWVAL].insert((*itr2 - *itr + 256) % 256);
                    if(s == "*") mp[NEWVAL].insert(*itr * *itr2 % 256);
                    if(s == "/") mp[NEWVAL].insert(*itr2 / *itr % 256);
                }
            }
            sta.push(NEWVAL);
            continue;
        }
        if(!mp[s].empty()) {
            sta.push(s);
        } else {
            /*
            cerr << "nmb: " << s << endl;
            cerr << f(s) << endl;
            */
            mp[NEWVAL].insert(f(s));
            sta.push(NEWVAL);
        }
    }
    cout << "correct" << endl;
    return 0;
}



Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 305, mlg = 18, rt = 1<<10, mod = 1e9 + 7;
int good[maxn][maxn][maxn], dp[maxn][maxn][maxn], n, m;
vector<pair<int, int>> constraints[maxn];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int l, r, x, i = 0; i < m; i++) {
		cin >> l >> r >> x;
		constraints[r].pb({l, x});
	}
	for(int r = 0; r <= n; r++)
		for(int g = 0; g <= n; g++)
			for(int b = 0; b <= n; b++) {
				good[r][g][b] = (r == 0 || r != g) && (g == 0 || g != b) && (b == 0 || b != r);
				for(auto i : constraints[max({r, g, b})]) {
					good[r][g][b] &= (r >= i.first) + (g >= i.first) + (b >= i.first) == i.second;
				}
			}
	dp[0][0][0] = 1;
	int ans = 0;
	for(int r = 0; r <= n; r++)
		for(int g = 0; g <= n; g++)
			for(int b = 0; b <= n; b++) {
				if(!good[r][g][b]) continue;
				int p = max({r, g, b});
				if(p == n) {
					add(ans, dp[r][g][b]);
					continue;
				}
				add(dp[p+1][g][b], dp[r][g][b]);
				add(dp[r][p+1][b], dp[r][g][b]);
				add(dp[r][g][p+1], dp[r][g][b]);
			}
	cout << ans;
}


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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '1') s[i] = '9';
		else if(s[i] == '9') s[i] = '1';
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N,i,count=0;
	scanf("%d",&N);
	int tmp=N/2;
	char s[N];
	scanf("%s",s);
	for(i=0;i<tmp;i++){
		if(s[i]!=s[i+tmp]){
			count++;
		}
	}
	if(count==0 && N%2==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " "
    << x << " "
    << y << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()
    d = collections.defaultdict(list)
    l = len(s)
    for i in range(l):
        d[s[i]].append(i)

    r = inf
    for c in d.keys():
        t = -1
        rc = 0
        for i in d[c]:
            if rc < i - t - 1:
                rc = i - t - 1
            t = i
        if rc < l - t - 1:
            rc = l - t - 1
        if r > rc:
            r = rc

    return r


print(main())


Measured memory_bytes: 7748