akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def dfs(i, g, used, ng):
    for j in g[i]:
        if not used[j]:
            if (i, j) == ng or (j, i) == ng:
                continue
            used[j] = True
            dfs(j, g, used, ng)


def main():
    N, M = map(int, input().split())
    g = defaultdict(list)
    edges = []
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append(b)
        g[b].append(a)
        edges.append((a, b))

    ans = 0
    for edge in edges:
        used = [False] * N
        used[0] = True
        dfs(0, g, used, edge)
        if False in used:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
VI A;
long dp(int i, int x) {
    if(i >= N) {
        if(x % 2 == 0) {
            return 1;
        } else {
            return 0;
        }
    }
    return dp(i+1, x*A[i]) + dp(i+1, x*(A[i]+1)) + dp(i+1, x*(A[i]-1));
}
int main() {
    std::cin >> N;
    A.resize(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    std::cout << dp(0, 1) << std::endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        static long x ;
        static long y ;
        static long x1;
        static long y1;
        static long gcd(long a , long b){
            if (a==0){
                x1 = 0;
                y1 = 1;
                return b;
            }
            long g = gcd(b%a , a);
            x = y1-(b/a)*x1;
            y = x1;
            x1 = x;
            y1 = y;
            return g;
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            for (int i = 0; i <n; i++) {
                in.nextInt();
            }
            System.out.println(1 + (int)Math.ceil(((double)n-k)/(k-1)));




        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

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

int memoization[45] = {0};

int fib(int n) {
  if (memoization[n])
    return memoization[n];
  memoization[n] = fib(n-2) + fib(n-1);
  return memoization[n];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  memoization[0] = 1;
  memoization[1] = 1;
  int n;
  cin >> n;
  cout << fib(n) << endl;
  return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>
#include <stdlib.h>
#define LIMIT 101
int main(void){
    int i, j, length, width;
    char **field;
    int row[LIMIT]={0};
    int col[LIMIT]={0};
    scanf("%d %d\n", &length, &width);
    //各行の配列へのポインタ分のメモリ領域を確保
    field = (char**)calloc(length, sizeof(char*));
    //割り当て失敗防止のため、NULLかどうかエラーチェック
    if(field == NULL){
        fprintf(stderr, "calloc error.\n");
        exit(1);
    }
    //各行の要素分のメモリ領域を確保
    for(i = 0; i < length; i++){
        field[i] = (char*)calloc(width, sizeof(char));
        //割り当て失敗防止のため、NULLかどうかエラーチェック
        if(field[i] == NULL){
            fprintf(stderr, "calloc error.\n");
            exit(1);
        }
    }
    //マス目が'.'か'#'かを受け取る
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&field[i][j]);
        }
    }
    //列ごとに'#'が含まれているかどうかを調べる
    //もし含まれていたらrow[i]が1になる
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(field[i][j]=='#'){
                row[i]=1;
                break;
            }
        }
    }
    //次に行ごとに'#'が含まれていないか調べる
    for(j=0;j<width;j++){
        for(i=0;i<length;i++){
            if(field[i][j]=='#'){
                col[j]=1;
                break;
            }
        }
    }
    //もし,'#'がひとつでも含まれていたらその行、列は書き出すようにする
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(row[i]==1&&col[j]==1){
                printf("%c",field[i][j]);
            }
        }
        printf("\n");
    }
    //メモリ領域の解放，各行の要素分の領域を開放し，
    //各行の配列へのポインタの領域を解放
    //int*を先に開放してしまうとintの住所が分からなくなってしまうため、メモリ領域の確保と逆順で開放する
    for(i = 0; i < length; i++){
        free(field[i]);
    }
    free(field);
    return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
const int MOD = 1e9 + 7;
// dp[i][j] – Number of ways that you can arrange the first i elements with the last element being j 
int dp[MAXN][MAXN], sums[MAXN], n;
string s;

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

int main(){
	cin >>  n >> s;
	dp[1][1] = 1;
	for(int N = 2; N <= n; ++N){
		// Creating prefix sums of dp[N - 1]
		sums[0] = 0;
		for(int i = 1; i < N; ++i){
		    sums[i] = dp[N - 1][i];
		}
		
		for(int i = 1; i <= N; ++i){
		    add_self(sums[i], sums[i - 1]);    
		  //  cout << sums[i] << "\t";
		}
// 		cout << "\n";
		
		char a = s[N - 2];
		for(int last_val = 1; last_val <= N;  ++last_val){
			if(a == '<'){
			    dp[N][last_val] = sums[last_val - 1];
				// for(int prev_val = 1; prev_val < last_val; ++prev_val){
				//     add_self(dp[N][last_val], dp[N - 1][prev_val]);
				// }
			}else if(a == '>'){
				dp[N][last_val] = sums[N - 1] - sums[last_val - 1];
				if(dp[N][last_val] < 0){
				    dp[N][last_val] += MOD;
				}
				// for(int prev_val = last_val + 1; prev_val <= N; ++prev_val){
			 //   	add_self(dp[N][last_val], dp[N - 1][prev_val - 1]);
				// }  
			}
		} 
		
// 		for(int i = 1; i <= N; ++i){
// 		    cout << dp[N][i] << "\t";
// 		}
// 		cout << "\n";
	}
        
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        add_self(ans, dp[n][i]);
    }
    cout << ans << "\n";
	return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

class Card {
private:
    char m_suit;
    int m_rank;

public:
    Card(char suit, int rank)
        : m_suit(suit), m_rank(rank) {}

    char suit() const
    {
        return m_suit;
    }

    int rank() const
    {
        return m_rank;
    }

    Card& operator=(const Card& card)
    {
        this->m_suit = card.m_suit;
        this->m_rank = card.m_rank;

        return *this;
    }

    void printCard() const
    {
        cout << m_suit << m_rank;
    }
};

void bubbleSort(vector<Card>& cards);
void selectionSort(vector<Card>& cards);
void swapCards(vector<Card>& cards, unsigned i, unsigned j);
bool isStable(vector<Card>& cards01, vector<Card>& cards02);

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

    vector<Card> cards01, cards02;
    cards01.reserve(cards_num);
    cards02.reserve(cards_num);

    for (auto i = 0; i < cards_num; i++) {
        char suit;
        int rank;
        cin >> suit >> rank;
        Card card(suit, rank);
        cards01.push_back(card);
        cards02.push_back(card);
    }

    bubbleSort(cards01);
    for (auto i = 0; i < cards_num; i++) {
        if (i != 0) {
            cout << " ";
        }
        cards01.at(i).printCard();
    }
    cout << endl;
    cout << "Stable" << endl;

    selectionSort(cards02);
    for (auto i = 0; i < cards_num; i++) {
        if (i != 0) {
            cout << " ";
        }
        cards02.at(i).printCard();
    }
    cout << endl;
    cout << (isStable(cards01, cards02)? "Stable": "Not stable") << endl;

    return 0;
}

void bubbleSort(vector<Card>& cards)
{
    for (auto i = 0; i < cards.size(); i++) {
        for (auto j = cards.size() - 1; j > i; j--) {
            if (cards.at(j).rank() < cards.at(j - 1).rank()) {
                swapCards(cards, j, j - 1);
            }
        }
    }
}

void selectionSort(vector<Card>& cards)
{
    int min;
    for (auto i = 0; i < cards.size(); i++) {
        min = i;
        for (auto j = i; j < cards.size(); j++) {
            if (cards.at(j).rank() < cards.at(min).rank()) {
                min = j;
            }
        }
        swapCards(cards, i, min);
    }
}

void swapCards(vector<Card>& cards, unsigned i, unsigned j)
{
    Card tmp = cards.at(i);
    cards.at(i) = cards.at(j);
    cards.at(j) = tmp;
}

bool isStable(vector<Card>& cards01, vector<Card>& cards02)
{
    for (auto i = 0; i < cards01.size(); i++) {
        if (cards02.at(i).suit() != cards01.at(i).suit()) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 1204
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>a(M), b(M);
	vector<vector<int>>c(M);
	rep(i, M) {
		cin >> a[i] >> b[i];
		c[i].resize(b[i]);
		rep(j, b[i])cin >> c[i][j];
		rep(j, b[i])c[i][j]--;
	}
	vector<int>dp(1ll << N, INF);
	dp[0] = 0;
	for (int i = 0; i < (1ll << N); i++) { //集合
		for (int j = 0; j < N; j++) { //次とるもの
			if ((i >> j) & 1)continue; //もうすでに含まれていたら
			for (int k = 0; k < M; k++) { //何番目の鍵を使う？
				bool isOK = false;
				for (int l = 0; l < b[k]; l++) {
					if (c[k][l] == j)isOK = true;
				}
				int ni = i;
				int nc = dp[i] + a[k];
				if (isOK) {
					for (int l = 0; l < b[k]; l++) {
						if ((ni >> c[k][l]) & 1)continue;
						ni |= 1ll << c[k][l];
						chmin(dp[ni], nc);
					}
				}
			}
		}
	}
	int ans = dp[(1ll << N) - 1];
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
   int n,m,i,j,jp;
   long long int area,lm,ln,lnn,lmm;
   lmm=lnn=0;
   scanf("%d %d",&n,&m);
   scanf("%d",&j);
   for(i=1;i<n;i++) {jp=j; scanf("%d",&j);ln=j-jp;ln=ln%1000000007; ln=ln*(n-i); ln=ln%1000000007; ln=ln*i; ln=ln%1000000007;lnn=lnn+ln; lnn=lnn%1000000007;}
   scanf("%d",&j);
   for(i=1;i<m;i++) {jp=j; scanf("%d",&j);lm=j-jp;lm=lm%1000000007; lm=lm*(m-i); lm=lm%1000000007; lm=lm*i; lm=lm%1000000007;lmm=lmm+lm; lmm=lmm%1000000007;}
   area=lmm;
   area=area%1000000007;
   area=area*lnn;
   area=area%1000000007;
printf("%I64d",area);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
constexpr int MAX = 1000001;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, M;
    cin >> N >> M;
    cominit();
    lint ans = 0;
    REP(i, N+1) {
        if(i%2 == 0) {
            ans = (ans + ncr(N, i, MOD) * fact[M] % MOD * fact[M-i] % MOD* finv[M-N] % MOD * finv[M-N] % MOD + MOD) % MOD;
        } else {
            ans = (ans - ncr(N, i, MOD) * fact[M] % MOD * fact[M-i] % MOD* finv[M-N] % MOD * finv[M-N] % MOD + MOD) % MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 27040
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

string a[105];

int main()
{
	int n, L;
	cin >> n >> L;
	for (int i = 0; i < n; ++ i)
		cin >> a[i];
	sort (a, a + n);
	for (int i = 0; i < n; ++ i)
		cout << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        string[] map = new string[H];
        for(int i = 0;i < H; i++)
        {
            map[i] = Console.ReadLine();
        }
        bool[,] isWhite = new bool[Math.Max(H, W), 2];

        for (int y = 0; y < H; y++)
        {
            isWhite[y, 1] = true;
            for (int x = 0; x < W; x++)
            {
                if (map[y][x] == '#')
                {
                    isWhite[y, 1] = false;
                    break;
                }
            }
        }

        for (int x = 0; x < W; x++)
        {
            isWhite[x, 0] = true;
            for (int y = 0; y < H; y++)
            {
                if (map[y][x] == '#')
                {
                    isWhite[x, 0] = false;
                    break;
                }
            }
        }

        for (int y = 0; y < H; y++)
        {
            if(isWhite[y, 1])continue;
            for (int x = 0; x < W; x++)
            {
                if (!isWhite[x, 0])
                {
                    Console.Write(map[y][x]);
                }
            }
            Console.WriteLine();
        }

    }
}


Measured memory_bytes: 11092
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ary array

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    int X,Y;
    cin >> X >> Y;
    int b = (Y-2*X);
    if(b < 0 || b % 2 !=0 || b/2 > X) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int n,m;
  cin >> n>>m;
  
  vector<int> p(n);
 
  rep(i,m){
    int x,y;
    cin >>x>>y;
    p[x-1]++;
    p[y-1]++;
  }
  
  rep(i,n){
    cout << p[i] << endl;
  }
  
}

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

#define rep(i,a,b) for (auto i = (a); i < (b); i++)
typedef long long ll;
const ll INF = 1000000000000000000;

int n;
ll mx[100000][3];
int arr[100000][3];

ll dp(int at, int last) {
    if (at == n) {
        return 0;
    }
    if (mx[at][last] != -1) {
        return mx[at][last];
    }

    rep(i,0,3) {
        if (i == last) continue;
        mx[at][last] = max(mx[at][last], arr[at][i] + dp(at+1, i));
    }
    return mx[at][last];
}

int main() {
    cin >> n;

    rep(i,0,n) {
        rep(j,0,3) {
            cin >> arr[i][j];
        }
    }

    memset(mx, -1, sizeof(mx));
    cout << max(dp(0, 0), max(dp(0,1), dp(0,2))) << endl;

    return 0;
}


Measured memory_bytes: 11520
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))
    
T = sorted(T)

bus_time = False
human = 0
count = 0
for i in range(N):
    now = T[i]
    if bus_time == False:
        bus_time = now + K
        human = 1
        count += 1
    else:
        if now <= bus_time and human < C:
            human += 1
        else:
            bus_time = now + K
            human = 1
            count += 1

print(count)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){

    ll N, K;
    cin >> N >> K;

    vector<ll> x(N), y(N);
    vector<pair<ll,ll>> xy(N);
    rep(i, 0, N){
        cin >> x[i] >> y[i];
        xy[i].first = x[i];
        xy[i].second = y[i];
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    ll ans = abs(x[N-1] - x[0]) * abs(y[N-1] - y[0]);

    rep(ix, 0, N-1){
        rep(iy, 0, N-1){
            rep(jx, ix+1, N){
                rep(jy, iy+1, N){
                    ll s = abs(x[jx] - x[ix]) * abs(y[jy] - y[iy]);
                    ll c = 0;
                    rep(i, 0, N){
                        if(x[ix] <= xy[i].first && xy[i].first <= x[jx] && y[iy] <= xy[i].second && xy[i].second <= y[jy]) c++;
                    }
                    if(c >= K) ans = min(ans, s);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  vector<int> x(N);
  for (int i = 0; i < N; i++){
    cin >> x.at(i);
  }
  
  for (int i = 0; i < N; i++){
    if (x.at(i) <= K / 2){
      sum += 2 * x.at(i);
    }else{
      sum += 2 * (K - x.at(i));
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanInt := func() int {
		scanner.Scan()
		num, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		return num
	}

	n, k := scanInt(), scanInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = scanInt()
	}
	sort.Ints(t)

	min := math.MaxInt32
	for i := 0; i < (n - k + 1); i++ {
		diff := t[i+k-1] - t[i]
		if min > diff {
			min = diff
		}
	}
	fmt.Println(min)
}


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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    if(S.size() == T.size()-1){
        if(S.compare(0, S.size(), T, 0, S.size()) == 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }   
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int i = scanner.nextInt();
    if(i < 1200){
      System.out.println("ABC");
    }else if(i < 2800){
      System.out.println("ARC");
    }else{
      System.out.println("AGC");
    }
  }
}

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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    cin>>vec.at(i);
  }
  int p=0;
  for(int i=0;i<m;i++){
    if(vec.at(i)<x){
      p++;
    }
  }
  cout<<min(p,m-p)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const ll inf=1e9;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int>t(n), a(n);
  rep(i,n) cin >> t[i];
  rep(i,n) cin >> a[i];
  
  vector<int>h(n);
  h[0] = t[0];
  rep(i,n-1){
    if(t[i]<t[i+1])h[i+1]=t[i+1];
  }
  
  bool ok = true;
  if(h[n-1]!=a[n-1] && h[n-1]!=0)ok=false;
  h[n-1] = a[n-1];
  
  rep(i,n-1){
    if(a[n-1-i] < a[n-1-(i+1)] && h[n-1-(i+1)] == 0) h[n-1-(i+1)]=a[n-1-(i+1)];
  }
  ll ans = 1;
  rep(i,n-1){
    if(h[i+1]==0){
      ans *= min(t[i+1],a[i+1]);
      ans %= MOD;
      h[i+1] = min(t[i+1],a[i+1]);
    }
  }
  ll ma = t[0];
  rep(i,n-1){
    if(h[i+1]>ma)ma=h[i+1];
    if(ma!=t[i+1])ok=false;
  }
  ma = a[n-1];
  rep(i,n-1){
    if(h[n-1-(i+1)]>ma)ma=h[n-1-(i+1)];
    if(ma!=a[n-1-(i+1)])ok=false;
  }
  if(!ok)ans = 0;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4488
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(1e7 + 1)


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index = int(v_detail[0])
        v_adj_length = int(v_detail[1])
        v_adj_list = v_detail[2:]
        # assert len(v_adj_list) == v_adj_length * 2
        for j in range(0, v_adj_length * 2, 2):
            init_adj_matrix[v_index][v_adj_list[j]] = int(v_adj_list[j + 1])

    return init_adj_matrix


def dijkstra_path():
    # path search init
    start_vertex_index = 0
    path_list[start_vertex_index] = 0
    path_heap = []
    # heapq: compare by tuple[0]
    hp.heappush(path_heap, (path_list[start_vertex_index], start_vertex_index))
    while len(path_heap) >= 1:
        current_vertex = hp.heappop(path_heap)[1]

        color[current_vertex] = BLACK

        for adj_vertex in range(vertices_num):
            current_adj_weight = adj_matrix[current_vertex].get(str(adj_vertex), -1)
            if current_adj_weight < 0:
                continue
            elif color[adj_vertex] is not BLACK:
                # d[u] + w[u,v]
                alt_path = path_list[current_vertex] + current_adj_weight
                if alt_path < path_list[adj_vertex]:
                    # update path_list
                    path_list[adj_vertex] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex))
                    parent_list[adj_vertex] = current_vertex
                    color[adj_vertex] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = list(map(lambda x: x.split(), _input[1:]))
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    adj_matrix = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 8956
def solve():
    N = int(input())
    p = list(map(float,input().split()))

    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(0,i+1):
            dp[i+1][j+1] += dp[i][j] * p[i]
            dp[i+1][j] += dp[i][j] * (1.0 -p[i])
    

    ans = 0
    for i in range(N+1):
        if i > (N-i):
            ans += dp[-1][i]
    
    print(ans)
            
if __name__ == '__main__':
    solve()

Measured memory_bytes: 263176
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	string A, B;
	cin >> A >> B;
	int lenA = A.size();
	int lenB = B.size();
	for (int i = 0; i < (int)max(lenA, lenB); ++i) {
		if (i < lenA) {
			cout << A[i];
		}
		if (i < lenB) {
			cout << B[i];
		}
	}
	cout << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main() {
  int n;
  ll cx,cy,H,endf=0,tmp;
  cin >> n;
  vector<ll>x(n);
  vector<ll>y(n);
  vector<ll>h(n);
  rep(i,n) cin >> x.at(i) >> y.at(i) >> h.at(i);
  rep(i,101){
  	cx=i;
  	rep(j,101){
  		cy=j;
  		rep(k,n){
  			if(h.at(k)>=1){
  				H=h.at(k)+abs(cx-x.at(k))+abs(cy-y.at(k));
  				break;
  			}
  		}
  		rep(k,n){
  			tmp=H-abs(cx-x.at(k))-abs(cy-y.at(k));
  			if(tmp<0) tmp=0;
  			if(tmp!=h.at(k)) break;
  			else if(k==n-1) endf=1;
  		}		
     	if(endf==1) break;	
  	}
  	if(endf==1) break;
  }
  cout << cx << " " << cy << " " << H << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,d;
    cin>>n>>d;
    ll ans = 0;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout<<ans<<"\n";
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute(int n,int K,vector<ll> &vec) {
  int sp = -1;
  rep(i,n) {
    if( vec[i] <= 0 &&vec[i+1] > 0 ) {
      sp = i;
      break;
    }
  }
  if( sp == -1 ) {
    if( vec[0] < 0 ) sp = n-1;
    if( vec[0] >= 0 ) sp = 0;
  }
  assert( sp != -1 );
  ll mini = LLONG_MAX;
  rep(_,2) {
    if( !( 0 <= sp && sp < n ) ) { ++sp; continue; } 
    REP(dir,-1,2) {
      if( dir == 0 ) continue;
      rep(i,n) {
	int cur = sp + i * dir;
	if( !( 0 <= cur && cur < n) ) continue;
	//cout << "?? cur = " << cur << ", sp = " << sp << " : " << vec[sp] << endl;
	ll cost = abs(vec[sp]);
	cost += ( max(vec[cur],vec[sp]) - min(vec[cur],vec[sp]) );
	//cout << "  cost = " << cost << endl;
	int rem = K-(i+1);
	//cout << "  rem = " << rem << endl;
	int nex = sp - rem * dir;
	//cout << "  nex = " << nex << endl;
	//cout << "  [INFO] sp = " << sp << ", turn point = " << cur << ", last point = " << nex << endl; 
	if( rem >= 0 && ( 0 <= nex && nex < n ) ) {
	  cost += ( max(vec[nex],vec[cur]) - min(vec[nex],vec[cur]) );
	}
	//cout << "  cost = " << cost << endl;
	if( !( 0 <= nex && nex < n ) ) continue;
	mini = min(mini,cost);
      }
    }
    ++sp;
  }
  cout << mini << endl;
}

int main() {
  int n,K;
  cin >> n >> K;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  compute(n,K,x);
  return 0;
}


Measured memory_bytes: 1024
N, K = map( int, input().split() )
mod = 10 ** 9 + 7
Cnt = [ 0 ] * ( K + 1 )

for i in range( K, 0, -1 ):
  elem_cnt = K // i
  i_s_cnt = pow( elem_cnt, N, mod)
  for j in range( 2, elem_cnt + 1 ):
    i_s_cnt -= Cnt[ i * j ]
  Cnt[ i ] = i_s_cnt

cnt = 0
for i , c in enumerate( Cnt ):
  cnt += i * c
  cnt = cnt % mod 

print( cnt )

Measured memory_bytes: 11284
#include<bits/stdc++.h>
typedef int LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=1e6+9,mod=998244353,inf=0x3f3f3f3f;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
LL add(LL x,LL y){
	return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
	return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
struct node{
	LL l, r;
}a[maxn],b[maxn],c[maxn];
LL n,ans;
LL vis[maxn],pre[maxn],nxt[maxn];
bool cmp1(node A,node B){
	return A.l<B.l || (A.l==B.l && A.r<B.r);
}
int main(){
    n=Read();
    for(LL i=1;i<=n;++i){
    	LL l(Read()),r(Read());
    	a[i]=(node){l,r};
    	ans=std::max(ans,r-l+1);
	}
	std::sort(a+1,a+1+n,cmp1);
	for(LL i=1;i<=n;++i){
		if(i==1){
			b[i]=a[i];
		}else{
			b[i]=b[i-1];
			b[i].l=a[i].l;
			Chkmin(b[i].r,a[i].r);
		}
	}
	for(LL i=n;i>=1;--i){
		if(i==n){
			c[i]=a[i];
		}else{
			c[i]=c[i+1];
			Chkmax(c[i].l,a[i].l);
			Chkmin(c[i].r,a[i].r);
		}
	}
	/*for(LL i=1;i<=n;++i){
		printf("(%d,%d)",a[i].l,a[i].r);
	}puts("");*/
	for(LL i=1;i<=n;++i){
		node Tmp;
		if(i==1) Tmp=c[i+1];
		else if(i==n) Tmp=b[i-1];
		else{
			Tmp=b[i-1];
		    Chkmax(Tmp.l,c[i+1].l);
		    Chkmin(Tmp.r,c[i+1].r);
		}
		//printf("%d,%d\n",Tmp.l,Tmp.r);
		if(Tmp.l<=Tmp.r) Chkmax(ans,a[i].r-a[i].l+1+(Tmp.r-Tmp.l+1));
	}
	//printf("%d\n",ans);
	LL mi(inf);
	for(LL i=n;i>=1;--i){
		if(mi<=a[i].r) vis[i]=1;
		Chkmin(mi,a[i].r);
	}
	LL tot(0);
	for(LL i=1;i<=n;++i){
		if(!vis[i]){
			a[++tot]=a[i];
		}
	}
	//printf("%d\n",tot);
	mi=inf;
	for(LL i=1;i<=tot;++i){
		Chkmin(mi,a[i].r);
		if(mi>=a[i].l) pre[i]=mi-a[i].l+1;
	}
	mi=a[tot].l;
	for(LL i=tot;i>=1;--i){
		if(mi<=a[i].r) nxt[i]=a[i].r-mi+1;
	}
	for(LL i=1;i<=tot;++i){
		Chkmax(ans,pre[i]); Chkmax(ans,nxt[i]);
		Chkmax(ans,pre[i]+nxt[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}



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

int main(void){
    int x,i;
    cin>>x;
    i=x%7;
    if(i==0){
        cout<<"thu";
    }
    if(i==1){
        cout<<"fri";
    }
    if(i==2){
        cout<<"sat";
    }
    if(i==3){
        cout<<"sun";
    }
    if(i==4){
        cout<<"mon";
    }
    if(i==5){
        cout<<"tue";
    }
    if(i==6){
        cout<<"wed";
    }
    cout<<endl;
}


Measured memory_bytes: 3084
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
const int maxv = 1e9;
 
long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}


int main(){
    int N, M;
    cin >> N >> M;
    long long res = 0;
    if (M > 1) res += combi(M,2);
    if (N > 1) res += combi(N,2);
    cout << res << endl;
    
    return 0;
}

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

int w, h;
int island[50][50], map[50][50];
int i_num = 0;

int Search() {
  int x, y, start = 0;

  //TõÂ\ÍÍàÅ¢TõÌêÉTõN_ðÝu
  for(y = 0; y < h; y ++) {
    for(x = 0; x < w; x ++) {
      //TõN_ª¾Á½Æ«AAµÄ¢éðTµnßé
      if(island[y][x] == 1 && start == 0) {
	start = 1;
      }
      else if(start == 1 && island[y][x] == 0) {
	start = 0;
      }
      //    printf("(x, y) = (%d, %d)\n", x, y);
      //    printf("island = %d, start = %d\n", island[y][x], start);

      _search(x, y, start);
    }
  }

  return i_num;
}

int _search(int x, int y, int start) {

  //TõÏÝ or TõÀWªÅÍÈ¯êÎTõI¹
  if(map[y][x] == 1 || island[y][x] == 0) {
    return 0;
  }
  else if(start == 1) {
    i_num ++;
    start = 0;
    //    printf("i_num = %d\n", i_num);
  }

  int i, j;

  map[y][x] = 1;  //±ÌÀWÉTõÏÝtOð§Äé

  //8ûüÉÂ¢ÄATõÂ\ÍÍàÅ¢TõÌêðTõ·é
  for(i = -1; i <= 1; i ++) {
    for(j = -1; j <= 1; j ++) {
      if(   x + i < 0 || w - 1 < x + i
	 || y + j < 0 || h - 1 < y + j
	 || map[y + j][x + i] == 1) {
	continue;
      }
      _search(x + i, y + j, start);
    }
  }
    
  return 0;
}

int main() {
  int i, j;

  while(1) {
    // ±±©ç
    for(i = 0; i < 50; i ++) {
      for(j = 0; j < 50; j ++) {
	island[i][j] = 0;
	map[i][j] = 0;
      }
    }

    scanf("%d %d", &w, &h);
    if(w == 0 && h == 0) { break; }

    for(i = 0; i < h; i ++) {
      for(j = 0; j < w; j ++) {
	scanf("%d ", &island[i][j]);
      }
    }
    // ±±ÜÅÒW·éÈ

    printf("%d\n", Search());
    i_num = 0;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    int ans[n]={0};
    int i;
    for(i=0;i<m;i++){
        cin >> a >> b;
        ans[a-1]++;
        ans[b-1]++;
    }
    for(i=0;i<n;i++){
        cout << ans[i] <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

int f(int a, int b, int c, int d) {
    return abs(a - c) + abs(b - d);
}

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    VI a(n), b(n), c(m), d(m);
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    REP(i,m){
        cin >> c[i] >> d[i];
    }

    REP(i, n) {
        int ans = -1, t = INT_MAX;
        REP(j, m) {
            if (t > f(a[i], b[i], c[j], d[j])) {
                ans = j;
                t = f(a[i], b[i], c[j], d[j]);
            }
        }
        cout << ++ans << endl;
    }

    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  
  const long long mod = pow(10, 9) + 7;
  long long ans = 0;
  for(long long i = k; i <= n+1; ++i){
    long long cnt = (n + n - i + 1) * i / 2;
    cnt -= (i - 1) * i / 2;
    ans = (ans + cnt + 1) % mod;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int A, B;
	string S;
	bool check = true;

	cin >> A >> B >> S;

	for (int i = 0; i < A; i++) {

		if (!(S[i] == '1' || S[i] == '2' || S[i] == '3' || S[i] == '4' || S[i] == '5' || S[i] == '6' || S[i] == '7' || S[i] == '8' || S[i] == '9' || S[i] == '0')) {

			check = false;

		}

	}
	if (S[A] != '-')check = false;
	for (int i = A + 1; i < S.size(); i++) {

		if (!(S[i] == '1' || S[i] == '2' || S[i] == '3' || S[i] == '4' || S[i] == '5' || S[i] == '6' || S[i] == '7' || S[i] == '8' || S[i] == '9' || S[i] == '0')) {

			check = false;

		}

	}

	if (check)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> enum_div(ll n)
{
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
  ret.push_back(n);
	return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans;
    vector<ll> r = enum_div(n);
    sort(r.begin(), r.end());
    ll tmp = r.size();
    if(tmp%2 == 1) ans = 2*r[tmp/2] - 2;
    else ans = r[tmp/2]+r[tmp/2-1] - 2;
    cout << ans << endl;
    return 0;
}


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

typedef struct _data{
  double x;
  double y;
} data;

double dist(data, data);

double S(double, double, double);

int main(){
  data a[20];
  int i;
  int n;
  double sum;
  for(i = 0; i < 20; i++) {
    if(scanf("%lf,%lf", &a[i].x, &a[i].y) == EOF) break;
  }
  n = i - 1;
  sum = 0;
  for(i = 0; i <= n - 2; i++) {
    sum += S(dist(a[0], a[i+1]), dist(a[0], a[i+2]), dist(a[i+1], a[i+2]));
  }
  printf("%f\n", sum);
  return 0;
}

double dist(data a, data b) {
  return sqrt(pow(b.x-a.x, 2.0) + pow(b.y-a.y, 2.0));
}

double S(double a, double b, double c) {
  double z;
  z = (a+b+c)/2.0;
  return sqrt(z*(z-a)*(z-b)*(z-c));
}

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

void main_()
{
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            auto divisor = (4 * h * n - N * n - N * h);
            if (divisor <= 0) {
                continue;
            }
            if ((N * h * n) % (4 * h * n - N * n - N * h) == 0) {
                auto w = (N * h * n) / (4 * h * n - N * n - N * h);
                if (w > 0 && w <= 3500) {
                    cout << h << " " << n << " " << w << endl;
                    return;
                }
            }
        }
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

typedef long long ll;
ll MOD = 1000000007;

int dp[21][51][51];

bool check(char c, char d) {
	return c == d || (c != '`' && d == '?');
}

int main() {
	int n; cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (; s[i].size() < 20; s[i].push_back('`'));
	}
	for (int i = 0; i <= n; i++)
		dp[20][i][i] = 1;
	for (int i = 0; i + 1 <= n; i++)
		dp[20][i][i + 1] = 1;
	for (int k = 19; k >= 0; k--)
		for (int l = 0; l <= n; l++) {
			vector<int> a(n + 1);
			a[l] = 1;
			for (char c = '`'; c <= 'z'; c++)
				for (int i = n; i >= l; i--)
					if (a[i])
						for (int j = i + 1; j <= n; j++) {
							if (!check(c, s[j - 1][k])) break;
							a[j] = (a[j] + (ll)a[i] * dp[k + 1][i][j]) % MOD;
						}
			for (int r = l; r <= n; r++)
				dp[k][l][r] = a[r];
		}
	cout << dp[0][0][n] << endl;
}

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

int main(){
	int i, now = 0, ans = 0;
	string S;
	cin >> S;
	for(i = 0; i < S.size(); i++){
		if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
			now++;
		}
		else{
			now = 0;
		}
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,o;
    cin>>n>>m>>o;
    cout<<(n^m^o)<<NL;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A, B;
    int res;

    scanf("%d %d", &A, &B);
    res = A - (2 * B);
    if(res < 0)
    {
        printf("0\n");
    }
    else
    {
        printf("%d\n", res);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 16;
bool bad[MAXN];
int n , k , m;
bool Check(int x)
{
	while(x)
	{
		if(bad[x % 10])
			return 0;
		x /= 10;
	}
	return 1;
}
int main()
{
	scanf("%d%d" , &n , &k);
	for(int i = 0 ; i < k ; ++i)
	{
		scanf("%d" , &m);
		bad[m] = 1;
	}
	while(!Check(n))
		++n;
	printf("%d" , n);
}

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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________

int dp[108000][13];

int32_t main()
{ 
  __
 
  string s;
  cin >> s;

  dp[0][0] = 1;

  for(int i = 0;i < s.size();i++)
  {
      for(int j = 0;j < 13;j++)
      {
          if(s[i] == '?')
          {
              for(int d = 0;d < 10;d++)
              {
                  (dp[i+1][(j*10+d)%13] += dp[i][j]) %= mod;
              }
          }
          else
          {
              int d = s[i] - '0';
              (dp[i+1][(j*10+d)%13] += dp[i][j]) %= mod;
          }
      }
  }

  /*
  
  for(int i = 0; i <= s.size(); i++)
  {
    for(int rem = 0; rem < 13; rem++)
    {
      cout << dp[i][rem] << ' ';
    }
    cout << endl;
  }
  */
  cout << dp[s.size()][5] << endl;
 return 0;
}

Measured memory_bytes: 10704
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int cnt = 1;
		while(true){
			int x = in.nextInt();
			if(x == 0)break;
			System.out.println("Case "+cnt+": "+x);
			cnt++;
		}
	}
}

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

int main()
{
    long long n,d;
    cin>>n>>d;
    long long c=0;
    while(n--)
    {
      long long p,q;
      cin>>p>>q;
      if(((p*p)+(q*q)) <= (d*d)) c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3584
N, M, K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
A_sum_list = [0]
B_sum_list = [0]

for i in range(0,N):
    A_sum_list.append(A_sum_list[i]+A_list[i])
for i in range(0,M):
    B_sum_list.append(B_sum_list[i]+B_list[i])
time = 0
number = 0
j = M

for i in range(0,N+1):
    if A_sum_list[i] > K:
        break 
    while K - A_sum_list[i] < B_sum_list[j]: 
        j -= 1
    number = max(number, i+j)
print(number)

Measured memory_bytes: 47332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    char c;
    cin>>c; 
    cout<<char(c+1)<<endl;
    
}

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

ll gcd(ll a,ll b)
{
    if(b == 1)
        return 1;
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
int main(void)
{
    ll a,b;
    cin>>a>>b;
    if(a < b)
    {
        ll t = a;
        a = b;
        b = t;
    }
    cout<<a*b/gcd(a,b)<<endl;
    return 0;
}



Measured memory_bytes: 256