akhauriyash/Code-Regression huggingface dataset:
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int n, a[3000]; cin >> n;
  int ans = 0;
  REP(i, n) {
    cin >> a[i];
    ans += a[i]-1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace CodingForces
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long power = 1;
            var mod = (int)Math.Pow(10, 9) + 7;
            for (var i = 1; i <= n; i++)
            {
                power = (power * i) % mod;
            }
            Console.WriteLine(power);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    ll A, B, K, i;
    in3(A, B, K);
    for(i=A; i<=B; i++){
        if(i-A<K || B-i<K) put(i);
    }
    return 0;
}


Measured memory_bytes: 128
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::*;
use std::string::*;
use std::f64::consts::PI;

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }

    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let s: String = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();

        return s.parse::<T>().ok().unwrap();
    }

    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn prime_factorization(n: i64) -> HashMap<i64, i64> {
    let mut n = n;
    let mut res = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            let count = res.entry(i).or_insert(0);
            *count += 1;
        }
        i += 1;
    }

    if n > 1 {
        res.insert(n, 1);
    }

    return res;
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut st = VecDeque::new();
    let mut ans = Vec::new();
    st.push_back(("".to_string(), 'a' as u8));
    while let Some((s, mx)) = st.pop_front() {
        if s.len() == n {
            ans.push(s.clone());
        } else {
            for c in 'a' as u8..mx + 1 {
                st.push_front((
                    format!("{}{}", s, c as char),
                    if c == mx { mx + 1 } else { mx }
                ));
            }
        }
    }
    ans.sort();
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 11896
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef long long ll;
/*
  (px + q)(rx + s)
  p > 0
  r > 0
  (p > r) or (p = r and q >= s)

  prx^2 + (ps + qr)x + qs
  a = pr
  b = ps + qr
  c = qs
 */
int main(){
    ll a,b,c,p,q,r,s,i,j,k;

    while( cin >> a >> b >> c, a|b|c ){
        bool ok = false;

        for(i=1; i*i<=a; i++){
            if( a%i != 0 ) continue;
            p = a/i, r = i;

            for(j=-abs(c); j<=abs(c); j++){
                if( (j == 0 && c != 0) || (j != 0 && abs(c)%abs(j) != 0) ) continue;
                if( j != 0 ){
                    q = c/j, s = j;
                }
                else{
                    q = b/r, s = 0;
                    if( p*s + q*r != b ) q = 0, s = b/p;
                    if( p*s + q*r != b ) continue;
                }

                //printf("%lld %lld %lld %lld\n",p,q,r,s);
                if( !( p*r == a && q*s == c && (p*s + q*r == b || p*r + q*s == b) ) ) continue;

                ok = true;
                if( p == r ){
                    printf("%lld %lld %lld %lld\n", p,max(q,s),r,min(q,s));
                }
                else{
                    if( p*s + q*r == b ){
                        printf("%lld %lld %lld %lld\n", p,q,r,s);
                    }
                    else{
                        printf("%lld %lld %lld %lld\n", p,s,r,q);
                    }
                }
                break;
            }
            if( ok ) break;
        }
        if( !ok ) puts("Impossible");
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans,x;
int main()
{    
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;i++)
      for(int j=0;j<=b;j++)
        for(int k=0;k<=c;k++)
        {
        	if(i*500+j*100+k*50==x)
        	{
        		ans++;
			}
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
Edge = [[] for _ in range(N)]
Num = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    Edge[x].append(y)
    Num[y] += 1
Q = deque()
for i, n in enumerate(Num):
    if n == 0:
        Q.append(i)

DP = [0] * N
ans = 0
while Q:
    now = Q.pop()
    for nex in Edge[now]:
        DP[nex] = max(DP[nex], DP[now] + 1)
        Num[nex] -= 1
        if not Num[nex]:
            Q.append(nex)
print(max(DP))



Measured memory_bytes: 87652
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long[] a =new long[n];
		long[] b =new long[n];
		long ans=0;
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
			b[i]=sc.nextLong();
			if((a[i] & ~k)==0){
				ans+=b[i];
			}
		}
		for(int i=30; i>=0; i--){
			if((k>>i & 1)==1){
				int x=((k>>i)<<i)-1;
				long tt=0;
				for(int j=0; j<n; j++){
					if((a[j] & ~x)==0){
						tt+=b[j];
					}
				}
				ans=Math.max(ans,tt);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 89968
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int INF=100000000;

// eXªwè³ê½FÉÈéÜÅÌÅ¬X^vñ
int dp[1<<16];
char field[5][5];
vector<pair<int,int> > stumps;
int n;
char color[]={'R','G','B'};

int dfs(int s){
    if(s==0)
        return 0;
    if(dp[s]!=INF)
        return dp[s];
    int cnt=INF;
    // TCYÒÁ½è ¤êðIñÅX^vðßµÄ¢­
    for(int k = 0; k < stumps.size(); k++){
        int h=stumps[k].first;
        int w=stumps[k].second;
        // ¶ãÌÀWðè
        for(int i = -h+1; i < 4; i++){
            for(int j = -w+1; j < 4; j++){
                int ns=s;
                bool first=false;
                bool b=false;
                char cc=0;
                // Iñ¾ÍÍªS¯¶FÅ é©Ç¤©ð`FbN·é
                for(int k = i; k<min(i+h,4); k++){
                    for(int l = j; l < min(j+w,4); l++){
                        if(!(k>=0&&l>=0&&k<4&&l<4))
                            continue;
                        // hçêÄ¢éêÌÝl¶·é
                        if((s>>(k*4+l))&1){
                            if(!first){
                                cc=field[k][l];
                                first=true;
                            }
                            else{
                                if(field[k][l]!=cc){
                                    b=true;
                                    break;
                                }
                            }
                        }
                    }
                    if(b)
                        break;
                }
                // SðÅ«éê,hèÂÔµððµÄAÄA
                if(!b&&first){
                    for(int k = i; k<min(i+h,4); k++){
                        for(int l = j; l < min(j+w,4); l++){
                            if(!(k>=0&&l>=0&&k<4&&l<4))
                                continue;
                            ns&=~(1<<(k*4+l));
                        }
                    }
                    cnt=min(cnt,dfs(ns)+1);
                }
            }
        }
    }
    return dp[s]=cnt;
}

void solve(){
    fill(dp,dp+(1<<16),INF);
    cin>>n;
    int h,w;
    for(int i = 0; i < n; i++){
        cin>>h>>w;
        stumps.push_back(make_pair(h,w));
    }
    for(int i = 0; i < 4; i++)
        for(int j = 0; j < 4; j++)
            cin>>field[i][j];
    cout<<dfs((1<<16)-1)<<endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 0
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//mint
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

/******************************************/


/*****************************************/

int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   int n;cin >> n;
   vector<ll> a(n);
   rep(i,n)cin >> a[i];
   
   int ans = 0;
   int i = 1;
   int j = 1;
   while(i < n){
      if(a[i-1] >= a[i])j++;
      else{
         maxs(ans,j);
         j = 1;
      }
      i++;
   }
   maxs(ans,j);
   cout << ans - 1 << endl;
   return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<cstdio>
#include <iostream>
#define N 5050
#define ll long long 
using namespace std;
ll mod;
int n;
ll x[N], y[N], u[N], sum[N], ret[N];
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
ll inv(ll a)
{
	return powmod(a, mod-2);
}
int main()
{
  	cin >> n;
  	mod = n;
  	for(int i=0; i<n; i++)
  	{
  		x[i] = i;
  		cin >> y[i];
  		u[i] = y[i];
  	}
  	ret[0] = u[0], sum[0] = 1;
  	for(int i=1; i<n; i++)
  	{
  		for(int j=n-1; j>=i; j--)
  		{
  			u[j] = (u[j]-u[j-1])*inv((x[j]-x[j-i]))%mod;
  		}
  		for(int j=i; j; j--)
  		{
  			sum[j] = (-sum[j]*x[i-1] + sum[j-1])%mod;
  			(ret[j] += sum[j]*u[i]%mod) %= mod;
  		}
  		sum[0] = -sum[0]*x[i-1]%mod;
  		(ret[0] += sum[0]*u[i]%mod) %= mod;
  	}
  	for(int i=0; i<n; i++) (ret[i] += mod) %= mod;
  	for(int i=0; i<n; i++) cout << ret[i] << ' ';
  	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<map>
#include<iostream>
using namespace std;
int a[100005],tot,i,j,k,l,s,n,m,x;
map<int,int>ma;
int main() {
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		scanf("%d",&x);
		if (ma[x]==1) a[++tot]=x,ma[x]=0;
		else if (!ma[x]) ma[x]=1;
	}
	sort(a+1,a+1+tot);
	if (tot<2) printf("0\n");
	else cout<<1ll*a[tot]*a[tot-1]<<endl;
}


Measured memory_bytes: 4992
R, G, B, N = map(int, input().split())
ans = 0
BN = []
for b in range(N+1):
    BN.append(N - (b * B))
BN = set(BN)
for r in range(N+1):
    for g in range(N+1):
        if r * R + g * G in BN:
            ans += 1
print(ans)




Measured memory_bytes: 42876
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

bool same(char a, char b) {
    return a == b || a == '?' || b == '?';
}

string s[3];
int match_cache[3][3][2000 + 2000 + 10];  // 0: not calculated; 1: match; 2: not match

bool match(int i1, int start, int i2) {
    check(start >= 0);
    if (match_cache[i1][i2][start] != 0) {
        return match_cache[i1][i2][start] == 1 ? true : false;
    }
    string a = s[i1];
    string b = s[i2];
    bool ans = true;
    rep(i, start, a.size() - 1) {
        if (i - start + 1 > b.size()) {
            break;
        }
        if (!same(a[i], b[i - start])) {
            ans = false;
            break;
        }
    }
    match_cache[i1][i2][start] = ans ? 1 : -1;
    return ans;
}

int solve(int i1, int i2, int i3) {
    string a = s[i1];
    string b = s[i2];
    string c = s[i3];
    int alen = a.size();
    int blen = b.size();
    int clen = c.size();
    int ans = alen + blen + clen;
    // denote s as result of combining a, b, c
    rep(i, 0, alen + max(blen, clen)) {
        // b starts at s[i] and after a
        if (!match(i1, i, i2)) {
            continue;
        }
        rep(j, i, alen + max(blen, clen)) {
            // c starts at s[j] and after b
            if (!match(i1, j, i3) || !match(i2, j - i, i3)) {
                continue;
            }
            int b_end = i + blen - 1;
            int c_end = j + clen - 1;
            int len = max(alen, max(b_end + 1, c_end + 1));
            ans = min(ans, len);
        }
    }
    return ans;
}

string rand_s(int n) {
    string a = "";
    rep(i, 0, n - 1) {
        bool q_mark = rand() < RAND_MAX / 10;
        if (q_mark) {
            a.push_back('?');
        } else {
            char c = rand() % 26 + 'a';
            a.push_back(c);
        }
    }
    return a;
}

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

    cin >> s[0] >> s[1] >> s[2];

    // int n = 10;
    // srand(time(0));
    // a = rand_s(n);
    // b = rand_s(n);
    // c = rand_s(n);
    // debug("a = %s\n", a.c_str());
    // debug("b = %s\n", b.c_str());
    // debug("c = %s\n", c.c_str());

    // combine a and b first, then consider c
    // permutation
    // so we could assume a then b and c
    int ans = s[0].size() + s[1].size() + s[2].size();
    rep(i, 0, 2) {
        rep(j, 0, 2) {
            if (i != j) {
                rep(k, 0, 2) {
                    if (i != k && j != k) {
                        ans = min(ans, solve(i, j, k));
                    }
                }
            }
        }
    }

    cout << ans << el;
}


Measured memory_bytes: 888
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)1e5;

int dat[N+5];

int main(){
    for (int i=0; i<N+3; i++) {
        dat[i] = 0;
    }

    int n,k,q; scanf("%d %d %d", &n, &k, &q);
    for (int i=1; i<=q; i++) {
        int a; scanf("%d", &a);
        dat[a]++;
    }

    for (int i=1; i<=n; i++) {
        puts(k-q+dat[i] > 0 ? "Yes" : "No");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
  if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
  ll N; cin>>N;
  ll a[N]; CINA(a,N); sort(a,a+N,greater<ll>());
  ll ans = 0;
  for(int i=1;i<N;++i){
    int idx = i/2;
    ans += a[idx];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 5168
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);

}

void solve() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}

int main() {
	init();
	solve();
}

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

using namespace std;
const int Nmax = 1e5 + 10;

long long n, c[Nmax], a, b;
long long ans;

int main() {
    scanf("%d %d %d", &n, &a, &b);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &c[i]);
        if (i == 1) continue;
        if ((c[i] - c[i-1])*a <= b) ans +=  (c[i] - c[i-1])*a;
        else ans += b;
    }
    cout << ans;
}


Measured memory_bytes: 1024
def c_candles(N, K, X):
    ans = float('inf')
    # [left, right] が指す連続したK本のろうそくに火をつけるといい
    for left in range(N):
        right = left + K - 1
        if right >= N:  # 右端がろうそくを指していない
            break
        # left→rightへ付けていく場合とright→leftへ付けていく場合
        ans = min(ans, abs(X[left]) + abs(X[right] - X[left]))
        ans = min(ans, abs(X[right]) + abs(X[right] - X[left]))
    return ans

N, K = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
print(c_candles(N, K, X))

Measured memory_bytes: 14384
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    IOS;
	
	char c;
	cin >> c;
	if(int(c) >= 65 && int(c) <= 90){
		cout << "A";
	}
	else cout << "a";
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vect(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() -1 ) cout << v[i] ;
	  else cout << " " << v[i]  ; 
	 }	
  cout << endl;
}

void solve(){
  int n;
  cin >> n;
  vector<int> v;
  for(int i = 0; i < n; i++){
	  v.push_back(i);  
	}	
  for(int i = 0 ; i < (1 << n); i++){
	  vector<int> ret;
	  for(int j = 0; j < n; j++){
		  if (i & (1 << j)){
			  ret.push_back(v[j]);  
			}  
		}
      cout << i << ":" ;
      for(auto it : ret) cout <<  " " << it;
      cout << endl; 
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3216
n, m = map(int, input().split())

if n == 2 or m == 2:
    ans = 0
elif n == 1 and m == 1:
    ans = 1
elif n == 1 or m == 1:
    ans = max(n, m) - 2
else:
    ans = (n - 2)*(m - 2)

print(ans)

Measured memory_bytes: 3060
n, w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]

dp = [[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if wv[i][0] <= j:
            dp[i+1][j] = max(dp[i][j-wv[i][0]]+wv[i][1],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1]))

Measured memory_bytes: 171784
import re
import sys
S = input()
T = input()
w = 0
if not re.match(r'^[a-z]+$', S) or not re.match(r'^[a-z]+$', T) or len(S) != len(T) or (10 ** 5 * 2) < len(S):
  sys.exit()
if S != T:
  i = 0
  for l in S:
    if l != T[i]:
      w = w + 1
    i = i + 1
print(w)

Measured memory_bytes: 10252
def solve():
    S = input()
    l = len(S)
    K = int(input())
    i = 0
    ans = ''
    while i < l-1 and K>0:
        n = ord(S[i])-ord('a')
        if n==0:
            ans += 'a'
            i += 1
            continue
        if 25-n<K:
            ans += 'a'
            K -= 26-n
        else:
            ans += S[i]
        i += 1
    if K == 0:
        ans += S[i:]
    else:
        ans += chr((ord(S[-1])-ord('a')+K)%26+ord('a'))
    return ans
print(solve())

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

int main()
{
	ll x,y,a,b,c,p;
	vector<ll>v,w,k,g;
	cin>>x>>y>>a>>b>>c;	
	for(ll i=0;i<a;i++)
	{
		cin>>p;
		v.push_back(p);
	}
	for(ll i=0;i<b;i++)
	{
		cin>>p;
		w.push_back(p);
	}
	for(ll i=0;i<c;i++)
	{
		cin>>p;
		k.push_back(p);
	}
	sort(v.begin(),v.end(),greater<ll>());
	sort(w.begin(),w.end(),greater<ll>());
	sort(k.begin(),k.end(),greater<ll>());
	for(ll i=0;i<x;i++)
	{
		g.push_back(v[i]);
	}
	for(ll i=0;i<y;i++)
	{
		g.push_back(w[i]);
	}
	sort(g.begin(),g.end());
	for(ll i=0;i<min(x+y,c);i++)
	{
		if(g[i]<k[i])g[i]=k[i];
	}
	ll sum=0;
	for(ll i=0;i<x+y;i++)
	{
		sum+=g[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4724
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(100001, Float::INFINITY)
dp[0] = 0
items.each do |w, v|
  prev = dp.dup
  prev.each_with_index do |pw, pv|
    if pw+w <= w_max && pw+w < prev[pv+v]
      dp[pv+v] = pw+w
    end
  end
end
puts dp.rindex{|v| v != Float::INFINITY}


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

int main(){
	long long n;	cin >> n;
	long long a[n];
	map <long long , long long> mp;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		mp[a[i]]++;
	}
	long long ans = 0;
	for(auto at : mp){
		ans += at.second * (at.second-1) / 2;
	}

	for (int i = 0; i < n; ++i){
		cout << ans - mp[a[i]] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 11008
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int w = 0, x = 0, y = 0, z = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            String t = s.replaceAll("AB", "X");
            w += s.length() - t.length();
            if (s.substring(0, 1).equals("B")) {
                if (s.substring(s.length() - 1, s.length()).equals("A")) {
                    x++;
                } else {
                    y++;
                }
            } else if (s.substring(s.length() - 1, s.length()).equals("A")) {
                z++;
            }
        }
        sc.close();
        if (x > 1) {
            w += x - 1;
            x = 1;
        }
        if (Math.max(x, Math.max(y, z)) == y) {
            w += x;
            w += z;
        } else if (Math.max(x, Math.max(y, z)) == z) {
            w += x;
            w += y;
        }
        System.out.println(w);
    }
}

Measured memory_bytes: 38660
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TapDance | diff TapDance.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TapDance.cpp && ./a.out

/*
 
 9/15/2019
 
 5:03-
 
 */

string S;

void solve() {
  int N=SZ(S);
  bool res=true;
  REP(i,N) {
    if(i%2==0) {
      if(S[i]=='L') res=false;
    } else {
      if(S[i]=='R') res=false;
    }
  }
  cout<<(res?"Yes":"No")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
H, W = map(int, input().split())
cntA = Counter()
for _ in range(H):
    cntA += Counter(list(input()))

if H % 2 + W % 2 == 0:
    if all(c % 4 == 0 for c in cntA.values()):
        print('Yes')
    else:
        print('No')
    exit()

if H % 2 + W % 2 == 1:
    two = (H if H % 2 == 0 else W) // 2
    cntTwo = 0
    for c in cntA.values():
        if c % 4 == 0:
            continue
        if c % 2 == 0:
            cntTwo += 1
            continue
        break
    else:
        if cntTwo <= two:
            print('Yes')
            exit()
    print('No')
    exit()

cntTwo = 0
cntOdd = 0
for c in cntA.values():
    if c % 4 == 0:
        continue
    if c % 2 == 0:
        cntTwo += 1
        continue
    cntOdd += 1

if cntOdd == 1 and cntTwo <= (H + W - 2) // 2:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3316
#include <cstdio>
int N,count=0;
void dfs(long long,unsigned char);
int main(void)
{
    scanf("%d",&N);
    dfs(0,0);
    printf("%d\n",count);
    return 0;
}
void dfs(long long nextNum,unsigned char flag357)
{
    if(nextNum<=N)
    {
        if(flag357==07)    // 07 is BIN 111
            count++;
        dfs(nextNum*10+3,flag357|01); // BIN 001
        dfs(nextNum*10+5,flag357|02); // BIN 010
        dfs(nextNum*10+7,flag357|04); // BIN 100
    }
}

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

using namespace std;

typedef long long int ll;

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

// 最小公倍数
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

int main(void){

    int a, b;
    cin >> a >> b;

    cout << (b > a? LCM(b,a) : LCM(a,b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int r;
  cin >> r;
  string ans;

  if(r < 1200)ans = "ABC";
  else if (r < 2800) ans = "ARC";
  else ans = "AGC";

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


Measured memory_bytes: 256
def calc(arr, n)
  (1...n).each{|i| arr[i] += arr[i-1] }
  arr
end
loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  l = n.times.map{ gets.to_i }
  k = m.times.map{ gets.to_i }
  list = [0] * ([l.reduce(:+), k.reduce(:+)].max + 1)
  res = 0
  (0...n).each do |i|
    arr = calc(l[i..-1], n - i)
    arr.each{ |v| list[v] += 1 }
  end
  (0...m).each do |i|
    arr = calc(k[i..-1], m - i)
    arr.each{ |v| res += list[v] }
  end
  p res
end

Measured memory_bytes: 38376
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible"<<endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: Vec<char> = iterator.next().unwrap().chars().collect();

    for i in 0..(n.len() / 2) {
        if n[i] != n[n.len() - 1 - i] {
            return "No".to_string();
        }
    }

    return "Yes".to_string();
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    K = min(K, sz(S));
    rep(i, K) cout << S[i];
    if (sz(S) > K) puts("...");
    return 0;
    // ll, 0, -, 1i, for s&g
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
	"sort"
	"strings"
)

type Alphabetic []string

func main() {
	var n, cnt int
	fmt.Scan(&n)

	s := make(Alphabetic, n)
	for i := range s {
		var w string
		fmt.Scan(&w)
		s[i] = sortString(w)
	}
	sm := make(map[string]int)

	for i := 0; i < len(s); i++ {
		str := s[i]
		n := sm[str]
		if n != 0 {
			cnt += n
		}
		sm[str]++
	}

	fmt.Println(cnt)
}

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        int x,y;cin>>x>>y;
        x=abs(x);
        y=abs(y);
        
        int b=x*x+y*y;
        
        int cnt=0;
        
        for(int i=-max(x,y);i<=max(x,y);i++){
            for(int j=-max(x,y);j<=max(x,y);j++){
                int a=i*i+j*j;
                if(a==0) continue;
                
                int s=abs(i*x+j*y),t=abs(i*y-j*x);
                
                if(gcd(s,t)%a==0&&b%a==0) cnt++;
                
                if(cnt>=9) break;
            }
        }
        
        if(cnt==8) cout<<"P"<<endl;
        else cout<<"C"<<endl;
        
        //cout<<cnt<<endl;
    }
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int n,d; cin>>n>>d;
  int count=0;
  for(int i=0;i<n;i++){
    int x,y; cin>>x>>y;
    if(x*x+y*y<=d*d)
      count++;
  }
  cout<<count<<endl;
}



Measured memory_bytes: 3632
import copy

N = int(input()) 
s = list(map(int, input().split()))
s2 = copy.deepcopy(s)
s.sort()
n = 0
for i in range(0, len(s)):
    if s[i] - s2[i] != 0:
        #print(s[i], s2[i])
        n+=1

if n == 2:
  print("YES")
elif n == 0:
    print("YES")
else:
  print("NO")

Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>
#define maxn 200010
#define mod 2019
#define LL long long
char s[maxn];
int cnt[mod];
LL ans;
int main(){
	int n,i,x,y;
	scanf("%s",s+1);
	n=strlen(s+1),y=1,x=0;
	for(i=n;i>=1;i--){
		x=(x+(s[i]-'0')*y)%mod;
		y=y*10%mod;
		cnt[x]++;
	}
	for(i=1;i<2019;i++)
		if(cnt[i]>1)ans+=(LL)(cnt[i]-1+1)*(cnt[i]-1)/2;
	ans+=(LL)cnt[0]*(cnt[0]+1)/2;//特殊余数处理
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3388
#include<bits/stdc++.h>
using namespace std;
int n,q,a,b,c;
typedef pair<int,int>P;
main(){
	cin>>n;
	vector<P>v(n);
	for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)cout<<v[i].first<<' '<<v[i].second<<endl;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int P = Integer.parseInt(tokens[1]);

		P += A * 3;
		System.out.println((P / 2));
		in.close();
	}

}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;
  int ans = 0;
  rep(i, 6){
    if(s[i] == '1') ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int n, m, v;
	int A[100][100], b[100];
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> v;
			A[i][j] = v;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> v;
		b[i] = v;
	}

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}


	return 0;
}


Measured memory_bytes: 3144
#include<stdio.h>
#include<stdlib.h>
#define N 100
int main(){
  int n,i,u,v,j,k;
  int A[N][N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d",A[i][0]);
    for(j=1;j<n;j++){
      printf(" %d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

int main(){
    int n,m;
    int h=0,x;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>x;
        h=h+x;
    }
    if(h>=n)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
H,W,K=map(int,input().split())

#横棒設置可能箇所（目的とする縦棒に関与しない）がi本であるときに，横棒を置ける通り数
a=[1]*max((W-1),1)
for i in range(W-1):
    a[i]+=i#横線を1本引く
    if i-2>0:#2本引く
        a[i]+=((i-1)*(i-2))//2
        if i==5:#3本引く
            a[i]+=1
        elif i==6:#3本引く*4パターン
            a[i]+=4
    
mod=10**9+7    

#高さiまででj番目の通り数
dp=[[0]*W for _ in range(H+1)]
dp[0][0]=1#高さ0では1に行けるのが1通り

for i in range(H):
    for j in range(W):
        for k in range(-1,2,1):#両隣+自身
            if j+k>=0 and j+k<W:
                l=min(j,j+k)
                r=max(j,j+k)
                dp[i+1][j+k]+=dp[i][j]*a[max(0,l-1)]*a[max(0,(W-1)-r-1)]#通り数*左の冗長*右の冗長
                dp[i+1][j+k]%=mod
                
print(dp[-1][K-1])



Measured memory_bytes: 39792
#include<iostream>
using namespace std;
int main(){
  int a,b,t,gTotal;
  cin >> a >> b >> t;
  gTotal = 0;
  if(a <= t){
    for(int i = 0; i <= t - a + 0.5; i+= a){
   		gTotal += b;
    }  
  }else{
    gTotal = 0;
  }
  cout << gTotal;
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i <= 1e7; i++) 
    if(i * 108/100 == n)
      return cout << i, 0;
  cout << ":(";

    

  
}



Measured memory_bytes: 3592
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif

        int n, d, x;
        cin >> n >> d >> x;
        vector<int> a(n);
        rep(i, n)cin >> a[i];
        rep(i, n) {
            x += ceil(double(d) / a[i]);
        }
        cout << x << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
while 1:
    n=int(input())
    if n==0:
        break
    D=[]
    for i in range(n):
        l,p,a,b,c,d,e,f,s,m=input().split()
        p,a,b,c,d,e,f,s,m=map(int,(p,a,b,c,d,e,f,s,m))
        D.append(((s*f*m-p)/((d+e)*m+a+b+c),l))
    D=sorted(D,key=lambda x:(-x[0],x[1]))
    for i in range(n):
        print(D[i][1])
    print('#')


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

typedef unsigned long long ull;
typedef unsigned long ul;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long a, b, w, p, q;
	cin >> w >> a >> b;
	if (b < a) swap(a, b);
	p = a+w;
	q = b+w;

	if (a >= b && b <= p) {
		cout << 0  << endl;
	} else if (b <= p) {
                    cout << 0 << endl;
	} else {
		cout << b-p << endl;
	}

	return 0;
}


Measured memory_bytes: 256