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

int main(void){
  int n;
  while(cin>>n,n){
    map<string,pair<int,int> > S;
    for(int i=0;i<n;++i){
      string s;cin>>s;
      int weekday,start;
      cin>>weekday>>start;
      if(start>=2400){
        weekday=(weekday+1)%7;
        start%=2400;
      }
      S[s]=make_pair(weekday,start);
    }
    int p;cin>>p;
    set<string> F;
    for(int i=0;i<p;++i){
      string s;cin>>s;
      F.insert(s);
    }
    vector<int> A(60*24*7);
    int ans=F.size();
    for(set<string>::iterator it=F.begin();it!=F.end();++it){
      int w = S[*it].first;
      int t = S[*it].second;
      int tt = t/100*60+t%100;
      for(int i=0;i<30;++i){
        ++A[(60*24*w+tt+i)%(60*24*7)];
        if(A[(60*24*w+tt+i)%(60*24*7)]>1) ans=-1;
      }
    }
    if(ans>=0){
	    vector<int> nF;
	    int i=0,mx=ans;
	    for(map<string,pair<int,int> >::iterator it=S.begin();it!=S.end();++it){
	      int w = (*it).second.first;
	      int t = (*it).second.second;
	      int tt = t/100*60+t%100;
	      nF.push_back(w*24*60+tt);
	    }
	    sort(nF.begin(),nF.end());
	    //cerr<<"#"<<nF.size()<<endl;
    	for(int i=0;i<nF.size();++i){
    		int cnt=0;
    		vector<int> B(24*60*7);
    		for(int j=0;j<24*60*7;++j)B[j]=A[j];
    		for(int j=i;j<i+nF.size();++j){
    			int strt = nF[j%nF.size()];
	    		bool f=false;
	    		//cerr<<"##"<<*it<<endl;
	    		for(int k=strt;k<strt+30;++k){
	    			if(B[k%(24*60*7)]>0) f=true;
	    		}
	    		if(f)continue;
	    		for(int k=strt;k<strt+30;++k){
	    			++B[k%(24*60*7)];
	    		}
	    		++cnt;
    		}
    		if(ans+cnt>mx)mx=ans+cnt;
    	}
    	ans=mx;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
def main():
  from itertools import combinations
  x = int(input())
  ls = [0]
  a = 0
  b = 0
  if x == 1:
    print(0, -1)
    exit()
  for i in range(1, 200):
    ls.append(i**5)
    ls.append(-i**5)
  ls.sort()
  for b in ls:
    if x + b in ls:
      a = x + b  
      break
  if a < 0:
    print(-1*int(pow(-a, 0.2)), end=' ')
  else:
    print(int(pow(a, 0.2)), end=' ')
  if b < 0:
    print(-1*int(pow(-b, 0.2)), end=' ')
  else:
    print(int(pow(b, 0.2)), end=' ')
  


if __name__ == '__main__':
  main()

Measured memory_bytes: 62588
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
    ll n;
    cin>>n;
    ll a;
    vll d(100000,0);
    ll count=0;
    rep(i,n){
        cin>>a;
        if(a>100000) count++;
        else d[a]++;
    }
    rep(i,100000){
        if(d[i]<i) count+=d[i];
        if(d[i]>i) count+=d[i]-i;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
s = list(map(int,list(input())))
ff = 10*s[0]+s[1]
ss = 10*s[2]+s[3]

if 0<=ff<=99 and 0<=ss<=99:
    if 1<=ff<=12:
        if 1<=ss<=12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if 1<=ss<=12:
            print("YYMM")
        else:
            print("NA")
else:print("NA")


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N,M;
    cin >> N >> M;
    int L[M],R[M];
    int num_max_L=0,num_min_R=100000;
    for(int i=0;i<M;++i){
        cin >> L[i] >> R[i];
        num_max_L=max(num_max_L,L[i]);
        num_min_R=min(num_min_R,R[i]);
    }
    int num=0;
    for(int i=1;i<=N;++i){
        if(i>=num_max_L && i<=num_min_R){
            ++num;
        }
    }
    cout << num;
    }


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int gcd(int a,int b){
    int temp;
    while(b!=0){
        temp=a;
        a=b;
        b=temp%b;
    }
    return a;
}

int main(){
    int n,k; cin>>n>>k;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    sort(al(a));
    int GCD=a[0];
    rep(i,n-1) GCD=gcd(GCD,a[i+1]);
    if(k<=a.back() && k%GCD==0)
    cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 3692
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	a, b, x = LI()
	if a%x == 0:
		y = 1
	else:
		y = 0
	print(b//x - a//x + y)

if __name__ == '__main__':
    main()

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

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  set<int>set;
  set.insert(a);
  set.insert(b);
  set.insert(c);
  cout << set.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){

   int sx, sy, gx, gy;
   cin>> sx>> sy>> gx>> gy;

   string s;
   s+=string(gy-sy, 'U');
   s+=string(gx-sx, 'R');
   s+=string(gy-sy, 'D');
   s+=string(gx-sx, 'L');
   s+="L";
   s+=string(gy-sy+1, 'U');
   s+=string(gx-sx+1, 'R');
   s+="D";
   s+="R";
   s+=string(gy-sy+1, 'D');
   s+=string(gx-sx+1, 'L');
   s+="U";

   cout<< s<< endl;

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> d(100000,-1);

void dfs(ll a,vector<vector<pair<ll,ll>>> &v){
    for(int i=0;i<v[a].size();i++){
        if(d[v[a][i].first]!=-1) continue;
        d[v[a][i].first]=d[a]+v[a][i].second;
        dfs(v[a][i].first,v);
    }
}

int main(){
    ll n;cin>>n;
    vector<vector<pair<ll,ll>>> v(n);
    for(int i=0;i<n-1;i++){
        ll a,b,c;cin>>a>>b>>c;
        a--;b--;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    ll q,k;cin>>q>>k;
    k--;
    d[k]=0;
    dfs(k,v);
    vector<ll> ANS(q);
    for(int i=0;i<q;i++){
        ll x,y;cin>>x>>y;
        x--;y--;
        ANS[i]=d[x]+d[y];
    }
    for(int i=0;i<q;i++) cout<<ANS[i]<<endl;
}

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

int main(){
	int a,b,c,n,t;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		if(a<b){
			t=a;
			a=b;
			b=t;
		}
		if(a<c){
			t=a;
			a=c;
			c=t;
		}
		cout<<(a*a==b*b+c*c ? "YES\n" : "NO\n");
	}
	return 0;
}

Measured memory_bytes: 1120
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for(int i = 1; i <= n; i++) cin >> a[i];
	vector<int> b(n + 1, 0);
	for(int i = n; i >= 1; i--){
		int cnt = 0;
		for(int j = 2; j * i <= n; j++){
			cnt += b[j * i];
		}
		cnt %= 2;
		if(cnt != a[i]) b[i] = 1;
	}
	vector<int> res;
	for(int i = 1; i <= n; i++){
		if(b[i] == 1) res.push_back(i);
	}
	cout << res.size() << endl;
	for(int i = 0; i < res.size(); i++){
		cout << res[i] << (i == res.size() - 1 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}
// (int) * (int) => (int)
// (int) / (int) => (int)

main(){cin.tie(0);ios::sync_with_stdio(false);
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	--s;--t;
	vpli E1[n],E2[n];
	fr(i,m){
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		--u;--v;
		E1[u]<<pli{a,v};
		E1[v]<<pli{a,u};
		E2[u]<<pli{b,v};
		E2[v]<<pli{b,u};
	}
	vpli vs=dijkstra(n,E1,s,(ll)1e15);
	vpli vt=dijkstra(n,E2,t,(ll)1e15);
	vl A(n);
	rf(i,n){
		A[i]=vs[i].first+vt[i].first;
		if(i!=n-1)A[i]=min(A[i+1],A[i]);
	}
	fr(i,n){
		print((ll)1e15-A[i]);
	}
}


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

int main()
{
   int n;
   cin >> n;
   int a[n];
   for(int i = 0; i < n; i++)
    cin >> a[i];
   sort(a, a+n);
   cout << a[n-1] - a[0] << endl;



    return 0;
}




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

typedef long long ll;

using namespace std;


int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    for (int i = 0; i < N; i++) {
        if (i == K - 1) {
            cout << (char)(S[i] - 'A' + 'a');
        } else {
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;
int mod_pow(int x,int n,int mod){
  int res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}

int carmichaelLambda(int n){
  int res = 1;
  if(n % 8 == 0) n/=2;
  auto lcm = [](int a,int b){return (a/__gcd(a,b)) * b;};

  auto compute = [&](int i){
    int sub = i - 1;
    n/=i;
    while(n%i == 0) n/=i, sub *=i;
    res = lcm(res,sub);
  };

  for(int i=2;i*i<=n;i++) if( n % i == 0) compute(i);
  if(n != 1) compute(n);
  return res;
}

signed main(){
  cin>>n;
  int car = carmichaelLambda(n);
  int car2 = carmichaelLambda(car);
  int ans = car2;
  if(mod_pow(n,1,car)==1) ans = 1;
  
  for(int i=1;i*i<=car2;i++){
    if(mod_pow(n,car2/i,car) == 1) Min(ans,car2/i);
    if(mod_pow(n,i,car) == 1) Min(ans,i);
  }
  
  if(car != 1 && mod_pow(n,car2,car) !=  1)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadIntArray();
            Array.Sort(A);

            int mx = A[A.Length - 1];
            int mn = A[A.Length - 2];
            for (int i = 0; i < A.Length - 2; i++)
            {
                if (Math.Abs(mx - mn * 2) > Math.Abs(mx - A[i] * 2))
                    mn = A[i];
            }

            Console.WriteLine("{0} {1}", mx, mn);

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

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

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

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

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 20960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int x=a.length();
    for(int i=0;i<x;i++)
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}





Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
constexpr int MOD=998244353;
constexpr int MAX=510000;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),cnt(100010);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        sum+=a[i];
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int b,c;
        cin>>b>>c;
        sum+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4048
n=int(input())
p=[int(x) for x in input().split()]

res=0
for i in range(n-2):
  if p[i]<p[i+1] and p[i+1]<p[i+2]:
    res+=1
  elif p[i]>p[i+1] and p[i+1]>p[i+2]:
    res+=1
print(res)

Measured memory_bytes: 38256
def resolve():
    (N, A, B, C) = list(map(int, input().split(" ")))
    ls = [int(input()) for i in range(N)]
    targets = [A, B, C]

    mincost = float('inf')
    for i in range(1, 1<<N):
        for j in range(1, 1<<N):
            if i & j: continue
            for k in range(1, 1<<N):
                if i & k: continue
                if j & k: continue
                
                cost = 0
                lensum = [0, 0, 0]
                for idx, target in enumerate([i, j, k]):
                    # 状態bitに基づいて長さとcostを算出
                    for order in range(N):
                        if (target >> order) & 1:
                            cost = cost + (10 if lensum[idx] != 0 else 0) # 一本目は合成魔法を使わない
                            lensum[idx] = lensum[idx] + ls[order]
                    if lensum[idx] != targets[idx]:
                        cost = cost + abs(targets[idx] - lensum[idx])
                
                mincost = min(mincost, cost)
    print(mincost)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str;
			int i = 1;
			int j;
			while((str = br.readLine()) !=  null){
				j = Integer.parseInt(str);
				if(j == 0) {
					break;
				}
				System.out.println("Case " + i + ": " + str);
				i++;
			}
			br.close();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}

Measured memory_bytes: 26204
A,B,C,K=map(int,input().split())
ans=0
ans=K
K-=A
def chk(k):
    if k>0:
        return True
    else:
        return False

if not chk(K):
    print(ans)
    exit()
ans=A
K-=B
if not chk(K):
    print(ans)
    exit()

ans=ans-K
print(ans)

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

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


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N; cin >> N;
VI h(N); rep(i, 0, N) cin >> h[i];

// 全探索．ジャンプ距離が +1 or +2 で O(2^N)．
// dp[i] = i に行くための最小コスト
VI dp(N); 
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);

rep(i, 2, N){
    dp[i] = min(dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2]));
}

cout << dp[N-1] << endl;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 1024
A = list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])
k = int(input())
print(A[k-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

bool p[22][52];

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

int main()
{
    int n;
    cin >> n;
    WeightedGraph<int> g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b, i);
        g.add_edge(b, a, i);
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        P pre[54];
        fill(pre, pre + n, P(-1, -1));
        queue<int> que;
        pre[u] = P(-2, -2);
        que.push(u);
        while(que.size()){
            int w = que.front();
            que.pop();
            for(Edge<int> e : g.g[w]){
                if(pre[e.to] == P(-1, -1)){
                    pre[e.to] = P(w, e.cost);
                    que.push(e.to);
                }
            }
        }
        vector<int> d;
        while(pre[v].second != -2){
            d.push_back(pre[v].second);
            v = pre[v].first;
        }
        for(int w : d) p[i][w] = true;
    }
    ll foo = 0;
    for(int b = 1; b < (1 << m); b++){
        bool ap[52]{0};
        int e = 0;
        for(int i = 0; i < m; i++){
            if((b >> i) & 1){
                for(int j = 0; j < n - 1; j++) ap[j] = (ap[j] | p[i][j]);
                e++;
            }
        }
        ll l = 0;
        for(int j = 0; j < n - 1; j++) if(!ap[j]) l++;
        if(e % 2) foo += (1ll << l);
        else foo -= (1ll << l);
    }
    cout << (1ll << (n - 1)) - foo << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

inline void solve()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int a[55];
int main()
{
    int t;
    int n;
    scanf("%d%d",&t,&n);
    for(int i=1;i<=t;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+t);
    int s=0;
    for(int i=t-n+1;i<=t;i++)
        s+=a[i];
    printf("%d\n",s);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

bool isPow(int n) {
	while (n > 1) {
		if (n % 2 == 1) {
			return false;
		}
		n /= 2;
	}
	return true;
}
int main() {
	int N; cin >> N;
	switch (N % 4) {
	case 1:
	{
		if (N == 1) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
			for (int i = 2; i + 1 <= N; i += 2) {
				cout << i << " " << i + 1 << endl;
				cout << i + 1 << " " << 1 << endl;
				cout << 1 << " " << N + i << endl;
				cout << N + i << " " << N + i + 1 << endl;
			}
			cout << N * 2 << " " << N + 1 << endl;
		}
	}
		break;
	case 2:
	{
		if (N == 2) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
			for (int i = 2; i + 1 <= N; i += 2) {
				cout << i << " " << i + 1 << endl;
				cout << i + 1 << " " << 1 << endl;
				cout << 1 << " " << N + i << endl;
				cout << N + i << " " << N + i + 1 << endl;
			}
			cout << N * 2 - 1 << " " << N + 1 << endl;

			cout << N * 2 << " " << N * 2 - 2 << endl;
			cout << (N ^ (N-2) ^ 1) << " " << N << endl;
		}
	}
		break;
	case 3:
	{
		cout << "Yes" << endl;
		for (int i = 2; i + 1 <= N; i += 2) {
			cout << i << " " << i + 1 << endl;
			cout << i + 1 << " " << 1 << endl;
			cout << 1 << " " << N + i << endl;
			cout << N + i << " " << N + i + 1 << endl;
		}
		cout << N * 2 << " " << N + 1 << endl;
	}
		break;
	case 0:
	{
		if (isPow(N)) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
			for (int i = 2; i + 1 <= N; i += 2) {
				cout << i << " " << i + 1 << endl;
				cout << i + 1 << " " << 1 << endl;
				cout << 1 << " " << N + i << endl;
				cout << N + i << " " << N + i + 1 << endl;
			}
			cout << N * 2 - 1 << " " << N + 1 << endl;

			int M = (N ^ (N - 1) ^ 1);

			cout << N << " " << N - 1 << endl;
			cout << M + N << " " << N * 2 << endl;
		}
	}
		break;
	}

	return 0;
}


Measured memory_bytes: 2304
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
MOD = 10**9+7
A = set(A)
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        continue
    if i == 1:
        dp[1] = dp[0]
    else:
        dp[i] = (dp[i-1]+dp[i-2])%MOD
print(dp[N])

Measured memory_bytes: 13192
#include<iostream>
using namespace std;
void replaceAll(string& str, const string&pat, const string& rep) {
  string::size_type p = str.find(pat);
  while(p != string::npos) {
    str.replace(p, pat.length(), rep);
    p = str.find(pat, p + rep.length());
  }
}
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  { string str; getline(cin, str); }
  while(n--) {
    string str;
    getline(cin, str);
    replaceAll(str, "Hoshino", "Hoshina");
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, P;
  std::cin >> A >> P;
  std::cout << (A * 3 + P) / 2 << std::endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
key = list(c.keys())
val = list(c.values())
ans = 0
for i, j in zip(key, val):
    if i > j:
        ans += j
    else:
        ans += j - i
print(ans)


Measured memory_bytes: 18668
import std;

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line = readln.split;
foreach (i,T;TList){T val=line[i].to!(T);Args[i]=val;}}
void dprint(TList...)(TList Args){debug{auto s=new string[](TList.length);
static foreach(i,a;Args) s[i]=text(a);s.map!(text).join(' ').writeln;}}
alias sread=()=>readln.chomp();enum MOD =10^^9+7;
alias PQueue(T,alias less="a<b") = BinaryHeap!(Array!T,less);
// dfmt on

void main()
{
    auto S = sread();
    writeln(S == "ABC" ? "ARC" : "ABC");
}


Measured memory_bytes: 3612
N = int(input())
ans = 0
for i in range(1, N + 1):
    cnt = 0
    if i % 2 != 0:
        for j in range(1, int(pow(i, 0.5)) + 1):
            if i % j == 0:
                cnt += 1
                if j != i // j:
                    cnt += 1
        if cnt == 8:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>


using namespace std;
#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REP_(i,n,m) for( long long int i = (n); i <= (m); i++ )
#define CNT(i,n) for( long long int i = (n); i > 0; i-- )
#define CNT_(i,n) for( long long int i = (n); i >= 0; i-- )
#define SKIP(i,n,m) for( long long int i = (n); i < (m) ; i+=2 )
#define ll long long
#define ld long double
#define ft first
#define sd second
#define ALL(a) (a).begin(), (a).end()
#define srt(v) sort( v.begin(), v.end() );
#define sz(v) ( int ) v.size()
#define erase( v, i ) v.erase( v.begin() + i)
#define last(v) v[sz(v)-1]
#define swap( v, i, j ) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define out(a) printf( " %.16f¥n ", a );
#define vi vector<int>
#define vd vector<double>
#define vl vector<long long>
#define pa pair<int, int>
#define mulM( a, b, c ) a = a * b % c;
#define mp make_pair
#define pb push_back
#define iinp(a) int a; cin >> a;
#define sinp(a) string a; cin >> a;
#define ios() ios_base::sync_with_stdio(0); cin.tie(0);
#define EPS (1e-10)
#define PI 3.14159265358979323846

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

void solve(){
  sinp( s )
  int ans=100000;
  REP(i,0,sz(s)-2){
    int temp = 0,dif=0;
    temp += (s[i]-48)*100;
    temp += (s[i+1]-48)*10;
    temp += (s[i+2]-48);
    dif = abs(temp-753);
    ans = min(ans, dif);
  }
  cout << ans << endl;
}

signed main() {
    ios()
    solve();
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char s;
		int cnt=0, ans=0;
		for (int i = 0; i < S.length(); i++) {
			s = S.charAt(i);
			if (s == 'A'||s=='T'||s=='G'||s=='C')
				cnt++;
			else {
				ans = Math.max(cnt, ans);
				cnt = 0;
			}
		}
		ans = Math.max(cnt, ans);
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  long long a, b, x;
  cin >> a >> b >> x;
  if ((a % x) == 0){
    cout << (b / x) - (a / x) + 1 << endl;
  }
  else {
    cout << (b / x) - (a / x) << endl;
  }

  return 0;
}


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

typedef pair<int,int> P;
typedef pair<P,int> PP;
int H, W;
long long int L;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const string DIR = "NESW";

void solve() {
    vector<string> v(H);
    for (int i = 0; i < H; i++) cin >> v[i];

    int sx, sy, dir;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            if (v[i][j] != '.' && v[i][j] != '#') sx = i, sy = j, dir = DIR.find(v[i][j]);

    v[sx][sy] = '.';

    map<PP,long long int> m;
    map<long long int, PP> rev;
    long long int loop_start = 0LL, loop_end = L;
    for (long long int i = 0LL; i < L; i++) {
        int nx = sx + dx[dir];
        int ny = sy + dy[dir];
      check:
        if (0 <= nx && nx < H && 0 <= ny && ny < W && v[nx][ny] == '.') {
            sx = nx;
            sy = ny;
        } else {
            dir = (dir + 1) % 4;
            nx = sx + dx[dir];
            ny = sy + dy[dir];
            goto check;
        }

        if (m.find(PP(P(sx,sy),dir)) != m.end()) {
            loop_start = m[PP(P(sx, sy), dir)];
            loop_end = i - 1;
            break;
        } else {
            m[PP(P(sx, sy), dir)] = i;
            rev[i] = PP(P(sx, sy), dir);
        }
    }

    long long int itr = (L - loop_start - 1) % (loop_end - loop_start + 1);
    itr += loop_start;
    cout << rev[itr].first.first+1 << " " << rev[itr].first.second+1 << " " << DIR[rev[itr].second] << endl;
}

int main() {
    while (cin >> H >> W >> L, H || W || L) solve();

    return 0;
}

Measured memory_bytes: 3788
object Main extends App {
    var loop = readLine.split(" ")(1).toInt
    var word = readLine
    var count : Array[Int] = new Array(word.size)
	for(i <- 1 to word.size - 1) {
    	count(i) = 
     		if(word(i-1)=='A' && word(i)=='C') count(i - 1) + 1 
    		else count(i - 1)
    }
	val out = new java.io.PrintWriter(System.out)
  	for(i <- 0 to loop - 1) {
      var position = readLine.split(" ")
	out.println(count(position(1).toInt - 1) - count(position(0).toInt - 1))
    }
	out.flush
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

template<typename T>
struct BIT_AddRange {
    int n;
    vector<T> dat;

    BIT_AddRange(int n=0){
        initialize(n);
    }

    void initialize(int nin){
        n = nin;
        dat.assign(n, 0);
    }

    void addRange(int l, int r, T x){
        plus(l, x);
        if(r<n) plus(r+1, MOD-x);
    }

    T get(int i){
        return sum(i);
    }

    private:

    T sum(int i){
        T s = 0;
        while(i >= 0){
            add(s, dat[i]);
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    void plus(int i, T x){
        while(i < n){
            add(dat[i], x);
            i |= i+1;
        }
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> L(K), R(K);
    for(int i=0; i<K; i++) cin >> L[i] >> R[i];
    BIT_AddRange<int64_t> bit(N+1);
    bit.addRange(1, 1, 1);
    for(int i=1; i<N; i++){
        int64_t v = bit.get(i);
        for(int k=0; k<K; k++){
            int l = L[k]+i, r = min(N, R[k]+i);
            if(l <= r) bit.addRange(l, r, v);
        }
    }
    cout << bit.get(N) << endl;
    return 0;
}


Measured memory_bytes: 4788
// author - shreyanshjn (Shreyansh Jain)
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
/* #define input 1 */
#define INF 100000000000000000
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
const int mod = 1e9 + 7;
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string trim(const string& str) {
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() { 
    #ifdef input
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(15);
    int n, w; cin >> n >> w;
    vector<pair<int, int>> items(n + 1);
    fori(1, n + 1) {
        cin >> items[i].ff >> items[i].ss;
    }
    ll dp[n + 1][100005];
    fori(0, 100005) {
        dp[0][i] = INF; 
    }
    fori(0, n + 1) {
        dp[i][0] = 0;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int p = 1; p <= 100004; p++) {
            if(items[i].ss <= p)
                dp[i][p] = min(items[i].ff + dp[i - 1][p - items[i].ss], dp[i - 1][p]);
            else 
                dp[i][p] = dp[i - 1][p];
            if(dp[i][p] <= w) {
                ans = p;
            }
        }
    }
    cout << ans << endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

Measured memory_bytes: 82776
N, M = map(int, input().split())
K = []
A = []
for n in range(N):
    INPUT = list(map(int, input().split()))
    K.append(INPUT[0])
    A.append(INPUT[1:])
intersection=set(A[0])
for a in A:
    intersection=intersection&set(a)
print(len(intersection))

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

int main(){
    int n,xx;
    cin >> n >>xx;
    vector<int>x(n);
    for(int i = 0; i<n; i++){
      cin >> x.at(i);
    }
    int ans;
    int count=1;
    for(int i = 0; i<n; i++){
       if(ans+x.at(i) > xx){
         cout << count << endl;
         return 0;
       }else{
         ans += x.at(i);
         count++;
       }
    }
    cout << count << endl;
    
}



Measured memory_bytes: 256
import math
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def cheak(x):
  kiso = b*x
  kai = 0
  for i in h:
    if kiso < i:
      kai += math.ceil((i-kiso)/(a-b))
  if kai > x:
    return 0
  else:
    return 1
dai = max(h)
syo = 0
while True:
  if dai-syo == 1:
    break
  kon = (dai+syo)//2
  c = cheak(kon)
  if c == 1:
    dai = kon
  else:
    syo = kon
print(dai)

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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> broken(n);
  rep(i,m){
    int a;
    cin >> a;
    broken[a] = 1;
  }
  
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i=n-1; i>=0; i--){
    if (broken[i]){
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] +dp[i+2]) % mod;
  }
  
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>


using namespace std;


typedef long long ll;


int main() {

	int N;
	scanf("%d", &N);

	vector<int> a;
	a.reserve(N);
	for (int i = 0; i < N; i++) {
		int an;
		scanf("%d", &an);
		a.push_back((an-1));
	}


	int numOfPair = 0;


	vector<vector<int>> loving;
	for (int i = 0; i < N; i++) {
		loving.push_back(vector<int>());
	}

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

		// 自分が好きな人を登録
		loving[i].push_back(a[i]);

		// 相手が自分を登録しているかを見に行く
		for (auto itr = loving[a[i]].begin(); itr != loving[a[i]].end(); ++itr) {

			if ((*itr) == i) {
				numOfPair++;
			}
		}
	}

	printf("%d\n", numOfPair);

	return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(x,n);

  int ans=1e9;
  rep(p,101){
    int tmp=0;
    rep(i,n){
      tmp += (x[i] - p)*(x[i] - p);
    }
    chmin(ans, tmp);
  }
  prt(ans);

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a = 1;
    while (a <= d) {
      ans++;
      a += v[i];
    }
  }
  cout << ans + x << endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int w, n = 0, ans = 0;
  string s;
  cin >> w >> s;
  for (int i = 0; i < w; i++) {
    if (s[i] == 'I')
      n++;
    else
      n--;
    ans = max(ans, n);
  }
  cout << ans << endl;
}


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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> d(n-1);
    rep(i,n-1) d[i] = a[i+1] - a[i];

    ll money = 1000, stock = 0;
    rep(i,n-1) {
        if (stock > 0) {
            if (d[i] < 0) {
                money += a[i]*stock;
                stock = 0;
            }
        } else {
            if (d[i] > 0) {
                stock = money/a[i];
                money %= a[i];
            }
        }
    }
    money += a[n-1]*stock;
    cout << money << endl;
    return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

string lcs(string &s, string &t) {

  int n = s.size(), m = t.size();

  s.insert(s.begin(), '#');
  t.insert(t.begin(), '$');

  vector<vector<int>> mat(n + 1, vector<int>(m + 1, 0));

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      if(s[i] == t[j])
        mat[i][j] = mat[i - 1][j - 1] + 1;
      else
        mat[i][j] = max(mat[i - 1][j], mat[i][j - 1]);
    }
  }

  string ans;
  int i = n, j = m;
  while(i > 0 && j > 0) {
    if(s[i] == t[j])
      ans += s[i], i--, j--;
    else if(mat[i][j - 1] > mat[i - 1][j])
      j--;
    else
      i--;
  }

  reverse(ans.begin(), ans.end());
  return ans;
}

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s, t;

  cin >> s >> t;

  cout << lcs(s, t) << endl;

}

Measured memory_bytes: 70784
N=int(input())
D=list(map(int,input().split()))
from collections import Counter
import sys
d=Counter(D)
M=1
if D[0]!=0 or d[0]!=1:
    print(0)
    sys.exit()
for i in range(max(D)-1):
    M*=d[i+1]**d[i+2]
print(M%998244353)

Measured memory_bytes: 18932
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cstring>

std::int64_t a[100000];

int main() {
	int n, k;
	while (std::cin >> n >> k, n + k != 0) {
		for (int i = 0; i < n; ++i)
			std::cin >> a[i];

		std::int64_t res = 0, mem = 0;
		for (int i = 0; i < n; ++i) {
			mem += a[i];

			if (i >= k) {
				mem -= a[i - k];
				res = std::max(res, mem);
			}
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 3784
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let x = a.iter().skip(2).fold(0, |s, &x| s ^ x);
    let mut s = a[0] + a[1];
    let mut dp = vec![vec![vec![-1i64; 2]; 2]; 43 + 1];
    dp[0][0][0] = 0;

    for ni in 0..43 {
        let cx = (x >> ni) & 1;
        let cs = (s >> ni) & 1;
        let ca = (a[0] >> ni) & 1;
        for nj in 0..2 {
            for nk in 0..2 {
                if dp[ni][nj][nk] == -1 {
                    continue;
                }
                for na in 0..2 {
                    let nb = cx ^ na;
                    if (nj as i64 + na + nb) % 2 != cs {
                        continue;
                    }
                    let cj = if nj as i64 + na + nb >= 2 { 1 } else { 0 };
                    let ck = if na == ca {
                        nk
                    } else if ca < na {
                        1
                    } else {
                        0
                    };
                    dp[ni + 1][cj][ck] = max(dp[ni + 1][cj][ck], dp[ni][nj][nk] | (na << ni));
                }
            }
        }
    }
    if dp[43][0][0] <= 0 {
        println!("-1");
        return;
    }
    println!("{}", a[0] - dp[43][0][0]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]){
   int a,b,p;
   cin >> a >> b;
   if(a <= 0 && b >= 0){
      cout << "Zero" << endl;
      return 0;
   }
   p = 1;
   for(int i = a;i <= b;i++){
      if(i<0){
         p *= -1;
      }
   }
   if(p < 0){
      cout << "Negative" << endl;
   }else{
      cout << "Positive" << endl;
   }
   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        for (int i = 1; 9 >= i; i++) {
            for (int l = 1; 9 >= l; l++) {
                int result = l*i;
                System.out.printf("%dx%d=%d", i, l, result);
                System.out.println();
            }
        }
    }
}



Measured memory_bytes: 24888