akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

#[derive(Debug, Clone, Copy)]
enum Judge {
    Equal(usize),
    Less(usize),
    No,
    Uninitialized,
}

fn main() {
    use Judge::*;
    input! {
        n: usize,
        xyh: [(usize, usize, usize); n],
    }

    let mut board = vec![vec![Uninitialized; 101]; 101];

    for i in 0..=100 {
        for j in 0..=100 {
            let mut height = Uninitialized;
            for (x, y, h) in xyh.iter().copied() {
                let pred = predict_height(i, j, x, y, h);
                match (height, pred) {
                    (Equal(h), Less(pred)) if h > pred => {
                        height = No;
                        break;
                    },
                    (Less(h), Less(pred)) if h > pred => {
                        height = Less(pred);
                    },
                    (Less(h), Equal(pred)) if h < pred => {
                        height = No;
                        break;
                    }
                    (Less(_), Equal(pred)) => {
                        height = Equal(pred);
                    }
                    (Equal(h), Equal(pred)) if h != pred => {
                        height = No;
                        break;
                    },
                    (Uninitialized, x) => {
                        height = x;
                    }
                    _ => {},
                }
            }
            board[i][j] = height;
        }
    }

    let mut ans = (0, 0, 0);

    for i in 0..=100 {
        for j in 0..=100 {
            let h = &board[i][j];
            if let Equal(h) = h {
                if ans.2 < *h {
                    ans = (i, j, *h);
                }
            }
        }
    }

    println!("{} {} {}", ans.0, ans.1, ans.2);
}

fn predict_height(c_x: usize, c_y: usize, x: usize, y: usize, h: usize) -> Judge {
    let ans = (c_x as isize - x as isize).abs() + (c_y as isize - y as isize).abs();
    let ans = ans as usize + h;
    if h == 0 {
        Judge::Less(ans)
    } else {
        Judge::Equal(ans)
    }
}


Measured memory_bytes: 2252
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int N; cin >>N;
  string S; cin >>S;
  ll ans = 0;
  string state = "none";
  int i=0;
  if (N==1){ ans = 3; i++; }
  while (i<N){
    if (i==0){
      if (S.at(i) == S.at(i+1)){
        ans = 6; i+=2; state = "horizontal"; continue;
      }else{
        ans = 3; i++; state = "vertical"; continue;
      } 
    }
    if (i==N-1){
      if (state == "vertical") ans = ans * 2 % MOD;
      i++; break;
    }
    if (S.at(i) == S.at(i+1)){
      if (state == "horizontal") ans = ans * 3 % MOD;
      else if (state == "vertical") ans = ans * 2 % MOD;
      i+=2; state = "horizontal"; continue;
    }else{
      if (state == "vertical") ans = ans * 2 % MOD;
      i++; state = "vertical"; continue;
    }
  }

  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;

int64_t f(int64_t L){
  if(L==0){return 1;}
  return 2*f(L-1)+3;
}
int64_t fp(int64_t L){
  if(L==0){return 1;}
  return 1+2*fp(L-1);
}
int64_t s(int64_t L,int64_t X){
  if(L==0){return 1;}
  if(X>=2+2*f(L-1)){return 2*fp(L-1)+1;}
  else if(X>2+f(L-1)){return s(L-1,X-2-f(L-1))+1+fp(L-1);}
  else if(X>1+f(L-1)){return 1+fp(L-1);}
  else if(X>1){return s(L-1,X-1);}
  else {return 0;}
}
int main() {
  int64_t N,X;
  cin>>N>>X;
  cout<<s(N,X)<<endl;
  return 0;  
}

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

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

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

	string s; cin >> s;

	int ans = 0;

	int cnt_J = 0;
	int cnt_O = 0;
	int cnt_I = 0;

	char p = 'X';

	for (int i = 0;i < s.size();i++){
		if(s[i] == 'J') {
			cnt_O = cnt_I = 0;
			if(p != s[i]) cnt_J = 1;
			else cnt_J++;
		} else if(s[i] == 'O') {
			if(cnt_J == 0){
				cnt_J = cnt_O = cnt_I = 0;
			} else {
				if(p == 'I') cnt_J = cnt_O = cnt_I = 0;
				else cnt_O++;
			}
		} else if(s[i] == 'I'){
			if(cnt_O == 0){
				cnt_J = cnt_O = cnt_I = 0;
			} else {
				cnt_I++;
				if(cnt_O <= cnt_J && cnt_O <= cnt_I) ans = max(cnt_O,ans);
			}
		}
		p = s[i];
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, W;
  ll dp[150][100500];
  ll w[100500], v[100500];
  
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    scanf("%lld%lld",&N,&W);
    for(int i=1;i<=N;i++) scanf("%lld%lld",w+i,v+i);
    for(int i=0;i<=N;i++) for(int j=0;j<=100200;j++) dp[i][j] = 1e18;
    dp[0][0] = 0;
    ll ans = 0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=100100;j++){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if( j-v[i] >= 0 ) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            if( dp[i][j] <= W ) ans = max(ans, (ll)j);
        }
    }
    printf("%lld\n",ans);
  return 0;
  
}

Measured memory_bytes: 80640
#include <cstdio>
#include <list>
#include <string>

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    list<int> l;
    for (size_t i=0; i<n; ++i) {
        char buf[1<<4];
        scanf("%s", buf);
        string command(buf);

        if (command == "insert") {
            int x;
            scanf("%d", &x);
            l.push_front(x);
        } else if (command == "delete") {
            int x;
            scanf("%d", &x);
            for (list<int>::iterator it=l.begin(); it!=l.end(); ++it)
                if (*it == x) {
                    l.erase(it);
                    break;
                }
        } else if (command == "deleteFirst") {
            l.pop_front();
        } else if (command == "deleteLast") {
            l.pop_back();
        }
    }

    for (list<int>::iterator it=l.begin(), last=--l.end(); it!=l.end(); ++it)
        printf("%d%c", *it, it!=last? ' ':'\n');

    return 0;
}

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

int main() {
  double n,l,all;
  cin >> n >> l;
  all=(l+(n-1)*0.5)*n;
  if(l<0&&(0-l)<n) cout << all << endl;
  else if(l<0) cout << all-l-n+1 << endl;
  else cout << all-l << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()


if A%C == 0:
	left_c = A//C - 1
else:
	left_c = A//C
right_c = B//C

if A%D == 0:
	left_d = A//D - 1
else:
	left_d = A//D
right_d = B//D

if A%((C*D)//gcd(C, D)) == 0:
	left_w = A//((C*D)//gcd(C, D)) - 1
else:
	left_w = A//((C*D)//gcd(C, D))
right_w = B//((C*D)//gcd(C, D))

print((B - A + 1) - (right_c - left_c) - (right_d - left_d) + (right_w - left_w))

Measured memory_bytes: 59628
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let [n,m,k] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let bs = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n m k as bs
  print ans

compute :: Int -> Int -> Int -> [Int] -> [Int] -> Int
compute n m k as bs = maximum $ loop ars 0 0 bs
  where
    ars = reverse $ zip [0..] $ takeWhile (0 <=) $ scanl (-) k as

loop [] _ _ _ = []
loop ((a,r):_) _ bcnt [] = [a+bcnt]
loop arars@((a,r):ars) bsum bcnt bbs@(b:bs)
  | r >= bsum1 = loop arars bsum1 (succ bcnt) bs
  | True       = a+bcnt : loop ars bsum bcnt bbs
  where
    bsum1 = bsum + b

Measured memory_bytes: 40452
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

struct key__t
{
  ll cost;
  size_t can_open_chest;
};

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  cin >> n >> m;
  vector <key__t> keys;
  rep (i, m)
  {
    key__t key;
    cin >> key.cost;
    size_t key_n;
    cin >> key_n;
    key.can_open_chest = 0;
    rep (j, key_n)
    {
      size_t index;
      cin >> index;
      -- index;
      key.can_open_chest |= 1ull << index;
    }
    keys.push_back (move (key));
  }

  vector <vector <ll>> dp (m + 1, vector <ll> (1ull << n, inf));
  rep (i, m + 1)
  {
    dp [i] [0] = 0;
  }
  rep (i, m)
  {
    auto && key = keys [i];
    rep (j, 1ull << n)
    {
      dp [i + 1] [j] = min (dp [i + 1] [j], dp [i] [j]);
      dp [i + 1] [j | key.can_open_chest] = min ({dp [i + 1] [j | key.can_open_chest], dp [i] [j | key.can_open_chest], dp [i] [j] + key.cost});
    }
  }
  auto ans = dp [m] [(1ull << n) - 1];
  if (ans >= inf)
  {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 32384
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, K) = Read2Longs();
            var P = ReadLongs().OrderBy(x => x).ToList();

            var sum = P.Take((int)K).Sum();

            return sum;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28532
#include<stdio.h>
#define LEN 1000000

typedef struct{
  char name[20];
  int time;
}Que;

Que que[LEN];
int head=0, tail=0;

void push(Que);
Que pop(void);
int size();

//----Main----
int main()
{
  int N, q;
  Que Q;
  int i, j, k;
  int times=0;

  //Read
  scanf("%d %d", &N, &q);
  for(i=0; i<N; i++)
    {
      scanf("%s %d", Q.name, &Q.time);
      push(Q);
    }

  //Start process
  while(1)
    {
      Q=pop();
      if(Q.time<=q)
	{
	  times+=Q.time;
	  printf("%s %d\n", Q.name, times);
	}
      else
	{
	  Q.time-=q;
	  times+=q;
	  push(Q);
	}

      //End process
      if(size()==0)break;
    }

  return 0;
}

//-----Methpd-----
void push(Que q)
{
  que[head]=q;
  head++;
}

Que pop(void)
{
  tail++;
  return que[tail-1];
}

int size(void)
{
  return head-tail;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
char s[110];
int main(){
	int k,n,i;
	scanf("%d%s",&k,s+1);
	n=strlen(s+1);
	if(n<=k)printf("%s\n",s+1);
	else{
		for(i=1;i<=k;i++)printf("%c",s[i]);
		printf("...\n");
	}
}
 

Measured memory_bytes: 1600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int i,c,d;
  char str[100],s[10],*p,a[10],b[10];
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  a[0]=s[0],a[1]=s[1],b[0]=s[2],b[1]=s[3];
  
  c=atoi(a);
  d=atoi(b);
  
  if((c<=0 || c>12) && (d<=0 || d>12)){
    printf("NA\n");
  }else if(c<=0 || c>12){
    printf("YYMM\n");
  }else if(d<=0 || d>12){
    printf("MMYY\n");
  }else{
    printf("AMBIGUOUS\n");
  }
  
  
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k, s;
    cin >> n >> k >> s;
    vl ret(n, 0);
    if (s == 0) {
        ll x = 0;
        while ((x + 1) * (x + 2) / 2 < k) {
            x++;
        }
        k -= x * (x + 1) / 2;
        for (int i = x; i < x + 2 * k; i += 2) {
            ret[i] = 1;
        }
        for (int i = x + 2 * k; i < n; ++i) {
            ret[i] = 1;
        }
        print(ret);
    } else {
        for (int i = 0; i < k; ++i) {
            ret[i] = s;
        }
        ll num = s + 1;
        if (s == 1000000000)
            num = 1;
        for (int i = k; i < n; ++i) {
            ret[i] = num;
        }
        print(ret);
    }
    return 0;
}

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

int main(){
  int a, b, x;
  cin >> a >> b >> x;
  int i = a + b;
  if(x == a){
    cout << "YES" << endl;
  }else if(a > x){
    cout << "NO" << endl;
  }else if(i >= x){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    ll num = abs(x / d);
    if (num > k) {
        if (x > 0) {
            cout << abs(x - d * k) << endl;
        }
        else {
            cout << abs(x + d * k) << endl;
        }
        return 0;
    }
    else {
        ll rest = k - num;
        if (rest % 2 == 0) {
            cout << abs(x%d) << endl;
        }
        else {
            cout << abs(abs(x%d) - d) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int x,y;
  cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  int a,b;
  a=y-(x+y)/3;b=x-(x+y)/3;
  if(a<0 or b<0){
    cout<<0<<endl;
    return 0;
  }
  ll MOD=1000000007;
  ll factorial[1000001];
  factorial[0]=1;
  for(int i=1;i<1000001;i++){
    factorial[i]=mod(factorial[i-1]*i,MOD);
  }
  ll inv[1000001];
  inv[1000000]=modpow(factorial[1000000],MOD-2,MOD);
  for(int i=999999;i>=0;i--){
    inv[i]=mod(inv[i+1]*(i+1),MOD);
  }
  cout<<mod(factorial[a+b]*mod(inv[a]*inv[b],MOD),MOD)<<endl;
  return 0;
}

Measured memory_bytes: 19240
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k, c; string s;
    cin >> n >> k >> c >> s;
    vi l(n+1, 0), r(n+1, 0);

    // 右方向に貪欲で働く日を決める
    ll last = -c-1, cnt = 0;
    for(ll i=0; i<n; i++){
        if(i-last > c && s[i] == 'o') cnt++, last = i;
        l[i+1] = cnt;
    }

    // 左方向に貪欲で働く日を決める
    string t = s;
    reverse(all(t));
    last = -c-1, cnt = 0;
    for(ll i=0; i<n; i++){
        if(i-last > c && t[i] == 'o') cnt++, last = i;
        r[i+1] = cnt;
    }

    // 重なっている日を出力
    rep(i, n){
        if(s[i] == 'x') continue;
        if(l[i] + r[n-1-i] < k) cout << i+1 << endl;
    }
}

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

int main(){
	int num[5], i, j, a;
	for(i = 0; i < 5; i++){
		cin >> num[i];
	}
	
	for(j = 4; j >= 0; j--){
		for(i = 0; i < j; i++){
			if(num[i] < num[i+1]){
				a = num[i];
				num[i] = num[i+1];
				num[i+1] = a;
			}
		}
	}
	
	for(i = 0; i < 4; i++){
		cout << num[i] << ' ';
	}
	cout << num[4] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,b;
	cin>>w>>b;
	w--;b--;
	vs s(100);
	rep(i,50){
		s[i]=string(100,'.');
		s[i+50]=string(100,'#');
	}
	for(int i=1;i<49;i+=2)for(int j=1;j<99;j+=2){
		if(b--==0)goto p1;
		s[i][j]='#';
	}
	p1:;
	for(int i=1;i<49;i+=2)for(int j=1;j<99;j+=2){
		if(w--==0)goto p2;
		s[i+50][j]='.';
	}
	p2:;
	cout<<"100 100"<<endl;
	rep(i,100)cout<<s[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





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

  int k,x;
  cin>>k>>x;
  for(int i=x-k+1;i<=x+k-1;i++)
    cout<<i<<' ';



}


Measured memory_bytes: 256
/*
    Author : Pranav_Raut.
*/

#include<bits/stdc++.h>
using namespace std;
#define input(arr,n) for(ll i=0;i<n;i++){cin>>arr[i];}
typedef long long int ll;
ll MOD = 1000000007;
ll MAXN = 100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll t = 1;
    while(t--)
    {
        /* JUST CODE TILL YOU CRACK IT !!! */
		ll n;
      	cin>>n;
      	ll arr[n+1];
      	input(arr,n);
      	arr[n] = arr[n-1];
      	ll ans[n+1];
      	ans[n-1] = 0;
      	ans[n] = 0;
      	for(ll i=n-2;i>=0;--i)
        {
        	ans[i] = min(abs(arr[i]-arr[i+1])+ans[i+1],abs(arr[i]-arr[i+2])+ans[i+2]);
        }
      	cout<<ans[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

void solve(void)
{
  int X;cin>>X;
  int q = X/11;
  int r = X%11;
  int ANS = q*2;
  if(r <= 6 && r != 0)
  {
    ANS++;
  }
  else if(r != 0)
  {
    ANS += 2;
  }
  cout<<ANS<<endl;
  
  return; 
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long k = sc.nextLong();
		
		if (Math.abs(a-b) > 1000000000000000000L) {
			System.out.println("Unfair");
		} else {
			if (k % 2L == 0) {
				System.out.println(a-b);
			} else {
				System.out.println((a-b)*-1);
			}
		}
	}
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll b=0;
int main()
{
	cin>>s;
	for(int i=0;i<=s.size();i++)
	{
		b=b+s[i];
	}
	if(b==198)
	cout<<"ARC";
	else
	cout<<"ABC"; 
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;



public class Main {
    public static void main(String Args[]) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int t=sc.nextInt();
        int l[] = new int[N];

        for(int i=0; i<N; i++)
        {
            l[i]=sc.nextInt();
        }
       Arrays.sort(l);
        int result=0;
        for(int i=0; i<t; i++)
        {
            result+=l[N-1-i];
        }
        System.out.println(result);
    }


}



Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int num = Integer.parseInt(in.next());
	int len = Integer.parseInt(in.next());
	in.close();
	int total = sum(num, len);
	int eat = len;
    if (len < 0) {
      eat = num <= len * (-1) ? len + num - 1 : 0;
    }
    int ans = total - eat;
    System.out.println(ans);
  }
  
  static int sum(int num, int len) {
    num--;
    if (num == 0) return len;
    return len + sum(num, len + 1);
  }
}

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

int main() {
	// 変数の宣言
	int a, b;

	// 値の取得
	cin >> a >> b;

	// 判定
	if ( a*b %2 ==0)
	{
		// 偶数の場合
		cout << "Even";
	}else
	{
		// 奇数の場合
		cout << "Odd";
	}
	
	
	

}

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() {
    ll x, y;
    cin >> x >> y;
    int i = 1;
    while(true){
    x = x * 2;
    if(x > y){
        break;
    }
    i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    a.sort()
    var ma = 0L
    var mi = 0L
    val mod = 1000000007L
    val c = comb(n,mod)
    c.init()
    for(i in k - 1 until n){
        ma += c.calc(i, k - 1) * a[i] % mod
        ma %= mod
    }
    for(i in 0 .. n - k){
        mi += (c.calc(n - i - 1, k - 1) * a[i] % mod + mod) % mod
        mi %= mod
    }
    println((ma - mi + mod) % mod)
}

class comb{
    val n : Int
    val mod : Long
    val f : LongArray
    val rf : LongArray
    constructor(n : Int, m : Long){
        this.n = n
        this.mod = m
        this.f = LongArray(n + 1)
        this.rf = LongArray(n + 1)
    }

    fun inv(x : Long) : Long{
        var ret = 1L
        var k = mod - 2
        var y = x
        while(k > 0){
            if(k and 1L == 1L) ret = (ret * y) % mod
            y = (y * y) % mod
            k /= 2
        }
        return ret
    }

    fun init(){
        f[0] = 1
        for(i in 1 .. n) f[i] = (f[i - 1] * i) % mod
        for(i in 0 .. n) rf[i] = inv(f[i])
    }

    fun calc(n : Int, k : Int) : Long{
        if(n > this.n || n < 0 || k > this.n || k < 0 || n < k) return 1L
        val a = f[n]
        val b = rf[n - k]
        val c = rf[k]
        val bc = (b * c) % mod
        return (a * bc) % mod
    }
}

Measured memory_bytes: 73788
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int c[3][3];
	rep(i, 3)rep(j, 3)cin >> c[i][j];
	int num1, num2;
	rep(i, 2) {
		rep(j, 3) {
			if (!j)num1 = c[i + 1][j] - c[i][j];
			else if (num1 != c[i + 1][j]-c[i][j]) {
				cout << "No";
				return 0;
			}

			if (!j)num2 = c[j][i + 1] - c[j][i];
			else if (num2 != c[j][i + 1] - c[j][i]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define repb(a,b) for(lli i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x,a;
    cin>>x>>a;
    if(x<a)
    cout<<"0";
    else
    cout<<"10";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

map<pair<int, int>, int> xy;
int H, W, N;
ll ans[10];

void solve() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> b >> a;
		for (int y = max(2, b-1); y <= min(H-1, b+1); y++) {
			for (int x = max(2, a - 1); x <= min(W-1, a + 1); x++) {
				xy[P(x, y)]++;
			}
		}
	}

	ll sum = 0;
	for (auto itr = xy.begin(); itr != xy.end(); ++itr) {
		ans[itr->second]++;
		sum++;
	}
	ans[0] = ((ll)H - 2)*(W - 2) - sum;
	
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

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

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    long long int n,i,fac=1;
    cin >> n;
    for(i=n; i>0; i--)
        fac*=i;
    cout << fac << endl;
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
 
int main() {
  cout << fixed << setprecision(20);
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  double RA = ((H * 60 + M) / 2);
  double TA = RA * (PI / 180);
  double AX = A * sin(TA);
  double AY = A * cos(TA);
  double RB = M * 6;
  double TB = RB * (PI / 180); 
  double BX = B * sin(TB);
  double BY = B * cos(TB);
  cout << sqrt((AX-BX) * (AX-BX) + (AY-BY) * (AY-BY)) << endl;
}


Measured memory_bytes: 4096
n, m = map(int, input().split())
ans = dict.fromkeys([str(i) for i in range(1,n+1)], 0)
li = [list(map(int, input().split())) for j in range(m)]
for i in range(m):
    ans[str(li[i][0])] += 1
    ans[str(li[i][1])] += 1
for k in range(1,n+1):
    print(ans[str(k)])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int H, W, h, w;
int ans[555][555];

int main(void) {
    scanf("%d%d%d%d", &H, &W, &h, &w);
    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;
        return 0;
    }
    LL sum = 0;
    REP(i, H) {
        REP(j, W) {
            
            if (i % h == 0 && j % w == 0) {
                ans[i][j] = INF - 1;
            } else if (i % h == h - 1 && j % w == w - 1) {
                ans[i][j] = -INF;
            }
            
            sum += ans[i][j];
        }
    }
    if (sum > 0) {
        cout << "Yes" << endl;
        REP(i, H) {
            REP(j, W) {
                printf("%d%c", ans[i][j], (j + 1 == W ? '\n' : ' '));
            }
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3968
#include<stdio.h>


int main(void){
  int N,i,c;
  int a[2000090];

  scanf("%d\n",&N );
  for(i=0; i<N-1; i++){
    scanf("%d",&c );
    a[c]++;
  }
  for(i=1;i<=N;i++){
    printf("%d\n",a[i] );
  }
  return 0;
}

Measured memory_bytes: 2460
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String input = sc.nextLine();
		char[] ipt = input.toCharArray();
		char[]one = {'S' , 'S' , 'W' , 'W'};
		char[]two = {'S' , 'W' , 'S' , 'W'};
		char[]ans = new char[N+1];
		for(int i = 0 ; i<4; i++) {
			ans[0] = one[i];
			ans[1] = two[i];
			ans = getAnswer(ans, ipt);
			if(ans[ans.length-1] == ans[0]) {
				if(ans[0] == 'S') {
					if(ipt[0] == 'o') {
						if(ans[1]!=ans[ans.length-2])continue;
					}
					else {
						if(ans[1]==ans[ans.length-2])continue;
					}
				}
				else {
					if(ipt[0] == 'o') {
						if(ans[1] == ans[ans.length-2])continue;
					}
					else {
						if(ans[1] != ans[ans.length-2])continue;
					}
				}
				for(int j = 0 ; j<ans.length-1; j++) {
					System.out.print(ans[j]);
				//	if((j-1)%211 == 0)System.out.println();
				}
				System.out.println();
			//	System.out.println(ans[0]+""+ans[1]);
				return;
			}
		}
		System.out.println(-1);
	}
	
	static char[] getAnswer(char[] ans, char[] ipt) {
		for(int i = 1; i<ipt.length; i++) {
			if(ipt[i] == 'o') {
				if(ans[i] == 'S') {
					if(ans[i-1] == 'S') {
						ans[i+1]='S';
					}
					else {
						ans[i+1]='W';
					}
				}
				else {
					if(ans[i-1] == 'S') {
						ans[i+1]='W';
					}
					else {
						ans[i+1]='S';
					}
				}
			}
			else {
				if(ans[i] == 'S') {
					if(ans[i-1] == 'S') {
						ans[i+1]='W';
					}
					else {
						ans[i+1]='S';
					}
				}
				else {
					if(ans[i-1] =='S') {
						ans[i+1]='S';
					}
					else {
						ans[i+1]='W';
					}
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 35860
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a=new int[N];
		for(int i = 0 ;i < N ; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long ans = 0 ;
		for ( int i = 0 ; i < N - K  ; i++) ans += a[i];
		System.out.println(ans);
	}
}


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

long long  N, M;
vector<bool> h(100010, true);
vector<long long> dp(100010, 0);

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

    REP(i, M){
        int a;
        cin >> a;
        h[a] = false;
    }

    REP(i, N+1) dp[i] = 0;

    dp[0] = 1;

    for (int i=1; i<N+1; i++){
        if(h[i]==false) continue;
        if(h[i-1]) {
            dp[i] += dp[i-1];
            dp[i] %= 1000000007;
            }
        if(i>1) if(h[i-2]) {
            dp[i] += dp[i-2];
            dp[i] %=1000000007;
        }
    }

    cout << dp[N] << endl;

   return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<cstdlib>
#define  ll int
using namespace std;
ll x,y,z;
int main()
{
	cin>>x>>y>>z;
	if(x+y+z>=22) cout<<"bust";
	else cout<<"win";
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

judge :: String -> String -> String
judge [] [] = "EQUAL"
judge (x : xs) (y : ys)
  | ord x > ord y = "GREATER"
  | ord x < ord y = "LESS"
  | otherwise = judge xs ys

main = do
  [a] <- getString
  [b] <- getString
  let la = length a
  let lb = length b
  let x | la > lb = "GREATER" | la < lb = "LESS" | otherwise = judge a b
  putStrLn x


Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdint>
#include <limits>
using namespace std;



/**
* 10進数 v を base進数の文字列へ変換する。
* @param [in] v    10進数の整数
* @param [in] base 変換した 2~36 のN進数の値
* @return base進数へ変換した文字列
*/
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
	static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ret;
	static numeric_limits<TypeInt> t;
	TypeInt n = v;
	if (t.is_signed) {
		if (v < 0) n *= -1;
	}

	while (n >= base) {
		ret += table[n%base];
		n /= base;
	}
	ret += table[n];
	if (t.is_signed) {
		if (v < 0 && base == 10) ret += '-';
	}
	// 文字列の順番を逆にする
	std::reverse(ret.begin(), ret.end());

	return ret;
}



int main(){
    int n, k;
    cin >> n >> k;
    string s = Itoa(n, k);
    cout << s.length() << endl;
}


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

int main(){
  long long n, s, a[MAX], x, m;
  int k = 0;
  scanf("%lld%lld", &n, &s);
  for(int i = 1; (long long)i*i <= n-s; i++){
    if((n-s)%i == 0){
      a[k++] = (n-s)/i+1;
      for(x = 0, m = n; m; x+= m%(i+1), m /= (i+1));
      if(x == s){
        printf("%d\n", i+1);
        return 0;
      }
    }
  }
  for(int i = k-1; i >= 0; i--){
    for(x = 0, m = n; m; x+= m%a[i], m /= a[i]);
      if(x == s){
        printf("%lld\n", a[i]);
        return 0;
      }
  }
  printf("%lld\n", n == s ? n+1 : -1);
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  while (a >= b) {
    b *= 2;
    k--;
  }
  while (b >= c) {
    c *= 2;
    k--;
  }
  
  if (k >= 0) cout << "Yes\n";
  else cout << "No\n";
}

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

template <typename T, typename U>
vector<pair<T, U>> prime_factorization(T x)
{
    vector<pair<T, U>> ret;
    for (T i = 2; i * i <= x; i++)
    {
        U count = 0;
        while (x % i == 0)
        {
            count++;
            x /= i;
        }
        if (count > 0)
        {
            ret.push_back(make_pair(i, count));
        }
    }
    if (x != 1)
    {
        ret.push_back(make_pair(x, 1));
    }
    return ret;
}

set<long long> get_divisor(long long n)
{
    set<long long> ret;

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.insert(i);
            ret.insert(n / i);
        }
    }
    return ret;
}

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

    long long ans = 1;
    for (pair<long long, int> p : prime_factorization<long long, int>(N - 1))
    {
        ans *= p.second + 1;
    }
    ans--;

    for (long long d : get_divisor(N))
    {
        if (d == 1)
        {
            continue;
        }
        long long M = N;
        while (M % d == 0)
        {
            M /= d;
        }
        if (M % d == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long

using namespace std;

int a[123456];
int A,B;
vector <int> vec;


bool is_ok(long long n,long long c)
{
    vec.clear();
    for(int i=0;i<n;i++){
        if((a[i]-c*B)>0) vec.push_back(a[i]-c*B);
    }
    if(vec.empty()){
        return 1;
    }
    int s = 0;
    for(auto x:vec){
        s += (x/(A-B)+((x%(A-B))?1:0));
    }
    if(s>c) return 0;
    return 1;
}



signed main()
{
    int n;
    scanf("%lld %lld %lld",&n,&A,&B);
    for(int i = 0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    long long l = 0, r = 1e9 ,mid;
    while(l <= r){
        mid = (l+r)/2;
        if(is_ok(n,mid)){
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << l <<endl;
    return 0;
}


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

ifstream in ( "test.in"  );
ofstream out( "test.out" );

const int DIM = 3e5 + 5;

int arr[DIM];
long long psm1[DIM], psm2[DIM];

inline int f( int x, int y, int m ) {
    if( x <= y ) return y - x;
    else         return m - x + y;
}

inline long long solve( int n, int m, int k ) {
    long long cst = 0;
    
    for( int i = 2; i <= n; i ++ ) {
        cst += f( arr[i - 1], arr[i], m );
    }
    
    return cst;
}

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

    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        
        if( i >= 2 ) {
            int x = arr[i - 1], y = arr[i];
            
            if( x > y ) y += m;
            if( x + 2 > y ) continue;
            
            psm1[x + 2] ++; psm1[y + 1] --; psm2[y + 1] -= ( y - (x + 1) );
            psm1[x + 2 + m] ++; psm1[y + 1 + m] --; psm2[y + 1 + m] -= ( y - (x + 1) );
        }
    }
    
    long long cst = solve( n, m, 1 ), ans = cst;
    for( int i = 1; i <= m * 3; i ++ ) {
        psm1[i] += psm1[i - 1];
        psm2[i] += psm2[i - 1] + psm1[i];
    }
    
    for( int i = m + 1; i <= m * 2; i ++ )
        ans = min( ans, cst - psm2[i] );
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 5376
N = int(input())

# get primes less than or equal to N
nums = list(range(2,N+1))
primes = []
while nums:
    p = nums.pop(0)
    nums = [x for x in nums if x % p]
    primes.append(p)

    
# factorize
factors_list = [[0] * len(primes), [0] * len(primes)]
for n in range(2, N+1):
    for i, p in enumerate(primes):
        div, mod = divmod(n, p)
        if mod == 0:
            fct = factors_list[div][:]
            fct[i] += 1
            factors_list.append(fct)
            break
            
# count divisors
factors_of_factorial = [sum(x) for x in zip(*factors_list)]
result = 1
for prod in factors_of_factorial:
    result *= prod+1
    result %= 1000000007
print(result)

Measured memory_bytes: 4468
#include "bits/stdc++.h"

using namespace std;

long long int N,M,L,R,K,H,W;
constexpr long long int MOD=1000000007;

int main(){
	cin>>N;
	vector<string>s(N);
	for(auto &i:s)cin>>i;
	vector<vector<int>>v(N);
	for(int i=0;i<N;i++){
		for(auto j:s[i])v[i].push_back(j-'0');
	}
	vector<vector<bitset<17>>>edge(N,vector<bitset<17>>(N));//iの末尾k文字がはみでてるときにjを置けるか
	vector<vector<pair<int,int>>>conv(17,vector<pair<int,int>>(1<<16,{-1,-1}));
	vector<vector<int>>vbit(N,vector<int>(16));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int num=0;
			for(int k=0;k<v[i].size();k++){
				num<<=1;
				num|=v[i][k];
			}
			int mask=(1<<(int)v[i].size())-1;
			for(int k=0;k<v[i].size();k++){
				bool flag=true;
				vbit[i][v[i].size()-k]=num;
				conv[v[i].size()-k][num]={i,k};
				mask>>=1;
				num&=mask;
				int num=min(v[i].size()-k,v[j].size());
				for(int l=0;l<num;l++){
					flag&=v[i][k+l]==v[j][l];
				}
				if(flag)edge[i][j].flip(v[i].size()-k);
			}
		}
	}
	vector<vector<int>>dp(16,vector<int>(1<<16,MOD));
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>PQ;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(!edge[i][j].test(v[i].size()))continue;
			if(v[i].size()==v[j].size())continue;
			if(v[i].size()>v[j].size()){
				if(dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]>v[i].size()){
					dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]=v[i].size();
					PQ.push({(int)v[i].size(),{(int)v[i].size()-v[j].size(),vbit[i][v[i].size()-v[j].size()]}});
				}
			}
			else{
				swap(i,j);
				if(dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]>v[i].size()){
					dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]=v[i].size();
					PQ.push({(int)v[i].size(),{(int)v[i].size()-v[j].size(),vbit[i][v[i].size()-v[j].size()]}});
				}
				swap(i,j);
			}
		}
	}
	while(!PQ.empty()){
		int c=PQ.top().first;
		int ca=PQ.top().second.first;
		int cb=PQ.top().second.second;
		PQ.pop();
		if(!ca)continue;
		if(dp[ca][cb]!=c)continue;
		int vnum=conv[ca][cb].first;
		for(int i=0;i<N;i++){
			if(edge[vnum][i].test(ca)){
				if(ca>v[i].size()){
					if(dp[ca-v[i].size()][vbit[vnum][ca-v[i].size()]]>c){
						dp[ca-v[i].size()][vbit[vnum][ca-v[i].size()]]=c;
						PQ.push({c,{ca-v[i].size(),vbit[vnum][ca-v[i].size()]}});
					}
				}
				else{
					if(dp[v[i].size()-ca][vbit[i][v[i].size()-ca]]>c+v[i].size()-ca){
						dp[v[i].size()-ca][vbit[i][v[i].size()-ca]]=c+v[i].size()-ca;
						PQ.push({c+v[i].size()-ca,{v[i].size()-ca,vbit[i][v[i].size()-ca]}});
					}
				}
			}
		}
	}
	if(dp[0][0]==MOD)dp[0][0]=0;
	cout<<dp[0][0]<<endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll ans[n + 1] = {};
    repd(x, 1, 350) {
        repd(y, 1, 350) {
            repd(z, 1, 350) {
                ll num = x * x + y * y + z * z + x * y + y * z + z * x;
                if (num <= n) {
                    ans[num]++;
                }
            }
        }
    }

    repd(i, 1, n + 1) { cout << ans[i] << endl; }
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    s1[0]=toupper(s1[0]);
    s2[0]=toupper(s2[0]);
    s3[0]=toupper(s3[0]);
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int gcd(int a, int b)
{
	int r = a % b;
	a = b;
	b = r;
	if (r == 0)
	{
		return a;
	}
	else
	{
		return gcd(a, b);
	}
}
int main()
{
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;

}


Measured memory_bytes: 3100
def get_int_array
    gets.strip.split(' ').map(&:to_i)
end

n, m = get_int_array

ps = n.times.map{|i| Array.new(0) }

m.times.each{|i|
    p, q = get_int_array
    ps[p-1].push q-1
    ps[q-1].push p-1
}

ptos = n.times.map{|i| nil }
ptos[0] = 0

queue = []

ps[0].each{|i| queue.push [i, 0] }

while queue.any?    
    # p queue
    pnext, pfrom = queue.shift
    if ptos[pnext].nil?
        ptos[pnext] = pfrom + 1 if ptos[pnext].nil?
        ps[pnext].each{|i| queue.push [i, pnext] if ptos[i].nil? }
    end
end

ptos = ptos.drop(1)
# p pf
if ptos.any?{|i| i.nil? }
    puts 'No'
else
    puts 'Yes'
    puts ptos
end

Measured memory_bytes: 37260