akhauriyash/Code-Regression huggingface dataset:
// atcoder/exawizards2019/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  str s;
  while (cin >> n >> m >> s) {
    vec<pair<char, char>> v(m);
    cin >> v;
    auto f = [&] () {
      auto fn = [&] (int x) {
        each (i, v) {
          if (s[x] == i.first) {
            if (i.second == 'R') ++x;
            if (i.second == 'L') --x;
          }
          if (x == s.size()) return false;
          if (x == -1) return true;
        }
        return false;
      };
      int small = 0;
      int large = s.size();
      while (small + 1 < large) {
        int mid = (small + large) / 2;
        if (fn(mid)) small = mid;
        else large = mid;
      }
      return fn(small) ? small + 1 : 0;
    };
    int x = f();
    reverse(s.begin(), s.end());
    each (i, v) {
      i.second = 'R' + 'L' - i.second;
    }
    x += f();
    cout << n - x << endl;
  }

  return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int k;cin>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            cout<<'*';
        }else cout<<s[k-1];
    }
    cout<<endl;
    return 0;
}

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

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main()
{
    ll a, b, tmp;
    ll ans;
    cin >> a >> b;
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    ans = lcm(a,b);

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

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

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

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

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

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

int main() {
	int x,y;
	cin >> x >> y;
	cout << x + y/2 << endl;
}		

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
 
class Program
{
    static void Solve()
    {
        var n = sc.Int();
        var m = sc.Int();

        var G = new List<Edge>[n];
        var used = new bool[n];
        var cost = new int[n];

        for (int i = 0; i < n; i++)
        {
            G[i] = new List<Edge>();
        }

        for (int i = 0; i < m; i++)
        {
            var l = sc.Int() - 1;
            var r = sc.Int() - 1;
            var d = sc.Int();

            G[l].Add(new Edge{ to = r, cost = d });
            G[r].Add(new Edge{ to = l, cost = -d });
        }

        bool ok = true;
        for (int i = 0; i < n; i++)
        {
            if (!dfs(G, i, cost[i], used, cost))
            {
                ok = false;
                break;
            }
        }
        
        if (ok)
            pr.WriteLine("Yes");
        else
            pr.WriteLine("No");
    }

    static bool dfs(List<Edge>[] G, int curr, int currCost, bool[] used, int[] cost)
    {
        if (used[curr])
            return currCost == cost[curr] ? true : false;
        
        used[curr] = true;
        cost[curr] = currCost;

        foreach (var nxt in G[curr])
            if (!dfs(G, nxt.to, currCost + nxt.cost, used, cost))
                return false;

        return true;
    }

    class Edge
    {
        public int to;
        public int cost;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }
 
    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}
 
#region IO
class Scanner
{
    private int _i = 0; 
    private string[] line = new string[0];
 
    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }
 
    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }
 
        return line[_i++];
    }
 
    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}
 
class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 48260
#include <iostream>
#include <string>
#include <list>
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(false);
    bool flag=false;
    int n,num;
    string s;
    list<int> intlist;
    list<int>::iterator it;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="insert"){
            cin >> num;
            intlist.push_front(num);
        }
        else if(s=="delete"){
            cin >> num;
            for(it=intlist.begin();it!=intlist.end();++it){
                if(*it ==num){
                    intlist.erase(it);
                    break;
                }
            }
        }
        else if(s=="deleteFirst"){
            intlist.pop_front();
        }
        else if(s=="deleteLast"){
            intlist.pop_back();
        }
    }
    for(it=intlist.begin();it!=intlist.end();++it){
        if(flag==false){
            cout << *it;
            flag=true;
        }
        else cout << " " << *it;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 34400
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    win = S.count('o')
    l = len(S)
    if 15 - l >= 8 - win:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.push_back(a%2);
    }
    
}

int solve(){
    for (int i = 0; i < N; i++)
    {
        if(A[i]) {cout << "first" << endl; return 0;}
    }
    cout << "second" << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
int main(void)
{
    int D, N;
    cin >> D >> N;
    int ans;
    if (N == 100)
        N = 101;
    if (D == 0)
    {
        ans = 1 * N;
    }
    else if (D == 1)
    {
        ans = 100 * N;
    }
    else
    {
        ans = 10000 * N;
    }
    cout << ans;
    return 0;
}


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


int main(){

    int N;
    cin >> N;
    

    int x = 1000-(N%1000);
    if(x!=1000)
    cout << x << endl;
    else
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);
const ll mod = 1'000'000'007;


int dp[105][4][4][4];

int main() {

	int N;
	cin >> N;

	// 0:A, 1:G, 2:C, 3:T

	dp[0][3][3][3] = 1;

	for (int n = 0; n < N; n++) {

		//最後から1文字目の文字
		for (int c1 = 0; c1 < 4; c1++) {

			//最後から2文字目の文字
			for (int c2 = 0; c2 < 4; c2++) {

				//最後から3文字目の文字
				for (int c3 = 0; c3 < 4; c3++) {

					if (dp[n][c1][c2][c3] == 0) continue;
					//最後に追加する文字
					for (int a = 0; a < 4; a++) {
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;

						dp[n + 1][a][c1][c2] += dp[n][c1][c2][c3];
						dp[n + 1][a][c1][c2] %= mod;

					}

				}
			}
		}
	}

	int ans = 0;

	for (int c1 = 0; c1 < 4; c1++) {

		//最後から2文字目の文字
		for (int c2 = 0; c2 < 4; c2++) {

			//最後から3文字目の文字
			for (int c3 = 0; c3 < 4; c3++) {

				ans += dp[N][c1][c2][c3];
				ans %= mod;

			}
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
local function read_a(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
M=io.read"*n"
io.read()
p,S={},{}
for i=1,M do
p[i],S[i]=io.read():match"(%d+)%s+(%S+)"
p[i]=tonumber(p[i])
end

t={}
for i=1,M do
	if(t[p[i]])then
		if(t[p[i]]>0)then
			if(S[i]=="WA")then
				t[p[i]]=t[p[i]]+1
			else
				t[p[i]]=-t[p[i]]
			end
		end
	else
		if(S[i]=="WA")then
			t[p[i]]=1
		else
			t[p[i]]=0
		end
	end
end
ac,pn=0,0
for i=1,N do
	if(t[i])then
		if(t[i]<=0)then
			ac=ac+1
			pn=pn-t[i]
		end
	end
end
print(ac,pn)

Measured memory_bytes: 7192
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
using namespace std;

#define roop(i,n) for(i=0;i<n;i++)

using ll = long long;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	char s[100001];
	int i;
	cin >> s;
	if (strlen(s) == 1) {
		cout << 0 << endl;
		return 0;
	}
	int zeroCount = 0;
	int oneCount = 0;
	roop(i, strlen(s)) {
		if (s[i] == '0') {
			zeroCount++;
		} else {
			oneCount++;
		}
	}
	cout << 2 * min(zeroCount, oneCount) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}




int main(){
    ll n; cin >> n;
    cout << (n-1)/2 + 1;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
	N, M, Q = MAP()
	LR = [LIST() for _ in range(M)]

	x = [[0]*N for _ in range(N)]
	for L, R in LR:
		x[L-1][R-1] += 1

	pq = [LIST() for _ in range(Q)]

	C = [[0]*N for _ in range(N)]

	for i in range(N):
		tmp = 0
		C[i] = list(accumulate(x[i]))

	for p, q in pq:
		p = p-1
		q = q-1
		ans = 0
		for i in range(p, q+1):
			if p-1 <= -1:
				ans += C[i][q]
			else:
				ans += C[i][q]-C[i][p-1]
		print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 121944
#include <stdio.h>

int main(int argc, char **argv)
{
	int n;
	char inputs[4];
	
	
	fgets( inputs, sizeof(inputs), stdin );
	sscanf( inputs , "%d", &n );
	
	printf("%d\n", n * n * n);
	
	
	return 0;
}

Measured memory_bytes: 1844
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long lli;
typedef unsigned long long ull;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

int h,w;
vst m;
int r,c;
vst x;
mat cmpm;
lli hsh = 0;
lli cmp = 0;

const lli b = 1000000007;
const lli d = 1000000009;
lli bbr = 1,bbc = 1;

vector<pll> ans;

int main(){
    cin >> h >> w;
    m = vst(h);
    for(lli i = 0;i < h;i++) cin >> m[i];
    cin >> r >> c;
    x = vst(r);
    for(lli i = 0;i < r;i++) cin >> x[i];
    for(lli i = 0;i < r;i++) bbr *= d;
    for(lli i = 0;i < c;i++) bbc *= b;
    for(lli i = 0;i < r;i++){
        lli hs = 0;
        for(lli j = 0;j < c;j++){
            hs =
            hs*b + 
            x[i][j];
        }
        hsh = hsh*d + hs;
    }
    cmpm = mat(h,vll(w));
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cmpm[i][j] = 
            (j-1 >= 0 ? cmpm[i][j-1]*b : 0) + 
            m[i][j] - 
            (j-c >= 0 ? m[i][j-c]*bbc : 0);
        }
    }
    for(int j = 0;j < w;j++){
        cmp = 0;
        for(int i = 0;i < h;i++){
            cmp = 
            cmp*d + 
            cmpm[i][j] -
            (i-r >= 0 ? cmpm[i-r][j]*bbr : 0);
            if(cmp == hsh) ans.push_back(pll(i-r+1,j-c+1));
        }
    }
    sort(ans.begin(),ans.end());
    for(lli i = 0;i < ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;


    return 0;
}

Measured memory_bytes: 20112
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


int main(){

	int N,M,table[1000],loc,count,dice[1000];

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i=0; i < N; i++){
			scanf("%d",&table[i]);
		}

		for(int i=0; i < M; i++){
			scanf("%d",&dice[i]);
		}

		loc = 0,count = 0;

		while(loc <  N-1 && count < M){
			loc += dice[count];

			count++;
			if(loc < N-1){
				loc += table[loc];
			}
		}

		printf("%d\n",count);
	}

    return 0;
}

Measured memory_bytes: 2696
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    for i in (0..n+1).rev() {
        let  b = format!("{:b}", i);
        if b.matches('1').count() == 1 {
            println!("{}", i);
            break;
        }
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <numeric>
#include <utility>

using namespace std;

const int MX = 100005;

int main(void) {
        int n, q;
        vector<int> cnt(MX);
        long long sum = 0;

        cin >> n;
        for (int i = 0; i < n; i++) {
                int tmp;
                cin >> tmp;
                sum += tmp;
                ++cnt[tmp];
        }

        cin >> q;
        for (int i = 0; i < q; i++) {
                long long b, c;
                cin >> b >> c;

                sum += cnt[b] * (c - b);
                cnt[c] += cnt[b];
                cnt[b] = 0;
                cout << sum << endl;
        }

        return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}



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

	ll n, k;
	cin >> n >> k;

	Array a(n,0);
	REP(i, n) cin >> a[i];

	Array sum(n + 1, 0);
	REP(i, n) sum[i + 1] = sum[i] + a[i];

	map<ll, ll> mp;
	ll ans = 0;
	for (ll j = 0; j <= n; j++) {
		if (j >= k) {
			ll i = j - k;
			mp[(sum[i] - i)%k]--;
		}
		mp[(sum[j]-j)%k]++;
		ans += mp[(sum[j]-j)%k] - 1;
		//cout << ans << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
/*  ex5_2 ACGT
    pandacodeb  */

#include <stdio.h>
#define SIZE 11

int main(void){
    char name[SIZE];
    char *ptr;
    int max = 0, length;

    //input name
    scanf("%s", name);

    ptr = name;
    while (*ptr != '\0'){
        length = 0;
        //find length for each ACGT subsequence
        while (*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            ptr++;
            length++;
        }

        //update new max value (if have to)
        if (length > max)
            max = length;

        //move to next index
        ptr++;
    }

    //print out length of the longest ACGT subsequence
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1716
#include <iostream>
#include <string>
#include <vector>


using namespace std;

long long solve(vector<vector<bool>> ADJ){
	
	long long dist = 0;
	long long N = ADJ.size();
	vector<vector<long long>> MD(N, vector<long long>(N, 1000000001));
	
	
	for(long long i = 0; i < N; i++){
		MD[i][i] = 0; 
		for(long long j = 0; j < N; j++){
			if (ADJ[i][j] == true) {
				MD[i][j] = 1;
				dist = 1;
			}
		}
	}
	

	
	for(long long k = 0; k < N; k++){
		
		for(long long i = 0; i < N; i++){
			
			for(long long j = 0; j < N; j++){
				
				if(MD[i][j] > MD[i][k] + MD[k][j]){
					MD[i][j] = MD[i][k] + MD[k][j];

				}
			}
		}	
		
	}
	
	for(long long i = 0; i < MD.size(); i++){
		for (const auto & e: MD[i]) {
			if(e < 1000000000) {
				if (dist < e) dist = e;
				
			}
		}
	}

	/*
	for(int i = 0; i < MD.size(); i++){
		
		for (const auto & e: MD[i]) cout << e << " ";
		cout << endl;
	}*/
	
	return dist;
}

int main() {
	long long H, W;
	cin >> H >> W;
	
	vector<vector<bool>> M(H, vector<bool> (W, false));
	
	for(long long i = 0; i < H; i++){
		
		for(long long j = 0; j < W; j++){
			char a;
			cin >> a;
			if(a == '.') M[i][j] = true;			
		}		
	}
	
	
	vector<vector<bool>> ADJ(H*W, vector<bool> (H*W, false));
	
	for(long long i = 0; i < H; i++){
		for(long long j = 0; j < W; j++){
			long long from = W*i + j;
			
			if(M[i][j] == true){
				
				if(j < W - 1){ 
					if(M[i][j+1] == true){
						
						long long to = W*i + j + 1;
						ADJ[from][to] = true;
						ADJ[to][from] = true;
						
					}
				}
				
				if(i < H - 1){
					if(M[i+1][j] == true){
						long long to = W*(i+1) + j;
						ADJ[from][to] = true;
						ADJ[to][from] = true;
					}
					
				}
			
			}else{
				
			}
		}		
	}	
	
	long long dist = solve(ADJ);
	
	
	/*
	for(int i = 0; i < ADJ.size(); i++){
		
		for (const auto & e: ADJ[i]) cout << e << " ";
		cout << endl;
	}*/
	
	cout << dist << endl;
	
	
	return 0;
	
}






Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    S = cin.stringList(N)
    D = _collections.defaultdict(int)
    for s in S:
        D["".join(sorted(s))] +=1
    ans = 0
    for v in D.values():
        ans += v * (v - 1) // 2
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 74584
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

 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; // Be careful not to overflow
 }
int main()
{
  long long n;
  cin >> n;
  long long ans = 1;
  for ( int i = 0; i < n;i++)
  { long long t;
   cin >> t;
   ans = lcm(ans,t);
  }
  cout <<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n,k;
    cin>>n>>k;
    int Xor=0;
    rep(i,pow(2,n)-1)Xor^=i;
    if(n==0){
        if(k==0)cout<<0<<" "<<0<<endl;
        else fin(-1);
    }
    else if(n==1){
        if(k==0)cout<<"0 0 1 1"<<endl;
        else fin(-1);
    }
    else if(n>=2 && k<=pow(2,n)-1) {
        rep(i,pow(2,n)){
            if(i==k)continue;
            cout<<i<<" ";
        }
        cout<<k<<" ";
        drep(i,pow(2,n)){
            if(i==k)continue;
            cout<<i<<" ";
        }
        cout<<k<<endl;
    }
    else {
        fin(-1);
    }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100

int main(){
  int x,top=0;
  char s[N];
  int S[N];

  while(scanf("%s", s)!=EOF){
    if (s[0] == '+'){
      S[top-2] = S[top-2] + S[top-1];
      top = top - 1;
    }else if(s[0]== '-' ){
      S[top-2] = S[top-2] - S[top-1];
      top = top - 1;
    }else if(s[0] == '*'){
      S[top-2] = S[top-2] * S[top-1];
      top = top - 1;
    }else{
      x = atoi(s);
      S[top] = x;
      top++;
    }
  }
  printf("%d\n",S[top-1]);
  return 0;
}

Measured memory_bytes: 548
package main

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

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	W := strings.ToLower(nextLine(sc))
	ans := 0
	for {
		// s := strings.ToLower(nextLine(sc))
		s := nextLine(sc)
		if s == "END_OF_TEXT" {
			break
		}
		s = strings.ToLower(s)
		var ss string
		for i := 0; i < len(s); i++ {
			if s[i] == ' ' || ('a' <= s[i] && s[i] <= 'z') {
				ss += string(s[i])
			}
		}
		sss := strings.Split(ss, " ")
		for i := 0; i < len(sss); i++ {
			if sss[i] == W {
				ans++
			}
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n, k, lr = 0, rl = 0, ans = 0;
    string s;
    cin >> n >> k >> s;
    for(int i=0;i<n-1;i++){
        if(s[i] == 'L' && s[i+1] == 'R') lr++;
        if(s[i] == 'R' && s[i+1] == 'L') rl++;
    }
    for(int i=0;i<n-1;i++){
        if(s[i] == 'L' && s[i+1] == 'L') ans++;
        if(s[i] == 'R' && s[i+1] == 'R') ans++;
    }
    for(int i=0;i<k;i++){
        if(lr > 0 && rl > 0){
            ans += 2;
            lr--;
            rl--;
        }
        else if(lr > 0){
            ans++;
            lr--;
        }
        else if(rl > 0){
            ans++;
            rl--;
        }
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	map<string, int> dic;
	int mx = 0;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		mx = max(mx, ++dic[s]);
	}

	vector<string> vec;
	for (auto &it : dic) if (it.Y == mx) vec.push_back(it.X);

	for (auto &i : vec) cout << i << endl;

	return 0;
}

Measured memory_bytes: 25584
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct UnionFind {
	vector<int> par,rank;
	int N;

	UnionFind(int n) {
		N = n;
		par.resize(n);
		rank.resize(n);

		rep(i,n) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x,int y) {
		x = find(x);
		y = find(y);

		if(x == y) return;

		if(rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y) {
		return find(x) == find(y);
	}

	int size() {
		int cnt = 0;
		rep(i,N) if(find(i) == i) cnt++;
		return cnt;
	}
};

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int n,vector<edge> v) {
	sort(v.begin(),v.end());
	UnionFind uf(n);

	int ret = 0;
	rep(i,v.size()) {
		edge e = v[i];
		if(!uf.same(e.from,e.to)) {
			uf.unite(e.from,e.to);
			ret += e.cost;
		}
	}
	return ret;
}

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

	vector<edge> v;
	rep(i, m) {
		int s, t, w;
		cin >> s >> t >> w;
		v.push_back(edge(s, t, w));
	}

	cout << kruskal(n, v) << endl;

	return 0;
}

Measured memory_bytes: 3616
/****************************************************************************************************
                                        SUBMITTED BY-

                                            AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
 bool visited[200003];
  vector<vector<int> >v(200003);
set<int>p;
int dfs(int e)
{
        int sum=0;
        for(int i=0;i<v[e].size();i++)
        {
            if(visited[v[e][i]]==false)
            {
                visited[v[e][i]]=true;
                sum+=1+dfs(v[e][i]);
            }
        }
        return sum;
}

int main()
{
   int n,m;
   cin>>n>>m;
   memset(visited,false,sizeof visited);

   for(int i=0;i<m;i++)
   {
       int a,b;
       cin>>a>>b;
       v[a].pb(b);
       v[b].pb(a);
   }
   int sum=0;
   for(int i=1;i<=n;i++)
   {
       visited[i]=true;
       int d=1+dfs(i);
       if(d>sum)
          sum=d;

   }
   cout<<sum<<"\n";
       return 0;
}


Measured memory_bytes: 23680
#include <stdio.h>

int main(void){
	double a, b, c, d, e, f, x;
	while( scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != -1){
		 x = (c*e-b*f)/(a*e-b*d);
		x += 0.00001;
		printf("%.3lf %.3lf\n", x, (c-a*x)/b);
	}
	return 0;
}

Measured memory_bytes: 656
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    while(true){
	int n = readln().chomp().to!int;
	if(n==0)break;
	int m = readln().chomp().to!int;
	int p = readln().chomp().to!int;
	int d = readln().chomp().to!int;
	string[] s;
	int[11] h;
	for(int i=0;i<11;i++) h[i] = i;
	for(int i=0;i<d;i++){
	    s ~= readln().chomp();
	    for(int j=0;j<n-1;j++){
		if(s[i][j] == '1'){
		    swap(h[j+1],h[j+2]);
		}
	    }
	}
	bool flg = false;
	if(h[p] == m) {
	    writeln(0);
	    flg = true;
	}
	else{
	    for(int i=0;i<d;i++){
		for(int j=0;j<n-1;j++){
		    if(j<n-2 && s[i][j+1] == '1' ) continue;
		    if(j>0 && s[i][j-1] == '1' ) continue;

		    int[11] h1;
		    for(int i1=0;i1<11;i1++) h1[i1] = i1;

		    for(int k=0;k<d;k++){
			for(int l=0;l<n-1;l++){
			    if(s[k][l] == '1' ||(k==i&&l==j)){
				swap(h1[l+1],h1[l+2]);
			    }
			}
		    }
		    if(h1[p]==m){
			flg = true;
			writeln(i+1," ",j+1);
			break;
		    }
		}
		if(flg) break;
	    }
	}
	if(!flg) writeln(1);
    }
}

Measured memory_bytes: 2468
def main():
    N=int(input())
    H=list(map(int,input().split()))
    up=[-1,N-1]
    if N==1:
        print(0)
    else:
        for i in range(0,N-1):
            if H[i]<H[i+1]:
                up.append(i)
        up.sort()
        print(max(up[i+1]-up[i]-1 for i in range(0,len(up)-1)))

if __name__ == '__main__':
    main()

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    atcoder::dsu uf(n);
    for (int i = 0; i < q; ++i) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t) cout << uf.same(u, v) << '\n';
        else uf.merge(u, v);
    }
    return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>             
            int main(void){
                int N;
                int sum = 0;
                scanf("%d",&N);
                int a[N];
                for(int i=0;i<N;i++){
        		scanf("%d",&a[i]);
        		sum = sum + a[i];
        	}
                printf("%d\n",sum-N);
                return 0;
            }

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
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;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n;
	std::cin >> n;
	std::cout << (n+1) * n / 2 << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a[8],b[8],c[8],cnt;
	for(cnt=1;cnt<=7;cnt++){
		scanf("%d %d",&a[cnt],&b[cnt]);
		c[cnt]=a[cnt]-b[cnt];
	}
	for(cnt=1;cnt<8;cnt++)
		printf("%d\n",c[cnt]);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}

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

long long N, M, K;
long long A[210000];
long long B[210000];

int main(void){

    cin >> N >> M >> K;
    for (int i = 1;i <= N;i++) cin >> A[i];
    for (int i = 1;i <= M;i++) cin >> B[i];

    long long TotalA[N+1];
    long long TotalB[M+1];
    int maxA = 0;
    int maxB = 0;

    TotalA[0] = 0;
    TotalB[0] = 0;
    for (int i = 1;i <= N;i++) {
        TotalA[i] = TotalA[i-1] + A[i];
    }
    for (int i = 1;i <= M;i++) {
        TotalB[i] = TotalB[i-1] + B[i];
    }

    int limitB = M;
    for (int i = 0;i <= N ;i++){
        for (int j = limitB; j >= 0;j--){
            if (TotalA[i] + TotalB[j] <= K){
                limitB = j;
                if(maxA + maxB < i + j){
                    maxA = i;
                    maxB = j;
                }
                break;
            }
        }
    }
    
    cout << maxA + maxB << endl;

    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> primes = {2, 3, 5, 7, 11, 13};
  for (int i = 17; i <= n - 1; i += 2) {
    bool is_prime = true;
    for (int j = 0; primes[j] * primes[j] <= i; ++j) {
      if (i % primes[j] == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime)
      primes.emplace_back(i);
  }
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    int k = i;
    int fac = 1;
    for (int j = 0; primes[j] * primes[j] <= k; ++j) {
      if (k % primes[j] == 0) {
        int cnt = 0;
        while (k % primes[j] == 0)
          cnt++, k /= primes[j];
        fac *= (cnt + 1);
      }
    }
    if (k != 1)
      fac *= 2;
    ans += fac;
  }
  cout << ans;
}

Measured memory_bytes: 3900
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		int cnt,num;
		while(cin.hasNext())
		{
			cnt = 0;
			num = cin.nextInt();
			for(int a=0; a<10; a++)
			for(int b=0; b<10; b++)
			for(int c=0; c<10; c++)
			for(int d=0; d<10; d++)
			{
				if(a+b+c+d == num)
				{
					cnt++;
				}
			}		
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int N;

int divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res.size();
}

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

	int ans = 0;
	rep(i, 2, N + 1) {
		if(i % 2 == 0) continue;
		if(divisor(i) == 8) ans++;
	}

	cout << ans << endl;
			
}


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

p=1
if k<=n:
  for i in range(k):
    p=a[p-1]
  print(p)
  exit()

t=[-1]*n
t[0]=0
for i in range(1,n):
  p=a[p-1]
  if t[p-1] !=-1:
    break
  t[p-1]=i

d=i-t[p-1]
k-=i
k%=d
for i in range(k):
  p=a[p-1]
print(p)


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int av[3100];
int as[3100];

int a, b, c, d, e, f;


int main() {
	cin >> a >> b >> c >> d >> e >> f;
	ll bw = 100 * a;
	ll bs = 0;
	av[0] = 1;
	for (int i = 1; i <= f; ++i) {
		if ((i >= 100 * a && av[i - 100 * a]) || (i >= 100 * b && av[i - 100 * b]))
			av[i] = 1;
	}
	as[0] = 1;
	for (int i = 1; i <= f; ++i) {
		if ((i >= c && as[i - c]) || (i >= d && as[i - d]))
			as[i] = 1;
	}
	for (int i = 0; i <= f; ++i)
		for (int j = 0; i + j <= f; ++j) {
			if (av[i] && as[j] && (j <= (i / 100) * e)) {
				if (bs * (i + j) < j * (bs + bw))
					bs = j, bw = i;
			}
		}
	cout << bs + bw << " " << bs << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct Vertex{pair<int, int> mx1; pair<int, int> mx2;};
vector<Vertex> e;
signed main() {
    int n;
    cin >> n;
    int k = 1<<n;
    vector<int> v(k);
    for (int i=0; i < k; i++) cin >> v[i];
    for (int i=0; i < k; i++){
        Vertex t;
        e.push_back(t);
        set<pair<int, int> > ms;
        ms.insert(make_pair(v[i], i));
        ms.insert(make_pair(-1, -1));
        for (int j=0; j < n; j++){
            int ba = (1<<j) & i;
            if (ba == 0) continue;
            int p = i - (1<<j);
            ms.insert(e[p].mx1);
            ms.insert(e[p].mx2);
        }
        set<pair<int, int> > ::iterator it = ms.end();
        it--;
        e[i].mx1 = *it;
        it--;
        e[i].mx2 = *it;
    }
    int ans = 0;
    for (int i=1; i < k; i++){
        ans = max(ans, e[i].mx1.first + e[i].mx2.first);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 13416
#include <bits/stdc++.h>
#define int long long 
using namespace std;
int n,m,k,r[200010],c[200010],v[200010];
int val[3010][3010],dp[3010][3010][5];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for(int i=0;i<k;i++)
	{
		cin>>r[i]>>c[i]>>v[i];
		val[r[i]][c[i]]=v[i];
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j][0]=max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]));
			dp[i][j][1]=max(dp[i][j-1][1],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))+val[i][j]);
			dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+val[i][j]);
			dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+val[i][j]);
		}
	}
	
	cout<<max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])))<<endl;
	
	return 0;
}

Measured memory_bytes: 431472