akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  std::string t;
  std::cin>>t;

  for(auto&& e:t){
    if(e=='?')e='D';
  } 

  std::cout<<t<<"\n";

  return 0;
}

Measured memory_bytes: 3740
from math import cos, sqrt, radians
A, B, H, M = map(int, input().split())

angle_a = 30 * H + 0.5 * M
angle_b = 6 * M

diff = abs(angle_a - angle_b)
if diff > 180:
    diff = 360 - diff

theta = radians(diff)

res = sqrt(A*A + B*B - 2 * A * B * cos(theta))

print(res)

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

using namespace std;
#define int long long
int n,m;
vector<int> v[100005];
int kq=0,f[100005];
int F(int i)
{
	if(f[i]!=-1) return f[i]; 
	else if(v[i].size()==0) return 0;
	else
	{
		int res=0;
		for(int j=0;j<v[i].size();j++)
		{
			res=max(res,F(v[i][j])+1);
		}
		f[i]=res;
		return res;
	}
}
main()
{
	cin>>n>>m;
	memset(f,-1,sizeof(f));
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
	{
		kq=max(kq,F(i));
	}
	cout<<kq;
}

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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

const int kMod = 998244353;

int main() {
  // freopen("1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, K;
  cin >> N >> K;

  vector<int> L(K), R(K);
  rep(i, K) {
    cin >> L[i] >> R[i];
  }

  vector<int> dp(N), sum(N);

  auto Sum = [&](int i, int j) {
    if (i == 0) {
      return sum[j];
    } else {
      int result = (sum[j] - sum[i - 1]) % kMod;
      return (result + kMod) % kMod;
    }
  };

  dp[0] = sum[0] = 1;
  repi(i, 1, N) {
    rep(j, K) {
      if (i - L[j] < 0) {
        continue;
      }

      int left = max(0, i - R[j]);
      int right = i - L[j];
      dp[i] = (dp[i] + Sum(left, right)) % kMod;
    }

    sum[i] = (sum[i - 1] + dp[i]) % kMod;
  }

  cout << dp[N - 1] << '\n';

  return 0;
}


Measured memory_bytes: 4720
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

using namespace std;

typedef long long LL;

struct edge {
	int to;
	int cost;
};

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	string s;
	LL k;
	cin >> s >> k;
	for (int i = 0; i < 100; i++) {
		if (s[i] == '1') {
			if (i + 1 >= k) {
				cout << 1;
				break;
			}
		}
		else {
			cout << s[i];
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX_DATA 2000000
void MergeSort(long long int x[ ],long long int y[ ], long long int left, long long int right);

int main (void){
  long long int N,M,A[2000000],B[2000000],ans=0;
  scanf("%lld\n",&N );
  scanf("%lld\n",&M );
  for (long long int i = 0; i < N; i++) {
    scanf("%lld\n",&A[i] );
    scanf("%lld\n",&B[i] );
  }
  MergeSort(A,B, 0, N - 1);
  for (int i = 0; i < N; i++) {
    if (M>B[i]) {
      M-=B[i];
      ans+=A[i]*B[i];
    }else{
      ans+=A[i]*M;
      printf("%lld\n",ans );
      return 0;
    }
  }
  return 0;
}







int temp[MAX_DATA];    /* 最小でも配列と同じサイズの領域が必要 */
int tempy[MAX_DATA];

  /* 配列 x[ ] の left から right の要素のマージソートを行う */
void MergeSort(long long int x[ ],long long int y[ ], long long int left, long long int right)
{
    long long int mid, i, j, k;

    if (left >= right)              /* 配列の要素がひとつなら */
        return;                     /* 何もしないで戻る */

                                    /* ここでは分割しているだけ */
    mid = (left + right) / 2;       /* 中央の値より */
    MergeSort(x,y, left, mid);        /* 左を再帰呼び出し */
    MergeSort(x,y, mid + 1, right);   /* 右を再帰呼び出し */

      /* x[left] から x[mid] を作業領域にコピー */
    for (i = left; i <= mid; i++){
        temp[i] = x[i];
        tempy[i] = y[i];
      }

      /* x[mid + 1] から x[right] は逆順にコピー */
    for (i = mid + 1, j = right; i <= right; i++, j--){
        temp[i] = x[j];
        tempy[i] = y[j];
      }

    i = left;         /* i とj は作業領域のデーターを */
    j = right;        /* k は配列の要素を指している */

    for (k = left; k <= right; k++){    /* 小さい方から配列に戻す */
        if (temp[i] <= temp[j]){        /* ここでソートされる */
            x[k] = temp[i];
            y[k] = tempy[i++];
          }
        else{
            x[k] = temp[j];
            y[k] = tempy[j--];
          }
          }
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         String S=gs();


         long ans=0;
         if(S.contains("RRR")) {
        	 ans=3;
         } else if(S.contains("RR")) {
        	 ans=2;
         } else if(S.contains("R")) {
        	 ans=1;
         }

         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

template <class T, class U>
inline bool chmin(T& t, const U& f) { return t > f ? t = f, true : false; }

template <class T, class U>
inline bool chmax(T& t, const U& f) { return t < f ? t = f, true : false; }

template <class T> inline T sqr(const T&& x) { return x * x; }

int main() {
    for (int r, n; cin >> r >> n, r | n;) {
        vector<int> height(45);
        while (n--) {
            int xl, xr, h; cin >> xl >> xr >> h;
            for (int x = xl; x < xr; ++x) chmax(height[x + 20], h);
        }
        double t = 20;
        for (int x = -r; x < r; ++x) {
            chmin(t, r - sqrt(r * r - sqr(x < 0 ? x + 1 : x)) + height[x + 20]);
        }
        cout << fixed << setprecision(4) << t << endl;
    }
}

Measured memory_bytes: 3208
# -*- coding: utf-8 -*-


def main():
    n, k = list(map(int, input().split()))
    ans = 0
    count1 = 0
    count2 = 0

    for i in range(1, n + 1):
        if i % k == 0:
            count1 += 1
        if i % k == k // 2:
            count2 += 1

    ans += count1 ** 3

    if k % 2 == 0:
        ans += count2 ** 3

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
N = int(input())
c = list(input())
#print(c)
myr_cnt = c.count('R')
if myr_cnt == 0:
    print(0)
    sys.exit()
#print(myr_cnt)
myw_cnt = 0
for i in range(myr_cnt):
    if c[i] == 'W':
        myw_cnt += 1
print(myw_cnt)

Measured memory_bytes: 10748
/**
 * @author torith
 * @date 2018-11-08
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;

    set<char> visited;
    for (int i = 0; i < S.size(); ++i) {
        if(S[i] != T[i]) {
            char s = S[i];
            char t = T[i];
            auto a = visited.find(S[i]);
            auto b = visited.find(T[i]);
            if(a != visited.end() || b != visited.end()){
                cout << "No" << "\n";
                return 0;
            }
            for (int j = i; j < S.size(); ++j) {
                if(S[j] == s){
                    S[j] = t;
                }else if (S[j] == t) {
                    S[j] = s;
                }
            }
        }
        visited.insert(T[i]);
    }

    if(S == T) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}



Measured memory_bytes: 916
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-09-15 19:45
# @url:

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
def main():
    x=int(input())
    dp=[0]*(x+1)
    mod=10**9+7
    for i in range(x+1):
        if i<3:
            dp[i]=0
            continue
        dp[i]=1
        for j in range(3,i-2):
            dp[i]+=dp[i-j]%mod
    print (dp[-1]%mod)
if __name__ == "__main__":
    main()

Measured memory_bytes: 77420
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String c;
		String ans = "";

		List<String> lists = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
				"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

		c = scanner.next();

		for (int i = 0; i < lists.size(); i++) {

			if (c.equals(lists.get(i))) {
				ans = lists.get(i + 1);
			}
		}

		System.out.println(ans);

	}

}

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        ll n,m,k;
        cin>>n>>m>>k;
        vector<ll>a(n);
        vector<ll>b(m);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
            cin>>b[i];
        vector<ll>sumA(n+1);
        vector<ll>sumB(m+1);
        for(int i=0;i<n;i++)
            sumA[i+1]=sumA[i]+a[i];
        for(int i=0;i<m;i++)
            sumB[i+1]=sumB[i]+b[i];
        int total=0;
        for(int i=0;i<=n;i++){
            ll other=k-sumA[i];
            if(other<0)
                continue;
            int l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
            if(l>m || sumB[l]>other)
                --l;
//            cout<<other<<" "<<l<<" "<<i<<" "<<"\n";
            total=max(total,i+l);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 9532
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;
const ll N = 10010;

ll a1[N], b1[N][N];

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

    ll x; cin >> x;

    for (int i = 1; i <= x; i ++) cin >> a1[i];
    ll f = 1;
    for (int i = 1; i <= n; i ++){
         if (i & 1){
            for (int j = 1; j <= m; j ++){
                    a1[f] --;
                    b1[i][j] = f;
                    if (a1[f] == 0) f ++;
            }
         }
         else {
            for (int j = m; j >= 1; j --){
                    a1[f] --;
                    b1[i][j] = f;
                    if (a1[f] == 0) f ++;
            }
         }
    }

    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= m; j ++){
            if (j == 1) cout << b1[i][j];
            else cout << " " << b1[i][j];
        }
        cout << "\n";
    }

    //main();

    return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define f first 
#define s second
#define ll long long
int main(){
   string s;
   string t;
   cin>>s>>t;
   int ans =0 ;
   for(int i = 0 ; i < s.length() ; i++){
        if(s[i] != t[i])ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3920
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			HashSet<int> set = new HashSet<int>();
			foreach (int i in a) {
				if (set.Contains(i)) {
					Console.WriteLine("NO");
					return;
				}
				set.Add(i);
			}
			Console.WriteLine("YES");


			//Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 36944
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int a[100000];
	int b[100000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;
	int ans;


	scanf("%d", &n);

	c = n / 100;
	d = n % 10;
	if(c==d)printf("Yes\n");
	else printf("No\n");

	return 0;
}



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


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

	char c = S[K - 1];
	for (int i = 0; i < N; ++i) {
		if (S[i] != c) {
			S[i] = '*';
		}
	}

	cout << S << endl;
}


Measured memory_bytes: 256
<?php
    $top = trim(fgets(STDIN));
    $btm = trim(fgets(STDIN));
    if($top[0] == $btm[2]){
      if($top[1] == $btm[1]){
        if($top[2] == $btm[0]){
          echo 'YES';
        }else{
          echo 'NO';

        }
      }else{
        echo 'NO';

      }
    }else{
      echo 'NO';
    }


  ?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll prefix[200005], a[200005], dp[200005];
int main(){
	ll n; cin >> n;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	prefix[1] = a[1];
	for (ll i = 3; i <= n; i += 2) prefix[i] = prefix[i - 2] + a[i];
	for (ll i = 2; i <= n; i++){
		if (i % 2 == 1) dp[i] = max(dp[i - 1], dp[i - 2] + a[i]);
		else dp[i] = max(prefix[i - 1], dp[i - 2] + a[i]);
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 8316
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int x[100001];

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	int neg = 0;
	for(int i = 0; i < n; i++){
			cin >> x[i];
			if(x[i] < 0)neg++;
	}
	ll res = inf;
	if(neg == 0){
			cout << x[k-1] << endl;
			return 0;
	}else if(neg == n){
			cout << abs(x[n - k]) << endl;
			return 0;
	}
	for(int i = 0; i + k - 1 < n; i++){
			if(x[i] > 0)break;
			if(x[i] <= 0 && x[i+k-1] > 0){
					ll tmp = -x[i] * 2 + x[i+k-1];
					res = min(res, tmp);
					tmp = -x[i] + x[i+k-1] * 2;
					res = min(res, tmp);
			}else if(x[i] <= 0 && x[i+k-1] == 0){
					ll tmp = -x[i];
					res = min(res, tmp);
			}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int q(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int t[1001];
int main(void) {
  int n,a,b;
  scanf("%d %d %d",&a,&b,&n);
  t[a]++;
  t[b]--;
  FOR(n){
    scanf("%d %d",&a,&b);
    t[a]++;
    t[b]--;
  }
  FOR(1000){
    if(i)t[i]+=t[i-1];
    if(t[i]>1){
      PRN(1);
      return 0;
    }
  }
  PRN(0);
  return 0;
}


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

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

	string s, t;

	cin >> s >> t;
	int max = -1;
	size_t slen = s.length(), tlen = t.length();
	for (size_t i = 0; i <= slen - tlen; i++) {
		int match = 0;
		for (size_t j = 0; i + j < slen && j < tlen; j++) {
			if (s[i + j] == t[j]) {
				match++;
			}
		}
		max = max < match ? match : max;
	}

	cout << tlen - max << '\n';
	return 0;
}


Measured memory_bytes: 3628
N = int(input())
cnt = 2 if N > 2 else 1

ret = []
for i in range(2, int(N**0.5)+1):
    if N % i == 0:
        k = N//i
        while k % i == 0:
            k //= i
        if k % i == 1:
            cnt += 1

        if N // i != i:
            j = N // i
            k = i
            while k % j == 0:
                k //= j
            if k % j == 1:
                cnt += 1

M = N - 1
for i in range(2, int((M)**0.5)+1):
    if M % i == 0:
        cnt += 1
        if M // i != i:
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(200000, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    // dp[i] := i番目の足場にいくのに最小コスト
    vector<int> dp(200000, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int n,x,a;
  int i,j,k;
  scanf("%d", &n);
  int hairetu[n];
  for(i = 0; i < n; i++){
    scanf("%d", &x);
    hairetu[i] = x;
  }

  for(k = 0; k < n; k++){
    if( k > 0)
      printf(" ");
    printf("%d",hairetu[k]);
  }
  printf("\n");
  
  for(i = 1; i < n; i++){
  
    a = hairetu[i];
    j = i - 1;

    while(1){
      if( !(j >= 0 && hairetu[j] > a) ) break;
      hairetu[j+1] = hairetu[j];
      j--;
    }   


    hairetu[j+1] = a;
    for(k = 0; k < n; k++){
      if( k > 0)
	printf(" ");
      printf("%d", hairetu[k]);
    }
    printf("\n");
  }
  return 0;
}







Measured memory_bytes: 2056
#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 ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
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 possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << 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};

vector<int> E[50];
int par[50], depth[50];
vector<int> children[50];

void dfs_tree(int v, int d)
{
  depth[v] = d;
  for (auto to : E[v])
  {
    if (par[to] == -2)
    {
      par[to] = v;
      children[v].push_back(to);
      dfs_tree(to, d + 1);
    }
  }
}

int lca[20];

int lca_func(int a, int b)
{
  while (depth[a] < depth[b])
    b = par[b];
  while (depth[a] > depth[b])
    a = par[a];
  while (a != b)
  {
    a = par[a];
    b = par[b];
  }
  return a;
}

int point[50];
int cnt;
int dfs_search(int v) //pointの和を返す
{
  if (children[v].empty())
  {
    if (point[v] > 0)
      cnt++;
    return point[v];
  }

  int ch_sum = 0;
  for (auto ch : children[v])
  {
    ch_sum += dfs_search(ch);
  }
  if (ch_sum + point[v] > 0)
    cnt++;
  return ch_sum + point[v];
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  ll n;
  cin >> n;

  rep(i, n - 1)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }

  rep(i, n)
  {
    par[i] = (i == 0 ? -1 : -2);
  }

  dfs_tree(0, 0);

  ll m;
  cin >> m;
  ll u[50], v[50];
  rep(i, m)
  {
    cin >> u[i] >> v[i];
    u[i]--, v[i]--;
  }
  rep(i, m)
  {
    lca[i] = lca_func(u[i], v[i]);
  }

  
  ll invalid = 0;
  REP(bi, 1, 1 << m)
  {
    //i番目のbitが立っているとき，i番目の条件を満たさない
    bitset<20> bs(bi);
    int bit_cnt = 0;
    rep(i, 20) bit_cnt += bs[i];
    fill(point, point + n, 0);
    cnt = 0;

    rep(i, m)
    {
      if (bs[i])
      {
        point[lca[i]] -= 2;
        point[u[i]]++;
        point[v[i]]++;
      }
    }
    dfs_search(0);
    ll sum = 1;
    rep(i, n - 1 - cnt) sum *= 2;
    int sgn = (bit_cnt % 2 == 0 ? -1 : 1);
    invalid += sgn * sum;
  }
  ll cnt_all = 1;
  rep(i, n - 1) cnt_all *= 2;
  cout << cnt_all - invalid << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int X, t;
    cin >> X >> t;

    cout << max(X-t, 0) << endl;
    
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

int dp[5555];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	init(10111111);
	int n,a; cin>>n>>a;
	for(int i=1;i<=a+1;i++)
	{
		//at least one loop at i
		//i+1 to a are ignored
		int A = i-1; //good prefix
		int B = n-a; //bad suffix
		dp[i]=mult(((i>a)?fact[n]:fact[n-1]),mult(A,inv[A+B]));
		for(int j=1;j<i;j++) 
		{
			int sgn=((j&1)?MOD-1:1);
			sgn=mult(sgn,choose(i-1,j));
			//if exist j loops before
			int A = i-1-j;
			int B = n-a;
			int val = mult(((i>a)?fact[n-j]:fact[n-j-1]),mult(A,inv[A+B]));
			radd(dp[i],mult(sgn,val));
		}
		//cerr<<i<<' '<<dp[i]<<'\n';
	}
	int sum=0;
	for(int i=1;i<=a+1;i++) radd(sum,dp[i]);
	cout<<sum<<'\n';
}


Measured memory_bytes: 161328
# B - Palindrome-phobia
from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=si()
d=defaultdict(int)
for ss in s:
    d[ss]+=1
n=len(s)
t=set(s)
m=len(t)

if n==1:
    print('YES')
elif n==2:
    if m==1:
        print('NO')
    elif m==2:
        print('YES')
elif n==3:
    if m==1:
        print('NO')
    elif m==2:
        print('NO')
    elif m==3:
        print('YES')
elif n>=4:
    if m==1:
        print('NO')
    elif m==2:
        print('NO')
    elif m==3:
        if n%3==1:
            if max(d.values())==(n//3)+1:
                print('YES')
            else:
                print('NO')
        elif n%3==2:
            if max(d.values())==(n//3)+1:
                print('YES')
            else:
                print('NO')
        elif n%3==0:
            if max(d.values())==n//3:
                print('YES')
            else:
                print('NO')

Measured memory_bytes: 3572
#include <bits//stdc++.h>
using namespace std;
 
int main(){
    long double a,b,c;
    cin >> a >> b >> c;
   	if( sqrtl(a) + sqrtl(b) + 1.0e-14 < sqrtl(c) ){
      cout << "Yes";
    }
	else
    {
      cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,M;cin>>N>>M;
    int sx[N],sy[N];
    REP(i,N)cin>>sx[i]>>sy[i];
  	int cx[M],cy[M];
  	REP(i,M)cin>>cx[i]>>cy[i];
    REP(i,N){
        int ans=0;
        int mindist=INF;
        REP(j,M){
            int dist=abs(sx[i]-cx[j])+abs(sy[i]-cy[j]);
            if(dist<mindist){
                ans=j+1;
                mindist=dist;
            }
        }
      	cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

int main() {
	const int INF = (1 << 29);

	int n, m;
	scanf("%d\n%d", &n, &m);

	vector<vector<int>> mat(n, vector<int>(n, INF));
	for(int i = 0; i < n; ++i) {
		mat[i][i] = 0;
	}

	for(int i = 0; i < m; ++i) {
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		--a; --b;
		mat[a][b] = c;
		mat[b][a] = d;
	}

	for(int k = 0; k < n; ++k) {
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				chmin(mat[i][j], mat[i][k] + mat[k][j]);
			}
		}
	}

	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	--x1; --x2;
	printf("%d\n", y1 - (mat[x1][x2] + mat[x2][x1] + y2));

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include <stdio.h>

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char map[105][105];  //H <= 100, W <= 100
int h, w, vis[105][105];

void dfs(int x, int y, char c)
{
    int i, xx, yy;

    for(i = 0; i < 4; i++)
    {
        xx = x + dx[i];
        yy = y + dy[i];
        
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && map[xx][yy] == c)  //?找相同区域?char相同
        {
            vis[xx][yy] = 1;  //搜索的?置?1以防下次搜索?区域
            dfs(xx, yy, c);
        }
    }
}

int main()
{
    int i, j, ans;

    while(scanf("%d%d", &h, &w) && (h || w))
    {
        getchar();  //?行考?

        for(i = 0; i < h; i++) scanf("%s", map[i]);  //按行?取
        memset(vis, 0, sizeof vis);  //vis全部元素置?0，即初始化数?
        ans = 0;

        for(i = 0; i < h; i++)
        {
            for(j = 0; j < w; j++)
            {
                if(!vis[i][j])
                {
                    ans++;  //一?始就是一个区域
                    dfs(i, j, map[i][j]);  //深度搜索
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

/*
??附?
在H*W的矩形果?里有苹果、梨、蜜柑三?果?，相?（上下左右）的同?果?属于同一个区域，?出果?的果?分布，求?共有多少个区域。
（原?的??中苹果?リ，梨?カ，蜜柑?ミ， ?中共10个区域） 
?入：
多?数据，??数据第一行??个整数H、W（H <= 100, W <= 100）， H =0 且 W = 0代表?入?束。
以下H行W列表示果?的果?分布，苹果是@，梨是#， 蜜柑是*。
?出：
?于??数据，?出其区域的个数。
*/

Measured memory_bytes: 1132
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::vector<std::string> vs;
  for (int i = 0; i < n; ++i) {
    std::cin >> s;
    vs.push_back(s);
  }

  bool flag = true;
  std::string temp = vs[0];
  for (int i = 1; i < n; ++i) {
    if (vs[i].front() != vs[i-1].back()) {
      flag = false;
      break;
    }
  }

  for (int j = 1; j < n; ++j) {
    for (int k = 0; k < n; ++k) {
      if (j != k && vs[j] == vs[k]) {
        flag = false;
      }
    }
  }

  if (flag) {
    puts("Yes");
  }
  else {
    puts("No");
  }

  return 0;
}

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

using ll = long long;
int main(){
    int n;
    string s;
    cin >> n;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin >> s;
        sort(s.begin(), s.end());
        v[i] = s;
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    ll tp = 0;
    for(int i=0;i<n;i++){
        if(v[tp] != v[i]){
            ll sub = i-tp;
            ans += ((sub - 1) * sub) / 2;
            tp = i;
        }
    }
    ll sub = n-tp;
    ans += ((sub - 1) * sub) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 5760
import sys,heapq
input = sys.stdin.buffer.readline




def main():
    h,w = map(int,input().split())


    class BIT:
        def __init__(self,len_A):
            self.N = len_A + 10
            self.bit = [0]*(len_A+10)
            
        # sum(A0 ~ Ai)
        # O(log N)
        def query(self,i):
            res = 0
            idx = i+1
            while idx:
                res += self.bit[idx]
                idx -= idx&(-idx)
            return res

        # Ai += x
        # O(log N)
        def update(self,i,x):
            idx = i+1
            while idx < self.N:
                self.bit[idx] += x
                idx += idx&(-idx)
        
        # min_i satisfying {sum(A0 ~ Ai) >= w} (Ai >= 0)
        # O(log N)
        def lower_left(self,w):
            if (w < 0):
                return -1
            x = 0
            k = 1<<(self.N.bit_length()-1)
            while k > 0:
                if x+k < self.N and self.bit[x+k] < w:
                    w -= self.bit[x+k]
                    x += k
                k //= 2
            return x


    #dp[i] : iの時の最小右移動回数
    dp = [0]*(w+1)

    #解候補
    res = [0]*w

    #解候補から消されるもの
    anti = []

    C = BIT(w)

    for i in range(1,w+1):
        C.update(i,1)

    for i in range(1,h+1):
        a,b = map(int,input().split())
        
        #a-1,b+1の値を計算
        x = a-1
        if x != 0 and x != w+1 and dp[x] == -1:
            #x以下のvalidな個数
            k = C.query(x-1)

            #k番目のvalidな位置okからXに行く
            if k != 0:
                ok = C.lower_left(k)
                #xをvalidにする
                dp[x] = dp[ok] + (x-ok)
                C.update(x,1)
                heapq.heappush(res,dp[x])
                
        x = b+1
        if x != 0 and x != w+1 and dp[x] == -1:
            #x以下のvalidな個数
            k = C.query(x-1)

            #k番目のvalidな位置okからXに行く
            if k != 0:
                ok = C.lower_left(k)
                #xをvalidにする
                dp[x] = dp[ok] + (x-ok)
                C.update(x,1)
                heapq.heappush(res,dp[x])

        k = C.query(a-1)+1

        while True:
            ok = C.lower_left(k)
            if ok > b or dp[ok] == -1:
                break
            
            heapq.heappush(anti,dp[ok])
            dp[ok] = -1
            C.update(ok,-1)
        
        while anti and res and anti[0] == res[0]:
            heapq.heappop(anti)
            heapq.heappop(res)

        if res:
            print(res[0]+i)
        else:
            print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 126820
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll N,M;
	cin>>N>>M;
	ll ans=N*M-N*2-M*2+4;
	if(N==1 && M==1){
		cout<<1<<endl;
		return 0;
	}
	if(N==1){
		cout<<M-2<<endl;
		return 0;
	}
	if(M==1){
		cout<<N-2<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}


vector<int> subv(vector<int> s,int n,int d){
    vector<int> rt;
    rep(i,d)rt.push_back(s[n+i]);
    return rt;
}

void solve(vector<int> a){
    int n=a.size()-2;
    int len=0;
    rep(i,n+1){
        len+=abs(a[i+1]-a[i]);
    }
    
    REP(i,1,n+1){
        int diff=abs(a[i+1]-a[i-1]) - ( abs(a[i]-a[i-1])+abs(a[i+1]-a[i]) );
        cout<<len+diff<<endl;
    }
    return;
}


int main(void){
    int n;
    ll ans=0;
    string s;
    cin>>n;
    vector<int> t(5,0);
    map<char, ll> mp;
    rep(i,n){
        cin>>s;
        mp[s[0]]++;
    }
    ll c=0;
    for(auto i:"MARCH"){
        t[c]=mp[i];
        c++;
        //cout<<i<<mp[i]<<endl;
    }
    n=5;
    rep(i,n){
        //ans+=t[i]*(t[i]-1)*(t[i]-2)/6;
        REP(j,i+1,n+1){
            //ans+=t[i]*(t[i]-1)*t[j]/3;
            REP(k,j+1,n+1){
                ans+=(ll)t[i]*(ll)t[j]*(ll)t[k];
            }
        }
    }
    cout<<ans<<endl;
    //solve(t);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  int k; cin >> k;
  char ans = '1';
  for (int i = 0; i < k; i++) {
    if (s[i] != '1') {
      ans = s[i];
      break;
    }
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 632
import java.util.Scanner;

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();
		
		if(a<b && b<c){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 0;
		for(int i=3; i<=n; i++){
			a=i;
			for(;;){
				if(i%3==0 || a%10==3){
				System.out.print(" " + i);
				break;
				}
				if(a<10)break;
				a=a/10;
			}
		}
		System.out.println();
	}
}

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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int X,t;
    cin >> X >> t;
    if(X<=t)cout << 0 << endl;
    else cout << X-t << endl;
 }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
namespace bigger
{
	typedef long long ll;
	const int N=2010,MOD=924844033;
	inline void inc(ll a,ll &b){b=(a+b)%MOD;}
	ll inv(ll x){return x<=1?1:((MOD-(MOD/x)*inv(MOD%x)%MOD)%MOD);}
	ll f[N][N][2][2],A[N],B[N],C[N];
	int n,k;
	void initialize()
	{
		scanf("%d%d",&n,&k);
		int n0=k-(n%k),n1=n%k,len=n/k+1;
		f[1][0][0][0]=f[1][1][0][1]=1;
		for(int i=1;i<=len;i++)
			for(int j=0;j<=i;j++)
			{
				ll v00=f[i][j][0][0],v01=f[i][j][0][1],v10=f[i][j][1][0],v11=f[i][j][1][1];

				inc(v00,f[i+1][j][0][0]);
				inc(v00,f[i+1][j+1][0][0]);
				inc(v00,f[i+1][j+1][0][1]);

				inc(v01,f[i+1][j][1][0]);
				inc(v01,f[i+1][j+1][1][0]);
				inc(v01,f[i+1][j+1][1][1]);
				
				inc(v10,f[i+1][j][0][0]);
				inc(v10,f[i+1][j+1][0][1]);

				inc(v11,f[i+1][j][1][0]);
				inc(v11,f[i+1][j+1][1][1]);
			}
		int tot=0;C[0]=1;

		for(int i=0;i<=len;i++)A[i]=(f[len][i][0][0]+f[len][i][1][0])%MOD;
		while(n1--)
		{
			for(int i=0;i<=tot+len;i++)B[i]=0;
			for(int i=0;i<=len;i++)
				for(int j=0;j<=tot;j++)
					inc(A[i]*C[j]%MOD,B[i+j]);
			tot+=len;
			for(int i=0;i<=tot;i++)C[i]=B[i];
		}
		len--;
		for(int i=0;i<=len;i++)A[i]=(f[len][i][0][0]+f[len][i][1][0])%MOD;
		while(n0--)
		{
			for(int i=0;i<=tot+len;i++)B[i]=0;
			for(int i=0;i<=len;i++)
				for(int j=0;j<=tot;j++)
					inc(A[i]*C[j]%MOD,B[i+j]);
			tot+=len;
			for(int i=0;i<=tot;i++)C[i]=B[i];
		}
//		printf("tot = %d\n",tot);
	}
	void solve()
	{
		initialize();
//		for(int i=0;i<=n;i++)printf("%lld ",C[i]);printf("\n");

		ll fact=1,ans=0;
		for(int i=1;i<=n;i++)fact=fact*i%MOD;
		for(int i=0;i<=n;i++)
		{
			if(i&1)ans=(ans-C[i]*fact%MOD)%MOD;
			else ans=(ans+C[i]*fact%MOD)%MOD;
			fact=fact*inv(n-i)%MOD;
		}
		printf("%lld\n",(ans%MOD+MOD)%MOD);
	}
}
int main()
{
	bigger::solve();
	return 0;
}


Measured memory_bytes: 124288
n, k = map(int, input().split())
*A, = map(int, input().split())

MOD = 10**9 + 7

C = {a for a in A}
n = len(C)
m = [[0]*256 for i in range(n+1)]
m[0][0] = 1
for c in C:
    for i in range(n-1, -1, -1):
        s = m[i]; t = m[i+1]
        for j in range(256):
            t[c^j] += s[j]

ans = 0
r = 1
for i in range(1, n+1):
    r = (r * i) % MOD
    ans += r * m[i][k]
    ans %= MOD
print(ans)

Measured memory_bytes: 4084
#include<stdio.h>
int a[105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        int key=a[i];
        int j=i-1;
        while(j>=0&&a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
         for(int i=0;i<n;i++)
        if(i==0) printf("%d",a[i]);
    else printf(" %d",a[i]);
    printf("\n");
    }

    return 0;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));




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

    vector<int> h(n);

    int co=0;
    for(int i=0;i<n;i++){
        cin>>h.at(i);
        if(h.at(i)>=k){
            co++;
        }
    }
    cout<<co<<endl;


}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int h, w, i, j;

	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w ==0)
			break;
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				if(i==0 || j==0 || i==h-1 || j==w-1)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
a = gets.chomp.to_i

MAX = 10**12

def solve(a)
    i = 1

    minStep = MAX

    while i <= Math.sqrt(a)
        if a % i == 0
            j = a / i
            step = (i-1) + (j-1)
            minStep = [minStep, step].min
        end
        i += 1
    end

    return minStep
end

puts solve(a)

Measured memory_bytes: 1916
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    min_num = min(a)
    min_num_idx = a.index(min_num)
    max_num = max(a)
    max_num_idx = a.index(max_num)
    ans = []

    plus_flg = abs(max_num) > abs(min_num)

    if plus_flg:
        for i in range(n - 1):
            while a[i] > a[i + 1]:
                a[i + 1] += max_num
                ans.append((max_num_idx, i + 1))
            if max_num < a[i + 1]:
                max_num_idx = i + 1
                max_num = a[i + 1]

    else:
        for i in range(n - 1, 0, -1):
            while a[i - 1] > a[i]:
                a[i - 1] += min_num
                ans.append((min_num_idx, i - 1))
            if min_num > a[i - 1]:
                min_num_idx = i - 1
                min_num = a[i - 1]

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1)


if __name__ == '__main__':
    main()


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

int main(){
    int n, x, y;
    cin >> n >> x >> y;

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

    if(n == 1) cout << abs(a[0] - y) << endl;
    if(n != 1) cout << max(abs(a[n-1] - y), abs(a[n-1] - a[n-2])) << endl;
    return 0;
}

Measured memory_bytes: 256