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


int main()
{
    std::ios::sync_with_stdio(false);	
	int N;
	cin>>N;
	vector<int> a(N);
	int mapcolor[10] = {0};
	for(int i = 0 ; i < N ; i++)
	{
		cin>>a[i];
		int kind ;
		if(a[i]<=399)
		{
			kind = 1;
		}
		else if(a[i]<=799)
		{
			kind = 2;
		}
		else if(a[i]<=1199)
		{
			kind = 3;
		}
		else if(a[i]<=1599)	
		{
			kind = 4;
		}
		else if(a[i]<=1999)
		{
			kind = 5;
		}
		else if(a[i]<=2399)
		{
			kind = 6;
		}
		else if(a[i]<=2799)
		{
			kind = 7;
		}
		else if(a[i]<=3199)
		{
			kind = 8;
		}
		else
		{
			kind = 9;
		}
		mapcolor[kind]++;
	}
	
	/*
	 1-399   1
400-799      2
800-1199     3
1200-1599    4
1600-1999    5
2000-2399    6
2400-2799    7
2800-3199    8
	*/
	
	int ansmin = 0;
	int zeros = 0;
	for(int i = 1 ; i <= 8 ; i++)
	{
		if(mapcolor[i]>0)
		{
			ansmin++;
		}
		else
		{
			zeros++;
		}
	}
	if(ansmin==0)
	{
		cout<<1<<" "<<mapcolor[9];
	}
	else
	{
		int ansmax = mapcolor[9] + ansmin;
		cout<<ansmin<<" "<<ansmax;
	}
	
    return 0;
}

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

 int main (){
     int n,a;
     cin >> n;
     int b[n];
     for(int i=0;i<n;i++){
         cin >> a;
         b[i]=a;
     }
     for (int i=n; 0<i;i--){
         if(i-1==0){
             cout << b[i-1] << endl;
         }else{
             cout << b[i-1] << " ";
         }
     }
 }



Measured memory_bytes: 3092
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> vc;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        vc.push_back(a);
    }

    int oddCnt = 0;
    for (int e: vc) if (e % 2 != 0) ++oddCnt;

    cout << (oddCnt % 2 == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 892
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def solve(A,B):
    N = len(A)
    start = [-1]*(N+1)
    end = [-1]*(N+1)
    start[A[0]] = 0
    end[A[-1]] = N

    for i,(p,a) in enumerate(zip(A,A[1:]),start=1):
        if a!=p:
            start[a] = i
            end[p] = i

    ca = [0]*(N+1)
    cb = [0]*(N+1)
    for a in A:
        ca[a] += 1
    for b in B:
        cb[b] += 1

    order = sorted((v for v in range(N+1) if ca[v] or cb[v]), key=lambda v:ca[v]+cb[v])
    res = [-1]*N
    # print(cnt)
    # print(start)
    # print(order)
    try:
        remaining = [(v,cb[v]) for v in order]
        s = set(v for v,_ in remaining)
        for v in reversed(order):
            if v not in s:
                continue
            add_back = None
            i = start[v]
            j = end[v]
            while i < j:
                u,r = remaining.pop()
                if u == v:
                    add_back = (u,r)
                    u,r = remaining.pop()
                n = min2(r,j-i)
                for k in range(i,i+n):
                    res[k] = u
                i += n
                if n < r:
                    remaining.append((u,r-n))
                else:
                    s.discard(u)
            if add_back:
                remaining.append(add_back)

        i = 0
        for u,r in remaining:
            while r > 0:
                while res[i] >= 0:
                    i += 1
                res[i] = u
                r -= 1
                i += 1
    except IndexError:
        return None
    return res


if __name__ == '__main__':
    N = int(readline())
    A = list(map(int,readline().split()))
    B = list(map(int,readline().split()))
    res = solve(A,B)
    if res is None:
        print('No')
    else:
        print('Yes')
        print(*res)

Measured memory_bytes: 74332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static List<int>[] graph;
        static void Solve()
        {
            var S = ReadLine().Split()[1];
            WriteLine($"A{S[0]}C");
        }
    }
}

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

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());
    ll ans = 0;
    rep(i, N){
        if(i <= K-1) continue;
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>
int main()
{
	int h, w;
	int i, j;
	while (1){
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)break;
		for (i = 0; i < h; i++){
				for (j = 0; j < w; j++){
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}
		return 0;
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
#define maxn 100005
int n,m;
struct per { int a[maxn]; per(){ memset(a,0,sizeof(a)); } }p,q;
per operator * (per a,per b) { per c; for(int i=1;i<=n;i++) c.a[i]=a.a[b.a[i]]; return c; }
per operator ^ (per a,int k) { per res; for(int i=1;i<=n;i++) res.a[i]=i; while(k) { if(k&1) res=res*a; a=a*a; k>>=1; } return res; }
per inv(per a) { per b; for(int i=1;i<=n;i++) b.a[a.a[i]]=i; return b; }
int main() {
	scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&p.a[i]); for(int i=1;i<=n;i++) scanf("%d",&q.a[i]);
	int x=(m-1)/6,y=m%6; per ip=inv(p),iq=inv(q),h=q*ip*iq*p,A=h^x,B;
	if(y==1) B=p; else if(y==2) B=q; else if(y==3) B=q*ip; else if(y==4) A=A*q,B=ip; else if(y==5) A=A*q*ip,B=iq; else A=A*q*ip,B=iq*p;
	per ans=A*B*inv(A); for(int i=1;i<=n;i++) printf("%d ",ans.a[i]);
}

Measured memory_bytes: 21504
n = int(input())
M = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    a,*b = map(int,input().split())
    a -= 1
    for i in b[1:]:
        M[a][i-1] = 1
for i in range(n):
    print(*M[i])


Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define il inline 
#define R register int
#define ll long long
#define gc getchar
using namespace std;
il int rd()
{
    R x=0,flag=1;
	char ch=0;
    while((ch>'9'||ch<'0')&&ch!='-')ch=gc();
	if(ch=='-')flag=-1,ch=gc();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=gc();
    return x*flag;
}
const int N=1000;
char a[N][N],b[N][N],c[N][N];
int n,m;
int main ()
{
	n=rd(),m=rd();
	for(R i=1;i<=n;i++)
		for(R j=1;j<=m;j++)
			b[i][j]=c[i][j]='.';
	
	for(R i=1;i<=n;i+=2)
		for(R j=1;j<m;j++)
			b[i][j]='#';
	
	for(R i=1;i<=n;i++)
		b[i][1]='#';

	
	for(R i=2;i<=n;i+=2)
		for(R j=2;j<=m;j++)
			c[i][j]='#';
	
	for(R i=1;i<=n;i++)
		c[i][m]='#';
	
	for(R i=1;i<=n;i++)
		for(R j=1;j<=m;j++)
		{

			cin>>a[i][j];
			if(a[i][j]=='#')
			{
				b[i][j]='#';c[i][j]='#';
			}
		}
	for(R i=1;i<=n;i++)
	{
		for(R j=1;j<=m;j++)
			cout<<b[i][j];
		cout<<endl;
	}
	cout<<endl;
	for(R i=1;i<=n;i++)
	{
		for(R j=1;j<=m;j++)
			cout<<c[i][j];
		cout<<endl;
	}
	return 0;
}


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

const ll MAX = 500000;
const ll INF = 1LL<<60;

ll cnt;

void merge(vector<ll> &seq, ll left, ll mid, ll right) {
    ll n1 = mid - left;
    ll n2 = right - mid;
    vector<ll> seq_left(n1), seq_right(n2);
    for(ll i = 0; i < n1; i++) seq_left.at(i) = seq.at(left+i);
    // for( ll i = 0; i < n1; i++) { cout << seq_left.at(i) << ' '; }
    // cout << endl;
    for(ll i = 0; i < n2; i++) seq_right.at(i) = seq.at(mid+i);
    // for( ll i = 0; i < n2; i++) { cout << seq_right.at(i) << ' '; }
    // cout << endl;
    seq_left.push_back(INF); seq_right.push_back(INF);
    ll i = 0, j = 0;
    for( ll k = left; k < right; k++ ) {
        cnt++;
        if( seq_left.at(i) <= seq_right.at(j)) {
            seq.at(k) = seq_left.at(i++);
        } else {
            seq.at(k) = seq_right.at(j++);
        }
    }
    // for( ll i = left; i < right; i++) { cout << seq.at(i) << ' '; }
    // cout << endl;
}

void merge_sort(vector<ll> &seq, ll left, ll right) {
    if( left + 1 < right) {
        ll mid = (left + right) / 2;
        // cout << "merge " << left << ' ' <<  mid << endl;
        merge_sort(seq, left, mid);
        // cout << "merge " << mid << ' ' << right << endl;;
        merge_sort(seq, mid, right);
        merge(seq, left, mid, right);
        // cout << "merged " << cnt << endl;
    }
}

signed main() {
    ll n; cin >> n; 
    vector<ll> seq(MAX);
    for( ll i = 0; i < n; i++ ) cin >> seq.at(i);
    cnt = 0;
    merge_sort(seq, 0, n);
    for( ll i = 0; i < n; i++) {
        cout << seq.at(i);
        if(i < n-1) printf(" ");
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 14724
#include <bits/stdc++.h>
using namespace std;
using state= pair<int, int>;

int64_t dp(state stat, const vector<int64_t> &data, map<state, int64_t> *memo){
  if(memo->count(stat)){ return memo->at(stat); }
  else{
    const int N= data.size();
    int rem,id;
    tie(rem, id)= stat;

    if(rem==0){ return memo->operator[](stat)= 0; }
    else if(2*rem- 1 > N-id){
      return memo->operator[](stat)= INT64_MIN;
    }
    else{
      state   pick= make_pair(rem-1, id+2);
      state nopick= make_pair(rem  , id+1);
      return memo->operator[](stat)= max(data.at(id)+ dp(pick, data, memo), dp(nopick, data, memo));
    }
  }
}

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

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  map<state, int64_t> memo;

  cout << dp(make_pair(N/2, 0), data, &memo) << endl;
}

Measured memory_bytes: 39120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[400];
ll dp[400][400];
ll Cost(ll i,ll j)
{
	ll sum=0;
	for(ll idx=i;idx<=j;idx++)
		sum+=arr[idx];
	return sum;
}
ll MinCost(ll i,ll j)
{
	if(i>=j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll mincost=1e18,cost=Cost(i,j);
	for(ll k=i;k<j;k++)
		mincost=min(mincost,MinCost(i,k)+MinCost(k+1,j)+cost);
	return dp[i][j] = mincost;
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	memset(dp,-1,sizeof(dp));
	cout<<MinCost(0,n-1);
}

Measured memory_bytes: 4888
/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    fastio;
    ll t, n, m, i, p, q, r, sum=0, a, b, c, d, f=0;
    char *ye="YES", *no="NO";
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>a;
        sum+=a;
    }
    if(sum<=n) cout<<n-sum<<endl;
    else cout<<"-1"<<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int x = N;
  int sum =0;
  
while (x>0){
   sum += (x%10);
   x = x/10;
}
  
if (N%sum == 0){
cout << "Yes" << endl;
}
  
  else{
  cout << "No" << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int cnt = 1;
    int ans = 0;
    for (int i = 0; i < N; i++){
        if (vec[i] == cnt){
            cnt++;
        }
        else{
            ans++;
        }
    }
  
    if (ans == N){
        ans = -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    //IOS;
    //ll t;cin>>t;while(t--)
    {
        ll a,b,c,d,i,j,k,l,m,n,sum=0,temp=0,f=0,cnt=0;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>a>>b;
            if(a==b)f++;
            else f=0;
            if(f>=3)temp=1;
        }
        if(temp)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;



    }
}


Measured memory_bytes: 3632
<?php
$input_line = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $s = str_replace(array("\r\n","\r","\n"), '', $s);
  $s = explode(" ", $s);
$flg = false;

for ($i = $s[0]; $i <= $s[1]; $i++) { 
  if ($i % $input_line == 0){
    $flg = true;
    break;
  }
}
if ($flg) {
  echo "OK";
}else {
  echo "NG";}

?>

Measured memory_bytes: 16128
# coding:utf-8
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
ans = sum(s)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            ans -= s[i]
            if ans % 10 != 0:
                print(ans)
                exit()
print(0)


Measured memory_bytes: 9076
package Scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc{
	my$self=shift;
	my$now_ord=0,$group_num=0,@low,@ord=(-1)x@{$self},@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			my$u=-1;
			while($u!=$v){
				$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
			}
			$group_num++;
		}
	};
	for$i(0..$#ord){
		$dfs->($i)if$ord[$i]==-1;
	}
	$_=$group_num-1-$_ for@ids;
	my@groups=map[],1..$group_num;
	for$i(0..$#ids){
		push@{$groups[$ids[$i]]},$i;
	}
	return\@groups;
}
package main;
my($N,$M)=split$",<>;
my$scc=Scc->new($N);
for(1..$M){
	my($a,$b)=split$",<>;
	$scc->add_edge($a,$b);
}
$groups=$scc->scc();
print scalar(@{$groups}),$/;
for$L(@{$groups}){
	print scalar(@{$L}),$","@{$L}",$/;
}


Measured memory_bytes: 289868
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int h,w;cin>>h>>w;
  int c[10][10];
  rep(i,10)rep(j,10){
    cin>>c[i][j];
  }
  rep(i,10)rep(j,10)rep(k,10)chmin(c[j][k],c[j][i] + c[i][k]);

  int ans = 0;
  rep(i,h)rep(j,w){
    int tmp;cin>>tmp;
    if(tmp >= 0)ans += c[tmp][1];
  }
  print(ans);

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long max(long long a,long long b)
{
	if(a>=b)
		return a;
	return b;
}
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;

	long long t = a;

	a = max(0,a-k);

	k = max(0,k-t);

	b = max(0,b-k);

	cout<<a<<" "<<b<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  bool rev = false;
  string src;
  cin >> src;
  deque<char> que(src.begin(), src.end());
  int num_q;
  cin >> num_q;
  for (int i = 0; i < num_q; ++i) {
    int T;
    cin >> T;
    if (T == 1) {
      rev = !rev;
    }
    else {
      int F;
      char C;
      cin >> F >> C;
      if ((!rev && F == 1) || (rev && F == 2)) {
        que.push_front(C);
      }
      else {
        que.push_back(C);
      }
    }
  }

  string ans(que.begin(), que.end());
  if (rev) {
    reverse(ans.begin(), ans.end());
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#define FIND 1
#define NOTFIND 0
#define PLUS 1
#define MINUS 0


int main(void){
    int i,X,N,p[100],a=0,tmp,flg,pmflg=PLUS,ans;
    scanf("%d %d",&X,&N);
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }

    while(1){
        flg = FIND;

        if(pmflg == PLUS){//pmflgがPLUS
            tmp = X+a;//　aが小さいのから探していく(絶対値の差が小さいもの)
            for(i=0;i<N;i++){//配列の小さいのから、そのtmpと同じのがあるか探す
                if(tmp == p[i]){
                    a++;//同じのがあればaをインクリメント
                    flg = NOTFIND;
                }
            }
            if(flg == FIND){
                ans = tmp;
                break;
            }else{
                pmflg = MINUS;
            }
        }else{//pmflgがMINUS
            tmp = X-a;//　aが小さいのから探していく(絶対値の差が小さいもの)
            for(i=0;i<N;i++){//配列の小さいのから、そのtmpと同じのがあるか探す
                if(tmp == p[i]){
                    flg = NOTFIND;
                }
            }
            if(flg == FIND){
                ans = tmp;
                break;
            }else{
                pmflg = PLUS;
            }
        }


    }
    
    // for(i=0;i<N;i++){
    // printf("%d ",p[i]);
    // }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
#define MAX(a,b) ((a)>(b)?(a):(b))
using namespace std;
int main(){
    int n,k,g,i;
    char s[20];
	cin>>s;
	if(strcmp(s,"Rainy")==0)cout<<"Sunny"<<endl;
    else if(strcmp(s,"Sunny")==0)cout<<"Cloudy"<<endl;
    else cout<<"Rainy"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int solve(int N, vector<vector<int>>& tasks){
	vector<vector<int>> dp(N,vector<int>(3));
	dp[0]=tasks[0];
	for (int i=1;i<N;i++){
		for (int j=0;j<3;j++){
			dp[i][j]=tasks[i][j]+max(dp[i-1][(3+j-1)%3],dp[i-1][(j+1)%3]);
		}
	}
	return max({dp[N-1][0],dp[N-1][1],dp[N-1][2]});
}
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
	int N;
    cin>>N;
    vector<vector<int>> task(N,vector<int>(3));
    for (int i=0;i<N;i++){
    	for (int j=0;j<3;j++)
    	cin>>task[i][j];
    }
	cout<< solve(N,task)<<endl;
    return 0; 
}


Measured memory_bytes: 14084
/**
*    created: 07.07.2020 15:02:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    cout << a[n-1]-a[0] << endl;
    return 0;
}

Measured memory_bytes: 3676
import java.util.*;
import static java.lang.Math.*;

public class Main {

	int w, h;
	int[][] board;
	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			w = in.nextInt(); h = in.nextInt();
			if(w==0 && h==0) return ;
			board = new int[h][w];
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					String s = in.next();
					char c = s.charAt(0);
					if(Character.isDigit(c)){
						board[i][j] = c - '0';
					}
					else if(c == 'T'){
						board[i][j] = -1;
					}
					else if(c == 'S'){
						board[i][j] = -2;
					}
				}
			}
			System.out.println(solve());
		}
	}

	class State{
		int dist, x, y, foot;
		State(int _d, int _y, int _x, int _f){
			this.dist = _d;
			this.y = _y;
			this.x = _x;
			this.foot = _f;
		}
	}

	class Cmp implements Comparator<State>{
		public int compare(State a, State b){
			return a.dist>b.dist?1:a.dist<b.dist?-1:0;
		}
	}

	int solve(){
		PriorityQueue<State> Q = new PriorityQueue<State>(11,new Cmp())	;
		int[][][] dist = new int[2][h][w];
		for(int k=0; k<2; k++)
			for(int i=0; i<h; i++)
				for(int j=0; j<w; j++)
					dist[k][i][j] = -1;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++)if(board[i][j] == -1){
				for(int k=0; k<2; k++)
					Q.add(new State(0,i,j,k));
			}
		}
		while(!Q.isEmpty()){
			State tp = Q.poll();
			if(dist[tp.foot][tp.y][tp.x] != -1) continue;
			dist[tp.foot][tp.y][tp.x] = tp.dist;
			for(int dx=1; dx<=3; dx++){
				for(int dy=-2; dy<=2; dy++)if(dx + abs(dy) <= 3){
					int ny = tp.y + dy, nx = tp.x + ((tp.foot==0)?dx:-dx);
					if(0<=ny && ny<h && 0<=nx && nx<w && board[ny][nx]!=0 && dist[1-tp.foot][ny][nx] == -1){
						Q.add(new State(tp.dist + (board[ny][nx]>0?board[ny][nx]:0), ny, nx, 1-tp.foot));
					}
				}
			}
		}
		
		int ret = 1<<20;
		for(int k=0; k<2; k++){
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(board[i][j] == -2 && dist[k][i][j] != -1 && ret > dist[k][i][j])
						ret = dist[k][i][j];
				}
			}
		}
		return ret==1<<20?-1:ret;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int d = sc.nextInt();
      switch(d){
      case 25:
        System.out.println("Christmas");
        break;
      case 24:
        System.out.println("Christmas Eve");
        break;
      case 23:
        System.out.println("Christmas Eve Eve");
        break;
      case 22:
        System.out.println("Christmas Eve Eve Eve");
        break;
      }
      
      
  }
}


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

#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
const int MAX_CHAR = 256;
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}

int main()
{
    hi();
  string s1,s2;
  cin>>s1;
  s2="ABC";
  int x = s1.compare(s2);
  if(x==0)
  {cout<<"ARC";}
  else
  {
    cout<<"ABC";}
    bye();
    return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK (cerr <<"OK"<< endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;

  cin >> n >> m;

  int minn, maxx;
  if(n == 1)
    minn = 0, maxx = 9;
  else if(n == 2)
    minn = 10, maxx = 99;
  else if(n == 3)
    minn = 100, maxx = 999;

  vector<ii> arr;
  while(m--) {
    int idx, d;
    cin >> idx >> d;
    idx--;
    arr.pb(ii(idx, d));
  }

  for(int x = minn; x <= maxx; x++) {
    string s = to_string(x);
    bool valid = true;
    for(ii &x: arr) {
      if(s[x.ff] - '0' != x.ss) {
        valid = false;
      }
    }

    if(valid)
      return cout << x << endl, 0;
  }
  cout << -1 << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
template<class T>bool CHMAX(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)

int main() {
	int a,b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (((a + b) % 2) == 1) {
		printf("IMPOSSIBLE\n");
	}
	else {
		printf("%d\n", (a+b) / 2);
	}

}

Measured memory_bytes: 128
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(ll i=(ll)(m) - 1;i>=(ll)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st s, t;
  ci(s, t);
  rep(i, sz(s)){
    if(s.at(i) != t.at(i)){
      co("No");
      rt 0;
    }
  }
  co("Yes");
}

Measured memory_bytes: 3548
A,B,C,X,Y = map(int,input().split())

ans = max(A*X+B*Y,C*max(X,Y)*2)

for nc in range(0,max(X,Y)*2+1,2):
  tmp = max((X-nc//2),0)*A+max((Y-nc//2),0)*B+nc*C
  ans = min(ans,tmp)
print(ans)

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> hoge(n);
	for(int i=0;i<n;i++) cin>>hoge.at(i);
	sort(hoge.begin(),hoge.end());
	vector<int> fuga;
	for(int i=0;i<n-1;i++) fuga.push_back(hoge.at(i));

	int nax=hoge.at(n-1);
	int nin=-1;
	double dis=pow(10,9);

	for(int i=0;i<n-1;i++){
		double ABS=(double)fuga.at(i)-(double)nax/2;
		if(ABS<0) ABS*=-1;

		if(ABS<=dis){
			dis=ABS;
			nin=fuga.at(i);
		}
	}

	cout<<nax<<" "<<nin<<endl;

	return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    lint six, nine;
    six = 6;
    nine = 9;

    std::vector<lint> cand;
    cand.push_back(1);

    std::vector<lint> dp_table(1e5 + 1, 0);

    while (six < 1e5)
    {
        cand.push_back(six);
        six *= 6;
    }

    while (nine < 1e5)
    {
        cand.push_back(nine);
        nine *= 9;
    }

    std::sort(cand.begin(), cand.end());

    for (int i = 1; i <= dp_table.size(); ++i)
    {
        lint min = 1e9;
        for (auto c : cand)
        {
            if (c > i)
                break;
            min = std::min(dp_table[i - c] + 1, min);
        }
        dp_table[i] = min;

        if (i == n)
        {
            printf("%lld", min);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec a(N);
    ll sum = 0;
    rep(i,N) {
        cin>>a[i];
        sum += a[i];
    }
    vec id(1, 0), ele(1, a[0]);
    ll last = a[0];
    reps(i,1,N){
        if(last < a[i]){
            id.push_back(i);
            ele.push_back(a[i]);
            last = a[i];
        }
    }
    vec num_plus(id.size(), 1);
    vec ans(N,0);
    rep(i, id.size()){
        ll lb = id[i], ub = (i == id.size() - 1 ? N : id[i+1]);
        reps(j, lb + 1, ub){
            auto ite = upper_bound(ele.begin(), ele.end(), a[j]);
            if(ite != ele.begin()) {
                ll index = ite - ele.begin();
                --ite;
                ans[id[index]] += a[j] - *ite;
                ++num_plus[index];
                //cout << j << ' ' << *ite << endl;
            }
        }
    }
    ll num = 1;
    /*rep(i,N) cout<<ans[i]<<' ';
    cout<<endl;
    rep(i,id.size()) cout<<num_plus[i]<<' ';
    cout<<endl;*/
    for(int i = id.size() - 1; i >= 0; --i){
        if(i == 0){
            ans[0] = sum;
        }else{
            ans[id[i]] += (ele[i] - ele[i-1]) * num;
            num += num_plus[i];
            sum -= ans[id[i]];
        }
    }
    rep(i,N) cout<<ans[i]<<endl;
}

Measured memory_bytes: 5228
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<=n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
	//freopen("t.in","r",stdin);
	//freopen("t.out","w",stdout);
	IOS;
	int a;
	string s;
	cin >> a >> s;
	if(a>=3200)
		cout << s << endl;
	else
		cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {

  double N;

  std::cin >> N;
  double sum=0.0;
  double tmp;
  string S;
  for(int i=0;i<N;i++){
    cin >>tmp;
    cin >>S;
    if(S=="JPY"){
      sum += tmp*1.0;
    }else{
      sum += tmp *380000.0;
    }
  }
  cout <<sum<<endl;
  return 0;
   
}


Measured memory_bytes: 256
N=int(input())
p=[[]for _ in range(N+1)]
for _ in range(N-1):
  u,v,w=map(int,input().split())
  p[u].append((v,w))
  p[v].append((u,w))
s=[(1,0)]
l=[-1]*N
while s:
  a,w=s.pop()
  l[a-1]=w%2
  for b,c in p[a]:
    if l[b-1]==-1:
      s.append((b,w+c))
for i in l:
	print(i)

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int A = 1;
  int B1, B2;
  
  for (int i = 0; i < N; i++) {
    
    B1 = A * 2;
    B2 = A + K;
    
    if (B1 > B2) {
      A = B2;
    } else {
      A = B1;
    }
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

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

    long long a = 1;
    string ans = "";

    if ( N == 0 ) { cout << 0 << endl; return 0; }

    bool b = true;
    while ( N != 0 ) {
        a *= 2;
        if ( N%a == 0 ) { ans += '0'; }
        else {
            ans += '1';
            N -= ( b ? a/2 : -(a/2) );
        }

        b = !b;
    }
    reverse( ans.begin(), ans.end() );
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n,m;	cin >> n >> m;
    vector<vector<int> >city(n);
    rep(i, m){
	int a,b;
	cin >> a >> b;
	city[a-1].push_back(b-1);
	city[b-1].push_back(a-1);
    }
    rep(i, n){
	cout << city[i].size() << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char R[510][510],B[510][510],P[510][510];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",P[i]+1);
	memcpy(R,P,sizeof(P));
	memcpy(B,P,sizeof(P));
	for(int i=1;i<=n;i++)
		for(int j=2;j<m;j++)
			if(i&1)R[i][j]='#';
			else B[i][j]='#';
	for(int i=1;i<=n;i++)
		R[i][1]=B[i][m]='#';
	for(int i=1;i<=n;i++)
		printf("%s\n",R[i]+1);
	puts("");
	for(int i=1;i<=n;i++)
		printf("%s\n",B[i]+1);
	return 0;
}

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

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int rest[26];

char winner(string &s, int &i);
char person(string &s, int &i);

char winner(string &s, int &i){
    if(s[i] == '['){
        ++i;
        char lhs = winner(s, i);
        ++i;
        char rhs = winner(s, i);
        ++i;
        if(lhs == '#' || rhs == '#') return '#';
        else if(rest[lhs-'a'] == 0){
            if(rest[rhs-'a'] >= 1){
                --rest[rhs-'a'];
                return rhs;
            }
            else return '#';
        }
        else{
            if(rest[rhs-'a'] != 0) return '#';
            --rest[lhs-'a'];
            return lhs;
        }
    }
    else return person(s, i);
}

char person(string &s, int &i){
    char ret = s[i];
    ++i;
    return ret;
}

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(auto c: s)if('a' <= c && c <= 'z') ++cnt;
    rep(i, cnt){
        char c;
        int a;
        scanf(" %c%d", &c, &a);
        rest[c-'a'] = a;
    }
    int i = 0;
    char w = winner(s, i);
    puts((w != '#' && rest[w-'a'] == 0) ? "Yes" : "No");
}


Measured memory_bytes: 3248
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

lint mypow(lint a, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a *= a;
		n >>= 1;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, K;
	cin >> N >> K;

	if (K % 2 == 0) cout << mypow(N / (K / 2) - N / K, 3) + mypow(N / K, 3) << "\n";
	else cout << mypow(N / K, 3) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define fef(i,a,b) for(ll i=a;i<=b;i++)
#define rer(i,a,b) for(ll i=b;i>=a;i--)
#define wew while(true)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "A.inp"
#define FILE_OUT "A.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define INF (ll(1000000007))
#define MAXN 300011
#define x first
#define y second
#define pii pair<int,int>
#define piii pair<int,pii>
#define pb push_back
#define endl "\n"
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> order_set;
typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> order_trie;
typedef long long ll;
class DisjointSet{ public:
    vector<int> parent;
    DisjointSet(int n): parent(n) { for(int i=0; i<n; i++) parent[i] = i; }
    void join(int a, int b) { parent[find(b)] = find(a); }
    int find(int a){ return a == parent[a] ? a : parent[a] = find(parent[a]); }
    bool check(int a, int b){ return find(a) == find(b); }
};
//---------END-------//

long long N;
pii A[MAXN],B[MAXN],C[MAXN];

int manhattan(int X, int Y){
    return abs(A[X].x-A[Y].x)+abs(A[X].y-A[Y].y);
}
int main(){
    //ofile;
    cin >> N;
    for (int i=1;i<=N;i++){
        cin >> A[i].x >> A[i].y;
        B[i]={A[i].x+A[i].y,i};
        C[i]={A[i].x-A[i].y,i};
    }
    cout << max(manhattan(max_element(B+1,B+N+1)->y,min_element(B+1,B+N+1)->y),
                manhattan(max_element(C+1,C+N+1)->y,min_element(C+1,C+N+1)->y));
}



Measured memory_bytes: 8320
H, W, K = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
dp = Array.new(H + 1) { Array.new(W, 0) }
dp[0][0] = 1
H.times do |h|
  # ある高さにおいて、2^(W-1)通りの横線の引き方がある
  (0...(1 << (W - 1))).each do |bit|
    W.times do |w|
      # check
      # 正しくないあみだくじを弾く
      # 1が連続して2つあったらアウト
      flag = false
      (1...W).each do |i|
        if bit[i] == 1 && bit[i - 1] == 1
          flag = true
        end
      end
      next if flag
      # transition
      if w != W - 1 && bit[w] == 1
        target = w + 1
      elsif w != 0 && bit[w - 1] == 1
        target = w - 1
      else
        target = w
      end
      dp[h + 1][target] = (dp[h + 1][target] + dp[h][w]) % MOD
    end
  end
end
puts dp[H][K - 1]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353

struct Divisor {
    long long N;
    vector<long long> result;
    vector<pair<long long, int>> c;
    
    Divisor(long long n) { 
        N = n;
        calc();
    }

    void calc() {
        long long d = N;
        for (long long i = 2; i * i <= d; i++) {
            int count = 0;
            while (d % i == 0) {
                d /= i; count++;
            }
            if (count) c.emplace_back(i, count);
        }
        if (d != 1) c.emplace_back(d, 1);
        rec(0, 1);
        sort(result.begin(), result.end());
    }

    void rec(int index, int cur) {
        if (index == c.size()) {
            result.emplace_back(cur);
            return;
        }
        for (int i = 0; i <= c[index].second; i++) {
            rec(index+1, cur);
            cur *= c[index].first;
        }
    }
};

int main() {
    int n; cin >> n;
    string s; cin >> s;
    long long all = 0; vector<long long> memo(n, 0);
    for (int i = 0; i < n; i++) {
        all *= 2; all += s[i] - '0';
        all %= mod; memo[i] = all;
    }
    all = (all+1) * n % mod * 2 % mod;
    Divisor d(n);
    vector<int> t;
    for (auto &x: d.result) {
        if (x == 1) continue;
        if (x & 1) t.emplace_back(x); 
    }

    map<int, long long> m;
    for (auto &x: t) {
        int h = n * 2 - n * 2 / x;
        for (auto &it: m) {
            if (x % it.first == 0) h = (h + mod - it.second) % mod;
        }
        m[x] = h;
        int loop = n / x;
        long long cnt = memo[loop-1]+1;
        for (int i = 0; i < n; i++) {
            int a = i / loop;
            int b = s[i % loop] - '0';
            if (a & 1) b = !b;
            if (s[i] - '0' < b) {
                cnt--; break;
            } else if (s[i] - '0' != b) {
                break;
            }
        }
        long long sub = cnt * m[x] % mod;
        all = (all - sub + mod) % mod;
    }
    cout << all << endl;
    return 0;
}

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

int n,a,b,ans;

int main(){
	std::cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int k=i,sum=0;
		while( k>0 ) sum += k%10,k /= 10;
		if( sum<=b && sum>=a ) ans+=i;
	}
	std::cout<<ans;
	
	return 0;
}

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

int gcd(int a, int b)
{
    if (a < b)
    {
        swap(a, b);
    }
    if (b == 0)
    {
        return a;
    }
    return gcd(a % b, b);
}
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    vector<int> S_pre, S_back;
    S_pre.push_back(A[0]);
    S_back.push_back(A[N - 1]);
    for (int i = 1; i < N; i++)
    {
        int tmp_pre = gcd(S_pre[i - 1], A[i]);
        int tmp_back = gcd(S_back[i - 1], A[N - 1 - i]);
        S_pre.push_back(tmp_pre);
        S_back.push_back(tmp_back);
    }
    reverse(S_back.begin(), S_back.end());
    //for (int i = 0; i < N; i++)
    //{
    //    cout << "S_pre:" << S_pre[i];
    //    cout << " S_back:" << S_back[i] << endl;
    //}
    vector<int> calc;
    calc.push_back(S_back[1]);
    for (int i = 1; i < N - 1; i++)
    {
        int tmp_calc = gcd(S_pre[i - 1], S_back[i + 1]);
        calc.push_back(tmp_calc);
    }
    calc.push_back(S_pre[N - 2]);
    //for (int i = 0; i < calc.size(); i++)
    //{
    //    cout << "calc:" << calc[i] << endl;
    //}
    int ans = *max_element(calc.begin(), calc.end());
    cout << ans << endl;
    return 0;
}

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

#define MAX 100002

int n;
int q;

vector<long long int> v;

map<long long int, long long int> mp;
map<long long int, long long int> nex;

long long int im[MAX];

int main(){
	cin >> n;
	cin >> q;
	v.push_back(n);
	for (int i = 0; i < q; i++){
		long long int a;
		scanf("%lld", &a);
		v.push_back(a);
	}
	long long int cur_len = v.back();
	mp[-cur_len] = 1;
	for (int i = v.size() - 1; i > 0; i--){
		nex.clear();
		long long int pr = v[i - 1];
		vector<long long int> del;
		del.clear();
		for (auto it = mp.begin(); it != mp.end(); it++){
			long long int val = -(*it).first;
			if (val <= pr){
				break;
			}
			long long int se = (*it).second;
			long long int sa = val / pr;
			nex[pr] += sa*se;
			sa = val%pr;
			if (sa){
				nex[sa] += se;
			}
			del.push_back((*it).first);
		}
		for (int j = 0; j < del.size(); j++){
			mp.erase(del[j]);
		}
		for (auto it = nex.begin(); it != nex.end(); it++){
			mp[-(*it).first] += (*it).second;
		}
		nex.clear();
	}
	for (auto it = mp.begin(); it != mp.end(); it++){
		im[-(*it).first] += (*it).second;
	}
	for (int i = n-1; i >= 1; i--){
		im[i] += im[i + 1];
	}
	for (int i = 1; i <= n; i++){
		printf("%lld\n", im[i]);
	}
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= x && i != n-1) x -= a[i];
        else{
            if(i == n-1 && a[i] == x) cnt++;
            break;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int A[1<<20];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	int r=1;
	long long sum=0;
	long long res=0;
	for(int l=1;l<=n;l++){
		while((r<=n)&&(sum+A[r]==(sum^A[r]))){
			sum+=A[r];
			r++;
		}
		res+=r-l;
		sum-=A[l];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024