akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;
typedef unsigned long long ULL;



typedef vector<vector<int>> Grafo;
int n, m;
Grafo G;

// Realiza ordenação topológica em um grafo dirigido
// Retorna true se foi possível realizar a ordenação
// ans -> vértices ordenados
// incoming[i] -> quantidade de arestas que incidem no nó i
vector<int> khan()
{
	int n = sz(G);
	int incoming[n];
	int visited[n];
	queue<int> Q;   // se os índices precisam estar ordenados, usar priority_queue

	// computando vetor incoming
	MEMSET(incoming,0);
	FOR(i,0,n){
		FOR(j,0,sz(G[i]))
			incoming[G[i][j]]++;
	}
		
	FOR(i,0,n){
		visited[i] = 0;
		if(incoming[i] == 0)
			Q.push(i);
	}

	vector<int> ans;   // vértices ordenados
	while(!Q.empty())
	{
		int cur = Q.front();
		visited[cur] = 1;
		ans.pb(cur);
		Q.pop();

		FOR(i,0,sz(G[cur])){
			int adj = G[cur][i];
			if(!visited[adj]){
				incoming[adj]--;
				if(incoming[adj] == 0)
					Q.push(adj);
			}
		}
	}
	return ans;
}

int longestPathDAG()
{
	vector<int> v = khan();
	int dist[n];
	MEMSET(dist,0);
	dist[v[0]] = 0;
	int longestPath = 0;
	for(auto cur : v)
	{
		for(auto adj : G[cur])
		{
			dist[adj] = max(dist[adj], dist[cur] + 1);
			longestPath = max(longestPath, dist[adj]);
		}
	}
	return longestPath;
}

int main(void)
{
	fastIO();
	
	cin >> n >> m;
	G = Grafo(n);
	FOR(i,0,m){
		int x, y;
		cin >> x >> y;
		x--, y--;
		G[x].pb(y);
	}
	cout << longestPathDAG() << endl;
}

Measured memory_bytes: 7164
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

char o(int n, char a){
    if(n==0) return a;
    if(a=='a') return o(n-1,'Z');
    if(a=='b') return o(n-1,'a');
    if(a=='c') return o(n-1,'b');
    if(a=='d') return o(n-1,'c');
    if(a=='e') return o(n-1,'d');
    if(a=='f') return o(n-1,'e');
    if(a=='g') return o(n-1,'f');
    if(a=='h') return o(n-1,'g');
    if(a=='i') return o(n-1,'h');
    if(a=='j') return o(n-1,'i');
    if(a=='k') return o(n-1,'j');
    if(a=='l') return o(n-1,'k');
    if(a=='m') return o(n-1,'l');
    if(a=='n') return o(n-1,'m');
    if(a=='o') return o(n-1,'n');
    if(a=='p') return o(n-1,'o');
    if(a=='q') return o(n-1,'p');
    if(a=='r') return o(n-1,'q');
    if(a=='s') return o(n-1,'r');
    if(a=='t') return o(n-1,'s');
    if(a=='u') return o(n-1,'t');
    if(a=='v') return o(n-1,'u');
    if(a=='w') return o(n-1,'v');
    if(a=='x') return o(n-1,'w');
    if(a=='y') return o(n-1,'x');
    if(a=='z') return o(n-1,'y');
    if(a=='A') return o(n-1,'z');
    if(a=='B') return o(n-1,'A');
    if(a=='C') return o(n-1,'B');
    if(a=='D') return o(n-1,'C');
    if(a=='E') return o(n-1,'D');
    if(a=='F') return o(n-1,'E');
    if(a=='G') return o(n-1,'F');
    if(a=='H') return o(n-1,'G');
    if(a=='I') return o(n-1,'H');
    if(a=='J') return o(n-1,'I');
    if(a=='K') return o(n-1,'J');
    if(a=='L') return o(n-1,'K');
    if(a=='M') return o(n-1,'L');
    if(a=='N') return o(n-1,'M');
    if(a=='O') return o(n-1,'N');
    if(a=='P') return o(n-1,'O');
    if(a=='Q') return o(n-1,'P');
    if(a=='R') return o(n-1,'Q');
    if(a=='S') return o(n-1,'R');
    if(a=='T') return o(n-1,'S');
    if(a=='U') return o(n-1,'T');
    if(a=='V') return o(n-1,'U');
    if(a=='W') return o(n-1,'V');
    if(a=='X') return o(n-1,'W');
    if(a=='Y') return o(n-1,'X');
    if(a=='Z') return o(n-1,'Y');
    return 's';
}

int main(){
    for(;;){
        int n;
        cin >>n;
        if(!n)break;
        vector<int> key(n);
        rep(i,n) cin >> key[i];
        string s;
        cin >> s;
        string ans="";
        int j=0;
        for (int i=0; i<s.length(); i++) {
            ans += o(key[j],s[i]);
            j++;
            if(j==key.size()) j=0;
        }
        cout << ans << endl;
    }
}

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

signed main(void)
{
	long long n, h, cnt, a_max; cin >> n >> h;
	vector<long long> a(n), b(n);
	a_max = 0;
	rep(i, n)
	{
		cin >> a.at(i) >> b.at(i);
		a_max = max(a_max, a.at(i));
	}
	sort(b.rbegin(), b.rend());
	cnt = 0;
	rep(i, n)
	{
		if (h <= 0 || a_max > b.at(i))
			break;
		h -= b.at(i);
		cnt++;
	}
	if (h > 0)
	{
		cnt += h / a_max;
		if (h % a_max != 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  
  if (N==1)
    cout << 1 << endl;
  else {
    int count = 1;
    sort(d.begin(), d.end());
    for (int i=0; i<N-1; i++) {
      if (d.at(i+1)>d.at(i)) {
        count++;
      }
    }
    cout << count << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  while( cin >> N >> K){
    if( N == 0 && K == 0){ break;}
    vector<string> P(N);
    for(int i = 0; i < N; i++){ int c; cin >> c; P[i] = to_string(c);}
  
   
    set<string> s;  
    
    if( K == 2){
      for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
          vector<string> vec;
          vec.push_back(P[i]); vec.push_back(P[j]);
          sort(vec.begin(),vec.end());
        do{
          s.insert(vec[0]+vec[1]);
        }while(next_permutation(vec.begin(),vec.end()));
        
        }}}
    
    if( K == 3){
      for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){
          for(int k = j+1; k < N; k++){
            
          vector<string> vec;
          vec.push_back(P[i]); vec.push_back(P[j]); vec.push_back(P[k]);
          sort(vec.begin(),vec.end());
        do{
          s.insert(vec[0]+vec[1]+vec[2]);
        }while(next_permutation(vec.begin(),vec.end()));
        
            
           
          }
        }
      }
    }
    
    if( K == 4){
      for(int i = 0; i < N-3; i++){
        for(int j= i+1; j < N-2; j++){
          for(int k = j+1;k < N-1; k++){
            for(int l = k+1; l < N; l++){
         vector<string> vec;
          vec.push_back(P[i]); vec.push_back(P[j]); vec.push_back(P[k]); vec.push_back(P[l]);
          sort(vec.begin(),vec.end());
        do{
          s.insert(vec[0]+vec[1]+vec[2]+vec[3]);
        }while(next_permutation(vec.begin(),vec.end()));
        
            }
          }
        }
      }
    }
    cout << s.size() << endl;
  }
    
  
  return 0;}
      



Measured memory_bytes: 3476
N, M = map(int, input().split())
lamps = [list(map(int, input().split()))[1:] for _ in range(M)]
Ps = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    clear = True
    for idx, l in enumerate(lamps):
        on = 0
        for j in range(N):
            if ((i>>j) &1):
                if j+1 in l:
                    on += 1
        if not on%2==Ps[idx]:
            clear = False
            break
    if clear:
        ans += 1
print(ans)
        


Measured memory_bytes: 3064
#include<cstdio>
#define maxn 2005
#define Get(a,x1,y1,x2,y2) (a[x2][y2]-a[x1][y2]-a[x2][y1]+a[x1][y1])
int n,m,q,sv[maxn][maxn],sh[maxn][maxn],sum[maxn][maxn];
char s[maxn][maxn];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			sv[i][j]=sv[i-1][j],sh[i][j]=sh[i][j-1],sum[i][j]=sum[i][j-1];
			if(s[i][j]=='1') sv[i][j]+=(s[i-1][j]=='1'),sh[i][j]+=(s[i][j-1]=='1'),sum[i][j]++;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) sum[i][j]+=sum[i-1][j],sh[i][j]+=sh[i-1][j];
	for(int j=1;j<=m;j++)
		for(int i=1;i<=n;i++) sv[i][j]+=sv[i][j-1];
	while(q--)
	{
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",Get(sum,x1-1,y1-1,x2,y2)-Get(sh,x1-1,y1,x2,y2)-Get(sv,x1,y1-1,x2,y2));
	}
}

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

using namespace std;


typedef long long ll;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d;
  ll t[100001],f[100001];

  cin>>n>>d;


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


  
  ll ans=0,p=1,nt=0,c=0;
  
  for(int i=0;i<n&&ans!=-1;i++){
    
    
    if((p-1)+f[i]-1<=t[i]-nt)ans+=(p-1)*c,c=1;

    else if(abs(f[i]-p)<=t[i]-nt)ans+=c*(t[i]-nt),c++;

    else ans=-1;

    if(c>d)ans=-1;
    
    nt=t[i];
    
    p=f[i];
    
  }

  if(ans!=-1)ans+=c*(p-1);

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

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 1e5 + 10;
const int M = 2e5 + 10;

int n, m;
vector<PII> adj[2*M + N];
int total_vertices = 0;
map<PII, int> id;

int encode(int u, int c) {
    if(id.find({u, c}) != id.end()) {
        return id[{u, c}];
    }
    if(c != 0) {
        adj[total_vertices].push_back({encode(u, 0), 0});
    }
    return id[{u, c}] = total_vertices++;
}

int dijkstra() {
    vector<int> dis(total_vertices, INF);
    int source = encode(1, 0);
    dis[source] = 0;
    set<PII> pq;
    pq.insert({0, source});
    while(!pq.empty()) {
        int u = pq.begin()->second;
        pq.erase(pq.begin());
        for(PII pp : adj[u]) {
            int v = pp.first;
            int d = pp.second;
            if (dis[u] + d < dis[v]) {
                pq.erase({dis[v], v});
                dis[v] = dis[u] + d;
                pq.insert({dis[v], v});
            }
        }
    }
    return dis[encode(n, 0)] == INF ? -1 : dis[encode(n, 0)];
}

int main() {
    cin >> n >> m;
    FOR(i, 1, n+1) encode(i, 0);
    REP(i, m) {
        int u, v, c;
        cin >> u >> v >> c;
        int uc = encode(u, c);
        int vc = encode(v, c);
        int u0 = encode(u, 0);
        int v0 = encode(v, 0);
        adj[uc].push_back({vc, 0});
        adj[vc].push_back({uc, 0});
        adj[u0].push_back({vc, 1});
        adj[v0].push_back({uc, 1});
    }
    cout << dijkstra() << '\n';
}






























Measured memory_bytes: 71796
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BPostdocs {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string t; cin >> t;
      for(auto& c: t) {
        if (c == '?') c = 'D';
      }
      cout << t << endl;
    }
};

signed main() {
  BPostdocs solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  long n, c;
  cin >> n >> c;

  vector<P> sushi(n);
  rep(i, n) {
    long x, v;
    cin >> x >> v;
    sushi[i] = {x, v};
  }

  vector<long> hidari(n+1);
  vector<long> hidariModori(n+1);
  vector<long> hidariMax(n+1);
  long before = 0;

  rep(i, n) {
    hidari[i+1] = hidari[i] + sushi[i].second - sushi[i].first + before;
    hidariModori[i+1] = hidari[i+1] - sushi[i].first;
    hidariMax[i+1] = max(hidari[i+1], hidariMax[i]);
    before = sushi[i].first;
  }

  vector<long> migi(n+1);
  vector<long> migiModori(n+1);
  vector<long> migiMax(n+1);
  before = 0;
  rep(i, n) {
    migi[i+1] = migi[i] + sushi[n-i-1].second - c + sushi[n-i-1].first + before;
    migiModori[i+1] = migi[i+1] - c + sushi[n-i-1].first;
    migiMax[i+1] = max(migi[i+1], migiMax[i]);
    before = c - sushi[n-i-1].first;
  }

  long res = 0;
  rep(i, n+1) {
    res = max(res, hidari[i]);
    res = max(res, migi[i]);
    res = max(res, hidariModori[i] + migiMax[n-i]);
    res = max(res, migiModori[i] + hidariMax[n-i]);
  }

  cout << res << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	std::string s;

	std::cin >> s;

	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == '7') {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}

	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3584
n = int(input())
taro   = 0
hanako = 0

for _ in range(n):
    t,h = input().split()
    if   t > h:
        taro   += 3
    elif t < h:
        hanako += 3
    elif t == h:
        taro   += 1
        hanako += 1
print('{} {}'.format(taro,hanako))


Measured memory_bytes: 5596
#pragma GCC optimize(3)
#include<cstdio>
int N,M,sum,xi,Map[55][55],visit[55];
main(){
scanf("%d%d",&N,&M);
for(int i=1;i<=M;i++){
int a,b;scanf("%d%d",&a,&b);
visit[a]++,visit[b]++;
Map[a][b]=Map[b][a]=1;}
bool falg=true;
while(1){
falg=true;
for(int i=1;i<=N;i++){
if(visit[i]==1){
sum++,xi=i,falg=false,visit[i]--;break;}}
if(falg)break;
for(int i = 1;i<=N;i++){
if(Map[xi][i]==1)
visit[i]--;}}
printf("%d\n",sum);}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int f(int n) {
  int k = 0;
  while (n % 100 == 0) {
    k++;
    n /= 100;
  }
  return k;
}
int main2() {
  int D = nextInt();
  int N = nextInt();
  for (int n = 1; ; n++) {

    if (f(n) == D) {
      N--;
      if (N <= 0) {
        cout << n << endl;
        return 0;
      }
    }
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
import math

nn = math.factorial(n)

if n ==1:
    print(1)
    
elif n ==2:
    print(2)
else:
    sosu =[2]  
   
    for i in range(3,n+1,2):
        judge = 0
        for j in range(2,i):
            if i % j == 0:
                judge = 1
        if judge ==0:
            sosu.append(i)
    
    slist =[0]*len(sosu)
    for k in range(0,len(sosu)):
        m = nn
        count = 0
        while m % sosu[k] ==0:
            m = m //sosu[k]
            count +=1
        slist[k] = count
    
    res = 1
    for l in range(0,len(slist)):
        res =res*(slist[l]+1) % 1000000007

    print(res)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, m;
	int[] b, a;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			b=new int[n];
			a=new int[m];
			for(int i=0; i<n; i++){
				b[i]=sc.nextInt();
			}
			for(int i=0; i<m; i++){
				a[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int p=0;
		int i;
		for(i=0; i<m; i++){
			p+=a[i];
			if(p>=n-1){
				break;
			}
			p+=b[p];
			if(p>=n-1){
				break;
			}
		}
		println(""+(i+1));
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int tanka[5] = {5,7,5,7,7};

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        string field[41];
        for(int i = 1; i <= n; i++) cin >> field[i];
        for(int start = 1; start <= n; start++) {
            int nowval = 0;
            int nowindex = 0;
            for(int i = start; i <= n; i++) {
                nowval += field[i].size();
                if(nowval == tanka[nowindex]) {
                    nowval = 0;
                    nowindex++;
                }
                if(nowindex == 5) break;
            }
            if(nowindex == 5) {
                cout << start << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,x,y,z,k,s;
  cin>>k>>s;
  int ans=0;
  for(i=0;i<=k;i++){
    for(j=0;j<=k;j++){
      if(s-i-j<=k&&0<=s-i-j){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
	return 0;
	}


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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n, x, t;

    std::cin >> n >> x >> t;

    std::cout << (n + x - 1) / x * t << std::endl;

    return 0;
}

Measured memory_bytes: 3632
N=int(input())
T,A = map(int,input().split())
H=list(map(int,input().split()))
I=[0]*N

target=(T-A)/0.006

for i,point in enumerate(H):
  I[i]= abs(H[i]-target)

#print(I)
mini=min(I)
print(I.index(mini)+1)

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {

    input = input.split("\n");
  
    let vals = input[0].split(" ");
    
    let A = parseInt(vals[0], 10);  // 赤
    let B = parseInt(vals[1], 10);  // 緑
    let C = parseInt(vals[2], 10);  // 青

    let cnt = parseInt(input[1], 10);

    let i = 0;

    while (A >= B) {
        B = B * 2;
        i++;
    }

    while (B >= C) {
        C = C * 2;
        i++;
    }

    if (i <= cnt) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int G(int a,int b){
  int R;
  R=max(a,b)%min(a,b);
  if(R==0)
    return min(a,b);
  else{
    while(true){
      if(b%R!=0){
        int r;
        r=b%R;
        b=R;
        R=r;
      }
      else{
        return R;
      }
    }
  }
}
  
  

 
int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int g=A.at(0);
  for(int i=1;i<N;i++){
    g=G(g,A.at(i));
  }
  cout<<g;
  
}

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

min_a = min(A)
max_a = max(A)

ans = float("inf")
for i in range(min_a, max_a+1):
  tmp = 0
  for j in A:
    tmp += (i - j) ** 2
  ans = min(ans, tmp)
  
print(ans)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll sum=0;
  for(auto&& e: a) 
  {
    cin>>e;
    sum+=e;
  }
  vector<ll> cost(n-1);
  ll left=0;
  for (int i = 0; i < n-1; ++i)
  {
    left+=a[i];
    cost[i]=abs(sum-left-left);
  }
  cout<<*min_element(cost.begin(), cost.end())<<endl;
}

Measured memory_bytes: 6404
import collections

n,m,k = map(int,raw_input().split(' '))

friendships = [map(int, raw_input().split(' ')) for _ in range(m)]
disses = [map(int, raw_input().split(' ')) for _ in range(k)]

parent = {i:i for i in range(0, n+1)}
sizes = {i:1 for i in range(0, n+1)}

hd = collections.Counter()

adj = collections.defaultdict(set)

def f(parent, u):
	if parent[u] != u: 
		parent[u] = f(parent, parent[u])
	return parent[u]

for a,b in friendships:
	if a == b: continue

	pa,pb = f(parent, a), f(parent, b)
	
	adj[a].add(b)
	adj[b].add(a)

	if pa != pb:
		if sizes[pa] >= sizes[pb]:
			parent[pb] = pa
			sizes[pa] += sizes[pb]
		else:
			parent[pa] = pb
			sizes[pb] += sizes[pa]

for c,d in disses:
	pc,pd = f(parent, c), f(parent, d)
	if (pc == pd):
		hd[c] += 1
		hd[d] += 1
"""
hd[u] = k
u has k disses in its connected component
"""

print ' '.join([str(sizes[f(parent,u)] - len(adj[u]) - hd[u] - 1)  for u in range(1, n+1)])

Measured memory_bytes: 116124
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
     
public class Main{
    
    static InputReader ir;
    static PrintWriter out;

    static void solve(){
	int t=ir.nextInt();
        while(t-->0){
	    int n=ir.nextInt();
	    int k=ir.nextInt();
	    int[] x=ir.nextIntArray(n);
	    int[] a=new int[n-1];
	    for(int i=0;i<n-1;i++)
		a[i]=x[i+1]-x[i];
	    Arrays.sort(a);
	    long ret=0;
	    for(int i=0;i<Math.max(0,n-k);i++)
		ret+=(long)a[i];
	    out.println(ret);
	}
    }

    public static void main(String[] args) throws Exception {
	ir = new InputReader(System.in);
     	out = new PrintWriter(System.out);
	solve();
	out.flush();
     }
 
    static class InputReader {
	private InputStream in;
	private byte[] buffer=new byte[1024];
	private int curbuf;
	private int lenbuf;

	public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
   
	public boolean hasNextByte() {
	    if(curbuf>=lenbuf){
		curbuf= 0;
		try{
		    lenbuf=in.read(buffer);
		}catch(IOException e) {
		    throw new InputMismatchException();
		}
		if(lenbuf<=0) return false;
	    }
	    return true;
	}
  
	private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
	private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
  
	private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
	public boolean hasNext(){skip(); return hasNextByte();}
  
	public String next(){
	    if(!hasNext()) throw new NoSuchElementException();
	    StringBuilder sb=new StringBuilder();
	    int b=readByte();
	    while(!isSpaceChar(b)){
		sb.appendCodePoint(b);
		b=readByte();
	    }
	    return sb.toString();
	}
  
	public int nextInt() {
	    if(!hasNext()) throw new NoSuchElementException();
	    int c=readByte();
	    while (isSpaceChar(c)) c=readByte();
	    boolean minus=false;
	    if (c=='-') {
		minus=true;
		c=readByte();
	    }
	    int res=0;
	    do{
		if(c<'0'||c>'9') throw new InputMismatchException();
		res=res*10+c-'0';
		c=readByte();
	    }while(!isSpaceChar(c));
	    return (minus)?-res:res;
	}
  
	public long nextLong() {
	    if(!hasNext()) throw new NoSuchElementException();
	    int c=readByte();
	    while (isSpaceChar(c)) c=readByte();
	    boolean minus=false;
	    if (c=='-') {
		minus=true;
		c=readByte();
	    }
	    long res = 0;
	    do{
		if(c<'0'||c>'9') throw new InputMismatchException();
		res=res*10+c-'0';
		c=readByte();
	    }while(!isSpaceChar(c));
	    return (minus)?-res:res;
	}
  
	public double nextDouble(){return Double.parseDouble(next());}
  
	public int[] nextIntArray(int n){
	    int[] a=new int[n];
	    for(int i=0;i<n;i++)
		a[i]=nextInt();
	    return a;
	}
  
	public char[][] nextCharMap(int n,int m){
	    char[][] map=new char[n][m];
	    for(int i=0;i<n;i++)
		map[i]=next().toCharArray();
	    return map;
	}
    }
}



Measured memory_bytes: 34960
import math

N = int(input())

li = []

for i in range(N):
    x, l = map(int, input().split())
    li.append([x-l,x+l])

li.sort(key=lambda x:x[0])
li.sort(key=lambda x:x[1])

ans = 0
t = 0 - 10**9 + 99
for i in range(N):
    if t <= li[i][0]:
        ans += 1
        t = li[i][1]

print(ans)

Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C=0,D=0,F=0;
  cin >> A;
  vector<int>P(A);
  rep(i,A)cin >> P[i];
  Sort(P);
  Out(P[A-1]-P[0]);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	string s;

	cin >> s;
	for(int i = s.size() - 1; i >= 0;){
		if(s[i] == 'r'){
			if(i < 1){
				cout << "NO" << endl;
				return 0;
			}
			if(s[i - 1] == 'e'){
				if(i < 2){
					cout << "NO" << endl;
					return 0;
				}
				if(s[i - 2] == 's'){
					if(i < 5){
						cout << "NO" << endl;
						return 0;
					}
					if(s[i - 3] == 'a' && s[i - 4] == 'r' && s[i - 5] == 'e'){
						i -= 6;	
					}
					else{
						cout << "NO" << endl;
						return 0;
					}
				}
				else if(s[i - 2] == 'm'){
					if(i < 6){
						cout << "NO" << endl;
						return 0;
					}
					if(s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd'){
						i -= 7;	
					}
					else{
						cout << "NO" << endl;
						return 0;
					}
				}
				else{
					cout << "NO" << endl;
					return 0;
				}
			}
			else{
				cout << "NO" << endl;
				return 0;
			}
		}
		else if(s[i] == 'e'){
			if(i < 4){
				cout << "NO" << endl;
				return 0;
			}
			if(s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e'){
				i -= 5;	
			}
			else{
				cout << "NO" << endl;
				return 0;
			}
		}
		else if(s[i] == 'm'){
			if(i < 4){
				cout << "NO" << endl;
				return 0;
			}
			if(s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd'){
				i -= 5;	
			}
			else{
				cout << "NO" << endl;
				return 0;
			}
		}
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int v[105] , w[105];
long long int dp[101][100010];
long long int solve(int n , int weight)
{
	if(n==0 || weight==0) return 0;
	if(dp[n][weight]!=-1) return dp[n][weight];
	
	if(w[n]<=weight)
	{
		dp[n][weight]= max(v[n] + (long long int)solve(n-1 , weight-w[n]) , (long long int)solve(n-1 , weight));
	}
	else
	    dp[n][weight]= (long long int)solve(n-1 , weight);
	    
	return dp[n][weight];
}
int main()
{
	int n , weight;
	cin>>n>>weight;
	for(int i=1;i<=n;i++)
	{
		int x , y;
		cin>>x>>y;
		w[i]=x;
		v[i]=y;
	}
	memset(dp , -1 , sizeof(dp));
	long long int ans=solve(n , weight);
	cout<<ans<<endl;
}

Measured memory_bytes: 79104
N, T = map(int, raw_input().split())
t = map(int, raw_input().split())
res = N * T
for t1, t2 in zip(t[:-1], t[1:]):
  if t2 - t1 > T:
    continue
  dup = t1 + T - t2
  res -= dup
print res

Measured memory_bytes: 27856
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<String, Integer> strMoney = new HashMap<>();

        int n = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            if (strMoney.containsKey(s)) {
                strMoney.put(s, strMoney.get(s) + 1);
            } else {
                strMoney.put(s, 1);
            }
        }

        int m = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < m; i++) {
            String s = scanner.nextLine();
            if (strMoney.containsKey(s)) {
                strMoney.put(s, strMoney.get(s) - 1);
            } else {
                strMoney.put(s, -1);
            }
        }

        int max = 0;
        for (String key : strMoney.keySet()) {
            int money = strMoney.get(key);
            if (money > max) {
                max = money;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21972
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	graph := make([][]bool, N)
	for i := 0; i < N; i++ {
		graph[i] = make([]bool, N)
	}
	for i := 0; i < M; i++ {
		a, b := ReadInt()-1, ReadInt()-1
		graph[a][b] = true
		graph[b][a] = true
	}

	order := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		order[i] = i + 1
	}

	ans := 0
	for {
		ok := true
		origin := 0
		for _, dest := range order {
			if !graph[origin][dest] {
				ok = false
				break
			}
			origin = dest
		}
		if ok {
			ans++
		}
		if !NextPermutation(order) {
			break
		}
	}
	fmt.Println(ans)
}

func NextPermutation(xs []int) bool {
	k := len(xs) - 2
	for ; k >= 0 && xs[k] >= xs[k+1]; k-- {
	}
	if k < 0 {
		return false
	}
	l := len(xs) - 1
	for ; xs[k] > xs[l]; l-- {
	}
	xs[k], xs[l] = xs[l], xs[k]
	for l, r := k+1, len(xs)-1; l < r; {
		xs[l], xs[r] = xs[r], xs[l]
		l++
		r--
	}
	return true
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1852
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))

ans = 0

for a, b, c in combinations(L, 3):
    if a == b or b ==c or a == c:
        continue
    if a + b + c - max(a, b, c) > max(a, b, c):
        ans += 1

print(ans)

Measured memory_bytes: 9048
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#define N 100000
using namespace std;

typedef struct{
	int parent;
	vector<int> decent;
	int dd;
} Node;
Node node[N];
int d[N];

int dep(int);
void swap(int *,int *);

int main(){
	int n,id,k,a;
	cin>>n;
	for(int i=0;i<n;i++){
		node[i].parent=-1;
		d[i]=-1;
	}
	for(int i=0;i<n;i++){
		cin>>id>>k;
		node[id].dd=k;
		for(int j=0;j<k;j++){
			cin>>a;
			node[a].parent=id;
			node[id].decent.push_back(a);
		}
	}
		for(int i=0;i<n;i++){
			if(node[i].parent==-1){
				d[i]=0;
				dep(i);
				break;
			}
		}
		for(int i=0;i<n;i++){
			printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,d[i]);
			if(node[i].parent==-1){
				printf("root, [");
				for(int j=0;j<node[i].decent.size();j++){
					printf("%d",node[i].decent.at(j));
					if(j!=node[i].decent.size()-1) printf(", ");
				}
				printf("]\n");
			}else if(node[i].decent.empty()){
				printf("leaf, []\n");
			}else{
				printf("internal node, [");
				for(int j=0;j<node[i].decent.size();j++){
					printf("%d",node[i].decent.at(j));
					if(j!=node[i].decent.size()-1) printf(", ");
				}
				printf("]\n");
			}
		}
	return 0;
}

int dep(int id){
	int in=id;
		for(int i=0;i<node[id].decent.size();i++){
			in=node[id].decent.at(i);
			d[in]=d[id]+1; //???????????????????¶????
			dep(in);
		}
	return 0;
}

void swap(int *a,int *b){
	int w=*a;
	*a=*b;
	*b=w;
}

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

int main() {
	bool prime[10000000];
	fill(prime, prime + 1000000, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i * i < 1000000; i++) {
		for (int j = 2; j * i < 1000000; j++) {
			if (!prime[i * j]) continue;
			prime[i * j] = false;
		}
	}

	int n;
	while (cin >> n) {
		if (n == 0) break;

		int t = 0, sum = 0;
		while (n > 0) {
			if (!prime[++t]) continue;

			n--;
			sum += t;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4052
def exam2():
    N, L = LI()
    S =[None]*N
    for i in range(N):
        S[i] = str(input())
    S.sort()
#    print(S)
    print("".join(map(str,S)))



import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

exam2()

Measured memory_bytes: 38256
N = int(input())
An = list(map(int, input().split()))

Sn = [0] * (N+1)
for i in range(1, N+1):
    Sn[i] = An[i-1] + Sn[i-1]

ans = float("inf")
for i in range(1, N):
    ans = min(ans, abs(Sn[N]-Sn[i] - Sn[i]))

print(ans)


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, m, mr = INT_MAX, mm = INT_MAX;
    cin >> a >> b >> m;
    vector<int>r(a, 0), mic(b, 0);
    for(int i = 0; i < a; i++) {
        cin >> r[i];
        mr = min(mr, r[i]);
    }
    for(int i = 0; i < b; i++) {
        cin >> mic[i];
        mm = min(mm, mic[i]);
    }
    int x, y, c, ans = mr+mm;
    for(int i = 0; i < m; i++) {
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, r[x] + mic[y] - c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3992
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <climits>
using namespace std;
#define ll long long int
int main(){
    ll A,B , N;
    cin >> A >> B >> N;
    ll ans;
    ll r;
    if(N<B)
       r=N;
    else
        r=B-1;
    ans = (A/B)*r+floor((double(A%B)/B)*r);
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

#define ll long long

#define si(x) scanf("%d", &x)
#define sll(x) scanf("%lld", &x)

int main(){
    ll a, b, c, k, sum = 0;

    sll(a), sll(b), sll(c), sll(k);

    if(a >= k){
        sum += k;
        k = 0;
    }else{
        sum += a;
        k -= a;
    }

    if(b >= k){
        k = 0;
    }else{
        k -= b;
    }

    if(c >= k){
        sum -= k;
    }else{
        sum -= c;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3748
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        boolean judge = true;
        if (1 < n) {
            for (int i = 0; i < h.length - 1; i++) {
                if (h[i + 0] <= h[i + 1] - 1) {
                    h[i + 1] -= 1;
                } else if (h[i + 0] != h[i + 1]) {
                    judge = false;
                    break;
                }
            }
        }
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 48468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;


ll n;
vector<ll> dp(202020,-1);
vector<ll> nex(202020,0);

ll solve(ll k){
    if(dp[k]>=0){
            return dp[k];
    }
    
    if(k==n-1) {
        dp[k]=1;
        return 1;
    }
    else {
        if(nex[k]==0) {
            dp[k]=solve(k+1)%Mod;
            return dp[k];
        }
        else {
            dp[k]=(solve(k+1)+solve(nex[k]))%Mod;
            return dp[k];
        }
    }

}


int main(){
    ll i,j;
    cin>>n;
    ll c[n];
    ll v[202020];
    for(i=0;i<202020;i++) v[i]=-1;
    
    for(i=0;i<n;i++){
        cin>>c[i];
        if(v[c[i]]>=0&&v[c[i]]+1<i) {
            nex[v[c[i]]]=i;
        }
        v[c[i]]=i;
    }
    
    cout<<solve(0)<<endl;

    return 0;
}

Measured memory_bytes: 12800
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define pf psuh_front
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

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

const ll N = 2 * 1e5 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll x, cnt;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> x;

  cout << (x / 11) * 2 + (x % 11 + 5) / 6;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n-1);
  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];
  for(int i=0;i<n;i++)
  { sum=sum+b[a[i]-1];}//cout<<b[a[i]-1]<<" ";}
  for(int i=1;i<n;i++)
    if((a[i-1]+1)==a[i])
    { sum=sum+c[a[i-1]-1];}
  cout<<sum;
           
  return 0;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
     public static void main(String[] args) {
        
        String s;
        
        Scanner input = new Scanner(System.in);
        
        s = input.nextLine();
        
        String s1 =  s.replace(",", " ");
       
        System.out.println(s1);
        
    }
}


Measured memory_bytes: 21716
N, M=map(int, input().split())
ball=[1]*N
red=[0]*N
red[0]=1
for i in range(M):
  x, y = map(int, input().split())
  ball[x-1]-=1
  ball[y-1]+=1
  if red[x-1]==1:
    red[y-1]=1
    if ball[x-1]==0:
      red[x-1]=0
print(sum(red))

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

int main(){
    long long int n, ans, sum;
    long long int a[5001];
    
    while(cin >> n){
        if(n == 0){
            break;
        }
        
        memset(a, 0, sizeof(a));
        
        for(int i = 0;i < n;i++){
            cin >> a[i];
        }
        
        ans = a[0];
            
        for(int i = 0;i < n;i++){
            sum = 0;
                
            for(int j = i;j < n;j++){
                sum += a[j];
                ans = max(sum, ans);
            }
        }
        
        cout << ans << endl;
    }

    return 0;
}

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

typedef long long ll;

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

      int n; cin >> n;
      if (n == 1) cout << "Hello World";
      else {
            int a, b; cin >> a >> b;
            cout << a+b;
      }

	return 0;
}


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

int main() {
  
  string S;
  
  cin >> S;
  
  if(S.at(0)=='A' && S.at(1)=='A' && S.at(2)=='A') {
    
    cout << "No" << endl;
    
  } else if(S.at(0)=='B' && S.at(1)=='B' && S.at(2)=='B') {
    
    cout << "No" << endl;
    
  } else {
    
    cout << "Yes" << endl;
    
  }
  
}

Measured memory_bytes: 256
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    A, B = ZZ()

    def bunkai(num):
        p = set()
        p.add(1)
        i = 2
        while i * i <= num:
            while num%i == 0:
                p.add(i)
                num //= i
            i += 1
        p.add(num)
        return p

    a = bunkai(A)
    b = bunkai(B)
    print(len(a & b))

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MAX 100002
typedef long long ll;
ll N, a[MAX];

int main(){
    scanf("%lld", &N);
    for(int i = 1; i <= N; i++)
        scanf("%lld", a + i);
    sort(a + 1, a + N + 1, [](const ll &x, const ll &y){
        return x > y;
    });
    ll ans = 0;
    ll mn = 1e9;
    for(int i = 2; i <= N; i++){
        if(abs(a[1] / 2 - a[i]) < mn){
            mn = abs(a[1] / 2 - a[i]);
            ans = a[i]; 
        }
    }
    printf("%lld %lld\n", a[1], ans);
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = 0;
	boolean check = false;

	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;

	    int[] page = new int[n];

	    for(int i = 0;i<n;i++) page[i] = sc.nextInt();

	    check = false;
	    System.out.print(page[0]);
	    if(n<=1) System.out.println();

	    for(int i = 1;i<n;i++){
		if(page[i-1]+1 != page[i]){
		    if(check){
			System.out.print("-" + page[i-1] + " " + page[i]);
			check = false;
		    }else{
			System.out.print(" " + page[i]);
		    }
		    if(i>=n-1) System.out.println();
		}else{
		    check = true;
		    if(i>=n-1) System.out.println("-" + page[i]);
		}
	    }

	}
    }
}

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

// int A = 2;
// int B = 2;
// int C = 2;

// int X = 100;

int A, B, C, X;

int main() {
    cin >> A >> B >> C >> X;
    int result = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int target = X - (500 * i) - 100 * j - 50 * k;
                if (target == 0) {
                    result++;
                }
            }
        }
    }

    cout << result << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, a;
    cin >> n;
    set<ll> st;
    for (ll i = 0; i < n; i++) {
        cin >> a;
        st.insert(a);
    }
    cout << (st.size() == n ? "YES" : "NO");
    return 0; 
}

Measured memory_bytes: 9600