akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(A: int, B: int, X: int):
    if X >= A and X - A <= B:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;

namespace ABC_120_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int A = int.Parse(word[0]);
            int B = int.Parse(word[1]);
            int C = int.Parse(word[2]);
            if (B / A < C)
            {
                Console.WriteLine(B / A);
            }
            else
            {
                Console.WriteLine(C);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

struct UnionFind{
    vector<ll> par;
    vector<ll> sizes;
    UnionFind(ll n) : par(n), sizes(n, 1) {
        rep(i,n) par[i] = i;
    }
    int find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return sizes[find(x)];
    }
};

struct Edge{
    ll a, b, cost;
    // コストの大小で順序定義
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph{
    int n;  // 頂点数
    vector<Edge> es;  // 辺集合

    // クラスカル法で無向最小全域木のコストの和を計算する
    // グラフが非連結のときは最小全域森のコストの和となる
    int kruskal() {
        // コストが小さい順にソート
        sort(es.begin(), es.end());

        UnionFind uf(n);
        int min_cost = 0;

        rep(ei, es.size()) {
            Edge& e = es[ei];
            if (!uf.same(e.a, e.b)) {
                // 辺を追加しても閉路ができないなら、その辺を採用する
                min_cost += e.cost;
                uf.unite(e.a, e.b);
            }
        }

        return min_cost;
    }
};

Graph input_graph() {
    Graph g;
    int m;
    cin >> g.n >> m;
    rep(i, m) {
        Edge e;
        cin >> e.a >> e.b >> e.cost;
        g.es.push_back(e);
    }
    return g;
}

int main(){
    Graph g = input_graph();
    cout << g.kruskal() << endl;
    return 0;
}


Measured memory_bytes: 6004
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


def phi(city, silver):
    return city*2501+silver


def psi(x):
    city = x//2501
    silver = x % 2501
    return city, silver


n, m, s = map(int, input().split())
g = [[] for _ in range(n*2501+1)]

for i in range(m):
    u, v, a, b = map(int, input().split())
    for j in range(2501):
        if j-a >= 0:
            g[phi(u-1, j)].append((phi(v-1, j-a), b))
            g[phi(v-1, j)].append((phi(u-1, j-a), b))

for i in range(n):
    c, d = map(int, input().split())
    for j in range(2501):
        if j + c <= 2500:
            g[phi(i, j)].append((phi(i, j+c), d))


def dijkstra(s, n, g):
    # g[i][j] : the cost of i→j  or g[i] = [(target, cost), ...]
    # must import heapq
    # sys.stdin.readline is recommended
    d = [10**18] * n
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in g[u]:  # 'in g[u]' if g is an adj list.
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d


s = min(s, 2500)
d = dijkstra(phi(0, s), n*2501+1, g)

for i in range(1, n):
    print(min(d[phi(i, 0):phi(i+1, 0)]))


Measured memory_bytes: 114052
N, K = map(int, input().split())
A = list(map(int, input().split()))

r = max(A)
l = 0

while l+1 < r:
    mid = (l+r)//2
    cnt = 0
    for a in A:
        if(a > mid):
            if(a%mid == 0):
                cnt += (a//mid)-1
            else:
                cnt += a//mid
    if(cnt > K):
        l = mid
    else:
        r = mid
print(r)

Measured memory_bytes: 30796
class card():
    def __init__(self, suit, number):
        self.s = suit
        self.n = number

def Partition(A, p, r):
    x = int(A[r].n)
    i = p - 1

    for j in range(p, r):
        if int(A[j].n) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]

    return i + 1

def QuickSort(A, p, r):
    if p < r:
        q = Partition(A, p, r)
        QuickSort(A, p, q - 1)
        QuickSort(A, q + 1, r)

def Main():

    n = int(input())
    cards = list()
    
    for i in range(n):
        S, N = input().split()
        c = card(S, N)
        cards.append(c)

    reference = sorted(cards, key=lambda x: int(x.n))
    QuickSort(cards, 0, len(cards) - 1)

    flag = 1

    for i in range(len(cards)):
        if cards[i].s != reference[i].s or cards[i].n != reference[i].n :
            flag = 0
            break;
    
    if flag:
        print("Stable")
    else:
        print("Not stable")

    for i in range(len(cards)):
        print("{0} {1}".format(cards[i].s, cards[i].n))
        
Main()


Measured memory_bytes: 33936
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int x;
int main() {
	cin >> n >> x;
	long long ans=0;
	for(int i=1; i<=n; i++) {
		cin >> a[i];
		if(a[i]>x) {
			ans+=a[i]-x;
			a[i] = x;
		}
		if(i>1 && a[i]+a[i-1]>x) {
			ans += (a[i]+a[i-1])-x;
			a[i] -= (a[i]+a[i-1])-x;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
 
int main() {
    int i, num;
    int flag = 0;
    int n, k, d;
    vector<int> v;
  	cin >> n >> k;
    for (i=0;i<k;i++) {
        cin >> d; 
        v.push_back(d);
    }
    sort(v.begin(), v.end());
    for (i=n;i<n*10;i++) {
        flag = 0;
        num = i;
        while(num != 0) {
            auto result = find(v.begin(), v.end(), num % 10);
            if (result != v.end()) flag = 1;
            num /= 10;
        }
        if (flag == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& e : v) assign(e, u...); }

constexpr lint mod = 1e9 + 7;
auto emod = [](lint a, lint p = mod) -> lint { return (a % p + p) % p; };
auto invm = [](auto invm, lint a, lint p = mod) -> lint { a %= p; return a == 1 ? 1 : -p / a * invm(invm, p % a) % p; };

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  lint fn = 1;
  for (lint i = n; i; --i) (fn *= i) %= mod;
  V<lint> c(n);
  for (int i = 1; i < n; ++i) c[i] = (c[i - 1] + fn * invm(invm, i + 1)) % mod;
  lint res = 0;
  for (int i = 0; i < n; ++i) (res += (c[i] + fn + c[n - i - 1]) * a[i]) %= mod;
  cout << emod(res) << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> used(N,0);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    used[a]++;
    used[b]++;
  }

  for(int i=0;i<N;i++){
    if(used[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 640
my ($N,$K)= split(/ /,<>);
my $s= <>;chomp $s;
my @dat = split(/ /,$s);
@dat = sort {$a  <=> $b} @dat;
my $sum =0;
for(my $i=0;$i<$K;$i++){
    #print "$dat[$i]\n";
    $sum = $sum + $dat[$i];
}
print "$sum";

Measured memory_bytes: 4876
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
        static void Main(string[] args)
        {
			AnswerC();
        }
  public static void AnswerC()
		{
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var N = input[0];
			var K = input[1];
			var input2 = Console.ReadLine().Split(' ');

			Dictionary<string, int> keyValuePairs = new Dictionary<string, int>();
			for(int i = 0; i < N; i++)
			{
				var isExist = keyValuePairs.ContainsKey(input2[i]);
				if (isExist)
				{
					keyValuePairs[input2[i]]++;
				}
				else
				{
					keyValuePairs.Add(input2[i], 1);
				}
			}
			var RK = keyValuePairs.Count;
			if (RK <= K)
			{
				Console.WriteLine("0");
			}
			else
			{
				var Sabun = (RK - K);
				var sortbyvalueDesc = keyValuePairs.OrderBy(value => value.Value);
				int cnt = 0;
				int index = 0;
				foreach(var s in sortbyvalueDesc)
				{
					if (index < Sabun)
					{
						cnt += s.Value;
					}
					else
					{
						break;
					}
					index++;
				}
				//var MinCntValue = keyValuePairs.Where(value => value.Value == keyValuePairs.Min(value2 => value2.Value));
				Console.WriteLine(cnt.ToString());
			}
		}
  
}


Measured memory_bytes: 41796
S=int(input())
A=[0]*(S+1)
for i in range(S+1):
    if i==0:
        A[i]=1
    elif i==1 or i==2:
        A[i]=0
    else:
        A[i]=A[i-1]+A[i-3]
print(A[S]%(10**9+7))

Measured memory_bytes: 9208
from collections import defaultdict
d_i = defaultdict(list)
d_j = defaultdict(list)

N = int(input())
A = [int(a) for a in input().split()]

for i in range(N):
    d_i[i-A[i]].append(i)
    d_j[i+A[i]].append(i)

cnt = 0
for key in d_j.keys():
    arr_i = d_i[key]
    arr_j = d_j[key]
    cnt += len(arr_j) * len(arr_i)
print(cnt)


Measured memory_bytes: 125628
main::IO()
main = do
  abc<-getLine
  let x:y:[]=map read  (words abc)::[Int]
  putStr ((solver x y)++"\n")

solver::Int->Int->String
solver x y = let a = mod (x-2) 13 in
             let b = mod (y-2) 13 in
             if a == b then "Draw" else if a>b then "Alice" else "Bob"


Measured memory_bytes: 508
use std::io::Read;

fn main() {
    let mut s = String::new();
    let mut prev = 'a';
    std::io::stdin().read_line(&mut s);
    for c in s.chars() {
        if prev == c {
            println!("Bad");
           std::process::exit(0);
        }
        prev = c;
    }
    println!("Good");
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x,a;
  cin >> x >> a;
  if(x<a) pr(0);
  else pr(10);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin>>S;
    for(int i=0; i<S.size(); i++){
    
      for(int j=i+1; j<S.size(); j++){
          if(S[i]==S[j]){
              cout<<"no"<<endl;
              return 0;
          }
           
          
      }
    }  
      
    cout<<"yes"<<endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int d;
    cin >> d;

    d = 25 - d;
    cout << "Christmas";
    while(d){
        cout << " Eve";
        d--;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long int n,k,s;
    long int i;

    scanf("%ld %ld %ld",&n,&k,&s);

    if(s==1000000000)
    {
        for(i=0;i<k;i++)
    {
        printf("%ld ",s);
    }

    for(i=0;i<n-k;i++)
    {
        printf("%ld ",s-1);
    }
    }
    else
    {    
        for(i=0;i<k;i++)
        {
            printf("%ld ",s);
        }

        for(i=0;i<n-k;i++)
        {
            printf("%ld ",s+1);
        }
    }

    printf("\n");

    return 0;
}

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

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

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong A,B,C,K;

	cin >> A >> B >> C >> K;
	cerr << endl;

	llong ans = (K&1) ? B-A : A-B;

	if(abs(ans) > 1e18)
		cout << "Unfair" << endl;
	else
		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
gets
as = gets.strip.split(" ").map(&:to_i)

head = Array.new(as.size, 0)
sum = 0
before = 0
0.upto(as.size - 1) do |i|
	head[i] = sum
  sum += (as[i] - before).abs
  before = as[i]
end 

tail = Array.new(as.size, 0)
sum = 0
before = 0
(as.size - 1).downto(0) do |i|
	tail[i] = sum
  sum += (as[i] - before).abs
  before = as[i]
end

0.upto(as.size - 1) do |i|
  p = (i == 0 ? 0 : as[i - 1])
  n = (i == as.size - 1 ? 0 : as[i + 1])

  puts head[i] + tail[i] + (n - p).abs
end

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

void Main() {
  int n;
  std::string color;
  std::cin >> n;
  std::cin >> color;

  int r = 0;
  char c = 0;
  for (int i = 0; i < n; i++){
    if (color[i] != c) {
      c = color[i];
      r++;
    }
  }

  std::cout << r << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

long long lcm(int a, int b) {
	return (long long) a * b / gcd(a, b);
}

int main() {
	int a, b;

	scanf("%d%d", &a, &b);
	printf("%lld\n", lcm(a, b));
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;

int main() {
    int N, D, ans = 0;
    cin >> N >> D;
    int X[N][D];
    rep(i, N) rep(j, D) {
        cin >> X[i][j];
    }
    rep(i, N) {
        REP(j, i + 1, N) {
            int sum = 0;
            rep(k, D) {
                sum += pow(X[i][k] - X[j][k], 2);
            }
            int sqrt_int = sqrt(sum);
            double sqrt_double = sqrt(sum);
            if (sqrt_int == sqrt_double) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
t=[int(i) for i in range(n+1)]
t_rev=[0]+[int(i) for i in range(n,0,-1)]

from itertools import accumulate
s=list(accumulate(t))
s_rev=list(accumulate(t_rev))
s.append(s[-1])
s_rev.append(s_rev[-1])

mod=10**9+7
ans=0
for i in range(k,n+2):
  ans+=s_rev[i]-s[i-1]+1
  ans%=mod
print(ans)


Measured memory_bytes: 47992
#include <iostream>

using namespace std;

const int MAX_H = 105;
const int MAX_W = 105;
char D[MAX_H][MAX_W];

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

void dfs(char c, int y, int x, int w, int h) {
  for (int k = 0; k < 4; k++) {
    int x2 = x + dx[k];
    int y2 = y + dy[k];
    if (0 <= x2 && x2 < w && 0 <= y2 && y2 < h && c == D[y2][x2]) {
      D[y2][x2] = '.';
      dfs(c, y2, x2, w, h);
    }
  }
}

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;

    for (int i = 0; i < H; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < W; j++) {
        D[i][j] = s[j];
      }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        char c = D[i][j];
        if (c != '.') {
          dfs(c, i, j, W, H);
          res++;
        }
      }
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include <limits>
#include <numeric>
#include <type_traits>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int n,k;
ll h[MAX],dp[MAX];
int main(){
    cin>>n>>k;
    rep(i,n)cin>>h[i];
    rep(i,MAX)dp[i]=INFTY;
    dp[0]=0;
    rep(i,n+1)rep(j,k+1){
        if(dp[i+j]>dp[i]+abs(h[i]-h[i+j])){
            dp[i+j]=dp[i]+abs(h[i]-h[i+j]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n, k;
    cin >> k >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    int max = -INF;
    rep(i, n){
        if (i != n - 1)
            chmax(max, v[i + 1] - v[i]);
        else if (i == n - 1)
            chmax(max, v[0] + k - v[n - 1]);
    }
    cout << k - max << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int count(char*, int);
int fact(int);
int combi(int, int);

int main() {
  char str[200];
  int k;
  scanf("%s", str);
  scanf("%d", &k);

  int length = strlen(str);

  printf("%d\n", count(str, k));

  return 0;
}

// 数値を表す文字列と残りのk（0以外の数）
int count(char* str, int k) {
  // 0以外の数値を入れられない場合、パターン数1
  if (k == 0) return 1;
  int length = strlen(str);
  if (length == 0) return 0;
  // 0以外の数値をk個含められない場合はパターン数0
  if (k > length) return 0;

  int total = 0;
  // 文字列が"n"(長さが1)なら1～nのnパターン kは1のはず
  if (length == 1 && k == 1) {
    return str[0] - '0';
  }

  // 最上位が0なら下位を調べる
  if (str[0] == '0') return count(&(str[1]), k);

  // 最上位桁をnに固定したパターン
  total += count(&(str[1]), k - 1);

  // 最上位桁を1～(n-1)に固定したパターン
  total += (str[0] - '0' - 1) * combi(length - 1, k - 1) * pow(9, k - 1);

  // 最上位桁を0に固定したパターン
  total += combi(length - 1, k) * pow(9, k);
  return total;
}

// 階乗
int fact(int n) {
  int sum = 1;
  for (int i = 1; i <= n; ++i) {
      sum *= i;
  }
  return sum;
}

// 組み合わせの数
int combi(int n, int r) {
  int p = 1;
  for (int i = n; i > n - r; --i) {
    p *= i;
  }
  return p / fact(r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vi A(N); REP(i,N) cin >> A[i];

  set<int> written;
  REP(i,N) {
    if (!written.count(A[i])) {
      written.insert(A[i]);
    }
    else {
      written.erase(A[i]);
    }
  }

  cout << written.size() << endl;
}

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

namespace AtCoder.Abc
{
    class A_161_ABCSwap
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            Console.WriteLine($"{array[2]} {array[0]} {array[1]}");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28152
s = input()
s0 = int(s[:2])
s1 = int(s[2:])

is_s0 = 1 <= s0 and s0 <= 12
is_s1 = 1 <= s1 and s1 <= 12

if is_s0==True and is_s1==True:
    print('AMBIGUOUS')
elif is_s0==True and is_s1==False:
    print('MMYY')
elif is_s0==False and is_s1==True:
    print('YYMM')
else:
    print('NA')

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a,b,t;

int main(){
    cin >> a >> b >> t;
    cout << t/a * b << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DAY_MAX		200005									// 最大日数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_DAY_MAX];									// 文字列
static int siDCnt;												// 日数
static int siWCnt;												// 働く日数
static int siSp;												// 働かない間隔
static int si1Work[D_DAY_MAX];									// 働く日

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Work, 0, sizeof(si1Work));

	// 条件 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d", &siDCnt, &siWCnt, &siSp);
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 働く日 - セット - 前詰め
	int liWCnt = 0;
	for (i = 0; i < siDCnt; i++) {
		if (sc1Str[i] == 'o') {
			si1Work[i]++;
			liWCnt++;
			i += siSp;
		}
	}
	if (liWCnt > siWCnt) {
		return 0;
	}

	// 働く日 - セット - 後詰め
	for (i = siDCnt - 1; i >= 0; i--) {
		if (sc1Str[i] == 'o') {
			si1Work[i]++;
			i -= siSp;
		}
	}

	// 出力
	for (i = 0; i < siDCnt; i++) {
		if (si1Work[i] == 2) {
			sprintf(lc1Buf, "%d\n", i + 1);
			fOutLine(lc1Buf);
		}
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2432
import java.io.PrintWriter;
import java.util.*;

public class Main{


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

        String s=sc.next();
        int n=s.length();
        int ans=0;
        int count=0;
        for (int i = 0; i <n ; i++) {
            if(f(s.charAt(i))){
                count++;
                if(ans<count)ans=count;
            }
            else{
                count=0;
            }
        }
        if(count>ans)ans=count;
        out.println(ans);

        out.close();
    }

    static boolean f(char a){
        if(a=='A' || a=='C' || a=='G' || a=='T')return true;
        else return false;
    }



}

Measured memory_bytes: 22868
#include<stdio.h>
int main()
{
  int deta,n,x,y,w,h,i,j,k;
  int catx[100],caty[100],nekokazu[100];

  for(k=0; k<100; k++){
    nekokazu[k]=0;
  }
  
  scanf("%d",&deta);
  for(i=0; i<deta; i++){

      scanf("%d%d%d%d",&x,&y,&w,&h);
      scanf("%d",&n);

      for(j=0; j<n; j++){
	scanf("%d%d",&catx[j],&caty[j]);
    }

      for(j=0; j<n; j++){

	if(catx[j]>=x && caty[j]>=y && catx[j]<=x+w && caty[j]<=y+h){
	  nekokazu[i]+=1;
	  }
      }

  }
  for(i=0; i<deta; i++){
  printf("%d\n",nekokazu[i]);

  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

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

  int sum = 0;
  int tmp = N;
  while ( N > 0 ) {
    sum += N % 10;
    N /= 10;
  }

  if ( tmp % sum == 0 ) std::cout << "Yes\n";
  else std::cout << "No\n";

  return 0;
}


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

char dir[4][2] = {{'D', 'U'}, {'U', 'D'}, {'R', 'L'}, {'L', 'R'}};

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    // 上下と左右の独立性を利用
    int H, W, N;
    cin >> H >> W >> N;
    int y, x;
    cin >> y >> x;
    y--, x--;
    string S, T;
    cin >> S >> T;
    for (int d = 0; d < 4; d++) {
        int p;
        if(d == 0) p = y;
        else if(d == 1) p = H - 1 - y;
        else if(d == 2) p = x;
        else if(d == 3) p = W - 1 - x;
        for (int i = 0; i < N; i++) {
            if(S[i] == dir[d][0]) p++;
            if(p >= (d & 2 ? W : H)) {
                cout << "NO" << endl;
                return 0;
            }
            if(T[i] == dir[d][1]) p--;
            if(p < 0) p = 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
long gcd(long a, long b) { return b ? gcd(b, a % b) : a; } // 最大公約数
long lcm(long a, long b) { return a * b / gcd(a, b); };    // 最小公倍数
long digitSum(int n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    int n;
    string str;
    cin >> n >> str;

    rep(i, str.size())
    {
        int a = (int)str[i] + n;

        if (a > (int)'Z')
            a -= 26;

        str[i] = a;

        cout << str[i];
    }
    cout << endl;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

int main(){
    std::string s;
    int a = 0; 
    int b = 0;

    std::cin >> s;

    sort(s.begin() ,s.end());

    for(char str = 'a'; str <= 'z'; str++){
        if(s[a] == str){
            
            if(s[a] == 'z'){
                std::cout << "None" << std::endl;
                break;
            }
            while(1){
                if(s[b + a] != str){
                    break;
                }
                b++;
            }
            a += b;
            b = 0;
        }else{
            std::cout << str << std::endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<int> p;
vector<int> q;
int main() {
	int N,t = 0;
	cin >> N;
	p.resize(N);
	rep(i, N)cin >> p[i];
	rep(i, N-1) {
		if (p[i] > p[i + 1]) {
			++t;
			if (p[p[i] - 1] != i + 1 || t > 2) {
				cout << "NO" << "\n"; 
				return 0; 
			}
		}
	}
	cout << "YES" << "\n";
	return 0;
}

Measured memory_bytes: 256
//ABC097B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for(int i=0;i<k;i++){
		if(max({a,b,c}) == a){
			a *= 2;
		}else if(max({a,b,c}) == b){
			b *= 2;
		}else{
			c *= 2;
		}
	}
	int ans = a+b+c;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, q = gets.split(" ").map(&:to_i)
a = []
b = []
c = []
d = []
q.times do |i|
  a[i], b[i], c[i], d[i] = gets.split(" ").map(&:to_i)
end
ans = 0
arr = [*(1..m)]
arr.repeated_combination(n).each do |t|
  sum = 0
  q.times do |i|
    sum += d[i] if (t[b[i]-1] - t[a[i]-1] == c[i])
  end
  if ans < sum
    ans = sum
  end
end
puts ans

Measured memory_bytes: 14632
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const X = readInt();
      auto dp = new bool[X + 1];
      dp[0] = true;
      foreach (a; 100 .. 105 + 1) {
        foreach (x; a .. X + 1) {
          if (dp[x - a]) {
            dp[x] = true;
          }
        }
      }
      writeln(dp[X] ? 1 : 0);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 380
from bisect import bisect_right

N, D, A = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

x = []
h = []
for d, i in sorted(X):
    x.append(d)
    h.append(i)

ans = 0
k = [-(-v // A) for v in h]
y = [0] * (N + 2)
for i in range(N):
    y[i + 1] += y[i]
    s = max(0, k[i] - y[i + 1])
    ans += s
    y[i + 1] += s
    y[bisect_right(x, x[i] + 2 * D) + 1] -= s
    
print(ans)


Measured memory_bytes: 150468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, x, t;
    cin >> n >> x >> t;
    cout << t * ((n + x - 1) / x) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,x,t;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>n>>x>>t;
    if(n % x == 0) {
        cout<<(n / x) * t<<endl;
    }
    else cout<<((n / x) + 1) * t<<endl;
    return 0;
}

Measured memory_bytes: 3620
#create date: 2020-07-03 10:09

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    t = ns()
    print("Yes" if s==t[:-1] else "No")

if __name__ == "__main__":
    main()

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M;
vector<int> a, b;

int main(){
  cin >> N >> M;
  a.resize(M), b.resize(M);
  vector<int> cnt(N, 0);
  REP(i, M){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    cnt[a[i]]++, cnt[b[i]]++;
  }
  bool ans = true;
  REP(i, N){
    if(cnt[i] % 2 != 0){
      ans = false;
    }
  }
  cout << (ans ? "YES": "NO") << endl;

  
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

char c[1010][1010];
int dist[1010][1010];
int H, W, sx, sy;

ll bfs(int num)
{
    queue<P> que;

    que.push(P{sy, sx});

    dist[sy][sx] = 0;

    while (!que.empty())
    {
        int x, y;

        tie(y, x) = que.front();
        que.pop();

        REP(i, 4)
        {
            int nx = x + dx[i], ny = y + dy[i];

            if (dist[ny][nx] != -1)
                continue;

            if (nx < 0 || ny < 0 || H <= ny || W <= nx)
                continue;

            if (c[ny][nx] == 'X')
                continue;

            if (c[ny][nx] == num + '0')
            {
                dist[ny][nx] = dist[y][x] + 1;

                sx = nx;
                sy = ny;

                return dist[ny][nx];
            }

            dist[ny][nx] = dist[y][x] + 1;

            que.push(P{ny, nx});
        }
    }
}

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

    int N;
    cin >> H >> W >> N;

    REP(i, H)
    {
        REP(j, W)
        {
            cin >> c[i][j];

            if (c[i][j] == 'S')
            {
                sx = j;
                sy = i;
            }
        }
    }

    ll ans = 0;

    REP(i, N)
    {
        memset(dist, -1, sizeof(dist));

        ans += bfs(i + 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8076
n, m = gets.split.map(&:to_i)
P = Array.new(n) {{ac: 0, penalty: 0}}
# Array.newに渡された初期化オブジェクトはP[n]で全て同一オブジェクトを参照するから下の書き方だとバグる
# P = Array.new(n, {ac: 0, penalty: 0})
# P = []
# for i in 1..n
#   P[i] = {ac: 0, penalty: 0}
# end
for i in 0..m-1
  p, s = gets.split
  p = p.to_i - 1
  if P[p][:ac] == 0
    if s == 'AC'
      P[p][:ac] = 1
    else
      P[p][:penalty] += 1
    end
  end
end
acCount = 0
penCount = 0
P.each do |x|
  next if x == nil
  acCount += x[:ac]
  penCount += x[:penalty] if x[:ac] == 1
end
puts "#{acCount} #{penCount}"


Measured memory_bytes: 31228
def canM(num):
    if num >= 1 and num <= 12:
        return True
    return False

def solve():
    s = input()
    f = int(s[:2])
    l = int(s[2:])

    if canM(f) ==True and canM(l) == True:
        res = "AMBIGUOUS"
    elif canM(f) == True and canM(l) == False:
        res = "MMYY"
    elif canM(f) == False and canM(l) == True:
        res = "YYMM"
    else:
        res = "NA"

    print(res)

solve()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int func(int a, int b){
  if (a <= b) return 0;
  int result = a - 2*b;
  return result<0 ? 0:result;
}

int main()
{
  int a,b;
  cin >> a >> b;
  cout << func(a,b)<< endl;
  return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())

def check(num_list):
    largest = max(num_list)
    largest_idx = num_list.index(largest)
    tmp = sum([pow(x, 2) for i, x in enumerate(num_list) if i != largest_idx])
    if tmp == pow(largest, 2):
        return "YES"
    else:
        return "NO"

for i in xrange(N):
    line = sys.stdin.readline()
    num_list = map(int, line.strip().split())
    print "{0}".format(check(num_list))

Measured memory_bytes: 4236
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int i = 1;
	while (1) {
		int x = 0;
		cin >> x;
		if (x == 0) {
			break;
		}
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>
#define ms(x,y)                     memset(x,y,sizeof(x))
#define ump                         unordered_map<int,int>

#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265

const int MOD = 1e9 + 7;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}

inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}

inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}

inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}

bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}
int dp[1005][1005];
int mat[1005][1005];
int solve(int i, int j, int n, int m)
{
  if (i == n && j == m)return 1;
  if (i > n || j > m || mat[i][j] == 0)return 0;
  if (dp[i][j] != -1)return dp[i][j];
  dp[i][j] = add(solve(i + 1, j, n, m), solve(i, j + 1, n, m));
  return dp[i][j];
}
int32_t main()
{
  fast ;


  int n, m; cin >> n >> m;

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      char c; cin >> c;
      if (c == '.')mat[i][j] = 1;

    }
  }
  ms(dp, -1);
  cout << solve(0, 0, n - 1, m - 1);
}



Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define endl "\n"
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 uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n,k;
  cin>>n>>k;

  if((n-1)*(n-2)/2<k) {
    cout << -1 << endl;
    return 0;
  }

  int ans=n-1;
  int m=abs(k-(n-1)*(n-2)/2);
  cout << ans+m << endl;

  for(int i=2;i<=n;i++){
    cout << 1 << " " << i << endl;
  }

  int x=2,y=3;
  while(m--){
    cout << x << " " << y << endl;
    if(y<n) y++;
    else {
      x++;
      y=x+1;
    }
  }

}

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

int main()
{
    bool inverted = false;
    std::string result;

    std::cin >> result;

    int queryCount = 0;
    std::cin >> queryCount;

    result.reserve(result.size() + queryCount);

    for (auto count = 0; count < queryCount; ++count)
    {
        int instruction = 0;
        std::cin >> instruction;
        if (instruction == 1)
        {
            inverted = !inverted;
        }
        else
        {
            int option = 0;
            std::cin >> option;
            bool optionInvert = inverted;
            if (option == 1)
            {
                optionInvert = !optionInvert;
            }

            char append = '\0';
            std::cin >> append;

            if (optionInvert)
            {
                result.insert(result.begin(), append);
            }
            else
            {
                result.push_back(append);
            }
        }
    }

    if (inverted)
    {
        std::string work;
        std::copy(result.rbegin(), result.rend(), std::back_inserter(work));
        std::cout << work;
    }
    else
    {
        std::cout << result;
    }
    return 0;
}

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

int main() {
  int N, ans=0;
  cin >> N;
  vector<int>l(N);
  vector<int>r(N);
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i) >> r.at(i);
    a.at(i) = r.at(i)-l.at(i)+1;
    ans += a.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int h;
int ray[100][100];

int Pri();

int main(){
  int i, j, a;
  int P;

  scanf("%d",&h);

  for(i = 0 ; i < h ; i++){
    for(j = 0 ; j < h ; j++){
      scanf("%d",&a);
      ray[i][j] = a;
      if(ray[i][j] == -1) ray[i][j] = INFTY;
    }
  }

  P = Pri();
  printf("%d\n",P);

  return 0;
}

int Pri(){
  int i, u, min;
  int d[100], p[100], color[100];
  int sum = 0;

  for(i = 0 ; i < h ; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0 ; i < h ; i++){
      if(min > d[i] && color[i] != BLACK){
	u = i;
	min = d[i];
      }
    }

    if(u == -1) break;
    
    color[u] = BLACK;
    for(i = 0 ; i < h ; i++){
      if(color[i] != BLACK && ray[u][i] != INFTY){
	if(d[i] > ray[u][i]){
	  d[i] = ray[u][i];
	  p[i] = u;
	  color[i] = GRAY;
	}
      }
    }
  }

  for(i = 0 ; i < h ; i++){
    if(p[i] != -1) sum += ray[i][p[i]];
  }

  return sum;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int a,b;
    cin >> a >> b;

    int q=a+b;
    int w=a+a-1;
    int e=b+b-1;
    cout << max(max(q,w),e) << endl;

    return 0;
}

Measured memory_bytes: 3620