akhauriyash/Code-Regression huggingface dataset:
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n,t,a;
vector<int> h;
void input(){
    cin>>n>>t>>a;
    scan_vector(n,h);
}
void src(){
    auto v= mapf(h,(function<double(int)>)[](auto x){return fabs(((double)t-x*0.006)-a);});
    cout<<distance(v.begin(),min_element(v.begin(),v.end()))+1;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		long N = io.nextLong();
		long A = io.nextLong();
		long B = io.nextLong();
		long ans = (B*(N-1)+A)-(A*(N-1)+B)+1;
		if(N==1) ans =(A==B)? 1:0 ;
		if(A>B) ans = 0;
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
/*
h s, d't skp th si tll i's sved
 * ABC141 E
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int sq(int n)
{
return n*n;
}
int main()
{
std::cout << std::setprecision(7);
int n;
cin>>n;
vector<pair<int,int> > vc;
int x,y;
for(int i=0;i<n;i++)
{
cin>>x>>y;
vc.push_back({x,y});
}
vector<int> arr;
int fac=1;
for(int i=1;i<=n;i++)
{
arr.push_back(i);
fac*=i;
}
double ans=0;
do
{
for(int i=1;i<n;i++)
{
ans+=(double)sqrt(sq(vc[arr[i]-1].first-vc[arr[i-1]-1].first)+sq(vc[arr[i]-1].second-vc[arr[i-1]-1].second));
}
}while(next_permutation(arr.begin(),arr.end()));
ans=(double)ans/fac;
cout<<ans;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b;
    cin >> a >> b;
    if (a == 0 or b == 0) {
        cout << "Zero" << endl;
    } else if (a < 0 and b > 0) {
        cout << "Zero" << endl;
    } else if (a > 0) {
        cout << "Positive" << endl;
    } else if (a == b) {
        cout << "Positive" << endl;
    } else {
        if (abs(a - b) % 2 == 1) {
            cout << "Positive" << endl;
        } else {
            cout << "Negative" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l,r,d;
    cin >> l >> r >> d;
    int ans = r/d - l/d + (l%d == 0);
    cout << ans << "\n";
    return 0;
}
 

Measured memory_bytes: 3644
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
vector<int> adj[100001];
int v[100001];
int d[100001];
int c[100001];
bool dp[100001][11];
int color[100001];
void dfs(int v,int d,int c){
    
    if(color[v]==0) color[v]=c;
    dp[v][d]=true;
    
    for(int i=0;i<adj[v].size();i++){
        int next = adj[v][i];
        if(d>0 && !dp[next][d-1]){
            dfs(next,d-1,c);
        }
    }
}
int main(int argc, const char * argv[]) {
 
    
    int n,m;
    
    scanf("%d %d",&n,&m);
    
    
    for(int i=0,x,y;i<m;i++){
        scanf("%d %d",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    
    int q;
    scanf("%d",&q);
    
    for(int i=0;i<q;i++){
        scanf("%d %d %d",&v[i],&d[i],&c[i]);
    }
    
    for(int i=q-1;i>=0;i--){
        dfs(v[i],d[i],c[i]);
    }
 
    for(int i=1;i<=n;i++){
        printf("%d\n",color[i]);
    }
    
    return 0;
}

Measured memory_bytes: 9080
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/abc164_c

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        HashSet<String> set = new HashSet<>();
        for(int i=0; i<n; i++) {
            set.add(in.next().trim());
        }
        out.println(set.size());
    }
    

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        out.close();
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
    }
}

Measured memory_bytes: 63064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, s = 0;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n) {
    s += a[i];
    if(i % 2) {
      if(s <= 0) {
        ans += abs(s) + 1;
        s = 1;
      }
    } else {
      if(s >= 0) {
        ans += abs(s) + 1;
        s = -1;
      }
    }
  }
  ll now = 0;
  s = 0;
  rep(i, n) {
    s += a[i];
    if(i % 2 == 0) {
      if(s <= 0) {
        now += abs(s) + 1;
        s = 1;
      }
    } else {
      if(s >= 0) {
        now += abs(s) + 1;
        s = -1;
      }
    }
  }
  ans = min(ans, now);
  cout << ans << endl;
}

Measured memory_bytes: 3968
from _collections import deque
n,m=map(int,input().split())
ab=[[0,0] for i in range(m)]
for i in range(m):
    ab[i][0],ab[i][1]=map(int,input().split())
ans=0
for i in range(m):
    edg=[[] for j in range(n+1)]
    dep=[-1]*(n+1)
    dep[0]=1
    dep[1]=1
    for j in range(m):
        if j!=i:
            a,b=ab[j][0],ab[j][1]
            edg[a].append(b)
            edg[b].append(a)
    data=deque([1])
    while len(data)>0:
        p=data.popleft()
        for j in edg[p]:
            if dep[j]==-1:
                dep[j]=1
                data.append(j)
    if not all(dep[i]==1 for i in range(n+1)):ans+=1
print(ans)


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

const int N = (2e5) + 5;
pair<ll, ll> x[N];
ll ft[N];
ll n, d, a;

void update(int idx, ll delta) {
	while (idx <= n) {
		ft[idx] += delta;
		idx += idx & -idx;
	}
}

void rangeUpdate(int l, int r, ll delta) {
	update(l, delta); update(r + 1, -delta);
}

ll query(int idx) {
	ll ret = 0;
	while (idx > 0) {
		ret += ft[idx];
		idx -= idx & -idx;
	}
	return ret;
}

void build(pair<ll, ll> arr[], int n) {
	for (int i = 0; i < n; ++i) {
		rangeUpdate(i + 1, i + 1, arr[i].second);
	}
}

ll ceilDiv(ll a, ll b) {
  return (a + b - 1) / b;
}
 
int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin >> n >> d >> a;
  for (int i = 0; i < n; ++i) {
    cin >> x[i].first >> x[i].second;
  }
  sort(x, x + n);
  build(x, n);
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll mx = query(i);
    if (mx > 0) {
      ll div = ceilDiv(mx, a);
      ans += div;
      ll r = upper_bound(x, x + n, make_pair(x[i - 1].first + 2 * d, LLONG_MAX)) - x;
      if (r - 1 >= 0) {
        rangeUpdate(i, r, -div * a);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

X = int(input())

ans = X
prime = False
while True:
    prime = is_prime(ans)
    if prime:
        break
    ans += 1

print(ans)


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

using namespace std;

#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define sz(c) int((c).size())

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
   int n, X; cin >> n >> X;
   int x, ans = 0;
   for(int i = 0; i < n; i++) {
   		cin >> x; ans = __gcd(ans, x-X);
   }
   cout << abs(ans);
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
a= [list(map(int, input().split())) for i in range(n)]

a.sort(key = lambda x: x[1])

sum = 0

for i in range(n):
    if i == 0:
        a[i][0] += 0
    else:
        a[i][0] += a[i-1][0]
    sum += a[i][0]

for i in range(n):
    if a[i][0] > a[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 88280
import math
a,b,h,m=map(int, input().split())

if m == 0:
    k1 = 360
    k2 = h * 30
else:
    k1 = m/5 * 30
    k2 = h * 30 + 30 * k1 / 360

if k1 > k2:
    kaku = k1 - k2
else:
    kaku = k2 - k1

c = (a*a) + (b*b) -(2*a*b*math.cos(math.radians(kaku)))
print(math.sqrt(c))

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[100005][4];
int main() {
    init();
    string S;
    cin >> S;
    ll sn = S.size();

    dp[0][0] = 1;
    auto getid = [](char a) { return ('A' <= a and a <= 'C' ? a - 'A' : 3); };
    rep(i, sn) {
        ll id = getid(S[i]);
        rep(j, 4) dp[i + 1][j] = dp[i][j] * (id==3 ? 3 : 1) % MOD;
        
        if(id<3){
            (dp[i + 1][id + 1] += dp[i][id]) %= MOD;
        }
        else{
            rep(j, 3)(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
        }
    }
    cout << dp[sn][3] << endl;
}

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

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

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

int main() {
	
	vector<char> S(4);
	
	for(int i=0; i<4; i++){
		
		cin >>S.at(i);
		
	}
	
	sort(S.begin(),S.end());
	if(S.at(1)==S.at(0)&&S.at(3)==S.at(2)&&S.at(1)!=S.at(2)){
		
		cout <<"Yes" <<endl;
		
	}
	else{
		
		cout <<"No" <<endl;
		
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,m,ans;
main(){
    cin>>n>>m;
    if(m-2*n>=0)ans+=n,m-=n*2,ans+=m/4;
    else if(m%2)ans+=(m-1)/2;
  	else if(m%2==0)ans+=m/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

const int M = 1000005;

int main(void) {

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi cnt(M);
    for (int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x) cnt[i]++;
    }
    int ans = 0;
    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	int time = 1e9;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i + k - 1 < n;i++) {
		time = min(time, abs(a[i]) + abs(a[i + k - 1] - a[i]));
		time = min(time, abs(a[i + k - 1]) + abs(a[i] - a[i + k - 1]));
	}
	cout << time << endl;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = readInt();

        long acc = 0L;

        HashMap<Long, Long> mp = new HashMap<>();
        mp.put((long)0, (long)1);

        for(int i=0; i<N; i++){
            long num = readLong();
            acc +=  num;

            if(mp.containsKey(acc)){
                long tmp = mp.get(acc);
                tmp += 1;
                mp.put(acc, tmp);
            }else{
                mp.put(acc, (long)1);
            }
        }

        long cnt = 0;

        for(long key: mp.keySet()){
            long tmpCnt = mp.get(key);
            cnt += Comb(tmpCnt);
        }

        System.out.println(cnt);
    }

    private static long Comb(long tmpCnt) {
        if(tmpCnt == 1){
            return 0;
        }else{
            return tmpCnt * (tmpCnt - 1) / 2;
        }
    }

    private static int readInt(){
        return Integer.parseInt(sc.next());
    }

    private static long readLong(){
        return Long.parseLong(sc.next());
    }

}

Measured memory_bytes: 70540
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()

print('IMPOSSIBLE')

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

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] input = Input.ScanStrArray();
          
          Console.WriteLine($"A{input[1][0]}C");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

#define MAX 250

int parent(int);
int left(int);
int right(int);

int main(){
  int i, n;
  //int left, right, parent;
  int key[MAX];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&key[i]);
  }

  for(i=1;i<=n;i++){

    printf("node %d: key = %d, ", i, key[i]);

    if(parent(i) >= 1) printf("parent key = %d, ", key[parent(i)]);
    if(left(i) <= n) printf("left key = %d, ", key[left(i)]);
    if(right(i) <= n) printf("right key = %d, ", key[right(i)]);

    printf("\n");
  }
  return 0;
}

int parent(int i){
  return (i/2);
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

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

string s;

int dp[2][2020];

int main()
{

   cin >> s;

   int ans = 0;

   int flag = 0;

   for(int i = 0; i < s.size(); ++i)
   {
       for(int j = 0; j < 2019; ++j)
           dp[flag][(j * 10 + s[i] - '0') % 2019] = dp[flag^1][j];
        dp[flag][s[i] - '0'] ++;

       ans += dp[flag][0];
       flag ^= 1;
   }

   cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3772
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <limits>
#include <math.h>
#include <iomanip>
//#define int long long
#define int double
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a, b, c;
	//int m;
	int h, w, x;
	int k;
	int d,t,s;
	//int t;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	//string s;
	//string s[100000];
	//string c[7];
	//int a[100000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	//int box[20000] = { 0 };
	//char box[20000];
	//int a[2000000] = { 0 };
	//int box = 0;
	//int box[7][7] = { 0 };
	//int box2;
	//int p[1111];
	//int x[2000], y[2000];
	//int l[100];


	//long double aaa;

	int count = 0;
	//int k, d;
	//int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	bool flag = true;
	//bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b >> c;
	//cin >> s;
	cin >> d >> t >> s;
	//cin >> n >> x >> t;

	/*for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}*/


	count = d / s;

	if (count <= t)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	//getline(cin, s);

	/*for (int i = 0; i < count; i++)
	{
		all += s[i] - '0';
	}*/

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	//cout << x << "\n";
	//cout << all << "\n";
	//cout << box << "\n";
	//cout << a << b << c << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
	//return 0;
}


Measured memory_bytes: 3720
import sys

n = int(input())

four = 0
odd = 0
two = 0

l = [int(x) for x in sys.stdin.readline().split()]

for x in l:
	if x % 4 == 0:
		four += 1
	elif x % 2 == 1:
		odd += 1
	else:
		two += 1

if four > 0:
	if four >= odd:
		print('Yes')
	elif odd - four == 1:
		if two == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
else:
	if odd > 0:
		print('No')
	else:
		if two >= 2:
			print('Yes')
		else:
			print('No')

Measured memory_bytes: 14172
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            if (S.Length <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                var buf = S.Substring(0, K);
                Console.WriteLine(buf + "...");
            }
        }
    }
}

Measured memory_bytes: 27552
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(C >=A and C<=B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
	vector<int> a(1000000,1);
	a[0]=0;
	a[1]=0;
	for(int i=0;i<a.size();i++){
		if(a[i]==1){
			for(int j=2*i;j<a.size();j+=i){
				a[j]=0;
			}
		}
	}
	
	//for(int i=0;i<a.size();i++)if(a[i]==1)cout<<i<<" ";
	while(1){
		int az,d,n;
		cin>>az>>d>>n;
		if(az==0&&d==0&&n==0)break;
		int i=0;
		while(1){
			if(a[az]==1)i++;
			if(i==n)break;
			az+=d;
		}
		cout<<az<<endl;
	}
	return 0;
}

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

namespace flow{
	const int _ = 1e6 + 7 , __ = 1e7 + 7;
	struct Edge{int end , upEd , f;}Ed[__];
	int head[_] , dep[_] , cur[_] , cntEd = 1 , S , T;

	void addEd(int a , int b , int c){Ed[++cntEd] = (Edge){b , head[a] , c}; head[a] = cntEd;}
	void addE(int a , int b , int c){addEd(a , b , c); addEd(b , a , 0);}
	
	queue < int > q;
	bool bfs(){
		memset(dep , 0 , sizeof(int) * (T + 1)); dep[S] = 1;
		while(!q.empty()) q.pop(); q.push(S);
		while(!q.empty()){
			int t = q.front(); q.pop();
			for(int i = head[t] ; i ; i = Ed[i].upEd)
				if(Ed[i].f && !dep[Ed[i].end]){
					dep[Ed[i].end] = dep[t] + 1;
					if(Ed[i].end == T){memcpy(cur , head , sizeof(int) * (T + 1)); return 1;}
					q.push(Ed[i].end);
				}
		}
		return 0;
	}

	int dfs(int x , int mn){
		if(x == T) return mn;
		int sum = 0;
		for(int &i = cur[x] ; i ; i = Ed[i].upEd)
			if(Ed[i].f && dep[Ed[i].end] == dep[x] + 1){
				int t = dfs(Ed[i].end , min(Ed[i].f , mn - sum));
				sum += t; Ed[i].f -= t; Ed[i ^ 1].f += t;
				if(mn == sum) break;
			}
		return sum;
	}

	int Dinic(int s , int t){S = s; T = t; int sum = 0; while(bfs()) sum += dfs(s , 1e9); return sum;}
}using flow::addE;
const int _ = 1e5 + 7;
int N , P[_] , Q[_] , belp[_] , belq[_];

int work(int *now , int *bel){
	int cnt = 0;
	for(int i = 1 ; i <= N ; ++i)
		if(!bel[i]){++cnt; int tmp = i; do{bel[i] = cnt; i = now[i];}while(i != tmp);}
	return cnt;
}

int main(){
	ios::sync_with_stdio(0); cin >> N;
	for(int i = 1 ; i <= N ; ++i){cin >> P[i]; ++P[i];}
	for(int i = 1 ; i <= N ; ++i){cin >> Q[i]; ++Q[i];}
	int szp = work(P , belp) , szq = work(Q , belq) , T = szp + szq + 1 , ans = 0;
	for(int i = 1 ; i <= N ; ++i)
		if(P[i] == i && Q[i] == i) ++ans;
		else if(P[i] == i) addE(szp + belq[i] , T , 1);
		else if(Q[i] == i) addE(0 , belp[i] , 1);
		else{
			addE(belq[i] + szp , belp[i] , 1);
			if(P[i] == Q[i]) addE(belp[i] , belq[i] + szp , 1);
		}
	cout << N - (ans + flow::Dinic(0 , T)); return 0;
}


Measured memory_bytes: 14464
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n%=100;
        n%=10;
        
        if(n==3)  System.out.println("bon");
        else if(n==0 || n==1 ||n==6 ||n==8) System.out.println("pon");
        else System.out.println("hon");
    }
}

Measured memory_bytes: 35584
#include<iostream>
using namespace std;
int main()
{
   int N;
   cin >> N;
   string S;
   cin >> S;
   int count = 1;
   for (int i=0; i<N-1; i++){
       if (S.at(i)!=S.at(i+1)){
           count += 1;
       }
   }
   cout << count;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int Q;
    cin >> Q;
    
    vector<bool> IsPrime(100001, true);
    IsPrime[0] = IsPrime[1] = false;
    for (int n = 2; n <= 100000; ++n) {
        if (!IsPrime[n]) continue;
        for (int m = 2; n*m <= 100000; ++m) {
            IsPrime[n*m] = false;
        }
    }
    
    vector<bool> IsLike(100001, false);
    for (int n = 2; n <= 100000; ++n) {
        if (IsPrime[n] && IsPrime[(n+1)/2]) IsLike[n] = true;
    }
    vector<int> Cul(100001, 0);
    for (int n = 1; n <= 100000; ++n) {
        Cul[n] = Cul[n-1] + (IsLike[n] ? 1 : 0);
    }
    
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        cout << Cul[r] - Cul[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)

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

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() {
    string s;
    cin >> s;
    deque<char> deq;
    for (char c : s) deq.push_back(c);
    bool flip = false;
    int q;
    cin >> q;
    string t;
    rep(qi,q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            flip = !flip;
        } else {
            int f; char c;
            cin >> f >> c;
            if (flip) f = 3 - f;
            if (f == 1) {
                deq.push_front(c);
            } else {
                deq.push_back(c);
            }
        }
    }
    if (flip) reverse(deq.begin(), deq.end());
    string ans;
    for (char c : deq) ans += c;
    cout << ans << endl;
    return 0;
}

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

int dfs(int n, int s, int k){
	if( n == 0 ){
		return ( s == 0 )? 1 : 0;
	}
	int res = 0;
	for(int i = k; i < 10; i++){
		res += dfs(n - 1, s - i, i + 1);
	}
	return res;
}

int main(){
	int n, s;
	while( cin >> n >> s, n || s ){
		cout << dfs(n, s, 0) << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

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

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;
    ll p[n];
    rep(i, n) { cin >> p[i]; }

    ll a[n];
    rep(i, n) { a[i] = i * n + 1; }
    ll b[n];
    rep(i, n) { b[i] = n * (n - i + 1); }
    rep(i, n) { b[p[i] - 1] += i + 1; }

    rep(i, n) { cout << a[i] << " "; }
    cout << endl;
    rep(i, n) { cout << b[i] << " "; }
    cout << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 1152
#include <iostream>
 
using namespace std;
 
int main(){
	int a,b,c,i,z=0;
	cin>>a>>b>>c;
	i=a;
	while (i>=a && i<=b){
		if (c%i==0){
			z=z+1;
		}
		i++;
	}
	
	cout<<z<<endl;

    return 0;
}



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

int main() {
	int a,b,k;
	cin>>a>>b>>k;
	if(b-a<k*2){
		for(int i=a;i<b+1;i++)cout<<i<<endl;
		return 0;
	}else{
		for(int i=a;i<a+k;i++)cout<<i<<endl;
		for(int i=b-k+1;i<b+1;i++)cout<<i<<endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;


bool ok(int x, vector<int> &a){
	while(x){
		if(a[x%10] == 0) return false;
		x/=10;
	}
	return true;
}

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

	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> a(10, 1);
	while(k--){
		int d;
		cin >> d;
		a[d] = 0;
	}
	int x = n;
	while(2>1){
		if(ok(x, a)) {
			cout << x << '\n';
			return 0;
		}
		x++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,t=0;cin>>n;
    vector<int> v(n);
    for(auto &i:v) cin>>i;
    vector<int> l(n);
    vector<int> r(n);
    l[0]=v[0];r[n-1]=v[n-1];
    for(int i=1;i<=n-1;i++) l[i]=__gcd(l[i-1],v[i]);
    for(int i=n-2;i>=0;i--) r[i]=__gcd(r[i+1],v[i]);
    for(int i=0;i<=n-3;i++) t=max(t,__gcd(l[i],r[i+2]));
    t=max(t,l[n-2]);
    t=max(t,r[1]);
    cout<<t;
}

Measured memory_bytes: 1408
N = int(input())
AB = []
for n in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])
AB.sort(key=lambda x:x[1])
t = 0
c = 0
for i in AB:
    t += i[0]
    if t>i[1]:
        break
    c += 1
if c<len(AB):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 38028
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t mod = 1'000'000'007;
template <uint32_t mod>
class modint{
    uint64_t value;
public:
    constexpr modint(const int64_t x=0) noexcept: value(x % mod + (x < 0 ? mod : 0)){ }
    constexpr explicit operator uint64_t() const noexcept{ return value; }
    constexpr modint inverse() const noexcept{ return pow(*this, mod-2); }
    constexpr bool operator==(const modint &rhs) const noexcept{ return value == rhs.value; }
    constexpr bool operator!=(const modint &rhs) const noexcept{ return value != rhs.value; }
    constexpr modint operator+() const noexcept{ return modint(*this); }
    constexpr modint operator-() const noexcept{ return modint(mod - value); }
    constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) noexcept{
        if((value += rhs.value) >= mod) value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{ return *this += mod - rhs.value; }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        if((value *= rhs.value) >= mod) value %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{ return *this *= rhs.inverse(); }
    constexpr modint operator++(int) noexcept{
        modint ret(*this);
        if((++value) >= mod) value -= mod;
        return ret;
    }
    constexpr modint operator--(int) noexcept{
        modint ret(*this);
        if((value += mod - 1) >= mod) value -= mod;
        return ret;
    }
    constexpr modint &operator++() noexcept{ return *this += 1; }
    constexpr modint &operator--() noexcept{ return *this -= 1; }
    friend std::ostream &operator<<(std::ostream &os, const modint<mod> &x){ return os << x.value; }
    friend std::istream &operator>>(std::istream &is, modint<mod> &x){
        int64_t i;
        is >> i;
        x = modint<mod>(i);
        return is;
    }
    friend constexpr modint<mod> pow(const modint<mod> &x, uint64_t y){
        modint<mod> ret{1}, m{x};
        while(y > 0){
            if(y & 1) ret *= m;
            m *= m;
            y >>= 1;
        }
        return ret;
    }
};

int main(){
    int n;
    modint<mod> x[100000];
    cin >> n;
    for(int i=0;i<n;++i) cin >> x[i];
    modint<mod> ans = 0;
    for(int i=0;i+1<n;++i){
        ans += (x[n-1] - x[i]) / (i+1);
    }
    for(int i=1;i<n;++i) ans *= i;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(x) for x in input().split()]

l = 0
r = sum(a)

d = 2 * 10 ** 9 + 1

for i in range(n - 1):
    l += a[i]
    r -= a[i]
    d = min(d, abs(l - r))

print(d)


Measured memory_bytes: 24940
//
//  main.cpp
//  20190725lesson
//
//  Created by Priscilla Leang on 7/25/19.
//  Copyright © 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int a, b, x, w;
    int m, n, p, q;
    cin >> w >> a >> b;
    x = w+a;
    
    m = a-b;
    n = x-b;
    p =a-(b+w);
    q = x-(b+w);
    if (m< 0){
        m = -1*m;
    }
    if (n < 0){
        n =-1*n;
    }
    if (p< 0){
        p = -1*p;
    }
    if (q < 0){
        q =-1*q;
    }
    
    
    if (p <m){
        m = p;
    }
    if (q< m){
        m = q;
    }
    
    //see if its in between
    if (((a<=b)&&(b<=x)) || ((a<=b+w)&&(b+w<=x))){
        cout<<"0";
    }
    else {
        if (m<= n){
            cout << m;
            
        }
        else{
            cout << n;
        }
    }
    
    cout<< endl;
    return 0;
}


Measured memory_bytes: 256
//2 | (B - A) →後手のターンで隣接
//              →先手は端へ
//              →後手勝ち
 
import java.util.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if( (B - A) % 2 == 0 ){
			System.out.println("Alice");
		}else{
			System.out.println("Borys");
		}
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; int A[N];
    int sum=0;
    int ans=0,ans2=0;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        sum+=A[i];
        if(i%2==0){
            if(sum<1){
                ans+=1-sum;
                sum=1;
            }
        }
        else {
            if(sum>-1){
                ans+=sum+1;
                sum=-1;
            }
        } 
    }
    sum=0;
    rep(i,N){
        sum+=A[i];
        if(i%2==1){
            if(sum<1){
                ans2+=1-sum;
                sum=1;
            }
        }
        else {
            if(sum>-1){
                ans2+=sum+1;
                sum=-1;
            }
        }
    }
    cout << min(ans,ans2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
	int i;
	int n;
	int c;
	scanf("%d", &n);
	for (i = 0; i < 25; i++) {
		c = n - 4 * i;
		if (c % 7 == 0 && c > 0) {
			printf("Yes\n");
			break;
		}
		else {
			c = n - 7 * i;
			if (c % 4 == 0 && c > 0) {
				printf("Yes\n");
				break;
			}
		}
	}
	if (c < 0) {
		printf("No\n");
	}
	return 0;
}

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

int main(){
	int n,sum,max=0;

	cin >>n;
	int array[2][n];

	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++)cin >>array[i][j];
	}
	for(int i=0;i<n;i++){
		sum=0;
		for(int j=0;j<n;j++){
			if(i+1==n&&j+1==n){
				sum+=array[0][j];
				sum+=array[1][j];
			}
			else if(i>=j)sum+=array[0][j];
			else if(i+1==j){
				sum+=array[1][j-1];
				sum+=array[1][j];
			}
			else sum+=array[1][j];
		}
		if(sum>max)max=sum;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int k,s;
	cin>>k>>s;
	ll ans=0;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int z=s-i-j;
			if(z<0 || z>k){}
			else ans++;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
s = input()
s1 = int(s[0:2])
s2 = int(s[2:])

isYM , isMY= False, False
if s1 >= 0 and s1 <= 99 and s2 >= 1 and s2 <= 12: isYM = True
if s1 >= 1 and s1 <= 12 and s2 >= 0 and s2 <= 99: isMY = True

if isYM and isMY:
    print("AMBIGUOUS")
elif isYM:
    print("YYMM")
elif isMY:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int A,N,n;
  char str[100];
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  fgets(str,sizeof(str),stdin);
  A=atoi(str);
  
  n=N%500;
    
   if(n<=A){
     
     printf("Yes\n");
     return 0;
   }
  printf("No\n");
  
 return 0; 
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


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

	scanf("%d%d%d", &n, &a, &b);

	int x = min(a, b);
	int y = max(0, (a + b) - n);

	printf("%d %d\n", x, y);

	return 0;
}

/* waffle */


Measured memory_bytes: 128
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    ll cmb(ll n,int a,int mod){
        ll res = 1;
        rep(i,a){
            res *= (n-i);
            res /= (i+1);
            res %= mod;
        }
        return res;
    }

    ll mod_pow(ll x,ll n,ll mod){
        ll res = 1;
        while(n>0){
            if(n&1)res = res*x%mod;
            x = x*x%mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
      int r,g,b;cin>>r>>g>>b;
      int res = 100*r+10*g+b;
      cout<<(res%4==0 ? "YES":"NO");
    }
    


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

const int N = (int) 1e5 + 5;

char s[N], t[N];
int q;
int sus[N], sut[N];

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> s + 1;
	cin >> t + 1;
	int ls = strlen(s + 1), lt = strlen(t + 1);
	for (int i = 1; i <= ls; i++) sus[i] = sus[i - 1] + s[i] - 'A' + 1;
	for (int i = 1; i <= lt; i++) sut[i] = sut[i - 1] + t[i] - 'A' + 1;
	cin >> q;
	while (q--) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		if (abs(sus[b] - sus[a - 1] - (sut[d] - sut[c - 1])) % 3 == 0) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 1664
/********************
*             __    *
*   OHM   |__|__    *
*          __|  |   *
*                   *
*********************/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
double dp[3000][3000];
long double solve( int  n, long double h[])
{
    dp[0][0] = (long double)1; //0 head with 0 coin
    for (int i = 1; i <=n ; i++)// i represents no of coin
    {
        for (int j = 0; j <=n ; j++)//j represtent no of head
        {
            if(j == 0)
                dp[i][j] = (1.0 - h[i]) * (dp[i-1][j]);//all tails
            
            else
            {
                        //i th is head        //i th is tail 
                dp[i][j] = (h[i]*dp[i-1][j-1]) + ((1.0-h[i])*dp[i-1][j]);
            }
            
        }
        
    }
    int reqd_h = n/2+1; long double res = 0.0;
    for (int i = reqd_h; i <= n; i++)
    {
        res+=dp[n][i];
    }
    return res;
}



int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;  cin>>n;
    memset(dp, 0, sizeof(dp));
    long double h[n+1]; //probability of head
    for (int i = 1; i <= n; i++)
    {
        cin>>h[i];
    }
    cout<< fixed << setprecision(10)<< solve(n, h);
    return 0;
}


Measured memory_bytes: 74152
using System;
using System.Linq;
using System.Linq.Expressions;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();

        int n = s.Length;
        int last = s[0] - 'a' + 1;
        int k = 1;
        int tmp = 0;
        for (int i = 1; i < n; i++)
        {
            tmp *= 27;
            tmp += s[i] - 'a' + 1;
            if (last != tmp)
            {
                k++;
                last = tmp;
                tmp = 0;
            }
        }
        Console.WriteLine(k);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 14432
A, B = list(map(int, input().split()))
S = list(input())

length = A + B + 1
index_of_hyphen = A
ans = 'No'

if len(S) == length and S.pop(index_of_hyphen) == '-':
    ans = 'Yes'
    for s in S:
        if s == '-':
            ans = 'No'
            break

print(ans)

Measured memory_bytes: 3060
[N,M,X,Y] = [int(x) for x in input().split()]
xs  = [int(x) for x in input().split()] + [X]
ys  = [int(x) for x in input().split()] + [Y]

nowar = max(xs) <  min(ys)

if nowar:
    print("No War")
else:
    print("War")



Measured memory_bytes: 2940