akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    int n;
    cin >> n;
    mint ans = 1;
    rep(i, 0, n){
        ans *= i + 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int ls = s.length(), lt = t.length();
  bool can = false;
  string ans = "";
  rep(i, ls - lt + 1){
    string sp = s;
    bool can = true;
    rep(j, lt){
      if(s[i+j] == '?') sp[i+j] = t[j];
      else if(s[i+j] != t[j]) can = false;
    }
    rep(i, ls){
      if(sp[i] == '?') sp[i] = 'a';
    }
    if(can && ans == "") ans = sp;
    else if(can && sp < ans) ans = sp;
  }
  if(ans == "") cout << "UNRESTORABLE" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
const int INF = 1e18;

struct edge
{
    int to;
    int cost;
};
using Graph = vector<vector<edge>>;

Graph G;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    G.resize(n);
    rep(i, n - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back((edge){b, c});
        G[b].push_back((edge){a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;
    int x[q], y[q];
    rep(i, q)
    {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    int seen[n];
    int dist[n];
    memset(seen, 0, sizeof(seen));
    memset(dist, 0, sizeof(dist));

    queue<int> que;
    que.push(k);
    seen[k] = true;
    dist[k] = 0;

    while (!que.empty())
    {
        int now = que.front();
        que.pop();
        for (auto ne : G[now])
        {
            int nv = ne.to;
            int nc = ne.cost;
            if (seen[nv])
                continue;
            seen[nv] = true;
            dist[nv] = dist[now] + nc;
            que.push(nv);
        }
    }

    rep(i, q)
    {
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
}

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


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
const ll INF = 1e9;
int main(){
    fast_io
    
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vector<int> dist(n+1, INF);
    vector<int> MostLeft(n+1, INF);
    dist[n]=0;
    MostLeft[0]=n;
    int Next = n-1;
    int Left = n;
    int timer=0;
    while(true){
        timer++;
        int newLeft = Left;
        while(Next>= Left-m && Next>=0){
            if(s[Next]=='0'){
                dist[Next]=timer;
                newLeft=Next;
            }
            Next--;
        }
        if(newLeft==Left){
            cout<<-1<<endl;
            return 0;
        }
        Left=newLeft;
        MostLeft[timer]=Left;
        if(Next<0)break;
    }
    timer=dist[0];
    //rep(i,n+1) cerr<<dist[i]<<endl;

    vector<int> ans;
    int now=0;
    while(timer>=1){
        timer--;
        ans.push_back(MostLeft[timer]-now);
        now=MostLeft[timer];
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i];
        if(i+1!=ans.size()) cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

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

  int ans = 0;
  int xx = 0;
  int Bx = 0;
  int xA = 0;
  int BA = 0;
  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); i++)
    {
      if (s.substr(i - 1, 2) == "AB") ans++;
    }
    if (s.at(0) == 'B' && s.at(s.size() - 1) == 'A') BA++;
    else if (s.at(0) == 'B' && s.at(s.size() - 1) != 'A') Bx++;
    else if (s.at(0) != 'B' && s.at(s.size() - 1) == 'A') xA++;
    else if (s.at(0) != 'B' && s.at(s.size() - 1) != 'A') xx++;
  }
  
  int B = Bx + BA;
  int A = xA + BA;
  if (B > 0 && A > 0 && (Bx > 0 || xA > 0 || BA > 1))
  {
    if (xA > 0) {xA -= 1; ans += BA;}
    else {ans += BA - 1;}
    if (Bx > 0) 
    {
      Bx -= 1; ans += 1;
      ans += min(Bx, xA);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        
        int a=N/1000;
        int b=N/100%10;
        int c=N/10%10;
        int d=N%10;
        String X="",Y="",Z="";
        
        for(int x=1;x<=2;x++){
            for(int y=1;y<=2;y++){
                for(int z=1;z<=2;z++){
                    if(a+Math.pow(-1,x)*b+Math.pow(-1,y)*c+Math.pow(-1,z)*d==7){
                        if(x==1){
                            X="-";
                        }else{
                            X="+";
                        }
                        if(y==1){
                            Y="-";
                        }else{
                            Y="+";
                        }
                        if(z==1){
                            Z="-";
                        }else{
                            Z="+";
                        }
                    }
                }
            }
        }
        System.out.println(a+X+b+Y+c+Z+d+"=7");
    }
}

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

int main() {
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;

    std::printf("%c%c%c\n", s1[0] - ('a' - 'A'), s2[0] - ('a' - 'A'), s3[0] - ('a' - 'A'));

    return 0;
}


Measured memory_bytes: 256
class Baseball
   def initialize
      @base={first: false,second: false ,third: false}
      @point=0
      @outnum=0
   end
   def hit
      if @base[:third]
         @base[:third]=false
         @point += 1
      end
      if @base[:second]
         @base[:third]=true
         @base[:second]=false
      end
      if @base[:first]
         @base[:second]=true
         @base[:first]=false
      end
      @base[:first]=true
   end
   def homerun
      @point += 1
      @base.each do |key,val|
         @point+=1 if val
         @base[key]=false
      end
   end
   def out
      @outnum+=1
      if @outnum == 3
         puts @point
      end
   end
   def gameover?
      return true if @outnum >= 3
      return false
   end
end

n=gets.to_i
n.times do
   obj=Baseball.new
   until obj.gameover? do
      str=gets.chop
      obj.hit if 'HIT'==str
      obj.homerun if 'HOMERUN'==str
      obj.out if 'OUT'==str
   end
end

Measured memory_bytes: 6116
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var A = n[0];
        var B = n[1];
        var K = n[2];
        
        var list = new List<int>();
        for(var i = 1;i <= Math.Min(A,B);i++){
            if(A % i == 0 && B % i == 0){
                list.Add(i);
            }
        }
        
        list.Reverse();
        Console.WriteLine(list[K - 1]);
    }
}


Measured memory_bytes: 13396
N = int(input())
As = []
Bs = []

for _ in range(N):
  c = 0
  m = 0
  for s in input():
    if s == '(':
      c += 1
    elif s == ')':
      c -= 1
    m = min(m, c)
  if c >= 0:
    As.append((-m, c - m))
  else:
    Bs.append((-m, c - m))

As.sort(key=lambda x: x[0])
Bs.sort(key=lambda x: x[1], reverse=True)

f = True
c = 0
for (l, r) in As:
  if c < l:
    f = False
    break
  c += r - l
if f:
  for (l, r) in Bs:
    if c < l:
      f = False
      break
    c += r - l

f = f and (c == 0)

if f:
  print('Yes')
else:
  print('No')

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

using namespace std;

int main()
{
    int h,w,a,b,ph,pw,par,d;
    cin>>h>>w>>a>>b;
    ph=h/a;
    pw=w/b;
    par=ph*pw*a*b;
    d=(h*w)-(par);
    cout<<d<<endl;
    return 0;
}



Measured memory_bytes: 3076
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	cout << n*(1+n+(n*n)) << endl;
	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

    n %= 10;
    
    if(n==2 || n==4 || n==5 || n==7 || n==9) cout << "hon" << endl;
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
    else cout << "bon" << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> arr;
  int i = 0;
  while (i < N) {
    int x;
    cin >> x;
    arr.push_back(x);
    i++;
  }
  
  int count = 0;
  bool judge = true;
  while (judge) {
    i = 0;
    while(i < N) {
      if(arr[i] % 2 != 0) {
        judge = false;
        break;
      }
      i++;
    }
    
    if (judge) {
      i = 0;
      while(i < N) {
        arr[i] /= 2;
        i++;
      }    
      count++;
    }
  }

  cout << count << endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

using p = pair<ll, ll>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<p> v(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        v[i] = p(x - 1, y - 1);
    }

    vector<int> index(n);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(),
         [&](const int &a, const int &b) { return v[a] < v[b]; });

    atcoder::dsu d(n);
    set<p> s;
    s.insert(p(v[index[0]].second, index[0]));

    repd(i, 1, n) {
        set<p> del_set;
        int j = index[i];
        del_set.insert(p(v[j].second, j));
        int remain_index = j;
        for (auto elem : s) {
            if (elem.first < v[j].second) {
                d.merge(elem.second, j);
                del_set.insert(elem);
                if (v[remain_index].second > v[elem.second].second) {
                    remain_index = elem.second;
                }
            } else {
                break;
            }
        }
        s.insert(p(v[j].second, j));
        for (auto elem : del_set) {
            s.erase(elem);
        }
        s.insert(p(v[remain_index].second, remain_index));
    }

    vector<int> ans(n);
    rep(i, n) { ans[index[i]] = d.size(index[i]); }
    rep(i, n) { cout << ans[i] << endl; }
    return 0;
}



Measured memory_bytes: 22160
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
using namespace std;

int main(){
	int n,r;
	while(scanf("%d%d",&n,&r),n){
		deque< int > DQ;
		for(int i = 0; i < n; i++){
			DQ.push_back(n-i);
		}
		for(int i = 0; i < r; i++){
			int p,c;
			scanf("%d%d",&p,&c);
			p--;c;
			vector < int > sub;
			for(int j = p; j < p+c; j++){
				sub.push_back(DQ[j]);
				DQ[j] = 0;
			}
			deque < int > :: iterator it = remove(DQ.begin(),DQ.end(),0);
			DQ.erase(it,DQ.end());
			for(int j = 0; j < sub.size(); j++){
				DQ.push_front(sub[sub.size()-1-j]);
			}
		}
		printf("%d\n",DQ[0]);
	}
	return 0;
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int inf= 1<<30;
const int maxn = 1005;
int a[maxn][maxn],vis[maxn][maxn];
int mx[4] = {0,0,1,-1};
int my[4] = {1,-1,0,0};
set<int> adj[1000005];
int d[1000005];

void solve(){
	int h,w;
	cin >> h >> w;
	int x,y,fx,fy;
	cin >> x >> y >> fx >> fy;
	for(int i=1; i <=h; i++){
		for(int j=1; j <=w; j++){
			char c;
			cin >> c;
			a[i][j] = (c == '.');
		}
	}
	
	int mark=1;
	queue<pii> q;
	for(int i=1; i <=h; i++){
		for(int j=1;j <=w; j++){
			if(!vis[i][j] && a[i][j]){
				//marcar
				q.push(pii(i,j));
				vis[i][j] = mark;
				while(!q.empty()){
					auto e = q.front();
					q.pop();
					int u = e.fi, v = e.se;
					for(int k=0; k < 4;k++){
						int uu = u+mx[k], vv = v+my[k];
						if(uu >= 1 && uu <= h && vv >=1 && vv <= w && a[uu][vv] && !vis[uu][vv]){
							vis[uu][vv] = mark;
							q.push(pii(uu,vv));
						}
					}
				}
				mark++;
			}
		}
	}

	for(int i=1; i <=h; i++){
		for(int j=1; j <=w; j++){
			if(!a[i][j]) continue;
			for(int u = i-2; u <= i+2; u++){
				if(u < 1 || u > h) continue;
				for(int v = j-2; v <= j+2; v++){
					if(v < 1 || v > w) continue;
					if(!a[u][v]) continue;
					if(vis[i][j] == vis[u][v]) continue;
					if(adj[vis[i][j]].find(vis[u][v]) != adj[vis[i][j]].end()) continue;
					adj[vis[i][j]].insert(vis[u][v]);
					adj[vis[u][v]].insert(vis[i][j]);
				}
			}
		}
	}

	if(vis[x][y] == 0 || vis[fx][fy] == 0){
		cout << -1 << endl;
		return;
	}

	int ini = vis[x][y];
	queue<int> q2;
	q2.push(ini);
	for(int i=0; i < 1000005; i++) d[i] = inf;
	d[ini] = 0;
	while(!q2.empty()){
		int x = q2.front();
		q2.pop();
		for(int v : adj[x]){
			if(d[x] + 1 < d[v]){
				d[v] = d[x]+1;
				q2.push(v);
			}
		}
	}
	
	if(d[vis[fx][fy]] == inf) d[vis[fx][fy]] = -1;
	cout << d[vis[fx][fy]] << endl;
}

int main(){
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 80692
from collections import deque

def bfs(H,W,G):
    d  = [[-1] * W for i in range(H)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    q = deque([])
    q.append((0,0))
    d[0][0] = 0

    while(len(q) != 0):
        x,y = q.popleft()

        if(x == (H-1) & y == (W-1)):
            break

        for i in range(4):
            nx , ny = x + dx[i] , y + dy[i]

            if (0 <= nx and nx <= (H-1) and 0<= ny and ny <= (W-1) and G[nx][ny] == 0 and d[nx][ny] == -1):
                q.append((nx,ny))
                d[nx][ny] = d[x][y]+1
    return d


H , W = map(int,input().split())
G = [[0] * W for i in range(H)]

for i in range(H):
    a = input()
    for j in range(len(a)):
        if a[j] == "#":
            G[i][j] = 1

d = bfs(H,W,G)
point = -1

if d[H-1][W-1] != -1:
    point = H * W - sum(map(sum,G)) - d[H-1][W-1] -1

print(point)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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


int dp[110][110],a[110][110];
int h,w;


int solve(int x,int y)
{
     if (x==h&& y==w) 
            return !a[x][y];
        else if (dp[x][y] != -1) 
            return dp[x][y];

         else {
            int ans1 = 1e18, ans2=1e18;
            if (x + 1<=h)
                ans1=solve(x+1,y)+(a[x][y]!=a[x+1][y]&&!a[x][y]);
            if (y+1<=w)
                ans2=solve(x,y+1)+(a[x][y]!=a[x][y+1]&&!a[x][y]);
            return dp[x][y] = min(ans1,ans2);
        }
}


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



  cin>>h>>w;
  memset(dp,-1,sizeof(dp));
  memset(a,0,sizeof(a));

  for(int i=1;i<=h;i++)
  {
     for(int j=1;j<=w;j++)
     {
         char c;
         cin>>c;
         if(c=='.')a[i][j]=1;
         else a[i][j]=0;
     }
  }
  cout<<solve(1,1);
 

}


Measured memory_bytes: 512
#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;
    if(n == m) cout << "Yes";
    else cout << "No";
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int maxh = 0;
    for (int i=0; i<n; i++) {
        cin >> h[i];
        maxh = max(maxh, h[i]);
    }

    int ans = 0;
    while (maxh > 0) {
        bool f = false;
        for (int i=0; i<n; i++) {
            if (h[i] == maxh) {
                h[i]--;
                if (!f) {
                    ans++;
                    f = true;
                }
            }
            else f = false;
        }
        maxh--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 504
#include <cstdio>
#include <climits>
using namespace std;

int main(){
    int n, i, r;
    int min = INT_MAX;
    int profit = INT_MIN;
    scanf("%d",&n);
    scanf("%d",&min);
    for(i=0;i<n-1;i++){
        scanf("%d",&r);
        if(r-min>profit)profit=r-min;
        if(r<min)min=r;
    }
    printf("%d\n",profit);
    return 0;
}



Measured memory_bytes: 2740
n = gets.chomp.to_i
list = []
for a in 1..n
  restaurant = []
  s, p = gets.chomp.split(&:to_s)
  restaurant << a
  restaurant << s
  restaurant << p.to_i
  list << restaurant
end
list.sort! do |a, b|
  (b[2] <=> a[2])
end
list.sort! do |a, b|
  (a[1] <=> b[1])
end
for b in 0..n - 1
  puts list[b][0]
end


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

using namespace std;


int main(){
	
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	
	cin>>n;
	for (int i=0; i<n; i++) {
		
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		
		if (abs(x2-x1)==0||abs(x4-x3)==0) {
			if (abs(x2-x1)==0 && abs(x4-x3)==0) {
				cout << "YES"<<endl;
			}
			else{
				cout << "NO" << endl;
			}
		}
		else {
			if (abs((y2-y1)/(x2-x1)-(y4-y3)/(x4-x3))==0) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}

		}

		
	}
	
	return 0;
}
 

Measured memory_bytes: 0
int check_prime(int a[], int n) {
  int cnt = 0;

  for (int i = 0; i < n; i++) {
    int flag = 1;
    for (int j = 2; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      cnt++;
    }
  }
  return cnt;
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  printf("%d\n", check_prime(a, n));
  return 0;
}



Measured memory_bytes: 2016
a,b = map(int,input().split())
c = b // 100 - a // 100
d = (a // 1000) % 10
e = a // 10000
f = a % 100
g = b % 100
h = (b // 1000) % 10
i = b // 10000
if 10 * d + e < f and (10 * h + i) <= g :
	print(c)
elif 10 * d + e < f and not 10 * h + i <= g :
	print(c - 1)
elif not 10 * d + e < f and 10 * h + i <= g :
	print(c + 1)
else:
	print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }




int main(int argc, char const *argv[]) {
  int n,cnt=0;
  cin >> n;
  vector<ll> a(n);
  ll sum=0,abmin=1e9;
  rep(i,n){
    cin >> a[i];
    sum+=abs(a[i]);
    if(a[i]<0) cnt++;
    chmin(abmin,abs(a[i]));
  }
  //cout << cnt << endl;
  //cout << abmin << endl;
  if(cnt%2==0) cout << sum << endl;
  else cout << sum-abmin*2 << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll x,n;
  cin >> x >> n;
  vll p(n);
  rep(i,0,n) cin >> p[i];
  sort(all(p));
  
  ll ans=0;
  ll dis=inf;
  repr(i,105,0){
    if(upper_bound(all(p),i)-lower_bound(all(p),i)==0&&dis>=abs(i-x)){
     ans=i;
      dis=abs(i-x);
    }
  }
  
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) return b;
    return gcd(b, a%b);
}

template<typename U>
U gcd_multi(vector<U> A) {
    int n = A.size();
    if (n == 1) return A[0];
    U G = gcd(A[0], A[1]);
    if (n == 2) return G;
    for (int i = 2; i < n; ++i) G = gcd(G, A[i]);
    return G;
}

const int MAX = 1001000;
bool IsPrime[MAX];
int MinFactor[MAX];
vector<int> preprocess(int n = MAX) {
    vector<int> res;
    for (int i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1;
    IsPrime[0] = false; IsPrime[1] = false; 
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            MinFactor[i] = i;
            res.push_back(i);
            for (int j = i*2; j < n; j += i) {
                IsPrime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
    return res;
}

vector<pair<int,int> > prime_factor(int n) {
    vector<pair<int,int> > res;
    while (n != 1) {
        int prime = MinFactor[n];
        int exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}


int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    if (gcd_multi(a) != 1) {
        cout << "not coprime" << '\n';
        return 0;
    }

    preprocess();
    map<ll, ll> mp;
    rep(i,n) {
        auto pf = prime_factor(a[i]);
        for (auto &&e: pf) {
            mp[e.first]++;
        }
    }

    for (auto &&e: mp) {
        if (e.second > 1) {
            cout << "setwise coprime" << '\n';
            return 0;
        }
    }

    cout << "pairwise coprime" << '\n';

    return 0;
}

Measured memory_bytes: 20976
n,m,k = map(int,input().split())

base = 998244353


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



ans = 0
rbase = 1
for i in range(n-1-k):
    rbase *= (m-1)
    rbase %= mod

temp = m*rbase
temp %= mod
for i in range(k+1):
    hoge = temp*cmb(n-1,k-i,mod)
    hoge %= mod
    ans += hoge
    temp *= (m-1)
    temp %= mod

print(ans%mod)


Measured memory_bytes: 32828
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int a,b;
	static int[][] field;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);
		int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};

		while(true){
			b=s.nextInt();
			a=s.nextInt();
			if(a==0)System.exit(0);
			boolean[][] map = new boolean[a][b];
			field = new int[2*a-1][];


			for(int i=0; i<2*a-1; i++) {
				if(i%2==1) {
					field[i] = new int[b];
					for(int j=0; j<b; j++) {
						field[i][j] = s.nextInt();
					}
				} else {

					field[i] = new int[b-1];
					for(int j=0; j<b-1; j++) {
						field[i][j] = s.nextInt();
					}
				}
			}

			ArrayList<int[]> list = new ArrayList<int[]> ();
			list.add(new int[] {0,0});

			int answer = 0,step=1;

			map[0][0] = true;

			while(!list.isEmpty()) {
				ArrayList<int[]> next = new ArrayList<int[]>();
				for(int[] k:list) {
					if(k[0]==a-1 && k[1]==b-1) {
						answer = step;
						break;
					}

					for(int p=0; p<4; p++) {
						int ni = k[0]+move[p][0];
						int nj = k[1]+move[p][1];

						if((0<=ni && ni<a) && (0<=nj && nj<b) && (!map[ni][nj])) {
							if(p==0 && field[k[0]*2][k[1]]==0) {
								map[ni][nj] = true;
								next.add(new int[] {ni,nj});
							}
							else if(p==1 && field[ni*2][nj]==0) {
								map[ni][nj] = true;
								next.add(new int[] {ni,nj});
							}
							else if(p==2 && field[k[0]*2+1][k[1]]==0) {
								map[ni][nj] = true;
								next.add(new int[] {ni,nj});
							}
							else if(p==3 && field[ni*2+1][nj]==0) {
								map[ni][nj] = true;
								next.add(new int[] {ni,nj});
							}
						}

					}
				}
				list = next;
				step++;
			}
			System.out.println(answer);
		}
	}

}



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

int main(){

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

        vector<int> dp(n + 5, 0);
        dp[2] = abs(frog[2] - frog[1]);

        for(int i = 3; i <= n; i++){
                dp[i] = min(dp[i - 1] + abs(frog[i - 1] - frog[i]), dp[i - 2] + abs(frog[i] - frog[i - 2]));
        }

        cout << dp[n] << endl;




        return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
    ll x=0,y=0,z=0,n,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t;
    cin >> s;
    rep(i,s.size()){
      if('B' !=  s[i]){
        t += s[i];
      }
      else{
        if(t !=""){
          t.pop_back();
        }
      }
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
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);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s, t;
  cin>>s>>t;

  int ans = 0;
  for(int i=0;i<3;i++) ans += s[i] == t[i];
  cout<<ans<<endl;

  return 0;
}


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

int main() {
	int a, b; cin >> a >> b;
	if (a <= b) {
		cout << "Impossible\n";
		return 0;
	}
	int n = a + b;
	vector<int> cand;
	auto ask = [](int first, int second) {
		cout << "? " << first << " " << second << endl;
		string ret; cin >> ret; return ret[0] == 'Y';
	};
	for (int i = 0; i < n; i++) {
		if (cand.empty()) {
			cand.push_back(i);
		} else {
			(ask(cand.back(), i) ? cand.push_back(i) : cand.pop_back());
		}
	}
	int true_man = cand.back();
	string ans;
	for (int i = 0; i < n; i++) {
		ans.push_back(ask(true_man, i) + '0');
	}
	cout << "! " << ans << endl;
	return 0;
}

Measured memory_bytes: 724
from itertools import product

N, M, X = map(int, input().split())
C, A = [], []
for _ in range(N):
    temp = [int(x) for x in input().split()]
    C.append(temp[0])
    A.append(temp[1:])

min_total = 10**10
for pattern in product([False, True], repeat=N):
    rikai = [0] * M
    total = 0
    for i, p in enumerate(pattern):
        if not p:
            continue
        for m in range(M):
            rikai[m] += A[i][m]
        total += C[i]

    if all(r >= X for r in rikai):
        min_total = min(total, min_total)

print(min_total if min_total < 10**10 else -1)

Measured memory_bytes: 74460
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import bisect
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def main():
    n = getN()
    nums = getlist()
    eo = [0, 0]
    for num in nums:
        eo[num % 2] += 1
    e = (eo[0] + eo[1] // 2) % 2
    o = eo[1] % 2
    if o == 0:
        print("YES")
    else:
        print("NO")
    # print(e,o)

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 62576
// abc135_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)
#define CHAR2INT(c) (c - '0')

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll d_10[100001] = {0};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    d_10[0] = 1;
    REP(i, 100001){
        d_10[i+1] = (d_10[i] * 10) % 13;
    }

    vector<ll> dp(13, 0);
    dp[0] = 1;
    REP(i, S.size()) {
        auto prev = dp;
        dp.assign(13, 0);
        REP(j, 13) {
            if (S[i] == '?') {
                REP(d, 10) {
                    ll x = (j + d * d_10[S.size()-i-1]) % 13;
                    dp[x] = (dp[x] + prev[j]) % MOD;
                }
            } else {
                int n = CHAR2INT(S[i]);
                ll x = (j + n * d_10[S.size()-i-1]) % 13;
                dp[x] = (dp[x] + prev[j]) % MOD;
            }
        }
    }
    print(dp[5]);

    return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans=100;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    int ca;
  if(x%2 ==1){
    ans=0;
     break;}
    else{
      ca=1;
      int A=x/2;
    while(A%2==0){
      A/=2;
      ca++;}
      }
    if(ans>ca) ans=ca;
    }
        cout << ans <<endl;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	cout << (((a * b) & 1) ? "Odd" : "Even") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<char> dchar;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい


int H,W;
string s[100];
int d[100][100];
deque<pint> dq;

void bfs(){
	d[0][0]=0;
	pint v;
	v.first = 0;
	v.second = 0;
	dq.push_front(v);
	while(!dq.empty()){
		pint w=dq.front();
		int y=w.first;
		int x=w.second;
		dq.pop_front();
		Rep(i,4){
			int ny = y+dy[i];
			int nx = x+dx[i];
			if(ny>=0&&ny<=H-1&&nx>=0&&nx<=W-1&&s[ny][nx]=='.' && d[ny][nx]>=inf){
				d[ny][nx] =d[y][x]+1;
				pint u;
				u.first= ny;
				u.second=nx;
				dq.push_back(u);
			}
		}
	}
}

int main(){
	cin>>H>>W;
	Rep(i,H) cin>>s[i];
	int cnt=0;
	Rep(i,H){
		Rep(j,W){
			if(s[i][j]=='.'){
				cnt++;
			}
		}
	}
	Rep(i,H) Rep(j,W) d[i][j]=inf;
	bfs();
	if(d[H-1][W-1]!=inf){
	cout<<cnt-d[H-1][W-1]-1<<endl;
	}
	else cout<<-1<<endl;
  return 0;
  }

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray();
        ulong n = vars[0];
        ulong m = vars[1];


        ulong gu = 0;
        ulong ki = 0;

        if(n >= 2)
        {
            gu = n * (n - 1) / 2;
        }

        if (m >= 2)
        {
            ki = m * (m - 1) / 2;
        }

        System.Console.WriteLine(gu + ki);
    }



}

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

using namespace std;

int main(){
	int a,b,t;
	scanf("%d%d%d",&a,&b,&t);
	long long int ans=0ll;
	for(int i=1;i<=t;i++){
		if(i%a){
			continue;
		}
		ans+=(0ll+b);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
//I don't want to do this....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//modulo exponentiation
ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 
/*void BFS(int v, vector<bool>& visited){
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		cout<<u<<" ";
		visited[u]=1;
		for(auto i:adj[u]){
			if(!visited[i])q.push(i);
		}
	}
}*/
const int N=500023;
bool vis[N];
vll adj[N];

int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);
 
                     ll t=1;
                    // cin >> t;
                     
                     while (t--){
                             string s;cin>>s;
                             ll n=s.length();ll jhc=-1;
                             for(ll i=0;i<n;){
                                 ll j;
                                 ll cnt=0;
                                 for(j=i;j<n;j++){
                                     if(s[j]=='R'){
                                         cnt++;
                                     }
                                     else break;
                                 }
                                 i=j+1;
                                 jhc=max(jhc,cnt);
                             }
                             cout<<jhc<<endl;
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    int H, A;
    cin >> H >> A;
    int ans = H / A;
    if(H%A==0){
        cout << ans << endl;
    } else {
        cout << ans+1 << endl;
    }

}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = int_fast64_t;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(25);

    i32 n,d,a; cin >> n >> d >> a;
    /**
     * 各モンスターに対して最低限当てるべき回数が定まる
     * -> (Hi+a-1)/a
     * 左端がxとすると x ~ x+2*d の範囲を1回分減らせる
     */
    vec<PII> xh(n); rep(i,n) cin >> xh[i].first >> xh[i].second;
    sort(all(xh));

    rep(i,n) xh[i].second = (xh[i].second+a-1)/a;


    /**
     *  値の取得と区間加算だが、これはいもす法でできる。
     *  いもす法というと、構築後に複数の処理をO(1)で行うために使われるが、
     *  処理をO(1)でやりつつ構築をしていくことが出来る。
     *
     */
    // 左から
    i32 cnt = 0;
    vi csum(n+1);
    for(i32 i = 0; i < n; ++i) {
        if (xh[i].second > csum[i]) {
            i32 x = xh[i].first;
            i32 bomb = xh[i].second - csum[i];
//            debug(xh[i].first);
//            debug(xh[i].second);
//            debug(bomb);
            i32 lidx = i, ridx = (partition_point(all(xh), [&](PII p) { return p.first <= x + 2 * d; })) - xh.begin();

            // imos しながら爆発させる。
            csum[lidx] += bomb;
            csum[ridx] -= bomb;
            cnt += bomb;
//            debug(cnt);
        }
        // いもす法の累積和構築処理
        csum[i+1] += csum[i];
    }

    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 4992
import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.ByteString.Char8         as C

main = do
    [n, k] <- unfoldr (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let minmax  = n * (n + 1) `div` 2
        mindiff = [n, n - 1 ..]
        minList = scanl (-) minmax mindiff
        maxdiff = [0, 1 ..]
        maxList = scanl (-) minmax maxdiff
        totList = zipWith (-) maxList minList
    print $ flip mod 1000000007 . (+) (n + 1 - k + 1) . sum . take (n + 1 - k + 1) $ totList


Measured memory_bytes: 4748
n = int(input())
x = []
x = list(map(int,input().split(' ')))
y = []
for i in range(len(x)):
    y.append(x[i])

y.sort()

#print(x)
#print(y)

b = int(n/2)
s = int(n/2)-1

if n == 2:
    print(x[1])
    print(x[0])
else:
    for i in range(n):
        if x[i] >= y[b]:
            print(y[s])
        else:
            print(y[b])


Measured memory_bytes: 25224
#include <iostream>

using namespace std;

int main(void) {
				unsigned char str[11], str2[12];
				cin >> str >> str2;
				for(int i=0;i<11 && str[i] != '\0';i++){if(str[i] != str2[i]){puts("No");return 0;}}
				puts("Yes");
				return 0;
}


Measured memory_bytes: 3640