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

int main(){
    ll n,x,jump;
    cin>>n>>x;
    ll sum=0;
    ll ans=1;
    rep(i,n){
        cin>>jump;
        sum+=jump;
        if(sum<=x){
            ans++;
        }else{
            break;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3620
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		char c=s[0];
		if(int.Parse(new string(c,3))>=int.Parse(s)){
			Console.WriteLine("{0}",new string(c,3));
		}
		else{
			int n=(c-'0')+1;
			c=n.ToString()[0];
			Console.WriteLine("{0}",new string(c,3));
		}
	}
}

Measured memory_bytes: 13140
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn = 2e5 + 10;
using namespace std;
int n, m;
int main()
{
	cin >> n >> m;
	if ((n + m) % 2)
	{
		printf("IMPOSSIBLE");
	}
	else
	{
		printf("%d", (n + m) / 2);
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	string s;
	cin >> s;
	REP(i, 4) {
		cout << s[i];
	}
	cout << " ";
	for (int i = 4;i < 12;++i) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
n,m,c=gets.split.map &:to_i
b=gets.split.map &:to_i
a=[]
ans=0
n.times do |i|
  a[i]=gets.split.map &:to_i
  sum=0
  m.times do |j|
    sum+=a[i][j]*b[j]
  end
  ans+=1 if sum>-c
end
puts ans


Measured memory_bytes: 14152
import sys
x, y = map(int, input().split())
list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
if x == 2 or y == 2:
    print('Yes') if x == y else print('No')
    sys.exit()

print('Yes') if list1.count(x) != list2.count(y) else print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 
 
using namespace std;
 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int x;
    cin>>x;
    int ans=0;
    ans=x/500*1000+(x-x/500*500)/5*5;
    cout<<ans;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define neko 100010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
typedef unsigned long long ll;
std::tr1::unordered_map<ll,int>book,S;
int now,ans,n,isnprime[neko];//this neko is not neko, it means sqrt(10^10)
ll a[neko],prime[neko],b[neko];
int cmax(int a,int b){return a>b?a:b;}
void init()
{
	isnprime[1]=1;
	f(i,2,100000)
	{
		if(!isnprime[i])prime[++prime[0]]=i;
		for(register int j=1;j<=prime[0]&&i*prime[j]<=100000;++j)
		{
			isnprime[i*prime[j]]=1;
			if(!(i%prime[j]))break;
		}
	}
}
void easize(int id,ll &x)
{
	b[id]=1;ll y=x;
	ll p,num;
	f(i,1,prime[0])
	{
		p=prime[i];
		if(p*p*p>y)break;
		if(y==1)break;
		while(!(y%(p*p*p)))x/=(p*p*p),y/=(p*p*p);
		if(!(y%(p*p)))b[id]*=p,y/=(p*p);
		if(!(y%p))b[id]*=p*p,y/=p;
	}
	if(y>1)
	{
		num=sqrt(y);
		if(num*num==y)b[id]*=num;
		else b[id]*=y*y;
	}
}
int main()
{
	init();
	scanf("%d",&n);
	f(i,1,n)scanf("%llu",&a[i]),easize(i,a[i]),++S[a[i]];
	f(i,1,n)
	{
		//	std::cerr<<i<<" "<<x<<" "<<a[i]<<std::endl;
		//printf("qwq %llu %llu\n",a[i],b[i]);
		if(book[a[i]])continue;
		book[a[i]]=book[b[i]]=1;
		if(a[i]==b[i])++ans;
		else ans+=cmax(S[a[i]],S[b[i]]);
	}
	printf("%d\n",ans);
	//std::cerr<<procStatus()<<std::endl<<clock()*1.0/CLOCKS_PER_SEC<<std::endl;
	return 0;
}

Measured memory_bytes: 18760
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	int n,a,d=0,x=1000,s;
	n=read();
	for(register int i=1;i<=n;i++)
	{
		a=read();
		if(a>d) d=a;
		if(a<x) x=a;
	}
	s=d-x;
	write(s);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll a, b, c, n, m, x, y;
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == '1')s[i] = '9';
		else if (s[i] == '9')s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 764
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 30000;
int n;
int s[MAX_N];
bool dp1[10];
bool dp2[10][10];
bool dp3[10][10][10];

int main() {
    fastio();
    string t;
    cin >> n >> t;
    forn(i, n) {
        s[i] = t[i] - '0';
    }

    forn(i, n) {
        forn(j, 10) forn(k, 10) {
            dp3[j][k][s[i]] |= dp2[j][k];
        }

        forn(j, 10) {
            dp2[j][s[i]] |= dp1[j];
        }

        dp1[s[i]] = true;
    }

    int ans = 0;
    forn(i, 10) forn(j, 10) forn(k, 10) if (dp3[i][j][k]) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            long sum = 0;

            for(int i = 1; i <= num; i++)
            {
                if(Check(i))
                {
                    sum += i;
                }
            }
                Console.WriteLine(sum);
        }
        static bool Check(int num)
        {
            if(num % 3 == 0)
            {
                return false;
            }
            else if(num % 5 == 0)
            {
                return false;
            }
            else if(num % 15 == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}

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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	
	rep(i, n){
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	
	ll b;
	if(n & 1){
		b = a[n / 2];
	}
	else{
		ll b_l = a[n / 2 - 1];
		ll b_r = a[n / 2];
		b = (b_l + b_r) / 2;
	}
	
	ll ans = 0;
	rep(i, n){
		ans += abs(a[i] - b);
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4772
#include"stdio.h"
int a[20];
int main()
{
 int i,t,j;
 for(i = 0; i < 10; i++)
 {
   scanf("%d",&t);
   for(j = i-1; j>=0 && t>a[j]; j--)
   a[j+1] = a[j];
   a[j+1] = t;
 }
 for(i = 0; i < 3; i++)printf("%d\n",a[i]);
 return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long d[100009],a[100009],n,i;
long long dp(int i){
    if(i>=n) return 1e15;
    if(i==n-1) return 0;
    if(d[i]!=-1) return d[i];
    d[i]=min(abs(a[i+1]-a[i])+dp(i+1),abs(a[i+2]-a[i])+dp(i+2));
    return d[i];
}
int main()
{
    cin>>n;
    memset(d,-1,sizeof d);
    for(i=0;i<n;i++) cin>>a[i];
    cout<<dp(0);
    return 0;
}


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

#define pb push_back
#define inf 0x3f3f3f3f
int v[100100];
int memo[100100];
int n, k;

int go(int i) {
	if (i == n-1) return 0;
	if (memo[i] != -1) return memo[i];

	int ans = inf;

	for(int j = 1; j <= k; j++) {
		if (i+j <= n-1) ans = min(ans, go(i+j) + abs(v[i+j] - v[i]));
	}

	return memo[i] = ans;
}

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> v[i];

	memset(memo, -1, sizeof(memo));
	cout << go(0) << endl;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.length();
    bool flg = true;
    for(int i=0; i<N/2; i++){
        if(S.at(i) != S.at(N-i-1)) flg = false;
    }
    for(int i=0; i<N/4; i++){
        if(S.at(i) != S.at(N/2-i-1)) flg = false;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define maxn 120
char S[maxn];
int main(){
	cin >> S;
	const char *s = "keyence";
	int n = strlen(S);
	int i = 0;
	while(i < 7 && s[i] == S[i]) i += 1;
	int j = 0;
	while(j < 7 && s[6 - j] == S[n - j - 1]) j += 1;
	cout << (i + j >= 7 ? "YES" : "NO");
}

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

int main(){
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<vector<bool>> ans(3,vector<bool>(3,false));
  for(int i=0;i<N;i++){
    int b;
    cin >> b;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A.at(j).at(k)==b)  ans.at(j).at(k)=true;
      }
    }
  }

  bool flag=false;
  for(int i=0;i<3;i++){
    if(ans.at(i).at(0) && ans.at(i).at(1) && ans.at(i).at(2)) flag=true;
  }
  for(int i=0;i<3;i++){
    if(ans.at(0).at(i) && ans.at(1).at(i) && ans.at(2).at(i)) flag=true;
  }
  if(ans.at(0).at(0) && ans.at(1).at(1) && ans.at(2).at(2)) flag=true;
  if(ans.at(0).at(2) && ans.at(1).at(1) && ans.at(2).at(0)) flag=true;
  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map &:to_i
board = $<.map{|s|s.chomp.chars}
DIRS = [[0,1],[0,-1],[1,0],[-1,0]]

bfs = ->{
  q = {}
  q[[0,0]] = 1
  count = 0
  used = H.times.map{[false] * W}
  while !q.empty?
    count += 1
    next_q = {}
    q.each{|(y,x),_|
      DIRS.each{|dy,dx|
        _y = y+dy
        _x = x+dx
        next if !_y.between?(0, H-1)
        next if !_x.between?(0, W-1)
        return count if [_y, _x] == [H-1, W-1]
        next if board[_y][_x] == ?#
        next if used[_y][_x]

        next_q[[_y,_x]] = 1
        used[_y][_x] = 1
      }
    }
    q = next_q
  end
  -1
}
num_dot = H*W - board.map{|s|s.count ?#}.inject(:+)
res = bfs[]
if res == -1
  p -1
else
  p num_dot - res - 1
end


Measured memory_bytes: 2172
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = 0;
    
    String s = sc.next();
    for(int i=0; i<(s.length()/2); i++){
      if(s.charAt(i)!=s.charAt(s.length()-i-1)){
        x++;
      }
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 23764
N, Q = map(int, input().split())
S = input()

cc = []

acc = 0

for idx in range(N):
    if S[idx - 1:idx + 1] == "AC":
        acc = acc + 1
    cc.append(acc)

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


Measured memory_bytes: 6184
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
    --p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
    --q[i];
  }
  map<vector<int>,int> ord;
  int iter=0;
  vector<int> v(n);
  for(int i=0;i<n;i++) v[i]=i;
  do{
    ord[v]=iter++;
  }while(next_permutation(v.begin(),v.end()));
  cout<<abs(ord[p]-ord[q])<<endl;
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {	

	ll n, m; cin >> n >> m;
	vector<bool> dame(n + 1, false);
	for (ll i = 0; i < m; i++) {
		ll a; cin >> a;
		dame[a] = true;
	}
	
	vector<ll> dp(n + 1,0);
	dp[0] = 1;
	if (!dame[1]) dp[1] = 1;
	for (int i = 2; i <= n; ++i) {
		if (!dame[i]) {
			dp[i] = dp[i - 1] + dp[i - 2];
		}
		dp[i] %= mod;
	}
		
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
function main(input) {
  var a = input.split(' ');
  var x = parseInt(a[0]);
  var y = parseInt(a[1]);
  if(x*y % 2 == 0) {
    console.log('Even');
  }else {
    console.log('Odd');
  }
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (6 <= a && a <= 12) b /= 2;
    else if (a < 6) b = 0;
    cout << b << endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
nOdd=len(l)%2==1
if nOdd:
    num=[x for x in range(len(l)) if n%2==0]
else:
    num=[x for x in range(len(l)) if n%2!=0]
dic={}
for i in num:
    dic[i]=0
for i in l:
    dic.setdefault(i,0)
    dic[i]+=1
for i,c in dic.items():
    if i==0 and nOdd:
        if c!=1:
            print(0)
            exit()

    elif c!=2:
        print(0)
        exit()
    

        
       

print(pow(2, len(l)//2) % 1000000007)


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

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

long long findGCD(vector<long long> arr, long long n) 
{ 
    long long result = arr[0]; 
    for (long long i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
} 
int main(){
    long long n, x; cin>>n>>x;
    vector<long long> cities(n+1); for (int i=0;i<n;i++){cin>>cities[i];};
    cities[n] = x;
    sort(cities.begin(), cities.end());

    vector<long long> diff(n);
    for (long long i=0;i<n;i++){
        diff[i] = cities[i+1] - cities[i];
    }
    cout << findGCD(diff, n) << endl;
    return 0;
}

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


int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    for(int i =0; i < n; i++){
        if(a[i] != (i + 1)){
            ans++;
        }
    }
    
    if(ans <= 2) cout << "YES" << endl;
    else cout << "NO " << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat(i,n) repeat_from(i,0,n)
using namespace std;
int solve(int & i, string const & s) {
    if (s[i] == '[') {
        vector<int> ns;
        i += 1;
        while (s[i] != ']') {
            ns.push_back(solve(i,s));
        }
        i += 1;
        int n = 0;
        sort(ns.begin(), ns.end());
        repeat (j,(ns.size()+1)/2) {
            n += ns[j];
        }
        return n;
    } else {
        assert ('0' <= s[i] and s[i] <= '9');
        int n = 0;
        while (s[i] != ']') {
            n *= 10;
            n += s[i] - '0';
            i += 1;
        }
        return (n+1) / 2;
    }
}
int main() {
    int testcase_num; cin >> testcase_num;
    repeat (testcase,testcase_num) {
        string s; cin >> s;
        int i = 0;
        cout << solve(i,s) << endl;
    }
    return 0;
}

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

using namespace std; 
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	if(n<=m){
		for(int i=0;i<m;i++){
			cout << n;
		}
	}
	else{
		for(int i=0;i<n;i++){
			cout << m;
		}
	}
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 505;

typedef pair<int,int>   ii;

int c[N][N];
int t[N][N];

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

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;  cin >> n;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < n ; ++j)    {
        c[i][j] = 1e9;
        c[i][j] = min(c[i][j],min(i,n - i - 1));
        c[i][j] = min(c[i][j],min(j,n - j - 1));
        t[i][j] = 1;
    }
    ll  ans = 0;

    for(int i = 0 ; i < n * n ; ++i)    {
        int val;    cin >> val;

        int px = (val - 1) / n;
        int py = (val - 1) % n;

        ans += c[px][py];
        t[px][py] = 0;  

        queue<ii>   qu;
        qu.push(ii(px,py));

        while (qu.size())   {
            int x = qu.front().X;
            int y = qu.front().Y;   qu.pop();

            for(int i = 0 ; i < 4 ; ++i)    {
                int xx = x + dx[i];
                int yy = y + dy[i];

                if (xx < 0 || xx >= n)  continue;
                if (yy < 0 || yy >= n)  continue;

                if (c[xx][yy] > c[x][y] + t[x][y])  {
                    c[xx][yy] = c[x][y] + t[x][y];
                    qu.push(ii(xx,yy));
                }
            }
        }
    }
    cout << ans << endl;
}

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

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

int main() {
  int A, B;
  cin >> A >> B;
  if (B % A == 0) cout << A + B << endl;
  else cout << B - A << endl;
};


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, Q = mapint()
S = list(str(input()))
from itertools import accumulate
lis = [0]*N
for i in range(1, N):
    if S[i-1]=='A' and S[i]=='C':
        lis[i] += 1
cum = list(accumulate(lis))

for _ in range(Q):
    l, r = mapint()
    print(cum[r-1]-cum[l-1])

Measured memory_bytes: 9428
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(i64);
    println!("{}", (N - 1) / 2)
}


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

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

    int sum = 0;
    for(int i=0; i<n-1; i++){
        int resSum = 0;
        for(int j=i+1; j<n; j++){
            resSum += d[j];
        }
        sum += resSum * d[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N;
  cin >> N;
  int t[N+1],x[N+1],y[N+1];
  t[0]=0;x[0]=0;y[0]=0;
  rep1(i,N) cin >> t[i] >> x[i] >> y[i];
  rep1(i,N){
    int d= abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    int dt=t[i]-t[i-1];
    if(dt!=d && dt>d && (dt-d)%2==0){
    }
    else if(dt!=d){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;  
  return 0;

}


Measured memory_bytes: 1408
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

mod=998244353


def do():
    
    def power_func(a,n,p):
        bi=str(format(n,"b"))
        res=1
        for i in range(len(bi)):
            res=(res*res) %p
            if bi[i]=="1":
                res=(res*a) %p
        return res
    
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
    
    n,m,k=INTM()
    
    ans=0
    
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range( 2, n  ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    
    for i in range(k+1):
        temp=m
        temp=m*power_func(m-1,n-1-i,mod)%mod
        temp=temp*cmb(n-1,i,mod)%mod
        #print(cmb(n-1,i,mod))
        ans+=temp
        ans=ans%mod
    print(ans)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 32952
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  #divisors.sort()
  return divisors

#X = str(input()).split()
#a = [int(x) for x in input().split()]


N = int(input())
ans = 0


for i in range(1,N+1):
  if not(i%2==0):
    Arr = make_divisors(i)
    if(len(Arr)==8):
      ans += 1

print(ans)



Measured memory_bytes: 38636
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if i < n and td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)


Measured memory_bytes: 70360
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
L = []

for i in reversed(range(len(X))):
    if i - 1 < 0:
        break
    if (X[i] >= 0 and X[i-1] >= 0) or (X[i] <= 0 and X[i-1] <= 0):
        L.append(abs(X[i] - X[i-1]))
    else:
        L.append(abs(X[i]) + abs(X[i-1]))

L.sort()
L_min = 0
for i in range(M-N):
    L_min += L[i]

print(L_min)


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,x;
    cin>>a>>b>>c>>x;
    ll ans=0;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
            {
                if(i*500+j*100+k*50==x)
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s,w=n1()
print("unsafe" if s<=w else "safe")

Measured memory_bytes: 9116
#include <stdio.h>

int main(void){
  int n, a, b, c, d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

  char s[n];
  scanf("%s", s);

  int cnt = 0;
  for (int i = a; i < c; i++) {
    if(s[i] == '#'){
      cnt++;
      if(cnt == 2){
        printf("No\n");
        return 0;
      }
    }else cnt = 0;
  }
  for (int i = b; i < d; i++) {
    if(s[i] == '#'){
      cnt++;
      if(cnt == 2){
        printf("No\n");
        return 0;
      }
    }else cnt = 0;
  }

  if(c < d){
    printf("Yes\n");
    return 0;
  }else{
    int cnt = 0;
    for (int i = b-2; i <= d; i++) {
      if(s[i] == '.'){
        cnt++;
        if(cnt == 3){
          printf("Yes\n");
          return 0;
        }
      }else cnt = 0;
    }
  }

  printf("No\n");

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

int LCS(char *X, char *Y){
	int i, j, m, n, a[1001][1001];
	m = strlen(X);
	n = strlen(Y);
	for(i = 0; i < m; i++){
		a[i][0] = 0;
	}
	for(j = 0; j < n; j++){
		a[0][j] = 0;
	}
	
	for(i = 1; i < m+1; i++){
		for(j = 1; j < n+1; j++){
			if (X[i-1] == Y[j-1])
				a[i][j] = a[i-1][j-1] + 1;
			else if (a[i-1][j] >= a[i][j-1])
				a[i][j] = a[i-1][j];
			else
				a[i][j] = a[i][j-1];
		}
	}
	
	return a[i-1][j-1];
}

int main(){
	int i, n;
	char x[1001], y[1001];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s", x);
		scanf("%s", y);
		printf("%d\n", LCS(x, y));
		
	}
	
	return 0;
}

Measured memory_bytes: 4524
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int sum=0;
	for(int i=0;i<n;++i)
		sum+=a[i];
	sum-=a[0];
	int sum2=a[0];
	int mins=max(sum-sum2,sum2-sum);
	for(int i=1;i<n-1;++i){
		sum-=a[i];
		sum2+=a[i];
		mins=min(mins,max(sum-sum2,sum2-sum));
	}
	cout<<mins<<endl;
	return 0;
}

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

const int MAXN = 4e5+5;

int n, mini = 1;;
int a[MAXN];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    ll tot = 0;
    tot += a[0]-1;
    mini = 2;
    for (int i = 1; i < n; ++i) {
        if (a[i] == mini) {
            mini++; continue;
        }
        tot += (a[i]-1)/mini;
    }

    cout << tot << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

inline char gc()
{
	static const int L = 23333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt)
	{
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) return EOF;
	}
	return *sss++;
}

#ifdef ___my_computer
#define gc getchar
#endif

#define dd c = gc()
template <class T>
inline bool read(T& x)
{
	x = 0;
	register char dd;
	bool flag = false;
	for (; !isdigit(c); dd)
	{
		if(c == '-') flag = true;
		else if(c == EOF) return false;
	}
	for (; isdigit(c); dd)
		x = (x << 1) + (x << 3) + (c ^ 48);
	if (flag) x = -x;
	return true;
}
#undef dd

template <class T>
inline void write(T x)
{
	if(!x)
	{
		putchar('0');
		return;
	}
	if (x < 0)
		putchar('-'), x = -x;
	int buf[20];
	*buf = 0;
	while (x)
	{
		buf[++(*buf)] = x % 10;
		x /= 10;
	}
	while (*buf)
		putchar(buf[(*buf)--] | 48);
}

template <class T>
inline void writeln(T x)
{
	write(x);
	puts("");
}

template <class T>
inline void writesp(T x)
{
	write(x);
	putchar(' ');
}

template <typename _EuclideanRingElement>
_EuclideanRingElement
gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
{
	while (__n)
	{
		_EuclideanRingElement __t = __m % __n;
		__m = __n;
		__n = __t;
	}
	return __m;
}

template <typename _EuclideanRingElement>
_EuclideanRingElement
lcm(_EuclideanRingElement __m, _EuclideanRingElement __n)
{
	return __m * __n / gcd(__m, __n);
}

const int maxn = 100005;

int n;
int fa[maxn];
int a[maxn], b[maxn];
int ta[maxn], tb[maxn];
map<int, int> ls;

inline int getfa(int x)
{
	return fa[x] == x ? x : (fa[x] = getfa(fa[x]));
}

int main()
{
//	freopen("a.in", "r", stdin);
	scanf("%d", &n);
	n++;
	for (int i = 1; i < n; ++i)
	{
		read(a[i]);
		a[n] ^= a[i];
	}
	for (int i = 1; i < n; ++i)
	{
		read(b[i]);
		b[n] ^= b[i];
	}
	for (int i = 1; i <= n; ++i)
		ta[i] = a[i], tb[i] = b[i];
//	cout << a[n] << ' ' << b[n] << endl;
	sort(ta + 1, ta + n + 1);
	sort(tb + 1, tb + n + 1);
	for (int i = 1; i < n; ++i)
	{
		if (ta[i] != tb[i])
		{
			puts("-1");
			return 0;
		}
		if (a[i] != b[i])
			ls[a[i]]++, ls[b[i]]++;
	}
	ls[a[n]]++, ls[b[n]]++;
	int siz = 0;
	for (map<int, int>::iterator it = ls.begin(); it != ls.end(); ++it)
		it->second = ++siz;
	for (int i = 1; i <= siz; ++i)
		fa[i] = i;
	int ans = 0;
//	ofstream fout("deb.out");
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] != b[i])
		{
			int fax = getfa(ls[a[i]]);
			int fay = getfa(ls[b[i]]);
			if (fax != fay)
				fa[fax] = fay;
//			fout << ls[a[i]] << ' ' << ls[b[i]] << '\n';
			if (i != n)
				ans++;
		}
	}
//	fout.close();
	for (int i = 1; i <= siz; ++i)
	{
		ans += (fa[i] == i);
//		if (fa[i] == i)
//			cout << i << endl;
	}
	write(max(0, ans - 1));
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

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

	double p[n],s[n+1];s[0]=0;
	rep(i,n){
		double a;cin>>a;
		p[i]=(a+1)/2;
		s[i+1]=s[i]+p[i];
	}
	double ans=0;
	for(int i=0;i<n-k+1;i++){
		ans=max(ans,s[i+k]-s[i]);
	}

	cout<<fixed<<setprecision(15)<<ans<<"\n";
}

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

    if(s[0]=='S')
    cout << "Cloudy" << endl;
    if(s[0]=='C')
    cout << "Rainy" << endl;
    if(s[0]=='R')
    cout << "Sunny" << endl;

return 0;
}


Measured memory_bytes: 256
program ec12;
var 
	k:qword;
	a:array[1..101] of qword;
	n,i:longint;
	ans:qword;
procedure qsrt(l,r:longint);
var 
	v,s:qword;
	i,j:longint;
begin 
	i:=l; j:=r; v:=a[(l+r) div 2];
	repeat
	while a[i]>v do inc(i);
	while a[j]<v do dec(j);
	if i<=j then 
	begin 
		s:=a[i];
		a[i]:=a[j];
		a[j]:=s;
		inc(i);
		dec(j);
	end;
	until i>=j;
	if l<j then qsrt(l,j);
	if i<r then qsrt(i,r);
end;
function gcd(a,b:qword):qword;
var 
	c:qword;
begin 
	while true do 
	begin
		if b=0 then 
		exit(a);
		c:=a;
		a:=b;
		b:=c mod b;
	end;
end;
begin 
	readln(n);
	for i:=1 to n do 
	readln(a[i]);
	if n=1 then 
	begin 	
		writeln(a[1]);
		halt;
	end;
	qsrt(1,n);
	if a[1]=a[2] then 
	ans:=a[1]
	else
	begin 
		k:=gcd(a[1],a[2]);
		ans:=(a[1] div k)*a[2];
	end;
	for i:=3 to n do 
	begin 
		if ans mod a[i]=0 then 
		continue;
		k:=gcd(ans,a[i]);
		ans:=(ans div k)*a[i];
	end;
	writeln(ans);
end. 

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<ll>A;
ll rec[80];
ll mod = 1e9 + 7;

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

	ll N;
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	for (ll j = 60; j >= 0; j--) {
		for (int i = 0; i < N; i++)if ((1LL << j)&A[i])rec[j]++;
	}
	
	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		for (int j = 60; j >= 0; j--)if((1LL << j)&A[i])rec[j]--;
		for (int j = 60; j >= 0; j--) {
			if((1LL << j)&A[i])ans += ((1LL << j) % mod)*(N-i-1LL-rec[j]);
			else ans += ((1LL << j) % mod)*rec[j];
			ans %= mod;
		}
	}
	puts(ans % mod);
	return 0;
}

Measured memory_bytes: 2560
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
using namespace std;
int main(void){

    int N;
    cin>>N;
    int a[120];
    int total;
    for(int i = 0;i < N - 1;i++){
        cin>>a[i];
    }
    cin>>total;

    long long int dp[120][25] = {{0}};
    dp[0][a[0]] = 1;
    for(int i = 0;i <= N - 1;i++){
        for(int j = 0;j <= 20;j++){
            if(dp[i][j] != 0){
                if(0 <= j - a[i+1] && j - a[i+1] <= 20)dp[i + 1][j - a[i+1]] += dp[i][j];
                if(0 <= j + a[i+1] && j + a[i+1] <= 20)dp[i + 1][j + a[i+1]] += dp[i][j];
            }
        }
    }/*
    for(int j = 0;j <= 20;j++){
        cout<<setw(2)<<j<<ends<<ends;
        for(int i = 0;i < N - 1;i++){
            cout<<setw(3)<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[N-2][total]<<endl;


    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define N 10000000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back

typedef long long ll;
const ll INF = (1e8);
const ll mod = (1e9 + 7);
ll f[maxn];
void init(){
    for(ll i = 1;i * i <= N;i++){
        for(ll j = i;i * j <= N;j++){
            f[i * j] += 2;
            if(i == j)f[i * j]--;
        }
    }
}
int main(){
    init();
    ll n;scanf("%lld",&n);
    ll ans = 0;
    for(ll i = 1;i <= n;i++){
        ans += f[i] * i;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 81892
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll ans=1;
        if(n!=2)ans++;
        ll x=n-1;
        // cout<<ans<<endl;
        for(ll i=2;i<=sqrt(x);i++){
            if(x%i==0){
                ans++;
                if(i*i!=x){
                    ans++;
                }
            }
        }
        x=n;
        for(ll i=2;i<=sqrt(x);i++){
            if(x%i==0){
                ll k=x;
                while(k%i==0)k=k/i;
                if((k-1)%i==0){
                    ans++;
                }
                if(i*i!=x){
                    ll u=x/i;k=x;
                    while(k%u==0)k=k/u;
                    if((k-1)%u==0){
                        ans++;
                    }
                }
            }
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char S[3][4];
    rep(i, 3) scanf("%s", S[i]);
    printf("%c%c%c\n", S[0][0], S[1][1], S[2][2]);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

int main() {
	int N, K, S;
	cin >> N >> K >> S;

	vector<int> ans;
	for (int i = 0; i < K; ++i) ans.push_back(S);
	for (int i = K; i < N; ++i) ans.push_back(S == 1 ? 2 : S - 1);

	for (int i = 0; i < N; ++i) cout << ans[i] << " "; cout << endl;
	return 0;
}

Measured memory_bytes: 3864
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int P[8], Q[8];
	rep(i, N) cin >> P[i];
	rep(i, N) cin >> Q[i];

	int A[8];
	rep(i, N) A[i] = i + 1;

	int a, b;
	int owari = 1;
	rep1(i, N) owari *= i;
	rep(i, owari) {
		bool OK = 1;
		rep(i, N) if (P[i] != A[i]) OK = 0;
		if (OK) a = i;
		OK = 1;
		rep(i, N) if (Q[i] != A[i]) OK = 0;
		if (OK) b = i;

		next_permutation(A, A + N);
	}

	co(abs(a - b));

	Would you please return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;
const int mod = 1e9 + 7;

int dp[14][100001];

#define FILENAME ""

void add_self (int& a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < s.size(); i++) {
        for (int sum = 0; sum <= 13; sum++) {
            if (s[i] == '?') {
                for (int dig = 0; dig <= 9; dig++) {
                    int len = i + 1;
                    add_self(dp[(sum*10 + dig) % 13][len], dp[sum][len - 1]);
                }
            }
            else {
                int len = i + 1;
                add_self(dp[(sum*10 + (s[i] - '0')) % 13][len], dp[sum][len - 1]);
            }
        }
    }
    cout << dp[5][sz(s)];
    return 0;
}

Measured memory_bytes: 5584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	ans := 0
	for _, r := range S {
		if r == '+' {
			ans++
		} else {
			ans--
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

int main() {
  int c[3][3];
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin>>c[i][j];
    }
  }
  int a[3],b[3];
  a[0]=0;
  for (int i=0; i<3; i++) {
    b[i]=c[0][i]-a[0];
  }
  for (int i=1; i<3; i++) {
    a[i]=c[i][0]-b[0];
  }
  bool f=true;
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      if (c[i][j]!=a[i]+b[j]) {
        f=false;
      }
    }
  }
  if (f) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main()
{
	int  h,w;

	while (1)
	{
		cin >> h >> w;

		if (h==0&&w==0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

bool compare(const pair<ll, ll>& lh, const pair<ll, ll>& rh) {
  if (lh.first < rh.first){
    return true;
  } else if (lh.first == rh.first){
    if (lh.second >= rh.second)
      return true;
  }
  
  return false;
}

int main(void){
  ll n;
  cin >> n;
  
  vector<pair<ll, ll>> a(n);
  ll num = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i].first;
    a[i].second = i;
    num += a[i].first;
  }
  sort(a.begin(), a.end());

  vector<ll> res(n, 0);
  ll id = n - 1, mi = n;
  while (true){
    while (id > 0 && a[id].first == a[id-1].first){
      id--;
    }
    if (id == 0){
      res[0] += n*a[0].first;
      break;
    }
    mi = min(mi, a[id].second);
    res[mi] += (n - id)*(a[id].first - a[id-1].first);
    id--;
  }


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

  return 0;
}


Measured memory_bytes: 3456