akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b, c):
    if a + b + c <= 21: return 'win'
    else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    a, b, c = list(map(int, input().split()))
    # S = input().split()
    # S = input()
    # T = input()
    print(sol(a, b, c))
    # S = input().strip()
    # print(sol(S))


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const int N = 3006;
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int cur = 0;

    for(int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        if(x != y) {
            cur = 0;
        } else {
            cur++;
        }
        if(cur == 3) {
            cout << "Yes\n";
            return 0;
        }
    }
    
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  string a,b,c;
  cin >> a>>b>>c;
  a[0] -= 32;
  b[0] -= 32;
  c[0] -= 32;
  cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int h, w, k, ans = 2000;
char s[12][1005];
int main(){
	scanf("%d%d%d", &h, &w, &k);
	rep(i,h) scanf("%s", s[i]);
	rep(bt, 1<<(h-1)){
		int n = __builtin_popcount(bt)+1, dp[12] = {}, cnt = n-1;
		bool ok = true;
		rep(i,w){
			int nw[12] = {}, e = 0;
			bool f = false;
			rep(j,h){
				if(s[j][i] == '1') nw[e]++;
				if((bt>>j)&1) e++;
			}
			rep(j,n) if(dp[j] + nw[j] > k){
				f = true;
				if(nw[j] > k) ok = false;
			}
			if(f){
				cnt++;
				rep(j,n) dp[j] = nw[j];
			}else rep(j,n) dp[j] += nw[j];
		}
		if(ok) ans = min(ans, cnt);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: u64, m: u64, k: u64
    }
    const M: u64 = 998244353;
    let fact = &fact_table(n as usize, M);
    
    let mut ans = 0u64;
    for g in 0..=k {
        let mut res = m;
        res *= mod_pow(m-1, n-g-1, M);
        res %= M;
        res *= mod_comb(n-1, g, M, fact);
        res %= M;
        ans += res;
        ans %= M;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
/// x ^ n % m
pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
#[allow(dead_code)]
pub fn mod_inverse(a: u64, m: u64) -> u64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as u64 % m) % m
}
#[allow(dead_code)]
pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as u64 * res[i - 1]) % m;
    }
    res
}
#[allow(dead_code)]
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as u64 % m;
        fact_inv[i] = m - ((m / i as u64) * fact_inv[(m % i as u64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
#[allow(dead_code)]
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
#[allow(dead_code)]
/// C(n, k) % p
pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
#[allow(dead_code)]
/// H(n, k) % p
pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}

Measured memory_bytes: 3544
str = input("")
n = len(str)
BOOL = True
for i in range(int((n + 1) / 2)):
    BOOL = BOOL and str[i] == str[n - 1 - i]

for i in range(int((n - 1) / 2)):
    BOOL = BOOL and str[i] == str[int((n - 1) / 2 - 1 - i)]

for i in range(int((n - 1) / 2)):
    BOOL = BOOL and str[int((n + 3) / 2 - 1 + i)] == str[n - 1 - i]

if BOOL == True:
    print ("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/*
 
dunjen_master
 
*/
 
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

 
#define all(x) (x).begin(),(x).end()




int main(){


   string s,t;
   cin>>s;
   cin>>t;
   t=t.substr(0,(int)s.size());
   if(s==t){
    cout<<"Yes"<<endl;
   }else{
    cout<<"No"<<endl;
   }
   

    

    
}

    

    
 
    



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

long long f(long long b, long long n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}

vector<long long> divisors(long long n) {
	vector<long long> res;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) res.push_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int main() {
	long long n, s;
	cin >> n >> s;

	for (int i = 2; i < 1e6; i++) {
		if (f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}

	if (n == s) {
		cout << s + 1 << endl;
		return 0;
	}

	if (n - s < 0) {
		cout << -1 << endl;
		return 0;
	}

	long long mini = LLONG_MAX;

	for (long long d : divisors(n - s)) {
		long long b = (n - s) / d + 1;

		if (b > 1 && f(b, n) == s) {
			mini = min(mini, b);
		}
	}

	if (mini == LLONG_MAX) {
		cout << -1 << endl;
	} else {
		cout << mini << endl;
	}
}

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

#define f(a, b) for(auto i = a;i < b;i++)
typedef long long int ll;

void solve()
{
	return ;
}

int main()
{
	// solve();
	ll n;
	cin >> n;

	ll x , y;
	cin >> x >> y;

	vector < ll > vect(n);
	for(ll i = 1;i <= n;i++)
	{
		for(ll j = i + 1;j <= n;j++)
		{
			ll sum = min(1 + abs(i - x) + abs(j - y), (j - i));

			vect[sum]++;
		}
	}


	f(1, n)
		cout << vect[i] << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>

using namespace std;

int A[100001];

int main(void)
{
    int N;
    cin >> N;
    A[0] = 0; A[N + 1] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    long ans = 0;
    for (int i = 0; i <= N; i++) {
        ans += (long)abs(A[i] - A[i + 1]);
    }
    for (int i = 1; i <= N; i++) {
        long t = (long)abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i - 1] - A[i + 1]);
        cout << ans - t << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
while s = gets

  d = s.split(',').map(&:to_f)
  v1, v2 = d.pop(2)
  d1 = v1 * d.inject(:+) / (v1 + v2) 

  p, r = 0, 0
  d.each_with_index { |d,i|
    p += d
    if p >= d1
      r = i + 1 
      break
    end 
  }

  puts r
end

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n];
    forn(i,n) cin>>a[i];
    for(i=1;i<n-1;i++){
        if(a[i]>a[i+1] and a[i]<a[i-1]) ans++;
        else if(a[i]<a[i+1] and a[i]>a[i-1]) ans++;
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> h(n);
  
  int ans = 1e9;
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  
  for(int i = 0; i <= n - k; i++){
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int mark[113];

int main()
{
    int x,n,i,minn=1000000,val,diff;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<endl;return 0;
    }
    int arr[n+3];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];mark[arr[i]]=1;
    }

    for(i=110; i>=0; i--)
    {
        if(mark[i]==0)
        {
            diff=abs(x-i);
        if(diff<=minn)
        {
            minn=diff;val=i;
        }
        }

    }
    for(i=-1; i>=-110; i--)
    {
        diff=abs(x-i);
        if(diff<=minn)
        {
            minn=diff;val=i;
        }
    }
    cout<<val<<endl;



    return 0;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  multiset<int> st;
  int diam = 0;
  REP(i, n) {
    int a;
    cin >> a;
    st.insert(a);
    diam = max(diam, a);
  }
  if (diam % 2 == 0) {
    for (int i = diam; i > diam / 2; --i) {
      if (st.find(i) != st.end()) {
        st.erase(st.find(i));
      } else {
        cout << "Impossible" << endl;
        return 0;
      }
    }
    for (int i = diam / 2; i <= diam; ++i) {
      if (st.find(i) != st.end()) {
        st.erase(st.find(i));
      } else {
        cout << "Impossible" << endl;
        return 0;
      }
    }
    if (!st.empty() && *st.begin() < diam / 2 + 1) {
      cout << "Impossible" << endl;
      return 0;
    }
  } else {
    for (int i = diam; i >= (diam + 1) / 2; --i) {
      if (st.find(i) != st.end()) {
        st.erase(st.find(i));
      } else {
        cout << "Impossible" << endl;
        return 0;
      }
    }
    for (int i = (diam + 1) / 2; i <= diam; ++i) {
      if (st.find(i) != st.end()) {
        st.erase(st.find(i));
      } else {
        cout << "Impossible" << endl;
        return 0;
      }
    }
    if (!st.empty() && *st.begin() < (diam + 1) / 2 + 1) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  return 0;
}

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

int main(){
	int n=0;
	int w=0;
	int v[1000];
	int m[1000];
	
	cin>>n>>w;
	int DP[n+1][w+1];
	for(int i=0;i<n;i++){
		cin>>v[i]>>m[i];
	}
	for(int j=0;j<=w;j++){
		DP[0][j]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(j<m[i-1]){
				DP[i][j]=DP[i-1][j];
			}
			else{
				if(DP[i-1][j]>DP[i][j-m[i-1]]+v[i-1]){
					DP[i][j]=DP[i-1][j];
				}
				else{
					DP[i][j]=DP[i][j-m[i-1]]+v[i-1];
				}
			}
		}
	}
	cout<<DP[n][w]<<endl;
	
	return 0;
}

Measured memory_bytes: 5112
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 09:59-

            Map<String, Long> cnts = new HashMap<>();

            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                char[] chars = sc.next().toCharArray();
                Arrays.sort(chars);

                cnts.compute(new String(chars), (k, v) -> v == null ? 1 : v + 1);
            }

            long total = 0L;
            for (Entry<String, Long> entry : cnts.entrySet()) {
                total += f(entry.getValue() - 1);
            }
            
            out.println(total);
        }
    }

    private static long f(long v) {
        long x = 0;
        for (int i = 1; i <= v; i++) {
            x += i;
        }
        return x;
    }

}


Measured memory_bytes: 54748
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end()) //vector
string s,t,ans="";
int dp[3005][3005],n,m;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>t;
    n=s.size(),m=t.size();
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
    		else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    	}
    }
    int i=n,j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		} 
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}
	reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    // cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	int x,y;cin>>x>>y;
	vector<int> v_x;
	vector<int> v_y;
	int tmp = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if (s[i] == 'F'){
			tmp++;
		}
		else{
			if (cnt % 2 == 0){
				v_x.pb(tmp);
				cnt++;
				tmp = 0;
			}
			else{
				v_y.pb(tmp);
				cnt++;
				tmp = 0;
			}
		}
	}
	// if (cnt % 2 == 0){
	// 		v_x.pb(tmp);
	// 	}
	// 	else{
	// 		v_y.pb(tmp);
	// 	}
	if (tmp != 0){
		if (cnt % 2 == 0){
			v_x.pb(tmp);
		}
		else{
			v_y.pb(tmp);
		}
	}
	vector<vector<bool>> dp(10000,vector<bool>(20000,false));
	dp[0][10000] = true;
	int n = v_x.size();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 20000; j++) {
			if (dp[i][j]){
				if (i == 0){
					dp[i + 1][j + v_x[0]] = true;
				}
				else{
					dp[i+1][j + v_x[i]] = true;  
					dp[i+1][j - v_x[i]] = true;  
				}
			}
		}
	}
	if (!dp[n][10000 + x]){
		cout << "No" << endl;
		return 0;
	}

	vector<vector<bool>> dp2(10000,vector<bool>(20000,false));
	dp2[0][10000] = true;
	n = v_y.size();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 20000; j++) {
			if (dp2[i][j]){
				dp2[i+1][j + v_y[i]] = true;  
				dp2[i+1][j - v_y[i]] = true;  
			}
		}
	}
	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }
	if (!dp2[n][10000 + y]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }

	return 0;
}


Measured memory_bytes: 50176
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt().toMutableSet()
    println(if (A.size == N) "YES" else "NO")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 79032
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
l, r = i, N-i-1
div = [[j, K-1-j] for j in range(K)]
minval = 10000000
for d in div:
    if l-d[0] >= 0 and r-d[1] >= 0:
        minval = min(minval, ceil((l-d[0])/(K-1)) + ceil((r-d[1])/(K-1)) + 1)
print(minval)

Measured memory_bytes: 23524
N = int(input())
ans= [0 for i in range(N)]

arr1 = [[0 for i in range(N)] for j in range(3)]
for i in range(N):
    num = list(map(int, input().split()))
    arr1[0][i] = num[0]
    arr1[1][i] = num[1]
    arr1[2][i] = num[2]
    

for i in range(3):
    check = [0 for i in range(100)]
    for j in range(N):
        check[arr1[i][j]-1] += 1
    
    for j in range(N):
        if check[arr1[i][j]-1] == 1:
            ans[j] += arr1[i][j]
            
for i in range(N):
    print(ans[i])


Measured memory_bytes: 5632
n,k,q = map(int,input().split())
anslist = [0]*n
for i in range(q):
    anslist[int(input())-1] += 1

if k<=q:
    for ans in anslist:
        if ans > q-k:
            print('Yes')
        else:
            print('No')

else:
    for m in range(n):
        print('Yes')

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

int lis(const vector<int>& A) {
    int n = A.size();
    vector<int> L(n, 0);
    L[0] = A[0];
    int length = 1;
    for (int i = 1; i < n; i++) {
        if (L[length - 1] < A[i])
            L[length++] = A[i];
        else
            *lower_bound(L.begin(), L.begin() + length, A[i]) = A[i];
    }
    return length;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a[i] = ai;
    }
    cout << lis(a) << endl;
    return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <stdio.h>

using namespace std;
int main(void){
    int a,b;
    while(1){
        cin>>a;
        cin>>b;
        
        if(a==0&&b==0){
            break;
        }
        
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(i==0||i==a-1||j==0||j==b-1)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3024
#include <stdio.h>
#define NMAX 100
#define INF 1000000000
int main(void)
{
  int n, k;
  while (scanf("%d %d", &n, &k), n) {
    int i, j, a, b, e, com, dist[NMAX][NMAX];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
	dist[i][j] = INF;
      }
      dist[i][i] = 0;
    }
    while (k--) {
      scanf("%d", &com);
      if (com) {
	scanf("%d %d %d", &a, &b, &e);
	a--;
	b--;
	if (dist[a][b] > e) {
	  dist[a][b] = dist[b][a] = e;
	  for (i = 0; i < n; i++) {
	    for (j = i + 1; j < n; j++) {
	      int newlen = dist[i][a] + e + dist[b][j];
	      if (newlen < dist[i][j]) dist[i][j] = dist[j][i] = newlen;
	      newlen = dist[i][b] + e + dist[a][j];
	      if (newlen < dist[i][j]) dist[i][j] = dist[j][i] = newlen;
	    }
	  }
	}
      } else {
	scanf("%d %d", &a, &b);
	a--;
	b--;
	if (dist[a][b] >= INF) printf("-1\n");
	else printf("%d\n", dist[a][b]);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1972
#include<stdio.h>
int main(void)
{
		int a, count = 0, sa, seki;
		for(;;)
		{
			scanf("%d", &a);
		if (a == 0)
		{
			break;
		}
		sa = 1000 - a;
		if (sa >= 500)
		{
			sa = sa - 500;
			count = count + 1;
		}
		if (sa >= 100)
		{
			seki = sa / 100;
			sa = sa - 100 * seki;
			count = count + seki;
		}
		if (sa >= 50)
		{
			sa = sa - 50;
			count = count + 1;
		}
		if (sa >= 10)
		{
			seki = sa / 10;
			sa = sa - 10 * seki;
			count = count + seki;
		}
		if (sa >= 5)
		{
			sa = sa - 5;
			count = count + 1;
		}
		if (sa >= 1)
		{
			seki = sa / 1;
			sa = sa - 1 * seki;
			count = count + seki;
		}
		printf("%d\n", count);
		sa = 0;
		seki = 0;
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1644
from io import StringIO
class BinaryTree:


    class Node:
        def __init__(self, key):
            self.key = key
            self.left = None
            self.right = None
            self.parent = None


    def __init__(self):
        self.root = None
        self.output = StringIO()

    def insert(self, key):
        if self.root is None:
            self.root = self.Node(key)
        else:
            root = self.root
            temp = None
            while True:
                temp = root
                if key > root.key:
                    root = root.right
                    if root is None:
                        temp.right = self.Node(key)
                        break
                else:
                    root = root.left
                    if root is None:
                        temp.left = self.Node(key)
                        break

    def ini_print_inorder(self):
        self.output = StringIO()
        self.print_inorder(self.root)
        return self.output.getvalue()

    def ini_print_preorder(self):
        self.output = StringIO()
        self.print_preorder(self.root)
        return self.output.getvalue()

    def print_inorder(self, node):
        if node is not None:
            self.print_inorder(node.left)
            print(node.key, end = " ", file = self.output)
            self.print_inorder(node.right)

    def print_preorder(self, node):
        if node is not None:
            print(node.key, end = " ", file = self.output)
            self.print_preorder(node.left)
            self.print_preorder(node.right)

    def test_insert(self, keys):
        for k in keys:
            self.insert(k)

length = int(input())
b = BinaryTree()
for _ in range(length):
    comm = input()
    if comm[0] == "i":
        com, num = comm.split(" ")
        b.insert(int(num))
    else:
        print(" ", end = "")
        print((b.ini_print_inorder())[:-1])
        print(" ", end = "")
        print(b.ini_print_preorder()[:-1])




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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

ll eval(string s)
{
  ll ans = 0;
  ll d = 0;
  rep(i, s.size()) {
    if(s[i] == '+') {
      ans += d;
      d = 0;
    } else {
      d = d * 10 + s[i] - '0';
    }
  }
  ans += d;
  return ans;
}


string divs(string s, ll b)
{
  string rs;
  rs.push_back(s[0]);
  for(ll i = 0; i < s.size() - 1; i++) {
    if((b >> i) & 1) {
      rs.push_back('+');
    }
    rs.push_back(s[i + 1]);
  }
  return rs;
}

void solve()
{
  string s; cin >> s;
  ll ans = 0;

  for(ll b = 0; b < (1 << (s.size()-1)); b++) {
    string ds = divs(s, b);
    ans += eval(ds);
  }

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3684
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
char ans;
vector<char > A,B,C;
string S,T,U;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

int dfs(char r){
	char s;
	if(r == 'a'){
		s = A[0];
		if(A.empty()){
			ans = 'A';
			return 0;
		}
		A.erase(A.begin());
	}else if(r == 'b'){
		s = B[0];
		if(B.empty()){
			ans = 'B';
			return 0;
		}
		B.erase(B.begin());
	}else if(r == 'c'){
		s = C[0];
		if(C.empty()){
			ans = 'C';
			return 0;
		}
		C.erase(C.begin());
	}
	dfs(s);

	return 0;
}

int main(){
	cin >> S;
	cin >> T;
	cin >> U;
	for (int i = 0; i < S.size(); ++i)
	{
		A.push_back(S[i]);
	}
	for (int i = 0; i < T.size(); ++i)
	{
		B.push_back(T[i]);
	}
	for (int i = 0; i < U.size(); ++i)
	{
		C.push_back(U[i]);
	}
	dfs(A[0]);
	cout << ans << '\n';
	return 0;
}

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

int main(){
    int N;
    string s, t;
    cin >> N;
    cin >> s >> t;
    for(int i = 0; i < N; i++){
        cout << s.at(i) << t.at(i);
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 180 * (n-2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from itertools import permutations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = np.array(readline().split(), np.int64)
b = np.array(readline().split(), np.int64)

n_lst = [i for i in range(1, n+1)]
per_lst = list(permutations(n_lst, n))

ans = abs((per_lst.index(tuple(a))+1) - (per_lst.index(tuple(b))+1))

print(ans)


Measured memory_bytes: 31804
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <utility>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::map<char, int> m;
  string s;
  rep(i, N) {
    cin >> s;
    switch(s[0]) {
    case 'M':
    case 'A':
    case 'R':
    case 'C':
    case 'H':
      m[s[0]]++;
    }
  }

  std::queue<std::pair<long long, int>> q;
  for (const auto& e : m) {
    int size = q.size();
    rep(i, size) {
      auto p = q.front();
      q.pop();

      q.push(std::make_pair(p.first * e.second, p.second + 1));
      q.push(p);
    }

    q.push(std::make_pair(e.second, 1));
  }

  long long sum = 0;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();

    if (p.second == 3) sum += p.first;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++)
  {
  if(s[i] == ',')
    s[i] = ' ';
  }
      cout << s;
  return 0;
}


Measured memory_bytes: 256
a = []
b = []
flag = 0
a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a.append(a0)
a.append(a1)
a.append(a2)
n = int(input())
for i in range(n):
    b.append(int(input()))
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] = 0

for i in range(3):
    if((a[i][0] + a[i][1] + a[i][2]) == 0):
        flag = 1
    elif((a[0][i] + a[1][i] + a[2][i]) == 0):
        flag =2
    elif((a[0][0] + a[1][1] + a[2][2]) == 0):
        flag = 3
    elif((a[0][2] + a[1][1] + a[2][0]) == 0):
        flag = 4

if(flag != 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double

LL exp(LL n, LL p){
    if(p == 0){
        return 1;
    }else if(p % 2 == 0){
        LL t = exp(n, p / 2);
        return (t * t);
    }else{
        return n * exp(n, p - 1);
    }
}

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

    for(LL a = -200; a <= 200; ++a){
        for(LL b = -200; b <= 200; ++b){
            if(exp(a,5) - exp(b,5) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <sstream>
#include <deque>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

//insta  -------  __ansh7
//MSDIAN

// Basic Template

int main()
{
    fastio

    string s1="abcdefghijklmnopqrstuvwxyz";

    string s2="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    char c;
    cin>>c;


    for(ll i=0;i<s1.length();i++)
    {
        if(c==s1[i])
        {
            cout<<"a";
            break;
        }
    }


    for(ll i=0;i<s2.length();i++)
    {
        if(c==s2[i])
        {
            cout<<"A";
            break;
        }
    }



 

        return 0;
    }

Measured memory_bytes: 3612
s="0b"+input()
a=int("0b"+"10"*(len(s)//2-1)+"1"*(len(s)%2==1),0)
s=int(s,0)
c=lambda x:str(bin(x)).count("1")
print(min(c(s^a),c(s^a^int("0b"+"1"*(len(bin(a))-2),0))))

Measured memory_bytes: 3316
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n,k = inpm()
    s = list(input())
    t = [0]
    for i in range(n-1):
        if s[i] != s[i+1]:
            t.append(i+1)
    a = len(t)
    if len(t)<2*k-1:
        print(n)
        return
    for i in range(2*a+4):
        t.append(n)
    ans = 0
    if s[0]=='1':
        for i in range(a):
            if 2*k+2*i+1 >= len(t):
                break
            ans = max(ans,t[2*k+2*i+1]-t[2*i])
    else:
        ans = t[2*k]
        for i in range(a):
            if 2*k+2*i+2 >= len(t):
                break
            ans = max(ans,t[2*k+2*i+2]-t[2*i+1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 61540
HN=input().split()
H = int(HN[0])
N = int(HN[1])

AA = input().split()

totalA = 0
for i in range(N):
  totalA += int(AA[i])

result = ""
if H <= totalA:
  result = "Yes"
else:
  result = "No"

print(result)

Measured memory_bytes: 10132
using System;
class A{
static void Main(){
while(true){
string n=Console.ReadLine();
if(n==null){break;}
int []a=new int[10];
for(int i=0;i<n.Length;i++){a[i]=int.Parse(n.Substring(i,1));}
Console.WriteLine((a[0]+(a[1]*9)+a[2]*6+a[3]*4+a[4]*6+a[5]*6+a[6]*4+a[7]*6+a[8]*9+a[9])%10);
 
}
}
}

Measured memory_bytes: 9144
#include <stdio.h>
#include <inttypes.h>

int64_t sumipe(int64_t mikakosi) {
	return mikakosi < 0 ? -mikakosi : mikakosi;
}

int N;
int64_t A[114514];

int main(void) {
	int i;
	int64_t cost;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	A[0] = A[N + 1] = 0;
	cost = 0;
	for (i = 1; i <= N + 1; i++) {
		cost += sumipe(A[i - 1] - A[i]);
	}
	for (i = 1; i <= N; i++) {
		printf("%" PRId64 "\n",
			cost - sumipe(A[i - 1] - A[i]) - sumipe(A[i] - A[i + 1]) + sumipe(A[i - 1] - A[i + 1]));
	}
	return 0;
}


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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;

int arr[N] , ase[N] ;
int rem[N] ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    memset( ase , 0 , sizeof(ase)) ;
    int n ; scanf("%d" , &n ) ;
    for( int i = 1 ; i <= n ; i++ ) {
        scanf("%d" , &arr[i] ) ;
        ase[ arr[i] ] = 1 ;
    }
    int tot = 0 ;
    for( int i = 1 ; i <= 10000 ; i++ ) {
        if( ase[i] == 0 ) rem[++tot] = i ;
    }
    int ans = 0 ;
    for( int i = 2 ; i < n ; i++ ) {
        if( arr[i] == arr[i - 1] && arr[i] == arr[i + 1] ) {
            arr[i] = rem[1] ;
            ans += 1 ;
            i += 1 ;
        }
    }
    for( int i = 1 ; i < n ; i++ ) {
        if( arr[i] == arr[i + 1] ) {
            arr[i] = rem[1] ;
            ans += 1 ;
        }
    }
    printf("%d\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 10496
N = int(input())
x = y = 0

for _ in range(N):
    t, _x, _y = map(int, input().split())
    dist = abs(_y - y) + abs(_x - x)
    if dist > t or (t - dist) % 2 == 1:
        print('No')
        quit()
print('Yes')


Measured memory_bytes: 3060
N = int(input())
t,x,y = [],[],[]

for _ in range(N):
	t_tmp, x_tmp, y_tmp = map(int, input().split())
	t.append(t_tmp)
	x.append(x_tmp)
	y.append(y_tmp)

ct,cx,cy = 0,0,0
cond = True
for i in range(N):
	dt = t[i] - ct
	dx = abs(cx - x[i])
	dy = abs(cy - y[i])

	if dt < dx + dy:
		cond = False
		break

	buff = dx+dy-dt

	if buff % 2 == 1:
		cond = False
		break

if cond:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 11840
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


int main()
{
    int N;
    cin >> N;
    int tmp;
    int count = 0;
    int index = 1;
    for(int i = 0;i < N;i++)
    {
        cin >> tmp;
        if(index == tmp)
        {
            index++;
        }
        else
        {
            count++;
        }
    }
    cout << (index == 1 ? "-1" : to_string(count)) << endl;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
import           Control.Monad               (when)
import           Control.Monad.ST            (ST, runST)
import qualified Data.Sequence               as S
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  k <- readLn
  print $ solve k

solve :: Int -> Int
solve k = runST $ do
  vs <- VM.replicate k False
  whileLeft (S.singleton (1, 1)) $ \q -> do
    let (n, d) S.:< q' = S.viewl q
    v <- VM.read vs n
    VM.write vs n True
    if | n == 0    -> return $ Right d
       | v         -> return $ Left q'
       | otherwise -> return $ Left $ (((n * 10) `mod` k, d) S.<| q') S.|> ((n + 1) `mod` k, d + 1)

whileLeft :: Monad m => a -> (a -> m (Either a b)) -> m b
whileLeft x f = f x >>= \case
  Left l  -> whileLeft l f
  Right r -> return r


Measured memory_bytes: 20860
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S;
    cin >> S;
    int base = 1;
    int now = 0;
    vector<int> cnt(2019);
    cnt[0]++;
    IREP(i, S.size()) {
        now = (now + (int)(S[i]-'0')*base) % 2019;
        cnt[now]++;
        base = (base * 10) % 2019;
    }
    lint ans = 0;
    REP(i, 2019) {
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans << endl;
}

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

public class Main {

  static boolean[] visited;
  static int[] point;
  static List<Integer>[] tree;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int Q = sc.nextInt();
    visited = new boolean[N];
    point = new int[N];
    tree = new List[N];

    for (int i = 0; i < N; i++) {
      tree[i] = new ArrayList<>();
    }

    for (int i = 0; i < N - 1; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      tree[a].add(b);
      tree[b].add(a);
    }

    for (int i = 0; i < Q; i++) {
      int p = sc.nextInt() - 1;
      int x = sc.nextInt();
      point[p] += x;
    }

    sc.close();

    dfs(0);

    PrintWriter out = new PrintWriter(System.out);
    
    out.print(point[0]);

    for (int i = 1; i < N; i++) {
      out.print(" ");
      out.print(point[i]);
    }

    out.println("");

    out.flush();

  }

  static void dfs(int parent) {

    visited[parent] = true;
    
    List<Integer> next_ = tree[parent];
    
    for (int id_ : next_) {
      if (!visited[id_]) {
        point[id_] += point[parent];
        dfs(id_);
      }
    }

  }

}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define outl(x) cout<< (x) << '\n'
#define pb(a) push_back(a)
#define fi first
#define se second
#define MOD 1000000007

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

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
  int x, y;
  ci >> x >> y;

  co << x + y / 2 << en;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ESP (1e-10)
using namespace std;

typedef struct Point {
	double x; 
	double y;

	Point() { }

	Point(double x, double y) :x(x), y(y) { }

	Point operator+(Point& p) {
		return Point(x + p.x, y + p.y);
	}

	Point operator-(Point& p) {
		return Point(x - p.x, y - p.y);
	}
};

typedef Point Vector;

 struct Line {
	Point p1, p2;
	Line() {}
	Line(const Point& a,const Point& b) : p1(a),p2(b) { }
};

 typedef Line Segment;

double abs(Point p1, Point p2) {
	double norm = (p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y);
	return sqrt(norm);
}

double product(Vector v1, Vector v2) {
	return v1.x*v2.x + v1.y*v2.y;
}

double cross(Vector p1, Vector p2) {
	return p1.x*p2.y - p1.y*p2.x;
}

int ccw(Point p0, Point p1, Point p2) {
	Vector v0 = p1 - p0;
	Vector v1 = p2 - p0;
	if (cross(v0, v1) > ESP) return 1;   //p0,p1,p2??????????¨???????
	if (cross(v0, v1) < -ESP) return -1;   //p0,p1,p2???????¨???????
	if (product(v0, v1) < -ESP) return 2;  //p2,p0,p1????????§????????´??????
	if (abs(p0, p1) < abs(p0, p2)) return -2;  //p0,p1,p2????????§????????´??????
	return 0;   //p2?????????(p0,p1)???
}

bool intersect(Point p0, Point p1, Point p2, Point p3) {
	return (ccw(p0, p1, p2)*ccw(p0, p1, p3) <= 0&&ccw(p2,p3,p0)*ccw(p2,p3,p1)<=0);
	//?????????????????????????????¶
}

bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

double DistanceLP(Line l, Point p) {
	return abs(cross(l.p2 - l.p1, p - l.p1)/abs(l.p1,l.p2));
}

double DistanceSP(Segment s, Point p) {
	if (product(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p, s.p1);
	if (product(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p, s.p2);
	return DistanceLP(s, p);
}

double DistanceSS(Segment s1, Segment s2) {
	if (intersect(s1, s2)) return 0.0;
	return min(min(DistanceSP(s1, s2.p1), DistanceSP(s1,s2.p2)), min(DistanceSP(s2, s1.p1), DistanceSP(s2, s1.p2)));
}

int main() {
	Point p0, p1,p2;
	cin >> p0.x; cin >> p0.y;
	cin >> p1.x; cin >> p1.y;
	int q; 
	cin >> q;
	for (int i = 0;i < q;i++) {
		cin >> p2.x; cin >> p2.y;
		int c = ccw(p0, p1, p2);
		if (c == 1) cout << "COUNTER_CLOCKWISE" << endl;
		if (c == -1) cout << "CLOCKWISE" << endl;
		if (c == 2) cout << "ONLINE_BACK" << endl;
		if (c == -2) cout << "ONLINE_FRONT" << endl;
		if (c == 0) cout << "ON_SEGMENT" << endl;
	}
}

Measured memory_bytes: 3200
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstdio>

using namespace std;

const int MX=100011,MXT=262333;
int n;
struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX<<1];
int hed[MX],ec;
inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]);hed[f]=ec;}
#define FE(k,i) for(int (i)=hed[k];(i);(i)=e[i].nxt)if(e[i].t!=f)
int sz[MX],fa[MX],d[MX],tp[MX],dc[MX];
int dfn[MX],dfc;
void dfs(int k,int f){
	sz[k]=1;
	FE(k,i)dfs(e[i].t,k),sz[k]+=sz[e[i].t];
}
void tcp(int k,int f,int _d,int _tp,int _dc){
	dfn[k]=++dfc;
	fa[k]=f,d[k]=_d,tp[k]=_tp,dc[k]=_dc;
	int mn=0,no=0;
	FE(k,i)if(sz[e[i].t]>mn)mn=sz[e[i].t],no=e[i].t;
	if(no){
		tcp(no,k,_d+1,_tp,_dc);
		FE(k,i)if(e[i].t!=no)tcp(e[i].t,k,_d+1,e[i].t,_dc+1);
	}
}
struct Seg{
	int mn,mnno;
	int ad;
	Seg(int _mn=0,int _mnno=0):mn(_mn),mnno(_mnno),ad(0){}
	inline void add(int x){ad+=x,mn+=x;}
}sg[MXT];
inline Seg operator+(const Seg &l,const Seg &r){return l.mn<=r.mn?Seg(l.mn,l.mnno):Seg(r.mn,r.mnno);}
inline void psdw(int no){if(sg[no].ad)sg[no<<1].add(sg[no].ad),sg[no<<1|1].add(sg[no].ad),sg[no].ad=0;}
inline void add(int no,int l,int r,int ll,int rr,int v){
	if(ll<=l&&rr>=r)sg[no].add(v);
	else{
		psdw(no);
		int mid=(l+r)>>1;
		if(ll<=mid)add(no<<1,l,mid,ll,rr,v);
		if(rr>mid)add(no<<1|1,mid+1,r,ll,rr,v);
		sg[no]=sg[no<<1]+sg[no<<1|1];
	}
}
inline Seg que(int no,int l,int r,int ll,int rr){
	if(ll<=l&&rr>=r)return sg[no];
	else{
		psdw(no);
		int mid=(l+r)>>1;
		if(rr<=mid)return que(no<<1,l,mid,ll,rr);
		else if(ll>mid)return que(no<<1|1,mid+1,r,ll,rr);
		else return que(no<<1,l,mid,ll,mid)+que(no<<1|1,mid+1,r,mid+1,rr);
	}
}
void build(int no,int l,int r){
	if(l==r)sg[no]=Seg(0,l);
	else{
		int mid=(l+r)>>1;
		build(no<<1,l,mid),build(no<<1|1,mid+1,r);
		sg[no]=sg[no<<1]+sg[no<<1|1];
	}
}
int C[MX],D[MX];
int xs[MX];
#define lbt(i) ((i)&(-(i)))
inline void upd(int x,int v){for(int i=x;i<=n;i+=lbt(i))xs[i]^=v;}
inline int que(int x){int r=0;for(int i=x;i;i^=lbt(i))r^=xs[i];return r;}
void add(int no,int V){
	int u=C[no],v=D[no];
	while(tp[u]!=tp[v]){
		if(dc[u]<dc[v])swap(u,v);
		add(1,2,n,dfn[tp[u]],dfn[u],V);
		upd(dfn[tp[u]],no),upd(dfn[u]+1,no);
		u=fa[tp[u]];
	}
	if(d[u]<d[v])swap(u,v);
	if(v!=u){
		add(1,2,n,dfn[v]+1,dfn[u],V);
		upd(dfn[v]+1,no);
		upd(dfn[u]+1,no);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		static int a,b;scanf("%d%d",&a,&b);
		ade(a,b),ade(b,a);
	}
	dfs(1,0);tcp(1,0,1,1,1);
	build(1,2,n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&C[i],&D[i]);
		add(i,1);
	}
	for(int i=1;i<n;i++){
		if(sg[1].mn>1)return puts("NO"),0;
		int no=que(sg[1].mnno);
		add(1,2,n,sg[1].mnno,sg[1].mnno,3);
		add(no,-1);
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 14336
while true do
  s=STDIN.gets
  h=s.split[0].to_i
  w=s.split[1].to_i
  break if (h==0 && w==0)

  w.times { printf("#") }
  puts "\n" 

  h-=2
  h.times {
    printf("#")
    (w-2).times {
      printf(".") }
    printf("#\n") }

  w.times { printf("#") }
  puts "\n" 

  puts "\n"
end

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
string vac = "Vacant";

bool chk(string sl, string sr, int left, int right)
{
  if(sl==sr) return (right-left)%2==1;
  else return (right-left)%2==0;
}

int main()
{
  int n; cin >> n;
  int left = 0, right = n/2;
  string sl, sr, str;
  cout << left << endl;
  cin >> sl;
  if(sl==vac) return 0;
  cout << right << endl;
  cin >> sr;
  if(sr==vac) return 0;
  
  if(!chk(sl,sr,left,right)){
    swap(sl,sr);
    left = right;
    right = n;
  }
  
  while((right-left)>1){
    int mid = (right+left)/2;
    cout << mid << endl;
    cin >> str;
    if(str==vac) return 0;
    if(chk(sl,str,left,mid)){
      sr = str;
      right = mid;
    }else{
      sl = str;
      left = mid;
    }
  }

  return 0;
}


Measured memory_bytes: 852