akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 +10 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def BellmanFord(graph,num_v,source=0):
    # graph = 隣接リスト g[source]=[(destination, dist),...]
    # edgeの初期化 edge = [(source,destination,dist),...]
    edges=[]
    for u in range(num_v):
        for v,d in graph[u]:
            edges.append((u,v,d))
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source]=0
    neg=[False for i in range(num_v)]
    neg_flg=False
    
    #辺の緩和
    for i in range(num_v):
#       負閉路があっても、それを通ってスタートからゴールに辿り着けない場合は結果に影響しない事に注意！
        if i==num_v-1:
            check=dist[n-1]
        for u,v,d in edges:
            if dist[v] > dist[u] + d:
                dist[v] = dist[u] + d
                if i==num_v-1:# and neg[v]==True:
                    # N回目で更新があったという事は負閉路が存在する
                    neg_flg=True
                neg[v] = True
    
    return neg_flg,dist
 

show_flg=False
show_flg=True


n,m,p=MI()
g=[[] for i in range(n)]
rg=[[] for i in range(n)]
for i in range(m):
    a,b,c=LI_()
    c+=1
    #g.append((a-1,b-1,p-c))
    g[a].append((b,p-c))
    rg[b].append(a)
    
q=[n-1]
v=[0 for i in range(n)]
v[n-1]=1
while q:
    c=q.pop()
    for nb in rg[c]:
        if v[nb]==0:
            v[nb]=1
            q.append(nb)

for i in range(n):
    if v[i]==0:
        g[i]=[]

fl,d=BellmanFord(g,n,0)
ans=d[n-1]

if fl:
    print(-1)
else:
    print(max(0,-d[n-1]))


Measured memory_bytes: 48360
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    int64_t res = 0, tmp = 0;
    for(int i=0; i<s.size();i++){
        if(s.at(i) == 'A'||s.at(i) == 'C'|| s.at(i) == 'G' || s.at(i) == 'T'){
            tmp++;
        }else{
            if(tmp>=res){
                res = tmp;
            }
            tmp = 0;
        }
    }
    if(tmp>=res){
        res = tmp;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
using System;

namespace abc165_b
{
    class Program
    {
        static void Main(string[] args)
        {
            double ago = double.Parse(Console.ReadLine());
            double currentYokin = 100;
            double max = Math.Pow(10, 18);

            for (double i = 100; i <= max; i++)
            {
                currentYokin = Math.Truncate(currentYokin * 1.01);
                if(ago <= currentYokin)
                {
                    Console.WriteLine(i - 99);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 27876
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	p = readline() |> split |> parseMap
	q = zeros(Int,n+1)
	for i in 1:n
		q[i+1] +=q[i]+p[i]
	end
	r = 0
	rx = 0
	for i in 1:n-k+1
		if r<q[i+k]-q[i]
			rx = i
			r = q[i+k]-q[i]
		end
	end
	s = 0.0
	for i in rx:rx+k-1
		s += (p[i]*(p[i]+1))/p[i]
	end
	println(0.5*s)
end

main()

Measured memory_bytes: 167252
#include <cstdio>
int arr[205], ans[205];
int main()
{
	// freopen("AGC012-C.in", "r", stdin);
	long long n;
	scanf("%lld", &n);
	n++;
	int cnt = 0, len = 0;
	while (n != 1)
	{
		cnt += n & 1;
		arr[len++] = n & 1;
		n >>= 1;
	}
	int l = cnt - 1, r = cnt, cur = 0;
	for (int i = len - 1; i >= 0; i--)
	{
		ans[r++] = cur++;
		if (arr[i])
			ans[l--] = cur++;
	}
	printf("%d\n", r << 1);
	for (int i = 0; i < r << 1; i++)
		printf("%d%c", i < r ? ans[i] + 1 : i - r + 1, " \n"[i + 1 == r << 1]);
	return 0;
}


Measured memory_bytes: 128
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var line = stdin.split(" ") //.map(Number)
var str = line[0]

var flag = "Good"
if(str[0] === str[1]) flag = "Bad"
if(str[1] === str[2]) flag = "Bad"
if(str[2] === str[3]) flag = "Bad"
log(flag)

Measured memory_bytes: 7372
def signature(word)
  word.chars.sort.join.intern
end

n = gets.chomp.to_i

graph = {}
(1..n).each do
  s = gets.chomp
  sig = signature s
  graph[sig] = 0 if graph[sig].nil?
  graph[sig] += 1
end

res = 0
graph.each do |g|
  res += g[1] * (g[1]-1) / 2
end

puts res


Measured memory_bytes: 37756
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    double price,sum,total_p=0,total_s,n=0;
    while(scanf("%lf,%lf",&price,&sum)!=EOF){
        total_p+=price*sum;
        total_s+=sum;
        n++;
    }
    total_s=total_s/n+0.5;
    printf("%d\n",(int)total_p);
    printf("%d\n",(int)total_s);
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    int a, b;
    cin >> a >> b;

    // 処理
    if (a == 1) {
        a = 14;
    }
    if (b == 1) {
        b = 14;
    }

    // 出力
    if (a > b) {
        cout << "Alice" << endl;
    } else if (a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = new int[n];

	int max = 0, second = 0;
	bool unique = true;
	for (int i = 0; i < n; i++)
	{
	    int x = int.Parse(ReadLine());
	    a[i] = x;

	    if (x > max)
	    {
		second = max;
		max = x;
		unique = true;
	    }
	    else if (x == max)
	    {
		unique = false;
	    }
	    else
	    {
		if (x > second)
		{
		    second = x;
		}
	    }
	}

	for (int i = 0; i < n; i++)
	{
	    int y = a[i];
	    if (y == max && unique)
	    {
		WriteLine(second);
	    }
	    else
	    {
		WriteLine(max);
	    }
	}
    }
}


Measured memory_bytes: 18608
import copy
H,W,K=map(int,input().split())
S=[list(input()) for _ in range(H)]
ans=10**18
for i in range(1<<(H-1)):
    x=bin(i).count('1')
    cho=[0]*(x+1)
    f=1
    cnt=x
    for w in range(W):
        j=0
        nx=[0]*(x+1)
        for h in range(H):
          cho[j]+=int(S[h][w])
          nx[j]+=int(S[h][w])
          if cho[j]>K:
            if nx[j]>K:
              f=0
              break
            else:
              cho=copy.copy(nx)
              cnt+=1
          if (i>>h)&1:
            j+=1
        if f==0:
          break
    if f:
      ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 44380
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class arc98_c
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();

            int[] west = new int[n];
            int[] east = new int[n];

            int count=0;
            for(int i=0; i<n; i++){
                if(str[i] == 'W')count++;
                west[i] = count;
            }

            count=0;
            for(int i=n-1; i>=0; i--){
                if(str[i] == 'E')count++;
                east[i] = count;
            }

            int min=int.MaxValue;
            for(int i=0; i<n; i++){
                int tmp=0;
                if(i == n-1){
                    tmp = west[i]+0;
                }else if(i == 0){
                    tmp = 0+east[i];
                }else{
                    tmp = west[i-1]+east[i+1];
                }
                min = Min(min, tmp);
            }
            WriteLine(min);
        }

        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
    }
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;


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(){
    ll a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
}

Measured memory_bytes: 3604
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M, X, Y = map(int, readline().split())
    x_max = max(list(map(int, readline().split())))
    y_min = min(list(map(int, readline().split())))
    if max(X,x_max)<min(Y,y_min):
        print('No War')
    else:
        print('War')



if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
import sys
from heapq import *
from math import ceil
from itertools import accumulate
def input(): return sys.stdin.readline().strip()


def main():
    n, h = map(int, input().split())
    cut = []
    throw = []
    for i in range(n):
        a, b = map(int, input().split())
        cut.append(a)
        throw.append(b)
    cut_max = max(cut)
    throw.sort(reverse=True)
    throw_sum = [0] + list(accumulate(throw))

    loss = set()
    ans = 10**10
    for t in range(n + 1):
        rem = max(0, h - throw_sum[t])
        ans = min(ans, t + ceil(rem / cut_max))
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 87372
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        for(int i = n - 1; i >= 0; i--){
            System.out.print(a[i]);
            if(i != 0){
                System.out.print(" ");
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 26232
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int N = buf[0], K = buf[1];
  int[] A = readln.chomp.split.to!(int[]);
  int[int] mp;

  for (int i = 0; i < N; i++) {
    mp[A[i]]++;
  }
  
  int ans;
  int[] mpv = mp.values;
  sort(mpv);
  for (int i = 0; i < cast(long)mp.length - K; i++) {
    ans += mpv[i];
  }

  writeln(ans);
}


Measured memory_bytes: 24976
N,L=map(int,input().split())
A=list(map(int,input().split()))

if N==2:
    if sum(A)>=L:
        print("Possible")
        print("1")
        exit()
    else:
        print("Impossible")
        exit()
ans=[]
for i in range(N-1):
    if A[i]+A[i+1]>=L:
        last=i
        for j in range(i):
            ans.append(j)
        for j in range(N-2,i,-1):
            ans.append(j)
        break

if len(ans)==0:
    print("Impossible")
    exit()

ans.append(last)

print("Possible")
for i in range(N-1):
    print(ans[i]+1)

Measured memory_bytes: 14436
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  N;
char a[105];
char b[105];
char c[105];

int ans;

int main(){
  scanf("%d",&N);
  rep(i,N) scanf(" %c", &a[i]);
  rep(i,N) scanf(" %c", &b[i]);
  rep(i,N) scanf(" %c", &c[i]);

  rep(i,N) {
    if (a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]) {
      ans += 2;
    } else if (a[i]==b[i] && a[i]==c[i]) {
    } else {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int h[10];
  int i,j;

  for(i=0;i<=9;i++){
    scanf("%d",&h[i]);
  }

  for(j=0;j<=9;j++){
    int k;
    for(k=j;k<=9;k++){
      if(h[j]<h[k]){
	int t;
	t=h[j];
	h[j]=h[k];
	h[k]=t;
      }
    }
  }

  int l=0;
  for(l;l<3;l++){
    printf("%d\n",h[l]);
  }
  return 0;
}
  

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001


int main() {
    int a, b, x;
    cin >> a >> b >> x;
    int ans = int(INF);
    int tmp_ans, tmp_x;

    for(int i=0; i<= (x/1000)+1; i++) {
        tmp_ans = i * a;
        tmp_x = x - i * 1000;

        if (tmp_x > 0) {
            tmp_ans += (tmp_x+499)/500 * b;
        }
//        cout << tmp_ans << endl;

        ans = min(ans, tmp_ans);
    }

    cout << ans << endl;
}




Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

const int MOD = 998244353;
const int INF = 1e9;
using ll = long long;

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

  ll count[N];
  rep(i, N) count[i] = 0;
  rep(i, N) {
    int d; cin >> d;
    if (i == 0 && d != 0) {
      cout << "0\n";
      return 0;
    }
    ++count[d];
  }
  if (count[0] != 1) {
    cout << "0\n";
    return 0;
  }
  ll ans = 1;
  rep(i, N-1) {
    rep(j, count[i+1]) {
      ans *= count[i];
      ans %= MOD;
    }
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 1024
X, K, D = map(int, input().split())
ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = (X+K*D)//(2*D)
    if a >= K:
        a = K
        ans = abs(X-K*D)
    else:
        ans_1 = abs(X+K*D-2*a*D)
        ans_2 = abs(X+K*D-2*(a+1)*D)
        ans = min(ans_1, ans_2)
print(ans)

Measured memory_bytes: 9184
n,q=[int(i) for i in input().split(" ")]

list=[]
for i in range(n):
    nt=input().split(" ")
    name=nt[0]
    time=int(nt[1])
    list.append([name,time])

time=0
while len(list)>0:
    if list[0][1]<=q:
        time+=list[0][1]
        print(list[0][0]+" "+str(time))
        list.pop(0)
    else:
        time+=q
        list[0][1]-=q
        list.append(list[0])
        list.pop(0)
    

Measured memory_bytes: 15444
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const R = parseInt(args[0][0], 10)
	const G = parseInt(args[1][0], 10)
	console.log(G * 2 - R)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = true;
  int time = 0, cnt = 0;
  for(int i = 0; i < 1e8; i++){
    if(time <= c && c <= time + a){
      cout << 60*cnt + c << endl;
      flag = false;
      break;
    }
    time += a + b;
    if(time > 60){
      cnt++, time -= 60;
    }
  }
  if(flag)cout << -1 << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

signed main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        sum += x;
    }
    if (sum > n) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }

}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    ll u = 0;
    rep(i, n) {
        ll h;
        cin >> h;
        if(u - h >= 2) {
            out("No");
            re0;
        }
        chmax(u, h);
    }
    
    out("Yes");
    re0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int n,m;
	cin>>n>>m;
	int l=0,r=inf;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		l=max(l,x);
		r=min(r,y);
	}
	if(r-l+1>0)cout<<r-l+1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int k,x;
  cin>>k>>x;
  int temp=k*500;
  if(temp>=x)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


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

int main() {
    int s;
    int a, b;
    cin >> s;

    a = s / 100;
    b = s % 100;

    if (1 <= a && a <= 12) {
        if (1 <= b && b <= 12) cout << "AMBIGUOUS" << "\n";
        else cout << "MMYY" << "\n";
    } else {
        if (1 <= b && b <= 12) cout << "YYMM" << "\n";
        else cout << "NA" << "\n";
    }
}

Measured memory_bytes: 3576
a,b=map(int, input().split())
x=list(map(int, input().split()))
x.sort()
x.append("a")
i = 0
r = 0
while b> 0:
    if x[i] == "a":
        r-=1
        break
    b -= x[i]
    if b >= 0:
        i +=1
        r +=1
print(r)
        

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

using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000; //十分小さい値を初期値に設定
	int minv = R[0];

	for (int i = 1; i < n; i++) { //ここで毎回、R[i]を読み込めば、配列は不要
		maxv = max(maxv, R[i] - minv); //最大値を更新
		minv = min(minv, R[i]); //ここまでの最小値を保持しておく
	}

	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3900
import java.util.*;

public class Main {

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

        int[] countChar = new int[3];

        for (int i = 0; i < s.length(); i++) {
            switch (s.charAt(i)) {
                case 'a':
                    countChar[0]+=1;
                    break;
                case 'b':
                    countChar[1]+=1;
                    break;
                case 'c':
                    countChar[2]+=1;
                    break;
                 default:
                    break;
            }
        }

        if (countChar[0] > 1 || countChar[1] > 1 || countChar[2] > 1) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

string S;
const int MOD = 1.0e9 + 7;
ll dp[100100][13];

int main() {
    cin >> S;

    memset (dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 0; i < S.length(); i++) {
        int s_i;
        if (S[i] == '?') s_i = -1;
        else s_i = S[i] - '0';


        if (s_i == -1) {
            for (int j = 0; j <= 9; j++) {
                for (int l = 0; l < 13; l++) {
                    dp[i+1][(l*10+j) % 13] = (dp[i+1][(l*10+j) % 13] + dp[i][l]) % MOD;
                }
            }
        }
        else {
            for (int l = 0; l < 13; l++) {
                dp[i+1][(l*10+s_i) % 13] = (dp[i+1][(l*10+s_i) % 13] + dp[i][l]) % MOD;
            }
        }        
    }
    
    cout << dp[S.length()][5] << endl;    

    return 0;
}


Measured memory_bytes: 10624
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int inputCount = int.Parse(Reader.ReadLine());


        Dictionary<char, int> count = new Dictionary<char, int>();
        for (char c = 'a'; c <= 'z'; c++)
        {
            count[c] = 100;
        }


        for (int i = 0; i < inputCount; i++)
        {
            string tmp = Reader.ReadLine();
            for (char c = 'a'; c <= 'z'; c++)
            {
                int cnt = tmp.Count(a => a == c);
                count[c] = Math.Min(cnt, count[c]);
            }

        }

        StringBuilder ans = new StringBuilder();
        for (char c = 'a'; c <= 'z'; c++)
        {
            if (count[c] == 0)
            {
                continue;
            }
            ans.Append(string.Empty.PadLeft(count[c], c));
        }
        Console.WriteLine(ans.ToString());
    
    
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


3
a
aa
b



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13280
#B
import math
N, D = map(int, input().split())
Xs = []
for i in range(N):
    Xs.append(list(map(int, input().split())))
result = 0
for i in range(N-1):
    for j in range(i+1,N):
        dlength = 0
        for k in range(D):
            dlength += (Xs[i][k]-Xs[j][k])**2
        tlength = math.sqrt(dlength)
        if tlength.is_integer():
            result +=1
print(result)

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

int main() {
    string s,t;
    cin >> s >> t;
    int MIN = INT_MAX;
    REP(i, s.length() - t.length() + 1){
        int x = 0;
        string ss = s.substr(i, i + t.length());
        REP(j, t.length()){
            if(ss[j] != t[j]) x++;
        }
        MIN = min(MIN, x);
    }
    cout << MIN << "\n";
    return 0;
}

Measured memory_bytes: 3632
def dwacon5th_prelims_b():
    n, k = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]
    B = []

    for i in range(n):
        cum = 0
        for a in A[i:]:
            cum += a
            B.append(cum)
    B.sort(reverse=True)

    bit = [0]*41
    cand = B.copy()
    for i in range(40, -1, -1):
        nx = []
        for b in cand:
            if (b >> i) & 1: nx.append(b)
        if len(nx) >= k:
            cand = nx.copy()
            bit[i] = 1

    ans = int(''.join([str(x) for x in reversed(bit)]), base=2)
    print(ans)

if __name__ == '__main__':
   dwacon5th_prelims_b()

Measured memory_bytes: 42200
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=0;
    for(int i=0;i<N;){
        int j=i;
        while(j<N and a[i]==a[j]) j++;
        ans+=(j-i)/2;
        i=j;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
vector<int> f(int x) {
  vector<int> res;
  for(int i = 1; i <= x; ++i) {
    if(x%i == 0) res.push_back(i);
  }
  return res;
}
int main() {
  int n;
  cin >> n; 
  int cnt = 0;
  for(int i = 1; i<= n; ++i) {
    if(i%2!=0) {
      if(f(i).size() == 8) cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

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

int main(){
    ll n,x;cin>>n>>x;
    vector<ll> a(n),b(n);
    for(ll i=0;i<n;i++){cin>>a[i];b[i]=a[i];}

    if(a[0]>x){a[0]=x;}
    for(ll i=0;i<n-1;i++){
        if(a[i]+a[i+1]>x){a[i+1]=x-a[i];}
    }

    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=abs(b[i]-a[i]);
    }

    cout<<ans<<endl;   
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t L0=2;
  int64_t L1=1;
  int64_t lucas=0;
  for(int i=0;i<N-1;i++){
    lucas=L0+L1;
    L0=L1;
    L1=lucas;
  }
  if(N==0){
    lucas=2;
  }else if(N==1){
    lucas=1;
  }
  cout<<lucas<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int holiday, assign;
    cin>>holiday>>assign;
    long task=0;
    while(assign--)
    {
        long x;
        cin>>x;
        task+=x;
    }
    long rem = holiday-task;
    if(rem<0){
        cout<<-1<<"\n";
    }
    else
    {
        cout<<rem<<"\n";
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<bitset>
using namespace std;
#define ll long long
#define re register
#define mp make_pair
typedef pair<int,int> pii;
inline int gi()
{
	int sum=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int main()
{
	int x=gi();
	if(x==22)puts("Christmas Eve Eve Eve"); 
	else if(x==23)puts("Christmas Eve Eve");
	else if(x==24)puts("Christmas Eve");
	else puts("Christmas");
	return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut q = vec![(0, 0, 0); n];
    for i in 0..n {
        let a = read::<usize>();
        let b = read::<usize>() + 1;
        // [a,b)に行けば1point
        q[i] = (b - a, a, b);
    }
    q.sort();
    let mut cnt = 0;
    let mut fen = Fenwick::new(m + 10);
    for i in 1..m + 1 {
        while cnt < n {
            let (range, l, r) = q[cnt];
            if range < i {
                fen.add(l, 1);
                fen.add(r, -1);
                cnt += 1;
            } else {
                break;
            }
        }
        let mut j = 0;
        let mut sum: i64 = (n - cnt) as i64;
        while j < m + 10 {
            sum += fen.sum(j + 1);
            j += i;
        }
        println!("{}", sum);
    }


}

#[derive(Debug)]
#[allow(dead_code)]
struct Fenwick {
    dat: Vec<i64>,
    n: usize,
}
#[allow(dead_code)]
impl Fenwick {
    pub fn new(n: usize) -> Fenwick {
        Fenwick {
            dat: vec![0i64; n],
            n: n,
        }
    }
    fn sum(&self, _i: usize) -> i64 {
        let mut i = _i.clone() as i64;
        i -= 1;
        let mut ret: i64 = 0i64;
        while i >= 0 {
            ret += self.dat[i as usize];
            i = (i & (i + 1)) - 1;
        }
        ret
    }
    fn sum_range(&self, _l: usize, _r: usize) -> i64 {
        self.sum(_r) - self.sum(_l)
    }
    fn add(&mut self, _i: usize, x: i64) {
        let mut i = _i.clone();
        while i < self.n {
            self.dat[i] += x;
            i = i | (i + 1)
        }
    }
}

#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}


Measured memory_bytes: 16636
#include <bits/stdc++.h>
using namespace std;
#define maxn 5005
#define int long long
#define maxm 250 
int n, m, dis[maxn], val[maxn][maxm];
int Ans, ans[maxn][maxn], Q[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct node
{
	int num, id;
	node(int _id = 0, int _num = 0) { num = _num, id = _id; }
}S[maxm][maxn];

signed main()
{
	n = read(), m = read();
	for(int i = 2; i <= n; i ++) dis[i] = read() + dis[i - 1];
	for(int i = 1; i <= n; i ++) 
		for(int j = 1; j <= m; j ++) val[i][j] = read();
	for(int i = 1; i <= m; i ++) S[i][0].id = n + 1;
	for(int i = n; i >= 1; i --)
	{
		for(int j = 1; j <= m; j ++)
		{
			int top = Q[j];
			ans[i][i] += val[i][j]; ans[i][i + 1] -= val[i][j];
			while(top && S[j][top].num <= val[i][j]) 
			{
				int l = S[j][top].id, r = S[j][top - 1].id;
				int t = val[i][j] - S[j][top].num; 
				ans[i][l] += t, ans[i][r] -= t; 
				top --;
			}
			S[j][++ top] = node(i, val[i][j]);
			Q[j] = top;
		}
	}
	for(int i = n; i; i --)
	{
		for(int j = i; j <= n; j ++)
			ans[i][j] += ans[i][j - 1];
		for(int j = i; j <= n; j ++) ans[i][j] += ans[i + 1][j];
		for(int j = i; j <= n; j ++) 
			Ans = max(Ans, ans[i][j] - dis[j] + dis[i]); 
	}
	printf("%lld\n", Ans);
	return 0;
}

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

int main(){
    char a[3];
    int b=0;

    scanf("%s", a);
    int n=0;
    while(a[n] != '\0'){
        if(a[n] == '7'){
            b = 1;
            printf("Yes");
            break;
        }
        n++;
    }
    if(b == 0) printf("No");
    }

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    //prev logic failed now sorting logic
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<n;){
        int x=a[i];
        int count=0;
        while(x==a[i] && i<n){
            i++;
            count++;
        }
        if(count%2!=0)ans++;
    }
    cout<<ans;
    
}

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

inline int fab(const int x){
	return x<0?x:-x;
}

const int MAXN=2e5;

int n,a[MAXN+5];

long long ans;

map<int,int>mp;

signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		ans=ans+mp[i-a[i]];
		++mp[a[i]+i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 20924
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;
void solve(){
    int h,n;
    cin>>h>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        h-=x;
    }
    if(h<=0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int ai[200005];
int bi[200005];
void fun()
{
    int sum = 0;
    for(int i=1;i<=999;i++){
        ai[i-1] = sum+i;
        sum = sum+i;
    }
}
int main()
{
    fun();
    int a,b,f;
    scanf("%d %d",&a,&b);
    for(int i=0;i<=999;i++)
    {
        if(ai[i]-a==ai[i+1]-b)
        {
            f = ai[i]-a;
            break;
        }
    }
    printf("%d\n",f);
}


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

int main(){
  int N , A;
  int S2 = 0;
  cin >> N;
  for(int i = 0; i < N ; i++){
    cin >> A;
    int S1;
    for (S1 = 0; A%2 == 0; S1++)
      A /= 2;
    if(i==0)
      S2 = S1;
    else if(S1 <= S2)
      S2 = S1; 
  }
  cout << S2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维 
**/
int main()
{
	ll n,i,j,t,k;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b-c>0) cout<<"No";
	
	 else {
	 	if(a*a+b*b+c*c-2*a*b-2*a*c-2*b*c>0) cout<<"Yes";
	 	else cout<<"No";	 }
 } 

Measured memory_bytes: 888
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
use input::*;

fn main() {
    let a = str2vec(&input_line_str());
    p(a.iter().filter(|&&x| x == '2').count());
}



Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>


using namespace std;

int main() {

  char s1[11], s2[11], s3[11];

  cin >> s1 >> s2 >> s3;

  cout << (char)(s1[0] - 32) << (char)(s2[0] - 32) << (char)(s3[0] - 32) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y = 0;
  cin >> x >> y;
  while (x != 0 || y != 0) {
    if (x <= y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
    cin >> x >> y;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

int main() {
  ll n, d;
  cin >> n >> d;
  int dd = 2*d+1;
  int ans = n/dd;
  if (n%dd != 0) ans += 1;
  cout << ans << endl;
}

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

int main(){
  string s;
  cin>> s;
  if(s=="SUN") cout<< 7<< endl;
  else if(s=="MON") cout<< 6<< endl;
  else if(s=="TUE") cout<< 5<< endl;
  else if(s=="WED") cout<< 4<< endl;
  else if(s=="THU") cout<< 3<< endl;
  else if(s=="FRI") cout<< 2<< endl;
  else cout<< 1<< endl;  
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);
    int N, M;
    cin >> N >> M;

    int L[M];
    int R[M];
    rep(i, M) cin >> L[i] >> R[i];
    // rep(i, M) cout << L[i] << " " << R[i] << endl;

    //処理

    int mini = 1000000;
    int maxi = 1;

    rep(i, M) {
        maxi = max(L[i], maxi);
        mini = min(R[i], mini);
    }

    int ans = mini - maxi + 1;
    if (ans < 0) {
        cout << 0 << endl;

    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
from heapq import heapify, heappop, heappush, heappushpop

class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)
      
N,M=map(int,input().split())
L = list(map(lambda s:int(s) * -1,input().split()))
#print(L)
pq = PriorityQueue(L)
import math
for _ in range(M):
  m = pq.pop()
  #print(m)
  pq.push(math.ceil(m / 2))
ANS=0
for _ in range(N):
  k = pq.pop()
  #print(k)
  ANS += k
print(ANS * -1)
  


Measured memory_bytes: 14380
#include <bits/stdc++.h>
#define inf (int)(1e8)
using namespace std;

using P = pair<int, int>;
int h, w;
P st, go;
vector<string> s;
vector<vector<int>> dist;
int d[4] = {0, 1, 0, -1};

int solve();
bool isvalid(P now) {
  return now.first >= 0 && now.first < h && now.second >= 0 && now.second < w &&
         s[now.first][now.second] == '.';
}

int main() {
  cin >> h >> w >> st.first >> st.second >> go.first >> go.second;
  --st.first, --st.second, --go.first, --go.second;
  dist.assign(h, vector<int>(w, inf));
  s.resize(h);
  for (auto& p : s) cin >> p;
  cout << solve() << endl;
  return 0;
}

int solve() {
  deque<P> qu;
  qu.push_front(st);
  dist[st.first][st.second] = 0;
  while (qu.size()) {
    auto [x, y] = qu.front();
    qu.pop_front();
    for (int i = 0; i < 4; ++i) {
      int nx = x + d[i], ny = y + d[i ^ 1];
      if (!isvalid(P(nx, ny))) continue;
      if (dist[nx][ny] > dist[x][y]) {
        dist[nx][ny] = dist[x][y];
        qu.push_front(P(nx, ny));
      }
    }
    for (int i = -2; i <= 2; ++i)
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i, ny = y + j;
        if (!isvalid(P(nx, ny))) continue;
        if (dist[nx][ny] > dist[x][y] + 1) {
          dist[nx][ny] = dist[x][y] + 1;
          qu.push_back(P(nx, ny));
        }
      }
  }
  if (dist[go.first][go.second] == inf) return -1;
  return dist[go.first][go.second];
}

Measured memory_bytes: 9548
#include<iostream>
#include<cmath>

using ull = unsigned long long;
int main() {
	ull n, c;
	std::cin >> n >> c;
	//std::cout << std::fixed;
	std::cout << static_cast<ull>( c*std::pow( c-1,n-1 ) )<< "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

bool isBig(int aw, int as, int bw, int bs){
	return as*(bw + bs) < bs*(aw + as);
}

int main(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	long long int a[n+1][n+1];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin>>a[i][j];
		}
	}
	bool ans = true;
	long long int cnt = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			long long int mini = LLONG_MAX;
			for(int k = 1; k <= n; k++){
				if(i == k || j == k)continue;
				mini = min(mini, a[i][k] + a[k][j]);
			}
			if(mini < a[i][j]){
				ans = false;
				break;
			}
			if(mini > a[i][j]){
				cnt += a[i][j];
			}
		}
		if(!ans)break;
	}
	if(!ans){
		cout<<-1<<endl;
	}else{
		cout<<cnt<<endl;
	}
}



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

int main(){
    int N,K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        ans += min(x, K - x) * 2;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int n = s.length();
  
  string ans = "First";
  if (s[0] == s[n - 1] && n % 2 == 1) ans = "Second";
  if (s[0] != s[n - 1] && n % 2 == 0) ans = "Second";

  cout << ans << '\n';

  return 0;
}


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

int main(){
	int h, w;
	cin >> h >> w;

	string edge;
	for(int i=0; i<w+2; i++) edge+='#';
	string a;
	
	cout << edge << endl;
	for(int i=0; i<h; i++){
		cout << '#';
		cin >> a;
		cout << a;
		cout << '#' << endl;
	}
	cout << edge << endl;

	return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k < a) cout << k << endl;
    else if (k <= a + b) cout << a << endl;
    else cout << a - (k - (a + b)) << endl;

    return 0;
}

Measured memory_bytes: 3580