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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    while(cin>>s){
        if(s[0]==s[1] && s[1]==s[2]){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}


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

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

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

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

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

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

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



int main() {

	long double a, b, c;
	cin >> a >> b >> c;
	printyn(sqrtl(a) + sqrtl(b) + 1e-14 < sqrtl(c));

	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct data1  // jaar r shobtheke chhoto
{
    int l,r,id;
    bool operator <(const data1 a)const
    {
        if(r==a.r)return id<a.id;
        return r<a.r;
    }
};

struct data2  // jaar l shobtheke boro
{
    int l,r,id;
    bool operator <(const data2 a)const
    {
        if(l==a.l)return id<a.id;
        return l>a.l;
    }
};

data1 d1;
data2 d2;
set<data1> s1;
set<data2>s2;

int ab(int x)
{
    if(x<0)return -x;
    return x;
}

int ll[100009],rr[100009],n;
LL ret=0;


void solve(int z)
{
    s1.clear();
    s2.clear();

    for(int i=1;i<=n;i++)
    {
        d1.l=d2.l=ll[i];
        d1.r=d2.r=rr[i];
        d1.id=d2.id=i;
        s1.insert(d1);
        s2.insert(d2);
    }
    auto it1=s1.begin();
    auto it2=s2.begin();
    int now=0;
    LL ans=0;

    it1=s1.begin();
    it2=s2.begin();
    d1=*it1;
    d2=*it2;
    if(d2.l<=now && d1.r>=now)
    {
        ret=0;
        return;
    }

    if(z==1)
    {
        if(d2.l<=now)return;
        ans+=1LL*(d2.l-now);
        now=d2.l;
        s2.erase(d2);
        d1.l=d2.l;
        d1.r=d2.r;
        d1.id=d2.id;
        s1.erase(d1);
    }
    else
    {
        if(d1.r>=now)return;
        ans+=1LL*(now-d1.r);
        now=d1.r;
        s1.erase(d1);
        d2.l=d1.l;
        d2.r=d1.r;
        d2.id=d1.id;
        s2.erase(d2);
    }

    while(!s1.empty())
    {
        it1=s1.begin();
        it2=s2.begin();
        d1=*it1;
        d2=*it2;
        if(d2.l<=now && d1.r>=now)break;
        if(now-d1.r>d2.l-now) // daame r e jabo
        {
            ans+=1LL*(now-d1.r);
            now=d1.r;
            s1.erase(d1);
            d2.l=d1.l;
            d2.r=d1.r;
            d2.id=d1.id;
            s2.erase(d2);
        }
        else
        {
            ans+=1LL*(d2.l-now);
            now=d2.l;
            s2.erase(d2);
            d1.l=d2.l;
            d1.r=d2.r;
            d1.id=d2.id;
            s1.erase(d1);
        }
    }
    ans+=1LL*ab(now);
    ret=max(ret,ans);
}


int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d %d",&ll[i],&rr[i]);

    }

    solve(1);
    solve(-1);


    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 14720
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n; cin >> n;
    bool ok = 0;
    REP(i,n/4+1)REP(j,n/7+1) if(4*i+7*j==n) ok = 1;
    Yn(ok);

    return 0;
}

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

int main(){//main_program
  int64_t N,D,count;
  int64_t H;
  count = 0;
  
  cin >> N >>D;
  H = D*D;
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  
  for(int i = 0;i < N ;i++){
    int64_t F; 
    cin >> X.at(i) >> Y.at(i);
    F = (X.at(i)*X.at(i)) + (Y.at(i)*Y.at(i));
    //cout << X.at(i)*X.at(i) <<":" << Y.at(i)*Y.at(i) <<endl;
    //cout << F <<endl;
    if(H >= F){
      count++;
    }
  }
  
  cout << count <<endl;
}

Measured memory_bytes: 6344
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a<b&&b<c)
System.out.println("Yes");
else 
System.out.println("No");
}}


Measured memory_bytes: 26172
fun main() {
    val(n,k) = readLine()!!.split(" ").map(String::toInt)
    var ls:MutableList<List<Int>> = mutableListOf()
    for (gomi in 1..k) {
        readLine()
        ls.add(readLine()!!.split(" ").map(String::toInt))
    }
    var ss:Set<Int> = ls.flatten().toSet()
    println(n-ss.size)
}

Measured memory_bytes: 39308
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int tc=1;
  int W;
  while(cin>>W, W){
    int n;
    cin>>n;
    vector<int> v(n), w(n);
    rep(i,n) scanf("%d,%d", &v[i], &w[i]);

    vector<int> dp(W+1, -INF);
    dp[0]=0;
    rep(i,n){
      for(int j=W; j-w[i]>=0; j--) if(j-w[i]>=0){
        dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
      }
    }
    int mw=0, mv=0;
    rep(i,W+1) if(dp[i]>mv){mv=dp[i], mw=i;}
    printf("Case %d:\n", tc); tc++;
    printf("%d\n%d\n", mv, mw);
  }

  return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
LL psum[MAXN];
int bit[MAXN];

int query(int x) {
    int sum = 0;
    while (x > 0) {
          sum += bit[x];
          x -= (x & (-x));
    }
    return sum;
}

void add(int x, int val, int N) {
     while (x <= N) {
           bit[x] += val;
           x += (x & (-x));
     }
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
        psum[i] = psum[i - 1] + tmp - K;
    }
    vector<LL> cand;
    for (int i = 0; i <= N; i++) cand.push_back(psum[i]);
    sort(cand.begin(), cand.end());
    cand.erase(unique(cand.begin(), cand.end()), cand.end());
    LL ans = 0;
    for (int i = 0; i <= N; i++) {
        int rk = upper_bound(cand.begin(), cand.end(), psum[i]) - cand.begin();
        ans += query(rk);
        add(rk, 1, N + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<"1"<<endl;
  }
  else if(a==b||b==c||c==a){
    cout<<"2"<<endl;
  }
  else{
    cout<<"3"<<endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b;
    cin>>a;
    if(a%7==6)cout<<"wed"<<endl;
    if(a%7==5)cout<<"tue"<<endl;
    if(a%7==4)cout<<"mon"<<endl;
    if(a%7==3)cout<<"sun"<<endl;
    if(a%7==2)cout<<"sat"<<endl;
    if(a%7==1)cout<<"fri"<<endl;
    if(a%7==0)cout<<"thu"<<endl;
    return 0;
}


Measured memory_bytes: 3112
x = int(input())
k = []
for i in range(1, x + 1):
    y = i
    if i % 3 == 0:
        k.append(i)
    else:
        while True:
            if y % 10 == 3:
                k.append(i)
                break
            else:
                if y <= 10:
                    break
                else:
                    y //= 10

print(' '+ ' '.join([str(x) for x in k]))


Measured memory_bytes: 6116
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var abc = IO.RSInt;
            var k = IO.RInt;

            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            int cnt = 0;
            while (a >= b)
            {
                b *= 2;
                cnt++;
            }
            while (b >= c)
            {
                c *= 2;
                cnt++;
            }
            IO.WriteLineYes_or_No(cnt <= k);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19096
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

    sort(a, a + nn);
    map<int, int> have, rem;
    have[a[nn - 1]]++;
    for (int i = 0; i < nn - 1; i++) rem[a[i]]++;
    while (n--) {
        vector<int> just;
        for (auto e : have) {
            for (int i = 0; i < e.second; i++) {
                auto it = rem.lower_bound(e.first);
                if (it != rem.begin()) {
                    it--;
                    it->second--;
                    just.pb(it->first);
                    if (it->second == 0) rem.erase(it);
                }

                else {
                    cout << "No";
                    return 0;
                }
            }
        }

        for (int e : just) have[e]++;
    }

    cout << "Yes";

}


Measured memory_bytes: 14080
package main

import (
	"bufio"
	"fmt"
	"os"
)

var dp1, dp2 [3010][3010]int

func main() {
	N, T := ReadInt(), ReadInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], B[i] = ReadInt(), ReadInt()
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= T-1; j++ {
			dp1[i][j] = Max(dp1[i-1][j], dp1[i][j-1])
			if j-A[i-1] >= 0 {
				dp1[i][j] = Max(dp1[i][j], B[i-1]+dp1[i-1][j-A[i-1]])
			}
		}
	}

	for i := N; i > 0; i-- {
		for j := 1; j <= T-1; j++ {
			dp2[i][j] = Max(dp2[i+1][j], dp2[i][j-1])
			if j-A[i-1] >= 0 {
				dp2[i][j] = Max(dp2[i][j], B[i-1]+dp2[i+1][j-A[i-1]])
			}
		}
	}

	ans := -1
	for i := 1; i <= N; i++ {
		for j := 0; j < T; j++ {
			ans = Max(ans, dp1[i-1][j]+dp2[i+1][T-1-j]+B[i-1])
		}
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 143116
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> b(n),a(n);
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    for(int j=b.size()-1; j>=0; j--) {
      if(b[j]==j+1) {
        a[i]=b[j];
        b.erase(b.begin()+j);
        break;
      }
    }
  }
  if(a[n-1]!=1) {
    cout << -1 << endl;
  }
  else {
    for(int i=n-1; i>=0; i--) {
      cout << a[i] << endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M;
bool broken[100005];
int ANS[100005];
signed main(){
    scanf("%lld %lld",&N,&M);
    int ans=0;
    rep(i,M){
        int a;
        scanf("%lld",&a);a--;
        broken[a]=true;
    }
    rep(i,N){
        if(broken[i]){ANS[i]=0;continue;}
        if(i==0)ANS[i]=1;
        else if(i==1)ANS[i]=ANS[0]+1;
        else ANS[i]=ANS[i-1]+ANS[i-2];
        ANS[i]%=mod;
        //printf("%lld!-",ANS[i]);
    }
    printf("%lld",ANS[N-1]%mod);
    return 0;
}


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

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

  int l,r,d;
  cin >> l >> r >> d;

  int answer = r / d;
  int sub = (l - 1) / d;

  cout << answer - sub << "\n";
}


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

int main() {
  string n;
  cin >> n;
  cout << (n[n.length()-1] == '3'
               ? "bon"
               : (n[n.length()-1] == '0' || n[n.length()-1] == '1' ||
                  n[n.length()-1] == '6' || n[n.length()-1] == '8')
                     ? "pon"
                     : "hon")
       << endl;

  return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,h ,i ,j ;	HashMap<Integer , Long> hm =new HashMap<>() ;	long ct =0 ;
 		for (i =1 ; i<=n ; ++i) {
 			h =fr.nextInt() ;	j =i-h ;
 			if (j>0 && hm.containsKey(j))	ct += hm.get(j) ;	j =h+i ;
 			if (!hm.containsKey(j))	hm.put(j , 0l) ;	hm.put(j , hm.get(j)+1) ;
 		}
		op.println(ct) ;	op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){
        swap(r[a], r[b]);
        swap(r[b], r[c]);
        swap(r[c], r[d]);
    }
    void spinW(){roll(0, 2, 5, 3);}
    void spinN(){roll(0, 1, 5, 4);}
};

int main() {
    bool ans = 0;
    int n;
    cin >> n;
    vector<Dice> D(n);
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < 6; j++) cin >> D[i].r[j];
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1 ; j < n ; j++) {
            char SWS[8]={"NNNWNNN"};
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                if (SWS[k] == 'W') D[j].spinW();
                else D[j].spinN();
            }
            for (int k = 0; k < 4; k++){
                if (D[i].r[0] == D[j].r[0]){
                    long cr = 1;
                    for (long l = 0; l < 6; l++){
                        if (D[i].r[l] != D[j].r[l]) cr = 0;
                    }
                    if (cr == 1) ans = 1;
                }
                D[j].spinW();
            }
        }
    }

    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;


int main(){
    CIN(N);
    vi A(N+1);
    rep(i,N){
        A[i+1]=IN_int();
    }
    flag=false;
    int cls=1;
    int cnt=0;
    rep(i,N){
        cnt++;
        cls=A[cls];
        if(cls==2) flag=true;
        if(flag) break;        
    }
    printf("%d\n",flag?cnt:-1);

    return 0;
}

Measured memory_bytes: 640
using System;

using System.Linq;
class A{static void Main()
{
///////////////////////////
ulong []a=Console.ReadLine().Split().Select(ulong.Parse).ToArray();
Array.Sort(a);
if(a[0]%2==0||a[1]%2==0||a[2]%2==0)
{Console.WriteLine("0");}else{Console.WriteLine(a[0]*a[1]);}
///////////////////////////
}}

Measured memory_bytes: 13396
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		while (sc2.hasNext()) {
			int v = sc2.nextInt();
			int d = sc2.nextInt();
			if (v == 1) {
				System.out.println(1);
				continue;
			}
			long[] f = new long[v];
			f[0] = 2;
			f[1] = 3;
			for (int i = 2; i < v; i++) {
				f[i] = (f[i - 1] + f[i - 2]) % 1001;
			}
			Arrays.sort(f);
			int cnt = 1;
			for (int i = 1; i < v; i++) {
				if (Math.abs(f[i] - f[i - 1]) >= d) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 22352
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;

ll fs[2020];

ll qp(ll b,ll e)
{
    if(!e)
        return 1;
    ll x=qp(b,e/2);
    x=(x*x)%2019;
    if(e&1)
        x=(x*b)%2019;
    return x;
}

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

    string s;
    cin >>  s;
    ll res=0;
    fs[0]++;
    ll ac=0;
    for(int i=0;i<s.size();i++)
    {
        ac=(ac+(s[s.size()-i-1]-'0')*qp(10,i))%2019;
        res+=fs[ac];
        fs[ac]++;
    }
    db(res)

    return 0;
}
/**
1817181712114
**/


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
long long w[200005] , h[200005];
long long n , C;
long long dp[200005];
struct line{
    int x , y;
    line(int x , int y){
        this->x = x , this->y = y;
    }
};
 
bool operator <(line a , line b){
    if(a.x == b.x) return a.y > b.y;
    else return a.x > b.x;
}
template <class type> 
class CHT{
    public : 
    bool cmp(type a , type b , type c){
        return ((double)((double) (c.y) - (a.y)) * ((double) (a.x) - (b.x))   <= ((double) ((double) (a.x) - (c.x)) * ((double) (b.y) - (a.y)) ) )  ; 
    }
    int sizex(){
        return cht.size();
    }
    void addLINE(type a){
            while(cht.size() >= 2 && cmp(cht[cht.size() - 2] , cht[cht.size() - 1] , a)){
                cht.pop_back();
            }
        cht.push_back(a);
    }
    int eval(type b , int a){
        int w = (b.x) * a + (b.y);
        return w;
    }
    void mergev(vector<type> nhcht){
        vector<type> newcht;
        for(int i = 0 ; i < nhcht.size() + cht.size() ; i++) newcht.pb(line(0,0));
        std::merge(nhcht.begin() , nhcht.end() , cht.begin() , cht.end() , newcht.begin() );
        cht.clear();
        for(int i = 0 ; i < newcht.size() ; i++) addLINE(newcht[i]);
    }
    int querymin(int x){
        if(cht.size() == 0) return (int) 1e18;
        int l = 0 , r = cht.size() - 1;
        r--;
        int ansj = -1;
        while(l<=r){
            int mid = (l+r)/2;
            if(eval(cht[mid] , x) >= eval(cht[mid + 1] , x)){
                l = mid + 1;
                ansj = mid;
            }
            else r = mid - 1;
        }
        int bestvalue = eval(cht.front() , x);
        if(ansj != -1) bestvalue = min(bestvalue , eval(cht[ansj] , x));
        ansj ++;
        if(ansj < cht.size()) bestvalue = min(bestvalue , eval(cht[ansj] , x));
 
        return bestvalue;
    }
    vector<type> vectorT(){
        return cht;
    }
    void clearv(){
        cht.clear();
    }
    vector<type> cht;
}; 
 
CHT <line> chts[33];
 
void addline(line a){
    vector<line> v;
    v.push_back(a);
    chts[0].mergev(v);
    for(int i = 0 ; i < 32 ; i++){
        int z = (1LL<<i);
        if(chts[i].sizex() > z){
            chts[i+1].mergev(chts[i].vectorT());
            chts[i].clearv();
        }
    }
    return ;
}
 
 
long long query(int x){
 
    long long bestvalue = (long long) 1e18;
    for(int i = 0 ; i < 32 ; i++){
        bestvalue  = min(bestvalue , chts[i].querymin(x));
    }
    return bestvalue;
}
 
 
int32_t main(){
    scanf("%lld%lld" , &n , &C);
    dp[0] = 0;
    for(int i = 1 ; i <=n ;i ++){
        scanf("%lld" , &h[i]);
    }
    dp[1] = 0;
    addline(line(-2*h[1] , h[1]*h[1]));
    for(int i = 2 ; i <= n ;i ++){
        dp[i] = query(h[i]) + h[i]*h[i]  + C;
        addline(line(-2*h[i] , h[i]*h[i]  + dp[i]));
    }
    printf("%lld\n" , dp[n]);
}

Measured memory_bytes: 16940
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

int main() {
    while (true) {
        // input
        int n, l; scanf("%d%d", &n, &l);
        if (n == 0 and l == 0) break;
        vector<char> d(n);
        vector<int> p(n);
        repeat (i, n) {
            scanf(" %c%d", &d[i], &p[i]);
        }
        // solve
        vector<int> t(n);
        repeat (i, n) {
            t[i] = (d[i] == 'L' ? p[i] : l - p[i]);
        }
        auto cmp = [&](int i, int j) {
            return make_pair(t[i], d[i] == 'L') < make_pair(t[j], d[j] == 'L');
        };
        vector<int> xs(n);
        iota(whole(xs), 0);
        bool last_parity = p[*max_element(whole(xs), cmp)] % 2;
        xs.erase(remove_if(whole(xs), [&](int i) {
            return p[i] % 2 != last_parity;
        }), xs.end());
        sort(whole(xs), cmp);
        int last_j = 0;
        repeat (i, xs.size() - 1) {
            if (d[xs[i]] == 'L') {
                ++ last_j;
            }
        }
        sort(whole(xs));
        last_j = xs[last_j];
        // output
        int last_t = *max_element(whole(t));
        printf("%d %d\n", last_t, last_j + 1);
    }
    return 0;
}

Measured memory_bytes: 2720
import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<Integer>[] graph = new ArrayList[n];
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            graph[i] = new ArrayList<Integer>();
            arr[i] = -1;
        }

        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            graph[start - 1].add(end - 1);
        }

        int length = 0;
        for (int i = 0; i < n; i++) {
           int curLength = calculate(i, graph, arr);
           if (curLength > length) {
               length = curLength;
            }
        }
        System.out.println(length);
    }

    static int calculate(int vertex,  ArrayList<Integer>[] graph, int[] arr) {
        if (arr[vertex] != -1) {
            return arr[vertex];
        }
        int length = 0;
        for(int i = 0; i < graph[vertex].size(); i++) {
            int neghbourLength = calculate(graph[vertex].get(i), graph, arr);
            if (neghbourLength + 1 > length) {
                length = neghbourLength + 1;
            }
        }
        arr[vertex] = length;
        return length;
    }
}

Measured memory_bytes: 104908
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
using namespace std;

int main() {
	int a, b;
	cin >> a;
	cin >> b;
	if (a+b>=a-b&&a+b>=a*b) {
		cout << a + b;
	}
	else if (a-b>=a+b&&a-b>=a*b) {
		cout << a - b;
	}
	else {
		cout << a*b;
	}
}

Measured memory_bytes: 256
// Gracias, Rodolfo
// Gracias, MarcosK
// Gracias, Graphter
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (Long i = a; i < b; i++)
#define roF(i,a,b) for (Long i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;
typedef vector<Long> Vector;
typedef vector<Pair> PairVector;

const int N = 1e6;
const Long INF = 1e18;
const Double EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

void solve() {
	Long n;
	cin >> n;
	Long ans = 0;
	Long a[n + 2];
	For(i, 0, n + 1) cin >> a[i];
	a[n + 1] = 0;
	Long b[n + 2];
	For(i, 0, n) cin >> b[i];
	b[n] = b[n + 1] = 0;
	For(i, 0, n + 1) {
		Long mini = min(b[i], a[i]);
		ans += mini;
		b[i] -= mini;
		mini = min(b[i], a[i + 1]);
		a[i + 1] -= mini;
		ans += mini;
	}
	cout << ans << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 5140
#!/usr/bin/env python3
#AGC23 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [0] + LI()
cnt = list(accumulate(a))
cnt = list(Counter(cnt).items())
ans = 0
for i,j in cnt:
    if j < 2:
        continue
    ans += j*(j-1)//2
print(ans)


Measured memory_bytes: 108280
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 1e5 + 5;
const int md2 = 998244353;
const int md = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

void solve() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    range(i, n) cin >> a[i];
    range(i, n) cin >> b[i];
    set<pair<int, pair<int, int>>> s1, s2;
    vector<int> cntcol(n+1);
    for(int i =0, j = 0; i < n; i = j) {
        while(a[j] == a[i]) j++;
        s1.insert({i-j, {i, j}});
        cntcol[a[i]] = i - j;
    }
    vector<pair<int, int>> v(n+1);
    for(int i =0, j = 0; i < n; i = j) {
        while(b[j] == b[i]) j++;
        v[b[i]] = {i, j};
        s2.insert({cntcol[b[i]] + i - j, {i, j}});
    }
    vector<int> ans(n);
    range(i, n) {
        auto p1 = *s1.begin();
        s1.erase(s1.begin());
        auto p2 = *s2.begin();
        s2.erase(s2.begin());
        if (b[p2.second.first] == a[p1.second.first]) {
            if (s2.empty()) {
                cout << "No\n";
                return;
            }
            auto p3 = *s2.begin();
            s2.erase(s2.begin());
            s2.insert(p2);
            p2 = p3;
        }
        ans[p1.second.first] = b[p2.second.first];
        int col = a[p1.second.first];
        if (v[col].second - v[col].first) {
            s2.erase({p1.first + v[col].first - v[col].second, v[col]});
            s2.insert({p1.first + v[col].first - v[col].second + 1, v[col]});
        }
        v[b[p2.second.first]].first++;
        p2.second.first++;
        p1.first++;
        p1.second.first++;
        p2.first++;
        if (p1.first) s1.insert(p1);
        if (p2.second.second - p2.second.first) s2.insert(p2);
    }
    cout << "Yes\n";
    range(i, n) cout << ans[i] << " ";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

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

int main(){
  
  string a,b;
  cin>>a>>b;
  
  if(b.size()==1){
    cout<<"No";
    return 0;
  }
  
  string s = b.substr(0,b.size()-1);
  
  if(a.compare(s)==0){
    cout<<"Yes";
  }else{
    cout<<"No";}
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) : par(n), sz(n, 1) {
    for (int i = 0; i < n; i++)
      par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  UnionFind uf(n);
  vector<ll> res(m);
  res[m-1] = (ll)n*(n-1)/2;
  for(int i = m-1; i > 0; i--) {
    ll sa = uf.size(a[i]), sb = uf.size(b[i]);
    if(uf.unite(a[i], b[i]))
      res[i-1] = res[i]-sa*sb;
    else
      res[i-1] = res[i];
  }
  rep(i, m)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int K,S;
    cin >> K >> S;
    int cnt = 0;
    for(int i = 0;i <= K;i++){
        if(i < S - K * 2)continue;
        for(int j = 0;j <= K;j++){
            if(S - i - j <= K && S - i - j >= 0)cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <deque>
#include <functional>
#include <iostream>
#include <string>

void PushBack(std::deque<char> &deq, char ch)
{
    deq.push_back(ch);
}

void PushFront(std::deque<char> &deq, char ch)
{
    deq.push_front(ch);
}

std::string BuildString(const std::deque<char> &deq, bool reversed)
{
    if (reversed) {
        return std::string(deq.rbegin(), deq.rend());
    }
    return std::string(deq.begin(), deq.end());
}

int main()
{
    std::string str;
    std::getline(std::cin, str);

    int queries;
    std::cin >> queries;

    std::deque<char> deq(str.begin(), str.end());
    auto op1 = PushFront;
    auto op2 = PushBack;
    auto reversed = false;

    for (int i = 0; i < queries; i += 1) {
        int type;
        std::cin >> type;

        if (type == 1) {
            std::swap(op1, op2);
            reversed = !reversed;
        } else {
            char ch;
            std::cin >> type >> ch;
            (type == 1 ? op1 : op2)(deq, ch);
        }
    }

    std::cout << BuildString(deq, reversed) << "\n";
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int main(){
	
	long long int m=999999999999,x=0,n,a[200005];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]<<" ";
	for(int i=0;i<n;i++){
		
		if(abs(a[n-1]-2*a[i])<m){
			m=abs(a[n-1]-2*a[i]);
			x=a[i];
		}
		
	}
	cout<<x;
}

Measured memory_bytes: 1024
p,q,r = map(int,input().split())

if p+q <= p+r and p+q <= q+r:
    print(p+q)

elif q+r <= p+q and q+r <= p+r:
    print(q+r)

elif p+r <= p+q and p+r <= q+r:
    print(p+r)

Measured memory_bytes: 3060
str = input()
n = [0 for i in range(26)]

for j in range(len(str)):
    for i in range(26):
        if ord(str[j]) == ord('a')+i: n[i] += 1

check_flag = 0
for i in range(26):
    if check_flag==0 and n[i] == 0:
        check_flag = 1
        print(chr(97+i))
        break

if check_flag == 0: print('None')




Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char ch[105];
int main()
{
	scanf("%s",ch);
	ch[5]=' ';
	ch[13]=' ';
	printf("%s\n",ch);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        float T = Integer.parseInt(sc.next());
        float X = Integer.parseInt(sc.next());
        out.println(T/X);
        out.flush();
    }
}


Measured memory_bytes: 21844
n,m=map(int,input().split())
itv=[]
for i in range(m):
  a,b=map(int,input().split())
  start=min(a,b)
  end=max(a,b)
  itv.append([end,start])
t,ans=0,0
itv=sorted(itv)
for e,s in itv:
  if t<=s:
    t=e
    ans+=1
print(ans)

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

int main(){
	ll A,B;
	cin >> A >> B;
	if((A+B)%2 == 0){
		cout << (A+B)/2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import collections
from itertools import product

H, W, N = map(int,input().split())
PaintList = []
pat = list(product((-2,-1,0),repeat=2))
for i in range(N):
  x,y = map(int, input().split())
  for p in pat:
    xw = x + p[0]
    yw = y + p[1]
    #print(xw,yw)
    if 1 <= xw <= H-2 and 1 <= yw <= W-2:
      PaintList.append((xw,yw))

c = collections.Counter(PaintList)
#print(c)
ans = [0] * 10
for k,v in c.items():
  if k[0] <= H-2 and k[1] <= W-2:
    ans[v] += 1
  
ans[0] = (H-2)*(W-2) - sum(ans[1:10])
 
for i in range(10):
  print(ans[i])

Measured memory_bytes: 192064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

int main(){
    string L;
    cin>>L;
    long long dp[100001][2];
    dp[0][0]=2;
    dp[0][1]=1;
    rep(i,1,L.size()){
        if(L[i]=='1'){
            dp[i][0]=dp[i-1][0]*2;
            dp[i][1]=dp[i-1][1]*3+dp[i-1][0];
            dp[i][0]%=MOD;dp[i][1]%=MOD;
        }
        else{
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][1]*3;
            dp[i][0]%=MOD;dp[i][1]%=MOD;
        }
    }
    cout<<(dp[L.size()-1][0]+dp[L.size()-1][1])%MOD;

    return 0;
}

Measured memory_bytes: 2048
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int a = input.nextInt();
    int b = input.nextInt();
    int c = input.nextInt();

    int remain = a - b;

    int result = c - remain > 0 ? c - remain : 0;


    System.out.println(result);

  }



}




Measured memory_bytes: 24788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>cnt(n+5);
    cnt[0]=3;
    ll ans=1;
    rep(i,n){
        ans*=cnt[a[i]];
        cnt[a[i]]--;
        cnt[a[i]+1]++;
        ans%=mod;
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1792
x = gets.to_i
a = [100, 101, 102, 103, 104, 105]
dp = Array.new(x + 1, 0)
dp[0] = 1
0.upto(x) do |i|
  a.each do |y|
    if i + y <= x && dp[i] > 0
      dp[i + y] += 1
    end
  end
end
puts dp[-1] == 0 ? 0 : 1

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    LL ans = 0;
    if(p == 2) {
        for(int i = 0; i < n; ++i) if((s[i]-'0') % 2 == 0) ans += i+1;
    } else if(p == 5) {
        for(int i = 0; i < n; ++i) if((s[i]-'0') % 5 == 0) ans += i+1;
    } else {
        map<int, int> mp;
        mp[0]++;
        int now = 0, idx = 1;
        for(int i = n-1; i >= 0; --i) {
            now = (now + (s[i]-'0')*idx) % p;
            ans += mp[now]++;
            idx = idx*10%p;
        }
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 916