akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 18;

char T[maxN];

vector <char> a, b;

void pr(vector <char> v)
{
	for (char c : v)
		printf("%c", c);
}

void solve()
{
	scanf ("%s", T);
	int n = strlen(T), inv = 0;
	int q;
	scanf ("%d", &q);
	while (q--)
	{
		int ev;
		scanf ("%d", &ev);
		if (ev == 1)
			inv ^= 3;
		else
		{
			int d;
			char in[3];
			scanf ("%d%s", &d, in);
			d ^= inv;
			d == 1 ? a.pb(in[0]) : b.pb(in[0]);
		}
	}
	
	if (inv)
	{
		reverse(ALL(b));
		pr(b);
		reverse(T, T+n);
		printf("%s", T);
		pr(a);
	}
	
	else
	{
		reverse(ALL(a));
		pr(a);
		printf("%s", T);
		pr(b);
	}
	
	printf("\n");
} 

 
int main()
{
    int t;
    t=1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
    #define COUT(x) cout<<(x)<<endl
    typedef long long ll;
    template<class T> inline void chmax(T& a, T b) {
      if (a < b) a = b;
    }
     
    template<class T> inline void chmin(T& a, T b) {
      if (a > b) a = b;
    }
     
    const long long INF = 1LL << 60;
    int main() {
      int r;
      cin >> r;
      const double pi = 3.1415926535;
      double leng = 2 * pi * r;
      cout << leng << endl;
      return 0;
     
    }

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int N, M, R;
int G[201][201];
int r[9];
int ans = INF;
bool used[9];

void dfs(int i, int p, int cost) {
    if (i == R) {
        chmin(ans, cost);
        return;
    }
    rep(j, R) {
        if (used[j]) continue;
        used[j] = true;
        if (p == -1) {
            dfs(i + 1, j, 0);
        } else {
            dfs(i + 1, j, cost + G[r[p]][r[j]]);
        }
        used[j] = false;
    }
}

int main() {
    cin >> N >> M >> R;
    rep(i, N) rep(j, N) if (i != j) G[i][j] = INF;
    rep(i, R) cin >> r[i], r[i]--;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        if (G[a][b] > c) G[a][b] = G[b][a] = c;
    }
    rep(k, N)rep(i, N)rep(j, N) chmin(G[i][j], G[i][k] + G[k][j]);

    dfs(0, -1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

string S;


signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for (int i = l; i <= r; i++) {
            if(i % d == 0) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main(){
  int n,sum,i,j;
  cin >> n;
  sum=0;
  if(n%2==0){
    sum=n/2-1;
  }else{
    sum=n/2;
  }
  cout << sum << endl;
  return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
signed main(){
    int a,b;
    cin>>a>>b;
    int ans=1;
    rep(i,a-1){
        ans=ans*(b-1);
    }
    cout<<ans*b<<endl;
    return 0;
}

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

int main(){
	string S;
  cin >> S;
  if(S[1]=='B'){ S = "ARC" ;}
  else S = "ABC";
  
  cout << S << endl;
  
    return 0;
  }

Measured memory_bytes: 3512
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> G[100100];
int N,Y,U,A;

int dfs(int x, int l, int m)
{
	vector<int> u;
	for (auto &y : G[x]) if (y != l){
		u.push_back(dfs(y,x,m)+1);
	}
	sort(u.begin(),u.end());
	int ret = 0;
	if (u.size() % 2 == 0){
		int y = 1;
		for (int i=0,j=(int)u.size()-1;i<j;i++,j--){
			if (u[i] + u[j] > m) y = 0;
		}
		if (!y){
			if (u.back() <= m) u.pop_back(), U++;
			else Y = 0;
		}
		else U += u.size() / 2;
	}
	if (u.size() % 2){
		int l = 0, r = u.size()-1, a = u.size();
		while (l <= r){
			int mm = (l + r) / 2;
			int y = 1;
			for (int i=0,j=(int)u.size()-1;i<j;i++,j--){
				if (i == mm) i++;
				if (j == mm) j--;
				if (i >= j) break;
				if (u[i] + u[j] > m) y = 0;
			}
			if (u[mm] > m) y = 0;
			if (y){
				a = mm;
				r = mm - 1;
			}
			else l = mm + 1;
		}
		if (a == u.size()) Y = 0;
		else ret = u[a], U += u.size() / 2;
	}
	return ret;
}

int chk(int m)
{
	Y = 1;
	U = 0;
	int l = dfs(1,0,m);
	if (l > m) Y = 0;
	if (l > 0) U++;
	if (U != A) Y = 0;
	return Y;
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<N;i++){
		int x,y; scanf ("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	int a = 0;
	for (int i=1;i<=N;i++) a += G[i].size() % 2;
	a /= 2;
	A = a;

	int l = 1, r = N, b = N;
	while (l <= r){
		int m = (l + r) / 2;
		if (chk(m)){
			b = m;
			r = m - 1;
		}
		else l = m + 1;
	}

	printf ("%d %d\n",a,b);

	return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;


#define MAX_N 1005

int N,M;
vector<int> G[10];


inline void add_edge(int a,int b){
	G[a].push_back(b);
	G[b].push_back(a);
}

bitset<10> vis;
ll ans;

inline void dfs(int now){
	if(vis.count()==N){
		++ans;
		return;
	}

	for(int i=0;i<G[now].size();++i){
		if(!vis[G[now][i]]){
			vis[G[now][i]]=1;
			dfs(G[now][i]);
			vis[G[now][i]]=0;
		}
	}
}

int main(){
	cin>>N>>M;
	vis.reset();
	for(int i=0;i<M;++i){
		int a,b;
		cin>>a>>b;
		add_edge(a,b);
	}
	/*if(M<N-1){
		puts("0");
		return 0;
	}*/

	vis[1]=1;
	dfs(1);

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 256
L,R=map(int,input().split())
i,j=2020,2020
if R-L+1>=2019:
    print(0)
else:
    ans=float('inf')
    for n in range(L,R+1):
        for m in range(n+1,R+1):
            ans=min(ans,(n*m)%2019)
            
    print(ans)

Measured memory_bytes: 9088
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(K):
    for c in range(K):
      total += gdc(c+1, gdc(b+1, a+1))
print(total)



Measured memory_bytes: 72484
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,k,ii,first,last,min1,min2,tmp;
  min1 = LONG_MAX;
  vector<long>tree;
  cin >> n >> k;
  tree.resize(n);
  for(ii=0;ii<n;ii++){
	cin >> tree[ii];
  }
  sort(tree.begin(),tree.end());

  //for(ii=0;ii<n;ii++){
  //  cout << tree[ii] << endl;
  //}
  
//  min1 = tree[k-1] - tree[0];
//  min2 = tree[n-1] - tree[n-1-k+1];
//
//  //cout << "min1:" << min1 << endl;
//  //cout << "min2:" << min2 << endl;
//  
//  if(min1 < min2){
//    cout << min1 << endl;
//  }
//  else{
//    cout << min2 << endl;
//  }
  for(ii=k-1;ii<n;ii++){
    tmp = tree[ii] - tree[ii-k+1];
    if(tmp < min1){
      min1 = tmp;
    }
  }
  cout << min1 << endl;
  return 0;
}


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

#define LL long long
#define MP make_pair
#define Debug(x) cerr << #x << ": " << x << endl;

inline int read() {
	char c = getchar(); int x = 0, f = 1;
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 3e5 + 5;

int M, N; int c[MAXN];

vector<pair<int, int>> v[MAXN];

inline int lowbit(int x) { return x & -x; }
inline void Modify(int x, int y) { for (int i = x; i <= N; i += lowbit(i)) c[i] += y; }
inline int Query(int x) { int ret = 0; for (int i = x; i; i -= lowbit(i)) ret += c[i]; return ret; }

int main() {
	M = read(); N = read();
	for (int i = 1; i <= M; i++) {
		int l = read(), r = read();
		v[r - l + 1].push_back(MP(l, r));
	}
	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		for (auto now : v[i]) {
			int l = now.first, r = now.second;
			Modify(l, 1); Modify(r + 1, -1); cnt++;
		}
		int ans = M - cnt;
		for (int j = i; j <= N; j += i) ans += Query(j);
		printf("%d\n", ans);
	}
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  if (k == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  cout << n - k << endl;
}


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

int main() {
  int n, q, t;
  string name;

  queue<pair<string, int> > Q;

  cin >> n >> q;

  for ( int i = 0; i < n; i++ ) {
    cin >> name >> t;
    Q.push(make_pair(name, t));
  }

  pair<string, int> u;
  int elaps = 0, a;

  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    a = min(u.second, q);
    u.second -= a;
    elaps += a;
    if ( u.second > 0 ) {
      Q.push(u);
    } else {
      cout << u.first << " " << elaps << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 6272
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var a = cin.ReadStrArray(n);
            var b = cin.ReadStrArray(m);
            for (int i = 0; i < n - m + 1; i++)
            {
                for(int j = 0; j < n - m + 1; j++)
                {
                    var now = 0;
                    while(true)
                    {
                        if(now == m)
                        {
                            WriteLine("Yes");
                            return;
                        }
                        var sub = a[i + now].Substring(j, m);
                        if(b[now] != sub)
                        {
                            break;
                        }
                        else
                        {
                            now++;
                            continue;
                        }
                    }
                }
            }
            WriteLine("No");

        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int C[8][8];
bool v[8];
int N;
int ans = 0;

bool checkallvisited() {
	bool allvisited = true;
	rep(i, 0, N) {
		allvisited &= v[i];
	}
	return allvisited;
}

void dfs(int n) {
	rep(i, 0, N) {
		if (i != n && C[n][i] == 1 && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}

	if (checkallvisited()) {
		ans++;
		return;
	}
}

int main() {
	int  M; cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, N) {
			C[i][j] = 0;
		}
	}

	rep(i, 0, N) {
		v[i] = false;
	}

	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		C[a - 1][b - 1] = 1;
		C[b - 1][a - 1] = 1;
	}

	v[0] = true;
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define em emplace_back
#define pi pair<int,int>
#define si second
#define fi first
// new include starts here.
#define endl '\n'
#define vi vector <int>
#define vii vector <pair<int,int>>
#define __s(x) cout<<#x<<"-> "; cout<<"{ ";F(x){cout<<it<<" ";}cout<<" }";cout<<endl;
#define _s(x) cout<<#x<<"-> "<<x<<endl;
#define _sp(x) cout<<#x<<"-> "<<x.fi<<" "<<x.si<<endl;
#define __sp(x) cout<<#x<<"-> "; cout<<"{ "<<endl;F(x){cout<<it.fi<<" "<<it.si<<endl;}cout<<" }";cout<<endl;
#define inf numeric_limits<int > :: max();
#define fit(it,y) for(auto it=y.begin(); it!=y.end();it++)
#define all(x) x.begin(),x.end()
// new includes end here .
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("/home/adarsh/Desktop/codes/input", "r", stdin); //freopen("/home/adarsh/Desktop/codes/output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

#define TRACE
#ifdef TRACE
#define _v(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define _v(...)
#endif

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=(p(a,b/2)); if(b%2==0)return (t*t); else return ((a)*(t*t)); } 

//---------------------------------------------------------------------------------------------------------------------------------------------

signed main(){
 
	#ifndef ONLINE_JUDGE
	FILEIO
	#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----


	int n;
	cin>>n;
	int a[n];
	f(n){
		cin>>a[i];
	}
	sort(a, a+n);

	map <int, int > s;
	f(n){
		s[a[i]]=0;
	}
	f(n){
		s[a[i]]++;
	}

	int ans=0;
	f(n){
		int x=a[i];
		int z=sqrt(x)+1;
		int u=0;
		ff(z){
			if(j==0 ||j==1){
				continue;
			}
			if(x%j==0){
				if(s.find(j)!=s.end() || s.find(x/j)!=s.end()){
					//_v(i, j, a[i], j, x/j);
					u=1;
				}
			}
		}
		if(s[x]>1){
			u=1;
		}
		if(x!=1){
			if(s.find(1)!=s.end()){
				u=1;
			}
		}

		//_v(a[i], u);
		if(u==0){
			ans++;
		}
	}
	cout<<ans<<endl;

	
	return 0;
}   

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

using namespace std;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, l;
	cin >> n >> l;
	string s[n];
	rep(i,n) cin >> s[i];
	sort(s, s+n);
	rep(i,n) cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
    
	int n,h[100100]; cin >> n;
	int x = 0,way = 0,ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (x == 1 && h[i] > h[i - 1]) { x = 0; ans = max(ans, way); way = 0; }
		if (x == 0) { x = 1; way = 0; continue; }
		if (x == 1 && h[i] <= h[i - 1]) { way++;  continue; }
	}
	if (x == 1) { ans = max(ans, way); }
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
from collections import deque
r=deque(map(int,list(input())))
l=deque()
cnt=0
while len(r)>0:
	if len(l)==0:
		l.append(r.popleft())
	if len(r)==0:
		break
	if l[-1] + r[0]==1:
		l.pop()
		r.popleft()
		cnt += 2
	else:
		l.append(r.popleft())
		
print(cnt)

Measured memory_bytes: 49520
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> w(n);
    int ave = 0;
    for (int i = 0; i < n; i++)
    {
        std::cin >> w[i];
    }

    std::vector<int> di;
    for (int t = 1; t <= n - 1; t++)
    {
        int s1 = 0;
        int s2 = 0;
        for (int i = 0; i < n; i++)
        {
            if(i < t) {
                s1 += w[i];
            } else {
                s2 += w[i];
            }
        }

        di.push_back(std::abs(s1-s2));
    }

    std::cout << *std::min_element(di.begin(), di.end()) << "\n";
}


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


int main()
{
    int n, ans = 0, ma = -1;
    cin >> n;
    vector<int> k(n);
    for(int i = 0;i < n;i++){
        cin >> k[i];
        ma = max(ma,k[i]);
    }

    for(int i = 0;i < ma;i++){
        int cnt = 0;
        
        for(int j = 0;j < n - 1;j++){
            if(k[j] == 0 && k[j + 1] != 0) cnt++;
        }

        
        if(k[0] != 0){
            cnt++;
        }

        for(int j = 0;j < n;j++){
            if(k[j] - 1 < 0){

            }
            else{
                k[j]--;
            }
        }

        ans += cnt;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
mis = []
for i in range(n):
  mi = int(input())
  mis.append(mi)
x = x - sum(mis)
mis_asc = sorted(mis)
m_mini = mis_asc[0]
dou = n
while x >= m_mini:
  dou += 1
  x -= m_mini
print(dou)

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

int main() {
  int n;
  cin>>n;
  int a[25];
  int b[25];
  int c[25];
  for (int i=0; i<n; i++) cin>>a[i];
  for (int i=0; i<n; i++) cin>>b[i];
  for (int i=0; i<n-1; i++) cin>>c[i];
  int b_n=-2,ans=0;
  for (int i=0; i<n; i++){
    ans+=b[i];
    if (a[i]==b_n+1) ans+=c[b_n-1];
    b_n=a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
h = l()

for i in range(1,n):
    if h[i-1]-h[i] > 0:
        ans += h[i-1]-h[i]

print(ans+h[-1])

"""
n = k()
s = v()

def check(n):
    if 

#コマンドの種類
comand = ["A","B","X","Y"]
p = list(itertools.permutations(comand,2))
for i in range(len(p)):
    p[i] = "".join(p[i])

for i in 
"""

Measured memory_bytes: 10248
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n);SCIN(s1,s2);
  V vec;//1なら縦0なら横
  REP(i,n){if(s1[i]==s2[i])vec.pb(1);else{vec.pb(0);i++;}}
  ll ans = (vec[0]==0?6:3);
  FOR(i,1,vec.size()){
    if(vec[i-1]==1&&vec[i]==1)ans*=2;
    else if(vec[i-1]==0&&vec[i]==0)ans*=3;
    else if(vec[i-1]==1&&vec[i]==0)ans*=2;
    ans%=MOD;
  }



  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a, b, c int
  
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  sum := 0
  if a >= b && a >= c{
    sum = b + c
  }
  if b >= c && b >= a{
    sum = c + a
  }
  if c >= a && c >= b{
    sum = a + b
  }
  fmt.Printf("%d", sum)
}

Measured memory_bytes: 1832
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
using namespace std;
#define N 1000000

int main(){
    long n;
    cin>>n;
    long a=pow(n, 0.5);
    int count=0;
    long num[N];
    for (int i=1; i<=a; i++){
        if (n%i==0){
            num[count]=(n/i)+i;
            count+=1;
        }
    }
    long minnum=1000000000000;
    for (int i=0; i<count; i++){
        if (minnum>num[i]){
            minnum=num[i];
        }
    }
    cout<<minnum-2<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  pair<int,int> r[N];
  pair<int,int> b[N];
  for(int i=0;i<N;i++){
    cin >> r[i].first >> r[i].second;
  }
  for(int i=0;i<N;i++){
    cin >> b[i].first >> b[i].second;
  }

  sort(b,b+N);
  bool used[N];
  fill(used,used+N,false);

  //cout << endl;
  int ans = 0;
  for(int i=0;i<N;i++){
    int ind = -1;
    int ymax = -1;
    for(int j=0;j<N;j++){
      if(!used[j] && r[j].first<b[i].first && r[j].second<b[i].second && ymax<r[j].second){
        ind = j;
        ymax = r[j].second;
      }
    }
    if(ind != -1){
      ans++;
      used[ind] = true;
      //cout << r[ind].first << " " << r[ind].second;
      //cout << "  " << b[i].first << " " << b[i].second << endl;
    }
  }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N,A,B,C;
string s;
int ans;

int main() {
    cin>>N;
    ans = N/3;
    p(ans);
    return 0;
}

Measured memory_bytes: 256
function main()
    S = chomp(readline())
    zs = 0
    os = 0
    for i in 1:length(S)
        s = S[i]
        if i % 2 == 0
            if s == '0'
                zs += 1
            else
                os += 1
            end
        else
            if s == '1'
                zs += 1
            else
                os += 1
            end
        end
    end
    println(min(os, zs))
end

main()

Measured memory_bytes: 158012
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace ABC158
{
    class A
    {
        static void Main(string[] args)
        {
            StringBuilder s = new System.Text.StringBuilder(Console.ReadLine());
            long q = long.Parse(Console.ReadLine());
            StringBuilder ans = new System.Text.StringBuilder();
            StringBuilder p = new System.Text.StringBuilder();
            int t = 1;
            int f = 1;
            char[] tfc = new char[3];
            for (int i = 0; i < q; i++)
            {
                tfc = Console.ReadLine().Split().Select(char.Parse).ToArray();
                if (tfc[0] == '1') { t = -t; continue; }
                else
                {
                    f = tfc[1] == '1' ? 1 : -1;
                    if (t * f == 1)
                    {
                        p.Append(tfc[2]);
                    }
                    else
                    {
                        s.Append(tfc[2]);
                    }
                }
            }
            for (int i = 0; i < s.Length; i++)
            {
                ans.Append(s[s.Length - i - 1]);
            }
            for (int i = 0; i < p.Length; i++)
            {
                ans.Append(p[i]);
            }
            s=ans;
            if (t == 1)
            {
                ans = new System.Text.StringBuilder();
                for (int i = 0; i < s.Length; i++)
                {
                    ans.Append(s[s.Length - i - 1]);
                }
                
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 20640
#include<iostream>
#include<cstring>
#include<algorithm>
#define M 1010 
using namespace std;
int a,b;
int main()
{
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a % 3 == 0 || b % 3 == 0 || (a+b)%3 == 0)
            printf("Possible\n");
        else
            printf("Impossible\n");
    }
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll a, b, c, x, y;

int main() {
   cin >> a >> b >> c >> x >> y;

   ll ans1 = a * x + b * y;
   ll ans2 = max(x, y) * 2 * c;

   ll ans3 = 0;
   if (x >= y) { // xが足りない
      ans3 += y * 2 * c;
      ll z = x - y; // 足りない分
      ans3 += z * a;
   } else {
      ans3 += x * 2 * c;
      ll z = y - x;
      ans3 += z * b;
   }

   cout << min({ans1, ans2, ans3}) << endl;

   return 0;
}

Measured memory_bytes: 256
import           Control.Exception           (assert)
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

main = do
  [n, m] <- getIntList

  d <- VM.new (n-1)
  VM.set d (0::Int)

  replicateM_ m $ do
    [a, b] <- getIntList
    when (a == 1) $ do
      t <- VM.read d (b-1)
      let t' = t .|. 1
      VM.write d (b-1) t'
      when (t' == 3) $ VM.write d 0 1
    when (b == n) $ do
      t <- VM.read d (a-1)
      let t' = t .|. 2
      VM.write d (a-1) t'
      when (t' == 3) $ VM.write d 0 1

  res <- VM.read d 0
  let ans = if res == 1 then "POSSIBLE" else "IMPOSSIBLE"
  putStrLn ans

Measured memory_bytes: 3068
lis=list(map(int,input().split()))
alist=[0]*(lis[0]+1)
for i in range(lis[1]):
    a=int(input())
    alist[a]=1
steps=[0]*(lis[0]+2)
steps[1]=1
mod=(10**9)+7
for i in range(2,lis[0]+2):
    if alist[i-1]==0:
        steps[i]=(steps[i-1]+steps[i-2])%mod
ans=steps[-1]
print(ans)


Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int a[3][3];
    rep(i,3){
        rep(j,3) cin>>a[i][j];
    }
    int n;cin>>n;
    bool b[3][3];
    rep(i,3)rep(j,3)b[i][j]=false;
    rep(_,n){
        int t;cin>>t;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==t) b[i][j]=true;
            }
        }
    }
    bool f=false;
    rep(i,3){
        if(b[i][0] and b[i][1] and b[i][2]) f=true;
    }
    rep(j,3){
        if(b[0][j] and b[1][j] and b[2][j]) f=true;
    }
    if(b[0][0] and b[1][1] and b[2][2]) f=true;
    if(b[0][2] and b[1][1] and b[2][0]) f=true;
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int64_t N, cnt = 0;

void solve(int64_t n, vector<bool> v) {
	if ((count(v.begin(), v.end(), 1) == 3) && (n <= N)) {
		cnt++;
	}

	if (n > N) return;
	else {
		auto v1 = v;
		auto v2 = v;
		auto v3 = v;
		v1.at(0) = 1;
		v2.at(1) = 1;
		v3.at(2) = 1;
		solve(10 * n + 3, v1);
		solve(10 * n + 5, v2);
		solve(10 * n + 7, v3);
	}
}

int main() {
	cin >> N;

	vector<bool> v(3);
	int64_t n = 0;
	solve(n, v);

	cout << cnt << endl;
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
なんか爆弾の個数が<3e5で抑えられている
爆弾の位置を指定するのが最適?
->そうでもない
爆弾のある行と列だけと考えても、結局3e5 * 3e5となるのでダメっぽい

ある行を固定すると、そのときの最適は最大のwとなりそうだけど、そこに爆弾があったら-1されてしまうのがネック
最大かもしれないものをピックアップする
ひかれるとしても-1なので、これを全部調べれば良さそう
mが3e5なので候補が3e5以上あったらその時点でそこに最大があるって感じでよさそう
*/

int	main(void)
{
	int h, w, m;
	cin >> h >> w >> m;
	map<pair<int, int>, bool> mp;
	vector<int> h_bomb(h, 0);
	vector<int> w_bomb(w, 0);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		h_bomb[a]++;
		w_bomb[b]++;
		mp[{a,b}] = true;
	}
	vector<pair<int, int>> sorted_h_bomb(h);
	for (int i = 0; i < h; i++) sorted_h_bomb[i] = {h_bomb[i], i};
	sort(sorted_h_bomb.begin(), sorted_h_bomb.end(), greater<pair<int, int>>());
	vector<pair<int, int>> sorted_w_bomb(w);
	for (int i = 0; i < w; i++) sorted_w_bomb[i] = {w_bomb[i], i};
	sort(sorted_w_bomb.begin(), sorted_w_bomb.end(), greater<pair<int, int>>());
	vector<pair<int, int>> ans_list;
	int h_max = sorted_h_bomb[0].first;
	int w_max = sorted_w_bomb[0].first;
	for (int i = 0; i < h; i++)
	{
		if (sorted_h_bomb[i].first != h_max) break ;
		for (int j = 0; j < w; j++)
		{
			if (sorted_w_bomb[j].first != w_max) break ;
			ans_list.push_back({sorted_h_bomb[i].second, sorted_w_bomb[j].second});
			if (ans_list.size() > m)
			{
				cout << h_max + w_max << endl;
				return (0);
			}
		}
	}
	for (int i = 0; i < ans_list.size(); i++)
	{
		if (mp[{ans_list[i].first, ans_list[i].second}] == false)
		{
			cout << h_max + w_max << endl;
			return (0);
		}
	}
	cout << h_max + w_max - 1 << endl;
	return (0);
}


Measured memory_bytes: 33240
#modの掛け算

def modmal(a,b,mod): #a*bをmodを法にして求める

    return a * b % mod


#modの割り算

def moddiv(a,b,mod): #a/bをmodを法にして求める

    return (a * pow(b,mod-2,mod)) % mod


#逆元

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


n = int(input())

dic = {}

a = list(map(int,input().split()))
twonum = None

for i in range(n+1):

    if a[i] not in dic:
        dic[a[i]] = [i]
    else:
        dic[a[i]].append(i)
        twonum = a[i]

mod = 10**9+7
fac,inv = modfac(n+10,mod)

for k in range(n+1):
    
    k += 1
    
    ans = modnCr(n+1,k,mod,fac,inv)

    l = dic[twonum][0]
    r = (n+1) - dic[twonum][1] - 1

    if l+r >= k-1:
        ans -= modnCr(l+r,k-1,mod,fac,inv)

    print (ans % mod)
    

Measured memory_bytes: 73448
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            long n = ReadLong ();
            List<long> a = GetListLong (Read ());

            long count = 0;
            Dictionary<long, long> dic = new Dictionary<long, long> ();
            for (int i = 0; i < n; i++) {
                long sa = i - a[i];
                if (dic.ContainsKey (sa)) {
                    count += dic[sa];
                }

                long wa = i + a[i];
                if (!dic.ContainsKey (wa)) {
                    dic.Add (wa, 1);
                } else {
                    dic[wa]++;
                }
            }

            Write(count);

            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string Read () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long ReadLong () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> GetList (string str) {
            return new List<string> (str.Split (" "));
        }

        public static List<int> GetListInt (string str) {
            return GetList (str).ConvertAll (x => int.Parse (x));
        }

        public static List<long> GetListLong (string str) {
            return GetList (str).ConvertAll (x => long.Parse (x));
        }
    }
}

Measured memory_bytes: 58664
n,k = map(int,input().split())
x = list(map(int,input().split()))
l = 0
r = k-1
ans = 0
if x[l] <= 0 and x[r] <= 0:
    ans = abs(x[l])
elif x[l] >= 0 and x[r] >= 0:
    ans = x[r]
else:
    ans = min(abs(x[l]), x[r]) * 2 + max(abs(x[l]), x[r])
for i in range(n-k):
    l += 1
    r += 1
    if x[l] <= 0 and x[r] <= 0:
        ans = min(ans,abs(x[l]))
    elif x[l] >= 0 and x[r] >= 0:
        ans = min(ans, x[r])
    else:
        ans = min(ans, min(abs(x[l]), x[r]) * 2 + max(abs(x[l]), x[r]))

print(ans)


Measured memory_bytes: 14480
//Grid Repainting 2
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int h,w;
    cin >> h >> w;
    string board[60];
    rep(i,h) cin >> board[i];

    //四方向の埋め込み
    vector<int> dx{1,-1,0,0};
    vector<int> dy{0,0,1,-1};

    bool can = true;
    rep(i,h){
        rep(j,w){
            if(board[i][j] == '#'){
                can = false;
                rep(k,4){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x>=0 && x<h && y>=0 && y<w && board[x][y]=='#'){
                        can=true;
                        continue;
                    }
                }
                if(can==false) break;
            }
        }
        if(can==false) break;
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

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


void precompute(vector <int>  &no_of_prime,int limit)
{
  vector <int> is_prime(limit,true);
  vector <int> prime;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i*i<limit;i++)
  {
    if(is_prime[i])
      prime.push_back(i);
    for(int j=(i*i);j<limit;j+=i)
    {
      is_prime[j]=false;
    }
  }
  for(int i = 3; i < limit; i++)
    {
        no_of_prime[i] = no_of_prime[i - 1] + (i%2 == 1 && is_prime[i] && is_prime[(i + 1)/2]);
}
}
  

int main()
{
  int t;
  cin>>t;
  vector <int>  no_of_prime(100001,0);
  precompute(no_of_prime,100001);
  
  while(t--)
  {
    int l,r,answer;
    cin>>l>>r;
    answer = no_of_prime[r]-no_of_prime[l-1];
    cout<<answer<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);	
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	
     	if((a*b) % 2 == 0){
        	System.out.println("Even");
        }
      	else if((a*b) % 2 != 0){
        	System.out.println("Odd");
        }      	
    }
}

Measured memory_bytes: 22996
using System;

public class Program
{
	public static void Main(string[] args)
	{
		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
		string s = Console.ReadLine();
		string sub = s.Substring(0, s.Length - 1);
		string p = Console.ReadLine();
		string ss = s + sub;
		int index = ss.IndexOf(p);
		if (index == -1)
		{
			Console.WriteLine("No");
		}
		else
		{
			Console.WriteLine("Yes");
		}
		//int ans = 0;
		/*for (int i = 0; i<s.Length-1;i++)
		{
			int xx = i + p.Length;
			string sub = ss.Substring(i, ss.Length-i);
			if (sub == p)
			{
				ans += 1;

			}
		}
		if (ans == 0)
		{
			Console.WriteLine("No");
		}
		else
		{
			Console.WriteLine("Yes");
		}*/

		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
string s;
ll k;
int main(){
  cin >> s >> k;
  int ans;
  for (ans = 0; ans < s.size(); ans++) {
    if(s[ans] != '1'){
      break;
    }
  }
  if(ans == s.size()){
    cout << 1 << endl;
    return 0;
  }
  if(k <= s.size()-1){
    if(s[k-1] == '1'){
      cout << "1" << endl;
    }else{
      cout << s[ans] << endl;
    }
  }else{
    cout << s[ans] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>

int main(void) {
  int c[3][3];
  
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      std::cin >> c[i][j];
    }
  }

  for (int a1 = 0; a1 <= 100; ++a1) {
    for (int a2 = 0; a2 <= 100; ++a2) {
      for (int a3 = 0; a3 <= 100; ++a3) {
        int b1 = c[0][0] - a1;
        int b2 = c[1][1] - a2;
        int b3 = c[2][2] - a3;
        if (c[0][1] == a1 + b2 && 
            c[0][2] == a1 + b3 &&
            c[1][0] == a2 + b1 &&
            c[1][2] == a2 + b3 &&
            c[2][0] == a3 + b1 &&
            c[2][1] == a3 + b2
           ) {
          std::cout << "Yes" << std::endl;
          return 0;
        }
      }
    }
  }
  
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
//AtCoder ABC084 Contest
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
lld p[555555];
vector<lld > pp,ans;
void sieve(){
    p[0]=1;
    p[1]=1;
    for(lld i=2;i<=111111;i++){
        if(p[i]==0){
            pp.push_back(i);
            for(lld j=2*i;j<=(111111);j+=i){
                p[j]=1;
            }
        }
    }
    for(lld i=0;i<pp.size();i++){
        lld mid=(pp[i]+1)/2;
        //cout<<pp[i]<<"\n";
        if(p[mid]==0){
            ans.push_back(pp[i]);
        }
    }
}

int main(){
    sieve();
    lld q;
    cin>>q;
    while(q--){
        lld l,r;
        cin>>l>>r;
        cout<<upper_bound(ans.begin(),ans.end(),r)-lower_bound(ans.begin(),ans.end(),l)<<"\n";
    }
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c == 'a' || c=='e' || c=='i'|| c=='o'||c=='u'){
        printf("vowel");
    }
    else printf("consonant");



    return 0;
}


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

typedef pair<int,int> Node; // v,com
typedef pair<int,Node> P;  // dp[Node],Node
typedef P Edge;           // int,Node

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1^(h2<<16);
    }
};

priority_queue<P,vector<P>,greater<P>> qu;
unordered_map<Node,vector<Edge>,pair_hash> g;
unordered_map<Node,int,pair_hash> dp;

int N,M;

void dijkstra(Node start){
    qu.push({dp[start]=0,start});
    while(qu.size()){
        P pr=qu.top(); qu.pop();
        Node v = pr.second;
        if(v==make_pair(N-1,-1))return;
        if(dp[v] < pr.first)continue;

        for(Edge e:g[v]){
            Node to = e.second;
            int cost = e.first;
            if(dp.count(to)==0 || dp[to] > dp[v]+cost){
                dp[to] = dp[v]+cost;
                qu.push({dp[to],to});
            }
        }
    }
}


int main(void){
    cin>>N>>M;
    rep(i,M){
        int p,q,c;
        scanf("%d %d %d",&p,&q,&c);
        p--,q--;
        if(g.count({p,c})==0){
            g[{p,c}].push_back({0,{p,-1}});
            g[{p,-1}].push_back({1,{p,c}});
        }
        if(g.count({q,c})==0){
            g[{q,c}].push_back({0,{q,-1}});
            g[{q,-1}].push_back({1,{q,c}});
        }
        g[{p,c}].push_back({0,{q,c}});
        g[{q,c}].push_back({0,{p,c}});
    }
    dijkstra({0,-1});
    cout<<(dp.count({N-1,-1}) ? dp[{N-1,-1}] : -1)<<endl;
    return 0;
}


Measured memory_bytes: 82420
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    while(cin >> s && s!="0") {
        int a=0, b=0;
        for(int i=1; i<s.size(); i++) {
            if(s[i]=='A') a++;
            else b++;
        }
        if(a>b) a++;
        else b++;
        cout << a << " " << b << endl;
    }
}


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

using namespace std;

int main(void)
{
  long int n,k,min=1000000001;
  scanf("%ld%ld",&n,&k);
  long int a[n],i;
  for(i=0;i<n;++i)
     scanf("%ld",&a[i]);
  
  sort(a,a+n);
  
  for(i=0;i<n-k+1;++i)
  {
    if(min>(a[i+k-1]-a[i]))
       min=a[i+k-1]-a[i];
  }
  
  printf("%ld",min);
   
   return 0;
}

Measured memory_bytes: 1024