akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

int n;
int a[maxn],maxd[maxn],smax[maxn], f[maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < (1 << n); i++) scanf("%d", a + i);
	maxd[0] = 0; smax[0] = (1<<n);
	for (int i = 1; i < (1 << n); i++)
	{
		maxd[i] = i; smax[0] = (1 << n);
		for (int j = 0; i >> j; j++) if((i>>j)&1)
		{
			if (a[maxd[i ^ (1 << j)]] > a[maxd[i]])
			{
				smax[i] = maxd[i];
				maxd[i] = maxd[i ^ (1 << j)];
			}
			else if (maxd[i^(1<<j)] != maxd[i] && a[maxd[i ^ (1 << j)]] > a[smax[i]])
			{
				smax[i] = maxd[i^(1<<j)];
			}
		}
	}
	
	for (int i = 1; i < (1 << n); i++)
	{
		f[i] = max(f[i - 1], a[maxd[i]] + a[smax[i]]);
		printf("%d\n", f[i]);
	}
}

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

int main(){
  
 int n;
 cin>>n;
  
 int a;
 int ans = 0;
  
 int mini = INT_MAX;
  
 for(int i=0;i<n;i++){
  cin>>a;
  if(a<=mini)
    ans++;
  mini = min(mini,a);
 }
  
 cout<<ans;
  
}


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int x = 0;
  for (int i = 0; i < k; i++) x += v[i];
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
vector<P> G[1111];
struct st{
  int prev,curr,dist,pass;
  st(){}
  st(int prev,int curr,int dist,int pass):prev(prev),curr(curr),dist(dist),pass(pass){}
  bool operator<(const st &a) const{
    return dist!=a.dist?dist>a.dist:pass>a.pass;
  }
};
struct Point{
  int x,y;
  Point(){}
  Point(int x,int y):x(x),y(y){}
  Point operator+(Point a){return Point(x+a.x,y+a.y);}
  Point operator-(Point a){return Point(x-a.x,y-a.y);}
  Point operator*(int k){return Point(x*k,y*k);}
};
typedef Point Vector;
int abs(Point a){
  return abs(a.x)+abs(a.y);
}
istream &operator>>(istream &is,Point &p){
  is>>p.x>>p.y;
  return is;
}
int cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
bool izryt(Vector a,Vector b){
  return (cross(a,b)<0);
}
 
int dp[1111][1111];
int dp2[1111][1111];
signed main(){
  int m,n;
  while(cin>>m>>n,m||n){
    for(int i=0;i<1111;i++) G[i].clear();
    string s[m];
    Point  p[n];
    for(int i=0;i<m;i++){
      cin>>s[i]>>p[i];
    }
    string a[n],b[n];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    string src,dst;
    cin>>src>>dst;
    map<string,int> ms;
    for(int i=0;i<m;i++) ms[s[i]]=i;
    for(int i=0;i<n;i++){
      G[ms[a[i]]].push_back(P(abs(p[ms[b[i]]]-p[ms[a[i]]]),ms[b[i]]));
      G[ms[b[i]]].push_back(P(abs(p[ms[b[i]]]-p[ms[a[i]]]),ms[a[i]]));
    }
    priority_queue<st> q;
    int INF=1LL<<55LL;
    for(int i=0;i<1111;i++)
      for(int j=0;j<1111;j++)
	dp[i][j]=dp2[i][j]=INF;
    for(P e:G[ms[src]]){
      //cout<<e.first<<" "<<e.second<<endl;
      dp[ms[src]][e.second]=e.first;
      dp2[ms[src]][e.second]=2;
      q.emplace(ms[src],e.second,e.first,2);
    }
    int ans=-1;
    while(!q.empty()){
      st pp=q.top();q.pop();
      int prev=pp.prev,curr=pp.curr,dist=pp.dist,pass=pp.pass;
      //cout<<prev<<" "<<curr<<" "<<dist<<" "<<pass<<endl; 
      if(dp[prev][curr]<dist) continue;
      if(dp[prev][curr]==dist&&dp2[prev][curr]<pass) continue;
      if(curr==ms[dst]){
	ans=dp2[prev][curr];
	break;
      }
      //cout<<prev<<" "<<curr<<" "<<dist<<" "<<pass<<endl; 
      Vector c,d;
      for(P e:G[curr]){
	if(e.second==prev) continue;
	c=p[curr]-p[prev];
	d=p[e.second]-p[curr];
	if(izryt(c,d)) continue;
	if(dp[curr][e.second]<dp[prev][curr]+e.first) continue;
	if(dp[curr][e.second]==dp[prev][curr]+e.first&&
	   dp2[curr][e.second]<=dp2[prev][curr]+1) continue;
	dp[curr][e.second]=dp[prev][curr]+e.first;
	dp2[curr][e.second]=dp2[prev][curr]+1;
	q.emplace(curr,e.second,dp[curr][e.second],dp2[curr][e.second]);
      }
    }
 
    if(ans<0) cout<<"impossible"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 23212
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, K, V[50];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> V[i];

	int ans = 0;
	rep(L, 0, N + 1) rep(R, 0, N + 1) {
		if (N < L + R) continue;
		int rest = K - (L + R);
		if (rest < 0) continue;

		vector<int> has;
		rep(i, 0, L) has.push_back(V[i]);
		rep(i, 0, R) has.push_back(V[N - 1 - i]);
		sort(all(has));

		int n = has.size();
		int sm = 0;
		fore(i, has) sm += i;
		rep(i, 0, min(rest, n)) {
			if (0 < has[i]) break;
			sm -= has[i];
		}
		chmax(ans, sm);
	}
	cout << ans << endl;
}















Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] alpha = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
            long n = long.Parse(Console.ReadLine());
            string result = "";
            do
            {
                n--;
                result = alpha[n % 26] + result;
                n = n / 26;
            } while (n != 0);
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> class RPQ : public priority_queue<T, vector<T>, greater<T>> { };
template<typename C> void dijkstra(int s, vector<pair<int, C>> g[], C d[]) {
	RPQ<pair<C, int>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while(! q.empty()) {
		C   c = q.top().FI;
		int v = q.top().SE;
		q.pop();
		if(d[v] != c) { continue; }
		for(auto & e : g[v]) {
			int ev = e.FI;
			C   ec = e.SE;
			if(setmin(d[ev], d[v] + ec)) { q.emplace(d[ev], ev); }
		}
	}
}

int n, d[200000];
vector<pair<int, int>> g[200000];

int main() {
	cin >> n;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].EB(b, 1);
		g[b].EB(a, 1);
	}
	
	inc(i, n) { d[i] = n + 1; }
	dijkstra(0, g, d);
	auto ma = MP(0, -1);
	inc(i, n) { setmax(ma, MP(d[i], i)); }
	
	inc(i, n) { d[i] = n + 1; }
	dijkstra(ma.SE, g, d);
	ma = MP(0, -1);
	inc(i, n) { setmax(ma, MP(d[i], i)); }
	
	cout << (ma.FI % 3 == 1 ? "Second" : "First") << endl;
	
	return 0;
}


Measured memory_bytes: 17108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  vector<ll> v1, v2, v3, v4;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    v1.push_back(x + y);
    v2.push_back(-x + y);
    v3.push_back(x - y);
    v4.push_back(-x - y);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());
  sort(v4.begin(), v4.end());
  ll ans = v1[v1.size() - 1] - v1[0];
  ans = max(ans, v2[v2.size() - 1] - v2[0]);
  ans = max(ans, v3[v3.size() - 1] - v3[0]);
  ans = max(ans, v4[v4.size() - 1] - v4[0]);
  cout << ans << endl;
}


Measured memory_bytes: 9764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    struct City
    {
        static int idGen = 0;
        public int Id { get;}
        public int Year{ get; }
        public City(int year)
        {
            Year = year;
            Id =idGen++;
        }
    }

    public Program()
    {
        string[] inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        List<City>[] cities = Enumerable.Range(0, n).Select(x => new List<City>()).ToArray();
        foreach(int i in Enumerable.Range(0, m))
        {
            inputs = Console.ReadLine().Split();
            cities[int.Parse(inputs[0]) - 1].Add(new City(int.Parse(inputs[1])));
        }
        string[] result = new string[m];
        foreach(var cs in cities.Select((x ,i) => i))
        {
            int cityId = 1;
            foreach(var city in cities[cs].OrderBy(x => x.Year))
            {
                result[city.Id] = $"{cs + 1:D6}{cityId++:D6}";
            }
        }
        Console.WriteLine(String.Join("\n", result));
    }
    static void Main(string[] args)
    {
        var p = new Program();
    }
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0 && a[i] % 2 == 1) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(void){
  int N; cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, mod;
	cin >> n >> mod;
	vector<int> a(n);
	for (auto &i : a) cin >> i;

	ll ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	a.insert(a.begin(), 0);
	for (int i = 1; i <= n; ++i)
	{
		a[i] += a[i-1];
		a[i] %= mod;

		if (i-mod >= 0) --mp[i-mod - a[i-mod]];
		ans += mp[i-a[i]];
		ans += mp[i-mod-a[i]];
		++mp[i-a[i]];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 19824
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >>arr[i];
    if(is_sorted(arr.begin(), arr.end())){
        cout <<"YES";
        return 0;
    }
    unordered_map<int, int> mp;
    for(int i = 0; i < n; i++){
        if(arr[i] != i + 1){
            mp[i + 1] = arr[i];
        }
    }
    if(mp.size() != 2)
        cout <<"NO";
    else 
        cout <<"YES";
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for(int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += max(0, v[i] - c[i]);
    }
    cout << ans << endl;
}

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

int main(){
  string S, T;
  int size;

  cin >> S;
  cin >> T;
  
  size = S.size();


  for (int i = 0; i < size; i++){
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;


  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#include <map>

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

int main(){
	int n;
	scanf("%d",&n);
	if(n == 3 || n == 5 || n == 7) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprim(int x){
	for(int j=2;j*j<=x;j++){
		if(x%j==0){
			return 0;
		}
	}
	return (x!=1);
}

/*
 _____________              __                ___        ___       __________________________     ____        ____
|             |            /\ \              |   |      |   |     |                          |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |     _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |    |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |    |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |    |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |    |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |    |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |    |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |    |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |    |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |    |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |____|     |____|     |____|          |__|

							<<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
							<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
							<<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>
*/

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	string s,t;
	cin>>s>>t;
	int c=0;
	for(int i =0;i<s.size();i++){
		if(s[i] != t[i])
		c++;
	}
	cout<<c;
	return 0;
}

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

int main() {
    string s;
    int k;
    cin>>s>>k;
    vector<string> v;
    int n=s.size();
    for (int i=0;i<n;i++)
        for (int j=1;j<=k&&i+j<=n;j++)
            v.push_back(s.substr(i,j));
    sort(v.begin(),v.end());
    unique(v.begin(),v.end());
    cout<<v[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc060.contest.atcoder.jp/tasks/arc060_c>
 問題文============================================================
 N 軒のホテルが一直線上に並んでいます。i (1≤i≤N) 番目のホテルは、座標 xi に位置しています。
 
 旅行者である高橋君には、次の 2 つの信念があります。
 
 高橋君の 1 日の移動距離は L を超えない。
 高橋君は野宿をしない。すなわち、1 日の終わりには必ずいずれかのホテルにいなければならない。
 
 Q 個のクエリが与えられます。j (1≤j≤Q) 番目のクエリとして、異なる 2 つの整数 aj, bj が与えられます。
 各クエリについて、前述の信念をともに守った上で、
 高橋君が aj 番目のホテルから bj 番目のホテルに移動するために必要な最小日数を求めてください。
 なお、高橋君が aj 番目のホテルから bj 番目のホテルに移動できることは保証されます。
 =================================================================
 解説=============================================================
 ================================================================
 */

ll check(ll i,ll d,vector<vector<ll>>& next){
    if(d == 0) return i;
    ll k = 0;
    while(d >= (1<<k)) k++;
    return check(next[k-1][i],d - (1<<(k-1)),next);
}
void solve(){
    ll N; cin >> N;
    vector<ll> x(N); for(auto& in:x) cin >> in;
    ll L; cin >> L;
    ll Q; cin >> Q;
    vector<ll> a(Q),b(Q);
    for(int i = 0; i < Q;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        if(a[i] > b[i]) swap(a[i],b[i]);
    }
    
    ll LOG_N = 0;
    while(N >= (1<<LOG_N)) LOG_N++;
    vector<vector<ll>> next(LOG_N+1,vector<ll>(N));
    for(int i = 0; i < N;i++){
        next[0][i] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }
    for(int k = 0; k < LOG_N; k++){
        for(int i = 0; i < N;i++){
            next[k+1][i] = next[k][next[k][i]];
        }
    }
    for(int i = 0; i < Q;i++){
        ll _a = a[i], _b = b[i];
        
        ll l = 0, r = N;
        while(r-l>1){
            ll m = (l+r)/2;
            
//            // a番目の要素のm個次の要素を求める
//            ll p = _a;
//            for(ll k = LOG_N-1; k>=0; k--){
//                if((m>>k)&1){
//                    p = next[k][p];
//                }
//            }
//            if(p >= _b){
//                r = m;
//            }else{
//                l = m;
//            }
            if(check(_a,m,next) >= _b) r = m;
            else l = m;
        }
        cout << r << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 17536
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> dp(1 << n, inf);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        int bit = 0;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            --c;
            bit |= 1 << c;
        }

        dp[bit] = min(dp[bit], a);
        for (int j = 1; j < 1 << n; ++j) {
            dp[bit | j] = min(dp[bit | j], dp[j] + a);
        }
    }

    if (dp[(1 << n) - 1] != inf)
        cout << dp[(1 << n) - 1] << endl;
    else
        cout << -1 << endl;
    return 0;
}

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

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/

	int n,m;
	cin>>n>>m;
	int p=n*3;
	if(p+m>=2)
	{
	cout<<(p+m)/2;
}
else
cout<<"0";


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x7fffffff
#define X first
#define Y second
#define N 210
typedef long long ll;
char s[N];
int main()  {
     scanf("%s", s);
     int n = strlen(s);
     int ans = (n-1) * 9;
     int sum = 0;
     for(int i = 0; i < n; i++)  {
        bool res = true;
        sum += s[i] - '0';
        if (s[i] == '0') continue;
        for(int j = i + 1; j < n; j++) if (s[j] != '9') res = false;
        int tot = (n - i - 1) * 9;
        tot += s[i] - '0';
        if (!res) tot--;
        ans = max(ans, tot);
     }
     ans = max(ans, sum);
     printf("%d", ans);
     return 0;
}


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

int N;
vector<int> A, B;

int main() {
    scanf("%d", &N);
    A.resize(N);
    B.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &A[i], &B[i]);
    }

    long long ans = 0;

    for(int i = N - 1; i >= 0; i--) {
        int R = (ans + A[i]) % B[i];
        if(R == 0) continue;
        ans += B[i] - R;
    }

    printf("%lld", ans);
}


Measured memory_bytes: 1024
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var K = Console.ReadLine().ToInt32();

        var min = 'z';
        var ls = new List<string>();
        var count = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] > min && count >= K)
                continue;
            else
                min = s[i];
            for (int j = i; j < s.Length; j++)
            {
                if (j - i + 1 >= 6)
                    break;
                var sr = s.Substring(i, j - i + 1);
                if (ls.IndexOf(sr) < 0)
                {
                    ls.Add(s.Substring(i, j - i + 1));
                    ls.Sort();
                    ls = ls.Take(K).ToList();
                }
            }
            count++;
        }

        Console.WriteLine(ls[K - 1]);
        Console.ReadLine();
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
}


Measured memory_bytes: 13532
//#pragma GCC optimize(3)
//#pragma comment(linker, "/STACK:102400000,102400000")  //c++
// #pragma GCC diagnostic error "-std=c++11"
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <algorithm>
#include  <iterator>
#include  <iostream>
#include   <cstring>
#include   <cstdlib>
#include   <iomanip>
#include    <bitset>
#include    <cctype>
#include    <cstdio>
#include    <string>
#include    <vector>
#include     <stack>
#include     <cmath>
#include     <queue>
#include      <list>
#include       <map>
#include       <set>
#include   <cassert>

using namespace std;
#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue
 
 

typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 bll;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
typedef pair<int,pii> p3;
 
//priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
//#define endl '\n'
 
#define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A)  //用来压行
#define REP(i , j , k)  for(int i = j ; i <  k ; ++i)
#define max3(a,b,c) max(max(a,b), c);
#define min3(a,b,c) min(min(a,b), c);
//priority_queue<int ,vector<int>, greater<int> >que;
 
const ll mos = 0x7FFFFFFF;  //2147483647
const ll nmos = 0x80000000;  //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f; //18
const int mod = 998244353;
const double esp = 1e-8;
const double PI=acos(-1.0);
const double PHI=0.61803399;    //黄金分割点
const double tPHI=0.38196601;
 
 
template<typename T>
inline T read(T&x){
    x=0;int f=0;char ch=getchar();
    while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
    while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x=f?-x:x;
}
 
 
/*-----------------------showtime----------------------*/

int main(){

            string str;
            cin>>str;
            int len = str.length();
            ll ans = 0;
            ll pre = 0;
            for(int i=0; i<len; i++){
                if(str[i] == 'B') pre++;
                else ans += pre;
            }
            cout<<ans<<endl;
            return 0;
}

Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;
ll K;

P X[MAX_N];

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

    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        X[i] = P(a, b);
    }

    sort(X, X + N);

    int ans;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        if (sum + X[i].second >= K) {
            ans = X[i].first;
            break;
        }
        sum += X[i].second;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CS_AtCoder {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
		public Calc() { }
		public void Solve() {
			int[] NK = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			long ans = NK[1];
			for (int i = 0; i < NK[0]-1; i++) {
				ans *= (NK[1] - 1);
			}
			ans.WL();
			return;
		}
	}
	public static class Utils {
		public static int ReadInt() => int.Parse(Console.ReadLine());
		public static void WL(this object obj) {
			Console.WriteLine(obj);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

const int mod = 10000;

int main(){
  int n,k; cin >> n >> k;
  int sum = 0;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }

  vi v;
  int ans;
  for(int i = 1; i*i <= sum; i++) {
    if(sum%i == 0){
      v.pb(i);
      v.pb(sum/i);
    }
  }

  sort(all(v),greater<int>());

  for(auto num : v) {
    vi na(n);
    int nsum = 0;
    rep(i,n){
      na[i] = a[i]%num;
      nsum += na[i];
    }

    sort(all(na),greater<int>());
    int cnt = 0;
    int nnsum = 0;
    rep(i,n) {
      cnt += num - na[i];
      nnsum += num;
      if(nnsum == nsum) break;
    }
    if(cnt <= k){
      ans = num;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int a,b;
   char op;
        while(1){
          scanf("%d %c %d",&a,&op,&b);
           if( op =='?')
               break;
           else if( op == '+')
               printf("%d\n",a+b);
           else if( op == '-')
               printf("%d\n",a-b);
           else if( op == '*')
               printf("%d\n",a*b);
           else if( op == '/')
               printf("%d\n",a/b);
           }
              return 0;
}


Measured memory_bytes: 2048
package main

import (
  "fmt"
)

func main() {
  var a, b, c, x, count int
  fmt.Scan(&a, &b, &c, &x)
  for i := 0; i < a+1; i++ {
    for j := 0; j < b+1; j++ {
      for k := 0; k < c+1; k++ {
        if i*500+j*100+k*50 == x {
          count++
        }
      }
    }
  }
  fmt.Println(count)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(void){
  int a,b;
  int i,tmp;
  
  while(scanf("%d %d",&a,&b)!=EOF){
    printf("%d\n",(int)log10((float)a+b) + 1);
  }
  
  return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int h, a;
    cin >> h >> a;
    if (h % a == 0) {
        cout << h / a << endl;
    } else {
        cout << h / a + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import collections

n = int(input())
d = {}
for _ in range(n):
    s = input()
    if d.get(s):
        d[s] += 1
    else:
        d[s] = 1
m = 0
ans = []
for k, v in d.items():
    if m < v:
        m = v
        ans = [k]
    elif m == v:
        ans.append(k)
for i in sorted(ans):
    print(i)

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs
************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k; 
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,0,n){
        ll b;
        cin >> b;
        a[i]=b;
    }
    for(int i=k;i<n;++i){
        if(a[i]>a[i-k]){
            cout << "Yes" ENDL;
        }else cout << "No" ENDL;
    }

    // //vector<int> tmp2(k);
    // long double tmp2=1;
    // for(int i=k-1;i>=0;--i){
    //     tmp2=(long double)tmp2*a[i];
    // }
    // //cout << tmp2 ENDL;
    // long double tmp=tmp2;
    // long double tmp1=1;
    // rep(i,k,n){
    //     //ll tmp1=1;
    //     if(i==k){
    //         tmp1=tmp2;
    //         tmp1=(long double)tmp1*a[i];
    //         tmp1=(long double)tmp1/a[i-k];
    //         //cout << tmp1 << " " << i ENDL;
    //         if(tmp1>tmp2){
    //             cout << "Yes" ENDL;
    //             tmp=tmp1;
    //         }else{
    //             cout << "No" ENDL;
    //             tmp=tmp1;
    //         }
    //     }else {
    //         //tmp1=1;
    //         tmp1=(long double)tmp1*a[i];
    //         tmp1=(long double)tmp1/a[i-k];
    //         //cout << tmp1 << " " << i ENDL;
    //         if(tmp1>tmp){
    //             cout << "Yes" ENDL;
    //             tmp=tmp1;
    //         }else{
    //             cout << "No" ENDL;
    //             tmp=tmp1;
    //         }
    //     }
    // }
    
    return 0;
}

Measured memory_bytes: 7164
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 100000+10
typedef long long LL;
int N,M,cur,temp;
priority_queue<int> p;
LL ans=0;

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++){
	    scanf("%d",&cur);
		p.push(cur);	
	}
	while(M--){
        temp = p.top();
        temp /= 2;
        p.pop();
        p.push(temp);
	}
	while(!p.empty()){
		ans += p.top();
		p.pop();
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main() {
  for(int tci = 0; ; tci++) {
    int W,H; scanf("%d%d", &W, &H); if(W==0) break;
    static char tbl[60][30];
    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        scanf(" %c", &tbl[y][x]);
      }
    }
    static int tim[60][30][2];
    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        tim[y][x][0] = tim[y][x][1] = -1;
      }
    }
    priority_queue<pair<pair<int,int>,pair<int,int> > > pq;
    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        if(tbl[y][x]=='S') {
          pq.push(make_pair(make_pair(0,0),make_pair(y,x)));
          pq.push(make_pair(make_pair(0,1),make_pair(y,x)));
        }
      }
    }
    int score = -1;
    while(!pq.empty()) {
      int t = pq.top().first.first;
      int d = pq.top().first.second;
      int y = pq.top().second.first;
      int x = pq.top().second.second;
      pq.pop();
      if(tim[y][x][d]!=-1) continue;
      tim[y][x][d]=-t;
      if(tbl[y][x]=='T') {
        score = -t;
        break;
      }
      for(int yy = max(0,y-3); yy <= min(H-1,y+3); yy++) {
        for(int xx = max(0,x-3); xx <= min(W-1,x+3); xx++) {
          bool ok = abs(yy-y)+abs(xx-x)<=3;
          if(d==0) ok = ok && x < xx;
          if(d==1) ok = ok && x > xx;
          ok = ok && tbl[yy][xx] != 'X';
          if(ok) {
            int cost = ('0' <= tbl[yy][xx] && tbl[yy][xx] <= '9') ? tbl[yy][xx]-'0' : 0;
            pq.push(make_pair(make_pair(t-cost,d^1),make_pair(yy,xx)));
          }
        }
      }
    }
    printf("%d\n", score);
  }
  return 0;
}

Measured memory_bytes: 1156
s = list(input())

def conditionA(s_list):
    return s[0] == "A"

def conditionC(s_list):
    return "C" in s_list[2:-1]

def conditionLower(s_list):
    return sum([e.isupper() for e in s_list]) == 2

if conditionA(s) and conditionC(s) and conditionLower(s):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int b = 1;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] == a[i]) b = 0;
    }

    cout << (b ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  long long K;
  cin>>N>>K;
  int A[200001],memo[200001];
  for(int i=1;i<=N;i++){
    cin>>A[i];
    memo[i]=0;
  }
  int loop=0;
  int x=1;
  memo[1]=1;
  for(int i=1;i<=N;i++){
    x=A[x];
    loop++;
    memo[x]++;
    if(memo[x]==2) i+=300000;
  }
  int cost=0;
  int y=1;
  if(x!=1){
  while(y!=x){
    cost++;
    y=A[y];
  }
  }
  loop-=cost;
  int answer=1;
  if(K<cost){
    for(int i=0;i<K;i++){
      answer=A[answer];
    }
  }
  else{
    K=(K-cost)%loop;
    answer=x;
    for(int i=0;i<K;i++){
      answer=A[answer];
    }
  }
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 5200
$ans = Array.new(4).map{Array.new(4,0)}

$relational =  Array.new(4).map{Array.new(2,0)}
#$relational =[[-2,1],[-1,1],[1,1],[1,2]]
#$relational = [[1,0], [2,1],[2,2],[3,3]]

def calc(x,y) #,x2,y2,x3,y3,x4,y4)
	
	if (x == 4) then
		$count += 1
	elsif ($ans[x][y] == 1) then
		if y == 3 then
			calc(x+1,0)
		else
			calc(x,y+1)
		end
	else
		$ans[x][y] = 1
		for re in $relational
			rx = x + re[1]
			ry = y + re[0]
			if (rx < 4) && (ry < 4) && (rx >= 0) && (ry >= 0) && ($ans[rx][ry] == 0) then
				$ans[rx][ry] = 1
				
				if y == 3 then
					calc(x+1,0)
				else
					calc(x,y+1)
				end
				$ans[rx][ry] = 0
			else
				#
			end
		end
		$ans[x][y] = 0
	end

end

loop{
	line = gets
	if line==nil then
		break
	end
	sp = line.split(nil)
	
	if sp.count() != 8 then
		break
	else
		$count = 0
		$relational = [[sp[0].to_i,sp[1].to_i],[sp[2].to_i,sp[3].to_i],[sp[4].to_i,sp[5].to_i],[sp[6].to_i,sp[7].to_i]]
		calc(0,0)
		print $count
		print("\n")
	end
}

Measured memory_bytes: 6120
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N=INT()
S=input()
if N<3:
  print(0)
  exit()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b
for i in range(N-2):
  for j in range(i+1,N-1):
    k=j*2-i
    if k>=N:
      continue
    if S[j]!=S[i] and S[k]!=S[i] and S[j]!=S[k]:
      ans-=1
print(ans)

Measured memory_bytes: 74392
#include<bits/stdc++.h>
using namespace std;
signed main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long sum1,sum2,ans1,ans2;
    sum1=a*c;
    sum2=a*d;
    ans1=b*c;
    ans2=b*d;
    if(sum1<sum2 && ans1<sum2 && ans2<sum2){
        cout<<sum2<<endl;
    }else if(sum2<sum1 && ans1<sum1 && ans2<sum1){
        cout<<sum1<<endl;
    }else if(sum1<ans1 && sum2<ans1 && ans2<ans1){
        cout<<ans1<<endl;
    }else{
        cout<<ans2<<endl;
    }
    return(0);
}

Measured memory_bytes: 3532
def route_num(stairs):
    if stairs <= 1:
        return 1
    else:
        return route_num(stairs - 1) + route_num(stairs - 2)

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

broken = {i:False for i in range(n + 1)}
for a_i in a:
    broken[a_i] = True

route_num = {}
for i in range(n + 1):
    if broken[i]:
        route_num[i] = 0
    elif i <= 1:
        route_num[i] = 1
    else:
        route_num[i] = (route_num[i-1] + route_num[i-2]) % 1000000007

print(route_num[n])


Measured memory_bytes: 34280
use std::io;

fn main() {
	let mut num: i8 = 0;
	let mut s = String::new();

	io::stdin().read_line(&mut s).unwrap();

	s = s.trim().to_string();

	for op in s.chars() {
		if op == '+' {
			num += 1;
		} else {
			num -= 1;
		}
	}

	println!("{}", num);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}
 
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
 
// Problem Specific Parameter:
const ll inf=1LL<<50;
 

//Appropriately Changed
using W = ll;
using edge = struct {int to, rev; W cap, flow;};
using G = vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph, int from, int to, W cap) {
    graph[from].push_back({to, int(graph[to].size()) , cap , 0});
    graph[to].push_back({from, int(graph[from].size()) - 1, 0 , 0});
}


W dinic(G &graph, int s, int t) {
    const int n = graph.size();
    vector<int> level(n), iter(n);

    auto bfs = [&](int s, int t) {
        fill(begin(level), end(level), -1);
        queue<int> q;
        level[s] = 0, q.push(s);

        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (auto &e : graph[v]) {
                if (level[e.to] == - 1 and e.cap > e.flow) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
        return (level[t] !=  -1);
    };

    auto dfs = [&](int v, int t, W f) {
        auto func = [&](int v, int t, W f, auto func)->W{

            if (v == t) return f;
            for (int &i = iter[v]; i < graph[v].size(); i++) {
                edge &e = graph[v][i];

                if (e.cap > e.flow and level[v] < level[e.to]) {

                    W d = func(e.to, t, min(f, e.cap - e.flow), func);

                    if (d > 0) {
                        e.flow += d, graph[e.to][e.rev].flow -= d;
                        return d;
                    }
                }
            }

            return 0;
        };
        return func(v, t, f, func);
    };

    while (bfs(s, t)) {
        fill(begin(iter), end(iter), 0);
        while (dfs(s, t, inf) != 0 );
    }

    W ret = 0;
    for (auto &e : graph[s]) ret += e.flow;
    return ret;
}
 
int main(void){
    int v,e;
    cin >> v >> e;
    G graph(v);
    rep(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        add_edge(graph,a,b,c);
    }
    cout << dinic(graph,0,v-1) << endl;
    return 0;
}

Measured memory_bytes: 3216
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    string S; cin >> S;
    vector<char> az(26);
//    vector<bool> a

    REP(i, 26) az.at(i) = 'a' + i;
    REP(i, 26) if(S.find(az.at(i)) == string::npos){
        cout << az.at(i);
        return 0;
    }else if(i >= 25){
        cout << "None";
    }

    return 0;
}

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

int main() {
    ios::sync_with_stdio( 0 );
    cin.tie( 0 );
    int n;
    bool f = true;
    cin >> n;

    while ( n-- ) {
        int k ;
        cin >> k;

        if ( !( k % 2 ) && k % 6 && k % 10 ) f = false;
    }

    if ( f ) cout << "APPROVED";
    else cout << "DENIED";

    return 0;
}


Measured memory_bytes: 3652
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N, X = inpl()

ALL, P = [1], [1]
for _ in range(N):
    ALL.append(ALL[-1] * 2 + 3)
    P.append(P[-1] * 2 + 1)


# | B (X = ALL[N])
# |
# | N - 1バーガー(上)
# |
# | P (X = ALL[N] // 2 + 1)
# |
# | N - 1バーガー(下)
# |
# | B (X = 1)
def func(N, X):
    if N == 0:  # レベル0バーガー
        return 1
    if X == 1:  # 下のB
        return 0
    elif X == ALL[N]:  # 上のB
        return P[N]
    elif X == ALL[N] // 2 + 1:  # 真ん中のP
        return P[N - 1] + 1
    else:
        if X < ALL[N] // 2 + 1:  # 下のN - 1バーガー
            return func(N - 1, X - 1)
        else:  # 上のN - 1バーガー
            return func(N - 1, X - ALL[N] // 2 - 1) + P[N - 1] + 1


print(func(N, X))


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64
    }

    println!("{}", if n % dsum(n) == 0 {"Yes"} else {"No"});
}

fn dsum(mut n: u64) -> u64 {
    let mut ret = 0;
    while n > 0 {
        ret += n % 10;
        n /= 10;
    }
    ret
}

Measured memory_bytes: 4352