akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    map<int,vector<int>> job;
    rep(i,0,n){
        int a,b; cin >> a >> b;
        job[a].emplace_back(b);
    }
    priority_queue<int> que;
    auto add = [&](int index){
        for(auto &x: job[index]){
            que.push(x);
        }
        return;
    };
    int ans = 0;
    rep(i,0,m+1){
        add(i);
        if(que.empty()) continue;
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
} 

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, X;
ll SIZE[52];
ll P[52];

ll f(ll n, ll x) {
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x <= SIZE[n-1] + 1) return f(n-1, x-1);
    if(x == SIZE[n-1] + 2) return 1 + P[n-1];
    if(x < SIZE[n]) return P[n-1] + 1 + f(n-1, x - SIZE[n-1] - 2);
    return P[n];
}

int main() {
    //cout.precision(10);
    cin >> N >> X;
    SIZE[0] = 1;
    P[0] = 1;
    for(int i = 1; i <= N; i++) {
        SIZE[i] = 3 + 2 * SIZE[i-1];
        P[i] = 1 + 2 * P[i-1];
    }
    cout << f(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

seq_A = []
seq_B = []

summation = 0
seq_A.append(0)
seq_B.append(0)

for i in range(0, N):
    summation += A[i]
    seq_A.append(summation)
summation = 0
for i in range(0, M):
    summation += B[i]
    seq_B.append(summation)

#print(seq_A)
#print(seq_B)

ans = 0
best = len(seq_B)-1
for i in range(len(seq_A)):
    for j in range(best, -1, -1):
        #print(j)
        if seq_A[i] + seq_B[j] <= K:
            #print(i, j)
            ans = max(ans, i+j)
            best = j
            break

print(ans)

Measured memory_bytes: 126708
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int N, B[20];
vector<vector<pair<int, int>>> A;
bool f() {
	int i, j, x, y;
	for (i = 1; i <= N; i++) {
		if (B[i] == 0) continue;
		for (j = 0; j < A[i].size(); j++) {
			x = A[i][j].first; y = A[i][j].second;
			if (B[x] != y) return false;
		}
	}
	return true;
}
int main() {
	cin >> N;
	int i, j, ans = 0, ret;
	vector<pair<int, int>> v;
	A.push_back(v);
	for (i = 0; i < N; i++) {
		int a,b,m;
		v.clear();
		cin >> m;
		while (m-- > 0) {
			cin >> a >> b;
			v.push_back({ a,b });
		}
		A.push_back(v);
	}
	for (i = 0; i < (1 << N); i++) {
		ret = 0;
		for (j = 0; j < N; j++) {
			B[j + 1] = (i >> j) & 0x1;
			ret += B[j + 1];
		}
		if (ans >= ret) continue;
		if (f()) ans = ret;
	}
	cout << ans << endl;
}

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

bool sp(int a,int b)
{
    return a>b;
}

int a[10000];

int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int i;
        int num=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            num+=a[i];
        }
        sort(a,a+n,sp);
        int f=0;
        double t=num/(4.0*m);
        for(i=0;i<m;i++)
        {
            if(a[i]<t)
                f=1;
        }
        if(f==0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]
for x in range(1000):
    x = str(x)
    if len(x) != n:continue
    ok = True
    for i in range(m):
        if int(x[sc[i][0]-1]) != sc[i][1]:
            ok = False
            break
    if ok:
        print(int(x))
        exit(0)
print(-1)
        
    


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

#define MOD 1000007
#define MAX 100007

int main(){
    int n;
    bool flag = false;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for( int j = 1; j <= 9; j++ ){
            if(i*j == n){
                flag = true;
                break;
            }
        }
    }
    if(flag){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    rep(i, n){
        int a;
        cin >> a;
    }

    cout << (n-1+k-2) / (k-1) << endl;

    return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
   for(int i=0;i<m;i++){
       cin>>a[i]>>b[i];
     }
  for(int i=0;i<n;i++){
    int count=0;
    for(int j=0;j<m;j++){
      if(a[j]==i+1)count++;
      if(b[j]==i+1)count++;
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    int A[N];
    for(int i=0; i<N; i++) scanf(" %d", &A[i]);

    int R[N]; // 水量/2
    R[0] = 0;
    for(int i=0; i<N; i++){
        if(i % 2 == 0) R[0] += A[i];
        else R[0] -= A[i];
    }
    R[0] /= 2;
    printf("%d ", 2*R[0]);
    for(int i=1; i<N; i++){
        R[i] = A[i-1] - R[i-1];
        printf("%d ", 2*R[i]);
    }
    printf("\n");
}

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

int func(string s, string t) {
  int ans = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    bool founds = false, foundt = false;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == c) {
        founds = true;
      }
    }
    for (int i = 0; i < t.size(); i++) {
      if (t[i] == c) {
        foundt = true;
      }
    }
    if (founds && foundt) ans++;
  }
  return ans;
}

int main() {
  int n; string s; cin >> n >> s;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int tmp = func(s.substr(0, i), s.substr(i));
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,p;cin>>n>>p;
  map<int64_t,int> m;
  for (int64_t i = 2; i*i <= p; i++) {
    while (p % i == 0) { m[i]++; p /= i;}
  }
  if (p != 1) m[p] = 1;
  ll ans = 1;
  for (auto i=m.begin(); i != m.end(); ++i) {
    if (i->second>=n) {
      ll pow = (i->second)/n, k=i->first; rep(i,pow) ans*=k;
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V) for (auto v : (V)) cout << v << " "
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >>N;
  vec<int>dp(N+1,INF);
  dp[0]=0;
  vec<int>a;
  a.pb(1);
  int valList[2]={6,9};
  FORA(val,valList){
    int v = val;
    while(val<=N){
      a.pb(val);
      val*=v;
    }
  }

  for (int i=0;i<=N;i++){
    FORA(e,a){
    if (i+e>N)continue;
     chmin(dp[i+e],dp[i]+1);
    //dp[i+e]=min(dp[i+e],dp[i]+1);
    }
  }
  //PRINTALL(a);
  //print("\n");
  print(dp[N]);
  return 0;
}

Measured memory_bytes: 1024
package MyApp;
use utf8;
use 5.016;

say func(map { chomp; $_ } <>);

sub func {
    my ($n1,$n2) = split / /, shift;
    if($n2 % $n1) {
        return $n2 - $n1;
    }
    else {
        return $n1 + $n2;
    }
}

1;
__END__


Measured memory_bytes: 512
#include<string>
#include<iostream>

using namespace std;

typedef long long ll;

int main(){ string s; cin >> s; ll  K; cin >> K; bool flag = true;
           for(int i = 0; i < min((ll)s.size(), K); i++){
             if(s[i] != '1'){ flag = false; cout << s[i] << endl; return 0;}}
          if(flag){ cout << 1 << endl; return 0;}}
             

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end())
#define DOUBLECHANGE(count) cout << setprecision(count)
#define REV(vec) reverse(vec.begin(),vec.end())
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

long long int factorial(long long int a){
    long long int ans = 1;
    for(int i = 0;i < a;i++){
        ans *= i+1;
    }
    return ans;
}

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N, M;
      cin >> N >> M;
      pair<int,int> card = make_pair(1,INF);
      for(int i = 0;i < M;i++){
          int a, b;
          cin >> a >> b;
          card.first = max(card.first,a);
          card.second = min(card.second,b);
          if(card.first > card.second){
              cout << 0 << endl;
              return 0;
          }
      }
      cout << card.second - card.first + 1 << endl;
}


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

using namespace std;
int main(){
  int x;
  cin >> x;
  if(x == 1) {
    cout << 1 << endl;
    return 0;
  }

  int ret = 1;
  for(int i = 2; i < 100; i++) {
    for(int j = 2; j < 100; j++) {
      if((int)pow(i, j) <= x) {
        ret = max(ret, (int)pow(i, j));
      } else {
        break;
      }
    }
  }

  cout << ret << endl;
  return 0;
} 


Measured memory_bytes: 4092
var
    s:string;
    i,cnt:longint;
begin
    readln(s);
    if s[1]<>'A' then 
        begin
            writeln('WA');
            exit;
        end;
    if not((s[2]>='a') and (s[2]<='z') and (s[length(s)]>='a') and (s[length(s)-1]<='z')) then 
        begin
            writeln('WA');
            exit;
        end;
    for i:=3 to length(s)-1 do
        if s[i]='C' then
            begin
                inc(cnt);
                if cnt>=2 then 
                    begin
                        writeln('WA');
                        exit;
                    end;
            end
        else if not((s[i]>='a') and (s[i]<='z')) then 
            begin
                writeln('WA');
                exit;
            end;
    if cnt=1 then writeln('AC')
    else writeln('WA');
end.

Measured memory_bytes: 128
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int k,t,a,cnt=0;
  cin >> k >> t;
  for(int i=0; i<t; i++) {
    cin >> a;
    cnt=max(cnt,a);
  }
  cout << max(0,cnt-1-(k-cnt)) << endl;
}

Measured memory_bytes: 256
/*input
9
W 3
B 1
B 4
W 1
B 5
W 9
W 2
B 6
W 5
B 3
W 8
B 9
W 7
B 2
B 8
W 4
W 6
B 7
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=2005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int b[maxn],w[maxn];

int bcnt[maxn][maxn];
int wcnt[maxn][maxn];

int dp[maxn][maxn];

int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n+n){
		string s;
		int tmp;
		cin>>s>>tmp;
		if(s[0]=='B') b[tmp-1]=i;
		else w[tmp-1]=i;
	}
	for(int i=0;i<n;i++){
		bcnt[i][0]=0;
		for(int j=1;j<=n;j++) bcnt[i][j]=bcnt[i][j-1]+(b[i]<w[j-1]);
	}
	for(int i=0;i<n;i++){
		wcnt[i][0]=0;
		for(int j=1;j<=n;j++) wcnt[i][j]=wcnt[i][j-1]+(w[i]<b[j-1]);
		// REP(j,n+1) cout<<bcnt[i][j]<<" \n"[j==n];
	}
	int ans=0;
	REP(i,n) for(int j=i+1;j<n;j++){
		if(b[i]>b[j]) ans++;
		if(w[i]>w[j]) ans++;
	}
	
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++){
		if(i==0||j==0) dp[i][j]=0;
		else{
			dp[i][j]=min(dp[i][j-1]+wcnt[j-1][i],dp[i-1][j]+bcnt[i-1][j]);
		}
		// cout<<dp[i][j]<<" \n"[j==n];
	}
	cout<<ans+dp[n][n]<<'\n';

	return 0;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
    string s;
    cin >> s;
    int n = s.length();
    string ans = "";
    rep(i,n){
        for(ll j=1; j<=n-i; j++){
            string str = s.substr(i,j);
            bool b=true;
            rep(k,str.length()){
                if(str[k]!='A'&&str[k]!='C'&&str[k]!='G'&&str[k]!='T'){
                    b=false;
                }
            }
            if(b) {
                if(ans.length()<str.length()) ans = str;
            }
        }
    }

    cout << ans.length() << endl;
}

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


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

int main()
{
  constexpr int Base=10;
  constexpr int Divisor=2019;
  
  std::string S;
  std::cin>>S;
  
  const size_t N=size(S);
  
  int result=0;
  std::vector<int> count;
  count.resize(Divisor);
  auto a=crbegin(S);
  int b=0;
  int c=1;
  int sum=0;
  for(size_t i=0;i!=N;i++)
  {
    count[sum]++;
    b=((a[i]-'0')*c%Divisor);
    c=c*Base%Divisor;
    sum=(sum+b)%Divisor;
    result+=count[sum];
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int n,d,x[15][15],cnt;
bool safe(int i,int j)
{
    int sum=0;
    for(int k=1;k<=d;k++)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    int t=sqrt(sum);
    if(t*t==sum)return true;
    else return false;
}
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++)for(int j=1;j<=d;j++)cin>>x[i][j];
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(safe(i,j))cnt++;
    cout<<cnt<<endl;
    return 0;
}

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

statements = []

for i in range(n):
    a = int(input())
    astates = [list(map(int, input().split())) for _ in range(a)]

    statements.append(astates)

cnt = 0
for i in range(2**n):
    state = format(i, "0"+str(n)+"b")

    pos = True
    for j in range(n):
        if state[j] == "1":
            for x, y in statements[j]:
                if not (state[x-1] == str(y)):
                    pos = False
                    break

        if not pos:
            break

    if pos:
        cnt = max(cnt, state.count("1"))

print(cnt)

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int m = scan.nextInt() - 2*n;
			char[] ch = (scan.next()).toCharArray();
			int count = 0;
			for(int i = 0;i < m;i++){
				if(ch[i] == 'I'){
					for(int j = 1;j < 2*n+1;j+=2){
						if(ch[i+j] != 'O' || ch[i+j+1] != 'I'){
							break;
						}else if(j == 2*n-1){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 32712
program main
  
  implicit none
  integer :: n,k,q
  integer,allocatable :: a(:), na(:)
  integer :: i,j

  read(*,*) n,k,q

  allocate( a(q) )
  allocate( na(n) )

  do i = 1, q
    read(*,*) a(i)
  end do

  na = - q + k

  do i = 1, q
    na(a(i)) = na(a(i)) + 1
  end do
  
  j = 0
  do i = 1, n
    if ( na(i) <= 0 ) then
      print*,"No"
    else
      print*,"Yes"
    end if
  end do
  

end program main



Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
char a[1005],b[1005];
int o[1005],p[1005];
int cmp(char a,char b){
	return a>b;
} 
int main(){
	gets(a);
	gets(b);
	int c=strlen(a),d=strlen(b);
	sort(a,a+c);
	sort(b,b+d,cmp);
	if(strcmp(a,b)<0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
number = int(input())
score = list(map(int,input().split()))
score.sort()
answer = 0
for i in range(len(score)):
    for j in range(len(score)-i-1):
        if score[i] != score[i+j+1]:
            for k in range(len(score)-i-j-2):
                if score[i+j+1] != score[i+j+k+2]:
                    if score[i]+score[i+j+1] > score[i+j+k+2]:
                        answer += 1
print(answer)

Measured memory_bytes: 71712
#include "bits/stdc++.h"
/* Properties of modulo:
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
    /*ROLLING HASH
    Rabin-Karp algorithm for pattern matching in a string in O(n) time
    Calculating the number of different substrings of a string in O(n2logn)
    Calculating the number of palindromic substrings in a string.
    */
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll unsigned long long
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
// o_set(ll) name ; -- defining ordered set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : counting from zero it returns the k-th largest or smallest element in the set - returns iterator
bool compare(ll a, ll b){
    return a > b;
}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
ll power(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
void solve(){
    ll n , k;
    cin >> n>> k;
    ll a[n + 1];
    for(ll i = 1 ; i < n + 1 ; i++) cin >> a[i];
    bool vis[n + 1] = {false};
    vector<ll> v;
    ll mark = 1;
    ll i = 1;
    while(1){
        if(vis[a[i]] == true) {
            mark = a[i];
            break;
        }
        else{
            vis[a[i]] = true;
            v.pb(a[i]);
        } 
        i = a[i];
    }
    ll len = v.size();
    ll ct =0 ;
    // for(ll i = 0 ; i < len ; i++) cout << v[i] << " ";
    //     nl;
    // cout << " mark " << mark << endl;
    for(ll i = 0 ; i < len ; i++ ){
        if(v[i] == mark) break;
        ct++;
    } 
    if(ct == len) ct =0;
    if(k <= ct) cout << v[k - 1] << endl;
    else{
        // cout << ct << endl;
        k = k - ct;
        // cout <<" ,k " << k << endl;
        ll rem = k%(len - ct);
        // cout <<" rem " << rem << endl;
       if(rem != 0)cout << v[rem + ct - 1 ] << endl;
        else cout << v[len - 1 ] << endl;
    }
}
int main(){
    IOS;
    ll T=1;
    //cin>>T;
    ll t=0;
    while(t++<T){
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 7092
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }
    int answer = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int sqsum = 0;
            for (int k = 0; k < d; ++k) {
                sqsum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int sq = sqrt(sqsum);
            if (sq * sq == sqsum) ++answer;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  string S;
  cin >> S;
  string w[3] = { "Sunny", "Cloudy", "Rainy" };
  for (int i = 0; i < 3; i++) {
	  if (S == w[i]) {
		  cout << w[(i + 1) % 3] << endl;
		}
	}
  return 0;
}


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

def kansu(n):
    ans = ""
    i = True
    while not(n == 0):
        #print(n)
        if n%2 == 0:
            n = n // 2
            ans = "0" + ans
        else:
            ans = "1" + ans
            if i:
                n += -1
            else:
                n += 1
            n = n // 2
        i = i ^ True
        
    if ans == "":
    	ans += "0"
    return ans
  

print(kansu(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a[200000];
ll f[200005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        f[a[i]]++;
    }
    ll sol = 0;
    for (int i = 1; i <= n; ++i)
        sol += f[i] * (f[i] - 1) / 2;
    for (int i = 0; i < n; ++i)
        cout << sol - (f[a[i]] - 1) << '\n';
}


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

void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	sort(v.rbegin(), v.rend());
	int cur = 1;
	ll sum = v[0];
	n -= 2;
	while (n > 0) {
		sum += v[cur];
		n--;
		if (n <= 0)break;
		sum += v[cur];
		n--;
		cur++;
	}
	cout << sum;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
typedef long long ll;


int main() {
    ll l, r, m, mn = 3000, i, j, k;
    cin >> l >> r;

    k = l + 3000;

    for (i = l; (i <= k) && (i <= r); ++i) {
        for (j = i+1; (j <= k) && (j <= r); ++j) {
            m = (i*j) % 2019;
            if (mn > m) mn = m;
        }
    }

    cout << mn << endl;

    return 0;
}



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


int main(){
  string S;
  cin >> S;
  bool ans=true;
  int x=S.size();
  for(int i=0;i<x;i++){
    if(i%2==0){
      if(S[i]=='L'){
        ans = false;
      }
    }
    else{
      if(S[i]=='R'){
        ans =false;
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
      
    
    
}
      


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;
 
#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
 
static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;
 
 
int main(){
    string s;
    char c;
    int t=0;
    int res=0;
    while(cin>>s){
    	rep(i,s.size()){
    		c=s[i];
        	if(c>='0'&&c<='9'){
           		if(t==0) t+=c-'0';
       			else{
               		t*=10;
               		t+=c-'0';
           		}
       		}
       		else{
           		res+=t;
       			t=0;
       		}
       		//cout<<t<<" "<<res<<endl;
    	}
    	res+=t;
    	t=0;
    }
    res+=t;
    cout<<res<<endl;
    return 0;
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    string ans;
    int g1[7] = {1, 3, 5, 7, 8, 10, 12};
    int g2[4] = {4, 6, 9, 11};

    if (x ==2 || y == 2) {
        cout << "No" << endl;
        return 0;
    }

    bool fx = false;
    bool fy = false;
    for (int i=0; i<7; i++)
    {
        if (x == g1[i]) fx = true;
        if (y == g1[i]) fy = true;
    }
    if (fx && fy) {
        cout << "Yes" << endl;
        return 0;
    }

    fx = false;
    fy = false;
    for (int i=0; i<4; i++)
    {
        if (x == g2[i]) fx = true;
        if (y == g2[i]) fy = true;
    }
    if (fx && fy) {
        cout << "Yes" << endl;
        return 0;
    } else cout << "No" << endl;
}


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

double dp[301][301][301] = {};
int N;

double rec(int i, int j, int k)
{
    if(dp[i][j][k] > 0) return dp[i][j][k];
    if(i==0 && j == 0 && k == 0) return 0;

    double samp = 0;
    double bb = i + j + k;
    if(i > 0) samp += i / bb * rec(i-1, j, k);
    if(j > 0) samp += j / bb * rec(i+1, j-1, k);
    if(k > 0) samp += k / bb * rec(i, j+1, k-1);
    samp += N / bb;

    dp[i][j][k] = samp;

    return samp;
}

int main(void)
{
    cin >> N;

    int fn = 0;
    int sn = 0;
    int tn = 0;

    for (int i = 1; i <= N; ++i)
    {
        int tmp;
        cin >> tmp;
        if(tmp == 1) ++fn;
        else if(tmp == 2) ++sn;
        else if(tmp == 3) ++tn;
    }

    double ans = rec(fn, sn, tn);

    cout << fixed << std::setprecision(18) << ans << endl;

    return 0;
}



Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

ll a, b, c, x, y, t;
int32_t main(){
    cin >> a >> b >> c >> x >> y;
    t=min(x, y);
    cout << min(a*x+b*y, min(2*t*c+(x-t)*a+(y-t)*b, max(x, y)*2*c));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

const int N = 200100;
ll a[N], p[N], s[N]; int n;

int minSplit(int lx, int rx) {
  int lo = lx, hi = rx-1;
  while(lo < hi) {
    int mid = (lo+hi)/2;
    if( abs( (p[mid] - p[lx-1]) - (s[mid+1]-s[rx+1]) ) <=
	abs( (p[mid+1]-p[lx-1]) - (s[mid+2]-s[rx+1]) ) )
      hi = mid;
    else lo = mid+1;
  }
  // if( lo == rx ) return false;
  return lo;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0); srand(time(0));

  cin >> n;
  for(int i=1; i<=n; i++)
    cin >> a[i];
  p[0] = 0;
  for(int i=1; i<=n; i++) p[i] = p[i-1] + a[i];
  s[n+1] = 0;
  for(int i=n; i>=1; i--) s[i] = s[i+1] + a[i];

  ll ans = 1e9;
  for(int i=2; i<=n-2; i++) {
    int index1 = minSplit(1, i);
    int index2 = minSplit(i+1, n);
    ll xp = p[index1];
    ll xq = p[i] - p[index1];
    ll xr = p[index2] - p[i];
    ll xs = p[n] - p[index2];
    ll mx = max({xp, xq, xr, xs});
    ll mn = min({xp, xq, xr, xs});
    ll temp = mx-mn;
    // cerr << index1 << ':' << i << ':' << index2 << " : " << temp << endl;
    // cerr << "?" << xp << ',' << xq << ',' << xr  << ',' << xs << endl;
    ans=min(ans, temp);
  }
  cout << ans << endl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// どういうDPか
// dp[i][j][k] := 3個の寿司i個，2個の寿司j個，1個の寿司k個のサイコロを降る期待値

// 計算方法
// dp[0][0][0] = 0
// dp[i][j][k] = N / (i + j + k) + dp[i-1][j+1][k] * (i / (i + j + k)) + dp[i][j-1][k+1] * (j / (i + j+ k)) + dp[i][j][k-1] * (k / (i + j + k))

// どういう順番
// 小さい順から
// j > N-j のときの総和

double dp[302][302][302];
int cnt[4];

int main() {
    int N;
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    for (int i=0; i<=N; ++i) {
        for (int j=0; j<=N; ++j) {
            for (int k=0; k<=N; ++k) {
                double sum = i+j+k;
                if (sum == 0.0) continue;
                dp[i][j][k] = (N / sum);
                if (i-1 >= 0) dp[i][j][k] += (dp[i-1][j+1][k] * (i / sum));
                if (j-1 >= 0) dp[i][j][k] += (dp[i][j-1][k+1] * (j / sum));
                if (k-1 >= 0) dp[i][j][k] += (dp[i][j][k-1] * (k / sum));
            }
        }
    }

    printf("%.10f\n", dp[cnt[3]][cnt[2]][cnt[1]]);
}


Measured memory_bytes: 215296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  set<int>s;
  s.insert(1);
  s.insert(2);
  s.insert(3);
  s.erase(a);
  s.erase(b);
  cout << *s.begin();
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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

  int n, m; cin >> n >> m;
  vll a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }

  int cnt = 0;
  while(a[0] % 2 == 0) {
    cnt++;
    a[0] /= 2;
  }
  bool ok = true;
  for(int i=1;i<n;++i) {
    int nowcnt = 0;
    while(a[i] % 2 == 0) {
      nowcnt++;
      a[i] /= 2;
    }
    if(cnt != nowcnt) {
      ok = false;
      break;
    }
  }

  if(!ok || !cnt) {
    cout << 0 << endl;
    return 0;
  }

  ll base = 1;
  for(int i=0;i<n;++i) {
    base = lcm(base, a[i]);
  }

  for(int i=0;i<cnt-1;++i) {
    base *= 2;
  }
  //cout << base << endl;

  cout << m / base / 2 + m / base % 2 << endl;

}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b ;
  cin >> a >> b ;
  int h = 0;
  rep(i,b-a){
    h += i;
  }
  
  cout << h-a ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = n * n * n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int point,dimension;
	cin >> point >> dimension;
	int arr[point][dimension];
	for(int i = 0;i < point;i++)
		for(int j = 0;j < dimension;j++)
			cin >> arr[i][j];
	int d = 0,j = 0,i = 1,dist,count = 0;;
	double distance = 0;
	while(d < point)
	{
		while(i < point)
		{
			if(j < dimension)
			{
				distance = distance + (arr[d][j] - arr[i][j])*(arr[d][j] - arr[i][j]);
				j++;
			}
			else
			{
				distance = sqrt(distance);
				dist = distance;
				if(dist == distance)count++;
				i++;j = 0;distance = 0;
			}
		}
		d++;
		i = d + 1;
		j = 0;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			long N = Long.parseLong(sc.next());
			long M = Long.parseLong(sc.next());
			long answer=s(N,M);
			
			System.out.println(answer);
		}
	}
	static long s(long N, long M){
		long A=0;
		if(M<=2*N){
			A=M/2;
		}else{
			A=(M+2*N)/4;
		}
		
		return A;
	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	string s;
	cin >> s;
	cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
    int n,d,a;
    cin>>n>>d>>a;
    vector<pair<int,int> >p(n);
    for(auto& e:p)cin>>e.first>>e.second;
    sort(p.begin(),p.end());
    vector<int> s(n+1);
	int r=0;
    long long ans=0;
    rep(i,n){
        p[i].second-=s[i];
        while(r<n&&p[r].first<=p[i].first+2*d)++r;
        if(p[i].second>0){
            int num=(p[i].second+a-1)/a;
            ans+=num;
            s[i]+=num*a;
            s[r]-=num*a;
        }
        s[i+1]+=s[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> s;
	ll ans = 0;
	char bc = '#';
	rep(i, 0, n-1){
		if(s[i] != bc){ans++;}
		bc = s[i];
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;

class p{
  static void Main(){
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    Console.WriteLine(n[0] * n[1] >= n[2] * n[3] ? n[0] * n[1] : n[2] * n[3]);
  }
}

Measured memory_bytes: 13396
#include <stdio.h>
#define MAX_N 10001

int main() {
  int n, q, S[MAX_N], t, num;
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }
  num = 0;
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &t);
    for(i = 0; i < n; ++i) {
      if(S[i] == t) {
        ++num;
        break;
      }
    }
  }
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 2144
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]

C = Counter(S)

max_v = max(v for k, v in C.items())

ans = []
for k, v in C.items():
  if v == max_v:
    ans.append(k)

ans.sort()

for a in ans:
  print(a)


Measured memory_bytes: 35568
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N,M;
  cin>>N>>M;
  string ans="No";
  if(500*N>=M)ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll n,r;
    cin>>n>>r;
    if(n>=10){cout<<r<<endl;}
    else{cout<<r+100*(10-n)<<endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  string s;
  cin>>s;
  int n=s.size();
  n++;

  vector<ll> q(n);
  vector<ll> r(n);

  ll x=0;
  q[0]=0;
  repo(i,n){
    if(s[i-1]=='<') q[i]=q[i-1]+1;
    else q[i]=0;
  }

  x=0;
  r[n-1]=0;
  for(int i=n-2;i>=0;i--){
    if(s[i]=='>') r[i]=r[i+1]+1;
    else r[i]=0;
  }

  ll ans=0;
  rep(i,n){
    ans+=max(q[i],r[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 11648
import sys
def input():
	return sys.stdin.readline().strip()

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

s_list = [0]*N
for i in range(N):
	s_list[A[i] - 1] = i + 1

def list_print(A):
	length = len(A)
	for i in range(length - 1):
		print(A[i], end="")
		print(" ", end="")
	print(A[- 1])

list_print(s_list)

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    int n;
    char ch;
    int x;
    cin >> n;
    vector<int> S(14);
    vector<int> H(14);
    vector<int> C(14);
    vector<int> D(14);
    REP(i,14) {
        S.at(i) = i;
        H.at(i) = i;
        C.at(i) = i;
        D.at(i) = i;
    }
    REP(i,n) {
        cin >> ch;
        switch (ch) {
            case 'S':
            cin >> x;
            if (x == S.at(x)) S.at(x) = 0;
            break;
            case 'H':
            cin >> x;
            if (x == H.at(x)) H.at(x) = 0;
            break;
            case 'C':
            cin >> x;
            if (x == C.at(x)) C.at(x) = 0;
            break;
            case 'D':
            cin >> x;
            if (x == D.at(x)) D.at(x) = 0;
            break;
        }
    }
    REP(i,14) if (0 != S.at(i)) { cout << 'S' << ' ' << S.at(i);
    cout << '\n'; }
    REP(i,14) if (0 != H.at(i)) { cout << 'H' << ' ' << H.at(i);
    cout << '\n'; }
    REP(i,14) if (0 != C.at(i)) { cout << 'C' << ' ' << C.at(i);
    cout << '\n'; }
    REP(i,14) if (0 != D.at(i)) { cout << 'D' << ' ' << D.at(i);
    cout << '\n'; }
    
}



Measured memory_bytes: 3088
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int n, m, mark[N], t[N];
int pen, cor;

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (s == "AC")
			mark[p] = 1;
		else if (!mark[p])
			t[p]++;
	}
	for (int i = 0; i < n; i++) {
		cor += mark[i];
		if (mark[i])
			pen += t[i];
	}
	cout << cor << " " << pen << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    rep(i, s.length() - 8)
            cout
        << s[i];
    cout << endl;
    return 0;
}

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

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

typedef long long ll;
typedef long long int64;

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

  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }

  int ret = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      ret += d[i] * d[j];
    }
  }

  cout << ret << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll ns[200010];
int main()
{
	int n,i;
	ll ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&ns[i]);
		ns[i] -= i+1;
	}
	sort(ns,ns+n);
	if(n%2 == 1)
	{
		for(i=0;i<n;i++)
			ans += abs(ns[i]-ns[n/2]);
	}
	else
	{
		ll t1=0,t2=0;
		for(i=0;i<n;i++)
			t1 += abs(ns[i]-ns[n/2-1]);
		for(i=0;i<n;i++)
			t2 += abs(ns[i]-ns[n/2]);
		ans = min(t1,t2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792