akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();
		long[] t = new long[n];
		for (int i = 0; i < t.length; i++)
			t[i] = cin.nextLong();

		long start = now();

		long ans = solve(n, t);

		cout.println(ans);
		trace("elapsed", now() - start);
	}

	private static long solve(int n, long[] t) {
		long a = t[0];
		for (int i = 1; i < n; i++) {
			long b = t[i];
			long gcd = gcd(a, b);
			long lcm = a / gcd * b;
			a = lcm;
		}
		return a;
	}

	private static long gcd(long a, long b) {
		if (a < b) {
			long t = a;
			a = b;
			b = t;
		}
		return a % b == 0 ? b : gcd(b, a % b);
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 22740
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.      IIT PATNA      ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)


#include <bits/stdc++.h>
#define ii int64_t
#define PI 3.14
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define f(x,n) for(int x=0;x<n;++x)
#define ff(x,y,z) for(x=y;x<=z;++x)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;


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

    }for(i=n/2+1;i<=n;i++)ans+=dp[i];
    cout<<setprecision(9)<<fixed<<ans;
    

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)

using namespace std;

const int N=100005;
int n,m;bool vi[N];
vector<int>e[N];
int dfs(int u,int fa){
    if(e[u].size()>2)return u;
    for(int v:e[u])if(v!=fa)return dfs(v,u);
    return u;
}

int main(){
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),u++,v++,e[u].pb(v),e[v].pb(u);
    fo(i,1,n)if(e[i].size()==1)vi[dfs(i,0)]=true,m++;
    fo(i,1,n)if(vi[i])m--;if(!m)m++;
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

using pil = pair<int, lint>;

int n, q, K;
vector<pil> G[MAX];
lint d[MAX];

void dfs(int v, int pv, lint td){
    d[v] = td;
    for(auto e: G[v])if(e.fi != pv) dfs(e.fi, v, td + e.se);
}

int main(){
    scanf("%d", &n);
    rep(i, n-1){
        int a, b; lint c;
        scanf("%d%d%lld", &a, &b, &c);
        --a; --b;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    scanf("%d%d", &q, &K);
    --K;
    dfs(K, -1, 0);
    rep(i, q){
        int x, y;
        scanf("%d%d", &x, &y);
        --x; --y;
        printf("%lld\n", d[x] + d[y]);
    }
}

Measured memory_bytes: 14336
import sys
N=int(input())
s = list(map(int, input().split()))
ans =1
for i in s:
    if i==0:
        print(0)
        sys.exit()
    
for i in s:
    ans*=i
    if ans>1e18:
        print(-1)
        sys.exit()

print(ans)


Measured memory_bytes: 21568
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;
int v[3005],h[3005];
int t[3005],s[3005];

    //?????¨       //??????
int imos[3005];
int dp[1005][3005];

P1 min_pair(P1 a,P1 b){
    if(a.first<b.first)return a;
    else if(a.first>b.first)return b;
    else {
        if(a.second<b.second)return a;
        else if(a.second>b.second)return b;
        else return a;
    }
}

void solve(){

    for(int i=0;i<1005;++i)for(int j=0;j<3005;++j)dp[i][j]=-INF;

    dp[0][0]=0;

    for(int i=0;i<M;++i){
        for(int j=0;j<=N;++j){
            int cost;
            if(j)cost=imos[j-1];
            else cost=0;
            if(cost>t[i])continue;
            if(j>0){
                dp[i+1][j]=max(dp[i][j-1]+h[j-1],dp[i+1][j]);
            }
            if(j>1){
                dp[i+1][j]=max(dp[i+1][j-1]+h[j-1]+abs(h[j-2]-h[j-1]),dp[i+1][j]);
            }
        }
        for(int j=0;j<=N;++j)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
        for(int j=0;j<=N;++j){
            if(dp[i+1][j]<s[i])dp[i+1][j]=-INF;
        }
    }

    for(int i=0;i<=N;++i){
        if(dp[M][i]!=-INF){
            if(!i)cout<<t[M-1]<<endl;
            else cout<<t[M-1]-imos[i-1]<<endl;
            return ;
        }
    }
    cout<<-1<<endl;

}

signed main(){
    cin>>N>>M;
    for(int i=0;i<N;++i)cin>>v[i]>>h[i];
    for(int i=0;i<M;++i)cin>>t[i]>>s[i];
    for(int i=0;i<N;++i){
        if(!i){
            imos[i]=v[i];
        }
        else imos[i]=imos[i-1]+v[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 26784
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = input().strip()
    result = s[2] == s[3] and s[4] == s[5]
    print("Yes" if result else "No")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
#define MAX_V 100010
bool comp(P a,P b){
	return a.second>b.second;
}
int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	vector<ll>a(n);
	vector<P>change(m);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	for(int i=0;i<m;i++){
		cin>>change[i].first>>change[i].second;
	}
	sort(change.begin(),change.end(),comp);
	ll now=0;
	for(int i=0;i<m;i++){
		ll commit=0;
		for(int j=now;j<n;j++){
			if(a[j]<change[i].second){
				a[j]=change[i].second;
				commit++;
				now++;
			}
			if(commit==change[i].first)break;
		}	
		if(commit==0)break;
	}
	for(int i=0;i<n;i++)ans+=a[i];
	cout<<ans<<endl;

}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func canPay(usable []bool, money int) bool {
	for money > 0 {
		if !usable[money%10] {
			return false
		}
		money /= 10
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	usable := make([]bool, 10)
	for i := range usable {
		usable[i] = true
	}
	for i := 0; i < k; i++ {
		d := nextInt()
		usable[d] = false
	}

	ans := n
	for ; !canPay(usable, ans); ans++ {
	}

	puts(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
const ll INF = 	922337203685477580;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
ll dp[100010];

int main(){
  int h,w;
  cin>>h>>w;
  string ans;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      string s;
      cin>>s;
      if(s=="snuke"){
        ans=(char)('A'+j)+to_string(i+1);
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
//#include <iostream>
//#include <vector>
//#include <algorithm>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int N,K;
  cin >> N >> K;
  int count=0;
  rep(i,N){
    int x; cin >> x;
    if(x>=K) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ Volume2 0226

#include <stdio.h>

int main(void)
{
    int r, a;
    int rn[4], an[4];
    int h, b;
    int i, j;
    
    while (1){
        scanf("%d%d", &r, &a);
        if (r == 0 && a == 0){
            break;
        }
        
        for (i = 0; i < 4; i++){
            rn[i] = r % 10;
            r /= 10;
            an[i] = a % 10;
            a /= 10;
        }
        
        h = b = 0;
        for (i = 0; i < 4; i++){
            for (j = 0; j < 4; j++){
                if (i == j && rn[i] == an[j]){
                    h++;
                }
                else if (i != j && rn[i] == an[j]){
                    b++;
                }
            }
        }
        printf("%d %d\n", h, b);
    }
    return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

const int m = 11;
int dp[(1<<m)+1][100001];

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

    int n;
    cin>>n;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=(1<<m);i++){
        if(i > n)break;
        int nx = i/2;
        for(int j=0;j<=100000;j++){
            chmax(dp[i][j],dp[nx][j]);
            if(j+b[i] <= 100000)chmax(dp[i][j+b[i]],dp[nx][j]+a[i]);
            if(j)chmax(dp[i][j],dp[i][j-1]);
        }
    }
    int q;
    cin>>q;
    while(q--){
        int v,l;
        cin>>v>>l;
        if(v <= (1<<m)){
            cout << dp[v][l] << "\n";
            continue;
        }
        // v,v/2,...
        int ans = 0;
        queue<array<int,3>> que;
        que.push({v,0,0});
        while(que.size()){
            array<int,3> now = que.front();
            que.pop();
            int w = now[1],val = now[2],p = now[0];
            if(p <= (1<<m)){
                chmax(ans,dp[p][l-w]+val);
            }
            else{
                if(w+b[p] <= l)que.push({p/2,w+b[p],val+a[p]});
                que.push({p/2,w,val});
            }
        }
        cout << ans << "\n";
    }
    
}


Measured memory_bytes: 805292
#include<iostream>
#include<set>
#include<vector>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
    string a,b,s;
    int n,m;

    cin >> a >> b;
    s = a + b;
    n = atoi(s.c_str());
    m = (int)sqrt((double)n);
    if(m*m == n) cout << "Yes" << '\n';
    else cout << "No" << '\n';



    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const MOD = 1000000007

var SIntListInitialValue int
var SIntListIsInitialized bool

type SIntList []int

func lib_ModSum(a, b, mod int) int {
	return ((a % mod) + (b % mod)) % mod
}
func lib_NewSIntList(length int, initialValue int) SIntList {
	if SIntListIsInitialized {
		panic("SIntList is already used")
	}
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	SIntListInitialValue = initialValue
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var M int
	scanner.Scan()
	M, _ = strconv.Atoi(scanner.Text())
	a := make([]int, M)
	for i := 0; i < M; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, M, a))
}
func solve(N int, M int, a []int) int {
	dp := lib_NewSIntList(N+1, 0)
	m := map[int]bool{}
	for _, ai := range a {
		m[ai] = true
	}
	if _, ok := m[1]; !ok {
		dp[1] = 1
	}
	if N == 1 {
		return dp[1]
	}
	if _, ok := m[2]; !ok {
		dp[2] = dp[1] + 1
	}
	if N == 2 {
		return dp[2]
	}
	for i := 3; i <= N; i++ {
		if _, ok := m[i]; ok {
			continue
		}
		dp[i] = lib_ModSum(dp[i-1], dp[i-2], MOD)
	}
	return dp[N]
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int x;
	cin >> x;
	int ok = 0;
	while (x) {
		ok |= (x % 10 == 7);
		x /= 10;
	}
	if (ok) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3132
#include<iostream>
using namespace std;
int main()
{
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++)
  	{
    for(int j=0;j<=n-i;j++)
		{
      		int z=n-i-j;
      		if(10000*i+5000*j+1000*z==y)
	  		{
        		cout<<i<<" "<<j<<" "<<z<<endl;
        		return 0;
      		}
    	}
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}

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

string s;
bool ans;
map<char, int> m;

int main(){
cin >> s;
for(int i =0; i<s.size();i ++){
   m[s[i]]++;
}
ans = ((m['N']!=0)==(m['S']!=0))&&((m['E']!=0)==(m['W']!=0));

if(ans)cout << "Yes";
else cout << "No";

//if((m['N']>0&&m['S']>0)&&(m['E']>0&&m['W']>0))cout << "Yes";
//else if((m['N']>0&&m['S']>0) && (m['E']==0 && m['W']==0))cout << "Yes";
//else if((m['N']==0&&m['S']==0) && (m['E']>0 && m['W']>0))cout << "Yes";
//else cout << "No";

return 0;}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll h(n);
    rep(i,n) cin>>h[i];
    if (n==1){
        cout << "Yes\n";
        return 0;
    }
    bool yes = true;
    for(int i=n-2; i>=0; i--){
        if (h[i]>h[i+1]){
            h[i]--;
            if (h[i]>h[i+1]) yes = false;
        }
    }
    if (yes){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 500010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,D,q;

int Now[maxn],d[maxn];

ll pos[maxn];

void Work(){
	read(q);
//	REP(i,1,n)cout<<Now[i]<<' ';cout<<endl;
//	REP(i,1,n+1)cout<<pos[i]<<' ';cout<<endl;
	while(q--){
		int x;read(x);
		if(Now[x-1]>=pos[x+1])puts("YES");else puts("NO");
	}
}

void Init(){
	read(n,D);
	REP(i,1,n)read(d[i]);
	pos[n+1]=1;
	RREP(i,n+1,2)if(pos[i]<=d[i-1]/2)pos[i-1]=pos[i];else pos[i-1]=pos[i]+d[i-1];
	Now[0]=D;
	REP(i,1,n)Now[i]=min(Now[i-1],abs(Now[i-1]-d[i]));
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 9728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int min = INF;
			int max = -INF;
			char[] s = in.nextString().toCharArray();
			for (int i = 0; i < s.length; i++) {
				if (s[i] == 'A') {
					min = min(min, i);
				}

				if (s[i] == 'Z') {
					max = max(max, i);
				}
			}

			out.println(max - min + 1);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

	static long max(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static int max(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static long min(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

	static int min(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

}


Measured memory_bytes: 28884
import math

A, B, H, M = map(int, input().split())

H = H * 30 + M * 0.5
M = M * 6

diff = H - M

if diff < 0:
    if diff < -180:
        diff = 180 - abs(diff + 180)
    else:
        diff = abs(diff)

if diff > 180:
    diff = 180 - (diff - 180)
print(math.sqrt(A**2 + B**2 - (2 * A * B * math.cos(math.radians(diff)))))

Measured memory_bytes: 9452
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
  }else if(a==1){
    cout<<"Alice"<<endl;
  }else if(b==1){
    cout<<"Bob"<<endl;
  }else if(a>b){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
cusum = [A[0]]
for i in range(1, N):
    cusum += [cusum[-1]+A[i]]
B = []
for i in range(N):
    B += [cusum[i]]
    for j in range(i+1, N):
        B += [cusum[j] - cusum[i]]
max_bit = 43
ans = 0
while max_bit > 0:
    counter = Counter()
    for b in B:
        for i in range(44):
            if b & 1 == 1:
                counter[i] += 1
            b = b >> 1
    for i in range(max_bit, -1, -1):
        if counter[i] >= K:
            filter_bit = 2 ** i
            B = [b for b in B if b & filter_bit == filter_bit]
            max_bit = i-1
            ans += filter_bit
            break
        max_bit = i
print(ans)


Measured memory_bytes: 102920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define mod 998244353LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 100000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pii a, pii b)//true for a before b
{
	if(a.S < b.S)
		return 1;
	if(a.S > b.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (3e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;



void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	if(abs(b-a) == 1)
	{
		cout << "Borys\n";
		return;
	}
	if((a&1) == (b&1))
	{
		cout << "Alice\n";
		return;
	}
	cout << "Borys\n";
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand(clock());

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(3);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case " << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int n;
//	private int m;
	
	Main() {
		readData();
		
		int h = n/3600;
		int r = n % 3600;
		int m = r / 60;
		int s = r % 60;
		
		
		System.out.println(h + ":" + m + ":" + s);
	}
	
	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			n = nextInt();
//			m = nextInt();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

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

int main()
{
	int n,b,f,r,v,a[5][4][11];
	
	cin >> n ;
	
	for(int h=0;h<4;h++)
	{
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<10;j++)
			{
				a[h][i][j]=0;
			}
		}
	}
	
	for(int g=0;g<n;++g){
		cin >> b >> f >> r >> v ;
		for(int h=0;h<4;++h){
			for(int i=0;i<3;++i){
				for(int j=0;j<10;++j){
					if(h==b-1 && i==f-1 && j==r-1){
						a[h][i][j]+=v;
					}
				}
			}
		}
	}
	
	for(int h=0;h<4;++h){
		for(int i=0;i<3;++i){
			for(int j=0;j<10;++j){
				cout << " " << a[h][i][j];
			}
			cout << "\n";
			
		}
		if(h <3){
				cout << "####################" << "\n";
			}

	}
	return 0;
}

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

// Returns count of numbers in [A B] that 
// are divisible by M. 
long long cd(long long A, long long B, long long M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
}
long long lcm(long long a,long long b)
{
  return a*b/__gcd(a,b);
}
int main()
{
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long n=b-a+1;
  long long ans=cd(a,b,c)+cd(a,b,d)-cd(a,b,lcm(c,d));
  cout<<n-ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); }
 
using namespace std;
using ll = long long;

//        N             N
// dp[N][何回変えたか][直前の値]
//        N+1          1..N
// dp[i+1][j][k'] <- dp[i][j][k] + max(0, H[i+1]-H[i])
// dp[i+1][j][k'] <- dp[i][j][k] + max(0, (k')-H[i])

void chmin(ll &x, ll y) {
  x = min(x, y);
}

int main() { init_io();
  int N, K; cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  vector<int> dict(H);
  dict.push_back(0);
  sort(range(dict));
  dict.erase(unique(range(dict)), dict.end());
  rep(i, N) H[i] = lower_bound(range(dict), H[i]) - dict.begin();
  static ll dp0[310][310];
  static ll dp1[310][310];
  constexpr ll inf = 1e18;
  rep(j, 301) rep(k, 301) dp0[j][k] = inf;
  rep(j, 301) rep(k, 301) dp1[j][k] = inf;
  dp0[0][0] = 0;
  rep(i, N) {
    rep(j, K+1) rep(k, dict.size()) {
      dp1[j][k] = inf;
    }
    rep(j, K+1) rep(k, dict.size()) {
      dp1[j+1][k] = dp0[j][k];
    }
    // use
    rep(j, K+1) rep(k, dict.size() - 1) {
      chmin(dp1[j][k+1], dp1[j][k] + dict[k+1] - dict[k]);
    }
    rep(j, K+1) reper(k, 1, dict.size()) {
      chmin(dp1[j][k-1], dp1[j][k]);
    }
    // doesn't use
    rep(j, K+1) rep(k, H[i]) {
      chmin(dp0[j][k+1], dp0[j][k] + dict[k+1] - dict[k]);
      dp0[j][k] = inf;
    }
    rep(j, K+1) reper(k, H[i]+1, dict.size()) {
      chmin(dp0[j][k-1], dp0[j][k]);
      dp0[j][k] = inf;
    }
    rep(j, K+1) rep(k, dict.size()) {
      chmin(dp0[j][k], dp1[j][k]);
    }
  }
  ll ans = inf;
  rep(j, K+1) rep(k, dict.size()) chmin(ans, dp0[j][k]);
  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
class hogehoge
{
	static void Main(string[] args)
	{
      string[] input = Console.ReadLine().Split();
      int N = int.Parse(input[0]);
      int T = int.Parse(input[1]);
      
      int[] c = new int[N];
      int[] t = new int[N];
      for(int i = 0; i < N; i++){
        input = Console.ReadLine().Split();
        c[i] = int.Parse(input[0]);
        t[i] = int.Parse(input[1]);
      }
      
      int index = -1;
      for(int i = 0; i < N; i++){
        if(t[i] > T)
          continue;
        if(index == -1) index = i;
        else if(c[i] < c[index]) index = i;
      }
      
      if(index == -1) Console.WriteLine("TLE");
      else Console.WriteLine(c[index]);
      
	}
}

Measured memory_bytes: 13140
X = list(map(int, input().split()))

ans1 = 0
# IJL
if X[0] > 0 and X[3] > 0 and X[4] > 0:
    i, j, l = X[0] - 1, X[3] - 1, X[4] - 1
    ans1 += 6
    ans1 += 4 * (i // 2) + 4 * (j // 2) + 4 * (l // 2)
    ans1 += 2 * X[1]

i, j, l = X[0], X[3], X[4]
ans2 = 4 * (i // 2) + 4 * (j // 2) + 4 * (l // 2) + 2 * X[1]

print(max(ans1, ans2) // 2)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
using ui = unsigned int;
using ul = unsigned long;
#pragma GCC optimize("Ofast")
#define loop(i, n) for (ui i = 0; i < n; i++)
struct BIT
{
private:
    vector<ul> bit;
    ui n;
    inline ul sum(ui x)
    {
        ul ret = 0;
        while (x > 0)
        {
            ret += bit[x];
            x -= x & -x;
        }
        return ret;
    }

public:
    BIT(ui n0, vector<ul> &A) : bit(n0 + 1, 0), n(n0)
    {
        for (ui i = 1; i <= n; i++)
            bit[i] = A[i - 1];
        for (ui i = 1; i < n; i++)
            bit[i + (i & -i)] += bit[i];
    }
    inline ul sum(ui l, ui r)
    {
        return sum(r + 1) - sum(l);
    }
    inline void add(ui i, ul x)
    {
        i++;
        while (i <= n)
        {
            bit[i] += x;
            i += i & -i;
        }
    }
};
#define scan(x) scanf("%ld", &x)
#define putout(a) printf("%ld\n", a)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ui N, Q;
    cin >> N >> Q;
    vector<ul> A(N);
    loop(i, N) cin >> A[i];
    BIT data(N, A);
    loop(i, Q)
    {
        ui a, b, c;
        cin >> a >> b >> c;
        if (a == 0)
            data.add(b, c);
        else
            cout << data.sum(b, c - 1) << "\n";
    }
    return 0;
}


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

#define ld          long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int inf = 1e18;
const int mod = 1e9+7;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 1e5+5;
int arr[N];

void solve()
{
    string s;
    cin >> s;
    int curr = 1;
    int rem = 0;
    mi mp;
    mp[0] = 1;
    int n = s.size();
    int ans = 0;
    
    for(int i=n-1; i>=0; i--){
        rem += curr*(s[i]-'0');
        rem %= 2019;
        curr *= 10;
        curr %= 2019;
        ans += mp[rem];
        mp[rem]++;
    }

    cout << ans << endl;
}                                   

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3912
#include <stdio.h>

int main() {
	int A, B, maior;
	
	scanf("%d %d",&A,&B);
	if((A<-1000 || B <-1000) || (A>1000 || B >1000)){
	do{
	scanf("%d %d",&A,&B);
	
	}while((A<-1000 || B <-1000) || (A>1000 || B >1000));
	}else if((A+B) > (A-B) && (A+B) > (A*B)){
		maior=(A+B);
		}
		else if((A-B) > (A+B) && (A-B) > (A*B)){
			maior=(A-B);
		}
		else if((A*B) > (A+B) && (A*B) > (A-B)){
			maior=(A*B);
		}
		else if((A+B) == (A-B) && (A+B) == (A*B)){
			maior=(A+B);
		}
	
	printf("%d",maior);
	return 0;
}


Measured memory_bytes: 128
N = int(input())

n = 100
a = 0

while N > n:
    a += n//100
    n *= 10

n //= 10

x = [[a]*9 for _ in range(9)]

b = N // n
for i in range(b-1):
    for j in range(9):
        x[i][j] += n//10

for i in range(N%n+1):
    c = i % 10
    if c != 0:
        x[b-1][c-1] += 1

for i in range(min(9, N)):
    x[i][i] += 1

cnt = 0

for i in range(9):
    for j in range(9):
        cnt += x[i][j] * x[j][i]

print(cnt)

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

int main(){
  string s; cin >> s;
  rep(i,3){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<long long> pos, zero, neg;
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (x > 0) pos.push_back(x);
		else if (x < 0) neg.push_back(x);
		else zero.push_back(x);
		ans += (x > 0 ? x : -x);
	}
	if (zero.size() >= 1 || neg.size() % 2 == 0) {
		cout << ans << endl;
	}
	else {
		long long mn = 1LL << 60;
		if (!pos.empty()) mn = min(mn, *min_element(pos.begin(), pos.end()));
		if (!neg.empty()) mn = min(mn, -*max_element(neg.begin(), neg.end()));
		cout << ans - mn * 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin>>k;
	cout<<a[k - 1]<<endl;
}


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

int main(){
  int a, b, c, k;
  std::cin >> a >> b >> c >> k;
  int count = 0;
  if(k > a){
    k = k - a;
    count += a;
    if(k > b){
      k = k - b;
      count -= k;
    }
  }
  else{
    count = k;
  }
  

  std::cout << count << '\n';
  
  return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

string b(int a[]) {
	int cnt[14+4] = {};
	for (int i = 0; i < 5; i++)
		cnt[a[i]]++;

	string r = "null";
	int c[6] = {};
	for (int i = 1; i <= 13; i++) {
		c[cnt[i]]++;
		if (cnt[i] && cnt[i + 1] && cnt[i + 2] && cnt[i + 3] && cnt[i + 4])
			r = "straight";
	}
	if (cnt[10] && cnt[11] && cnt[12] && cnt[13] && cnt[1])
		r = "straight";

	if (c[4])r = "four card";
	else if (c[3] && c[2])r = "full house";
	else if (c[3])r = "three card";
	else if (c[2] == 2)r = "two pair";
	else if (c[2])r = "one pair";

	return r;
}

int main() {
	int a[5];
	char c;
	while (cin >> a[0] >> c >> a[1] >> c >> a[2] >> c >> a[3] >> c >> a[4])
		cout << b(a) << endl;

	return 0;
}

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

int main() {
    ll t,n,k,a1=0,a2=0,a3=0,a4=0,a5=0;
    cin>>n;
    ll a[n];
    for(int i=1;i<=n;i++){
        cin>>t;
        if(t&1 && i&1)
            a1++;
    }
    cout<<a1<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define mod 1e9 + 7
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
void FIO(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("inputPrayag.txt", "r", stdin);
    freopen("outputPrayag.txt", "w", stdout);
    #endif
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

int main(){
// FIO();
   int n,m;
   cin>>n>>m;
   vi adj[n+1];
   lpi(0,m){
   	int u,v;
   	cin>>u>>v;
   	adj[u].pb(v);
   	adj[v].pb(u);
   }
   int dp[n+1];
   memset(dp,-1, sizeof(dp));
   queue<int> q;
   q.push(1);
   dp[1] = 0;
   //int dis=0;
  while(!q.empty()){
  	int p = q.front();
  	q.pop();
  	for(auto i:adj[p]){
  	    if(dp[i]==-1)
  		q.push(i);
  		if(dp[i]==-1){
  			dp[i]=p;
  		}
  	}
  }
   lpi(1,n+1){
   	if(dp[i]==-1){
   		cout<<"No\n";
   		return 0;
   	}
   }
   cout<<"Yes\n";
   lpi(2,n+1){
   	cout<<dp[i]<<endl;
   }
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  string a,b,c,ans="";
  cin>>a>>b>>c;
  
  char d;
  d = a[0]+'A'-'a';
  ans += d;
  d = b[0]+'A'-'a';
  ans += d;
  d = c[0]+'A'-'a';
  ans += d;
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, A[3][101], i, j, k, sum, max=0;

    cin >> N;

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

    for(k=1; k<=N; k++){
        sum = 0;

        for(j=1; j<=N; j++){
            if(j < k){
                sum += A[1][j];
            }
            else if(j == k){
                sum += A[1][j];
                sum += A[2][j];
            }
            else{
                sum += A[2][j];
            }
        }

        if(sum > max){
            max = sum;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
{
  const run = (input: string) => {
    const [x, y] = input.trim().split(" ").map(v => parseInt(v))

    let min = x * 2
    if (y < min) {
      return 'No'
    }
    const rest = y - min;
    return rest % 2 === 0 && rest / 2 <= x ? 'Yes' : 'No'
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


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


int main ()
{

  string s1,s2;
  
  cin >> s1 >> s2;
  
  int count=0;
  
  if(s1[0]==s2[0])
  {
		count++;
  }
  if(s1[1]==s2[1])
  {
	  count++;
  }
  if(s1[2]==s2[2])
  {
	  count++;
  }
  
  cout << count << endl;

	return 0;
}











Measured memory_bytes: 3176
s = gets.chomp.split('')
if s[0] == 'A' && s[2..(s.length-2)].count('C') == 1
    s.shift
    s.delete_at(s.index('C'))
    if s.all?{|c|c == c.downcase}
        puts 'AC'
        exit
    end
end
puts 'WA'


Measured memory_bytes: 1788