akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

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

    ll mod = pow(10, 9) + 7;

    string S;

    cin >> S;

    vector<vector<ll> > dp(S.length() + 1, vector<ll>(13));

    dp[0][0] = 1;

    for(int i = 0; i < S.length(); i++) {
        int c;
        if(S[i] == '?') c = -1;
        else  c = S[i] - '0';

        for(int j = 0; j < 10; j++) {
            if(c != -1 && c != j) continue;
            for(int k = 0; k < 13; k++) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
            for(int k = 0; k < 13; k++) {
                dp[i + 1][k] %= mod;
                //cerr << dp[i + 1][k] << " ";
            }
            //cerr << endl;
        }
    }

    cout << dp[S.length()][5] << endl;
}


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

int main() {
  int N, l, r, G;
  G = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int p = 0;
    cin >> l >> r;
    p = ((r - l) + 1);
    G += p;
  }
  cout << G << endl;

  return 0;
}

Measured memory_bytes: 3568
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new A().doIt();
    }
    class A{
        void doIt(){
        	while(true){
        		int map[] = new int [100000];
        		int n = sc.nextInt();
        		if(n == 0)break;
        		for(int i = 0;i < n*2;i++){
        			String str[] = sc.next().split(":");
        			if(i % 2 == 0){
        				map[Integer.parseInt(str[0])*3600 + Integer.parseInt(str[1])*60 + Integer.parseInt(str[2])]++;
        			}else{
        				map[Integer.parseInt(str[0])*3600 + Integer.parseInt(str[1])*60 + Integer.parseInt(str[2])]--;
        			}
//        			System.out.println(Integer.parseInt(str[0])*3600 + Integer.parseInt(str[1])*60 + Integer.parseInt(str[2]));
        		}
        		int max = map[0];
        		for(int i = 1;i < 100000;i++){
        			map[i] = map[i] + map[i-1];
        			max = Math.max(max,map[i]);
        		}
        		System.out.println(max);
        	}
        }
    }
}

Measured memory_bytes: 101380
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
 
int main()
{
	char a[5];
	int j=1;
	while(~scanf("%s",&a))
	{
		j=1;
		for(int i=0;a[i]!='\0';i++)
		{
			if(a[i]==a[i+1])
				j++;
			if(a[1]!=a[2])
				break;
		}
		if(j>2) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 256
#include<complex>
#include<cstdio>
#include<cmath>
using namespace std;
typedef complex<double> P;
#define F(a,b,c) (acos((b*b+c*c-a*a)/(2*b*c)))
int main(){
	int n;
	double d,e,f,g,h,i;
	for(scanf("%d",&n);n--;){
		scanf("%lf%lf%lf%lf%lf%lf",&d,&g,&e,&h,&f,&i);
		P a(d,g),b(e,h),c(f,i);
		double A=abs(b-c),B=abs(c-a),C=abs(a-b),
		s=sin(2*F(A,B,C)),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;
		printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(F(A,B,C))/2);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		String str = br.readLine();
		boolean flg = false;
		for(int i = 0 ; i < str.length() ; i++){
			if(str.charAt(i) == '9'){
				flg = true;
			}
		}
		if(flg){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
			
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h> 
using namespace std; 
int main(){
    int n;
    cin>>n;
    string s;
    int AC=0,TLE=0,RE=0,WA=0;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="AC"){
           AC+=1;
       }else if(s=="RE"){
           RE+=1;
       }else if(s=="WA"){
           WA+=1;
       }else if(s=="TLE"){
           TLE+=1;
       }
    }
    cout<<"AC"<<" x "<<AC<<endl;
    cout<<"WA"<<" x "<<WA<<endl;
    cout<<"TLE"<<" x "<<TLE<<endl;
    cout<<"RE"<<" x "<<RE<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

typedef long long ll;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)

ll A,B;
vector<int> bita(41,0),bitb(41,0),bitans(41,0);


int nishinA(ll n){
  int i = 0;
  while(n > 0) {
    bita.at(i) = n % 2;
	n = n/2;
	i++;
  }
  return 0;
}

int nishinB(ll n){
  int i = 0;
  while(n > 0) {
    bitb.at(i) = n % 2;
	n = n/2;
	i++;
  }
  return 0;
}

int nishinc(int a, int a0, int b, int b0) {
  int ans = 0;
  if(a == 1 && a0 == 1) ans++;
  if(b == 1 && b0 == 0) ans++;
  return ans%2;
}

int main() {
  cin >> A>>B; 
  nishinA(A);
  nishinB(B);
  
  rep(i,41){
    if(i != 0) bitans.at(i) = nishinc(bita.at(i),bita.at(0),bitb.at(i),bitb.at(0));
	if(i == 0) {
	  ll temp = B - A + 1;
	  int k = temp % 4;
	  int t = 0;
	  if(k == 1 && bita.at(0) == 1) t = 1;
	  if(k == 2) t = 1;
	  if(k == 3 && bita.at(0) == 0) t = 1;
	  bitans.at(0) = t;
	}
  }
  ll ans = 0;
  ll pow2 = 1;
  rep(i,41) {
    ans += bitans.at(i) * pow2;
	pow2 *= 2;
  }
  cout << ans << endl;
  //rep(i,41) cout << bita.at(i);
}



Measured memory_bytes: 256
def kesu(x, s, c, h):
    global n
    if (x[0] - 1, x[1]) not in s and a[x[0] - 1][x[1]] == c:
        s.add((x[0] - 1, x[1]))
        kesu((x[0] - 1, x[1]), s, c, h + 1) 
    if (x[0] + 1, x[1]) not in s and a[x[0] + 1][x[1]] == c:
        s.add((x[0] + 1, x[1]))
        kesu((x[0] + 1, x[1]), s, c, h + 1) 
    if (x[0], x[1] - 1) not in s and a[x[0]][x[1] - 1] == c:
        s.add((x[0], x[1] - 1))
        kesu((x[0], x[1] - 1), s, c, h + 1) 
    if (x[0], x[1] + 1) not in s and a[x[0]][x[1] + 1] == c:
        s.add((x[0], x[1] + 1))
        kesu((x[0], x[1] + 1), s, c, h + 1)
    if h == 0 and len(s) > 3:
        for i in s:a[i[0]][i[1]] = "."
        n |= s

def otosu():
    for i in range(1,12)[::-1]:
        for j in range(1, 7):
            n = 0
            while i + n < 12:
                if a[i + n][j] != "." and a[i + n + 1][j] == ".":
                    a[i + n][j], a[i + n + 1][j] = a[i + n + 1][j], a[i + n][j]
                    n += 1
                else:break
                

for _ in range(int(input())):
    a = [["." for _ in range(8)]] + [["."] + list(input()) + ["."] for _ in range(12)] + [["." for _ in range(8)]]
    rensa = 0
    while 1:
        n = set()
        for i in range(1, 13):
            for j in range(1, 7):
                if a[i][j] in ("RGBYP"):
                    kesu((i, j), set(), a[i][j], 0)
        if n == set():break
        else:
            rensa += 1
            for i in range(1, 13):
                for j in range(1, 7):
                    if a[i][j] == "O":
                        if (i - 1, j) in n or (i + 1, j) in n or (i, j - 1) in n or (i, j + 1) in n:a[i][j] = "."
        otosu()
    print(rensa)


Measured memory_bytes: 5628
B = 101
DIV = 1<<32
def rolling_hash(s, n)
  hash = Array.new(n+1)
  hash[0] = 0
  n.times{ |i| hash[i+1] = (hash[i]*B + s[i].ord) % DIV }
  hash
end
s = gets.chomp
t = gets.chomp
sl = s.size
tl = t.size
p = Array.new(sl+1)
p[0] = 1
tl.times{ |i| p[i+1] = p[i]*B % DIV }
h1 = rolling_hash(s,sl)
h2 = rolling_hash(t,tl)
(0..(sl-tl)).each do |i|
  p i if (h1[i+tl] - h1[i]*p[tl]) % DIV == h2[tl]
end

Measured memory_bytes: 26832
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=1000;
ll LINF=10000000000000000;

int main(){
  int N;
  cin >> N ;
  priority_queue<ll,vector<ll>,greater<ll>> plus; //小さい順に取り出す
  priority_queue<ll> minus; //大きい順に
  ll asum=0,csum=0;
  ll ary1[N+1],ary2[N+1];
  ll a,b[N],c;
  rep(i,N){
    scanf("%lld",&a);
    asum+=a;
    plus.push(a);
  }
  rep(i,N){
    scanf("%lld",&b[i]);
  }
  rep(i,N){
    scanf("%lld",&c);
    csum+=c;
    minus.push(c);
  }
  ary1[0]=asum;
  ll temp;
  rep(next,N){
    temp=plus.top();
    if(b[next]>temp){
      plus.push(b[next]);
      plus.pop();
      ary1[next+1]=asum+b[next]-temp;
      asum=ary1[next+1];
    }else{
      ary1[next+1]=asum;
    }
  }
  ary2[N]=csum;
  for(int next=N-1;next>=0;next--){
    temp=minus.top();
    if(b[next]<temp){
      minus.push(b[next]);
      minus.pop();
      ary2[next]=csum+b[next]-temp;
      csum=ary2[next];
    }else{
      ary2[next]=csum;
    }
  }
  ll ans=-LINF;
  rep(i,N+1){
    //cout << ary1[i] << "," << ary2[i] << endl;
    ans=max(ans,ary1[i]-ary2[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4852
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string s;
  cin >> s;
  int64_t res = 0, k = 0;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s[i] == 'W') {
      res += i - k;
      ++k;
    }
  }
  cout << res << endl;
}



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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 < A || N % 500 == A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    


Measured memory_bytes: 256
//
// Created by tac on 2016/10/18.
//

#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>

namespace {

double area(double a, double b, double deg) {
    return a * b * std::sin(deg * M_PI / 180.0) / 2.0;
}

double length(double a, double b, double deg) {
    return a + b + std::sqrt(a * a + b * b - 2 * a * b * std::cos(deg * M_PI / 180.0));
}

double hight(double a, double b, double deg) {
    return b * std::sin(deg * M_PI / 180.0);
}

}

int main() {
    int a, b, deg;

    std::cin >> a >> b >> deg;
    std::cout << std::fixed << std::setprecision(8);
    std::cout << area(a, b, deg) << std::endl;
    std::cout << length(a, b, deg) << std::endl;
    std::cout << hight(a, b, deg) << std::endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3576
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vl a(3*n);

int main(){
	cin>>n;
	a=vl(3*n);
	for(int i=0;i<3*n;i++) cin>>a[i];
	vl s(3*n+1);
	for(int i=1;i<=3*n;i++) s[i]=s[i-1]+a[i-1];
	vl b(n+1),c(n+1);
	priority_queue<ll> q;
	for(int i=0;i<n;i++) q.push(-a[i]);
	b[0]=s[n];
	for(int i=n;i<2*n;i++){
		q.push(-a[i]);
		ll p=q.top();
		q.pop();
		b[i-n+1]=b[i-n]+a[i]+p;
	}
	c[0]=s[3*n]-s[2*n];
	priority_queue<ll> Q;
	for(int i=2*n;i<3*n;i++) Q.push(a[i]);
	for(int i=2*n-1;i>=n;i--){
		Q.push(a[i]);
		ll p=Q.top();
		Q.pop();
		c[2*n-i]=c[2*n-i-1]+a[i]-p;
	}/*
	for(int i=0;i<=3*n;i++) cout<<s[i]<<' ';
	cout<<endl;
	for(int i=0;i<=n;i++) cout<<b[i]<<' ';
	cout<<endl;
	for(int i=0;i<=n;i++) cout<<c[i]<<' ';
	cout<<endl;*/
	ll res=-INF;
	for(int i=0;i<=n;i++) res=max(res,b[i]-c[n-i]);
	cout<<res<<endl;
}

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

int dfs(int p, int q)
{
    if (p > q)
    {
        return 0;
    }
    if (dp[p][q] != -1)
    {
        return dp[p][q];
    }
    dp[p][q] = dfs(p, q - 1) + dfs(p + 1, q) - dfs(p + 1, q - 1) + v[p][q];
    return dp[p][q];
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    memset(dp, -1, 4 * 510 * 510);
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        v[x][y]++;
    }
    rep(i, q)
    {
        int p, q;
        cin >> p >> q;
        cout << dfs(p, q) << endl;
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long X,K,D;
    cin>>X>>K>>D;
    long long n=abs(X)/abs(D);
    long long ans;
    if(K-n<=0){
        ans=abs(X)-K*abs(D);
      cout<<ans<<endl;
    }else{
        ans=abs(X)-n*abs(D);
        if((K-n)%2==0)cout<<ans<<endl;
        else cout<<abs(ans-D)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
ans = 0
for i in s:
    if i == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

Measured memory_bytes: 38384
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flag = False  
for i in range(n-m+1):
    #flag = True
    for k in range(n-m+1):
        flag=True#ここ
        for j in range(i,i+m):
            #if i==k==3:
            #    print(a[j][k:k+m],b[j-i],a[j][k:k+m]==b[j-i],flag)
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if flag:
            break
    if flag:
        break
#print(i,k,flag)        
print("Yes" if flag else "No")


Measured memory_bytes: 3060
//バグがあるらしい…
//doubleの計算時の誤差か・_・
#include<iostream>
#include<cmath>
using namespace std;
char *ans[1000];

struct Pos{
	double x,y;
};

Pos VSub(Pos *a,Pos *b){
	Pos p;
	p.x = a ->x - b ->x;
	p.y = a ->y - b ->y;
	return p;
}
double VDot(Pos *a,Pos *b){
	return a->x * b->x + a->y * b->y;
}
int main(){
	int cor = 0,i;
	Pos c[4];
	while(cin >> c[0].x){
		cin >> c[0].y;
		for(i = 1;i < 4;i++)
			cin >> c[i].x >> c[i].y;
		Pos v[2];
			v[0] = VSub(&c[0],&c[1]);
			v[1] = VSub(&c[2],&c[3]);
			if(fabs(VDot(&v[0],&v[1])) <= 1e-12){
				ans[cor] = "YES";
			}
			else{
				ans[cor] = "NO";
			}
			cor++;
	}
	for(i = 0;i < cor;i++)
		cout << ans[i] << endl;
	return 0;
}

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

int rev(int dig, int num)
{
  if(num==1)
    return pow(10, dig)*9;
  else if(num==9)
    return pow(10, dig);
  else
    return pow(10, dig)*num;
}

int main(){
  int a;
  cin >> a;
  int ans=0;
  int dig[3];
  dig[0]=a%100%10;
  a/=10;
  dig[1]=a%10;
  a/=10;
  dig[2]=a;
  
  ans+=rev(0,dig[0]);
  ans+=rev(1,dig[1]);
  ans+=rev(2,dig[2]);
  cout << ans << '\n';
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main()
{
  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        
 
        int count = 0;
 
        for(char x: input.toCharArray()){
            if(x == '1'){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    int n; cin >> n;
    int cnt = 0;
    bool valid = 1;
    REP(i, n) {
        string s; cin >> s;
        if (s == "A") {
            ++cnt;
        } else if (--cnt < 0) {
            valid = false;
        }
    }
    cout << (valid and cnt == 0 ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 3232
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    sc.close();
    while(!is_prime(x)) {
    	x++;
    }
    System.out.println(x);
  }
  private static boolean is_prime(int x) {
	  boolean p = false;
	  int count = 0;
	  if(x == 2){
		  return true;
	  }else if(x%2 == 0) {
		  return false;
	  }
	  for(int i=1;i<=x;i+=2) {
		  if(x%i==0) {
			  count++;
		  }
	  }
	  if(count == 2) {
		  p = true;
	  }
	  return p;
  }
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int N;
V dig;

int main() {
    cin >> N;
    int cnt = 0, cnt1 = 0;
    while(N > 0) {
        if(N % 10) cnt++;
        if(N % 10 == 1) cnt1++;
        dig.push_back(N % 10);
        N /= 10;
    }
    if(cnt1 == 1 && cnt == 1) {
        cout << 10 << "\n";
    } else {
        int ans = 0;
        REP(i, dig.size()) { ans += dig[i]; }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a;
	scanf("%d",&a);
	printf("%s\n",a/100==a%10?"Yes":"No");
}


Measured memory_bytes: 256
import collections
def solve(a, b, ab_list):

    route = {}

    for a, b in ab_list:
        if a not in route:
            route[a] = []
        if b not in route:
            route[b] = []

        route[a].append(b)
        route[b].append(a)

    deque = collections.deque()
    deque.extend(route[1])
    route_memo = {i:1 for i in route[1]}
    while len(deque) > 0:
        room = deque.popleft()
        for i in route[room]:
            if i != 1 and i not in route_memo:
                route_memo[i] = room
                deque.append(i)

    if len(route_memo.keys()) == n-1:
        print("Yes")
        tmp = sorted(route_memo.items())
        for i in tmp:
            print(i[1])
    else:
        print("No")

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    ab_list = [[int(i) for i in input().split()] for j in range(m)]
    solve(n, m, ab_list)


Measured memory_bytes: 74640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

long long solve(long long x){
    if(x == 1){
        return 1;
    }else{
        return 2*solve(x/2)+1;
    }
}
	
int main(){
    long long H;
    cin >> H;

    cout << solve(H) << endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;

class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                String N = sc.next();

                boolean ch =
                        (N.charAt(0)==N.charAt(1) && N.charAt(0)==N.charAt(2))
                        || (N.charAt(3)==N.charAt(1) && N.charAt(3)==N.charAt(2));

                if(ch){
                        System.out.print("Yes");
                }else{
                        System.out.print("No");
                }
        }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,m,K;
void solve(){
	scanf("%d %d",&n,&m);
	for(int i=m-n+1;i<=m+n-1;i++){
		printf("%d ",i);
	}puts("");
}
int main (){
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  while(1){
  ll N,M;
  cin >> N >> M;
  if(N==0 && M==0){
    break;
  }
  vector<vector<int>> G(M);
  for(int i=0; i<N; i++){
    int d,v;
    cin >> d >> v;
    d--;
    G[d].push_back(v);
  }
  ll sum = 0;
  for(int i=0; i<M; i++){
    sort(G[i].begin(),G[i].end(),greater<int>());
    sum += G[i][0];
  }
  cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
n = int(input())
k = n%8
t = n//8
if n == 3:
  print(*[2,5,63])
  quit()
ans = [[2,3,4,6,8,9,10,12],[6],[3,9],[3,6,9],[2,3,9,10],[2,3,6,9,10],[2,3,4,8,9,10],[2,3,4,6,8,9,10]][k]
if k == 0:
  for i in range(1,t):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
else:
  for i in range(1,t+1):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
print(*ans)

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

#a_L,b_L,c_L = [],[],[]

#dp = [-1] * (10**5 +1)
# dpテーブル初期化
#dp = [[-1] * 3] * (10**5 +1) これだとダメ
dp=[[-1]*3 for _ in range(n+1)]

for i in range(3):
    dp[0][i] = 0
 
# 値のinput
w_L = [[0,0,0]]

for i in range(n):
    tmp = list(map(int,input().split()))
    w_L.append(tmp)


for i in range(1,n+1):
    dp[i][0] = max(dp[i-1][1] + w_L[i][0],dp[i-1][2] + w_L[i][0])
    dp[i][1] = max(dp[i-1][0] + w_L[i][1],dp[i-1][2] + w_L[i][1])
    dp[i][2] = max(dp[i-1][0] + w_L[i][2],dp[i-1][1] + w_L[i][2])
    #print(i)

print(max(dp[n]))


Measured memory_bytes: 74860
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
using namespace std;

const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		//===============================================
        int a = rand() % N;
        int b = rand() % N;
        swap(r[a],r[b]);
        if(Evaluate(r) <= mi) mi = Evaluate(r);
        else
        {
            if(Changes(cnt)) mi = Evaluate(r);
            else swap(r[a],r[b]);
        }
		//===============================================
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
    srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 5000

using namespace std;

int n;
ll c[maxn+5], ans;
int p[maxn+5];
bool viz[maxn+5];

void umax (ll &a, ll b) {
  a = max(a, b);
}

void solver (int m, ll k) {
  fill(viz, viz+n+1, 0);
  int i, j, z;
  ll now = 0, pas, rep;
  i = 0; ///i = lg ciclului
  while (k) {
    if (viz[m]) {
      for (pas = (1LL<<30), rep = 0; pas > 0; pas /= 2)
        if (1LL*i*(rep+pas) <= 1LL*k) rep += pas;
      if (rep > 0) rep--; ///!!cine stie ce castigi pe ult ciclu facut complet
      now *= (rep+1);
      umax(ans, now);
      k -= rep*i;
      while (k) {
        m = p[m];
        now += c[m];
        umax(ans, now);
        k--;
      }
      return;
    }
    viz[m] = 1;
    m = p[m];
    now += c[m];
    umax(ans, now);
    k--;
    i++;
  }
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll k; cin >> n >> k;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> p[i];
  for (i = 1; i <= n; i++) cin >> c[i];
  ans = -(1LL<<62);
  for (i = 1; i <= n; i++) solver(i, k);
  cout << ans;
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,b=1,c=1;
    string s;
    int a[26]={0};
    cin >> s;
    for (i = 0; i < s.length(); i++){
        a[s[i]-'a']++;
    }

    for(i = 0; i < 26; i++){
        if(a[i]>1){
            b = 0;
        }
    }

    if(b==0){
        cout <<"no";
    }
    else{
        cout << "yes";
    }

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int k = Integer.parseInt(sc.next());
		
		int x = 1;
		int y = 1;
		for(int i=2; i<k; i++) {
			if(i%2==1) {
				x++;
			} else {
				y++;
			}
		}
		System.out.println(x*y);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;        
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

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

int main() {
    int a, b, n; cin >> a >> b >> n;
    vector<int> l(1001, 0), s(1001, 0);
    for(int i=0; i<n; i++){
        int s, f; cin >> s >> f;
        l[s]++;
        l[f]--;
    }
    l[a]++;
    l[b]--;
    s[0]=l[0];
    for(int i=1; i<1001; i++){
        s[i]=s[i-1]+l[i];
    }
    bool flg=0;
    for(int i=0; i<1001; i++){
        if(s[i]==2){
            flg=1;
            break;
        }
    }
    cout << flg << endl;
}


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

int wm,hm;
vector< vector<int> > wh(51, vector<int>(51,0));

int xp[]={-1,0,1,-1,1,-1,0,1};
int yp[]={-1,-1,-1,0,0,1,1,1};

void dfs(int y,int x){
  for(int i=0;i<8;i++){
    int nx=x+xp[i];
    int ny=y+yp[i];
    if(nx>-1&&nx<wm&&ny>-1&&ny<hm&&wh[ny][nx]==1){
      //cout<<nx<<" "<<ny<<" "<<wh[nx][ny]<<endl;
      wh[ny][nx]=0;
      dfs(ny,nx);
    }
  }
}

int main(){
  while(1){
    //int wm,hm;
    int aa,bb;
    cin>>aa>>bb;
    wm=aa;
    hm=bb;
    if(wm==0&&hm==0)break;
    //vector< vector<int> > wh(wm, vector<int>(hm));
    for(int i=0;i<hm;i++){
      for(int j=0;j<wm;j++){
        int a;
        cin>>a;
        wh[i][j]=a;
      }
    }
    int ans=0;
    for(int i=0;i<hm;i++){
      for(int j=0;j<wm;j++){
        if(wh[i][j]==1){
          //cout<<"*"<<i<<" "<<j<<endl;
          wh[i][j]=0;
          dfs(i,j);
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll g(ll n)
{
    if (n == -1)
        return 0;

    ll rtn = n;
    if (n % 2 == 0) {
        rtn = n ^ ((n / 2) % 2);
    } else {
        rtn = (n - 1) ^ (((n - 1) / 2) % 2);
        rtn = rtn ^ n;
    }
    return rtn;
}

int main()
{
    ll a, b;
    cin>>a>>b;
    //cout<<g(a-1)<<" "<<g(b)<<endl;
    cout<<(g(a - 1) ^ g(b))<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

H = H[::-1]
check = 0
for i in range(1, N):
    if H[i] > H[i-1] + 1:
        check = 1
        break
    if H[i] > H[i-1]:
        H[i] -= 1

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

Measured memory_bytes: 14396
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
vector<int> ve[200000];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		ve[x].push_back(y);
		ve[y].push_back(x);  
	}
	bool f=0;
	for(int i=0;i<ve[1].size();i++){
		for(int j=0;j<ve[ve[1][i]].size();j++){
			if(ve[ve[1][i]][j]==n) f=1;
		}
	}
	if(f) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
	return 0;
}

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

int stepCnt;
int gcd(int x,int y){stepCnt++;return y?gcd(y,x%y):x;}

int main(void){
  int a, b;
  
  while (cin >> a >> b){
    if (a==0 && b==0) break;
    if (a<b){
      stepCnt = a; a = b; b = stepCnt;
    }
    stepCnt = 0;
    cout << gcd(a,b) << " ";
    cout << (stepCnt-1) << endl;
  }
  return 0;
}
  
  



Measured memory_bytes: 3080
w = input()

for i in range(len(w)):
  check = 0
  for j in range(len(w)):
    if w[i] == w[j]:
      check += 1
  
  if (check % 2) != 0:
    break
    
if (check % 2) == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	
	int n;
	cin >> n;
	vector<int> v(n+1);
	FOR(i,1,n+1)cin>>v[i];
	FOR(i,1,n+1){
		cout << "node "<<i<<": key = "<<v[i]<<", ";
		if(i>1)cout<<"parent key = "<<v[i/2]<<", ";
		if(2*i<=n)cout << "left key = "<<v[2*i]<<", ";
		if((2*i+1)<=n)cout << "right key = "<<v[2*i+1]<<", ";
		cout << '\n';
	}
}



Measured memory_bytes: 3052
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 101
#define MOD 1000000007

int main(){

    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> mp;
    REP(i,n){
        cin >> a[i];
        mp[a[i]+1]++;
        mp[a[i]]++;
        mp[a[i]-1]++;
    }

    ll maxi = -1;
    for(auto itr:mp){
        if(maxi < itr.second){
            maxi = itr.second;
        }
    }
    cout << maxi << endl;


    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " "<< x <<" "<< y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<ll, ll>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    if(n & 1) {
        sort(ALL(v));
        int m = n / 2;
        ll L = v[m].first;
        sort(ALL(v),
             [](const P &a, const P &b) { return a.second < b.second; });
        ll R = v[m].second;
        print(max(0LL, R - L + 1));
    } else {
        sort(ALL(v));
        int m1, m2;
        m2 = n / 2;
        m1 = m2 - 1;
        ll L = v[m1].first + v[m2].first;
        sort(ALL(v),
             [](const auto &a, const auto &b) { return a.second < b.second; });
        ll R = v[m1].second + v[m2].second;
        print(max(0LL, R - L + 1));
    }
}

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

const int N = 12;

int n, m, x;
int c[N];
int a[N][N];

int main() {
  scanf("%d %d %d", &n, &m, &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }

  int mini = -1;
  for (int mask = 1; mask < 1 << n; ++mask) {
    vector<int> v(m, 0);
    int cost = 0;
    for (int i = 0; i < n; ++i) {
      if (mask >> i & 1) {
        cost += c[i];
        for (int j = 0; j < m; ++j) {
          v[j] += a[i][j];
        }
      }
    }

    bool ok = true;
    for (int i = 0; i < m; ++i) if (v[i] < x) ok = false;

    if (ok) {
      if (mini == -1 || cost < mini) mini = cost;
    }
  }

  printf("%d\n", mini);
  return 0;
}


Measured memory_bytes: 3816
#include<stdio.h>
int main()
  { 
    int N,count=0,i;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);

  for(i=0;i<=N-3;i++)
    { 
      if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
        { 
        count++;
        }
    }
  printf("%d",count);
  return 0;
  }


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

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


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [n, m] = nextIntArray()
    let ans = m <= 2 * n ? Math.floor(m / 2) : Math.floor((2 * n + m) / 4)
    console.log(ans)
}
Main()


Measured memory_bytes: 29620
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 2e5+2;
const ll mod = 1e9+7;
int p[SIZE];

int main(){ 
	speedhack()
	int n; cin >> n;
	int maxx = 0;
	int smax = 0;
	vector<int> v;
	for(int i = 1; i <= n; i++){
		cin >> p[i];
		v.push_back(p[i]);
	}
	sort(all(v));
	for(int i = 1; i <= n; i++){
		if(p[i] == v[v.size()-1]){
			cout << v[v.size()-2] << endl;
		}else{
			cout << v[v.size()-1] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3316
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let k: usize = read();
  println!("{}", vec![1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][k - 1]);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, a[2][100];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[0][i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> a[1][i];
	}

	int dp[2][100];
	dp[0][0] = a[0][0];
	dp[1][n - 1] = a[1][n - 1];

	for (int i = 0; i < n-1; ++i) {
		dp[0][i + 1] = dp[0][i] + a[0][i + 1];
		dp[1][n - 2 - i] = dp[1][n - 1 - i] + a[1][n -2 - i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans = max(ans, dp[0][i] + dp[1][i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256