akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> l(m,0);
    vector<int> r(m,0);
    rep(i,m)cin >> l.at(i) >> r.at(i);
    int max_l = *max_element(l.begin(),l.end());
    int min_r = *min_element(r.begin(),r.end());
    if(max_l <= min_r)cout << min_r - max_l+1 << endl;
    else cout << 0 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main() {
  int D, G;
  cin >> D >> G;
  int p[10], c[10];
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for (int mask = 0; mask < (1 << D); mask++) {
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (mask >> i & 1) {
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= p[rest_max]) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string S, T;
	cin >> S >> T;
	int r = 0;
	for (int i = 0; i < S.length(); ++ i) {
		if (S[i] != T[i]) ++ r;
	}
	cout << r << endl;
}


Measured memory_bytes: 3916
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N,P;
    cin >> N >> P;
    int A[N];
    REP(i,N) cin >> A[i];
    bool even=false;
    bool odd=false;
    if(P==1){
        odd=true;
    }
    else{
        even=true;
    }
    LL ans=0;
    LL odd_num=0,even_num=0;
    for(int i=0;i<N;++i){
        if(A[i]%2==0){
            ++even_num;
        }
        else{
            ++odd_num;
        }
    }
    LL odd_sum=odd_num,even_sum=even_num;
    LL act=0;
    if(even_num==N){
        if(P==0){
            ans=pow(2,even_num);
        }
        else{
            ans=0;
        }
    }
    else{
        ans=pow(2,N-1);
    }
    cout << ans;
}

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

int main() {
  int x, y;
  while(1){
    cin >> x >> y;
    if((x == 0 && y == 0)){
      break;
    } else{
      if(x<=y){
        cout << x << " " << y << "\n";
      } else{
        cout << y << " " << x << "\n";
      }
    }
  }
}

Measured memory_bytes: 1160
n, a, b, c, d = list(map(int, input().split()))
s = input()

last = "."
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]

if c < d:
    print("Yes")
else:
    length = 0
    for i in range(b-2, d+1):
        if s[i] == ".":
            length += 1

            if length == 3:
                print("Yes")
                exit()
        else:
            length = 0

    print("No")

Measured memory_bytes: 9420
#include<stdio.h>
int main(void){
    long long int i,N,a,sa,sum=0;
    long long int A[100005]={0};
    scanf("%lld",&N);
    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
        sum+=A[i];
    }
    A[N]=A[0];
    if(sum%(N*(N+1)/2)!=0){printf("NO\n");return 0;}
    sa=sum/(N*(N+1)/2);
    for(i=0;i<N;i++){
        if((A[i]+sa-A[i+1])%N!=0||(A[i]+sa-A[i+1])<0){printf("NO\n");return 0;}
    }
    printf("YES\n");return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}
lli m = 1e9 + 7;
int main(void)
{
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
        s += "es";
        cout << s << endl;
        return 0;
    }
    else
    {
        s += "s";
        cout << s << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int	intcmp(const void *n1, const void *n2)
{
	return (*(int *)n1 - *(int *)n2);
}

int	main()
{
	int	N;
	int	i;
	double	sum;
	int	*v;

	i = 0;
	scanf("%d\n", &N);
	v = (int *)malloc(sizeof(int) * (N + 1));
	while (i < N)
	{
		scanf("%d ", &v[i]);
		i++;
	}
	qsort(v, i, sizeof(int), intcmp);
	sum = ((double)v[0] + (double)v[1]) / 2;
	i = 1;
	while (++i < N)
		sum = (sum + (double)v[i]) / 2;
	printf("%lf\n", sum);
	return (0);
}

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

int main(){
    int h, w, n;
    cin >> h >> w >> n;

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

    vector<vector<int>> c(h, vector<int>(w));
    int x=0, y=0;
    for(int i=0; i<n; i++){
        //cout << "a[" << i << "] = " << a[i] << endl;
        while(a[i] > 0){
            //cout << "x = " << x << ", y = " << y << endl;
            c[x][y] = i+1;
            a[i] -= 1;
            if(y % 2 == 0 && x < h-1) x += 1;
            else if(y % 2 != 0 && x > 0) x -= 1;
            else y += 1;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

template<class T>
T power(T x, unsigned long long n){
    T res = T(1);
    while(n){
        if(n & 1ull){
            res *= x;
        }
        x *= x;
        n >>= 1;
    }
    return res;
}

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

    vector<lint> v(3);
    rep(i, 3){
        cin >> v[i];
    }

    SORT(v);

    int k;
    cin >> k;

    cout << v[0] + v[1] + v[2] * power(2, k) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if ((c - (a + b)) < 0) {
    cout << "No";
    return 0;
  }
  c = ((c - (a + b)) * (c - (a + b)));
  if ((4 * a * b) < c) cout << "Yes";
  else cout << "No";
  return 0;
}

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


int main(){
  int a,b;
  cin>>a>>b;
  int c = b/10;
  a *= 10;
  while(c!=0){
    c = c/10;
    a *= 10;
  }
  int d = a+b;
  int e = sqrt(d);
  
  if(d==e*e){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(int, 3, as);
    sort(Range(as));
    Cout(as[0] == as[1] ? as[2] : as[0]);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "Impossible";
            if (iA % 3 == 0) { sOut = "Possible"; }
            if (iB % 3 == 0) { sOut = "Possible"; }
            if ((iA + iB) % 3 == 0) { sOut = "Possible"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}


Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
x=[-1]*n
for i in range(n-1,-1,-1):
    if i>=(n+1)/2:
        x[i]=a[i]
    else:
        j=(i+1)*2
        while(j<=n): 
            a[i]=(a[i]+a[j-1])%2
            j+=i+1
        x[i]=a[i]
print(sum(x))
if sum(x)!=0:
    for i in range(n):
        if x[i]==1:
            print(i+1,end=' ')
    

Measured memory_bytes: 62940
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0;i<x; i++)
typedef long long  ll;
using namespace std;
int main(){
  string S;
  cin>>S;
  int N = S.size();
  
    
  rep(i,((N-1)/2)/2){
  	if(S[i] != S[(N-1)/2-1-i]){
      cout<<"No";
      return 0;	
    }
  }
  for(int i=0;i<(N-1)/2/2;i++){
  	if(S[(N+3)/2-1+i] != S[N-1-i]){
    	cout<<"No";
      	return 0;
    }
  }
  
  rep(i,N/2){
  	if(S[i] != S[N-1-i]){
    	cout<<"No";
      	return 0;
    }
  }
  cout<<"Yes";
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i: i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])


Measured memory_bytes: 52016
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

#define mod 1000000007LL
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res + m) * ( a + m) % m;
        a = a * a % m;
        b >>= 1;
    }
    return (res + m) % m;
}

long long mul(long long a, long long b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return ((a + mod) * (b + mod))%mod;
}
long long add(long long a, long long b){
    a += mod;
    b += mod;
    return (a + b)%mod;
}
ll inv(ll x){
    return binpow(x, mod - 2, mod);
}
int main()
{
    ll n;cin>>n;
    vector<ll> a(n);
    for(auto&i: a)cin>>i;
    map<ll, ll> dp;
    for(ll i = 0;i<n;i++){ 
        if(!i){ 
            dp[a[i]] = dp[a[i] - 1] = dp[a[i] + 1] = 1;
        }else{ 
            dp[a[i]] = 1 + dp[a[i]];
            dp[a[i] - 1] = 1 + dp[a[i] - 1];
            dp[a[i] + 1] = 1 + dp[a[i] + 1];
        }
    }
    ll ans= 0;
    for(auto i: dp){ 
        ans = max(ans, i.second);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9620
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int N,K,i;
char key;


int main(void){
    cin >> N ;
    char S[N];
    scanf("%s",S);
    cin >> K;

    key=S[K-1];

    for(i=0;i<N;i++)
    {
        if(S[i]!=key)S[i]='*';
    }


    printf("%s",S);

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define REP(i, n) FOR(i, 0, n)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
#define PB push_back
#define MP make_pair

#define N 112345
char s[N];
int a[N];
int n;
int d1(){
	int mi=INT_MAX, mx=INT_MIN;
	REP(i, n){
		SML(mi, a[i]);
		LAR(mx, a[i]);
	}
	return mx-mi;
}
int d12(int p){
	int q=p-3;
	int stat=0;
	int mi=INT_MAX, mx=INT_MIN;
	REP(i, n){
		if(stat==1){
			if(a[i]<=q){
				stat=0;
				LAR(mx, 10+a[i]);
			}else{
				return INT_MAX;
			}
		}else{
			if(a[i]==1){
				stat=1;
			}else if(a[i]>=p){
				SML(mi, a[i]);
			}else{
				return INT_MAX;
			}
		}
	}
	if(stat==1 || mi==INT_MAX || mx==INT_MIN) return INT_MAX;
	else return mx-mi;
}
int d(int k){
	int m=n/k;
	FOR(i, 1, m){
		REP(j, k-2){
			if(a[j]!=a[i*k+j]) return INT_MAX;
		}
	}
	int mi=INT_MAX, mx=INT_MIN;
	REP(i, m){
		int b=a[(i+1)*k-2]*10+a[(i+1)*k-1];
		SML(mi, b);
		LAR(mx, b);
	}
	return mx-mi;
}

int main(){
	scanf("%s", s);
	n = strlen(s);
	REP(i, n) a[i]=s[i]-'0';
	int ans=d1();
	if(n>2){
		FOR(i, 4, 10){
			SML(ans,d12(i));
		}
	}
	FOR(i, 2, n) if(n%i==0) SML(ans,d(i));
	printf("%d\n", ans);
}

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

using ll=long long; 

void solve(){
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0; i<a; i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No"<<endl;
			return;
		}
	}
	if(s[a]!='-'){
		cout<<"No"<<endl;
		return;
	}
	for(int i=a+1; i<a+b+1; i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
}

signed main(){
	//while(1)
	solve();
}


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

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

    vector<int> a(1000000);
    a[0]=s;
    for(int i=1;;i++){
        if(a[i-1]%2==0) a[i]=a[i-1]/2;
        else a[i]=3*a[i-1]+1;

        for(int j=0;j<i;j++)if(a[i]==a[j]){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4096
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //while(true){
            int n = sc.nextInt();
            int[] x = new int[n];
            for(int i=0;i<n;i++){
                x[i] = sc.nextInt();
            }
            
            for(int i=n-1;i>0;i--){
                System.out.printf("%d ",x[i]);
            }
            System.out.printf("%d%n",x[0]);
        //}
        
        sc.close();
    }
}


Measured memory_bytes: 26660
#include<stdio.h>
int main(void)
{
   int a,b;
   int coin=0;

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

   if(a >= b)
    {coin = a; a--;}
   else if(a < b)
    {coin = b; b--;}
   
   if(a >= b)
    coin += a;
   else if(a < b)
    coin += b;
   
   printf("%d", coin);

   return 0;
}


    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int a[N], n, m, num;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d", &a[i]);
        num += a[i] & 1;
    }
    if (num > 2) {
        printf("Impossible\n");
        return 0;
    }
    for (int i = 2; i < m; i++)
        if (a[i] & 1) swap(a[(a[1] & 1) ? m : 1], a[i]);
    for (int i = 1; i < m; i++) printf("%d ", a[i]);
    printf("%d\n", a[m]);
    if (m == 1) a[++m] = a[1], a[1] = 0;
    a[1]++;
    printf("%d\n", (--a[m]) ? m : --m);
    for (int i = 1; i < m; i++) printf("%d ", a[i]);
    printf("%d\n", a[m]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=3e7;
ll a[N][3],dp[N][4],n,k;
ll solve(int i,int last){
    if(i==n)return 0;
    ll &ret=dp[i][last];
    if(ret+1)return ret;
    ret = 0;
    for(int j=0;j<3;j++){
        if(last==j)continue;
        ret = max(ret,solve(i+1,j)+a[i][j]);
    }
    return ret;
}
int main()
{
    memset(dp,-1,sizeof dp);
    FASTIO
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    cout << solve(0,3) << endl;
    return 0;
}
/**

*/


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

long long f(int x, int y, int z)
{
  return pow(x,2)+pow(y,2)+pow(z,2)+x*y+y*z+z*x;
}

int main() {
	// your code goes here
  int n;
  cin>>n;
  unordered_map<int,int> m;
  for(int x=1;x<=n;x++)
  {
    if(f(x,1,1)>n)
      break;
    for(int y=1;y<=n;y++)
    {
      if(f(x,y,1)>n)
        break;
      for(int z=1;z<=n;z++)
      {
        long long fun=f(x,y,z);
        m[fun]++;
        if(fun>n)
          break;
      }
    }
  }
  for(int i=1;i<=n;i++)
  {
    if(m.count(i))
      cout<<m[i]<<endl;
    else
      cout<<0<<endl;
  }
  return 0;
}


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


/*

struct vertex
{
  vector<int> rel;
  int parent = -1;
  ll count = 0;
};




void counter(vector<vertex> &tree, int target, int plus)
{
  vertex &nowtree = tree.at(target);
  nowtree.count += plus;
  for (auto &&i : nowtree.rel)
  {
    if (i != nowtree.parent)
    {
      counter(tree, i, plus);
    }

  }
  
  
}


int main(){
  int n,q;cin>>n>>q;
  vector<vertex> tree;
  tree.resize(n);
  tree.at(0).parent = 0;
  for (int i = 0; i < n - 1; i++)
  {
    int a,b;cin>>a>>b;
    a--;b--;
    tree.at(a).rel.push_back(b);
    tree.at(b).rel.push_back(a);
  }
  vector<pair<int,int>> px(q);
  for (auto &&i : px)
  {
    cin >> i.first >> i.second;
  }


/*
  for (int i = 0; i < tree.size(); i++)
  {
    cout << "rels at " << i + 1 << ": ";
    for (auto &&j : tree.at(i).rel)
    {
      cout << j + 1 << " ";
    }
    cout << endl;

  }
*/
  

  
/*

  for (int i = 0; i < tree.size(); i++)
  {
    for (auto &&j : tree.at(i).rel)
    {
      if(tree.at(i).parent != -1){
        if (j != tree.at(i).parent)
          tree.at(j).parent = i;
      }

    }
    
  }

/*
  cout << "parents: ";
  for (auto &&i : tree)
  {
    cout << i.parent + 1 << " ";
    
  }
  cout << endl;
*/
  
  /*
  for (auto &&i : px)
  {
    int target = i.first;
    int plus = i.second;
    target--;
    counter(tree,target,plus);

  }
  
  printf("%d ",tree.at(0).count) ;
  for (int i = 1; i < n; i++)
  {
    printf("%d ",tree.at(i).count) ;
  }
  printf("\n") ;
  
  
}

*/


Graph g;
vector<ll> vals;
vector<ll> ans;

void dfs(int vertex, int parent, int sum)
{
  ans.at(vertex) += vals.at(vertex);
  ans.at(vertex) += sum;
  for (auto &&i : g.at(vertex))
  {
    if(i == parent)continue;
    dfs(i,vertex,ans.at(vertex));
  }
  

}

int main()
{
  int n,q;cin>>n>>q;
  g.resize(n);
  for (int i = 0; i < n - 1; i++)
  {
    int a,b;cin>>a>>b;
    a--;
    b--;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
  }
  
  vals.resize(n);
  ans.resize(n);
  for (int i = 0; i < q; i++)
  {
    int p,x;cin>>p>>x;
    p--;
    vals.at(p) += x;
  }

  dfs(0,-1,0);
  
  cout << ans.at(0);
  for (int i = 1; i < n; i++)
  {
    cout << " " << ans.at(i);
  }
  cout << endl;

}


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;
vector<pair<int, int>> adj[N];
int n, co[N];

void dfs(int node, int pa, int c) {
    co[node] = c;
    for(auto x: adj[node]) {
        if(x.ff != pa) {
            dfs(x.ff, node, c^x.ss);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    REP(i, 0, n-1) {
        int x, y, w;
        cin >> x >> y >> w;
        --x, --y;
        w = w & 1;
        adj[x].pb({y, w});
        adj[y].pb({x, w});
    }
    dfs(0, -1, 0);
    REP(i, 0, n) {
        cout << co[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 11452
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX = 100000;
const ll inf = 5e18;

int main() {
	fastio;
	ll r;
	cin>>r;
	double pi = 3.14159265358979323;
	cout<<setprecision(10);
	cout<<2*pi*r<<"\n";
return 0;
}

Measured memory_bytes: 3776
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n>>m;
    rep(i,0,m){cin>>q;
    ans+=q;
    }
    if(ans<n)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    
}

Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		String input = new java.util.Scanner(System.in).nextLine(); 
		String[] input2 = input.split(" ");
		int a = Integer.parseInt(input2[0]);
		int b = Integer.parseInt(input2[1]);
		if(a < b)
		{
			System.out.println("a < b");
		}
		else if(a > b)
		{
			System.out.println("a > b");
		}
		else
		{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17140
#include <stdio.h>
#include<math.h>

#define N 10000
#define MAX 100000000

int judge(int);

int main()
{
  int i, n, count=0, a[N];

    scanf("%d", &n);

  for(i = 0; i < n; i++)
    {
      scanf("%d", &a[i]);
      if((judge(a[i])) == 1)count++;
    }
  printf("%d\n",count);

  return 0;
}

int judge(int a)
{
  int i, flag;
  
  for(i=2;i*i<=a;i++)
    {
      if(a%i == 0)return 0;
    }
  return 1;
}



Measured memory_bytes: 2100
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)
    while (true) {
      val R = scanner.nextInt()
      val N = scanner.nextInt()
      if (R == 0 && N == 0) {
        return
      }
      val in = List.fill(N)(scanner.nextInt, scanner.nextInt, scanner.nextInt)
      var map = scala.collection.mutable.ArrayBuffer.fill(R * 2)(0)
      in.foreach {
        case (xl, xr, h) =>
          (xl until xr)
            .map(_ + R)
            .filter(_ >= 0)
            .filter(_ < map.length)
            .foreach(i => map(i) = Math.max(map(i), h))
      }
      val result = map.zipWithIndex.map {
        case (h, index) => calc(index, h, R)
      }.min
      println(result)
    }
  }

  def calc(index: Int, h: Int, R: Int): Double = {
    h + R - Math.sqrt(Math.pow(R, 2) - Math.pow(getRFromIndex(index, R), 2))
  }

  def getRFromIndex(index: Int, R: Int): Double = {
    R - index match {
      case r if r <= 0 => -r
      case r => r - 1
    }
  }
}

Measured memory_bytes: 55284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

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

//階乗,factで初期化
vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

//nCk 繰り返し高速
ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,k;
  cin >> n >> k;
  fact(n);
  for(ll i=1;i<=k;i++) {
    ll ans=0;
    ll r=n-k;
    if(r+1>=i) {
      ll num=i-1;
      (ans=comb(k-1,i-1)*comb(r+1,i)%mod)%=mod;
    }
    cout << ans << endl;
  }
}

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

const int mod = 1e9+7;
const int n = 1e6;
ll fact[n+1], fin[n+1];

ll powe(ll x, ll e) {
    ll r = 1;
    while(e) {
        if(e&1) r = r * x % mod;
        x = x * x % mod;
        e >>= 1;
    }
    return r;
}

void init() {
    fact[0] = 1;
    for(int i=1;i<=n;i++) fact[i] = fact[i-1] * i % mod;
    fin[n-1] = powe(fact[n-1], mod-2);
    for(int i=n-2;i>=0;i--) fin[i]= fin[i+1] * (i+1) % mod;
}

ll choose(int a, int b) {
	return fact[a] * fin[b] % mod * fin[a - b] % mod;
}

ll permute(int a, int b) {
	return fact[a] * fin[a - b] % mod;
}

int main(){
    init();
    int n, m;
    cin >> n >> m;
    ll res = 0;
    // PIE
    for(int i=0;i<=n;i++) {
        int c = i%2 ? -1 : 1;
        ll add = c * choose(n, i) % mod * permute(m, i) % mod * permute(m-i, n-i) % mod * permute(m-i, n-i) % mod;
        add = (add + mod) % mod;
        res = (res + add) % mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 19248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

const ll MAX = 1e6;
ll dp[MAX];
ll dp2[MAX];
int main() {
	IOS;
	vector<ll> a, a2;
	ll n   = 1;
	ll tmp = 2;
	while (tmp < 1e6) {
		tmp = n * (n + 1) * (n + 2) / 6;
		a.push_back(tmp);
		if (tmp % 2 == 1) a2.push_back(tmp);
		n++;
	}
	Fill(dp, INF);
	Fill(dp2, INF);
	ll m  = a.size();
	ll m2 = a2.size();
	dp[0] = dp2[0] = 0;
	for (int i = 1; i <= MAX; i++) {
		for (int j = 0; j < m; j++) {
			if (i >= a[j]) dp[i] = min(dp[i], dp[i - a[j]] + 1);
		}
	}
	for (int i = 1; i <= MAX; i++) {
		for (int j = 0; j < m2; j++) {
			if (i >= a2[j]) dp2[i] = min(dp2[i], dp2[i - a2[j]] + 1);
		}
	}

	ll i = 1;
	while (i) {
		cin >> i;
		if (i == 0) break;
		cout << dp[i] << " " << dp2[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 18752
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
    string s;
    ll k;
    cin>>s>>k;
    set<string> pitsu;
    rep(i,s.size()){
        string t = "";
        ll cnt = 0;
        for(ll j = i;j<s.size() && cnt < 500;j++){
            t += s[j];
            pitsu.insert(t);
            cnt++;
        }
    }
    ll i = 0;
    for(string tmp:pitsu){
        if(i == k-1){
            cout<<tmp<<endl;
            return 0;
        }
        i++;
    }
	return 0;
}


Measured memory_bytes: 795648
#include<stdio.h>
int main(){
  int n,q;
  int i,j;
  int count=0;
 
  scanf("%d",&n);
  int S[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j]==T[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),(n|m)){
        string hit[128];
        int money[128];
        int res = 0;
        rep(i,n){
            cin >> hit[i];
            scanf("%d",&money[i]);
        }
        rep(i,m){
            string str;
            int foo = 0;
            cin >> str;
            rep(j,n){
                bool f = false;
                rep(k,8){
                    //cout << str[k] << ":" << hit[j][k] << endl;
                    if(hit[j][k] == '*')continue;
                    if(str[k] == hit[j][k]){
                        continue;
                    }
                    else{
                        f = true;
                        break;
                    }
                }
                if(!f && foo < money[j]){
                   foo = money[j];
                }
            }
            res += foo;
        }
        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int x, r = 0;
    cin >> x;
    r = x / 11*2;
    x %= 11;
    r += (x > 6) + (x > 0);
    cout << r;
}

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

using namespace std;

template <class T> T gcd(T a, T b) {
	if (a < b) swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}

class Solution {
public:
	void solve() {
		int x;
		cin >> x;
		long long ans = 0;
		for (int i = 1; i <= x; i++) {
			for (int j = 1; j <= x; j++) {
				for (int k = 1; k <= x; k++) {
					ans += gcd(i, gcd(j, k));
				}
			}
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
long long min(long long m,long long n){
    if (m>n) return n;
    else return m;
}
int main() {
    long long a,b,c,d,e,n,f;
    scanf("%lld%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d,&e);
    f=a;
    if (f>b) f=b;
    if (f>c) f=c;
    if (f>d) f=d;
    if (f>e) f=e;
    printf("%lld\n",(n-1)/f+5);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define thekingisborn ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld  long double
#define f first
#define se second
#define pb push_back
#define maxn 200005
#define mod 1000000007
#define pi 3.14159265359

using namespace std;

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

/*ll power(ll a,ll n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    a = a%mod;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
ll gcd(int a,int b)
{
    if(a%b == 0)return b;
    return gcd(b,a%b);
}*/
/*int root(int x)
{
    while(par[x] != x)
    x = par[x];
    return x;
}
void dsu(int x,int y)
{
  if(root(x) == root(y))return;
  par[root(y)] = root(x);
  return;
}
void dfs(int x)
{
    done[x] = true;
    for(int i=0;i<int(adj[x].size());++i)
    {
        int y = adj[x][i];
        if(!done1[y])
        dfs(y);
    }
}*/

int n;
vector<ll>v,a;
ll ans1,ans2;

int main()
{
    thekingisborn;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        ll x;
        cin >> x;
        a.pb(x);
        v.pb(x-i-1);
    }
    sort(v.begin(),v.end());
    int sz = int(v.size());
    ll b1 = v[sz/2],b2 = v[(sz-1)/2],b3;
    if((sz+1)/2 < n)b3 = v[(sz+1)/2];
    for(int i=0;i<n;++i)
    {
        ans1 += labs(b1-a[i]+i+1);
        ans2 += labs(b2-a[i]+i+1);
    }
    cout << min(ans1,ans2);
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int r = n / k;
  int g = n % k;
  if (r > 0 && g == 0 ) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
main=do
 s<-getLine
 putStrLn (g s ((length s)-1) 0)
  where g s i f = if i<0 then "No"
                         else (if f==0 then (g s (i-1) (if s!!i=='F' then 1 else 0))
                                       else (if s!!i=='C' then "Yes" else (g s (i-1) 1)))

Measured memory_bytes: 380
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int sw = 1;
	int cnt = 0;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		if (sw == s[i] - '0') cnt++;
		else {
			v.push_back(cnt);
			cnt = 1;
			sw = 1 - sw;
		}
	}
	if (cnt != 0) v.push_back(cnt);
	if (v.size() % 2 == 0)v.push_back(0);
	vector<ll> sum(v.size() + 1);
	rep(i,v.size()) {
		sum[i + 1] = sum[i] + v[i];
	}
	int w = 2 * k + 1;
	ll ans = 0;
	for (int i = 0; i < sum.size(); i += 2) {
		int r = min(i + w, (int) sum.size() - 1);
		ans = max(ans, sum[r] - sum[i]);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4724
N = int(input())
a = list(map(int, input().split()))

a = [0] + a + [0]


lef = [0] * (N + 2)
rig = [0] * (N + 2)
def gcd(a, b):
    if a * b == 0:
        return a + b
    elif a % b == 0:
        return b
    else:
        return gcd(b, a % b)

for i in range(1, N + 1):
    lef[i] = gcd(lef[i - 1], a[i])

for i in reversed(range(1, N + 1)):
    rig[i] = gcd(rig[i + 1], a[i])

ans = 1
for i in range(1, N + 1):
    ans = max(ans, gcd(lef[i - 1], rig[i + 1]))

print(ans)

Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    int n,k;cin >>n>>k;
    vector<mint>dp(n+1,0);
    dp[0]=1;dp[1]=-1;
    V l(k);
    V r(k);
    for (int i = 0; i < k; ++i) {
        cin >>l[i]>>r[i];
        r[i]++;
    }
    for (int i = 0; i < n; ++i) {
        dp[i+1]+=dp[i];
        for (int j = 0; j < k; ++j) {
            if(i+l[j]<n)dp[i+l[j]]+=dp[i];
            if(i+r[j]<n)dp[i+r[j]]-=dp[i];
        }
    }
    cout <<dp[n-1]<<endl;
}


Measured memory_bytes: 4836
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        int n = readln.chomp.to!int;
        if (n==0) break;
        long[] p = readln.split.to!(long[]);
        long[] j = readln.split.to!(long[]);

        int[] ary = (n-1).iota.array;
        sort!((a,b)=>a[1]>b[1])(zip(ary, j.dup));
        long num = n*p.sum;
        foreach(i; 0..ary.length) {
            long[] _p = p[0..ary[i]] ~ (p[ary[i]]+j[ary[i]]+p[ary[i]+1]) ~ (ary[i]+2<p.length ? p[ary[i]+2..$]:[]);
            long[] _j = j[0..ary[i]] ~ j[ary[i]+1..$];
            long _num = _p.length*_p.sum;
            if (_num > num) {
                p = _p;
                j = _j;
                num = _num;
                ary = ary.map!(a=>a>ary[i]?a-1:a).array;
            } else {
                break;
            }
        }
        num.writeln;
    }
}

Measured memory_bytes: 15576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();

        if (D == 25) {
            System.out.println("Christmas");
        } else if (D == 24) {
            System.out.println("Christmas Eve");
        } else if (D == 23) {
            System.out.println("Christmas Eve Eve");
        } else {
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string T;
    cin >> T;

    map<char, int> score;
    score['s'] = r;
    score['p'] = s;
    score['r'] = p;
    vector<string> S(k, string(""));
    for (int i = 0; i < n; i++)
        S[i % k] += T[i];

    int ans = 0;
    for (int i = 0; i < k; i++){
        char prev = 'j';
        for (const auto &s: S[i]){
            if (prev != s){
                ans += score[s];
                prev = s;
            } else {
                prev = 'j';
            }
        }
    }

    cout << ans << endl;

}

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

typedef long long int llint;

int main(void){
  std::string s;
  llint k;
  std::cin >> s >> k;

  llint ret = 0;
  
  char last = s[0];
  bool first = true;
  for(int i=1; i<s.size(); i++){
    //std::cout << i << ret << std::endl;
    if(last == s[i]){
      if(first){
	ret++;
	first = false;
      }else{
	first = true;
      }
    }else{
      last = s[i];
      first = true;
    }
  }
  ret *= k;

  int temp1 = 0;
  int temp2 = 0;
  char top = s[0];
  for(int i=0; i<s.size(); i++){
    if(s[i] == top) temp1++;
    else            break;
  }
  if(s.size() != temp1){
    for(int i=0; i<s.size(); i++){
      if(s[s.size()-i-1] == top) temp2++;
      else                       break;
    }
    if(temp1%2 != 0 && temp2%2 != 0 && (temp1+temp2)%2==0){
      ret += k-1;
    }
  }else{
    ret = (s.size() * k)/2;
  }
  
  std::cout << ret << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

namespace patch{
    template <typename T> string to_string(const T& n){
        ostringstream stm;
        stm << n;
        return stm.str();
    }
}

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

int main(){
    while(1){
        vector<string> a(100);
        int l;
        cin>>a[0]>>l;
        if(a[0] == "0" && l == 0) return 0;

        int cnt=0;
        while(1){
            vector<char> s(l);
            for(int i=0; i<l; i++){
                if(i < a[cnt].size()) s[i] = a[cnt][i];
                else s[i] = '0';
            }

            cnt++;

            int amax=0, amin=0;
            sort(s.begin(), s.end());

            for(int i=0; i<l; i++){
                amax += (s[l-1-i] - '0') * modpow(10, l-1-i);
                amin += (s[i] - '0') * modpow(10, l-1-i);
            }

            int anxt = amax - amin;
            a[cnt] = patch::to_string(anxt);

            for(int i=cnt-1; i>=0; i--){
                if(a[i] == a[cnt]){
                    cout << i << " " << anxt << " " << cnt - i << endl;
                    goto END;
                }
            }
        }

        END:;
    }
}


Measured memory_bytes: 3188
#define INT_MAX 2147483647
#include<bits/stdc++.h>
using namespace std;
 
const int MAX_N=10000000;
  
int n;
int dat[MAX_N*2-1];
  
void init(){
    int i=n;
    n=1;
 
    while (n<i)n*=2;
     
    fill(dat,dat+n*2,INT_MAX);
}
  
void update(int i,int x){
    i+=n-1;
    dat[i]=x;
    while(i>0){
        i=(i-1)/2;
        dat[i]=min(dat[i*2+1],dat[i*2+2]);
    }
}
  
int query(int a,int b,int k,int l,int r){
    if(r<a||b<l)return INT_MAX;
    if(a<=l&&r<=b) return dat[k];
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2+1,r);
        return min(vl,vr);
    }
}
 
int main(){
    int q,a,b,c;
    cin>>n>>q;
     
    init();
     
    while(q--){
        cin>>a>>b>>c;
        if(a)cout<<query(b,c,0,0,n-1)<<endl;
        else update(b,c);

    }
     
}


Measured memory_bytes: 4108
/* LETS SEE IF U CAN PULL IT UP THIS TIME OR NOT */
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY*/
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define ran(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

int n, m;
vector<list<int>> adjList;
vector<int> val;
vector<int> dp;
bitset<100005> vis;

void dfs(int node) {
	vis[node] = true;

	for (int child : adjList[node]) {
		if (!vis[child]) dfs(child);
		dp[node] = max(dp[node], val[child]);
		dp[child] = max(dp[child], val[node]);
	}
}

int32_t main() {
	fast
	cin >> n >> m;
	adjList.resize(n + 1), val.resize(n + 1), dp.resize(n + 1, -inf);
	for (int i = 1; i <= n; i++)
		cin >> val[i];
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adjList[b].pb(a);
		adjList[a].pb(b);
	}

	for (int i = 1; i <= n; i++)
		if (!vis[i]) dfs(i);

	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (val[i] > dp[i])
			cnt++;

	cout << cnt << endl;
}

Measured memory_bytes: 15084