akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int a[200005], b[200005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
        b[a[i]] = i;
    }
    ll l[200005], r[200005];
    for(int i = 0; i < n; i++){
        l[i] = -1;
        r[i] = n;
    }
    set<int> st;
    for(int i = 0; i < n; i++){
        auto itr = st.lower_bound(b[i]);
        if(itr != st.end()) r[i] = *itr;
        if(itr != st.begin()) l[i] = *--itr;
        st.insert(b[i]);
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += (r[i] - b[i]) * (b[i] - l[i]) * (i + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 17644
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	//char[] S = null;
	int N = 0;
	int[] t = null;
	int[] x = null;
	int[] y = null;
	boolean ans = false;
	
	public void input() throws IOException {
		/*
		S = br.readLine().toCharArray();
		/*/
		N = in.nextInt();
		t = new int[N];
		x = new int[N];
		y = new int[N];
		for (int i=0; i<N; i++) {
			t[i] = in.nextInt();
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}
		//*/
		
	}

	public void solve() throws IOException {
		int nowt = 0;
		int nowx = 0;
		int nowy = 0;
		for (int i=0; i<N; i++) {
			int dt = t[i] - nowt;
			int dx = Math.abs(x[i] - nowx);
			int dy = Math.abs(y[i] - nowy);
			int diff = dt - dx -dy;
			if (diff < 0 || diff%2 != 0) {
				return;
			}
			nowt = t[i];
			nowx = x[i];
			nowy = y[i];
		}
		ans = true;
	}
	
	
	
	public void output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


Measured memory_bytes: 23380
# C
N,M=map(int,input().split())
cnd=[tuple(int(i) for i in input().split()) for j in range(M)]
ans=-1
for n in range(10**N):
    # print(n)
    flag=True
    n_str=str(n)
    if len(n_str)!= N:
        continue
    for s,c in cnd:
        if n_str[s-1]!=str(c):
            # print(n_str[s-1],c)
            flag=False
            break
    if flag:
        ans=n
        break
print(ans)

Measured memory_bytes: 3064
/*input
3
1 1 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element 
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (int)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const int maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
vector<pii> ans;
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	REP(i,n) cin>>arr[i];
	sort(arr,arr+n);
	int pos=0;
	if(arr[0]>=0) pos=n-1;
	else if(arr[n-1]<=0) pos=1;
	else{
		REP(i,n) if(arr[i]>=0) ++pos;
	}
	int neg=n-pos;
	int ans1=arr[n-1];
	REP(i,neg-1){
		ans.pb(make_pair(ans1,arr[i+1]));
		ans1-=arr[i+1];
	}
	int ans2=arr[0];
	REP(i,pos-1){
		ans.pb(make_pair(ans2,arr[n-i-2]));
		ans2-=arr[n-i-2];
	}
	cout<<ans1-ans2<<'\n';
	for(auto x:ans) cout<<x.f<<' '<<x.s<<'\n';
	cout<<ans1<<' '<<ans2<<'\n';
}

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        //input
        int N = NextInt();
        int[] h = LineInt();
        int[] dp = new int[N];
        for (int i = 1; i < N; i++) dp[i] = INF;
        for (int i = 1; i < N; i++)
        {
            dp[i] = dp[i - 1] + Math.Abs(h[i - 1] - h[i]);
            if (i == 1) continue;
            dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i - 2] - h[i]));
        }
        Console.WriteLine(dp[N - 1]);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 20192
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    string s; cin >> s;
    ll cnt = 0;
    f0(i, s.size()){
        int a = s[i]-48;
        cnt += a;
    }

    if(cnt%9 == 0) cout << "Yes" << nl;
    else cout << "No" << nl;
}



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


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int d[2][n];
  memset(d,0,sizeof(d));
  int s=0;
  for(int i=1;i<n;i++){
    cout<<"? "<<1<<" "<<i+1<<endl;
    cin>>d[0][i];
    if(d[0][s]<d[0][i]) s=i;
  }
  int t=s;
  for(int i=0;i<n;i++){
    if(s==i) continue;
    cout<<"? "<<s+1<<" "<<i+1<<endl;
    cin>>d[1][i];
    if(d[1][t]<d[1][i]) t=i;
  }
  int ans[n];
  for(int i=0;i<n;i++) ans[d[1][i]]=i+1;
  cout<<"!";
  for(int i=0;i<n;i++) cout<<" "<<ans[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3568
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[M];
		int b[] = new int[M];
		int c[] = new int[M];
		
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			for(int j = 0; j < b[i]; j++) {
				c[i] |= 1<<(sc.nextInt() - 1);
			}
		}
		
		int dp[] = new int[1<<N];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for(int i = 0; i < 1<<N; i++) {
			for(int j = 0; j < M; j++) {
				if(dp[i] != Integer.MAX_VALUE) {
					int t = i | c[j];
					int cost = dp[i] + a[j];
					dp[t] = Math.min(dp[t], cost);
				}
			}
		}
		
		System.out.println(dp[(1<<N) - 1] == Integer.MAX_VALUE ? -1 : dp[(1<<N) - 1]);
	}
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    string s; cin >> s;
    string year = s.substr(0,4);
    string mon = s.substr(5,2);
    string day = s.substr(8,2);

    if(stoi(year) <= 2019 && stoi(mon)<= 4 && stoi(day)<=30)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}


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

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> h(n + 1), a(m), b(m), t(n+1, true);
  rep(i, n) cin >> h[i + 1];
  rep(i, m) {
    cin >> a[i] >> b[i];
    if(h[a[i]] == h[b[i]]) {
      t[b[i]] = false;
      t[a[i]] = false;
    } else if(h[a[i]] > h[b[i]]) {
      t[b[i]] = false;
    } else {
      t[a[i]] = false;
    }
  }
  rep(i, n) {
    if(t[i + 1] == true) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pc = pair<char,int>;
using icpc = vector<pc>;

icpc readICPC()
{
    icpc ret;
    char c;
    while(cin >>c,(c!='$'))
    {
        int l;
        cin >>l;
        ret.pb({c,l});
    }
    return ret;
}

icpc solve(icpc a, icpc b, icpc c)
{
    int A = a.size(), B = b.size(), C = c.size();

    if(B==1)
    {
        rep(i,A)
        {
            // ?????????????????§??????
            if(a[i].fi==b[0].fi && a[i].se>=b[0].se)
            {
                icpc ret;
                rep(j,i) ret.pb(a[j]);
                rep(j,C) ret.pb(c[j]);
                ret.pb({b[0].fi, a[i].se-b[0].se});
                for(int j=i+1; j<A; ++j) ret.pb(a[j]);
                return ret;
            }
        }
    }
    else
    {
        rep(i,A-B+1)
        {
            bool ok = false;
            if(a[i].fi==b[0].fi && a[i].se>=b[0].se && a[i+B-1].fi==b[B-1].fi && a[i+B-1].se>=b[B-1].se)
            {
                ok = true;
                for(int j=1; j<B-1; ++j)
                {
                    if(!(a[i+j].fi==b[j].fi && a[i+j].se==b[j].se)) ok = false;
                }
            }

            if(ok)
            {
                icpc ret;
                rep(j,i) ret.pb(a[j]);
                ret.pb({a[i].fi, a[i].se-b[0].se});
                rep(j,C) ret.pb(c[j]);
                ret.pb({a[i+B-1].fi, a[i+B-1].se-b[B-1].se});
                for(int j=i+B; j<A; ++j) ret.pb(a[j]);
                return ret;
            }
        }
    }
    // ???????????????????????°???????????????
    return a;
}

icpc compress(icpc s)
{
    icpc ret;
    rep(i,s.size())
    {
        if(s[i].se == 0) continue;

        if(ret.size() == 0) ret.pb(s[i]);
        else
        {
            int R = ret.size();
            if(ret[R-1].fi == s[i].fi) ret[R-1].se += s[i].se;
            else ret.pb(s[i]);
        }
    }
    return ret;
}

int main()
{
    icpc a = readICPC();
    icpc b = readICPC();
    icpc c = readICPC();

    icpc ans = compress(solve(a,b,c));
    rep(i,ans.size()) printf("%c %d ", ans[i].fi, ans[i].se);
    printf("$\n");
    return 0;
}

Measured memory_bytes: 3296
#include <iostream>
typedef long long ll;

#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <queue>
#include <set>

using namespace std;

inline bool contain(const int x1, const int y1, const int z1,
                    const int x2, const int y2, const int z2,
                    const int x,  const int y,  const int z){
  return x1 <= x && x <= x2 &&
    y1 <= y && y <= y2 &&
    z1 <= z && z <= z2;
}

int main(){
  const int n = getInt();
  const int k = getInt();

  vector<int> xl(n), xh(n);
  vector<int> yl(n), yh(n);
  vector<int> zl(n), zh(n);

  vector<int> xc, yc, zc;

  REP(i,n){
    xc.push_back(xl[i] = getInt());
    yc.push_back(yl[i] = getInt());
    zc.push_back(zl[i] = getInt());
    xc.push_back(xh[i] = getInt());
    yc.push_back(yh[i] = getInt());
    zc.push_back(zh[i] = getInt());
  }

  sort(xc.begin(), xc.end());
  sort(yc.begin(), yc.end());
  sort(zc.begin(), zc.end());

  xc.erase(unique(xc.begin(), xc.end()), xc.end());
  yc.erase(unique(yc.begin(), yc.end()), yc.end());
  zc.erase(unique(zc.begin(), zc.end()), zc.end());

  ll ans = 0;
  REP(ii,xc.size() - 1) REP(jj,yc.size() - 1) REP(kk,zc.size() - 1){
    const int x1 = xc[ii];
    const int x2 = xc[ii + 1];
    const int y1 = yc[jj];
    const int y2 = yc[jj + 1];
    const int z1 = zc[kk];
    const int z2 = zc[kk + 1];

    int cnt = 0;
    REP(a, n){
      if(contain(xl[a], yl[a], zl[a],
                 xh[a], yh[a], zh[a],
                 x1, y1, z1) &&
         contain(xl[a], yl[a], zl[a],
                 xh[a], yh[a], zh[a],
                 x2, y2, z2))
        cnt++;
    }

    if(cnt >= k){
      ans += (ll)(x2 - x1) * (ll)(y2 - y1) * (ll)(z2 - z1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
 
 
int main()
{
	int matrix[100][100] = {0};
	int n;
	cin>>n;
	for(int i = 0; i < n;i++){
		int u,k;
		cin>>u>>k;
		u--;
		for(int j = 0; j < k; j++){
			int v;
			cin>>v;
			v--;
			matrix[u][v] = 1;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n;j++){
			if( j != 0) cout<<" ";
			cout<<matrix[i][j];
		}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 3140
N = int(input())
A = list(map(int,input().split()))

money = 1000
stock = 0

for i in range(N-1):
    if A[i+1] > A[i]:
        if money >= A[i]:
            n = money // A[i]
            stock += n
            money -= A[i] * n
    elif A[i+1] == A[i]:
        continue
    else:
        if stock > 1:
            money += stock * A[i]
            stock = 0

if stock > 0:
    money += stock * A[-1]

print(money)

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

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];

    int ans = 0;
    while (!(a[0] == a[1] && a[1] == a[2])) {
        int m = *max_element(a, a + 3);
        int mc = count(a, a + 3, m);
        rep(i, 3) if (a[i] != m) mc == 1 ? a[i]++ : a[i] += 2;
        ans++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define mp make_pair
#define pb push_back

const int mod = (int)1e9 + 7;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const int N = (int)1e5 + 100;
const int MAXA = (int)3e6;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    // ifstream cin("input.txt");
    //ofstream cout("output.txt");
    // freopen("nochange.in", "r", stdin);
    //freopen("nochange.out", "w", stdout);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0,p = 0;
    for(int i = 0;i < n;i++){
        ll cur = p + 1;
        if(cur < a[i]){
            ans += a[i] / cur - (a[i] % cur == 0);
            a[i] = 1;
        }
        p = max(p, a[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<long long>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;

int main() {
    int N; cin >> N; 
    vector<string> S(N); for(int i = 0; i < N; i++) cin >> S.at(i);
    int num_AC = 0, num_WA = 0, num_TLE = 0, num_RE = 0;

    for (int i = 0; i < N; i++) {
        if(S.at(i) == "AC") num_AC++;
        else if(S.at(i)=="TLE") num_TLE++;
        else if(S.at(i)=="WA") num_WA++;
        else num_RE++;
    }

    cout << "AC x " << num_AC << endl;
    cout << "WA x " << num_WA << endl;
    cout << "TLE x " << num_TLE << endl;
    cout << "RE x " << num_RE << endl;
    

}

Measured memory_bytes: 6400
import java.util.*;

public class Main {
	char[] a;
	int n;
	
	void J(){
		char b = a[n-1];
		for(int i=n-1;i>0;i--) a[i] = a[i-1];
		a[0] = b;
	}
	
	void C(){
		char b = a[0];
		for(int i=0;i<n-1;i++) a[i] = a[i+1];
		a[n-1] = b;
	}
	
	void E(){
		char[] b = new char[n];
		int s = n/2;
		int t = n%2;
		for(int i=0;i<s;i++) b[i] = a[s+t+i];	
		for(int i=0;i<s;i++) b[s+t+i] = a[i];
		if(t==1) b[s] = a[s];
		a = b.clone();
	}
	
	void A(){
		char[] b = new char[n];
		for(int i=0;i<n;i++) b[i] = a[n-1-i];
		a = b.clone();
	}
	
	void P(){
		for(int i=0;i<n;i++){
			if(a[i]=='0') a[i] = '9';
			else if(a[i]>=49 && a[i]<=57) a[i]--;
		}
	}
	
	void M(){
		for(int i=0;i<n;i++){
			if(a[i]=='9') a[i] = '0';
			else if(a[i]>=48 && a[i]<=56) a[i]++;
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int m = sc.nextInt();
			for(int i=0;i<m;i++){
				char[] c = sc.next().toCharArray();
				a = sc.next().toCharArray();
				n = a.length;
				for(int j=c.length-1;j>=0;j--){
					if(c[j]=='J') J();
					else if(c[j]=='C') C();
					else if(c[j]=='E') E();
					else if(c[j]=='A') A();
					else if(c[j]=='P') P();	
					else M();
				}
				for(int j=0;j<n;j++) System.out.print(a[j]);
				System.out.println();
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();	
	}	
}

Measured memory_bytes: 15380
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll K; 
vector<int> A, F;

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

  cin >> N >> K;
  ll a;
  rep(i, N) {
    cin >> a;
    A.push_back(a);  
  }
  rep(i, N) {
    cin >> a;
    F.push_back(a);  
  }
  sort(ALL(A));
  sort(ALL(F),greater<ll>());

  ll r = 1e12; // 練習回数の最長
  ll l = -1ll; // 練習回数の最短
  while (l+1 < r) {
    ll median = (l+r)/2;
    ll sum = 0ll;
    rep(i, N) sum += max(0ll, A[i]- (median/F[i]));
    if (sum <= K) r = median;
    else l = median;
  }
  cout << r << "\n";
  return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string score;
string ans[300];
string win;
int a,b;
int cou;
 
void saiki(int ac,int bc ,int d) {
   
  if(d == a+b && (score[a+b-1] == win[0] || win[0] == 'd') ) {
    cou++;
    for(int i=0;i<a+b;i++) ans[cou-1] += score[i];
    
  }
     
  if(a+b > d && !(ac == 3 && bc == 5) && !(ac == 5 && bc == 3)) {
    if(ac < a) {
      score[d] = 'A';
      saiki(ac+1,bc,d+1);
    }
    if(bc < b) {
      score[d] = 'B';
      saiki(ac,bc+1,d+1);
    }
  }
     
}
 
int main(){
 
  int flg = 0;
  cin >> a >> b;
  if((a == 4 && b == 5)) flg = 1,a = b = 4;
  if (a == 5 && b == 4)  a = b = flg =  4;
 
  win = "d";
  score.resize(a+b);
  if(a > b && (a >= 5 && b <= 3) || a == 6) win = "A";
  else if(b > a && (b >= 5 && a <=3) || b == 6) win = "B";
  //  cout << win << endl;
 
  cou = 0;
  saiki(0,0,0);
 
  if(flg == 1)
    for(int i=0;i<cou;i++) ans[i] += 'B';
  if(flg == 4) 
    for(int i=0;i<cou;i++) ans[i] += 'A'; 
   
  sort(ans,ans+cou);
 
 
  for(int i=0;i<cou;i++) {
    cout << ans[i] << endl;
    if(ans[i] == ans[i+1]){
      cout <<"ok"<<endl;
      break;
    }
  }
 
  // cout << cou << endl;
 
 
  return 0;
 
}
 

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;

int a[N];
int aord[N];
vector<int> g[N];
int ans[N];

int nid;
const int B = N * 60;
int X[B], L[B], R[B];

int n;
int build(int l=0, int r=n) {
    int id = ++nid;
    if (r - l <= 1) {
        X[id] = 0;
        return id;
    }

    int mid = (l + r) / 2;
    L[id] = build(l, mid);
    R[id] = build(mid, r);
    X[id] = X[L[id]] + X[R[id]];
    return id;
}

int add(int id, int pos, int value, int l=0, int r=n) {
    if (r - l <= 1) {
        int id2 = ++nid;
        X[id2] = X[id] + value;
        return id2;
    }

    int id2 = ++nid;
    int mid = (l + r) / 2;
    if (pos < mid)
        L[id2] = add(L[id], pos, value, l, mid), R[id2] = R[id];
    else
        R[id2] = add(R[id], pos, value, mid, r), L[id2] = L[id];
    X[id2] = X[L[id2]] + X[R[id2]];
    return id2;
}

int query(int id, int pos, int l=0, int r=n) {
    if (X[id] == 0 || r <= pos)
        return -1;

    if (r-l <= 1)
        return l;

    int mid = (l + r) / 2;
    int ansLeft = query(L[id], pos, l, mid);
    if (ansLeft != -1)
        return ansLeft;
    return query(R[id], pos, mid, r);
}

int roots[N];
void dfs(int u, int p=0) {
    int x = lower_bound(aord+1, aord+n+1, a[u]) - (aord+1);
    int lb = query(roots[p], x);

    if (lb == -1) {
        roots[u] = add(roots[p], x, 1);
    } else {
        roots[u] = add(roots[p], lb, -1);
        roots[u] = add(roots[u], x, 1);
    }

    ans[u] = X[roots[u]];

    for (int v : g[u]) if (v != p) {
        dfs(v, u);
    }
}

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

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        aord[i] = a[i];
    }
    sort(aord+1, aord+n+1);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    roots[0] = build();
    dfs(1);

    for (int u = 1; u <= n; u++)
        cout << ans[u] << endl;

    return 0;
%>

Measured memory_bytes: 118056
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(int argc, char const *argv[]) {
    int k; cin>>k;
    ll ans = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int c = 1; c <= k; ++c) {
                ans += gcd(i,gcd(j,c));
            }
        }
    }

    cout << ans << '\n';
    return 0;
}

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

string substrBack(string str, size_t pos, size_t len) {
    const size_t strLen = str.length();
    return str.substr(strLen - pos, len);
}
 
int main(){
    string a;
    cin >> a;
    string b = substrBack(a, 1, 1);
    if(b == "s"){
        cout << a + "es" << endl; 
    }else{
        cout << a + "s" << endl; 
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(make_pair(0, n));
  VL dp(n+1, 0), nxt(n+1, -1);
  for(int i = n-1; i >= 0; --i) {
    for(;;) {
      if(que.top().second > i + m) que.pop();
      else break;
    }
    P p = que.top();
    if(s[i] == '1') {
      dp[i] = INF;
    }
    else {
      dp[i] = p.first + 1;
      nxt[i] = p.second;
    }
    que.push(make_pair(dp[i], i));
  }
  if(dp[0] >= INF) out(-1);
  else {
    int idx = 0;
    while(nxt[idx] > 0) {
      cout << nxt[idx] - idx << ' ';
      idx = nxt[idx];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);

	    while(sc.hasNext()){
	        int a = sc.nextInt();
	        int b = sc.nextInt();
	        int c = sc.nextInt();
	        int d = a+b;

	        if((a==-1)&&(b==-1)&&(c==-1))
	            break;
            else{
                if(d>=80)
                    System.out.print("A\n");
                else if(d>=65&&d<80)
                    System.out.print("B\n");
                else if((d>=50&&d<65)||c>=50)
                    System.out.print("C\n");
                else if((d<30)||((a==-1||b==-1)))
                    System.out.print("F\n");
                else if((d>=30)&&(d<50))
                    System.out.print("D\n");

            }
        }
    }
}



Measured memory_bytes: 26428
class MyNode
  attr_accessor :parent, :left_child, :right_sibling, :depth

  def type
    if @parent == -1
      "root"
    elsif @left_child
      "internal node"
    else
      "leaf"
    end
  end

  def depth(nodes)
    if @parent == -1
      return 0
    else
      return nodes[@parent].depth(nodes) + 1
    end
  end

end

def set_depth(nodes, i, d)
  node = nodes[i]
  node.depth = d
  if node.left_child
    set_depth(nodes, node.left_child, d + 1)
  end
  if node.right_sibling
    set_depth(nodes, node.right_sibling, d)
  end
end


n = gets.to_i
nodes = []
n.times do
  nodes << MyNode.new
end


n.times do
  inputs = gets.split.map(&:to_i)
  node_id = inputs.shift
  node = nodes[node_id]
  d = inputs.shift
  prev_id = nil
  inputs.each_with_index do | c_id, i|
    nodes[c_id].parent = node_id
    if i.zero?
      node.left_child = c_id
    else
      nodes[prev_id].right_sibling = c_id
    end
    prev_id = c_id
  end
end

root_id = nil
nodes.each_with_index do |node, i|
  if node.parent.nil?
    node.parent = -1
    root_id = i
  end
end

# set_depth(nodes, root_id, 0)

nodes.each_with_index do |node, i|
  childlen_ids = []
  if node.left_child
    childlen_ids << node.left_child
    child_node = nodes[node.left_child]
    while child_node.right_sibling
      childlen_ids << child_node.right_sibling
      child_node = nodes[child_node.right_sibling]
    end
  end

  puts "node #{i}: parent = #{node.parent}, depth = #{node.depth(nodes)}, #{node.type}, [#{childlen_ids.join(', ')}]"
end


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

int main(){
    int m;
    while(cin >> m, m){
        vector<int> t(m);
        for(int i = 0; i < m; i++)  cin >> t[i];
        vector<int> d(100, 24);
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
            int a, b;
            cin >> a >> b;
            d[a-1] = min(d[a-1], b);
        }
        vector<vector<int>> dp(100, vector<int>(m, 1<<30));
        dp[0][0] = 0;
        for(int i = 0; i+1 < 100; i++){
            for(int j = 0; j < m; j++){
                if(dp[i][j] == 1<<30)   continue;
                dp[i+1][0] = min(dp[i+1][0], dp[i][j]+1);
                if(t[(j+1)%m] <= d[i+1])   dp[i+1][(j+1)%m] = min(dp[i+1][(j+1)%m], dp[i][j]);
            }
        }
        int ans = 1<<30;
        for(int j = 0; j < m; j++)  ans = min(ans, dp[99][j]);
        cout << ans << endl;
    }
    return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    
    vector<int> x(n, 0);
    ll t = 0;
    rep (i, n) t += (i % 2 == 0) ? a[i]*2 : -a[i]*2;
    x[0] = t/2;
    rep (i, 1, n) x[i] = a[i-1]*2 - x[i-1];
    rep (i, n) cout << x[i] << " ";
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 4016
/*************************************************************************
	> File Name: A.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/4 20:17:54
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d %d %d",c,a,b);
	return 0;
}


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

const int maxn = 105;
int a[maxn << 1];

int main() {
  int n;
  std::cin >> n;
  for (int i = 1; i <= n * 2; i++) {
    std::cin >> a[i];
  }
  std::sort(a + 1, a + 2 * n + 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += a[i * 2 - 1];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w_tmp, v_tmp = map(int, input().split())
    weight.append(w_tmp)
    value.append(v_tmp)

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    for j in range(W+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

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


int main()
{
	int k,x,s,f ;
	cin>>k>>x;
	f=(k-1)*2;
	f ++;
	s=x-(k-1);
	for (int i=0; i<f ; i++){
		cout<<s<<" ";
		s +=1;
	}


		return 0;
}
	


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    vector<tuple<int, int, int> > v(n);
    int m = n / 2;
    for(int i=0; i<n; ++i){
        int a = k + i;
        int b;
        if(i < m)
            b = k + 2 * n - m + i;
        else
            b = k + n - m + i;
        v[i] = make_tuple(a + b, a, b);
    }
    sort(v.begin(), v.end());

    for(int i=0; i<n; ++i){
        int a, b, c;
        tie(c, a, b) = v[i];
        c = k + 2 * n + i;
        if(c < a + b){
            cout << -1 << endl;
            return 0;
        }
        v[i] = make_tuple(c, a, b);
    }

    for(int i=0; i<n; ++i){
        int a, b, c;
        tie(c, a, b) = v[i];
        cout << a << ' ' << b << ' ' << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
def f(n):
    if n % 2 == 0:
        return int(n/2)
    
    return int(3*n + 1)
    
s = int(input())

arr = [s]

for i in range(1, 1000001):
    c = f(arr[i-1])
    if c in arr:
        re = i + 1
        break
    arr.append(c)

print(re)

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

using namespace std;

int calc(int x)
{

	int cnt=0;
	while(1)
	{
		x=x/2;
		cnt++;
		if(x&1)
			break;
	}

	return cnt;

}


long long res=0;

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

	int a[n+5];

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


		for(int i=0;i<n;i++)
		{
			if(a[i]%2==0)
			{
				res+=calc(a[i]);
			}
		}

		cout<<res<<'\n';

	return 0;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

ll N, K, A[200009];

int main() {
    cin >> N >> K;
    FOR(i, 1, N) cin >> A[i];

    ll dest[200009];
    ll visited[200009];

    REP(i, N+1) {
        dest[i] = 0;
        visited[i] = -1;
    }

    dest[0] = 1;
    visited[1] = 0;
    
    ll T, a;

    FOR(i, 1, N) {
        dest[i] = A[dest[i-1]];
        if (visited[dest[i]] >= 0) {
            a = visited[dest[i]];
            T = i - a;
            break;
        }
        visited[dest[i]] = i;
    }
    
    ll ans;
    if (K < a) ans = dest[K];
    else {
        K -= a;
        ans = dest[a + K%T];
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 8308
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
    string S, T;
    int operation = 0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> S >> T;
    for(int i = 0; i < S.size(); i++)
        if(S[i] != T[i])
            operation++;

    cout << operation << endl;
    return 0;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;
            int a = 0;
            
            
            for(int i = 1 ; i <= n ; i+=2)
            {
                a = 0;
                for(int j = 1 ; j <= i ; j+=2)
                {
                    if(i % j == 0) a++;
                }
                if(a==8) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 13140
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

	N, K := readInt(), readInt()
	S := readString()

	trial := 0
	happiness := 0

	i := 0
	for i < N-1 {
		if S[i] == S[i+1] {
			happiness++
			i++
			continue
		}

		if trial == K {
			i++
			continue
		}

		j := i + 1
		for j < N && S[i] != S[j] {
			happiness++
			j++
		}
		if j != N {
			happiness++
		}
		trial++
		i = j
	}
	fmt.Println(happiness)
}


Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread!ulong();
    auto S1 = new long[](N + 1);
    auto S2 = new long[](N + 1);
    foreach (i; 0 .. N)
    {
        S1[i + 1] = S1[i] + A[i];
        S2[i + 1] = S2[i] ^ A[i];
    }

    long i;
    long j;
    long ans;
    while (i < N)
    {
        while (j < N && (S1[j+1] - S1[i]) == (S2[j+1] ^ S2[i]))
            j++;
        ans += j - i;
        i++;
    }
    writeln(ans);
}


Measured memory_bytes: 13224
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll


int n,m,q;
int d[1000][1000];

signed main(){
  cin>>n>>m>>q;
  rep(i,m){
    int l,r;
    cin>>l>>r;
    d[l][r]++;
  }

  FOR(i,1,n+1){
    FOR(j,1,n+1){
      d[i][j]+=d[i][j-1];
    }
  }

  rep(i,q){
    int a,b;
    cin>>a>>b;
    int ans = 0;
    FOR(j,a,b+1){
      ans += d[j][b]-d[j][a-1];
    
    }
    cout<<ans<<endl;
  }

}

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

#define mx 100005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
}

int ar[mx];
char ch[mx];

int m,n,k,ii;


void solve()
{
	string s;
	cin>>s;
	if(s=="RRR")
	{
		cout<<3<<endl;
	}
	else if(s[0]=='R' && s[1]=='R')
	{
		cout<<2<<endl;
	}
	else if(s[2]=='R' && s[1]=='R')
	{
		cout<<2<<endl;
	}
	else if(s=="SSS")
	{
		cout<<0<<endl;
	}
	else cout<<1<<endl;
}

int main()
{
	IO();

	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << ":" << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;


}

using namespace atcoder;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	cin >> a;
	int ans = 1000;
	for (int i = 0; i < a.size() - 2; i++) {
		ans = min(abs(stoi(a.substr(i, 3)) - 753), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class AGC002
{
  public static void Main()
  {
    bool zeroexists=false;
    long minuscount=0;
    long[]ab=Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    if(ab[0]<=0&&ab[1]>=0)zeroexists=true;
    else if(ab[0]<0&&ab[1]<0)minuscount=(ab[1]-ab[0]+1);
    if(zeroexists)Console.WriteLine("Zero");
    else if(minuscount%2==0)Console.WriteLine("Positive");
    else Console.WriteLine("Negative");
  }
}


Measured memory_bytes: 13268