akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{

  ll a, b, h, m;
  cin >> a >> b >> h >> m;

  double btheta = m * (2 * M_PI / 60);
  double bx = cos(btheta) * b;
  double by = sin(btheta) * b;
  double atheta = (h * 30 + m * 0.5) * (M_PI / 180.0);
  double ax = cos(atheta) * a;
  double ay = sin(atheta) * a;

  double d = sqrt(pow(bx - ax, 2) + pow(by - ay, 2));
  cout << setprecision(20) << d << endl;
  return 0;
}


Measured memory_bytes: 4160
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n,a,s;
	s=0;
	cin>>n;
	a=n;
	for (int i=100000000;i>=1;i/=10){
		if (n>=i){
			s+=a/i;
			a=a%i;
		}
	}
	if (n%s==0){
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


set<int> SET;

int main(){

	int num_query;
	scanf("%d",&num_query);

	int command;
	int x,L,R;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){

		case 0:

			scanf("%d",&x);
			SET.insert(x);
			printf("%lld\n",SET.size());
			break;

		case 1:

			scanf("%d",&x);
			printf("%lld\n",SET.count(x));
			break;

		case 2:

			scanf("%d",&x);
			SET.erase(x);
			break;

		case 3:

			scanf("%d %d",&L,&R);

			auto at = SET.lower_bound(L);

			while(at != SET.end() && *at <= R){

				printf("%d\n",*at);
				at++;
			}

			break;
		}
	}

	return 0;
}



Measured memory_bytes: 12500
#include <stdio.h>
#include <string.h>
int main(void) {
	char s[4];
	char day[7][4] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
	scanf("%s", &s);
	for (int i=0; i<7; i++) {
		if (strcmp(s, day[i]) == 0) {
			printf("%d", i+1);
			return 0;
		}
	}
	return 0;
}

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

int main()
{
  int n, a, b, ct = 0, gai = 0;
  string str;

  cin >> n >> a >> b >> str;
  int m = str.size();
  int c = a + b;
  for (int i = 0; i < m; i++){
    if (str[i] == 'a' && ct < c){
      cout << "Yes" << endl;
      ct++;
    }
    else if (str[i] == 'b' && ct < c && gai < b){
      cout << "Yes" << endl;
      ct++;
      gai++;
    }
    else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
#include <cstdio>
#include <set>
#include <numeric>
#include <algorithm>

typedef long long i64;

const int N = 200000 + 10;

int n, x[N], y[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &x[i], &y[i]);
  for (int i = 1; i <= n; ++i) if (x[i] > y[i]) std::swap(x[i], y[i]);
  std::multiset<int> a(x + 1, x + n + 1), b(y + 1, y + n + 1);
  static int id[N];
  std::iota(id, id + n + 1, 0);
  std::sort(id + 1, id + n + 1, [&] (int u, int v) { return y[u] < y[v]; });
  auto f = [&] { return ((i64)*a.rbegin() - *a.begin()) * (*b.rbegin() - *b.begin()); };
  i64 ans = f();
  for (int i = n; i > 0; --i) {
    int z = id[i];
    a.erase(a.find(x[z]));
    b.erase(b.find(y[z]));
    std::swap(x[z], y[z]);
    a.insert(x[z]);
    b.insert(y[z]);
    ans = std::min(ans, f());
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 23424
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
int choose(int n, int k){ 
    int C[k+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1; 
    for (int i = 1; i <= n; i++) { 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
signed main(){
    fastio
    int n , m ;
    cin >> n >> m ; 
    cout << choose(n, 2) + choose(m, 2) << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a,b,x;
    cin >> a>>b>>x;

    if(a <= x && x <= a+b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		Scanner sc=new Scanner(System.in);
		long a[]=new long[3],m[]=new long[3];
		long g1,g2,l1,l2,g3,l3;
		int i,count[]=new int[3];
		while(true){
			for(i=0;i<3;i++){
				a[i]=sc.nextLong();
				m[i]=sc.nextLong();
			}
			if(a[0]==0 && a[1]==0 && a[2]==0 && m[0]==0 && m[1]==0 && m[2]==0) break;
			for(i=0;i<3;i++){
				count[i]=mcount(a[i],m[i]);
			}
			
			g1=gcd(count[0],count[1]);
			l1=count[0]*count[1]/g1;
			
			g2=gcd(count[1],count[2]);
			l2=count[1]*count[2]/g2;
			
			g3=gcd(l1,l2);
			l3=l1*l2/g3;
			System.out.println(l3);
		}
	}
	static long gcd(long a,long b){
		if(b==0){
			return a;
		}
		else{
			return gcd(b,a%b);
		}
	}
	static int mcount(long a,long m){
		int count=0;
		long x=1;
		while(true){
			x=(a*x)%m;
			count++;
			if(x==1) break;
		}
		//System.out.println(count);
		return count;
	}

}

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

int main()
{
    int r;
    cin >> r;
    cout << r * r * 3 << endl;
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static int maxn = 200000;
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = info[0];
            int Q = info[1];
            List<int>[] edges = new List<int>[maxn + 1];
            for (int i = 0; i <= maxn ; ++i)
                edges[i] = new List<int>();
            long[] vrt = new long[maxn + 1];
            for (int i = 0; i < N - 1; ++i)
            {
                info = Console.ReadLine().Split().Select(int.Parse).ToArray();
                edges[info[0]].Add(info[1]);
                edges[info[1]].Add(info[0]);
            }

            for(int i = 0; i < Q; ++i)
            {
                info = Console.ReadLine().Split().Select(int.Parse).ToArray();
                vrt[info[0]] += info[1];
            }
            update_nodes(1, 0, vrt, edges, new bool[maxn + 1]);
            for (int i = 1; i <= N; ++i)
                Console.Write(vrt[i] + " ");

        }

        static void update_nodes(int vrt, long sm, long[] v, List<int>[] edges, bool[] mrk)
        {
            v[vrt] += sm;
            mrk[vrt] = true;
            for (int i = 0; i < edges[vrt].Count; ++i)
            {
                if (mrk[edges[vrt][i]])
                        continue;
                update_nodes(edges[vrt][i], v[vrt], v, edges, mrk);
            }
        }
    }
}


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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0;
  string s;
  cin >> n >> s;
  rep(i, n - 2) {
    string ss = s.substr(i, 3);
    if (ss == "ABC") ans++;
  }
  cout << ans;
  return 0;
}


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

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

int f(int x){
	int ret = 0;
	while(x != 0){
		ret += x%10;
		x /= 10;
	}
	return ret;
}

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

	int N; cin >> N;

	cout << ( N%f(N) == 0 ? "Yes" : "No" ) << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

struct dat {
    int y, x, d;
};

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

    int H, W, C[2], D[2];
    cin >> H >> W >> C[0] >> C[1] >> D[0] >> D[1];
    C[0]--, C[1]--;
    D[0]--, D[1]--;
    vector<vector<bool>> iswall(H, vector<bool>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            if (c == '#')
                iswall[i][j] = true;
        }
    }

    deque<dat> que;
    vector<vector<int>> dist(H, vector<int>(W, 1e8));
    que.push_front({C[0], C[1], 0});
    dist[C[0]][C[1]] = 0;
    int dy[] = {1, 0, -1, 0};
    int dx[] = {0, 1, 0, -1};
    while (!que.empty()) {
        auto [y, x, d] = que.front();
        que.pop_front();
        if (dist[y][x] < d)
            continue;
        for (int i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || nx < 0 || ny >= H || nx >= W)
                continue;
            if (iswall[ny][nx])
                continue;
            if (dist[ny][nx] <= dist[y][x])
                continue;
            dist[ny][nx] = dist[y][x];
            que.push_front({ny, nx, dist[ny][nx]});
        }

        for (int ny = y - 2; ny <= y + 2; ++ny) {
            for (int nx = x - 2; nx <= x + 2; ++nx) {
                if (ny < 0 || nx < 0 || ny >= H || nx >= W)
                    continue;
                if (iswall[ny][nx])
                    continue;
                if (dist[ny][nx] <= dist[y][x] + 1)
                    continue;
                dist[ny][nx] = dist[y][x] + 1;
                que.push_back({ny, nx, dist[ny][nx]});
            }
        }
    }

    cout << (dist[D[0]][D[1]] < 1e8 ? dist[D[0]][D[1]] : -1) << endl;

    return 0;
}


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

int main() {
    int d;
    long long n;
    cin >> d >> n;
    if (n == 100)
    {
        n++;
    }

    switch (d)
    {
    case 0:
        cout << n << endl;
        break;
    case 1:
        cout << n * 100 << endl;
        break;
    case 2:
        cout << n * 10000 << endl;
        break;
    default:
        break;
    }
}


Measured memory_bytes: 256
N = int(input())
ans = 0
ss = []
for _ in range(N):
    s = input()
    s = list(s)
    s.sort()
    s = "".join(s)
    ss.append(s)
ss.sort()
now = ss[0]
ruiseki = 0
for i in range(1,N):
    if ss[i] == now:
        ruiseki +=1
        ans += ruiseki
    else:
        ruiseki = 0
        now = ss[i]
print(ans)

Measured memory_bytes: 10612
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int arr[][] = new int [3][n];
		int count[] = new int [100002]; 
		
		for(int i = 0 ; i<n ; i++){
			arr[0][i] = scanner.nextInt();
		}
		for(int i = 0 ; i<n ; i++){
			arr[1][i] = arr[0][i]-1;
		}
		for(int i = 0 ; i<n ; i++){
			arr[2][i] = arr[0][i]+1;
		}
		
		for(int i = 0 ; i<3 ; i++){
			for(int j = 0 ; j<n ; j++){
				count[arr[i][j]+1]++;
			}
		}
		
		int max = 0;
		for(int i=0 ; i<count.length ; i++){
			if(count[i]>max){
				max = count[i];
			}
		}
		System.out.println(max);
		
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/16  Problem: ABC 076 D / Link: http://abc076.contest.atcoder.jp/tasks/abc076_d  ----- */


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

	LL N;
	cin >> N;
	vector<double> t(N);
	for (int i = 0; i < N; ++i) {
		cin >> t[i];
	}
	vector<double> limit_v(N);
	for (int i = 0; i < N; ++i) {
		cin >> limit_v[i];
	}

	vector<double>de_min(N + 1, 0);
	double now_v = 0;
	FOR(i, 0, N) {
		now_v = min(now_v + t[i], limit_v[i]);
		de_min[i + 1] = now_v;
	}
	de_min[N] = 0;
	now_v = 0;
	FORR(i, N - 1, 0 - 1) {
		now_v = min(now_v + t[i], limit_v[i]);
		de_min[i] = min(de_min[i], now_v);
	}

	double ans = 0;
	FOR(i, 0, N) {
		double virtual_v = max(de_min[i], de_min[i + 1]) + (t[i] - abs(de_min[i] - de_min[i + 1])) / 2;
		double virtual_s = (de_min[i] + virtual_v)*(virtual_v - de_min[i]) / 2 + (de_min[i+1] + virtual_v)*(virtual_v - de_min[i + 1]) / 2;
		if (virtual_v < limit_v[i])ans += virtual_s;
		else {
			ans += virtual_s - (virtual_v-limit_v[i])*(virtual_v - limit_v[i]);
		}
	}
	cout << fixed << setprecision(10) << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll a[1010];
ll b[1010];
ll dp[10010];
int main(){
	ll h,n;
	cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<=10000;i++)dp[i]=1000000000;
	dp[h]=0;
	for(int i=h;i>=1;i--){
		for(int j=0;j<n;j++){
			dp[max(0LL,i-a[j])]=min(dp[max(0LL,i-a[j])],dp[i]+b[j]);
//			cout<<max(0LL,i-a[j])<<" "<<dp[max(0LL,i-a[j])]<<endl;
		}
	}
	cout<<dp[0]<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n, m;
    cin>>n>>m;
    vector <int> s(m);
    vector <char> c(m);
    for(int i=0;i<m;i++){
        cin>>s[i]>>c[i];
    }
    int ans=-1;
    for(int i=0;i<1000;i++){
        string ss=to_string(i);
        if(ss.length()!=n){
            continue;
        }
        bool flag=true;
        for(int j=0;j<m;j++){
            if(n>=2&&(s[j]==1&&c[j]==0)){
                flag=false;
                break;
            }
            if(ss[s[j]-1] != c[j]){
                flag=false;
                break;
            }
        }
        if(flag){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n,q=map(int,input().split())
    ab=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    visit=[False]*n
    cnt=[0]*n
    for i in range(q):
        p,x=map(int,input().split())
        cnt[p-1]+=x
    q=[(0,0)]
    while q:
        v,a=q.pop()
        visit[v]=True
        a+=cnt[v]
        cnt[v]=a
        for i in ab[v]:
            if visit[i]:
                continue
            else:
                q.append((i,a))
    print(*cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 60972
using System;

class Solution
{
    static void Main(String[] args)
    {
 
        var s = Console.ReadLine().Split();
        var a= Convert.ToSByte(s[0]);
        var b= Convert.ToSByte(s[1]);
        var c= Convert.ToSByte(s[2]);
        var temp=a;
        a=b;
        b=temp;
        temp=a;
        a=c;
        c=temp;
        
    Console.WriteLine($"{a} {b} {c}");
    }
 
}

Measured memory_bytes: 13396
N, M = map(int, input().split())
S = input().rstrip()
A = [0]*N
cnt = 0
S = reversed(S)
for i, s in enumerate(S):
    if s=="1":
        cnt += 1
        A[i] = cnt
    else:
        cnt = 0
dp = 0
res = []
while dp+M <= N-1:
    t = M - A[dp+M]
    if t>0:
        dp += t
    else:
        print(-1)
        exit()
    res.append(t)
res.append(N-dp)
res.reverse()
print(*res)

Measured memory_bytes: 84336
#include<iostream>
#include<cstring>
using namespace std;
char a[1000010];
int s=0;
int main(){
	cin>>a;
	int l=strlen(a);
	for(int i=1;i<l;i++){
		if(a[i]!=a[i-1]){
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
using ll = long long;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (float(d) / t <= float(s))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }

  int Hmax = 20005;

  vector<int> dp(Hmax + 1, INF);
  dp[0] = 0;
  rep(h, Hmax) {
    rep(j, N) {
      if (h + A[j] > Hmax)
        continue;
      chmin(dp[h + A[j]], dp[h] + B[j]);
    }
  }

  int ans = INF;
  repp(i, H, Hmax) {
    chmin(ans, dp[i]);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll md = 1e9+7;

int main()
{
	string s;
	ll d;
	cin >> s >> d;
	int n = s.length();
	ll dp[n][d];
	dp[0][0] = 1;
	for (int q = 1; q < d; q++)
	{
		dp[0][q] = 0;
	}
	for (int q = 1; q < n; q++)
	{
		for (int w = 0; w < d; w++)
		{
			dp[q][w] = 0;
			for (int e = 0; e < 10; e++)
			{
				dp[q][w] = (dp[q][w] + dp[q-1][(((w-e) % d) + d) % d]) % md;
			}
		}
	}
	ll tot = 0;
	ll dsum = 0;
	for (int q = 0; q < n; q++)
	{
		int digit = s[q] - '0';
		for (int w = 0; w < digit; w++)
		{
			tot = (tot + dp[n-q-1][(((-dsum-w) % d) + d) % d]) % md;
		}
		dsum = (dsum + digit) % md;
	}
	if (dsum % d == 0)
	{
		tot = (tot + 1) % md;
	}
	cout << (tot+md-1) % md << "\n";
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int in, inn, n, itr=0,ans=0;
	cin >> n;
	rep(i, n) {
		cin >> in >> inn;
		if (itr < in) {
			itr = in;
			ans = inn;
		}
	}
	cout << ans + itr << endl;
}

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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }

  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
}comb(1000005);

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

  mint all=1, ex=1, onlyz=0, onlyn=0;
  rep(i,n) all*=10;
  rep(i,n) ex*=8;

  vector<mint> e(n,1);
  for(int i=1; i<n; i++) e.at(i) = e.at(i-1)*8;

  for(int i=1; i<=n; i++){
    mint add = comb(n,i)*e.at(n-i);
    onlyz += add;
  }

  onlyn = onlyz;
  mint ans = all - ex - onlyn - onlyz;
  cout << ans;
}



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

int main() {
  string S;
  cin >> S;
  int len = S.size();
  vector<LL> count(2019, 0);
  count[0]++;
  int tk = 1, tsum = 0;
  for(int i=len-1; i>=0; --i) {
    tsum = (tsum + tk * (S[i] - '0')) % 2019;
    count[tsum]++;
    tk = tk * 10 % 2019;
  }
  LL ret = 0;
  REP(i, 2019) {
    ret += count[i] * (count[i] - 1) / 2;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ret;
	if(N == 1){
		ret = "Hello World";
	}
	else{
		int A, B;
		cin >> A >> B;

		ret = to_string(A+B);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int main() {
	long long n, k;
	pair<long long, long long>a[100010];
	cin >> n >> k;
	for (long long i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	long long sum = 0;
	for (long long i = 0; i < n; i++) {
		sum += a[i].second;
		if (sum >= k) {
			cout << a[i].first << endl;
			break;
		}
	}
	getchar();
	getchar();
	return 0;
}

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

using namespace std;

typedef long long ll;

ll n, k, num, ans, tans, last_highest, height[16];

int main(){
    tans = 2e18;
    cin>> n >> k;
    for(int i = 0; i < n; i++){
        cin >> height[i];
    }
    for(int i = 0; i < (1 << n); i++){
        last_highest = 0;
        num = 0;
        ans = 0;
        for(int j = 0; j < n; j++){
            if(i & (1 << j)){
                num++;
            }
        }
        if(num == k){
            for(int j = 0; j < n; j++){
                if((1 << j) & i){
                    if(height[j] > last_highest){
                        last_highest = height[j];
                    }
                    else{
                        ans += last_highest+1-height[j];
                        last_highest++;
                    }
                }
                else{
                    if(height[j] > last_highest){
                        last_highest = height[j];
                    }
                }
            }
            tans = min(tans, ans);
        }
    }
    cout << tans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 ll a[100002][3];
 ll r[100002][3];
 ll n;
 ll res(ll b,ll c)
 {
     ll i;
     if(b==n)
        return 0;
     if(r[b][c]==-1)
     {
         ll ma=INT_MIN;
         for(i=0;i<3;i++)
         {
             if(i==c)
                continue;
             ma=max(ma,a[b][c]+res(b+1,i));

         }
         r[b][c]=ma;
     }
     return r[b][c];
 }
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll t,i,j,k,x,y,c=0,m;
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>a[i][0]>>a[i][1]>>a[i][2];

     }
 memset(r,-1,sizeof(r));
     ll mi=max(res(0,0),max(res(0,1),res(0,2)));
     cout<<mi<<"\n";

}


Measured memory_bytes: 12800
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll k, n; cin >> k >> n;
	vector<ll> v; v.resize(n);
	vector<ll> pre;
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < v.size()-1; i++) {
		pre.push_back(v[i + 1] - v[i]);
	}
	pre.push_back((k - v[n - 1])+v[0]);
	sort(pre.begin(), pre.end());
	pre.pop_back();
	ll ans = 0;
	for (int i = 0; i < pre.size(); i++) {
		ans += pre[i];
	}
	cout << ans;

}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 4084
#include <iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
vector<vector<int> > t;
ll mem[2][100005];
ll num_ways(bool black,int node,int par)
{
    if(t[node].size() == 1 && node!=1)
    {
        if(black)
            return 1;
        return 2;
    }
    if(mem[black][node] != -1)
        return mem[black][node];
    ll ans1=1,ans2=1;
    if(black)
    for(int i=0;i<t[node].size();i++)
    {
        if(t[node][i] != par)
            ans1  = (ans1*num_ways(false,t[node][i],node))%mod;
    }
    else
    for(int i=0;i<t[node].size();i++)
    {
        if(t[node][i] != par){
            ans1  = (ans1*num_ways(false,t[node][i],node) )%mod;
            ans2  = (ans2*num_ways(true,t[node][i],node) )%mod;
        }
            
    }
    if(black)
        return mem[black][node] = ans1;
    return mem[black][node] = (ans1+ans2)%mod;
}
int main() {
    int x,y;
	cin>>n;
	t.resize(n+1);
	for(int i=1;i<n;i++)
	{
	    cin>>x>>y;
	    t[x].push_back(y);
	    t[y].push_back(x);
	}
	memset(mem,-1,sizeof(mem));
	cout<<num_ways(false,1,-1);
	return 0;
}

Measured memory_bytes: 14208
li_1 = list(map(int,input().split()))
li_2 = list(map(int,input().split()))
li_3 = list(map(int,input().split()))
ans = []
n = int(input())
li_b = []
for i in range(n):
  b= int(input())
  if b in li_1:
    id = li_1.index(b)
    ans.append(id)
  if b in li_2:
    id = li_2.index(b) + 3
    ans.append(id)
  if b in li_3:
    id = li_3.index(b) + 6
    ans.append(id)
tf = False
ans.sort()
for i in ans:
  if i ==0 or i==3 or i==6:
    if i+1 in ans:
      if i+2 in ans:
        tf = True
  if i==0 or i==1 or i==2:
    if i+3 in ans:
      if i+6 in ans:
        tf = True
  if 0 in ans:
    if 4 in ans:
      if 8 in ans:
        tf = True
  if 2 in ans:
    if 4 in ans:
      if 6 in ans:
        tf = True
if tf==True:
  print("Yes")
else:
  print("No")

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (((a * b) % 2) == 0) { /* 積が偶数 */
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>

using namespace std;

int main(){
  long long n;
  cin >> n;
  vector<long long> ans(n,0);
  long long tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    if(i%2==1){
      ans[n/2 - (i+1)/2] = tmp;
    }else{
      ans[n/2 + (i+1)/2] = tmp;
    }
  }
  if(n%2==1){
    reverse(ans.begin(), ans.end());
  }
  for(int i = 0; i < n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  
  return 0;
} 


Measured memory_bytes: 3840
n, m, c = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
cnt = 0
for a in range(n):
	a = [int(i) for i in input().split()]
	tmp = sum([bb * aa for bb, aa in zip(b, a)]) + c
	if tmp > 0:
		cnt += 1
print (cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if(k%2==0){
		cout << a-b << endl;
	} else {
		cout << b-a << endl;
	}	

	return 0;
}


Measured memory_bytes: 384
k,n = map(int, input().split())
l = list(map(int, input().split()))

#print(k,n, l)

x = []
for i in range(1, n):
    x .append(l[i]-l[i-1])
#print(x)
x = x + [k - sum(x)]

#print(x)
print(sum(x) - max(x))




Measured memory_bytes: 26444
class UnionFind:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

N,K,L = map(int,input().split())
road = UnionFind(N)
railway = UnionFind(N)
for i in range(K):
    p,q = map(int,input().split())
    road.union(p-1,q-1)
for i in range(L):
    r,s = map(int,input().split())
    railway.union(r-1,s-1)

from collections import defaultdict
d = defaultdict(lambda:0)

for i in range(N):
    p1,p2 = road.find(i),railway.find(i)
    d[(p1,p2)] += 1

ans = [str(d[(road.find(i),railway.find(i))]) for i in range(N)]
print(' '.join(ans))

Measured memory_bytes: 49420
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MAXN = (int) 1e5;

int fr[MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, x;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> x;
        fr[x]++;
    }
    int ans = 0;
    for(i = -1; i <= MAXN + 1; i++) {
        int tot = 0;
        if(i - 1 >= 0)
            tot += fr[i - 1];
        if(i + 1 <= MAXN)
            tot += fr[i + 1];
        if(i >= 0 && i <= MAXN)
            tot += fr[i];
        ans = max(ans, tot);
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = cin.next;
        if (S == "keyence")
        {
            WriteLine("YES");
            return;
        }

        for (int i = 0; i < S.Length; i++)
        {
            for (int j = i; j < S.Length; j++)
            {
                var d = "";
                if (i > 0) d += S.Substring(0, i);
                if (j <= S.Length - 2) d += S.Substring(j + 1, S.Length - j - 1);
                if (d == "keyence")
                {
                    WriteLine("YES");
                    return;
                }
            }
        }
        WriteLine("NO");
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 11092
n = int(input())
a = list(map(int, input().split()))
m = {}

for i in a:
    m[i] = m.get(i, 0) + 1

result = 0
for i in m.keys():
    v = m.get(i, 0)
    if v >= i:
        result += v - i
    else:
        result += v
print(result)


Measured memory_bytes: 18168
#include <stdio.h>


int solve(int x, int y){
  if(x==0&&y>0) return y;
  else if(x==0&&y<0) return 1-y;
  else if(x>0&&y==0) return 1+x;
  else if(x<0&&y==0) return -x;
  else if((x^y)>0&&y>=x) return y-x;
  else if((x^y)>0&&y<x) return 2+x-y;
  else if((x^y)<0&&y>=x) return (-x<=y)?1+y+x:1-x-y;
  else return (-y>=x)?-y-x+1:1+x+y;
}

int main(){
  int x, y;
  scanf("%d%d", &x, &y);
  printf("%d\n", solve(x,y));
  return 0;
}


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

ll num[sz];

int main()
{



  ll c=0,n,i,j,a;

  cin>>n;

  for(i=1;i<=n;i++)
  {
      cin>>a;

      if(a%2==0)
      {
          if(a%3==0 || a%5==0){}
          else
            c++;
      }

  }

  if(c==0)cout<<"APPROVED"<<endl;
  else
    cout<<"DENIED"<<endl;



  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		for(int i=0;i<n;i++){
			int y = stdIn.nextInt();
			int m = stdIn.nextInt();
			int d = stdIn.nextInt();
			
			int toku = (y-1)/3;
			int kihon = y-1-toku;
			int day = toku*200;
			day += kihon*195;
			
			if(y%3==0){
				day += (m-1)*20;
			}
			else{
				int t_sho = (m-1)/2;
				int t_dai = m-1-t_sho;
				day += t_sho*19;
				day += t_dai*20;
			}
			day += d-1;
			day = 196470-day;
//			day++;
			System.out.println(day);
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;

ll N,M;
vector<vector<P>> G;
ll d[200000];

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=1;i<N;i++) G[i].push_back({i-1,0});
    for(int i=0;i<M;i++){
        ll l,r,c;
        cin >> l >> r >> c;
        G[l-1].push_back({r-1,c});
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push({0,0});
    for(int i=0;i<N;i++) d[i] = -1;
    while(d[N-1] < 0 && !pq.empty()){
        P p = pq.top();
        pq.pop();
        ll n = p.second;
        ll c = p.first;
        if(d[n] >= 0) continue;
        d[n] = c;
        for(auto &e : G[n]){
            if(d[e.first] >= 0) continue;
            pq.push({d[n]+e.second,e.first});
        }
    }
    cout << d[N-1] << endl;
    return 0;
}

Measured memory_bytes: 13612
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define REP(i, a, n) for (int i = ((int)a); i < ((int)n); i++)
#define lli long long int

#define MAX 100000000
//#define DEBUG

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

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
#else
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
#endif
    int N;
    string S;
    int n;
    string out;
    cin >> N >> S >> n;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == S[n-1])
        {
            out.push_back(S[n-1]);
        }
        else
        {
            out.push_back('*');
        }
    }
    cout << out << endl;
    return 0;
}
/* 注意すべき点
グローバル以外の配列は初期化すべし
*/

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	int n;
	
	cin>> n;
	if(n>=64)cout<<64;
	else if(n>=32)cout<<32;
	else if(n>=16) cout<<16;
	else if(n>=8) cout<<8;
	else if(n>=4) cout<<4;
	else if(n>=2) cout<<2;
	else cout<<n;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
using Graph = vector<vector<int>>;

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

// グラフ入力受取
Graph G(N);
for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    /*
    G[a].push_back(b);
    G[b].push_back(a);
    */
   //　At coder に対応して頂点を1~Nに
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
}

// BFS のためのデータ構造
vector<int> dist(N, -1); //全頂点を「未訪問」に初期化(-1)
queue<int> que; //キューの配列
vector<int> next(N, 0); // 頂点 i における次に進むべき頂点

// 初期条件(頂点 0 を初期ノードとする)
dist[0] = 0;
que.push(0); //キューに 0 を追加 = 0 を橙色頂点(「訪問予定」)にする

// BFS開始(キューが空になるまで探索を行う)
while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop(); // キューの先頭を削除

    // v から辿れる頂点を全て調べる
    for (int nv : G[v]){
        if (dist[nv] != -1) continue; // 既に発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1; // v からの距離に 1 を加える
        next[nv] = v; // 頂点 nv において次に進むべき頂点は v
        que.push(nv);
    }

}
/*
// 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
*/

// 結果出力(各頂点において次に進むべき頂点を示す)
cout << "Yes" << endl;
for(int v = 1; v < N; v++) cout << next[v] + 1 << endl;




}


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

string s;
int main()
{
  cin >> s;

  for(int i = 0; i < s.size(); i++){
    char out;
    if(s[i] <= 'C')
      out = s[i] + 23;
    else
      out = s[i] - 3;
    cout << out;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 1176
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/variant.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
template<class T>class binary_indexed_tree
{
	typedef T type;
	std::vector<type> ar;
	std::size_t size;
public:
	binary_indexed_tree(std::size_t size_) :ar(size_), size(size_)
	{

	}
	void add(type val, int index)
	{
		++index;
		while (index <= size)
		{
			ar[index - 1] += val;
			index += index & -index;
		}
	}
	auto get(int index)const
	{
		++index;
		type ret{};
		while (index != 0)
		{
			ret += ar[index - 1];
			index -= index & -index;
		}
		return ret;
	}
	auto operator[](int index)const
	{
		if (index == 0)
		{
			return get(0);
		}
		else
		{
			return get(index) - get(index - 1);
		}
	}
};
struct merge_query
{
	std::int64_t a;
	std::int64_t b;
};

struct output_query
{

};
typedef boost::variant<merge_query, output_query> query;

struct operation_t
{
	binary_indexed_tree<int> count;
	binary_indexed_tree<std::int64_t> sum;
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	int sz;
	std::int64_t constant;
	operation_t(std::map<std::int64_t, int>&& index, std::vector<std::int64_t>&& vs, int size) :
		count(size), 
		sum(size), 
		indexes(std::move(index)),
		values(std::move(vs)),
		sz(size),
		constant()
	{

	}
	void operator()(merge_query const& q)
	{
		auto a = q.a;
		auto b = q.b;
		auto i = indexes[a];
		count.add(1, i);
		sum.add(a, i);
		constant += b;
	}
	void operator()(output_query const&)
	{
		auto max = count.get(sz - 1);
		auto rng = boost::irange(0, sz);
		auto i = *std::partition_point(rng.begin(), rng.end(), [&](int i)
			{
				auto v = count.get(i);
				return v < max - v;
			});
		auto left = sum.get(i);
		auto right = sum.get(sz - 1) - left;
		auto c = count.get(i);
		auto d = max - c;
		auto v = (c - d) * values[i] + right - left + constant;
		std::cout << values[i] << " " << v << std::endl;
	}
};

void Main()
{
	int Q;
	std::cin >> Q;
	std::set<std::int64_t> as;
	std::vector<query> queries;
	for (int i : boost::irange(0, Q))
	{
		int q;
		std::cin >> q;
		if (q == 1)
		{
			std::int64_t a, b;
			std::cin >> a >> b;
			queries.emplace_back(merge_query{ a,b });
			as.emplace(a);
		}
		else
		{
			queries.emplace_back(output_query{});
		}
	}
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	indexes[-1000000001] = 0;
	values.emplace_back(0);
	int index = 1;
	for (auto a : as)
	{
		indexes[a] = index;
		values.emplace_back(a);
		++index;
	}
	operation_t op(std::move(indexes), std::move(values), index);
	for (auto const& q : queries)
	{
		boost::apply_visitor(op, q);
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main(){
     int a ,b, c, d, e, f, g;
     cin >> a >> b >> c >> d;
  e = abs(a-b);
  f = abs(b-c);
  g = abs(a-c);
    if(g <= d) {cout << "Yes" << endl;
             }
   else if(e <= d && f <= d) {cout << "Yes" << endl;
              }
    else {cout << "No" << endl;
       }
}


Measured memory_bytes: 256
var n;

function CS(a,b,k){
    var c = new Array(k + 1);
    for(var i = 0;i <= k;i++)
        c[i] = 0;
    for(var j = 0;j < n;j++)
        c[a[j]]++;
    for(var i = 1;i <= k;i++)
        c[i] += c[i - 1];
    for(var j = 0;j < n;j++)
        b[-1 + c[a[j]]--] = a[j];
}

function Main(input){
    input = input.split("\n");
    n = parseInt(input[0],10);
    input[1] = input[1].split(" ");
    var a = Array(n),ans = Array(n);
    for(var i = 0;i < n;i++)
        a[i] = parseInt(input[1][i],10);
    CS(a,ans,10000);
    String(ans);
    var out = ans[0];
    for(i = 1;i < n;i++)
        out += " " + ans[i];
    console.log(out);
}

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

Measured memory_bytes: 206988
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;
struct node
{
	ll a,b;
}e[maxn];
bool operator<(node a,node b)
{
	return a.b<b.b;
}
ll n;
bool ok()
{
	ll now=0;
	for(int i=1;i<=n;++i)
	{
		now+=e[i].a;
		if(now<=e[i].b)continue;
		else return 0;
	}
	return 1;
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld%lld",&e[i].a,&e[i].b);
	}
	sort(e+1,e+n+1);
	puts(ok()?"Yes":"No");
	return 0;
} 

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int e=0,w=0,res=1<<30;
    for(int i=0;i<n;i++){
        if(s[i]=='E')e++;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='E'){
            e--;
            //cout<<w+e<<endl;;
            res=min(w+e,res);
        }
        else{
            //cout<<w+e<<endl;
            res=min(w+e,res);
            w++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N;
	cin >> N;
	vector<ll> H(N);
	rep(i, N) cin >> H[i];

	ll cnt = 0;
	ll ans = 0;

	rep(i, N-1) {
		if(H[i]>=H[i+1]) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	
	ans = max(ans, cnt);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1024