akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int k = 0;
	long long curr = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		while (k <= i) {
			curr += a[k++];
		}
		while (k < n && a[k] <= curr * 2) {
			curr += a[k++];
		}
		if (k == n) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef pair<int,int> Paint;
bool pairSecond(const Paint& pf,Paint&ps){
  if(pf.first == ps.first){
    return pf.second < ps.second;
  }else{
    return pf.first < ps.first;
  }
}
int main(){
  int n;cin>>n;
  vector<Paint> a(n);
  cout << fixed << setprecision(10);
  for(int i = 0; n  > i; i++){
    cin>>a[i].first >> a[i].second;
  }
  sort(a.begin(),a.end(),pairSecond);
  int sm = 0;
  double ans = 0.0;
  do{

    for(int i = 1; n > i; i++){
      ans += (double)sqrt((a[i-1].first-a[i].first)*(a[i-1].first-a[i].first)+(a[i-1].second-a[i].second)*(a[i-1].second-a[i].second));
      //cout << ans << endl;
    }

    sm++;
  }while(next_permutation(a.begin(),a.end()));
  cout << ans/sm << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long x = sc.nextInt();
		long m = sc.nextInt();
		List<Long> list = new ArrayList<Long>(); 
		Set<Long> set = new HashSet<Long>();
		boolean exist = false;
		long now = x;
		int loopst = 0;
		int loopfin = 0;
		long last = 0;
		list.add(now);
		set.add(now);
		for (long i = 0; i < n; i++) {
            now = now * now % m;
            if (set.contains(now)) {
                last = now;
                break;
            } else {
                set.add(now);
                list.add(now);
            }
        }
		for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == last) {
                loopst = i;
            }
        }
		//ループが始まる前の和
		long sumbef = 0;
		for(int i = 0; i < loopst; i++) {
			sumbef+=list.get(i);
		}
		//ループ内のA_nの和
		long sumloop = 0;
		for(int i = loopst; i < list.size(); i++) {
			sumloop+=list.get(i);
		}
		long loopnum = list.size() - loopst;
		long block = (n-loopst)/loopnum;
		sumloop*=block;
		//ループのあまり分の和
		long summod = 0;
		long loopmod = (n-loopst)%(list.size()-loopst);
		for(int i = 0; i < loopmod; i++) {
			summod+=list.get(loopst+i);
		}
		long ans = sumbef + sumloop+ summod;
		System.out.println(ans);
	}
}

Measured memory_bytes: 44660
#include<bits/stdc++.h>
using namespace std;
inline void max_self(long long &a, long long b){
	a = max(a,b);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, w;
	cin>>n>>w;
	long long val, wt;

//	for (int i=0; i<n;i++)cin>>wt[i]>>val[i];

	long long dp[2][w+1];
	for (int i=0;i<=w;i++)dp[0][i]=0;
	dp[1][0]=0;
	

	for (int i=1; i<=n; i++){	
		cin>>wt>>val;
		for (int weight=1; weight<=w; weight++){

			dp[i%2][weight] = dp[(i-1)%2][weight];

			if(weight >= wt){
				max_self(dp[i%2][weight], val + dp[(i-1)%2][weight- wt]);
			}
		}
	}

	cout<<dp[(n)%2][w];

	return 0;
};


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> v_cnt(n + 1, 0);
  for (int i = 0; i < n - 1; ++i) {
    int idx;
    cin >> idx;
    v_cnt[idx]++;
  }

  for (int i = 1; i < v_cnt.size(); ++i) {
    cout << v_cnt[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)    cin>>a[i];
    vector<bool> dp(k+1,false);
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0 && dp[i-a[j]]==false){
                dp[i] = true;
                break;
            }
        }
    }
    if(dp[k])   cout<<"First"<<endl;
    else    cout<<"Second"<<endl;
}


Measured memory_bytes: 256
# 奇数は偶数個->偶数を除いたときに偶数なら公約数が２になる
import math
import collections
N = int(input())
# for N in range(20000, 2, -1):
ans = [2, 3, 25]
if N <= 1003:
    ans += [i for i in range(30, (N-3)*30+1, 30)]
    # print(*ans)
else:

    D = N - len(ans)
    for i in range(12, min(30000, (D//10)*20) + 1, 30):
        ans.append(i)
        ans.append(i+2)
        ans.append(i+4)
        ans.append(i+6)
        ans.append(i+8)
        ans.append(i+10)
        ans.append(i+12)
        ans.append(i+14)
        ans.append(i+16)
        ans.append(i+18)
    count = 0
    d = N - len(ans)
    for i in range(32, min(30000, (D//5)*10) + 1, 30):
        if i + 30 > min(30000, (D//5)*10) and (d - count*5) % 2 == 0:
            break

        count += 1
        ans.append(i)
        ans.append(i+2)
        ans.append(i+4)
        ans.append(i+6)
        ans.append(i+8)

    d = N - len(ans)
    # if d == 0:
    for i in range(33, min(30000, (d//4)*30 + 30)+1, 30):
        ans.append(i)
        ans.append(i+6)
        ans.append(i+18)
        ans.append(i+24)
    d = N - len(ans)
    for i in range(15, min(30000, (d//2)*60)+1, 60):
        ans.append(i)
        ans.append(i+30)

    d = N - len(ans)
    for i in range(325, min(30000, (d//2 - 1)*300 + 325)+1, 300):
        ans.append(i)
        ans.append(i+100)

print(*sorted(ans[:N]))
# S = sum(ans[:N])
# s = S
# t = 0
# while(S > 0):
#     t += S % 10
#     S //= 10
# k = collections.Counter(ans[:N]).most_common()

# if t % 3 != 0 or s % 10 != 0 or len(ans) < N or k[0][1] > 1:
#     print(ans[:N])
#     print(t, s, len(ans), N)
#     print(k[0])
#     break
# else:
#     print(N, t, s, len(ans))


Measured memory_bytes: 10600
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int migi = S%100;
    int hidari = (S-migi)/100;
    
    if(migi==0 && hidari==0) {
    	System.out.println("NA");
    }else if(hidari>12 && migi>12) {
    	System.out.println("NA");
    }else if(hidari>12 && migi==0) {
    	System.out.println("NA");
    }else if(hidari==0 && migi>12) {
    	System.out.println("NA");
    }else if(hidari>0 && hidari<=12 && migi>0 && migi<=12) {	
    System.out.println("AMBIGUOUS");
    }else if(hidari>0 && hidari<=12 && migi>12) {	
    System.out.println("MMYY");
    }else if(hidari>0 && hidari<=12 && migi==00) {	
        System.out.println("MMYY");
    }else {
    System.out.println("YYMM");
    }
}
}


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

int main() {
	string S;
	cin >> S;
	int val = 0;
	for (int i=0;i<S.length();i++) {
		val += (int)S[i]-(int)'0';
	}

	if (val%9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a[6];
	forn(i,1,5){
		cin>>a[i];
		if(a[i]==0) cout<<i<<"\n";
	}
}

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

signed main(){

    char c[3] = {'A', 'B', 'C'};
    vector<pair<int, char> > v(3);
    for(int i = 0; i < 3; i++){
        int x; cin >> x;
        v[i] = {x, c[i]};
    }

    sort(v.begin(), v.end());
    cout << v[2].second << endl;
    
    return 0;
}


Measured memory_bytes: 3140
n = gets.to_i
d = gets.split.map(&:to_i)
m = gets.to_i
t = gets.split.map(&:to_i)
h = Hash.new(0)
g = Hash.new(0)
n.times do |i|
  h[d[i]] += 1
end
m.times do |i|
  g[t[i]] += 1
end
f = true
g.each_key do |k|
  if h[k] < g[k]
    f = false
    break
  end
end
puts (f) ? "YES" : "NO"

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

int main() {
  int n, m , c, ans, evaluation;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep (i, m) {
    cin >> b.at(i);
  }
  vector<vector<int>> a(n, vector<int>(m));
  rep (i, n) {
    rep (j, m) {
      cin >> a.at(i).at(j);
    }
  }
  ans = 0;
  rep (i, n) {
    evaluation = c;
    rep (j, m) {
      evaluation += a.at(i).at(j) * b.at(j);
    }
    if (evaluation > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] ps;

    private void solve() {
        N = nextInt();
        ps = new int[N];
        for(int i = 0;i < N;i++) {
            ps[i] = nextInt();
        }

        int max = Arrays.stream(ps).max().getAsInt();
        int sum = Arrays.stream(ps).sum();
        out.println(sum - max / 2);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


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

int n;
vector<int> et[25];
int root_id;
int parent[25];
int depth[25];
int height[25];

void input() {
	bool is_root[25];
	cin >> n;
	for (int i = 0; i < n; i++) is_root[i] = true;
	for (int i = 0; i < n; i++) {
		int id, left, right;
		cin >> id >> left >> right;
		if (left >= 0)  { et[id].push_back(left);  is_root[left] = false; }
		if (right >= 0) { et[id].push_back(right); is_root[right] = false; }
	}
	for (int i = 0; i < n; i++) {
		if (is_root[i]) {
			root_id = i;
			break;
		}
	}
}

int dfs(int p, int v, int dep = 0) {
	parent[v] = p;
	depth[v] = dep;
	for (int i = 0; i < et[v].size(); i++) {
		height[v] = max(height[v], dfs(v, et[v][i], dep + 1) + 1);
	}
	return height[v];
}

int main() {
	input();
	dfs(-1, root_id);
	
	for (int i = 0; i < n; i++) {
		int sibling;
		if (i == root_id || et[parent[i]].size() <= 1) sibling = -1;
		else if (et[parent[i]][0] == i) sibling = et[parent[i]][1];
		else sibling = et[parent[i]][0];
		
		char *type;
		if (i == root_id) type = "root";
		else if (et[i].size() == 0) type = "leaf";
		else type = "internal node";
		
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, parent[i], sibling, et[i].size(), depth[i], height[i], type);
	}
	return 0;
}

Measured memory_bytes: 3268
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int n;
  int cnt =0;
  cin >> n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
      cin >> num.at(i);
  }
  for(int i=1;i<n-1;i++){
      if(num.at(i)<num.at(i+1)&&num.at(i)>num.at(i-1)){
          cnt++;
      }
      if(num.at(i)>num.at(i+1)&&num.at(i)<num.at(i-1)){
          cnt++;
      }
  }
  
  cout << cnt << endl;

}


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

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int a[MAX],b[MAX],c[MAX],n;
int dp[MAX][5];
bool vis[MAX][5];
// 0-A
// 1-B
// 2-C
int solve(int i,int last){
	if(i==n)return 0;
	if(vis[i][last])return dp[i][last];
	vis[i][last]=1;
	int ans=0;
	for(int j=0;j<3;j++){
		if(j!=last){
			if(j==0){
				ans=max(ans,a[i]+solve(i+1,j));
			}
			if(j==1){
				ans=max(ans,b[i]+solve(i+1,j));
			}
			if(j==2){
				ans=max(ans,c[i]+solve(i+1,j));
			}
		}
	}
	return dp[i][last]=ans;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	cout << solve(0,-1);
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    unordered_set <int> mp;
    mp.insert(a);
    mp.insert(b);
    mp.insert(c);
    if(mp.size()==2)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e5+5;

int a[N],b[N],p,n;

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	n=read();
	Rf(i,1,n) {
		a[i]=read();
		if(p) b[1]-=a[i];
		else b[1]+=a[i];
		p^=1;
	}
	write(b[1]);
	Rf(i,2,n) {
		putchar(' ');
		b[i]=a[i-1]*2-b[i-1]/2*2;
		write(b[i]);
	}

    return 0;
}


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

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

    for(;;N++) {
        bool ans = true;

        string s = to_string(N);

        rep (i, s.size() - 1) ans &= s[i] == s[i + 1];

        if (ans) {
            cout << N << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
int main(){
	int H,W,K;
	std::cin>>H>>W>>K;
	std::vector<std::vector<int>> C(H,std::vector<int>(W));
	for(int i=0;i<H;i++){
		std::cin.ignore();
		for(int j=0;j<W;j++){
			char tmp;
			std::cin.get(tmp);
			if(tmp=='.'){
				C[i][j]=0;
			}else{
				C[i][j]=1;
			}
		}
	}
	int ans=0,pattern=0,now=0;
	while(pow(2,H+W)>pattern){
		now=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((0!=(int)(pattern/pow(2,i))%2)&&(0!=(int)(pattern/pow(2,H+j))%2)&&C[i][j]==1){
					now++;
				}
			}
		}
		if(now==K){
			ans++;
		}
		pattern++;
	}
	std::cout<<ans;
	return 0;
}


Measured memory_bytes: 4112
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int n,a[1000005],hcf,pc,sc,nc;
bool prime[1000005];
map<int,int>tim;
int main(){
    for(int i=1;i<=1e6;i++)
        prime[i]=1;
    prime[1]=0;
    for(int i=2;i<1e6;i++)
        for(int j=2;i*j<=1e6;j++)
            prime[i*j]=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(int j=2;j<=a[i];j++){
            if(a[i]%j==0)
                tim[j]++;
            while(a[i]%j==0)
                a[i]/=j;
            if(prime[a[i]]){
                tim[a[i]]++;
                break;
            }
        }
    }
    for(int i=2;i<=1e6;i++){
        if(tim[i]==n){
            nc=1;
            sc=0;
            break;
        }
        if(tim[i]>1){
            sc=1;
        }
    }
    if(nc)
        printf("not coprime");
    else if(sc)
        printf("setwise coprime");
    else
        printf("pairwise coprime");
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second

const int mov[4][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<vector<int>> dp(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			dp[i][j] = min({ i, j, n-i-1, n-j-1 });

	int ans = 0;
	vector<vector<int>> alive(n, vector<int>(n, 1));
	for (int w = n*n, x, i, j; w--; )
	{
		cin >> x;
		--x;
		i = x / n;
		j = x % n;

		ans += dp[i][j];
		alive[i][j] = 0;

		queue<pair<int, int>> q;
		q.push({ i, j });

		while (!q.empty())
		{
			tie(i, j) = q.front();
			q.pop();

			int mn = dp[i][j] + alive[i][j];
			for (int k = 0; k < 4; ++k)
			{
				int ni = i + mov[k][0], nj = j + mov[k][1];
				if (ni >= 0 && ni < n && nj >= 0 && nj < n && mn < dp[ni][nj])
				{
					dp[ni][nj] = mn;
					q.push({ ni, nj });
				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5568
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let op = read::<String>();
    let op = op.chars().collect::<Vec<char>>()[0];
    let B = read::<i32>();

    if op == '+' {
        println!("{}", A + B);
    } else {
        println!("{}", A - B);
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    if (N == 3)
    {
        cout << "2 5 63" << endl;
        return 0;
    }

    vector<int> v;
    //! 3の倍数を偶数個入れられるだけ入れる
    ll t = std::min((ll)5000, (N - 2) - (N - 2) % 2);
    REP(i, t)
    {
        v.push_back(3 + 6 * i);
    }
    REP(i, (N - t) / 2)
    {
        if (2 * (i + 1) != 15000)
            v.push_back(2 * (i + 1));
        v.push_back(30000 - 2 * (i + 1));
    }
    if (N > v.size())
    {
        v.push_back(30000);
    }
    REP(i, N)
    {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

signed main(){
    int n;
    cin >> n;
    vector<int> a(3, 0);
    rep(n){
        int tmp;
        cin >> tmp;
        if(tmp % 4 == 0) a[2]++;
        else if(tmp % 2 == 0) a[1]++;
        else a[0]++;
    }

    if(a[0] == 0){
        cout << "Yes";
        return 0;
    }

    a[0]--;
    int last = 0;
    rep(n-1){
        if(last == 0){
            if(a[2] > 0){
                a[2]--;
                last = 2;
            }else{
                cout << "No";
                return 0;
            }
        }else if(last == 1){
            if(a[1] > 0){
                a[1]--;
                last = 1;
            }else if(a[2] > 0){
                a[2]--;
                last = 2;
            }else{
                cout << "No";
                return 0;
            }
        }else{
            int flag = 0;
            rep(3){
                if(a[i] > 0){
                    a[i]--;
                    last = i;
                    flag = 1;
                    break;
                }
            }
            if(!flag){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

#include<math.h>
using namespace std;


int main(){
    int N,D,count=0;
    cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>X[i][j];
        }
        cout<<'\n';
    }
    int sum;
    double a;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            sum=0;
            for(int k=0;k<D;k++){
                sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            a= sqrt((double)sum);
            if(a==(int)a)count++;
        }
    }
    cout<<count;

}

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

  int N, K, i;
  cin >> N >> K;
  
  int sum=1,sum1=0, sum2=0;
  
  for(i=0;i<N;i++){
    sum1 = sum*2;
    sum2 = sum+K;
    if(sum1 > sum2){sum = sum2;}
    else{sum = sum1;}    
  }
  
  cout << sum << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<pair<string,int>> s(n);
	rep(i,n){
	    cin>>s[i].first>>s[i].second;
	}
	string st;
	cin>>st;
	int ans=0;
	rep(i,1,n){
	    if(ans!=0||st==s[i-1].first){
	        ans+=s[i].second;
	    }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# 解説放送
# 写経

def main():
    from itertools import islice

    inf = 18 * (10 ** 6 + 1)

    s = '0' + input()
    n = len(s)

    s = map(int, reversed(s))  # 先に一括でintにした

    dp = [[inf] * 2 for _ in range(n + 1)]
    dp[0][0] = 0

    for i, c in enumerate(islice(s, 0, n, 1)):
        for j in range(2):
            x = c + j
            if x < 10:
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + x)  # a=x,b=0
            if x > 0:
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + (10 - x))  # a=0,bに繰り下がり

    print(dp[n][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 139636
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
	long A, B, C, ans = 0;
	cin >> A >> B >> C;
	if (A + B < C) {
		ans += A + B;
		ans += B;
		++ans;
	}
	else {
		ans += C;
		ans += B;
	}
	cout << ans;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()
grid=[]
for i in range(H):
    grid.append(list(input()))

L=list2d(H, W, 0)
R=list2d(H, W, 0)
D=list2d(H, W, 0)
U=list2d(H, W, 0)

for i in range(H):
    cnt=0
    for j in range(W):
        if grid[i][j]=='#':
            cnt=0
        else:
            cnt+=1
        L[i][j]=cnt
    cnt=0
    for j in range(W-1, -1, -1):
        if grid[i][j]=='#':
            cnt=0
        else:
            cnt+=1
        R[i][j]=cnt

for i in range(W):
    cnt=0
    for j in range(H):
        if grid[j][i]=='#':
            cnt=0
        else:
            cnt+=1
        D[j][i]=cnt
    cnt=0
    for j in range(H-1, -1, -1):
        if grid[j][i]=='#':
            cnt=0
        else:
            cnt+=1
        U[j][i]=cnt

ans=0
for i in range(H):
    for j in range(W):
        if grid[i][j]!='#':
            ans=max(ans, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)


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

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

int main(){
    int a, p;
    scanf("%d%d", &a, &p);
    printf("%d\n", (a*3+p)/2);
}

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

int main() {
    int n, l;
    cin >> n >> l;
    string S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    sort(S, S+n);
    for(int i = 0; i < n; i++){
        cout << S[i];
    }
    cout << endl;
    return 0;
    
}



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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    string ans1 = "", ans2 = "";
    for(int i = 0; i < b; ++i){
        ans1 += to_string(a);
    }
    for(int i = 0; i < a; ++i){
        ans2 += to_string(b);
    }
    if(ans1 >= ans2) cout << ans2 << endl;
    else cout << ans1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int dp[405][405];
#define INF 1e18+5
signed main()
{ 
          int n;
          cin>>n;
          int arr[n+1];
         vector<int>presum(n+1);
         
          for(int i=1;i<=n;i++) 
          {cin>>arr[i];
          presum[i]=presum[i-1]+arr[i];
          }
          
          for(int l=2;l<=n;l++)
             {
                       for(int i=1;i<=(n-l+1);i++)
                       {      
                                 int j=i+l-1;
                                 dp[i][j]=INF;
                                 for(int pos=i;pos<j;pos++)
                                 {
                                           dp[i][j]=min(dp[i][j],dp[i][pos]+dp[pos+1][j]+presum[j]-presum[i-1]);
                                 }
                       }
             }
             cout<<dp[1][n]<<"\n";
          
}




Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    a, b, c, d = MI()

    for i in range(1000000):
        c -= b
        if c <= 0:
            print('Yes')
            return
        a -= d
        if a <= 0:
            print('No')
            return


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	ll a, b,c,d;
	cin >> a >> b >> c >> d;

	ll lcm = c*d/gcd(c,d);
	ll ans = b - a + 1;
	ans -= b/c;
	ans += (a-1)/c;
	ans -= b/d;
	ans += (a-1)/d;
	ans += b/lcm;
	ans -= (a-1)/lcm;

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


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    for(int i=0; i<N; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(auto& x : v) {
        cout << x;
    }
    cout << endl;
}


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

int main(){
    int n, m;

    cin >> n >> m;
    vector<int> city(n, 0);

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        city[a - 1]++;
        city[b - 1]++;
    }

    for(int i = 0; i < n; i++){
        cout << city[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool ok[100000009],ok2;
long long n,m,i,k,l1,l2,ans[100000009];
vector<long long> v[10000009];
queue<int> j;
void bfs(queue<int> q)
{
	long long z,i,k;
		z=q.size();
		while(!q.empty())
		{
			for(k=1;k<=z;k++)
			{
				for(i=0;i<v[q.front()].size();i++)
				{
					if(ok[v[q.front()][i]]==false) 
					{
						ans[v[q.front()][i]]=q.front();
						ok[v[q.front()][i]]=true;
						q.push(v[q.front()][i]);
					}
				}
				q.pop();
			}
		}
}
int main()
{
	cin>>n>>m;
	for(k=1;k<=m;k++)
	{
		cin>>l1>>l2;
		v[l1].push_back(l2);
		v[l2].push_back(l1);
	}
	j.push(1);
	bfs(j);
	for(k=1;k<=n;k++)
	{
		if(ok[k]==false) 
		{
			ok2=true;
			break;
		}
	}
	if(ok2==true)
	{
		cout<<"No";
		return 0;
	}
	else
	{
		cout<<"Yes"<<endl;
		for(k=2;k<=n;k++)
		{
			cout<<ans[k]<<endl;
		}
	}
}

Measured memory_bytes: 244872
#include <iostream>
#include <set>
#define int long long
using namespace std;
set<int>s;
int n, p, c = 1;
signed main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> p; s.insert(p); }
	cin >> n; for (int i = 0; i < n; i++) { cin >> p; if (!s.count(p))c = 0; }
	cout << c << endl;
}


Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, k;
  cin >> m >> k;
  
  if (k == 0) {
    for (int i=0; i<(1<<m); ++i) {
      cout << i << ' ' << i << ' ';
    }
    cout << endl;
  } else if (m == 1 || (1<<m) <= k) {
    cout << -1 << endl;
  } else {
    cout << 0 << ' ' << k << ' ' << 0 << ' ';
    for (int i=1; i<(1<<m); ++i) {
      if (i != k) cout << i << ' ';
    }
    cout << k << ' ';
    for (int i=(1<<m)-1; i>0; --i) {
      if (i != k) cout << i << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn merge(a: &mut [i32], left: usize, mid: usize, right: usize) -> i32{
    let n1 = mid - left;
    let n2 = right - mid;
    let mut l = vec![0; n1];
    let mut r = vec![0; n2];
    l.copy_from_slice(&a[left..mid]);
    r.copy_from_slice(&a[mid..right]);
    l.push(std::i32::MAX);
    r.push(std::i32::MAX);
    let mut i = 0;
    let mut j = 0;
    let mut cnt = 0;
    for k in left..right {
        cnt+=1;
        if l[i] <= r[j] {
            a[k] = l[i];
            i += 1;
        } else {
            a[k] = r[j];
            j += 1;
        }
    }
    cnt
}

fn merge_sort(a: &mut[i32], left: usize, right: usize) -> i32{
    let mut cnt = 0;
    if left + 1 < right {
        let mid = (left + right) / 2;
        cnt += merge_sort(a, left, mid);
        cnt += merge_sort(a, mid, right);
        cnt += merge(a, left, mid, right);
    }
    cnt
}

fn main() {
    let mut sc = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = sc.next();
    let mut a = Vec::new();
    for _ in 0..n {
        let x: i32 = sc.next();
        a.push(x);
    }
    let cnt = merge_sort(&mut a[..], 0, n);
    let a = a.iter().map(ToString::to_string).collect::<Vec<String>>().join(" ");
    writeln!(out, "{}", a).ok();
    writeln!(out, "{}", cnt).ok();
}



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

using namespace std;

int main() {
    string S;
    cin >> S;
    int x = 2000000, y = -1;
    for(int i = 0; i < S.length(); i++) {
        char c = S[i];
        if(c == 'A' && x == 2000000) {
            x = i;
        }
        if(c == 'Z') {
            y = i;
        }
    }
    cout << y - x + 1 << endl;
}


Measured memory_bytes: 644
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B,X;

void solve(){
    if(B > X - A && A <= X)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

int main(){
    cin >> A >> B >> X;

    solve();
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    l_n = [True] * n
    for i in range(m):
        a, b = map(int, input().split())
        if h[a-1] == h[b-1]:
            l_n[b-1] = False
            l_n[a-1] = False
        elif h[a-1] <= h[b-1]:
            l_n[a-1] = False
        elif h[a-1] >= h[b-1]:
            l_n[b-1] = False
    print(sum(l_n)) 

if __name__ == '__main__':
    main()

Measured memory_bytes: 20368
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <bitset>
#include <stack>
#include <queue>
using namespace std;

string s;

int main(void){
    cin >> s;
    long long int len = s.size();
    long long int ans = 0;
    for(long long int mask = 0; mask < (1LL << (len - 1)); mask++){
        long long int subnum = s[0] - '0';
        for(int i = 0; i < len - 1; i++){
            if(1 & (mask >> i)){
                ans += subnum;
                subnum = 0;
            }
            subnum = subnum * 10 + s[i+1] - '0';
        }
        ans += subnum;
    }
    cout << ans << endl;
    //printf("%d\n", ans);
    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double n,k,ma=-1,a=0,x,sum=0;
	int cnt1=0,cnt2=0;
	cin>>n>>k;
	vector<double>v(n),w(n);
	for(int i=0;i<n;i++){
		cin>>v.at(i);
		a+=v.at(i);
		if(cnt1>=k){
			a-=v.at(cnt2);
			cnt2++;
		}
		if(i>=k-1){
			if(a>=ma){
				ma=a;
				x=i-k+1;
			}
		}
		cnt1++;
	}
	for(double i=x;i<x+k;i++){
		sum+=(1/2.000000)*v.at(i)*(v.at(i)+1)/v.at(i);
	}
	cout<<fixed<<setprecision(12)<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3456
n=int(input())
dic={i:{j:2 for j in range(1,n+1)}for i in range(1,n+1)}
proof={k:0 for k in range(n+1)}
       
for i in range(1,n+1):
    a=int(input())
    for _ in range(a):
        x,y=map(int,input().split())
        dic[i][x]=y
                    
#dicに誰々が正直者か嘘つきであるかということをまとめるdic[x][y]=? xからｙは正直者あるいは真偽不明の者である

maxi=0

for _ in range(1,2**n): 
    #計算量 3* (10)**4
    choice=format(_,"0%ib"%n)
    #1が正直者,0がよくわからない人
    #正直者の発言が全て一致していなくてはいけない　それであれば、矛盾は生じない
    flag=True
    honest=[0 for _ in range(n+1)]
    for i in range(n):
        if choice[i]=="1":
            honest[i+1]=1
    for i in range(1,n+1):
      for j in range(1,n+1):
        if (i!=j and dic[i][j]==0 and honest[i] and honest[j]) or(i!=j and dic[i][j]==1 and honest[i] and (not honest[j])):
          flag=False
          break
         
    if flag:
      maxi=max(maxi,sum(honest))
      
      	

print(maxi)

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

using namespace std;

const int N = 1e5+7;
const int MOD = 1e9+7;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int _v) { this->v = _v; return *this; }
    Mint operator = (const long long _v) { this->v = static_cast<int>(_v%_MOD); return *this; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) { return Mint(v+b.v); }
    Mint operator - (const Mint &b) { return Mint(v-b.v); }
    Mint operator * (const Mint &b) { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) { return Mint(b.inv()*v); }
    Mint operator += (const Mint &b) { return *this = *this+b; }
    Mint operator -= (const Mint &b) { return *this = *this-b; }
    Mint operator *= (const Mint &b) { return *this = *this*b; }
    Mint operator /= (const Mint &b) { return *this = *this/b; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n;
int a[N], cnt[N];
mint res = 1;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    cnt[0] = 3;
    for (int i = 1; i <= n; ++i) {
        res *= cnt[a[i]];
        --cnt[a[i]];
        ++cnt[a[i]+1];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n,len,dp[2][2020];
string s;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    cin>>s;
    len=s.length();
    long long res=0;
    dp[0][(s[0]-'0')%2019]=1;
    for (int i=1;i<len;i++)
    {
        //cout<<dp[1][0]<<endl;
        for (int j=0;j<2019;j++)
        {
            dp[1][ ( j*10 + (s[i]-'0') ) % 2019 ]+=dp[0][j];
            //if (( j*10 + (s[i]-'0') ) % 2019==0) cout<<i<<" "<<j<<" "<<dp[0][403]<<endl;
        }
        res+=dp[1][0];
        //cout<<res<<endl;
        memcpy(dp[0],dp[1],sizeof(dp[1]));
        dp[0][(s[i]-'0')%2019]++;
        memset(dp[1],0,sizeof(dp[1]));
    }
    cout<<res;
    
}

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

int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    cout << "GREATER" << endl;
  } else if (a.size() < b.size()) {
    cout << "LESS" << endl;
  } else {  // a.size() = b.size(
    rep(i, a.size()) {
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        return 0;
      } else if (a[i] < b[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
  return 0;
}


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int n;

int main() {
	scanf("%d", &n);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i%3 == 0 || i%5 == 0) continue;
		ans += i;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorlonglong(vector<long long> * p, long long a){
    rep(i, a){
        long long input;
        cin >> input;
        p -> push_back(input);
    }
}

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


int main(int argc, const char * argv[]) {

    std::string inS;
    int N;
    N=inputValue();
    cin >> inS;

    const char *S = inS.c_str();
    int tmp = 0;
    for(int i=0;i<inS.size();i++){
        tmp = (unsigned char)S[i];
        tmp += N;
        if(tmp>90){
            tmp -= 26;
        }
        cout << (char)tmp;
    }
  cout <<endl;

    //cout << S << endl;
    return 0;
}

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

using ll = long long int;

const ll MAX = (ll)(1e13 + 5);

ll f(ll b, ll n) {
  if (n < b) {
    return n;
  }
  else {
    return f(b, floor(n / b)) + (n % b);
  }
}

ll n, s;

ll ans = MAX;

int main(void) {
  // Here your code !
  scanf("%lld", &n);
  scanf("%lld", &s);


  if (n == s) {
    printf("%lld\n", n + 1);
    return 0;
  }

  ll sqrtn = sqrt(n) + 1000;

  for (int b = 2; b < sqrtn; ++b) {
    if (s == f(b, n)) {
      printf("%lld\n", b);
      return 0;
    }
  }

  for (ll p = 1; p < sqrtn; ++p) {
    if ((s - n) % p != 0) continue;
    ll b = (n - s) / p + 1;
    if (b < 2) continue;

    if (s == (f(b , n))) {
      ans = min(ans, b);
    }
  }

  if (ans < MAX) printf("%lld\n", ans);
  else printf("%lld\n", (ll)(-1));

  return 0;
}

Measured memory_bytes: 256
lst=input().split()
lst=list(map(lambda i:float(i),lst))
x_1=lst[0]
x_2=lst[1]
y_1=lst[2]
y_2=lst[3]
dis=((x_1-y_1)**2+(x_2-y_2)**2)**(1/2)
print(dis)




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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

	string s;
	cin >> s;

	int cnt = 0;
	for (char c: s) {
		cnt += (c == 'o');
	}

	int need = 8 - cnt;
	if (need <= 15 - s.size()) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
    return 0;
}


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

int main() {
  int X;
  cin >> X;
  int H = X / 500 * 1000 + (X % 500) / 5 * 5;
  cout << H << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
void CountingSort(int);
#define MAX 2000001
#define VMAX 10000
int C[VMAX+1];
unsigned short *A, *B;
int main(){
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i < n;i++){
    scanf("%hd",&A[i]);
  }
  CountingSort(n);
  for(i = 1; i < n+1; i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}


void CountingSort(k){
  int i,j;
  for(i = 0 ;i <= VMAX;i++){
    C[i] = 0;
      }
  /* C[i] に i の出現数を記録する */
  for(j = 0; j < k; j++){
    C[A[j]]++;
      }
  /* C[i] に i 以下の数の出現数を記録する*/
  for (i = 1; i < VMAX; i++){
    C[i] = C[i] + C[i-1];
      }
  for(j = k-1 ; j >= 0; j--){
    B[C[A[j]]] = A[j];
      C[A[j]]--;
      }

}



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

using namespace std;

#define ldouble long double
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong x, y;
    cin >> x >> y;

    llong ans = 0;
    if (x < y) {
        if (x >= 0 && y >= 0) {
            ans = y - x;
        } else if (x < 0 && y >= 0) {
            if (y >= abs(x)) ans = y + x + 1;
            else ans = abs(x + y) + 1;
            if (y == 0) --ans;
        } else {
            ans = y - x;
        }
    } else if (x > y) {
        if (x >= 0 && y >=0) {
            ans = x - y + 2;
            if (y == 0) --ans;
        } else if (x >= 0 && y < 0) {
            ans = abs(x + y) + 1;
        } else {
            ans = abs(y) - abs(x) + 2;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N,i;
    cin  >> N;
    double v[N];
    for(i=0; i<N; i++){
        cin >> v[i];
    }

    sort(v, v+N);

    for(i=0; i<N-1; i++){
        v[i+1] = (v[i] + v[i+1])/2;
    }

    cout << v[N-1] << endl;
    return 0;
}

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

typedef long long ll;

string s,rs="",s1="",s2="",rs1="",rs2="";
bool can=false;
ll n;
int main(){
	cin>>s;
	n=s.length();
	for(int i=n-1;i>=0;i--){
		rs+=s[i];
	}
	for(int i=0;i<(n-1)/2;i++){
		s1+=s[i];
	}
	for(int i=((n-1)/2)-1;i>=0;i--){
		rs1+=s[i];
	}
	for(int i=((n+3)/2)-1;i<n;i++){
		s2+=s[i];
	}
	for(int i=n-1;i>=((n+3)/2)-1;i--){
		rs2+=s[i];
	}
	if(s==rs&&s1==rs1&&s2==rs2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256