akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n;
vector<int> a;
long long int p, m;
long long int ans;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		int t;
		scanf("%d", &t);
		a.push_back(t);
	}

	long long int b = 0;
	for(int i=0; i<n; ++i){
		b += a[i];
		if(i%2==0){
			if(b<=0){
				p+=1-b;
				b=1;
			}
		}else{
			if(b>=0){
				p+=1+b;
				b=-1;
			}
		}
	}
	b = 0;
	for(int i=0; i<n; ++i){
		b += a[i];
		if(i%2!=0){
			if(b<=0){
				m+=1-b;
				b=1;
			}
		}else{
			if(b>=0){
				m+=1+b;
				b=-1;
			}
		}
	}
	ans = min(p, m);
	printf("%lld\n", ans);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int Q;
  cin >> Q;
  REP(q, Q) {
    lint A, B;
    cin >> A >> B;
    lint l = min(A, B) - 1;
    lint r = max(A, B) + 1;
    while(r-l > 1) {
      lint m = (l+r) / 2;
      if(m*m < A*B) {
        l = m;
      } else {
        r = m;
      }
    }
    lint ans = 0;
    if(l*(l+1) < A*B) {
      ans =  2*l-1;
    } else {
      ans = 2*(l-1);
    }
    if(A == B) ans++;
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    ll n; cin >> n;
    vector<ll> t(n);
    vector<ll> x(n);
    vector<ll> y(n);
    bool yes = true;
    for(ll i = 0;i < n;i++){
        ll t,x,y;
        cin >> t >> x >> y;
        if(t % 2 != (x + y) % 2 || t < x + y){
            yes = false;
        }
    }
    if(yes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

class max_flow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};
	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	int DFS(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	max_flow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

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

    int v,e;cin>>v>>e;
    max_flow mf(v);
    for(int i=0;i<e;i++){
        int u,v,c;cin>>u>>v>>c;
        mf.add(u,v,c);
    }
    cout<<mf.dinic(0,v-1)<<endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;



class UnionFindTree {
private:
	static const int MAX_N = 100002;
	int par[MAX_N], ran[MAX_N];
	int con_size[MAX_N];

public:
	UnionFindTree(int n) {
		if (n > MAX_N) cerr << "INVALID INPUT" << endl;
		for (int i = 0; i < n; i++) {
			par[i] = i;
			ran[i] = 0;
			con_size[i] = 1;
		}
	}

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

public:
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

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

	int size(int x) {
		return con_size[find(x)];
	}

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

UnionFindTree uft(100001);

int main() {
	int n, m; cin >> n >> m;
	vector<pair<int, int>> q(m);
	for (int i = 0; i < m; i++) {
		cin >> q[i].first >> q[i].second;
		q[i].first--; q[i].second--;
	}
	vector<ll> ans(m);
	ll sum = (ll)n*(n - 1)/2;
	for (int i = m - 1; i >= 0; i--) {
		ans[i] = sum;
		int a = q[i].first, b = q[i].second;
		if (!uft.same(a, b)) {
			ll aa = uft.size(a), bb = uft.size(b);
			sum += aa * (aa - 1) / 2 + bb * (bb - 1) / 2;
			uft.unite(a, b);
			ll t = uft.size(a);
 			sum -= t * (t - 1) / 2;
		}
	}
	for (int i = 0; i < m; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int A, B;
	cin >> A>> B;
	if (B == 1)cout << 0 << endl; else
	{
		for (int i = 1; i < 23; i++) {
			if (i == 1)B -= A;
			else B -= A - 1;
			if (B <= 0) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
		long long n,a,b;
		cin >> n >> a >> b;
		if (a > b)
		{
				cout <<0;
				exit(0);
		}
		if (n == 1 && a != b)
		{
				cout <<0;
				exit(0);
		}
		if (n <= 2)
		{
				cout <<1;
				exit(0);
		}
		cout <<(n-2)*b - (n-2)*a + 1;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
struct node {
    int st,en,id,ans;
}q[500010];
int cmp(struct node a,struct node b){
    return a.en<b.en;
}
int cmp1 (struct node a,struct node b){
    return a.id<b.id;
}
int cal[500010];
int lowbit(int x) {return x&(-x);}
int getsum(int x){
    int s=0;
    for(;x>0;x-=lowbit(x)) s+=cal[x];
    return s;
}
void update(int x,int value){
    for(;x<=500005;x+=lowbit(x)) cal[x]+=value;
}
int n,Q;
int a[500010];
int main()
{
    map<int,int>mp;
    int i;
    scanf("%d%d",&n,&Q);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=Q;i++){
        scanf("%d%d",&q[i].st,&q[i].en);
        q[i].id=i;
    }
    sort(q+1,q+Q+1,cmp);
    int temp=1;
    for(i=1;i<=Q;i++){
            while(temp<=q[i].en){
                if(mp[a[temp]]!=0){
                    update(mp[a[temp]],-1);
                }
                mp[a[temp]]=temp;
                update(temp,1);
                temp++;
            }
            q[i].ans=getsum(q[i].en)-getsum(q[i].st-1);
    }
    sort(q+1,q+1+Q,cmp1);
    for(i=1;i<=Q;i++){
        printf("%d\n",q[i].ans);
    }
    return 0;
}

Measured memory_bytes: 38880
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

int main(){
	fastio;
	 ll n,a,b;
	 cin>>n>>a>>b;
	 if(a > b)
	 	swap(a,b);
	 ll ans;
	 if((b-a)%2 == 0)
	 	ans = (b-a)/2;
	 else{
	 	ll t1=0, t2=0;
	 	t1 += a-1;
	 	t1++;
	 	t1 += (b-a-1)/2;

	 	t2 += n-b;
	 	t2++;
	 	t2 += (b-a-1)/2;
	 	ans = min(t1,t2);
	 }
	 cout<<ans;
}

Measured memory_bytes: 3576
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, K;
    cin >> N >> K;
    ll K2 = K * 2;
    struct Wish {
        ll x;
        ll y;
    };
    vector<Wish> wishes;
    wishes.reserve(N);
    rep(i,0,N) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            x += K;
        }
        x = x % K2;
        y = y % K2;
        wishes.push_back(Wish{x, y});
    }
    vector<ll> grid(K2 * K2);
    rep(w,0,N) {
        Wish& wish = wishes[w];
        rep(p,0,2) {
            grid[(wish.x)%K2   + ((wish.y)%K2)  *K2] += 1;
            grid[(wish.x+K)%K2 + ((wish.y)%K2)  *K2] -= 1;
            grid[(wish.x)%K2   + ((wish.y+K)%K2)*K2] -= 1;
            grid[(wish.x+K)%K2 + ((wish.y+K)%K2)*K2] += 1;
            if (wish.x + K >= K2) {
                grid[(0)%K2 + ((wish.y)%K2)    *K2] += 1;
                grid[(0)%K2 + ((wish.y+K)%K2)  *K2] -= 1;
            }
            if (wish.y + K >= K2) {
                grid[(wish.x  )%K2 + ((0)%K2)*K2] += 1;
                grid[(wish.x+K)%K2 + ((0)%K2)*K2] -= 1;
            }
            if (wish.x + K >= K2 && wish.y + K >= K2) {
                grid[(0)%K2 + ((0)%K2)*K2] += 1;
            }
            wish.x += K;
            wish.x = wish.x % K2;
            wish.y += K;
            wish.y = wish.y % K2;
        }
    }
    rep(y,0,K2) {
        rep(x,1,K2) {
            grid[x+y*K2] += grid[(x-1)+y*K2];
        }
    }
    rep(x,0,K2) {
        rep(y,1,K2) {
            grid[x+y*K2] += grid[x+(y-1)*K2];
        }
    }
    ll mn = numeric_limits<ll>::max();
    ll mx = numeric_limits<ll>::min();
    rep(x,0,K2) {
        rep(y,0,K2) {
            mn = min(mn, grid[x+y*K2]);
            mx = max(mx, grid[x+y*K2]);
        }
    }
    cout << ((mx - mn) + N) / 2 << endl;
}

Measured memory_bytes: 33024
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int a[1024][1024];

bool solve(int X, int Y, int w, int h)
{
	if(X%w == 0)
		return false;
	
	for(int y=0; y<Y; y+=1)
		for(int x=0; x<X; x+=w)
		{
			a[y][x] = 1000;
			for(int xx=x+1; xx<x+w; ++xx)
				a[y][xx] = 0;
			a[y][x+w-1] = -1001;
		}
	
	return true;
}

int main()
{
	ios::sync_with_stdio(false);

	int X, Y, w, h;
	cin >> Y >> X >> h >> w;

	int ans = 0;
	
	if(!(ans = solve(X, Y, w, h)))
	{
		ans = solve(Y, X, h, w);
		for(int y=0; y<max(X,Y); ++y)
			for(int x=y+1; x<max(X,Y); ++x)
				swap(a[x][y], a[y][x]);
	}
	
	if(ans)
	{
		cout << "Yes\n";
		for(int y=0; y<Y; ++y)
		{
			//cout << a[y][0];
			for(int x=0; x<X; ++x)
				cout << a[y][x] << " ";
			cout << "\n";
		}
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

ll modpow(ll a, ll n, ll mod) { // a^n % mod
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> m >> n;
    cout << modpow(m, n, MOD) << endl;
}



Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[110];
    rep(i, N) cin >> a[i];
    int ans = INF;
    REP(i, -100, 100) {
        int tmp = 0;
        rep(j, N) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout <<ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

bool solve(char *s) {
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i+1]) return false;
  }
  return true;
}

int main() {
  char s[10];
  cin >> s;
  printf("%s\n", solve(s) ? "Good" : "Bad");
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <iostream>

using namespace std;

namespace {

struct Process {
  char name[10];
  // required time to process this task.
  int time;
};

// Ring-buffer based queue. Enqueue and dequeue run in O(1).
template <int N>
class Queue {
 public:
  // Note: leave one element empty so that we can distinguish
  // that the ring buffer is empty or full.
  Queue() : size_(N + 1), head_(0), tail_(0) {}

  void Enqueue(Process p) {
    assert(!IsFull());
    data_[tail_] = p;
    tail_ = next(tail_);
  }

  Process Dequeue() {
    assert(!Empty());
    auto p = data_[head_];
    head_ = next(head_);
    return p;
  }

  bool IsFull() const { return head_ == next(tail_); }

  bool Empty() const { return head_ == tail_; }

 private:
  int next(int a) const { return (a + 1) % size_; }

  Process data_[N + 1];
  const int size_;
  int head_;
  int tail_;
};

}  // namespace

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

  Queue<100000> queue;
  for (int i = 0; i < n; ++i) {
    Process p;
    cin >> p.name >> p.time;
    queue.Enqueue(p);
  }

  int current_time = 0;
  while (!queue.Empty()) {
    auto p = queue.Dequeue();
    const int used = min(p.time, q);
    p.time -= used;
    current_time += used;

    if (p.time <= 0) {
      printf("%s %d\n", p.name, current_time);
      continue;
    }
    queue.Enqueue(p);
  }
  return 0;
}

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

int main(void)
	
{
	
	char a[6],b[6],i_str[6];
	int a_suu,b_suu,i,n,m,cnt = 0,hen,x,o;
	
	
	scanf("%s %s",&a,&b);
	
	a_suu = atoi(a);
	b_suu = atoi(b);
	

	for(i = a_suu; i <= b_suu; i++){
		
		n = 0;
		m = 4;
		
		//i_str = i;
		
		x = 0;
		o = i;
		
		for(hen = 10000; hen > 0; hen = hen/10){
			
			i_str[x] = o / hen;
			o = o % hen;
			x++;
			
		}
			
		
		while(i_str[n] == i_str[m] && n < m){
			n++;
			m--;
		}
		
		if(n == 2 && m == 2){
			cnt++;
		}
		
	}
	
	printf("%d",cnt);
	
	return 0;
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
#define cppio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;

const int maxn=2e3+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

VI edge[maxn];

ll num[maxn];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=3;i<=n;i++){
		num[i]=1;
	}
	for(int i=3;i<=n;i++){
		for(int j=3;j<=n-i;j++){
			num[i+j]=(num[i+j]+num[i])%mod;
		}
	}
	printf("%lld",num[n]);
	return 0;
}


Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);
    	int N = sc.nextInt();
    	long K = sc.nextLong();
    	int[] A = new int[N+1];
    	for(int i=1;i<=N;i++) {
    		A[i] = sc.nextInt();
    	}

    	int now = 1;
    	int count = 0;
    	int[] visited_town_list = new int[N+1];

    	boolean loopnotfound = true;

    	int firstvisit = 0;
    	int secondvisit = 0;

    	while(loopnotfound) {
    		count = count + 1;
    		int next = A[now];
    		if(visited_town_list[next] == 0) {
        		visited_town_list[next] = count;
        		now = next;
    		}
    		else {
    			firstvisit = visited_town_list[next];
    			secondvisit = count;
    			loopnotfound = false;
    		}
    	}
//    	System.out.println("first:"+firstvisit);
//    	System.out.println("second:"+secondvisit);
    	int ans = 0;
    	if(K>=firstvisit) {
        	int q = (int) ((K-firstvisit+1)%(secondvisit-firstvisit));
        	for(int i =1;i<N+1;i++) {
        		//ループに入る前のものは無視
        		if(visited_town_list[i]>=firstvisit) {
        			//
        			if((visited_town_list[i]-firstvisit+1)%(secondvisit-firstvisit)==q) {
        				ans = i;
        			}
        		}
        	}

    	} else {
    		for(int i=1;i<N+1;i++) {
    			if(visited_town_list[i]==K) {
    				ans = i;
    			}
    		}
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 50000
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;


#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
    };


int main() {

    vector<vector<vi>> A(3,vector<vi>(3,vi(2))); 

    REP(i,3)REP(j,3){
        cin >> A[i][j][0];
    }

    int N;

    cin >> N;

    vi b(N);

    REP(i,N)cin >> b[i];

    REP(k,9){
        REP(i,3)REP(j,3){
         if(b[k] == A[i][j][0])A[i][j][1]=1;
        }
    }

    bool flag = false;

    if(A[0][0][1] ==1 && A[0][1][1] ==1 && A[0][2][1] == 1)flag = true;
    if(A[1][0][1] ==1 && A[1][1][1] ==1 && A[1][2][1] == 1)flag = true;
    if(A[2][0][1] ==1 && A[2][1][1] ==1 && A[2][2][1] == 1)flag = true;
    if(A[0][1][1] ==1 && A[1][1][1] ==1 && A[2][1][1] == 1)flag = true;
    if(A[1][0][1] ==1 && A[0][0][1] ==1 && A[2][0][1] == 1)flag = true;
    if(A[0][2][1] ==1 && A[1][2][1] ==1 && A[2][2][1] == 1)flag = true;
    if(A[0][0][1] ==1 && A[1][1][1] ==1 && A[2][2][1] == 1)flag = true;
    if(A[0][2][1] ==1 && A[1][1][1] ==1 && A[2][0][1] == 1)flag = true;

    cout << ((flag)?"Yes":"No") << endl;

    return 0;
}

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

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

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int b[n];
    int mid;
    if (n % 2 == 1) {
        mid= (n + 1) / 2 - 1;
        b[0] = a[mid];
        if (a[mid] - a[mid - 1] < a[mid + 1] - a[mid]) {
            for (int i = 0; i < mid; ++i) {
                b[(i + 1) * 2] = a[i];
                b[i * 2 + 1] = a[n - 1 - i];
            }
        } else {
            for (int i = 0; i < mid; ++i) {
                b[(i + 1) * 2] = a[n - 1 - i];
                b[i * 2 + 1] = a[i];
            }
        }
    } else {
        mid= n / 2;
        for (int i = 0; i < mid; ++i) {
            b[i * 2 + 1] = a[i];
            b[i * 2] = a[mid + i];
        }
    }

    long long sum = 0;
    for (int i = 1; i < n; ++i) {
        sum += (long long)abs(b[i - 1] - b[i]);
    }

    cout << sum << '\n';

    return 0;
}


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

int main(){

  int W, H, x, y, r;
  bool flag = true;

  cin >> W >> H >> x >> y >> r;

  if( (W < x+r) || (x-r < 0) ) flag = false;
  if( (H < y+r) || (y-r < 0) ) flag = false;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



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

int h[100002];

int dp[100002];

int solve(int i, int n) {
    if(i == n )
        return dp[i] = 0;
    if(dp[i]!=-1)
        return dp[i];
    int ans ;
    if(i == n-1)
        ans = abs(h[n] - h[n-1]);
    else
        ans = min( 
            
            abs(h[i] - h[i+1]) + solve(i+1, n), 
            abs(h[i] - h[i+2])  + solve(i+2, n));
        
        return dp[i] = ans;
}
int main() {
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)   cin>>h[i], dp[i] = -1;
	int ans = solve(1, n);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001];
int main()
{
	ll n; cin >> n;
	ll maxA = 0;
	rep(i, 0, n) {
		cin >> a[i];
		if (maxA <= a[i]) {
			maxA = a[i];
		}
	}

	ll minV = 1e20;
	ll minIndex = 0;
	rep(i, 0, n) {
		if (a[i] != maxA) {
			if (minV >= abs(2 * a[i] - maxA)) {
				minV = abs(2 * a[i] - maxA);
				minIndex = i;
			}
		}
	}
	cout << maxA << " " << a[minIndex] << endl;

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
s=0
N=int(input())
#Nori=N
#D, N=input().split()
#S=input()
#T=input()
#S_list=list(S)
factor_list=  list(map(int, input().split(" ")))
def deletef(j):#関数は必ずreturnすること
    if j%2 ==0:
      return  j/2
    else:
        j=0
        return j

for i in range (10**13):
 factor_list = list(map(deletef ,factor_list))
 b = [x for x in factor_list if x >= 1]
 factor_list=b
 s=s+len(b)
 if len(b)==0:
     break
print(s)

#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1])
#D=int(D)
#N=int(N)
#不本意だが内包表記で二次元の空のリストを作成する
     
#dp=[['' for i in range(2)] for j in range(N)]
#absTH=[''for i in range(N)]
#K=int(K)
#S_list=[]
#sentence_list=[]
#total=0
#mojiretu=""
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#weight_value_list =  [list(input())for i in range(N)]#一文字づつばらして入れてしまう
#s = [input() for i in range(N)]
#複数行に複数の入力値を取得し、出力する
#sentence_list =  (list(input())for i in range(N))
#for i in range(H):
#  ppixel_list=list(input())
    
#print(pixel_list)
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる
#print(a_list)
first_term=0
second_term=0
#整数二次元配列を読み込む時のやり方
#a_b_c_list =  [list(map(int, input().split(" ")))for i in range(N)]
     
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
  
     
#x, y = [0]*N, [0]*N#N個の空のリストを作成
#l = list(range(N))#範囲がNのリストを作成する
     
#for i in range(N):
#  x[i], y[i] = map(int, input().split())
#分けて入力する形式を設定することで可読性が高く仕上がっている
#素晴らしいことだ
     
     
distance = 0
#comb = list(itertools.permutations(l))
#prmutation:英語の意味としては順列である
'''p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
'''
#for i in range(0, len(comb)):#i番目のパターンの時を考える。
#  for j in range(0, N-1):#lのリスト番号を読み込み
#    distance += math.sqrt((x[comb[i][j]]-x[comb[i][j+1]])**2 + (y[comb[i][j]]-y[comb[i][j+1]])**2)
'''
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
'''
#print(distance/len(comb))
# dp[i+1][j]=max(dp[i][j]+a_b_c_list[i],dp[i][j],dp[i][j])
#リストを一周するようにすればいいのか


Measured memory_bytes: 4212
#include <iostream>
#include <cmath>

int main(){
   long long int A, B, C;
   std::cin >> A >> B >> C;
   if ((A%2==0) || (B%2==0) || (C%2==0)){
      std::cout << 0 << std::endl;
   } else{
      long long int tmpA = std::abs((A*B*(C/2))-(A*B*(C-C/2)));
      long long int tmpB = std::abs((B*C*(A/2))-(B*C*(A-A/2)));
      long long int tmpC = std::abs((C*A*(B/2))-(C*A*(B-B/2)));
      std::cout << std::min(std::min(tmpA, tmpB), tmpC) << std::endl;
   }
}



Measured memory_bytes: 3600
n = int(input())
arr = []
for i in range(n):
    na = int(input())
    ar0 = []
    for j in range(na):
        x,y = map(int,input().split())
        ar0.append([x-1,y])
    arr.append(ar0)


#1：正直者
#0：嘘つき
#最大数
ans=0
#全探索
for i in range(1<<n):
    #全候補
    c_list=[]
    for j in range(n):
        c_list.append((i>>j)%2)

    check=1
    for j in range(n):
        #1ならばTrue
        if c_list[j]:
            
            for z in arr[j]:
                
                if c_list[z[0]]!=z[1]:
                    check=0
    if check:
        ans=max(ans,sum(c_list))
print(ans)

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

using namespace std;
int main()
{
int n,x,t;
  cin>>n;
  cin>>x;
  cin>>t;
 
  if((n%x)==0)
  {
    cout<<(n/x)*t;
  }
  else
  {
    cout<<(n/x+1)*t;
  }
  
  return 0;
}

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

int main()
{
  vector<int> divisor8_count(201);
  rep(i, 201)
  {
    if (i % 2 == 0)
      continue;
    int count = 0;
    for (int num = i; num > 0; num--)
    {
      if (i % num == 0)
        count++;
    }
    if (count == 8)
      divisor8_count[i]++;
    //    cout << i << "->" << divisor8_count[i] << endl;
  }
  rep(i, 200) divisor8_count[i + 1] += divisor8_count[i];
  int N;
  cin >> N;
  int ans = divisor8_count[N];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
function main(input){
  const lines = input.split('\n');

  const N = parseInt(lines[0]);
  const S = lines[1].split('');

  
  var result = Math.pow(10, 8);
  var current_count = 0;
  for(var i=1;i<N;i++){
    if(S[i]=='E'){current_count++;}
  }
  result = current_count;

//    console.log(current_count);
  for(var i=1;i<N;i++){
    if(S[i]=='E'){current_count--;}
    if(S[i-1]=='W'){current_count++;}
    result = Math.min(result, current_count);
//    console.log(current_count);
  }
//    console.log('---');

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11084
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    ll cnt=0;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='o') cnt++;
    }
    if((15-s.size()+cnt)>=8) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 999999937;
ll _MOD = 1000000009;
double EPS = 1e-10;

int mod_inv(ll x, int M) {
	int t = M - 2, y = 1;
	for (; t; t>>=1) {
		if (t & 1) y = y * x % M;
		x = x * x % M;
	}
	return y;
}

struct rolling_hash {
	int M;
	vector<int> a, b;
	rolling_hash(string s, int _M) {
		M = _M;
		int N = s.length();
		a.resize(N + 1);
		ll x = 1;
		for (int i = 0; i < N; i++) {
			a[i + 1] = (a[i] + x * s[i]) % M;
			x = x * 256 % M;
		}
		ll inv = mod_inv(256, M);
		b.resize(N + 1);
		b[0] = 1;
		for (int i = 0; i < N; i++)
			b[i + 1] = b[i] * inv % M;
	}
	int get(int l, int r) {
		return ((ll)(a[r] - a[l]) * b[l] % M + M) % M;
	}
};

int p[500001], nxt[500001];

bool good(int l, int r, rolling_hash& a, rolling_hash& b) {
	int d = r - l;
	if (d == 1) return true;
	vector<int> ps;
	for (;;) {
		if (p[d]) ps.push_back(p[d]);
		else if (d > 1) ps.push_back(d);
		d = nxt[d];
		if (!d) break;
	}
	for (int p: ps) {
		int x = (r - l) / p;
		if (a.get(l, r - x) == a.get(l + x, r) && b.get(l, r - x) == b.get(l + x, r))
			return false;
		d = nxt[d];
	}
	return true;
}

int main() {
	string s; cin >> s;
	int N = s.length();
	bool same = true;
	for (int i = 0; i + 1 < N; i++)
		if (s[i] != s[i + 1])
			same = false;
	if (same) {
		cout << N << endl;
		cout << 1 << endl;
		return 0;
	}
	rolling_hash a(s, MOD), b(s, _MOD);
	for (int i = 2; i <= 500000; i++)
		if (!p[i])
			for (int j = i * 2; j <= 500000; j += i)
				if (!p[j]) {
					p[j] = i;
					for (nxt[j] = j; nxt[j] % i == 0; nxt[j] /= i);
				}
	if (good(0, N, a, b)) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 1; i <= N - 1; i++)
		if (good(0, i, a, b) && good(i, N, a, b))
			ans++;
	cout << 2 << endl;
	cout << ans << endl;
}


Measured memory_bytes: 12956
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long 
using namespace std;

int main(){
  string s;
  cin>>s;
  int count0=0,count1=0;
  rep(i,s.length()){
    if(s[i]=='0'){
      count0++;
    }else{
      count1++;
    }
  }
  cout<<2*min(count0,count1)<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 100100
using namespace std;
int n;
struct cc
{
	int a,i;
	bool operator<(const cc& b)
	{
		return a<b.a;
	}
}s[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i].a),s[i].i=i; 
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)cout<<s[i].i<<" ";
	cout<<"\n";
	
	return 0;
}



Measured memory_bytes: 1536
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int CalcAns(int n) { return n * (n - 2) / 2; }
void PrintAns(int N) {
  for (int ii = 1; ii <= N; ++ii) {
    for (int jj = ii + 1; jj <= N; ++jj) {
      if (ii + jj == N + 1) continue;
      cout << ii << " " << jj << endl;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  if (N % 2 == 0) {
    cout << CalcAns(N) << endl;
    PrintAns(N);
  } else {
    cout << CalcAns(N - 1) + N-1 << endl;
    PrintAns(N-1);
    for (int ii = 1; ii <= N - 1; ++ii) {
      cout << ii << " " << N << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  string s;
  cin>>s;
  rep(i,s.size()){
    if(41 <= s[i]+n && s[i]+n <= 90)
    cout << (char)(s[i] + n);
    else
    cout << (char)(s[i] + n - 26);
    
  }
  return 0;
}

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

using namespace std;

ifstream fin("carte.in");
ofstream fout("carte.out");

int n, dp[100002], v[100002];

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (i == 2)
      dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    else
      dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
  }
  cout << dp[n];
  return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t A, B, K;
	std::cin >> A >> B >> K;
	if (A > 0 && K > 0) {
		int64_t tmp = std::min(A, K);
		A -= tmp;
		K -= tmp;
	}
	if (B > 0 && K > 0) {
		int64_t tmp = std::min(B, K);
		B -= tmp;
		K -= tmp;
	}

	std::cout << A << " " << B << std::endl;
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>


using namespace std;

int main() {
    int a[3];
    while (scanf("%d%d%d", &a[0], &a[1], &a[2]) != EOF) {
        sort(a, a + 3);
        if (a[0] + a[1] == a[2]) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(10) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    vector<double> p(n);
    for (auto &&x : p) cin >> x;

    vector<vector<double>> dp(2, vector<double>(n + 1));
    auto &cur = dp[0], &nxt = dp[1];
    cur[0] = 1.0;
    for (int i = 0; i < n; ++i) {
        fill(nxt.begin(), nxt.end(), 0.0);
        for (int j = 0; j <= i; ++j) {
            nxt[j] += (1.0 - p[i]) * cur[j];
            nxt[j + 1] += p[i] * cur[j];
        }
        swap(cur, nxt);
    }

    double res = 0.0;
    for (int i = n / 2 + 1; i <= n; ++i) res += cur[i];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
a = input()
b = list(a)
if b[0] == "R":
    if b[1] == "R":
        if b[2] == "R":
            print(3)
        else:
            print(2)
    else:
        if b[2] == "R":
            print(1)
        else:
            print(1)
else:
    if b[1] == "R":
        if b[2] == "R":
            print(2)
        else:
            print(1)
    else:
        if b[2] == "R":
            print(1)
        else:
            print(0)


Measured memory_bytes: 9076
def main():
    N = input()
    L = len(N)
    K = int(input())
    dp = [[0 for _ in range(L + 1)] for _ in range(K + 1)]
    dpp = [[0 for _ in range(L + 1)] for _ in range(K + 1)]
    dpp[0][0] = 1
    for i in range(1, L + 1):
        n = int(N[i - 1])
        for k in range(K + 1):
            # from dpp
            kk = k + (1 if n > 0 else 0)
            if kk <= K:
                dpp[kk][i] = dpp[k][i - 1]
            if n > 0:
                dp[k][i] += dpp[k][i - 1]
                if k + 1 <= K:
                    dp[k + 1][i] += (n - 1) * dpp[k][i - 1]
            # from dp
            dp[k][i] += dp[k][i - 1]
            if k + 1 <= K:
                dp[k + 1][i] += 9 * dp[k][i - 1]
    print(dp[K][L] + dpp[K][L])


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

const int MAX_N = 1000001;
bool isP[MAX_N];
vector<ll> p_vec;
ll N;
ll A[10000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    isP[0] = isP[1] = true;
    for(int i=2;i<MAX_N;i++){
        if(isP[i]) continue;
        p_vec.push_back(i);
        for(int j=2;i*j<MAX_N;j++) isP[i*j] = true;
    }
    vector<ll> p_count(p_vec.size(),0);
    for(int i=0;i<N;i++){
        ll ai = A[i];
        for(int j=0;j<p_vec.size()&&p_vec[j]*p_vec[j]<=A[i];j++){
            ll c = 0;
            while(ai % p_vec[j] == 0){
                ai /= p_vec[j];
                c++;
            }
            p_count[j] = max(p_count[j], c);
            if(ai == 1){
                break;
            }
        }
        if(ai != 1){
            ll ind = lower_bound(p_vec.begin(),p_vec.end(),ai) - p_vec.begin();
            p_count[ind] = max(p_count[ind],(ll)1);
        }
    }
    mint lcm = 1;
    for(int j=0;j<p_vec.size();j++) lcm *= (mint(p_vec[j])).pow(p_count[j]);
    mint ans = 0;
    for(int i=0;i<N;i++) ans += lcm / A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2676
////////////
//||||| ||//
//   || ||//
//||||||||//
//|| ||   //
//|| |||||//
////////////
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   MAX 1000000
#define   eps 1e-8
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
//S.order_of_key(x)[Give me the position of x]
//S.find_by_order(x)[Give me the x th element in set]
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b) {return (a * b) / __gcd(a, b);}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c = 0, d, e, f = 0, g, h, i, j, k, m, n, o, p, s, t, v, w, x = 0, y, z, l;
    ll cnt = 0, l1 = 0, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2, str3 = "", str4 = "";
    ll ide = 0, idx = 0, Q;
    cin>>str;
   for(i=0;i<str.length();i++)
   {
   	c+=str[i]-'0';
   }

   if(c%9==0)
   	cout<<"Yes\n";
   else
   	cout<<"No\n";

    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    map<ll, ll> mp, mp2;
    ll N; cin >> N;
    rep(i, N) {
        ll d; cin >> d;
        mp[d]++;
    }
    ll M; cin >> M;
    rep(i, M) {
        ll t; cin >> t;
        mp2[t]++;
    }
    for (auto i = mp2.begin(); i != mp2.end(); i++) {
        if (i->se > mp[i->fi]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')



int N;

int main()
{
	cin>>N;
	rep(i,60000)
	{
		int r=i*108/100;
		if(r==N)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	puts(":(");
}


Measured memory_bytes: 256