akhauriyash/Code-Regression huggingface dataset:
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define int long long
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
string str;


 
int32_t main()
{
	IOS;
	cin>>n>>str;
	ll ans=0;
	set<int> r,g,b;
	forn(i,n){
		if(str[i]=='R') r.insert(i);
		else if(str[i]=='G') g.insert(i);
		else b.insert(i);
	}
	for(auto i: r){
		for(auto j: g){
			// dbg(i),dbg(j);
			// if(i>j) swap(i,j);
			ans+=b.size();
			if((j+i)%2==0){
				int cen=(i+j)/2;
				if(b.count(cen)) ans--;
			}
			if(b.count(2*j - i)) ans--;
			if(b.count(2*i - j)) ans--;
			// dbg(ans);

		}
	}
	cout<<ans<<ln;

}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 998244353;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n;
	cin>>n;
	vector<ll> dist(n);
	rep(i,n)cin>>dist[i];
	if(dist[0]>0){
		cout<<0<<endl;
		return 0;
	}

	vector<ll> cnt(n,0);
	rep(i,n){
		cnt[dist[i]]++;
	}
	if(cnt[0]>1){
		cout<<0<<endl;
		return 0;
	}
	ll ans = 1;
	ll max_ = *max_element(all(dist));
	rep(i,max_+1){
		if(i==0)ans *= cnt[i];
		else ans *= power(cnt[i-1],cnt[i]);
		ans %= mod;
	}
	cout<<ans<<endl;
	 
	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException {
		int max = 0; // 各要素におけるMAX値(k)
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 要素の個数
		 StringBuilder sb = new StringBuilder();
		int[] num = new int[n]; // 個数のリスト
		int[] B = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = scan.nextInt();
			max = Math.max(max,num[i]);
		}
		
		
		/*	if (max < num[i]) {
				max = num[i];
			}
			*/
		
		scan.close();
		 CountingSort(num, B,max);
		 
		 sb.append(B[0]);
	        for (int i = 1; i<n ; i++ ) {
	            sb.append(" ").append(B[i]);
	        }
	  
	        System.out.println(sb);

		 
		 
/*		 System.out.print(B[0]);
		for (int i = 1; i < n; i++) {
		
				System.out.print(" "+B[i]);
		
		}
		System.out.println();
		*/
	}

	/**
	 * 計数ソート
	 * 
	 * @param A
	 *            入力リスト
	 * @param k
	 *            リスト要素の最大値
	 * @param n
	 *            リストの個数
	 * @return ソート後のリスト
	 */
	public  static void CountingSort(int[] A, int[] B ,int k) {
		int n = A.length;
		//int[] B = new int[n];
		int[] C = new int[k+1];
	/*	for (int i = 0; i < k; i++) { // initialize
			C[i] = 0;
		}
		*/

		for (int j = 0; j <= n - 1; j++) {
			C[A[j]]++;
		}
		for (int i = 1; i <= k; i++) {
			C[i] = C[i] + C[i - 1];
		}
		for (int j = n - 1; j >= 0; j--) {
			
			B[C[A[j]]-1] = A[j];
			C[A[j]]--;
		}

	//	return B;
	}
}



Measured memory_bytes: 515856
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

struct node
{
	vector<shared_ptr<node>>ch;
	char c;
	int value()
	{
		if (ch.empty())
		{
			return c - '0';
		}
		assert('*' == c || '+' == c);
		int s = 0;
		if (c == '*')s = 1;
		for (auto n : ch)
		{
			if (c == '*')s *= n->value();
			else s += n->value();
		}
		return s;
	}
};

int main(void)
{
	int n = 0;
	int read = 0;
	for (;;)
	{
		cin >> n;
		if (!n)break;
		{
			vector<shared_ptr<node>>las;
			for (int i = 0; i < n; ++i)
			{
				string str;
				cin >> str;
				int s = str.length();
				las.resize(s - 1);
				las.push_back(shared_ptr<node>(new node{ vector<shared_ptr<node>>(),str.back() }));
				if (s > 1)
				{
					las[las.size() - 2]->ch.push_back(las.back());
				}
			}
			cout << las[0]->value() << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3220
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}


fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let v: Vec<u32> = (0..n).map(|_| iter.parse()).collect();

    let mut vv = vec![0_u32; n];
    let mut ans = Vec::new();
    for i in (0..n).rev() {
        let mut c = 0;
        let mut x = (i + 1) * 2;
        while x <= n {
            if vv[x - 1] == 1 {
                c += 1;
            }
            x += i + 1;
        }
        if v[i] != c % 2 {
            ans.push(i + 1);
            vv[i] = 1;
        }
    }

    println!("{}", ans.len());
    if !ans.is_empty() {
        println!(
            "{}",
            ans.into_iter()
                .map(|x| x.to_string())
                .collect::<Vec<_>>()
                .join(" ")
        );
    }
}

Measured memory_bytes: 13308
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String[] sp = S.split("");
        if(sp[0].equals(sp[1]) && sp[0].equals(sp[2])) {
            System.out.println("No");
        }else {
            System.out.println("Yes");
        }
    }
}

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

namespace ASPC2019_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = AB[0];
            var B = AB[1];
            var P = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var level = new int[3];

            foreach (var p in P)
            {
                if (p <= A) level[0]++;
                else if (p <= B) level[1]++;
                else level[2]++;
            }

            Console.WriteLine(level.Min());
        }
    }
}


Measured memory_bytes: 13396
number = gets.chomp
aa = number[0] + number[1]
bb = number[2] + number[3]

if ("01" <= aa && aa <= "12") && ("01" <= bb && bb <= "12")
  puts "AMBIGUOUS"
elsif "01" <= aa && aa <= "12"
  puts "MMYY"
elsif "01" <= bb && bb <= "12"
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
N = int(input())
d = list(map(int, input().split()))[:N]

# ソートする
sd = sorted(d)

# 長さは偶数なので、ちょうど２分できる数値が存在する
mid = int(len(sd)/2)

# ソートされた配列を、２分する値で分割し、小さい方(l)の最大値と大きい方(r)の最小値を求める
l_max = sd[mid-1]
r_min = sd[mid]

print(r_min - l_max)

Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c=0,i;
	char s[10];
	
	for(i=0;i<3;i++)
	{
		cin>>s[i];
		if(s[i]=='o')
		c++;
	}
	c=c*100;
	cout<<(700+c)<<endl;
	return 0;
}

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

int main() {
  int a, b; 
  cin >> a >> b;
  
  int ans=0;
  for(int i=a; i<=b; i++){
    string temp = to_string(i);
    if(temp[0]==temp[4] && temp[1]==temp[3]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3772
import math
a,b,c,d=map(int, input().split())
def gcd(a,b):
    if(a%b!=0):
        return gcd(b,a%b)
    else:
        return b
def lcm(a,b):
    return a*b//gcd(a,b)

numb = b-(b//c + b//d) + (b//(lcm(c,d)))
numa = (a-1)-((a-1)//c+(a-1)//d) + ((a-1)//lcm(c,d))
print(numb-numa)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int Mod=1e9+7,MAXN=55;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int n,C[MAXN][MAXN],F[MAXN][MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,0,n){C[i][0]=1;Rep(j,1,i)C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;}
	F[1][0]=F[1][1]=n;
	Rep(i,1,n-1)Rep(j,1,n-i)Rep(k,0,j)if(!((k^j)&1)){
		int x=(j-k)>>1;Rep(d,0,j)F[i+j][abs(x-d)]=(F[i+j][abs(x-d)]+1ll*F[i][k]*C[n-i][j]%Mod*C[j][d])%Mod;
	}cout<<F[n][0]<<'\n';
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		String[] t = sc.next().split("");
		for(int i = 0;i <s.length;i++) {
			boolean sameFlag = true;
			for(int j = 0;j < s.length;j++) {
				if(!s[j].equals(t[j])) {
					sameFlag = false;
					break;
				}
			}
			if(sameFlag) {
				System.out.println("Yes");
				return;
			}
			String taihi = s[s.length-1];
			for(int k =s.length-1; k >0 ;k--) {
				s[k] = s[k-1];
			}
			s[0] = taihi;
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    rep(i, N){
        a[i] = (ll)pow(2,31) - 1;
    }
    int com, s, t;
    ll ans;
    rep(i, Q){
        cin >> com >> s >> t;
        if(com==0){
            a[s] = t;
        }else if(com==1){
            ans = INT64_MAX;
            FOR(j, s, t+1){
                if(ans > a[j]) ans = a[j];
            }
            print(ans);
        }
    }
    return 0;
}


Measured memory_bytes: 3520
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int x;
    cin >> x;
    cout << (x + 1) * x / 2 << "\n";
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  for (int i=0; i<n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }

  priority_queue<int> q;
  long long ans = 0;
  for (int i=m-1; i>=0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n;
  cin>>k;
  int count=0;
  int data;
  for(int i=0;i<n;i++){
    cin>>data;
    if(data>=k)count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define R register
#define Max(_A, _B) (_A > _B ? _A : _B)
#define Min(_A, _B) (_A < _B ? _A : _B)

const long long Inf = 1ll << 55;
int n, k, a[500010], b[500010], l[500010], r[500010], cnt;
struct Data{ long long v, t; Data *l, *r; } c[500010 * 32], *root = c; int tot;
void Pd(R Data *u, R int begin, R int end)
{
	if(~u->t)
	{
		if(u->l == c){ u->l = c + ++tot; *u->l = c[0]; }
		if(u->r == c){ u->r = c + ++tot; *u->r = c[0]; }
		R int mid = begin + end >> 1;
		u->l->v = u->t - mid;
		u->l->t = u->t;
		u->r->v = u->t - end;
		u->r->t = u->t;
		u->t = -1;
	}
}
void Pu(R Data *u){ u->v = Min(u->l->v, u->r->v); }
long long Query(R Data *u, R int begin, R int end, R int l, R int r)
{
	if(l <= begin && end <= r) return u->v;
	Pd(u, begin, end);
	R int mid = begin + end >> 1; R long long t1 = Inf, t2 = Inf;
	if(l <= mid) t1 = Query(u->l, begin, mid, l, r);
	if(r > mid) t2 = Query(u->r, mid + 1, end, l, r);
	Pu(u);
	return Min(t1, t2);
}
void Modify(R Data *&u, R int begin, R int end, R int l, R int r, R long long val)
{
	if(l > r) return ;
	if(u == c){ u = c + ++tot; *u = c[0]; }
	if(l <= begin && end <= r)
	{
		u->v = val - end;
		u->t = val;
		return ;
	}
	Pd(u, begin, end);
	R int mid = begin + end >> 1;
	if(l <= mid) Modify(u->l, begin, mid, l, r, val);
	if(r > mid) Modify(u->r, mid + 1, end, l, r, val);
	Pu(u);
}
long long GetAns(R Data *u, R int begin, R int end)
{
	if(u->t != -1 || begin == end) return u->v + end;
	R int mid = begin + end >> 1;
	R long long t1 = Inf, t2 = Inf;
	t1 = GetAns(u->l, begin, mid);
	t2 = GetAns(u->r, mid + 1, end);
	return Min(t1, t2);
}
void Print(R Data *u, R int begin, R int end)
{
	if(u == c) return ;
	printf("[%d %d] -> %lld %lld\n", begin, end, u->v, u->t);
	R int mid = begin + end >> 1;
	Print(u->l, begin, mid);
	Print(u->r, mid + 1, end);
}
int main()
{
	c[0] = (Data){0, -1, c, c};
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d %d", &a[i], &b[i]);
	R long long sum = 0;
	for(int i = 1; i <= n; ++i)
	{
		sum += a[i];
		if(b[i] == 1)
		{
			if(a[i] << 1 > k){ puts("-1"); return 0; }
			r[++cnt] = (k - (sum << 1) % k) % k;
			l[cnt] = (k - ((sum - a[i]) << 1) % k) % k;
		}
	}
	Modify(root, 0, k - 1, 0, k - 1, 0);
	for(int i = 1; i <= cnt; ++i)
	{
		if(l[i] > r[i])
		{
			R long long t = Query(root, 0, k - 1, r[i] + 1, l[i]) + l[i];
			Modify(root, 0, k - 1, r[i] + 1, l[i] - 1, Inf);
			Modify(root, 0, k - 1, l[i], l[i], t);
		}
		else
		{
			R long long t1 = Query(root, 0, k - 1, 0, l[i]) + l[i];
			R long long t2 = Query(root, 0, k - 1, r[i] + 1, k - 1) + l[i] + k;
			Modify(root, 0, k - 1, 0, l[i] - 1, Inf);
			Modify(root, 0, k - 1, r[i] + 1, k - 1, Inf);
			Modify(root, 0, k - 1, l[i], l[i], Min(t1, t2));
		}
	}
	printf("%lld\n", GetAns(root, 0, k - 1) + (sum << 1));
	return 0;
}

Measured memory_bytes: 92672
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b){
        if(b < c){
            cout << "Yes" << endl;
        }
        else{
            cout <<"No"<<endl;
        }
    }else{
        cout <<"No"<<endl;
    }
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << max(0, A - 2 * B) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();

		double area = r * r * Math.PI;
		double cl = 2 * r * Math.PI;

		String area1 = String.format("%.7f", area);
		String cl1 = String.format("%.7f", cl);
		sc.close();

		System.out.println(area1 + " " + cl1);
	}

}

Measured memory_bytes: 28256
s=input()
#一文字めから(N-1)//2文字目まで
mo1=s[:(len(s)-1)//2]
#(N+3)//2文字目から最後まで
mo2=s[(len(s)+3)//2-1:]

ans=["Yes","Yes","Yes"]

for i in range(len(s)//2):
    #(s[i],s[-(i+1)])
    if s[i]!=s[-(i+1)]:
        ans[0]="No"
        break

for i in range(((len(s)-1)//2)//2):
    #print(mo1[i],mo1[-(i+1)])
    if mo1[i]!=mo1[-(i+1)]:
        ans[1]="No"
        break

for i in range(((len(s)+3)//2)//2):
    #print(mo2[i],mo2[-(i+1)])
    if mo2[i]!=mo2[-(i+1)]:
        ans[2]="No"
        break

if "No" in ans:
    print("No")
else:
    print("Yes")







            




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


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==c)cout<<b<<endl;
	else if(b==c)cout<<a<<endl;
	else cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
tbl=[[False for i in range(13)] for j in range(4)]
mark=["S","H","C","D"]
n=int(input())
for i in range(n):
    x,y=input().split()
    y=int(y)

    tbl[mark.index(x)][y-1]=True

for i in range(4):
    for j in range(13):
        if tbl[i][j]==False:
            if i==0:
                str="S"
            elif i==1:
                str="H"
            elif i==2:
                str="C"
            elif i==3:
                str="D"
            print(str,end=" ")
            print(j+1)










Measured memory_bytes: 5612
#!/mnt/c/Users/moiki/bash/env/bin/python
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcd(a,b):
    return a*b//gcd(a,b)
from functools import reduce
# N,M = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))


r = reduce(lcd, a)
# print(r)
ans = 0
for ea in a:
    ans += (r-1)%ea
print(ans)


Measured memory_bytes: 50928
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] ary = new int[n];

		for (int i=0; i<n; i++) {
			ary[i] = stdIn.nextInt();
		}

		int count = 0;
		for (int i=0; i<ary.length; i++) {
			int mini = i;
			for (int j=i; j<ary.length; j++) {
				if (ary[j] < ary[mini]) {
					mini = j;
				}
			}
			swap(ary,i,mini);
			if(i != mini)
				count++;
		}

		for (int i=0; i<n-1; i++) {
			System.out.print(ary[i]+" ");
		}
		System.out.println(ary[n-1]);
		System.out.println(count);
	}

	static void swap(int[] ary,int x,int y){
		int temp = ary[x];
		ary[x] = ary[y];
		ary[y] = temp;
	}
}

Measured memory_bytes: 19164
#include "bits/stdc++.h"
using namespace std;
#define maxn 100000
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

std::vector<int> e[maxn];
int a[maxn];
void dfs(int u, int f){
    a[u] = 0;
    for(int v: e[u]) if(v!=f){
        dfs(v, u);
        a[u] ^= (1 + a[v]);
    }
}

void solve(){
    int n,m,k;
    int x,y,z,A,B,C,D;
    cin >> n;
    rep(i,n-1){
        cin >> x >> y;
        --x,--y;
        e[x].pb(y);
        e[y].pb(x);
    }
    dfs(0,-1);
    cout << (a[0]==0? "Bob":"Alice");
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 12416
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		System.out.println(N/3);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

map<string, string> mp, mpg, mpa;


/*--------------------template--------------------*/

int main() {

    cin >> n >> m;
    ans = 1;
    ll a, b;
    REP(i, n) {
        ans = min(ans * 2, ans + m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

// ref. https://atcoder.jp/contests/abc155/submissions/10152895
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long K = sc.nextLong();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);

    long l = -1000_000_000_000_000_000L;
    long r = 1000_000_000_000_000_000L;
    //    long l = -20;
    //    long r = 20;
    while (l + 1 < r) {
      long kThProd = (l + r) / 2;
      long cnt = countPairLessThan(kThProd, A);
      if (cnt < K) { // Find 'cnt == K -1', then 'kThProd' is K-th smallest product.
        l = kThProd; // l:ok.
      } else {
        r = kThProd; // r:ng.
      }
    }
    System.out.println(l);
  }

  private static long countPairLessThan(long m, long[] A) {
    long tot = 0;
    for (long a : A) {
      int l = -1, r = A.length;
      if (a > 0) {
        while (l + 1 < r) {
          int c = (l + r) / 2;
          if (a * A[c] < m) l = c; // l:ok, r:ng
          else r = c;
        }
        tot += l + 1; // Because index starts with 0. OK count is (l+1).
      } else {
        while (l + 1 < r) {
          int c = (l + r) / 2;
          if (a * A[c] < m) r = c; // l:ng, r:ok
          else l = c;
        }
        tot +=
            A.length - (l + 1); // Remove NG count. Because index starts with 0. NG count is (l+1).
      }
      if (a * a < m) tot--;
    }

    return tot / 2;
  }
}

// i < j
// Search m, where count(a*x <= m) equals K
// -----------------
// condition of a | count where | count
// -----------------
// a > 0: x <= m/a | |
// a== 0:          | | num-zero * x
// a < 0: x >= m/a | | N- count(x < m/a) <=> N-count(x <= m/a -1)
//   ref: 3/(-2) => -1


Measured memory_bytes: 90484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
    string S;
    cin >> S;
    int len = S.size();

    ll ans = 0;
    for (int i = 0; i < (1 << (len - 1)); ++i) {
        ll tmp = S[0] - '0';
        for (int j = 0; j < len - 1; ++j) {
            if (i & (1 << j)) {
                ans += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + S[j + 1] - '0';
        }
        ans += tmp;
    }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(int i = 1, x; (x = scn.nextInt()) != 0; i++) {
            System.out.println("Case " + i + ": " + x);
        }
    }
}

Measured memory_bytes: 44880
//        VIVEK UPADHYAY
    //        MANIT, BHOPAL(M.P)


//                         JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 + 10 ;
ll mod = 1e9 + 7 ;
int main() {
    
    
    int D , G ;
    cin >> D>>G ;
    int a[D][2] ;
    for(int i=0;i<D;i++) cin>>a[i][0] >>a[i][1] ;
    
    int  mx = 10000 ;
    for(int mask=0;mask<(1<<D);mask++){
        int tot =0 ,cnt=0;
        for(int j=0;(1<<j)<=mask;j++)
            if(mask&(1<<j)){
                tot+=a[j][1] +(a[j][0])*100*(j+1);
                cnt+=a[j][0] ;
            }
        tot = G-tot ;
       // cout<<tot<<" "<<cnt<<endl;
        if(tot<=0){
            mx = min(mx , cnt) ;
            continue ;
        }
        
        for(int i=D-1;i>=0;i--){
            if(((1<<i)&mask)==0){
                
                if((a[i][0]-1)*(i+1)*100 >=tot){
                    
                    int v = ceil(tot*1.0/(100*(i+1))) ;
                    tot =0 ;
                    cnt+=v ;
                    
                }
                else{
                    tot-=(a[i][0]-1)*100*(i+1) ;
                    cnt+=a[i][0]-1 ;
                }
            }
            if(tot<=0) break ;
            
        }
        
        if(tot<=0)
            mx = min(cnt , mx) ;
          
    }
    cout<<mx<<endl;
    return 0 ;
}


Measured memory_bytes: 256
max = 50021

primes = (2..Math.sqrt(max)).inject([*2..max]) do |nums, sieve|
  nums.reject { |num| num % sieve == 0 && num != sieve }
end

while line = gets
  n = line.chomp.to_i
  min = primes.take_while { |x| x < n }.max
  max = primes.sort { |a, b| b <=> a }.take_while { |x| x > n }.min
  puts "#{min} #{max}" 
end

Measured memory_bytes: 21544
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

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

    long A[N + 1];
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
    }

    const long modnum = pow(10, 9) + 7;
    long A_sum[N + 1];
    A_sum[N + 1] = 0;
    for (int i = 0; i <= N; i++)
    {
        A_sum[N - i] = (A_sum[N - i + 1] + A[N - i]) % modnum;
    }

    long long ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ans = ans + ((A[i] * A_sum[i + 1]) % modnum);
    }
    ans = ans % modnum;
    cout << ans << "\n";
}


Measured memory_bytes: 6316
n,m = map(int,input().split())
lst = [[] for _ in range(8)]
for i in range(n):
    x,y,z = map(int,input().split())
    lst[0].append(x+y+z)
    lst[1].append(x+y-z)
    lst[2].append(x-y+z)
    lst[3].append(x-y-z)
    lst[4].append(-x+y+z)
    lst[5].append(-x+y-z)
    lst[6].append(-x-y+z)
    lst[7].append(-x-y-z)
for i in range(8):
    lst[i].sort(reverse=True)
res = []
for i in range(8):
    res.append(sum(lst[i][:m]))
print(max(res))

Measured memory_bytes: 39024
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	string A, B;
	cin >> A >> B;
	A += B;
	if (SQRTOR(stoi(A)))
		cout << "Yes";
	else
		cout << "No";
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int h,w,k;cin >> h >> w >> k;
  char s[h][w];
  rep(i,h)
    rep(j,w) cin >> s[i][j];

  int ans[h][w];
  vint z;

  int out=0;
  bool p;//今表示してる区画にもう苺があるか
  bool e;//その行に苺が存在するか
  rep(i,h){
    p=false;
    e=false;
    out++;
    rep(j,w){
      if(s[i][j]=='#'){
        e=true;
        if(!p){
          p=true;
        }else out++;
        ans[i][j]=out;
      }else
        ans[i][j]=out;
    }
    if(!e)z.push_back(i);
  }


  rfor(z,e){
    repi(i,e,h)
      rep(j,w)ans[i][j]--;
  }

  rfor(z,i){
    if(i!=0)
      rep(j,w)ans[i][j]=ans[i-1][j];
    else 
      rep(j,w)ans[i][j]=ans[i+1][j];
  }
  for(int i=h-2;i>=0;i--)
    rep(j,w){
      if(ans[i][j]==0){
        ans[i][j]=ans[i+1][j];
      }
    }

  rep(i,h){
    rep(j,w){
      printf("%d ",ans[i][j]);
    }
    puts("");
  }
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod=1000000007;
int N;
int a[100001];
int ans=1;
int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++)scanf("%d",&a[i]);
  sort(a,a+N);
  if(N%2==1){
    if(a[0]!=0){
      printf("0\n");
      return 0;
    }
    for(int i=1;i<N;i=i+2){
      if(!(a[i]==a[i+1] && a[i+1]==i+1)){
	printf("0\n");
	return 0;
      }
    }
    for(int i=0;i<N/2;i++) ans=ans*2%mod;
     
    printf("%d\n",ans);
  }
  else{
    for(int i=1;i<N;i=i+2){
      if(!(a[i]==a[i-1] && a[i]==i)){
	printf("0\n");
	return 0;
      }
    }
    for(int i=0;i<N/2;i++) {ans=ans*2%mod;}
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string s;
  cin >> s;

  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if(s[2] == 'o') ans += 100;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int x,y,z;
  if(a>=b){
  x=a-b;
  }else{
  x=b-a;
  }
  if(b>=c){
  y=b-c;
  }else{
  y=c-b;
  }
  if(a>=c){
  z=a-c;
  }else{
  z=c-a;
  }
  if(z<=d){
  printf("Yes");
  }else{
    if(x<=d&&y<=d){
  printf("Yes");
  }else{
  printf("No");
  }
  }  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define f first
#define s second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    ld a,b; cin >> a >> b;
    cout<<(ll)(a*b)<<endl;
}

Measured memory_bytes: 3752
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        int[] arr = nextIntArr(n);
        long[] dp = new long[1 + k];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            long[] nxt = new long[1 + k];
            nxt[0] = 1;
            long[] pref = new long[1 + k + 1];
            for (int j = 1; j < pref.length; j++) {
                pref[j] = pref[j - 1] + dp[j - 1];
            }

            for (int j = 1; j <= k; j++) {
                int start = Math.max(0, j - arr[i - 1]);
                // [start, j]
                long tmp = pref[j + 1] - pref[start];
                tmp = tmp % MOD;
                nxt[j] = tmp;
            }
            
            dp = nxt;
        }
        outln(dp[k]);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 52528
#include<stdio.h>
int main(void)
{
    int n,k,x,y,z;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(k<n){
	    z=k*x+(n-k)*y;
		printf("%d\n",z);
	}
	else{
	    printf("%d\n",n*x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using LL = long long int;
using namespace std;
int main(){
    LL n,d;
    cin >> n >> d;
    LL counter = 0;
    for(LL i = 0;i < n;i++)
    {
        LL x,y;
        cin >> x >> y;
        if(x * x + y * y <= d * d){
            counter++;
        }
    }
    cout << counter;
    return 0;
}


Measured memory_bytes: 3628
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 1000000000
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)

Measured memory_bytes: 11464
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    
    int n, m;
    cin >> n;
    unordered_map<string, int> um;
    int res = 0;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        um[s]++;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> s;
        um[s]--;
    }
    for (auto p : um) {
        res = max(res, p.second);
    }
    cout << res << endl;
}




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

int main() {
    std::vector<int> a(3);
    std::cin >> a[0] >> a[1] >> a[2];

    int max = std::max({a[0], a[1], a[2]});

    int cnt = 0;
    while (a[0] < max)
    {
        a[0] += 2;
        cnt++;
    }

    while (a[1] < max)
    {
        a[1] += 2;
        cnt++;
    }

    while (a[2] < max)
    {
        a[2] += 2;
        cnt++;
    }

    int cnta = 0;
    for (int i = 0; i < 3; i++)
    {
        if(max < a[i]) {
            cnta++;
        }
    }

    if(a[0]== a[1] && a[1]==a[2]) {
        std::cout << cnt << "\n";
    } 
    if(cnta == 2) {
        std::cout << cnt - 1 << std::endl;
    } 
    
    if(cnta == 1){
        std::cout << cnt + 1 << std::endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
    string s;
    cin>>s;
    int start,end,cnt=0;
     for(int i=0;i<(int)s.length();i++){
	   if(s[i]=='A'){
		    start=i;
		    break; 
		  }	   
	}
	for(int i=(int)s.length()-1;i>=0;i--){
	  if(s[i]=='Z'){
		   end=i;
		   break; 
		 }	
	}
    for(int i=start;i<=end;i++)cnt++;
    cout<<cnt<<endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 720
N,M=map(int,input().split())
S=[]
for i in range(M):
    s=list(map(int,input().split()))
    S.append(s[1:])
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
    i=bin(i)[2:].zfill(N)
    p=[0]*M
    for k in range(N):
        for j in range(M):
            if i[k]=="1" and (k+1 in S[j]):
                p[j]+=1
                p[j]%=2
    if p==P:
        ans+=1
print(ans)


Measured memory_bytes: 42608
A, B, C, D = map(int, input().split())


def battle(HP, attack):
    HP -= attack
    return HP


while A >= 0 or C >= 0:
    C = battle(C, B)
    if C <= 0:
        print("Yes")
        break
    A = battle(A, D)
    if A <= 0:
        print("No")
        break


Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main(void) {
	int W, N, i, j = 1, index, maxValue, minWeight;
	int result[1001], weight[1001], value[1001];
	char c;

	while (1) {
		cin >> W;
		if (W == 0) {
			break;
		}

		for (i = 0; i < 1001; i++) {
			value[i] = weight[i] = result[i] = 0;
		}

		cin >> N;
		for (i = 0; i < N; i++) {
			cin >> value[i] >> c >> weight[i];
		}
		
		for (i = 0; i < N; i++) {
			for (index = W; index >= weight[i]; index--) {
				result[index] = max(result[index], result[index - weight[i]] + value[i]);
			}
		}

		maxValue = result[W];
		for (i = 0; i < 1001; i++) {
			if (result[i] == maxValue) {
				minWeight = i;
				break;
			}
		}

		cout << "Case " << j << ":" << endl << maxValue << endl << minWeight << endl;
		j++;
	}

	return 0;
}




Measured memory_bytes: 3116
function Dice( faces ) {
  this.faces = faces;
  this.getFace = function ( id ) {
    return this.faces[id];
  }
  this.roll = function ( cmds ) {
    var t;
    for( var i=0; i<cmds.length; i++ ) {
      if( 'E' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = t;
      } else if( 'S' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = t;
      } else if( 'W' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;
      } else if( 'N' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = t;        
      } else if( 'M' == cmds[i] ) {
        t = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;        
      }
    }
  }  
}
Dice.TOP = 0;
Dice.FRONT = 1;
Dice.RIGHT = 2;
Dice.LEFT = 3;
Dice.BACK = 4;
Dice.BOTTOM = 5;

var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var output = [];
  var faces = data[0].split( ' ' ).map( Number );
  var mydice = new Dice( faces ); 
  var q = parseInt( data[1] );
  
  for( var i=0; i<q; i++ ) {
    var labels = data[2+i].split( ' ' ).map( Number );
    var cmds = "NWWWN";
    for( var j=0; j<cmds.length; j++ ) {
      if( labels[0] == mydice.getFace( Dice.TOP ) ) { break; }
      mydice.roll( cmds[j]  );
    }
    cmds = "MMM";
    for( var j=0; j<cmds.length; j++ ) {
      if( labels[1] == mydice.getFace( Dice.FRONT ) ) { break; }
      mydice.roll( cmds[j] );
    }
    output.push( mydice.getFace( Dice.RIGHT ) );
  }
  console.log( output.join( '\n' ) );
});

Measured memory_bytes: 15672
n = input()
l = list(map(int, input().split()))
s = 0
now = l[0]
count = 0
for i in range(1, len(l)):
    if s == 0:
        if l[i] > now:
            s = 1
        elif l[i] < now:
            s = -1
    elif s == 1:
        if not (l[i] >= now):
            count += 1
            s = 0
    else:
        if l[i] > now:
            count += 1
            s = 0
    now = l[i]
print(count + 1)

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};


const static int MAX = 200;
llong d[MAX + 1][MAX + 1];

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> R(r);
    rep(i, r) cin >> R[i];
    rep(i, n) rep(j, n) d[i][j] = (i == j) ? 0 : INF;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        d[a][b] = c, d[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    sort(all(R));
    llong ans = INF;
    do {
        llong tmp_dist = 0;
        for (size_t i = 0; i < r - 1; ++i) {
            //cout << R[i] << " ";
            tmp_dist += d[R[i] - 1][R[i + 1] - 1];
            // cout << R[i] << " " << R[i + 1] << " " << d[R[i] - 1][R[i + 1] - 1];
        }
        // cout << endl;
        ans = min(ans, tmp_dist);
        //cout << ans << endl;
    } while(next_permutation(all(R)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
S=input()
A=int(S[:2])
B=int(S[2:])
if 1<=A<=12 and 1<=B<=12:
  print('AMBIGUOUS')
elif 1<=A<=12:
  print('MMYY')
elif 1<=B<=12:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060