akhauriyash/Code-Regression huggingface dataset:
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl

const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;






int main(){
    fastio();
    
    char a,b; cin>>a>>b;
    int val=a-'0';
    int val1=b-'0';
    string p,q;
    for(int i=0;i<val;i++){
        p+=b;
    }
    for(int i=0;i<val1;i++){
        q+=a;
    } 
    if(p>q){
        cout<<q<<endl;
    }else{
        cout<<p<<endl;
    }

    return 0;
}

 

Measured memory_bytes: 3128
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
#include <cstdio>
using namespace std;
const int MAXN = 100000 + 5;
// log2(MAXN)
const int MAXDEPTH = 17 + 3;

int N, Q, L;
int X[MAXN];
// The farthest hotel to get on the 2^(MADEPTH) day
int farthest[MAXN][MAXDEPTH+1];

int main()
{
    int u, v;
    //cin >> N ;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        //cin >> X[i];
        scanf("%d", &X[i]);
    //cin >> L;
    scanf("%d", &L);

    int cur = 2;
    for(int i = 1; i <= N; i++)
    {
        cur --;
        while(cur <= N && X[cur] - X[i] <= L)
        {
            //cerr << "Checking : " << i << " " << cur << endl ;
            farthest[i][0] = cur;
            cur++;
        }
    }


    for(int k = 1; k < MAXDEPTH; k++)
        for(int i = 1; i < N; i++)
            farthest[i][k] = farthest[farthest[i][k-1]][k-1];
    /*
    for(int i = 1; i <= N; i++)
    {
        copy(&farthest[i][0], &farthest[i][MAXDEPTH], ostream_iterator<int>(cerr, " "));
        cerr << endl ;
    }
    */

    //cin >> Q ;
    scanf("%d", &Q);
    while(Q--)
    {
        int ans = 0;
        //cin >> u >> v ;
        scanf("%d%d", &u, &v);
        if(v < u)
            swap(u, v);
        for(int i = MAXDEPTH-1; i >= 0; i--)
        {
            if(farthest[u][i] != 0 && farthest[u][i] < v)
            {
                u = farthest[u][i];
                ans += (1 << i);
            }
        }
        //cout << ans+1 << endl ;
        printf("%d\n", ans+1);
    }


}


Measured memory_bytes: 9472
import Foundation
// Decimal型の有効桁数は38桁
let line = readLine()!.components(separatedBy: " ").map { Decimal(string: $0)! }

for i in 0..<5 {
    if line[i] == 0 {
        print(i + 1)
        exit(EXIT_SUCCESS)
    }
}


Measured memory_bytes: 17868
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
const int MOD = 1e9 + 7;
const int N = 45;
int n, x, y, z;
int dp[N][1 << 17][2];
void add(int &x, int y)	{
	x = (x + y > MOD) ? x + y - MOD : x + y;
}
signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> x >> y >> z;
	int needmask = ( (1 << (z - 1)) | (1 << (z + y - 1)) | (1 << (x + y + z - 1)) );
	int rem = (1 << 17) - 1; 	
	dp[0][0][0] = 1;
	for(int i = 0; i <= n; ++i)		for(int j = 0; j < (1 << 17); ++j) {
		if(dp[i][j][0])		{
			for(int nxt = 1; nxt <= 10; ++nxt)	{
				int nexmask = (j << nxt) + (1 << (nxt - 1));
				nexmask &= rem;
				if((nexmask & needmask) == needmask) add(dp[i + 1][nexmask][1], dp[i][j][0]);
				else add(dp[i + 1][nexmask][0], dp[i][j][0]);
			}
		} 
		if(dp[i][j][1])		{
			for(int nxt = 1; nxt <= 10; ++nxt)	{
				int nexmask = (j << nxt) + (1 << (nxt - 1));
				nexmask &= rem;
				add(dp[i + 1][nexmask][1], dp[i][j][1]); 
			}
		}
	}
	int sum = 0ll;
	for(int i = 0; i < (1 << 17); ++i) sum = (sum + dp[n][i][1]) % MOD;
	cout << sum;
}

Measured memory_bytes: 86272
#include <iostream>
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr if(true) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }

void solve(long long N, vector<long long> a){
	sort(ALL(a));
	reverse(ALL(a));
	ll ans = 0;
	ll c = 0;
	for(int i =1 ;i<N*3;i+=2){ans += a[i];c++;if(c == N)break;}
	cout << ans << endl;
}



int main(){
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	vector<long long> a(3*N-1+1);
	for(int i = 0 ; i <= 3*N-1 ; i++){
		cin >> a[i];
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(void){
    int m, f, r;
    while(cin >> m >> f >> r){
        if(m == -1 && f == -1 && r == -1)   break;
        
        if(m == -1 || f == -1)  cout << "F" << endl;
        else if(m + f >= 80)    cout << "A" << endl;
        else if(m + f >= 65 && m + f < 80) cout << "B" << endl;
        else if(m + f >= 50 && m + f < 65) cout << "C" << endl;
        else if(m + f >= 30 && m + f < 50){
            if(r >= 50) cout << "C" << endl;
            else    cout << "D" << endl;
        }
        else if(m + f <= 30)    cout << "F" << endl;
        
    }
    
    return 0;
    
}



Measured memory_bytes: 3068
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int sum=0;
int a[N],b[N];
int32_t main()
{
        int n;
        cin>>n;
        for(int i=1;i<=n+1;i++)
        {
            cin>>a[i];
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(b[i]<=a[i])
            {
                sum+=b[i];
                continue;
            }
            sum+=a[i];
            int z=b[i]-a[i];
            if(z>=a[i+1])
            {
                sum+=a[i+1];
                a[i+1]=0;
            }
            else
            {
                sum+=z;
                a[i+1]-=z;
            }

        }
        cout<<sum<<endl;
}


Measured memory_bytes: 1792
a=[]
b=[]
while  n=gets
  a = n.split(" ").map(&:to_i)
  m=gets
  b = m.split(" ").map(&:to_i)
  j=0
  k=0
  4.times{|i|
    j+=1 if a[i]==b[i]
    k+=1 if a.include?(b[i])
  }
  puts print("#{j} #{k-j}")
end


Measured memory_bytes: 6840
N,K = map(int,input().split())

# a = b * x + K
# bを固定してaを1~Nまで動かしたとき、aをbで割った余りは1,2...b-1,0のb通り。
# その中にK以上の余りはb-K通り。
# 余りを順に並べると、1,2...b-1,0,1,2...b-1,0,1,2...N%b となる。
# 1,2...N%b の中にK以上の数はN%b-K+1通り。
# 1,2...b-1,0はN//b回繰り返される。
# Kが0のときは、a,bはどんな組み合わせでもいいからN**2通り。

if K == 0:
  print(N**2)
  exit()
ans = 0
for b in range(1,N+1):
  if b-K > 0:
    ans += (b-K)*(N//b)
  if N%b-K+1 > 0:
    ans += N%b-K+1
print(ans)

Measured memory_bytes: 39024
#include<iostream>
#include<cstring>
#include<cstring>
#include<stdlib.h>
using namespace std;
#include<algorithm>
long long a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	
		cin>>a[i];
	sort(a+1,a+n+1);
	int k1=1,k2;
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
			{
				k1=(k1+1)%2;
			}
		else
			k2+=k1,k1=1;
	}
	if(k1%2)
		k2++;
	cout<<k2<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    double v,t,y;
    while(scanf("%lf",&v)!=EOF){
        int n=1;
        t=v/9.8;
        y=4.9*t*t;
        //printf("%lf\n",y);
        while(y>0){
            y-=5;
            n++;
        }
        printf("%d\n",n);
    }

    return 0;
}

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

int main(){
  char a;
  int b = 0;
  int c;
  string d;
  string e = "";
  while(cin >> a){
    e += a;
    d = a;
    c = stoi(d);
    b += c;

  }
  int f = stoi(e);
  if(f%b == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

void testCase(){
    int n, a;
    map<int, int> m;
    cin>>n;
    for(int i = 0; i < n-1; i++){
        cin>>a;
        m[a]++;
    }
    for(int i = 1; i <= n; i++){
        cout<<m[i]<<endl;
    }
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



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

int main(int argc, char const *argv[]) {
	int a[4];
	int b[4];
	for (int i = 0; i < 4; i++){
		cin >> a[i];
	}
	for (int i = 0; i < 4; i++){
		cin >> b[i];
	}
	int a_sum = 0;
	int b_sum = 0;

	for (int i = 0; i < 4; i++){
		a_sum = a_sum + a[i];
	}
	for (int i = 0; i < 4; i++){
		b_sum = b_sum + b[i];
	}
	if (a_sum < b_sum){
		cout << b_sum << endl;
	}
	else{
		cout << a_sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(
        X: int, Y: int, Z: int, K: int,
        A: "List[int]", B: "List[int]", C: "List[int]"):
    z = [0]

    def f(a: "List[int]"):
        nonlocal z
        a.sort(reverse=True)
        z = [zi + ai for zi, ai in product(z, a[:K])]
        z.sort(reverse=True)
        z = z[:K]

    f(A)
    f(B)
    f(C)
    for zi in z:
        print(zi)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 160040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long K, std::vector<long long> A)
{
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ll tmp = 0;
        for (int j = 0; j < N; j++)
        {
            if (A[i] > A[j])
            {
                if (i < j)
                {
                    ans += K * (K + 1) / 2;
                    ans %= MOD;
                }
                else
                {
                    ans += K * (K - 1) / 2;
                    ans %= MOD;
                }
            }
        }

    }


    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N - 1 - 0 + 1);
    for (int i = 0; i < N - 1 - 0 + 1; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<numeric>
using namespace std;

int main(void)
{
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    int counter = 0;
    while(1){
        if (B <= A) {
            B = B * 2;
            ++counter;
        }
        else{
            break;
        }
    }
    while(1){
        if (C <= B) {
            C = C * 2;
            ++counter;
        }
        else{
            break;
        }
    }
    if (counter <= K){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
const MOD: usize = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;
    let c = Combination::new(h+w,MOD);
    for i in 0..(h-a){
        // println!("{} {}",h+w-i-b,w-b);
        let res = c.comb(i+b-1, i) * c.comb(h+w-b-i-2, w-b-1);
        // println!("{} {}",c.comb(i+1+b-1, b-1) , c.comb(h-i+w-b-1, w-b));
        ans = (ans + res) % MOD;
    }

    println!("{}",ans);

}

pub struct Combination{
    fac : Vec<usize>,
    finv : Vec<usize>,
    m : usize,
}

impl Combination{
    pub fn new(n : usize, m : usize) -> Self{
        let mut inv = vec![1;n+1];
        let mut fac = vec![1;n+1];
        let mut finv = vec![1;n+1];

        for i in 2..(n+1){
            fac[i] = (fac[i-1] * i) % m;
            inv[i] = m - (inv[m%i] * (m/i) % m);
            finv[i] = (finv[i-1]*inv[i])%m;
        }

        Combination{
            fac,
            finv,
            m,
        }
    }

    pub fn comb(&self, n : usize, k: usize) -> usize{
        if n < k{
            return 0;
        }

        (self.fac[n] * (self.finv[k] * self.finv[n-k] % self.m)) % self.m
    }
}

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

int main() {
  long N,A,B;
  cin>>N>>A>>B;
  long ans =0;
  if(abs(B-A)%2==1){
  ans = min(N-A,B-1);

  long tmpans=N-B;
  long tmpb=N;
  long tmpa=A+tmpans;
  tmpans+=1;
  tmpa++;
  if(tmpa<=N){
    tmpans += (tmpb-tmpa)/2;
  }
  ans = min(tmpans,ans);

  tmpans=A-1;
  tmpa=1;
  tmpb=B-tmpans;
  tmpans+=1;
  tmpb--;
  if(tmpb>=1){
    tmpans += (tmpb-tmpa)/2;
  }
  ans = min(tmpans,ans);



  }
  else{
    ans = (B-A)/2;
    ans = min(ans,min(N-A,B-1));
  }
cout<<ans<<endl;
  }


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

vector<int> p;
int ans;

int find_root(int x) {
  if (p[x] != x) p[x] = find_root(p[x]);
  return p[x];
}

void unite(int x, int y) {
  int nx = find_root(x);
  int ny = find_root(y);
  if (nx == ny) return;
  else {
    if (nx > ny) p[nx] = ny;
    else p[ny] = nx;
    ans --;
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  ans = n;
  p = vector<int>(n);
  for (int i = 0; i < n; i ++) p[i] = i;
  for (int i = 0; i < m; i ++) {
    int x, y, z;
    cin >> x >> y >> z;
    x --, y --;
    unite(x, y);
  }
  cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        //int mod = (int) 1e9 + 7;
        //out.println("AMAN");
        int n = sc.nextInt();
        double[] a = new double[n];
        for(int i=0;i<n;i++) {
            a[i] = sc.nextDouble();
        }

        double dp[] = new double[n+1];
        dp[0] = 1;
        for(int i=0;i<n;i++) {
            for(int j=n;j>=0;j--) {
                dp[j] = (j==0? 0: dp[j-1]*a[i]) + dp[j]*(1-a[i]);
            }
        }
        double sum = 0;
        for(int i=0;i<=n;i++) {
            int tails = n-i;
            if(tails<i) {
                sum+=dp[i];
            }
        }
        out.println(sum);

        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public Double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public Float nextFloat() throws IOException {
            return Float.parseFloat(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi acos(-1)
#define lli long long int
using namespace std;

int main()
{
    FIO
    string s;
    cin >> s;

    int j,i,len,cc = 0;
    len = s.length();

    j = len - 1;
    for ( i = 0; i < (len/2); i++, j--)
    {
        if (s[i] != s[j])
        {
            cc ++;
        }
    }  
    cout << cc << endl;

    return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, s;
  unordered_map<ll, ll> buka_num;

  cin >> n;
  for (ll i = 1; i <= n; i++)
  {
    buka_num[i] = 0;
  }
  for (ll i = 0; i < n - 1; i++)
  {
    cin >> s;
    buka_num[s] = buka_num[s] + 1;
  }
  for (ll i = 1; i <= n; i++)
  {
    cout << buka_num[i] << endl;
  }

  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

signed main() {
  int n;
  cin >> n;
  vi a;
  REP(i, n) { a.PB(read()); }
  vi l(n), r(n);
  REP(i, n - 1) { l[i + 1] = gcd(l[i], a[i]); }
  for (int i = n - 1; i >= 1; i--) r[i - 1] = gcd(r[i], a[i]);
  int ans = 1;
  REP(i, n) { chmax(ans, gcd(l[i], r[i])); }
  print(ans);
}


Measured memory_bytes: 2676
#include <iostream> 
#include <cstring>
#include <algorithm> 
#include <cmath> 
#include <cstdio> 
typedef long long ll;
#define size 500050
using namespace std;
int a[size];
int main()
{
	int n,l;
	cin>>n>>l;
	int li = l;
	int minn = 0x3f3f3f;
	for(int i=0; i<n; i++) {
		minn = min(minn,abs(li));
		a[i] = li++;
	}	
	int sum = 0;

	for(int i=0; i<n; i++) {
		sum += a[i];
	}
	
	if(sum<0) {
		sum += minn;
	}
	if(sum>0) {
		sum -= minn;
	}
	cout<<sum<<endl;
	
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define FORMAP(x, mp) for(auto x=mp.begin();x!=mp.end();x++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define printd(x, f) cout << fixed << setprecision(f) << x << endl;

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI acos(-1.0)

int main()
{
  int N; cin >> N;
  ll ans = 0;
  map<ll, int> mp;
  REP(i, N) {
    ll i_; cin >> i_;
    if (mp[i_]) {
      ans--;
      mp[i_] = 0;
    } else {
      ans++;
      mp[i_] = 1;
    }
  }
  println(ans);
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string str;
    cin>>str;
    ll n=str.length();

    ll sum{0};
    for(ll i=0;i<n;i++){
    	sum=sum+(int(str[i])-48);
    }

    if(sum%9==0){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }

	return 0;
}



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

int main() {
	double a;
	while (cin >> a)
	{
		if (48.00 >= a) {
			cout << "light fly" << endl;
		}
		else if (48.00 < a&&a <= 51.00) {
			cout << "fly" << endl;
		}
		else if (51 < a&&a <= 54) {
			cout << "bantam" << endl;
		}
		else if (54 < a&&a <= 57) {
			cout << "feather" << endl;
		}
		else if (57 < a&&a <= 60) {
			cout << "light" << endl;
		}
		else if (60 < a&&a <= 64) {
			cout << "light welter" << endl;
		}
		else if (64 < a&&a <= 69) {
			cout << "welter" << endl;
		}
		else if (69 < a&&a <= 75){
			cout << "light middle" << endl;
		}
		else if (75 < a&&a <= 81) {
			cout << "middle" << endl;
		}
		else if (81 < a&&a <= 91) {
			cout << "light heavy" << endl;
		}
		else {
			cout << "heavy" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>

int32_t pow(int32_t a, bool p) { return (p ? a : 1); }

bool get_bit(uint32_t array, uint32_t pos) { return ((array >> pos) & 1); }

int main() {
  std::string S;
  std::cin >> S;

  uint32_t i = 0;
  while (i < 8) {
    int32_t val = S[0] - '0';
    for (size_t j = 1; j < 4; j++)
      val += pow(-1, get_bit(i, 3 - j)) * (S[j] - '0');
    if (val == 7) break;
    i++;
  }

  std::cout << S[0];
  for (size_t j = 1; j < 4; j++)
    std::cout << (get_bit(i, 3 - j) ? '-' : '+') << S[j];
  std::cout << "=7" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k;std::cin>>n>>k;
    std::vector<lint>a(n+1);
    for(lint i=1;i<=n;i++)std::cin>>a.at(i);
    std::partial_sum(a.begin(),a.end(),a.begin());
    lint max=0;
    for(lint i=0;i<=n-k;i++){
        lint x=a.at(i+k)-a.at(i);
        if(max<x)max=x;
    }
    std::cout<<real(max+k)/2<<'\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long i,s=0;
	string n;
	cin>>n;
	for(i=1;i<n.size();i++)
	{
		if(n[i]!=n[i-1]) s++; 
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

const long long P = 998244353;

using pii = pair<int, int>;

bool f(pii x, pii y, pii z) {
  int x1 = x.first - y.first;
  int y1 = x.second - y.second;
  int x2 = x.first - z.first;
  int y2 = x.second - z.second;
  return x1 * y2 - y1 * x2 == 0;
}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second;
  long long pw[222] = {0};
  pw[0] = 1;
  for (int i = 0; i < n; i++)
    pw[i + 1] = (pw[i] * 2) % P;
  long long ret = pw[n];
  ret = (ret - n - 1 + P) % P;
  bool used[222][222] = {0};
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      if (used[i][j])
        continue;
      vector<int> v;
      v.push_back(i);
      v.push_back(j);
      for (int k = j + 1; k < n; k++) {
        if (used[i][k] || !f(p[i], p[j], p[k]))
          continue;
        v.push_back(k);
      }
      ret = (ret - pw[v.size()] + v.size() + 1 + P) % P;
      for (int k = 0; k < v.size(); k++)
        for (int h = k + 1; h < v.size(); h++)
          used[v[k]][v[h]] = true;
    }
  cout << ret << endl;
  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
const ll INF = 1e17;
const int inf = 1e9;

int dist[100005][3];

int main()
{
  ll N;
  scanf("%lld",&N);
  ll M;
  scanf("%lld",&M);
  vector<vector<ll>> g(N);
  for(int i = 0 ; i < M ; i++){
    ll u,v;
    scanf("%lld",&u);
    scanf("%lld",&v);
    g[u-1].push_back(v-1);
  }
  ll S; scanf("%lld",&S); S--;
  ll T; scanf("%lld",&T); T--;

  for (int i=0; i<N; i++) {
    for (int j=0; j<3; j++) {
      dist[i][j]=inf;
    }
  }
  queue<ii> q;
  q.push(ii(S,0));
  dist[S][0] = 0;
  while(!q.empty()) {
    ll v = q.front().first;
    ll l = q.front().second;
    q.pop();
    for (ll u : g[v]) {
      ll nl = (l+1)%3;
      if (dist[u][nl] != inf) continue;
      dist[u][nl] = dist[v][l]+1;
      q.push(ii(u,nl));
    }
  }
  ll ans = dist[T][0];
  if (ans==inf) ans = -1;
  else ans/=3;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6912
H, W, D = map(int, input().split())

field = {}
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        field[A[j]] = (i,j)

Q = int(input())


cum = [0] * (H*W+1)
for i in range(D+1, H*W+1):
    cum[i] = cum[i-D] + abs(field[i][0] - field[i-D][0]) + abs(field[i][1] - field[i-D][1])

"""
for i in range(1,D+1):
    tmp = 0
    cum[i] = 0
    n = D
    while i+n <= H*W:
        cum[i+n] = cum[i+n-D] + abs(field[i+n][0] - field[i+n-D][0]) + abs(field[i+n][1] - field[i+n-D][1])
        #print("---", i+n, cum[i+n], field[i+n][0] , field[i+n-D][0], field[i+n][1] , field[i+n-D][1])
        n += D
"""
#print(cum)
for i in range(Q):
    L, R = map(int, input().split())
    print(cum[R] - cum[L])

#print(field)

Measured memory_bytes: 22560
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

int main() {
    cin >> n;
    vector<ll> Avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> Avec[i];

    ll now = 1000;
    ll kabu = 0;
    for(int i = 0; i < n-1; ++i) {
        if(Avec[i] <= Avec[i+1]) {
            kabu = (now/Avec[i]);
            // cout << kabu << endl;
            now -= Avec[i]*kabu;
            now += kabu*Avec[i+1];
        }
    }
    cout << now << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
struct Point{
	double x;
	double y;
};
void gohho(int n,Point a,Point b){
	if(n==0)
	return;
	Point s,t,u;
	double yh=M_PI*60.0/180.0;
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	t.x=(1.0*a.x+2.0*b.x)/3.0;
	t.y=(1.0*a.y+2.0*b.y)/3.0;
	u.x=(t.x-s.x)*cos(yh)-(t.y-s.y)*sin(yh)+s.x;
	u.y=(t.x-s.x)*sin(yh)+(t.y-s.y)*cos(yh)+s.y;
	gohho(n-1,a,s);
	std::cout<<s.x<<"  "<<s.y<<"\n";
	gohho(n-1,s,u);
	std::cout<<u.x<<"  "<<u.y<<"\n";
	gohho(n-1,u,t);
	std::cout<<t.x<<"  "<<t.y<<"\n";
gohho(n-1,t,b);
}
int main(){
	Point a,b;
	int n;
	std::cin>>n;
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	std::cout<<a.x<<"  "<<a.y<<"\n";
	gohho(n,a,b);
	std::cout<<b.x<<"  "<<b.y<<"\n";
return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

LL lpow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int main() {
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> num_list(k);
    for(LL i=0; i<k; i++){
        cin >> num_list[i];
    }

    LL ans;

    for(LL i=n; i<100000; i++){
        bool is_ok=true;
        LL kiyu=i;
        LL kbt;
        //cout << i << endl;
        while(kiyu>0){
            kbt=kiyu%10;
            for(LL j=0; j<k; j++){
                if(kbt==num_list[j]){
                    is_ok=false;
                    break;
                }
            }
            kiyu/=10;
            //cout << kiyu << endl;
        }
        if(is_ok==true){
            ans=i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector<bool>a(27,false);
  for(int i=0;i<s.size();i++){
    a.at(s.at(i)-'a') = true; //ASCIIコード
  }
  for(int i=0;i<27;i++){
    if(i==26){
      cout <<"None"<<endl;
    }
    else{
      if(a.at(i)==false){
        cout<<char('a'+i)<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 512
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


struct segt {

	struct node {
		ll t, mx, lazyby, lazyto;
		ll length, s, e;
		bool set;
		node* l;
		node* r;
	};

	node* rt;

	void build(int i, int j, node* v) {
		v->mx = v->t = v->lazyby = v->lazyto = 0;
		v->length = j - i + 1;
		v->s = i;
		v->e = j;
		if (i == j) return;
		v->l = new node();
		v->r = new node();
		build(i, (i + j) / 2, v->l);
		build((i + j) / 2 + 1, j, v->r);
	}

	segt() {}
	segt(int n) {
		rt = new node();
		build(0, n - 1, rt);
	}

	inline void prop(node* v) {
		if (v->l != nullptr) {
			if (v->set) {
				v->l->lazyby = v->r->lazyby = 0;
				v->l->lazyto = v->r->lazyto = v->lazyto;
				v->l->set = v->r->set = true;
			}
			v->l->lazyby += v->lazyby;
			v->r->lazyby += v->lazyby;
		}
		if (v->set) {
			v->t = v->lazyto * v->length;
			v->mx = v->lazyto;
		}
		v->t += v->lazyby * v->length;
		v->mx += v->lazyby;
		v->set = v->lazyby = v->lazyto = 0;
	}

	void update(int i, int j, ll val, bool by, node* v) {
		if (j < v->s || v->e < i) return;
		if (i <= v->s && v->e <= j) {
			prop(v);
			if (by) v->lazyby += val;
			else {
				v->lazyto = val;
				v->set = true;
			}
			prop(v);
			return;
		}
		prop(v);
		update(i, j, val, by, v->l);
		update(i, j, val, by, v->r);
		prop(v->l);
		prop(v->r);
		v->t = v->l->t + v->r->t;
		v->mx = max(v->l->mx, v->r->mx);

	}

	void updateby(int i, int j, int val) { update(i, j, val, true, rt); }
	void updateto(int i, int j, int val) { update(i, j, val, false, rt); }


	ll query(int i, int j, bool m, node* v) {
		if (j < v->s || v->e < i) {
			if (m) return -1000000000;
			return 0;
		}
		prop(v);
		if (i <= v->s && v->e <= j) {
			if (m) return v->mx;
			return v->t;
		}
		ll l = query(i, j, m, v->l);
		ll r = query(i, j, m, v->r);
		if (m) return max(l, r);
		return l + r;
	}

	ll querysum(int i, int j) { return query(i, j, false, rt); }
	ll querymax(int i, int j) { return query(i, j, true, rt); }
};

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

	int n, q;
	cin >> n >> q;
	segt a(n + 3);
	segt b(n + 3);
	
	a.updateto(2, n - 1, n);
	b.updateto(2, n - 1, n);
	
	ll ans = (n - 2);
	ans *= (n - 2);
	int minfr = n;
	int minsc = n;
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		if (x == 1) {
			int z = b.querysum(y, y);
			ans -= (z-2);
			minfr = min(minfr, y);
			if (minfr == y) {
				a.updateto(2, z, y);
			}
		}
		if (x == 2) {
			int z = a.querysum(y, y);
			ans -= (z - 2);
			minsc = min(minsc, y);
			if (minsc == y) {
				b.updateto(2, z, y);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 78664
from collections import defaultdict
import bisect
N=int(input())
A=list(map(int,input().strip().split()))

D=defaultdict(list)
for i in range(N):
    D[A[i]].append(i)

CNT={}

for k,v in D.items():
    #find ind of k in v  
    for n in v:
        if n-k>0:
            if n-k in CNT:
                CNT[n-k]+=1
            else:
                CNT[n-k]=1
Ans=0
for i in range(len(A)):
    shift=A[i]+i
    if shift in CNT:
        Ans+=CNT[shift]
print(Ans)

Measured memory_bytes: 57652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << max({2*a-1, 2*b-1, a+b}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

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

Measured memory_bytes: 256
n = gets.chomp.to_i
xx = 0
yy = 0
count = 0
tt = 0
n.times do |i|
    t, x , y = gets.chomp.split(" ").map(&:to_i)
    tt = t - tt
    sa  = (x - xx).abs + (y - yy).abs
    if tt < sa
        puts "No"
        exit
    end
    if tt  % 2 !=  sa % 2
        puts "No"
        exit
    end
    xx = x
    yy = y
    tt = t
end
    puts "Yes"

Measured memory_bytes: 1788
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str, call, p;
    int q, a, b;
    char[] stch, pch;
    int i, j, n, pn;
    char tmp;

    str = sc.next();
    q = sc.nextInt();
    n = str.length();
    stch = new char[n];
    for(i = 0;i < n;i++){
      stch[i] = str.charAt(i);
    }

    for(i = 0;i < q;i++){
      call = sc.next();
      if("replace".equals(call)){
        a = sc.nextInt();
        b = sc.nextInt();
        p = sc.next();

        pn = p.length();
        pch = new char[pn];
        for(j = 0;j < pn;j++){
          pch[j] = p.charAt(j);
        }

        for(j = a;j <= b;j++){
          stch[j] = pch[j - a];
        }
      }else if("reverse".equals(call)){
        a = sc.nextInt();
        b = sc.nextInt();
        for(j = 0;j < (b - a + 1) / 2;j++){
          tmp = stch[a + j];
          stch[a + j] = stch[b - j];
          stch[b - j] = tmp;
        }
      }else if("print".equals(call)){
        a = sc.nextInt();
        b = sc.nextInt();
        for(j = a;j <= b;j++){
          System.out.print(stch[j]);
        }
        System.out.println();
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

int main() {
  ll k, x;
  cin >> k >> x;

  if (500*k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

int cnt=0;

void isort(int* a,int n,int g){
	
	int v,j;
	
	for(int i=g;i<n;i++){
		v=a[i];
		j=i-g;
		while(j>=0&&a[j]>v){
			a[j+g]=a[j];
			j=j-g;
			cnt++;
		}
		a[j+g]=v;
	}
}

void shsort(int* a,int n){
	
	int cnt=0;
	int j=0;
	int h=1;
	int* g=(int*)malloc(sizeof(int)*n);
	
	while(h<=n){
		g[j]=h;
		j++;
		h=3*h+1;
	}
	
	int m=j;
	for(int i=m-1;i>=0;i--){
		isort(a,n,g[i]);
	}
	printf("%d\n",m);
	
	for(int i=m-1;i>=0;i--){
			printf("%d",g[i]);
			if(i!=0){
				printf(" ");
		}else{
			printf("\n");
		}
	}
	
}

int main(void){
	
	int n;
	
	scanf("%d",&n);
	
	int* a=(int*)malloc(sizeof(int)*n);
	
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	shsort(a,n);
	
	printf("%d\n",cnt);
	
	
	for(int i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	
}



Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

#define int long long
#define INF (long long)1000000007

int gcd(int a, int b)
{
    if (a == 0 && b == 0)
        return 1;
    if (a == 0)
        return b;
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}

void set_two_pow(vector<int> &v, int n)
{
    v[0] = 1;
    for (int i = 1; i < n + 1; i++)
    {
        v[i] = v[i - 1] * 2;
        v[i] %= INF;
    }
}

signed main()
{
    int N;
    cin >> N;

    vector<int> two_pow(N + 1, 0);
    set_two_pow(two_pow, N);

    map<pair<int, int>, pair<int, int>> m;
    m[pair<int, int>(0, 1)] = pair<int, int>(0, 0);
    int nO = 0;

    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;

        if (a == 0 && b == 0)
        {
            nO++;
            continue;
        }
        else if (a == 0)
        {
            m[pair<int, int>(0, 1)].first++;
            continue;
        }
        else if (b == 0)
        {
            m[pair<int, int>(0, 1)].second++;
            continue;
        }

        int d = gcd(abs(a), abs(b));
        a /= d;
        b /= d;

        if (a * b > 0)
        {
            pair<int, int> p;
            p.first = abs(a);
            p.second = abs(b);
            if (m.find(p) == m.end())
            {
                m[p] = pair<int, int>(1, 0);
            }
            else
            {
                m[p].first++;
            }
        }
        else
        {
            pair<int, int> p;
            p.first = abs(b);
            p.second = abs(a);
            if (m.find(p) == m.end())
            {
                m[p] = pair<int, int>(0, 1);
            }
            else
            {
                m[p].second++;
            }
        }
    }

    int ans = 1;

    for (const auto &[key, value] : m)
    {
        //cout << key.first << " " << key.second << " " << value.first << " " << value.second << endl;
        int tmp = two_pow[value.first] + two_pow[value.second] - 1;
        tmp %= INF;
        ans *= tmp;
        ans %= INF;
    }

    ans--;
    ans += nO;
    ans %= INF;
    ans = (ans + INF) % INF;

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

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

#define Rep0(i, n)  for (int i=0; i<n; i++)
#define Rep1(i, n)  for (int i=1; i<=n; i++)

struct  Item {
    int v=0;
    int w=0;
};

int main() {
    // Input
    int N, W;
    cin >>N >>W;
    vector<Item> V(N+1);
    Rep1(i, N)
        cin >>V.at(i).v >>V.at(i).w;
    // DP table: Item# x Available-Weight
    vector<vector<int>> DP(N+1, vector<int> (W+1, 0));
    Rep1(i, N) { // From Item# 1 to N
        int vv=V.at(i).v;
        int ww=V.at(i).w;
        Rep0(w1, W+1) { // For each available weight
            int w0=w1-ww;
            if (w0>=0) // If available to add this, try both and pick up the better one
                DP.at(i).at(w1)=max(DP.at(i-1).at(w1), DP.at(i-1).at(w0)+vv);
            else // No, no more space
                DP.at(i).at(w1)=DP.at(i-1).at(w1);
        }
    }
    // Search for the best
    int S=0;
    Rep1(i, W)
        S=max(S, DP.at(N).at(i));
    cout <<S <<endl;
    return 0;
}



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

int main() {
    ll X, K, D; cin >> X >> K >> D;
    X = abs(X);
    ll m = X / D;
    if (K <= m) {
        cout << X - D * K << endl;
    } else {
        X -= m * D;
        K -= m;
        if (K % 2 == 0) {
            cout << X << endl;
        } else {
            cout << min({abs(X + D), abs(X - D)}) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;

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

    unsigned long long result = 0;
    for(int i = 1; i <= N - 1; ++i)
    {
        result += i;
    }
    cout << result;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define inf 1e8
using namespace std;

int main(void){
	int n,m,s,g1,g2;
	while(cin>>n>>m>>s>>g1>>g2,n){
		int a,b,c;
		int edge[101][101];
		REP(i,1,n+1) REP(j,1,n+1) {
			if(i==j) edge[i][j]=0;
			else edge[i][j]=inf;
		}
		REP(i,0,m){
			cin>>a>>b>>c;
			edge[a][b]=c;
		}
		REP(k,1,n+1) REP(i,1,n+1) REP(j,1,n+1)
    				edge[i][j]=min(edge[i][k]+edge[k][j],edge[i][j]);
		int ans=3*1e8;
    	REP(i,1,n+1){
    		ans=min(ans,edge[s][i]+edge[i][g1]+edge[i][g2]);
    	}
    	p(ans);
	}
	return 0;
}

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

ll num(const vector<ll> &v, ll low, ll up, ll a){
    if(v[v.size() - 1] + a < low) return 0;
    else if(v[0] + a >= up) return 0;
    ll ok = v.size() - 1, ng = -1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(v[mid] + a >= low) ok = mid;
        else ng = mid;
    }
    ll left = ok;
    ok = v.size();
    ng = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(v[mid] + a >= up) ok = mid;
        else ng = mid;
    }
    ll right = ok;
    return right - left;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    for(ll &i : a) cin >> i;
    for(ll &i : b) cin >> i;
    ll ans = 0;
    for(ll i = 0; i <= 28; i++){
        ll cnt = 0;
        vector<ll> tmp;
        for(ll u : b) tmp.push_back(u % (1 << (i + 1)));
        sort(tmp.begin(), tmp.end());
        for(ll u : a){
            u %= (1 << (i + 1));
            cnt += num(tmp, (1 << i), (1 << (i + 1)), u);
            cnt += num(tmp, (1 << (i + 1)) + (1 << i), (1 << (i + 1)) + (1 << (i + 1)), u);
        }
        if(cnt & 1) ans += (1 << i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool a, b, c;
	a = b = c = false;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'a')a = true;
		if(s[i] == 'b')b = true;
		if(s[i] == 'c')c = true;
	}
	if(a && b && c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256