akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
ll cnt = 0;
int main()
{
    string s, t;
    cin >> s >> t;
    for (ll i = 0; i < t.length(); i++)
    {
        if (s[i] != t[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		StringBuilder sb = new StringBuilder(in.next());
		int num = in.nextInt();

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

			String command = in.next();

			if(command.equals("print")){

				// ???????????????????????????????????§?????????????????????
				int first_num = in.nextInt();
				int second_num = in.nextInt();

				// ????????????????????????????????????
				System.out.println(sb.substring(first_num, second_num + 1));

			}else if(command.equals("reverse")){

				// ???????????????????????????????????§????????????????????????
				int first_num = in.nextInt();
				int second_num = in.nextInt();

				// ????????????????????????????????????????????????
				String reverse_word = sb.substring(first_num, second_num + 1);
				// ??????????????????????????????????????§?????????????????????
				StringBuilder reverse_sb = new StringBuilder(reverse_word);
				// ???????????????????????????
				reverse_word = reverse_sb.reverse().toString();
				// ???????????????????????????????????????????????´?????????????????????
				sb = sb.replace(first_num, second_num+1, reverse_word);

			}else if(command.equals("replace")){

				// ???????????????????????????????????§???????????????????????????
				int first_num = in.nextInt();
				int second_num = in.nextInt();
				// ??????????????????????????????
				String str = in.next();
				// ?????????????????????
				sb.replace(first_num, second_num + 1, str);

			}
		}
	}
}

Measured memory_bytes: 29512
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

void
printv(const vector<int> a)
{
    stringstream ss;
    for (auto it = a.cbegin(); it != a.cend(); it++) {
        if (it != a.begin()) {
            ss << ' ';
        }
        ss << *it;
    }
    cout << ss.str() << endl;
}

void
trace(const vector<int> a)
{
    vector<int> work(a);

    for (int i = 1; i < work.size(); i++) {
        int j = i - 1;
        int key = work[i];
        while (j >= 0 && work[j] > key) {
            work[ j + 1 ] = work[j];
            j--;
        }
        work[ j + 1 ] = key;
        printv(work);
    }
}

int
main()
{
    int N;
    cin >> N; cin.ignore();

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i]; cin.ignore();
    }
    printv(A);

    trace(A);

    return 0;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << ((a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) ? "YES" : "NO") << "\n";

  return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#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 ;
#define PI 3.141592653589793

int main(){
  int can[1010100];
  rep(i, 1000){
    int a = i*(i-1)/2; can[a] = i;
  }
  int N; cin >> N;
  if(!(can[N])){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
  cout << can[N] << endl;
  int cnt = 0; int ans[can[N]][can[N]];
  rep(i, can[N]){
    rep(j, i){
      cnt++;
      ans[i][j] = ans[j][i] = cnt;
    }
  }
  rep(i, can[N]){
    cout << can[N]-1;
    rep(j, can[N]){
      if(i==j) continue;
      cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
      
   
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;
const int m =773267297;

/*C++になってるか認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    ll N, K, c; cin>>N>>K;
    ll S=0;
    for(int i=K; i<=N+1; i++){
        c=(1+i*(N+1-i))%MOD;
        S=(S+c)%MOD;
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N;
    cin >> N;
    set<string> x;
    rep(i, N){
        string s;
        cin >> s;
        x.insert(s);
    }
    cout << x.size() << endl;
    return 0;
}

Measured memory_bytes: 19028
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
bool is_prime(int num){
    if(num <= 1){
        return false;
    }
    for (int i = 2; i + i < num;i++)
    {
        if(num%i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    int X;
    cin >> X;
    int stay = 0;
    int i = X;
    while (stay == 0)
    {
        if(is_prime(i) == true){
            cout << i << endl;
            stay = 1;
        }
        else{
            i++;
        }
    }
}

Measured memory_bytes: 256
S = list(input())
answer = 0
while True:
    if len(S) >= 1:
        S.pop(-1)
        # print(S[0:len(S)//2])
        # print(S[len(S)//2+1:-1])
        if S[0:len(S)//2] == S[len(S)//2:-1]:
            answer = len(S)-1
            break
    else:
        break
    # print(S)
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

int main() {
  ll t;
  cin >> t;
  while(t--) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b>a) {
      cout << "No" << endl;
      continue;
    }
    if(b<=a&&b>d) {
      cout << "No" << endl;
      continue;
    }
    if(b<=a&&d>=b&&c>=b) {
      cout << "Yes" << endl;
      continue;
    }
    ll g=gcd(b,d);
    if(b-g+a%g>c) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
# define PI acos(-1)
using namespace std;
int main()
{
    int n,max,min,t;
    long long sum;
    cin>>n;
    cin>>t;
    max = min = sum = t;
    for(int i=1;i<n;i++){
        cin>>t;
        if(t>max) max = t;
        if(t<min) min = t;
        sum += t;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  char str[200];
  int i = 0,n;

  scanf("%[^\n]",str);

  
  for(i=0; str[i] != '\0'; i++){
    str[i] = toupper(str[i]);
  }
  
  printf("%s\n",str);

  return 0;
}

Measured memory_bytes: 524
from collections import deque, Counter

N, K, L = [int(s) for s in input().split()]
edge_road = [[int(s) - 1 for s in input().split()] for _ in range(K)]
edge_train = [[int(s) - 1 for s in input().split()] for _ in range(L)]
graph_road = [[] for _ in range(N)]
graph_train = [[] for _ in range(N)]

for i, j in edge_road:
    graph_road[i].append(j)
    graph_road[j].append(i)

for i, j in edge_train:
    graph_train[i].append(j)
    graph_train[j].append(i)

group_road = [0] * N
group_num = 0

visited = [False]*N

for i in range(N):
    if visited[i]:
        continue
    dq = deque([i])
    group_road[i] = group_num
    visited[i] = True
    while(dq):
        search_obj = dq.pop()
        for candidate_obj in graph_road[search_obj]:
            if not visited[candidate_obj]:
                group_road[candidate_obj] = group_num
                dq.appendleft(candidate_obj)
                visited[candidate_obj] = True
    group_num += 1


group_train = [0] * N
group_num = 0

visited = [False]*N

for i in range(N):
    if visited[i]:
        continue
    dq = deque([i])
    group_train[i] = group_num
    visited[i] = True
    while(dq):
        search_obj = dq.pop()
        for candidate_obj in graph_train[search_obj]:
            if not visited[candidate_obj]:
                group_train[candidate_obj] = group_num
                dq.appendleft(candidate_obj)
                visited[candidate_obj] = True
    group_num += 1

group_count = Counter(zip(group_road, group_train))

for gr, gt in zip(group_road, group_train):
    print(group_count[(gr, gt)], end=' ')


Measured memory_bytes: 114728
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
int n;
std::vector<int> a;
std::cin >> n;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    a.push_back(temp);
}
std::vector<int> b(n, 0);
int bin = n % 2;
int indexa = 0;
int indexb = 1;
for(int i = 1; i <= n; i++){
   if(i % 2 == 1){
        b[indexa] = a[n - i];
        indexa++;
    } else {
        b[n - indexb] = a[n - i];
        indexb++;
    }
}
for(int i = 0; i < n - 1; i++){
    std::cout << b[i] << " ";
}
std::cout << b[n - 1] << std::endl;
return 0;
}

Measured memory_bytes: 4464
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long A, long long B);

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

void Main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
}

void solve(long long A, long long B){
    cout << A*B << el;
}



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


int main()
{int N, A, B;
 cin >> N;
 cin >> A >> B;
 if((A-B)%2) cout << "Borys" << endl;
 else cout << "Alice" << endl;

      
}

Measured memory_bytes: 256
import java.io.*;class Main{public static void main(String[]a)throws Exception{int i,j;boolean f;float l[]=new float[8];BufferedReader B=new BufferedReader(new InputStreamReader(System.in));for(String s;(s=B.readLine())!=null;System.out.println(f?"NO":"YES")){a=s.split(",");f=false;for(j=0;j<2;j++){for(i=0;i<8;i++)l[i]=Float.valueOf(a[(4*j+i)%8]);f|=((l[0]-l[2])*(l[5]-l[1])+(l[1]-l[3])*(l[0]-l[4]))*((l[0]-l[2])*(l[7]-l[1])+(l[1]-l[3])*(l[0]-l[6]))<0;}}}}



Measured memory_bytes: 24244
a, b, k = map(int, input().split(' '))
for i in range(0, k):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a//2
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b//2
print(f'{max(0,a)} {max(0,b)}')


Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ans=0,j=0,c=0,k=0,p,x=0;
    cin>>n;
    int a[n+2],b[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    j=0;
    if(n%2==0)
    {
        for(i=0; i<n; i++)
        {
            k=i+1;
            if(k%2==0)
            {
                b[j++]=a[i];
            }

        }
        x=j;
        for(p=j-1; p>=0; p--)
            cout<<b[p]<<" ";
        for(i=0; i<n; i++)
        {
            k=i+1;
            if(k%2!=0)
            {
                b[j++]=a[i];
            }

        }
        for(p=x; p<j; p++)
            cout<<b[p]<<" ";
    }
    else
    {
        for(i=n-1; i>=0; i-=2)
        {
            cout<<a[i]<<" ";
        }
        for(i=1; i<n; i+=2)
        {
            cout<<a[i]<<" ";
        }



    }
}


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

using namespace  std;
using ll = long long int;
const int mod = 1000000007;

ll PowMod_RepeatSquaring(ll n,ll p,ll m){
    if (p==0) return 1;
    if (p%2==0){
        ll t = PowMod_RepeatSquaring(n, p/2,m);
        return t*t % m;      
    }
    return n * PowMod_RepeatSquaring(n,p-1,m) % m;
}

ll fact(ll n){
    ll i=1;
    ll j=1;
    while(i<n){
        j = j*(i+1) %mod ;
        i++;
    }
    return j;
}

ll fact(ll n,ll a){
    ll i=n-a+1;
    ll j=n-a+1;
    while(i<n){
        j = j*(i+1) % mod ;
        i++;
    }
    return j;
}

int main(){

    ll n;
    ll a;
    ll b;
    
    cin >> n;
    cin >> a;
    cin >> b;

    ll s=0;
    ll p=0;
    ll q=0;

    s = PowMod_RepeatSquaring(2,n,1000000007);
    p = PowMod_RepeatSquaring(fact(a),1000000005,1000000007)  ;
    p = (p*fact(n,a))%1000000007;
    q = PowMod_RepeatSquaring(fact(b),1000000005,1000000007)  ;
    q = (q*fact(n,b))%1000000007;
    

    cerr << s << " " << p << " " << fact(b) << endl;
    cout << (s-p-q-1 + 2*1000000007 )%1000000007 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, n, max, min;

    scanf("%d %d %d", &n, &a, &b);
    if(a>b){
        max=b;
    }
    else{
        max=a;
    }
    min=a+b-n;
    if(min<0){
        min=0;
    }

    printf("%d %d\n", max, min);
    return 0;
}


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

bool included[1000][1000][1000] = {false};

typedef struct {
  long long deli;
  int apos;
  int bpos;
  int cpos;
}ANS;

static bool lerger(const long long& a, const long long& b) {
  return a > b;
}
static bool ans_lerger(const ANS& a, const ANS& b) {
  return a.deli > b.deli;
}

int main(void) {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector <long long> A(X), B(Y), C(Z);
  for (int i = 0; i < X; i++) cin >> A[i];
  for (int i = 0; i < Y; i++) cin >> B[i];
  for (int i = 0; i < Z; i++) cin >> C[i];

  sort(A.begin(), A.end(), lerger);
  sort(B.begin(), B.end(), lerger);
  sort(C.begin(), C.end(), lerger);

  memset(included, 0, sizeof(included));

  int apos = 0, bpos = 0, cpos = 0;

  vector <ANS> ans;
  ANS top;
  top.deli = A[0] + B[0] + C[0];
  top.apos = top.bpos = top.cpos = 0;
  ans.push_back(top);
  included[0][0][0] = true;

  for (int i = 0; i < K; i++) {
    sort(ans.begin()+i, ans.end(), ans_lerger);
    ANS wk = ans[i];
    cout << wk.deli << endl;


    if (wk.apos < X-1) {
      if (!included[wk.apos+1][wk.bpos][wk.cpos]) {
        included[wk.apos+1][wk.bpos][wk.cpos] = true;
        ANS next_ans;
        next_ans = wk;
        next_ans.apos = wk.apos+1;
        next_ans.deli = A[next_ans.apos] + B[next_ans.bpos] + C[next_ans.cpos];
        ans.push_back(next_ans);
      }
    }
    if (wk.bpos < Y-1) {
      if (!included[wk.apos][wk.bpos+1][wk.cpos]) {
        included[wk.apos][wk.bpos+1][wk.cpos] = true;
        ANS next_ans;
        next_ans = wk;
        next_ans.bpos = wk.bpos+1;
        next_ans.deli = A[next_ans.apos] + B[next_ans.bpos] + C[next_ans.cpos];
        ans.push_back(next_ans);
      }
    }
    if (wk.cpos < Z-1) {
      if (!included[wk.apos][wk.bpos][wk.cpos+1]) {
        included[wk.apos][wk.bpos][wk.cpos+1] = true;
        ANS next_ans;
        next_ans = wk;
        next_ans.cpos = wk.cpos+1;
        next_ans.deli = A[next_ans.apos] + B[next_ans.bpos] + C[next_ans.cpos];
        ans.push_back(next_ans);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 977216
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    vector<string> S(3);
    cin >> S[0] >> S[1] >> S[2];

    int now = 0;
    while(!S[now].empty()) {
        char c = S[now].front();
        S[now].erase(0, 1);
        now = c - 'a';
    }

    cout << (char)(now+'A') << endl;
    return 0;
}


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

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

    vector<string> day{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    reverse(day.begin(), day.end());
    int ans = 0;
    for (int i = 0; i < 7; i++)
    {
        if (S == day[i])
        {
            ans = i + 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;

int main(){
  ios_base::sync_with_stdio(false); 
  string S;
  cin >> S;
  N = S.length();
  int i = 0;
  for(i=0; i<N; ){
    int flag = 1;
    if(i+10 < N && S.substr(i, 11) == "dreameraser")
      i += 11, flag = 0; 
    else if(i+9 < N && S.substr(i, 10) == "dreamerase")
      i += 10, flag = 0;
    else if(i+6 < N && S.substr(i, 7) == "dreamer")
      i += 7, flag = 0;
    else if(i+5 < N && S.substr(i, 6) == "eraser")
      i += 6, flag = 0;
    else if(i+4 < N &&(S.substr(i, 5) == "dream" || S.substr(i, 5) == "erase"))
      i += 5, flag = 0;
    if(flag)
      break;
  }
  if(i < N)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll l,r;
cin>>l>>r;
ll ans=2018;
if(r-l<2019){
    l=l%2019;
    r=r%2019;
    for(int i=l;i<r;i++){
        for(int j=l+1;j<=r;j++){
            chmin(ans,(ll)(i*j)%2019);
        }
    }
    cout<<ans<<endl;
}else{
    cout<<0<<endl;
}
}





Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String args[]) throws IOException {
        FastReader s = new FastReader();
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int x = s.nextInt();
        int ans = 0;
        for(int i=0;i<=a;i++){
            for(int j=0;j<=b;j++){
                for(int k=0;k<=c;k++){
                    int val = i*500+j*100+k*50;
//                    System.out.println(i+" "+j+" "+k);
                    if(val == x){
//                        System.out.println("In");
                        ans++;
                    }
                }

            }
        }
        System.out.println(ans);

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>

using namespace std;
using ll = long long;


int main()
{
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 and M == 0) {
            break;
        }
        vector<int> ng(N, 0);
        ng[0] = 1;
        vector<tuple<int, int, int>> pac;
        for (int i = 0; i < M; i++) {
            int t, s, d;
            cin >> t >> s >> d;
            s--, d--;
            pac.push_back(make_tuple(t, s, d));
        }
        sort(pac.begin(), pac.end());
        for (const auto& p : pac) {
            const int from = get<1>(p);
            const int to = get<2>(p);
            if (ng[from]) {
                ng[to] = 1;
            }
        }
        cout << accumulate(ng.begin(), ng.end(), 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
from collections import deque
N = int(input())
h = list(map(int, input().split()))
count = 0
water=deque()
while sum(h)!=0:
    for i in range(N):
        if h[i] != 0:
            water.append(i)
        if water and h[i]==0:
            break
    for i in range(len(water)):
        k=water.popleft()
        h[k]-=1
    count += 1
    water.clear()

print(count)

Measured memory_bytes: 3316
import Control.Monad

type Degree = Int
type Sec   = Int

solver :: Int -> Int -> Int -> Int -> Int -> Int
solver a b c d e
  | a < 0    = heathen (-a) c + d + heathen b e
  | a > 0    = heathen (b-a) e
  |otherwise = d + heathen b e

heathen :: Degree -> Sec -> Sec
heathen d s = d * s


main :: IO()
main = do
  contents <- replicateM 5 getLine
  let (a:b:c:d:e:_) = map (read :: String -> Int) contents
  print $ solver a b c d e

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    int a,b;
	
	    // 文字列の入力
	scanf("%d %d",&a, &b);//AB
	
	if(a>10){
		printf("%d\n", b);
		return 0;
	}
	printf("%d \n", b+100*(10-a));
	    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

vector<string> a, b;
set<string> c;
void solve()
{
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        c.insert(a[i]);
    }
    
    int m;
    cin >> m;
    b.resize(m);
    for(int i = 0; i < m; i++)
    {
        cin >> b[i];
        c.insert(b[i]);
    }
    
    int ans = 0;
    while(c.size() > 0)
    {
        string cur = *c.begin();
        c.erase(c.begin());
        int temp = 0;
        for(int i = 0; i < n; i++)
        {
            temp += (cur == a[i]);
        }
        
        for(int i = 0; i < m; i++)
        {
            temp -= (cur == b[i]);
        }
        ans = max(ans, temp);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int gcd(int a, int b)
{
    if (a > b)
        swap(a, b);
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main()
{
    int n, k;
    cin >> n >> k;
    VI v(n);
    rep(i, n) cin >> v[i];
    int g = v[0];
    rep(i, 1, n)
    {
        g = gcd(g, v[i]);
    }
    rep(i, n)
    {
        if (v[i] >= k && (v[i] - k) % g == 0)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}

function Main({ int, str, strs, ints }: NormalInput) {
  const X=int();
  const number500=Math.floor(X/500);
  const number5=Math.floor((X%500)/5)
  console.log(number500*1000+number5*5)
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int main(){
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--,b--;
    uf.unite(a,b);
  }
  int ans = 0;
  rep(i,n)ans = max(ans,uf.size(i));

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


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

int  main()
{
	int n;
	cin >> n;
	vector<tuple<int, int, int> > tp;
	tuple<int, int, int> s = make_tuple(0, 0, 0);
	tp.push_back(s);
	string ans = "Yes";
	rep(i, n)
	{
		int t, x, y;
		cin >> t >> x >> y;
		int mp = abs(get<1>(tp.back()) - x) + abs(get<2>(tp.back()) - y);
		int time = abs(get<0>(tp.back()) - t);
		if (mp <= time)
		{
			if ((time % 2 && mp % 2==0) || (time % 2 == 0 && mp % 2))
				ans = "No";
		}
		else
			ans = "No";
		s = make_tuple(t,x,y);
		tp.push_back(s);
	}
	cout << ans << endl;
	return (0);
}


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

int main(){
  int m,f,b;

  cin >> m >> f >> b;

  if(m >= b){
    cout << "0" << endl;
  }else{
    int work = b - m;
    if(work > f){
      cout << "NA" << endl;
    }else{
      cout << work << endl;
    }
  }
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,k;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k;
    vector<double> p(n);
    vector<double> ki(1005,0);
    FOR(i,1,1001){
        ki[i] = ki[i-1] + i;
    }
    FOR(i,1,1001){
        ki[i] = ki[i]/i;
    }

    REP(i,n) {
        int idx;
        cin>>idx;
        p[i] = ki[idx];
    }

    //DEBUG_VEC(p);
    double ans=0;
    double tmp=0.0;
    REP(i,min(n,k)){
        tmp += p[i];
    }
    ans = tmp;
    //DEBUG(tmp);
    FOR(i,k,n){
        tmp = (tmp + p[i]) - p[i-k];
        if(ans<tmp) ans = tmp;
    }

    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  if(n + 1 >= k*2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(raw_input())
h = map(int, raw_input().split())

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

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

int main() {
	vector<int> o1(100000);
	vector<int> o2(50000);
	int n1;
	int n2;
	int count = 0;
	int n;
	cin >> n1;
	for (int i = 0; i < n1; i++)
	{
		cin >> o1[i];
	}
	sort(o1.begin(), o1.end());
	cin >> n2;
	for (int j = 0; j < n2; j++)
	{
		cin >> o2[j];
	}
	for (int i = 0; i < n2; i++)
	{
		if(binary_search(o1.begin(), o1.end(), o2[i]))
                      {
			count++;
                      }
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3372
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A,B,C;
    cin >> A >> B >> C;
    int t= min(A,B+C);
    if(t==A) cout << B+C-A << endl;
    else cout << "0" << endl; 
    return 0;
}

Measured memory_bytes: 888
S = input()

cnt_1=0
cnt_0=0
for idx,s in enumerate(S):
  if (idx%2 == 0 and s == "0") or (idx%2 == 1 and s == "1"):
    cnt_0+=1
  if (idx%2 == 1 and s == "0") or (idx%2 == 0 and s == "1"):
    cnt_1+=1
print(min(cnt_0,cnt_1))
    

Measured memory_bytes: 3188
#include<stdio.h>

int main(){
  int a, b, temp;

  scanf("%d%d",&a,&b);
  
  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }

  while(b > 0){
    temp = a % b;
    a = b;
    b = temp;
  }
    
  printf("%d\n", a);

  return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//abc178d
ll dp[2005];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll s;
    cin>>s;
    V<ll> a;
    for(ll i=3;i<=s;i++) a.push_back(i);
    for(int i=3;i<=s;i++) dp[i]++;
    for(ll i=3;i<=s;i++){
        for(ll cur:a){
            if(cur+i<=s) dp[cur+i]=(dp[cur+i]+dp[i])%mod;
        }
    }
    out(dp[s]);
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {
	ll a, ans = 0;
	cin >> a;

	ans = a + a * a + a * a * a;
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

const int N = (int) 1e6 + 10;
int a[N], b[N], p[N], n;

bool cmp_sum(int i, int j) {
	return a[i] + b[i] > a[j] + b[j];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		p[i] = i;
	}
	sort(p, p + n, cmp_sum);
	int64 res = 0;
	for (int i = 0; i < n; ++i) {
		if (i % 2 == 0) {
			res += a[p[i]];
		} else {
			res -= b[p[i]];
		}
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        int k = scanner.nextInt();

        char[] array = s.toCharArray();

        char al = array[k-1];
        
        for(int i = 0; i < array.length; i++) {
            if(array[i] != al) array[i] = '*';
        }
        
        for(char c: array) {
            System.out.print(c);
        }
        System.out.println();
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
ll n,m;cin >> n>>m;
if(n==m)cout << "Yes" << endl;
else cout << "No" << endl;

    return 0;
}





Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

if a.sort == a
  p 0
else
  MIN = a.min
  MAX = a.max
  cumulativeOp = []
  if MIN >= 0
      posseq = true
  elsif MAX <= 0
      posseq = false
  else
    if MAX.abs > MIN.abs
      index = a.index(MAX) + 1
      posseq = true
    else
      index = a.index(MIN) + 1
      posseq = false
    end
    cumulativeOp = a.size.times.map{|i|[index,i+1]}
  end
  
  if posseq
    cumulativeOp.concat([*1..a.size].each_cons(2).to_a)
  else
    cumulativeOp.concat([*1..a.size].reverse.each_cons(2).to_a)
  end
  
  p cumulativeOp.size
  cumulativeOp.each do |i|
      puts i.join(" ")
  end
end

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
/*Advanced
vi g[N];
int a[N];
*/
bool possible(int max, vector<int> a, int n, int k) {
	bool ans = true;
	int i;
	fo(i, n) {
		k -= (a[i] - 1) / max;				
		if(k < 0) {
			ans = false;
			break;
		}
	}
	
	return ans;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n;
	int k;
	cin >> n;
	cin >> k;
	vector<int> a(n);
	int i;
	fo(i,n) cin >> a[i];
	int min = 1;
	int max = (int) 1e9 + 100;
	int mid = (min + max) / 2;
	i = 0;
	while(min != max) {
		if(possible(mid, a, n, k)) {
			max = mid; 
		} else {
			min = mid + 1;
		}
		mid = (max + min) / 2;
	}
	cout << min;
			
    return 0;
}
/*
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
*/


Measured memory_bytes: 4752
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

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 (a>b) { a=b; return 1; } return 0; }

int main(){
    int h,w;
    std::cin >> h >> w;
    std::vector<std::string> stage(h);
    rep(i,h) std::cin >> stage[i];

    std::vector<std::vector<long long> > dp(h,std::vector<long long>(w,1145141919));
    //i,jに行くまでにかかる最小の更新数
    if(stage[0][0]=='#') dp[0][0] = 1;
    else dp[0][0] = 0;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            //right direction
            int dx = 1, dy = 0, z;
            if(i+dx >= h || j+dy >= w){
                ;
            }else{
                if(stage[i+dx][j+dy]=='#' && stage[i][j]=='.') z=1;
                else z=0;
                chmin(dp[i+dx][j+dy], dp[i][j]+z);
            }
            //bottom direction
            dx = 0; dy = 1;
            if(i+dx >= h || j+dy >= w){
                ;
            }else{
                if(stage[i+dx][j+dy]=='#' && stage[i][j]=='.') z=1;
                else z=0;
                chmin(dp[i+dx][j+dy], dp[i][j]+z);
            }
        }
    }

    std::cout << dp[h-1][w-1] << "\n";
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	int flag = 0;
	int ans = 1;
	for(int i = 0; i < n-1; i++){
		if(a.at(i+1) < a.at(i)){
			if(flag == 1){
				ans++;
				flag = 0;
			}else{
				flag = -1;
			}
		}else if(a.at(i) < a.at(i+1)){
			if(flag == -1){
				ans++;
				flag = 0;
			}else{
				flag = 1;
			}	
		}
	}
	cout << ans << endl;
}

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

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

   res=((n+m)*(n+m-1))/2-n*m;
   cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define p 1000000007
using namespace std;

int n,m,i,j,k;
int pre[100005],ans[100005];
int fac[100005],fac_inv[100005];

int Power(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=(long long)a*a%p)if(b&1)ans=(long long)ans*a%p;
	return ans;
}

int C(int n,int m){return (long long)fac[n]*fac_inv[m]%p*fac_inv[n-m]%p;}

int main()
{
	scanf("%d",&n);
	fac[0]=1;
	for(i=1;i<=n+1;++i)fac[i]=(long long)fac[i-1]*i%p;
	for(i=0;i<=n+1;++i)fac_inv[i]=Power(fac[i],p-2);
	for(i=1;i<=n+1;++i)ans[i]=C(n+1,i);
	for(i=1;i<=n+1;++i)
	{
		scanf("%d",&k);
		if(!pre[k])pre[k]=i;
		else
		{
			m=n+1-i+pre[k]-1;
			for(j=0;j<=m;++j)
			ans[j+1]=(ans[j+1]+p-C(m,j))%p;
		}
	}
	for(i=1;i<=n+1;++i)printf("%d\n",ans[i]);
}

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

int main() {
    int n, x, y, h, w;
    while (cin >> n, n) {
        int sum = 0;
        for (int i=0; i<n; ++i) {
            cin >> x >> y >> h >> w;
            if (x+y+h <= 60 && w <= 2) {
                sum += 600;
            } else if (x+y+h <= 80 && w <= 5) {
                sum += 800;
            } else if (x+y+h <= 100 && w <= 10) {
                sum += 1000;
            } else if (x+y+h <= 120 && w <= 15) {
                sum += 1200;
            } else if (x+y+h <= 140 && w <= 20) {
                sum += 1400;
            } else if (x+y+h <= 160 && w <= 25) {
                sum += 1600;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>

inline double distance(double xa, double ya, double xb, double yb){
	return std::sqrt(pow(xa - xb, 2) + pow(ya - yb, 2));
}

int judge(std::vector<double> ve){
	double center_dis = distance(ve[0], ve[1], ve[3], ve[4]);
	if(center_dis > ve[2] + ve[5]){
		return 0;	
	}else if(center_dis < ve[2] - ve[5]){
		return 2;
	}else if(center_dis < ve[5] - ve[2]){
		return -2;
	}else{
		return 1;
	}
}

int main(void){
	int num;
	std::vector<double> ve(6);

	std::cin >> num;

	for(int i = 0; i < num; ++i){
		std::cin >> ve[0] >> ve[1] >> ve[2] >> ve[3] >> ve[4] >> ve[5];
		
		std::cout << judge(ve) << std::endl;
	}
	return 0;
}

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

using namespace std;
int A[10000], B[10000], NA, NB;

int linearsearch(int A[], int N, int key)
{
	for (int i = 0; i < N; i++)
	{
		if (A[i] == key)
			return 1;
	}
	return 0;
}

int main()
{
	int sum = 0;
	cin >> NA;
	for (int i = 0; i < NA; i++)
	{
		cin >> A[i];
	}
	cin >> NB;
	for (int i = 0; i < NB; i++)
	{
		cin >> B[i];
		if (linearsearch(A, NA, B[i]))
			sum++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <queue>

#define P pair<int,int>
using namespace std;

// マスの縦横
int H,W;
// #,.を格納するマス
char A[1000][1000];
// 幅優先探索の深さを格納するマス
int am[1000][1000];
// 隣り合う辺への移動量
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
// 答え
int ans=0;
 
void BFS(){
  // 入力を受取り、キューに位置x,yを格納
  cin >> H >> W;
  queue<P> que;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> A[i][j];
      //am[i][j] = -1;
      if (A[i][j]=='#'){
        am[i][j] = 0;
        que.push(P(i,j));
      }
    }
  }
  // キューを前から取り出し、隣り合う辺が.か#か調べ.なら#に更新し、深さを1足す
  while (!que.empty()){
    P p = que.front();
    que.pop();
    for (int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx>=0 && nx<H && ny>=0 && ny<W && A[nx][ny]!='#'){
        A[nx][ny] = '#';
        am[nx][ny] = am[p.first][p.second]+1;
        que.push(P(nx,ny));
      }
    }
  }
}
 
int main(){
  BFS();
  // 答えとなる最も深いものを取り出す
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      ans = max(ans, am[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13328