akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            if (S[0] == S[1] && S[2] == S[3] && S[1] == S[2]) WriteLine("No");
            else if (S[0] == S[1] && S[2] == S[3]) WriteLine("Yes");
            else if (S[0] == S[2] && S[1] == S[3]) WriteLine("Yes");
            else if (S[0] == S[3] && S[1] == S[2]) WriteLine("Yes");
            else WriteLine("No");

        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1]={0};
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if (i == 0 || j == 0)  
                dp[i][j] = 0; 
            else if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
            
        }
    }
    // cout<<"Length:"<<dp[n][m]<<endl;
   string ans;
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          ans += s[i-1];  
          i--; j--;      
      }  
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
    reverse(ans.begin(), ans.end()); 
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
//package com.beginner.b052;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int cities [] = new int [n];
        for(int i=0;i<n;i++)
            cities[i] = sc.nextInt();

        long minCost = 0L;

        for(int i=0;i<n-1;i++){
            int dist = cities[i+1]-cities[i];
            minCost+=Math.min((long)dist*a,(long)b);
        }

        System.out.print(minCost);

        sc.close();
    }

}

Measured memory_bytes: 34276
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<HashSet<_>>();

    let M = buf_it.next().unwrap().parse::<usize>().unwrap();
    let B = (0..M).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<HashSet<_>>();

    let ans = A.intersection(&B).collect::<HashSet<_>>().len();
    println!("{}",ans);
}


Measured memory_bytes: 5040
n = gets.to_i
ns = gets.chomp.split(' ').map(&:to_i)

r = 'Yes'

(n - 1).downto(1) do |i|
    if ns[i - 1] - ns[i] > 1
        r = 'No'
        break
    end
    ns[i - 1] -= 1 if ns[i - 1] - ns[i] == 1
end

puts r

Measured memory_bytes: 9604
n,k = map(int,input().split())
h = []
for _ in [0]*n:
  h += [int(input())]
h.sort()
m = h[-1]-h[0]
for i in range(0,n-k+1):
  m = min(m, h[i+(k-1)]-h[i])
print(m)  
  

Measured memory_bytes: 7840
s = input()
tc = [ chr(i)*2 for i in range(ord('a'), ord('z')+1) ]  + [ chr(i)+chr(j)+chr(i) for i in range(ord('a'), ord('z')+1) for j in range(ord('a'), ord('z')+1)]
x=y=-1
t = "0"
for i in set(tc):
  if i in s:
    t = i
for i in range(len(s)):
    if s[i:i+len(t)] == t:
      x = i+1
      y = i+len(t)
print(x, y)

Measured memory_bytes: 3188
def meiro(sx,sy):
    num = [[-1] * w for i in range(h)]
    num[sx][sy] = 0
    now = {(sx,sy)}
    for i in range(1,400):
        tmp = set()
        for x,y in now:
            if x > 0:
                if lis[x-1][y] == "." and num[x-1][y] == -1:
                    num[x-1][y] = i
                    tmp.add((x-1,y))
            if x < h-1:
                if lis[x+1][y] == "." and num[x+1][y] == -1:
                    num[x+1][y] = i
                    tmp.add((x+1,y))
            if y > 0:
                if lis[x][y-1] == "." and num[x][y-1] == -1:
                    num[x][y-1] = i
                    tmp.add((x,y-1))
            if y < w-1:
                if lis[x][y+1] == "." and num[x][y+1] == -1:
                    num[x][y+1] = i
                    tmp.add((x,y+1))
        now = tmp
    nu = -1
    for i in range(h):
        for j in range(w):
            if num[i][j] != -1:
                nu = max(nu,num[i][j])
    return nu

h,w = map(int,input().split())
lis = [str(input()) for i in range(h)]
ans = -1
for sx in range(h):
    for sy in range(w):
        if lis[sx][sy] == ".":
            ans = max(ans,meiro(sx,sy))
print(ans)


Measured memory_bytes: 66160
S=input()
first=S[:2]
second=S[2:]


month1=0
month2=0
if int(first)>0 and int(first)<13:
    month1=1
if int(second)>0 and int(second)<13:
    month2=1

if month1==1 and month2==1:
    print('AMBIGUOUS')
elif month1==1 and month2==0:
    print('MMYY')
elif month1==0 and month2==1:
    print('YYMM')
else:
    print("NA")

Measured memory_bytes: 38384
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
class PotUnionFind:
    __slots__ = ["parent", "gsize", "diff_p"]
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.gsize = [1]*n #グループの要素数
        self.diff_p = [0]*n #親ノードを基準としたポテンシャル
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.diff_p[x] += self.diff_p[self.parent[x]]
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 

    def weight(self, x): #root(x): xの根ノードを返す．
        c=0
        while self.parent[x] != x:
            self.diff_p[x] += self.diff_p[self.parent[x]]
            self.parent[x] = self.parent[self.parent[x]]
            c += self.diff_p[x]
            x = self.parent[x]
        return c


    def merge(self, x, y, dxy): #ポテンシャル差p(y)-p(x)=dxyでxとyの組をまとめる
        dxy += self.weight(x) - self.weight(y) #dxyをで置き換え
        x,y = self.root(x), self.root(y)
        if x == y: return False
        if self.gsize[x] > self.gsize[y]: #rxの要素数が大きいように
            x,y,dxy = y,x,-dxy
        self.gsize[x] += self.gsize[y] #xの要素数を更新
        self.parent[y] = x #ryをrxにつなぐ
        self.diff_p[y] = dxy #ryの相対ポテンシャルを更新
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def diff(self,x,y): #diff(x,y): xを基準としたyのポテンシャルを返す 
        if self.root(x) == self.root(y):
            return self.weight(y) - self.weight(x)
        else:
            return None

    def size(self,x): #size(x): xのいるグループの要素数を返す
        return self.gsize[self.root(x)]


n,m = list(map(int,input().split()))
 
uf = PotUnionFind(n)
ans = True
for i in range(m):
    l,r,d=list(map(int,input().split()))
    l-=1;r-=1;
    if uf.issame(l,r):
        ans = d==uf.diff(l,r)
    else:
        uf.merge(l,r,d)
    if ans == False:
        break
 
if ans == False:
    print('No')
else:
    print('Yes')
                
                


Measured memory_bytes: 69080
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll cnt = 0;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    rep(i, n) {
        cnt += ((a[i]+cnt+b[i]-1)/b[i])*b[i] - (a[i]+cnt);
    }
    cout << cnt << endl;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d)
    cout<<"Yes"<<endl;
  else if(abs(a-b)<=d&&abs(b-c)<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int N,M;
vector<P> X; // AとB

int main()
{
  cin >> N >> M;
  X.resize(N);

  REP(i,0,N) {
    int A,B;
    cin >> A >> B;
    X[i] = P(A,B);
  }

  sort(ALL(X));

  // 安いところからM個
  ll m = M;  // 残り本数
  ll res = 0;  // 使った金
  // REP(i,0,N) {
  //   if (
  int i = 0;
  while (m > 0) {
    ll count = min(X[i].second, m);  // B[i]本すべて買う
    res += X[i].first * count; // 1つA[i]円
    m -= count;
    ++i;
  }

  cout << res << endl;

  return 0;
}


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

int foo(long long n, long long m, long long X){
  long long at = 0, a0 = n, a1 = n, b0 = m, b1 = m, a2 = 0, b2 = 0, time=0, temp;
 
  while(1){
    if(time%2==X){
      at = a0;
      temp = min(b2,at);
      b2 -= temp; at -= temp;
      temp = min(b1, at/2);
      b1 -= temp; at -= temp*2;
      if(at){
	if(b2)b2--;
	else if(b1)b1--,b2++;
      }
    }else{
       at = b0;
       temp = min(a1,at);
       a1 -= temp; a2 += temp; at -= temp;
       temp = min(a2, at);
       a2 -= temp; at -= temp;
    }
    a0 = a1+a2;
    b0 = b1+b2;
    

    if(!a0||!b0)break;
    time++;
  }
  //cout<<time<<endl;
  return time;
}

int main(){
  long long n, m;
  cin>>n>>m;
  cout<<min(foo(n,m,0), foo(m,n,1))<<endl;
  return 0;
}


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

int main(){
  int n,m=0;
  cin>>n;
  vector<char>s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  
  for(int i=0;i<n;i++){
    if(s[i]=='Y'){
      m++;
    }
  }
  if(m!=0){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}



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

using namespace std;

static string S;
string solve();

string solve() {
  for (uint i = 0; i < 3; i++) {
    if (S[i] == S[i + 1]) {
      return "Bad";
    }
  }
  return "Good";
}

int main() {
  cin >> S;
  cout << solve() << endl;
  return 0;
}


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

int n, v[2], M;
map<int,P> m[2];
int tate[2][500];
int yoko[2][500];
int nana[2][2];
int sum[2];
bool ok[2];

int main(){
	cin >> n >> v[0] >> v[1] >> M;
	rep(u,2) rep(i,n) rep(j,n){
		int x; cin >> x;
		m[u][x] = P(i+1,j+1);
	}
	if(n == 1){
		int num; cin >> num;
		if(m[0][num].first != 0 && v[0] == 1) ok[0] = true;
		if(m[1][num].first != 0 && v[1] == 1) ok[1] = true;
		if(ok[0] == true && ok[1] == true){
			puts("DRAW");
			return 0;
		}
		if(ok[0] == true){
			puts("USAGI");
			return 0;
		}
		if(ok[1] == true){
			puts("NEKO");
			return 0;
		}
		puts("DRAW");
		return 0;
	}
	rep(i,M){
		int num; cin >> num;
		rep(j,2){
			P p = m[j][num];
			if(p.first == 0) continue;
			p.first--; p.second--;
			tate[j][p.first]++;
			yoko[j][p.second]++;
			if(tate[j][p.first] == n) sum[j]++;
			if(yoko[j][p.second] == n) sum[j]++;
			if(p.first == p.second){
				nana[j][0]++;
				if(nana[j][0] == n) sum[j]++;
			}
			if(p.first+p.second==n-1){
				nana[j][1]++;
				if(nana[j][1] == n) sum[j]++;
			}
			if(sum[j] >= v[j]) ok[j] = true;
		}
		if(ok[0] == true && ok[1] == true){
			puts("DRAW");
			return 0;
		}
		if(ok[0] == true){
			puts("USAGI");
			return 0;
		}
		if(ok[1] == true){
			puts("NEKO");
			return 0;
		}
	}
	puts("DRAW");
}

Measured memory_bytes: 20632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%.15f ",(double)(w*h)/2.0);
	if(x*2==w&&y*2==h) cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int a[n];
  rep(i,n) R a[i];
  sort(a,a+n,greater<int>());
  int c[2]={0,0};
  rep(i,n) c[i%2]+=a[i];
  pr(c[0]-c[1]);
}

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


Measured memory_bytes: 256
import sys
import os
N = int(input())
A = list(map(int,input().split()))

negativeCnt = 0
for a in A:
    if a < 0:
        negativeCnt += 1
A = list(map(lambda a: -a if a < 0 else a, A))
miniA = min(A)
if negativeCnt%2 == 0:
    print(sum(A))
else:
    print(sum(A)-2*miniA)


Measured memory_bytes: 14332
#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<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    string s;
    cin >> s;
    ll red = 0, blue = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) == '0')
        {
            red++;
        }
        else
        {
            blue++;
        }
    }
    if (red && blue)
    {
        cout << min(red, blue) * 2 << endl;
    }
    else
    {
        cout << "0" << endl;
    }
}

Measured memory_bytes: 512
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
set<P> s;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            s.insert(P(i,j));
    if(n&1)
    {
        for(int i=1;i<=n/2;i++) s.erase(P(i,n-i));
    }
    else for(int i=1;i<=n/2;i++) s.erase(P(i,n+1-i));
    printf("%d\n",(int)s.size());
    for(auto p:s) printf("%d %d\n",p.F,p.S);
    return 0;
}



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

int N, K;
vector<int> p(200010);
vector<double> CSum_p(200010, 0);  //i番目までのpの和
double res = 0;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){ cin >> p[i]; CSum_p[i+1]=p[i]+CSum_p[i]; }
    for(int i = K; i <= N; i++) res=max(res,((CSum_p[i]-CSum_p[i-K]+K)/2)); 
    printf("%.12f\n", res);
    return 0;
}

Measured memory_bytes: 5452
/*************************************
 *プログラム名：C.c
 *
 *************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#include <pthread.h>

//<<<<<>>>>>//

int main(void)
{
	int i, N, num, sum = 0;
	char S[100001];
	
	scanf("%s", S);
	//printf("%s\n", S);
	
	N = strlen(S);
	
	for (i = 0, num = 0; i < N; i++) {
		if (S[i] == 'B') {
			if (num != 1) {
				sum++;
				num = 1;
			}
		} else {
			if (num != 2) {
				sum++;
				num = 2;
			}
		}
	}
	
	printf("%d\n", sum - 1);
	
	return (0);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x,y,a[13];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	a[1]=1;
	a[3]=1;
	a[5]=1;
	a[7]=1;
	a[8]=1;
	a[10]=1;
	a[12]=1;
	a[4]=2;
	a[6]=2;
	a[9]=2;
	a[11]=2;
	a[2]=3;
	cin>>x>>y;
	if (a[x]==a[y]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



long long a, b;

int main() {
    while (cin >> a >> b) {
        if (b < 0) {
            if ( (b - a + 1) & 1 ) puts("Negative");
            else puts("Positive");
        }
        else if (a > 0) puts("Positive");
        else puts("Zero");
    }
}




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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL n;cin>>n;
    LL result = 0;

    VL a(n+10,1);
    FOR(i,2,n+1){
        a[i]++;
        for(int j=2;i*j<=n;j++){
            a[i*j]++;
        }
    }

    //REP(i,n+1){
    //    cerr<<i<<" "<<a[i]<<endl;
    //}

    FOR(i,1,n+1){        
        result += i * a[i];
    }
    cout<<result<<endl;

    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 81280
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] NM = Console.ReadLine().Split(' ');
        int N = int.Parse(NM[0]);
        int M = int.Parse(NM[1]);
        List<Tuple<int, int>> n = new List<Tuple<int, int>>();
        for (var i = 0; i < N; i++)
        {
            string[] n2 = Console.ReadLine().Split(' ');
            int A = int.Parse(n2[0]);
            if (A > M) continue;
            int B = int.Parse(n2[1]);
            n.Add(new Tuple<int, int>(B, A));
        }
        n.Sort();
        n.Reverse();
        long ans = 0;
        int[] max = new int[M+1];
        for (var i = 0; i < M; i++)
        {
          max[i] = i;
        }
        foreach (var i in n)
        {
          bool hit = false;
          for (var j = M-i.Item2; j > 0; j = max[j])
          {
            if (max[j] == j)
            {
              hit = true;
              ans += i.Item1;
              max[M-i.Item2] = max[j] = max[j-1];
              break;
            }
          }
          if (!hit)
          {
            if (max[0] == 0)
            {
              ans += i.Item1;
              max[0] = -1;
            }
          }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 23776
alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
n = int(input())
s = input()
s_list = list(s)
rot=[]
for i in range(len(s_list)):
    for j in range(26):
        if alpha[j] == s_list[i]:
            pos = (j+n) % 26
            rot.append(alpha[pos])
print(''.join(rot))

Measured memory_bytes: 40176
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int N=2e5+10;
const int P=27;
const int mod1=19260817;
const int mod2=1e7+9;
string s[N];
int n,cnt[33],vis1[mod1],vis2[mod2];
unordered_map<ll,int>alp;
ll ans=0;
bool cmp(string a,string b){return a.size()>b.size();}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		ll hs=0;
		for(int j=s[i].size()-1;j>=0;j--)hs=hs*P+s[i][j]-'a'+1;
		alp[hs]++,vis1[hs%mod1]=1,vis2[hs%mod2]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=26;j++)cnt[j]=0;
		int m=s[i].size();ll hs=0;
		for(int j=0;j<m;j++)cnt[s[i][j]-'a'+1]++;
		for(int k=1;k<=26;k++)if(cnt[k]&&vis1[(hs*P+k)%mod1]&&vis2[(hs*P+k)%mod2])ans+=alp[hs*P+k];
		for(int j=m-1;j>=0;j--)
		{
			hs=hs*P+s[i][j]-'a'+1;
			cnt[s[i][j]-'a'+1]--;
			for(int k=1;k<=26;k++)if(cnt[k]&&vis1[(hs*P+k)%mod1]&&vis2[(hs*P+k)%mod2])ans+=alp[hs*P+k];
		}
	}
	printf("%lld\n",ans-n);
	return 0;
}


Measured memory_bytes: 131472
N = int(input())
d = dict()
for i in range(N):
    s = list(input())
    s.sort()
    s = ''.join(s)
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

ans = 0
for i in d.values():
    ans += (i * (i-1)) // 2

print(ans)

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int D, G;
  cin >> D >> G;
  vector<PII> ps(D);
  cin >> ps;

  int ans = 1e9;
  REP(b,1<<D){
	int s = 0, n = 0;
	REP(k,D){
	  if(b>>k&1){
		s += ps[k].FF * (k+1)*100 + ps[k].SS;
		n += ps[k].FF;
	  }
	}

	for(int k=D-1;k>=0;--k){
	  if(G <= s) break;
	  if(!(b>>k&1)){
		int x = min(ps[k].FF, (G - s + (k+1)*100-1) / ((k+1)*100));
		s += (k+1)*100 * x;
		n += x;
	  }
	}
	if(G <= s)
	  mini(ans, n);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int siz=100001;
    int q=sc.nextInt();
    boolean[] p=new boolean[siz];
    Arrays.fill(p,true);
    boolean[] l=new boolean[siz];
    int[] wa=new int[siz+1];
    p[0]=p[1]=false;
    for(int i=2;i<siz;i++){
      if(!p[i]){
        continue;
      }
      for(int j=i+i;j<siz;j+=i){
        p[j]=false;
      }
    }
    for(int i=1;i<siz;i+=2){
      if(p[i]&&p[(i+1)/2]){
        l[i]=true;
      }
    }
    for(int i=0;i<siz;i++){
      if(l[i]){
        wa[i+1]=wa[i]+1;
      }else{
        wa[i+1]=wa[i];
      }
    }
    for(int i=0;i<q;i++){
      int a=sc.nextInt();
      int b=sc.nextInt();
      System.out.println(wa[b+1]-wa[a]);
    }
  }
}

Measured memory_bytes: 64120
#include <bits/stdc++.h>
/**
 *    author:  dattrinh
 *    created:    Codeforces Round #635
**/
#define pb push_back
#define fi first
#define ss second
#define tp(x) fixed<<setprecision(x)
using namespace std;
using ll = int64_t;
const int N = 1000003;
ll t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,t=0;
    cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)
        {
            for(int k=1;k<=n;++k){
                t+=(__gcd(i,__gcd(j,k)));
            }
        }
    }
    cout<<t;
    return 0;
}






Measured memory_bytes: 3656
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e4 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
signed main() {
    int n; cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3620
import sys
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i]+a[i+1]>x:
    if a[i]<x:
      ans+=a[i]+a[i+1]-x
      a[i+1]=x-a[i]
    else:
      ans+=a[i]+a[i+1]-x
      a[i+1]=0
print(ans)

Measured memory_bytes: 84884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    string s;
    cin >> s;
    string ans = s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>

int main(void){
	int t,n,f,s,i;
	while(1){
		scanf("%d",&t);
		if(t==0){
			return 0;
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			t=t+s-f;
		}
		if(t<=0){
			printf("OK\n");
		}
		else{
			printf("%d\n",t);
		}
	}

return 0;
}

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

using namespace std;
using ll = long long;
using pl = pair<ll,ll>;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  ll ans = 0;
  vector<ll> v;
  for(ll i=0; i<N; i++) {
    ll j = lower_bound(v.begin(), v.end(), A[i]) - v.begin(); //number of elements which are smaller than A[i]
    if(j == 0) { // not found
      v.insert(v.begin(), A[i]);
      ans++;
    } else { //found
      v[j-1] = A[i];
    }
    //sort(v.begin(), v.end());f
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 2168
n=int(input())
from collections import defaultdict
d=defaultdict(list)
for i in range(n):
    s,p=input().split()
    d[s].append((int(p),i+1))
keys=sorted(d.keys())
# print(keys)
# print(d)
for key in keys:
    for item in sorted(d[key],key=lambda x : x[0],reverse=True):
        print(item[1])

Measured memory_bytes: 38512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define d second
#define p first

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, m, res; cin >> n >> m, n; cout << res << endl){
        res = 0;

        vector<pii> q(n);

        rep(i, n){
            cin >> q[i].d >> q[i].p;
        }
        sort(all(q), greater<pii>());

        rep(i, n){
            int rest = q[i].d - min(q[i].d, m);
            m = max(0, m - q[i].d);

            res += q[i].p * rest;
        }
    }

	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
   int a, b, c, x;

   cin >> a >> b >> c >> x;

   int ans = 0;

    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                if (x == 500 * i + 100 * j + 50 * k) {
                    ans++;
                }
            }
        }
    }

     cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
int MAX_N,q;
int par[(int)2e5];
int ranks[(int)2e5];

void init(int n) {
    for (int i=0; i<n; i++){
        par[i] = i;
        ranks[i] = 0;
    }
}

int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x==y) return;

    if (ranks[x] < ranks[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if (ranks[x]==ranks[y]) ranks[x]++;
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}

int main(){
  	cin >> MAX_N >> q;
    init(MAX_N);
    for(int i=0;i<q;i++){
        int a,b,c;
        cin >> a >> b >> c;
        if(a==0){
            unite(b,c);
        }
        else{
            if(same(b,c)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
}

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

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
    int r;
    cin>>r;
    printf("%.10f",2*3.14159265*r);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}
#define level 22

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    
    
    ll ans=k-a[n-1]+a[0];
    
    for(int i=0;i<n-1;i++)
    {
        ans=max(ans,a[i+1]-a[i]);
    }
  //  cout<<ans<<endl;

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


Measured memory_bytes: 1792
from fractions import gcd

def count_divisible_by(n, start, end):
    return end // n - (start - 1) // n

a, b, c, d = [int(i) for i in input().split()]

lcm = c * d // gcd(c, d)
print(b-a+1 - count_divisible_by(c, a, b) - count_divisible_by(d, a, b) + count_divisible_by(lcm, a, b))


Measured memory_bytes: 5048
#include <cstdio>
#include <utility>
#include <cctype>
#include <string>
#include <regex>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	regex a {">'(=+)#(=+)\\~"} ,b {">\\^(Q=)+\\~\\~"};
	smatch m;
	times(i, in) {
		string s = in;
		outl(regex_match(s, m, a) ? m[1].length() == m[2].length() ? "A" : "NA" :
			 regex_match(s, b) ? "B" : "NA");
	}
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	string s ;

	cin >> s ;

	int n = s.size() ;

	int l , r ;

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

		if( s[i] == 'A' ){

			l = i + 1 ; 

			break ;

		}

	}
	for( int i = n - 1 ; i > -1 ; i -- ){

		if( s[i] == 'Z' ){

			r = i + 1 ;

			break ;

		}

	}

	cout << (r - l )+ 1  << endl ;

}

Measured memory_bytes: 720
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , q , a[N] , t[N] , res[N] ;

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

	cin >> n >> q ;

	q ++ ;
	a[0] = n ;
	for (int i = 1 ; i < q ; i ++) {
		int x ;
		cin >> x ;
		while (i && a[i - 1] >= x) i -- , q -- ;
		a[i] = x ;
	}

	t[q - 1] = 1 ;

	for (int i = q - 1 ; ~i ; i --) {
		int k = a[i] ;

		while (i && k >= a[0]) {
			int low = 0 , high = i ;

			while (high - low > 1) {
				int mid = (low + high) >> 1 ;
				if (k >= a[mid]) low = mid ;
				else high = mid ;
			}

			t[low] += t[i] * (k / a[low]) ;
			k %= a[low] ;
		}
		
		res[k] += t[i] ;
	}

	for (int i = n ; i ; i --) res[i] += res[i + 1] ;

	for (int i = 1 ; i <= n ; i ++) cout << res[i] << '\n' ;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;

      cin>>n>>m;

         int total=0;

           if(n > 1)
            total+=(n*(n-1))/2;

            if(m > 1)
            total+=(m*(m-1))/2;

          cout<<total<<endl;    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;


int main()
{

	cin >> N;

	bool ans = false;

	int n = N;
	for (int i = 0; i < 3 && !ans; i++) {
		int a = n % 10;
		if (a == 7) { ans = true; }
		n /= 10;
	}



	cout << (ans?"Yes":"No") << endl;

	return 0;
}


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

const int N = 5e5 + 5;
typedef long long LL;

LL mod = 1e9 + 7, ans, fac[N], inv[N], s;
int n, m;

LL Ksm(LL a, LL b) {
	LL res = 1;
	while(b) {
		if(b&1) res = res*a%mod;
		b = b>>1;
		a = a*a%mod;
	}
	return res;
}

LL Comb(int n, int k) {
	return fac[n]*inv[n - k]%mod*inv[k]%mod;
}

int f(int i) {
	return (i%2 == 1) ? 1: -1;
} 

int main() {
	cin>>n>>m;
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= m; i++)
		fac[i] = fac[i - 1]*i%mod, inv[i] = Ksm(fac[i], mod - 2);
	ans = fac[m]*inv[m - n]%mod;
	for(int i = 1; i <= n; i++)
		s = (s + f(i)*Comb(n, i)%mod*fac[m - i]%mod*inv[m - n]%mod)%mod;
	ans = ans*(ans - s)%mod;
	cout<<(ans + mod)%mod<<endl;

	return 0;
}

Measured memory_bytes: 11376
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int h,w;
	cin>>h>>w;
	vvi f(h,vi(w));
	rep(i,h)rep(j,w)cin>>f[i][j];
	int ans=0;
	vvi answers;
	rep(i,h)rep(j,w){
	    if(f[i][j]%2==0)continue;
	    if(j+1!=w){
	        f[i][j]--;
	        f[i][j+1]++;
            ans++;
	        answers.push_back(vi{i+1,j+1,i+1,j+2});
	    }else if(i+1!=h){
	        f[i][j]--;
	        f[i+1][j]++;
            ans++;
	        answers.push_back(vi{i+1,j+1,i+2,j+1});
	    }
	}
	cout<<ans<<endl;
	for(auto a:answers)cout<<a<<endl;
	
	return 0;
}


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


int n, m;

double dp[3000] = {};

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

	dp[0] = 1.0;

	for(int i = 0; i < n; i++){
		double p; cin >> p;
		for(int j = i; j >= 0; j--){
			dp[j+1] += dp[j] * p;
			dp[j] *= (1.0 - p);
		}
	}

	double ans = 0.0;
	for(int i = n/2+1; i <= n; i++){
		ans += dp[i];
	}

	cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

li x,y;

bool chk(li mid){
	li res=0;
	for(li i=max(mid/2-100,1ll);i<=min(mid/2+100,mid);i++){
		li a=i;
		li b=mid-i+1;
		if(a>=x) ++a;
		if(b>=y) ++b;
		res=max(res,a*b);
	}
	return res<x*y;
}

void solve(){
	cin>>x>>y;
	if(x>y) swap(x,y);
	li lo=0;
	li hi=3e9;
	li ans=0;
	while(lo<=hi){
		li mid=lo+hi>>1;
		if(chk(mid)){
			ans=mid;
			lo=mid+1;
		}else{
			hi=mid-1;
		}
	}
	cout<<ans<<"\n";
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

class Rand {
public:
	Rand(const int &in = 123) :init{ in } {};
	int operator()() {
		return init = next(init);
	}
private:
	int init;
	int next(const int &i) const {
		return (i * i) / 100 % 10000;
	}
};

int main() {
	int n;
	std::cin >> n;
	for (auto c = 1; c <= n; ++c) {
		int init;
		std::cin >> init;
		Rand rand(init);
		std::cout << "Case " << c << ":\n";
		for (auto i = 0; i < 10; ++i) {
			std::cout << rand() << '\n';
		}
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int p[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &p[i]);
	}
	int ans = 0;
	REPN(i, 1, n){
		if (p[p[i]] == i){
			ans++;
		}
	}
	ans /= 2;
	printf("%d\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long p = 1000;
			long n = Integer.parseInt(sc.next());
			int buy = Integer.parseInt(sc.next());
			long k = p / buy;
			for (int i = 1; i < n; i++) {
				int sell = Integer.parseInt(sc.next());
				if (sell > buy) {
					// 売って買う
					p += (sell - buy) * k;
					buy = sell;
					k = p / sell;
				} else {
					// 買いなおし
					buy = sell;
					k = p / sell;
				}
			}
			System.out.print(p);
		}
	}
}

Measured memory_bytes: 35688