akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;



int main() {
	int a, b, c, d, e;

	cin >> a >> b >> c >> d >> e;

	int min_1 = 0;
	int price = 0;

	int orders[] = { a, b, c, d, e };

	for (int order : orders)
	{
		//cout << order << endl;
		if ((order + 9) % 10 < (min_1 + 9) % 10)
		{
			if (min_1 > 0)
			{
				price += (min_1 + 9) - (min_1 + 9) % 10;
			}
			min_1 = order;
		}
		else
		{
			price += (order + 9) - (order + 9) % 10;
		}

	}
	price += min_1;
	cout << price << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    int dp[5005][5005];

int main(){
    int N, result = 0;
    string S;
    cin >> N >> S;

    for(int i = N-1; i >= 0; i--)
        for(int j = N-1; j >= 0; j--){
            if(S[i] != S[j])    dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1; 
        }

    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++){
            if(i >= j)  continue;
            int now = min(dp[i][j], j-i);
            result = max(result, now);
        }

    cout << result << endl;
}

Measured memory_bytes: 98048
import java.util.Scanner;

public class Main {
	public static int l = 5;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m, t, p;
		int dir,col;
		int[][] times;
		l=32;
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}

			m = sc.nextInt();
			t = sc.nextInt();
			p = sc.nextInt();
			
			// times initialize
			times = new int[l][l];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					times[i][j] = 1;
				}
			}
			
			//turn
			for(int i = 0; i < t; i++) {
				dir = sc.nextInt();
				col = sc.nextInt();
				times = turn(times,dir,col);
			}
			
			//system out
			for(int i=0;i<p;i++) {
				System.out.println(times[sc.nextInt()][sc.nextInt()]);		
			}
		}
		sc.close();
	}

	public static int[][] turn(int[][] times, int dir, int col) {
		int[][] temp = new int[l][l];
		if(dir == 1) {
			int jmax = 0;
			for(int j = 0; j < l; j++) {
				if(times[0][j] > 0) {
					jmax++;
				}else {break;}
			}
			for(int i=0; i<l-col;i++) {
				for(int j=0; j<jmax; j++) {
					temp[i][j] = times[i+col][j];
				}
			}
			for(int i=0;i<col;i++) {
				for(int j=0; j<jmax; j++) {
					temp[i][j] += times[col-1-i][j];
				}
			}
		}else {
			int imax = 0;
			for(int i = 0; i < l; i++) {
				if(times[i][0] > 0) {
					imax++;
				}else {break;}
			}
			for(int j=0;j<l-col;j++) {
				for(int i=0;i<imax;i++) {
					temp[i][j] = times[i][j+col];
				}
			}
			for(int j=0;j<col;j++) {
				for(int i=0;i<imax;i++) {
					temp[i][j] += times[i][col-1-j];
				}
			}
			
		}
		return temp;
	}

}



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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  int i,h;

  h= (h1(getKey(str)) + i * h2(getKey(str))) % M;



  for(i=0;i<14;i++){
    h= (h1(getKey(str)) + i * h2(getKey(str))) % M;
    if(strcmp( H[h], str)==0) return 1;
  }
  return 0;
  
}

int insert(char str[]){

  int i;
  if(find(str)) return 0;
  for(i=0;i<14;i++){
    if(H[ (h1(getKey(str)) + i * h2(getKey(str))) % M ][0]=='\0'){
      strcpy(H[ (h1(getKey(str)) + i * h2(getKey(str))) % M ],str);
      return 1;
    }
  }
  return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>

struct Magic
{
    int damage{};
    int cost{};
    float eff{};
};

int main()
{
    int h{}, n{};
    std::cin >> h >> n;
    std::vector<Magic> magics(n);
    for (int i = 0; i < n; i++) {
        std::cin >> magics[i].damage >> magics[i].cost;
    }

    std::vector<int> dp(h + 1, std::numeric_limits<int>::max());
    dp[0] = 0;
    for (int i = 0; i <= h; i ++) {
        if (dp[i] == std::numeric_limits<int>::max()) continue;
        for (int j = 0; j < n; j++) {
            const auto attack = std::min(h, i + magics[j].damage);
            dp[attack] = std::min(dp[attack], dp[i] + magics[j].cost);
        }
    }

    std::cout << dp[h] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int function2(int arr[],int initial,int final,int mat[][13],int value,int total,int n,int memo[][4101])
{
	if(initial>final)
	{
		if(value==total)
		   return 0;
		else
		   return 1000000000;
	}
	if(memo[initial][value]!=-1)
	    return memo[initial][value];
	else
	{
		int newval=value;
		int j;
		for(j=0;j<n;j++)
		{
			if(mat[initial][j]==1)
			{
				newval|=power(2,j);
			}
		}
		int x=arr[initial]+function2(arr,initial+1,final,mat,newval,total,n,memo);
		int y=function2(arr,initial+1,final,mat,value,total,n,memo);
		memo[initial][value]=min(x,y);
		return memo[initial][value];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int value=0;
	int mat[m+1][13];
	int i,j;
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			mat[i][j]=0;
		}
	} 
	int cost[m+1];
	for(j=0;j<m;j++)
	{
		int b;
		cin>>cost[j]>>b;
		for(i=0;i<b;i++)
		{
			int lock;
			cin>>lock;
			lock--;
			mat[j][lock]=1;
		}
	}
	int total=power(2,n)-1;
	int memo[m+1][4101];
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=4100;j++)
		{
			memo[i][j]=-1;
		}
	}
	int answer=function2(cost,0,m-1,mat,value,total,n,memo);
	if(answer>=1000000000)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 36420
#include <iostream>
using namespace std;
int main(void){
    long long int L, R;
    cin >> L >> R;
    int mod_min = 2019;
    
    for (long long int i = L; i < R; i++) {
        for (long long int j = i+1; j <= R; j++) {
            if ((i*j) % 2019 < mod_min)
                mod_min = (i*j) % 2019;
            if (mod_min == 0)
                break;
        }
        if (mod_min == 0)
            break;
    }
    
    cout << mod_min << endl;
}

Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

//#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 303;
int n, d[N], A, B, C;
db dp[3 * N][2 * N][N];
bool used[3 * N][2 * N][N];

db calc(int a, int b, int c) {
    if (a == 0 && b == 0 && c == 0) {
        return 0;
    }
    if (used[a][b][c]) {
        return dp[a][b][c];
    }
    db & res = dp[a][b][c];
    if (a > 0) {
        res += (calc(a - 1, b, c) + 1) * (db)a / n;
    }
    if (b > 0) {
        res += (calc(a + 1, b - 1, c) + 1) * (db)b / n;
    }
    if (c > 0) {
        res += (calc(a, b + 1, c - 1) + 1) * (db)c / n;
    }
    db left = (db)(n - a - b - c) / n;
    res += left;
    res /= (1.0 - left);
    used[a][b][c] = true;
    return res;
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> d[i];
        if (d[i] == 1) {
            A++;
        }   else if (d[i] == 2) {
            B++;
        }   else {
            C++;
        }
    }
    db ans = calc(A, B, C);
    cout << setprecision(20) << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


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

#define ll long long
using namespace std;

class Unionfind {
    vector<int> par;//親
    vector<int> rank; //深さ

public:
    void init(int n)//初期化
    {
        par = vector<int>(n);
        rank = vector<int>(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)//根を求める
    {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }


public:
    void unite(int x, int y)//集合を併合
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        else {
            if (rank[x] < rank[y]) par[x] = y;
            else {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }
        }
    }

public:
    bool issame(int x, int y)//同じ集合に属しているか
    {
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(m);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            v[c - 1].push_back(i);
        }
    }

    Unionfind uf;
    uf.init(n);
    for (int i = 0; i < m; i++) {
        if (!v[i].empty()) {
            for (int j = 0; j < v[i].size(); j++)uf.unite(v[i][0], v[i][j]);
        }
    }

    bool ret = true;
    for (int i = 0; i < n; i++)
        if (!uf.issame(0, i))ret = false;
    cout << (ret ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int d[101],dd,m,n,q;
	while(1){
		int max=0,maxd;
		for(int i=0;i<101;i++)d[i]=0;
		cin>>n>>q;
		if(n==0&&q==0)return 0;
		for(int i=0;i<n;i++){
			cin>>m;
			for(int j=0;j<m;j++){
				cin>>dd;
				d[dd]+=1;
			}
		}
		for(int i=0;i<101;i++){
			if(d[i]>max){max=d[i];maxd=i;}
		}
		if(max>=q)cout<<maxd<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 864
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

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


int a[10010],N;
int main(){
  cin>>N;
  bool flag=true;
  REP(i,N){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        flag=false;
      }
    }
  }

  if(flag)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;

}


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

using namespace std;
using ll = long long;

int n, k;

void DODP(vector<vector<bool>> &dp, const vector<int> &a) {
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= k; j++) {
            if(!dp[i][j])continue;
            dp[i + 1][j] = true;
            dp[i + 1][min(k, j + a[i])] = true;
        }
    }
}


//サイズは全部k + 1
bool marge(vector<bool> dp1, vector<bool> dp2, int a) {
    if(a >= k)return false;
    // for(int i = k - 1; i >= k - a; i--)if(dp1[i] || dp2[i])return false;
    vector<int> fr, bc;
    for(int i = 0; i < k; i++) {
        if(dp1[i])fr.push_back(i);
        if(dp2[i])bc.push_back(i);
    }
    int m = fr.size();
    for(int i = 0; i < m; i++) {
        auto les = lower_bound(bc.begin(), bc.end(), k - a - fr[i]);
        auto gre = lower_bound(bc.begin(), bc.end(), k - fr[i]);
        if(les != gre)return false;
    }
    return true;
}


int main()
{
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    vector<vector<bool>> dpf(n + 1, vector<bool>(k + 1)), dpb(n + 1, vector<bool>(k + 1));
    DODP(dpf, a);
    reverse(a.begin(), a.end());
    DODP(dpb, a);
    reverse(a.begin(), a.end());

    int cnt = 0;
    // print(dpb[n - 1]);
    for(int I = 0; I < n; I++) {
        bool res = marge(dpf[I], dpb[n - I - 1], a[I]);
        if(res)cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 10124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp = i;
        int keta = 1;
        while(tmp/10) {
            keta++;
            tmp/=10;
        }
        if(keta%2==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[], int N)
{
	int i, j, t, sw = 0,minj;
	for( i = 0; i < N -1; i++)
	{
		minj = i;
		for( j = i; j < N; j++)
		{
			if(A[j] < A[minj]) minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if(i != minj) sw++;
	}
	return sw;
	
}
int main()
{
	int A[100], N, i, sw;
	scanf("%d",&N);
	for(i = 0;i < N;i++) scanf("%d", &A[i]);
	sw = selectionSort(A,N);
	for(i = 0;i < N; i++)
	{
		if(i > 0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	return 0;
}



Measured memory_bytes: 1968
n, k = map(int, input().split())
data = [0] * n
d = []
a = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        data[a[j]-1] += 1
res = 0
for s in range(n):
    if data[s] == 0:
        res += 1
print(res)


Measured memory_bytes: 9188
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X = int(input())

s = set()
s.add(1)
for i in range(2, 1001):
    t = i
    while True:
        t *= i
        if t > 1000:
            break
        s.add(t)

while True:
    if X in s:
        print(X)
        break
    else:
        X -= 1


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

int main(){
    list<char> ans;
    int rev = 0;

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        ans.push_back(s.at(i));
    }

    int q, t, f;
    char c;

    cin >> q;
    rep(i,q){
        cin >> t;
        if(t == 1){
            rev = 1 - rev;
        }else{
            cin >> f >> c;
            if( (rev == 0 && f == 1) || (rev == 1 && f == 2) ){
                ans.push_front(c);
            }else if( (rev == 0 && f == 2) || (rev == 1 && f == 1)){
                ans.push_back(c);
            }
        }
    }

    if(rev == 1) ans.reverse();

    while(!ans.empty()){
        cout << ans.front();
        ans.pop_front();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 10112
// Author :mastermindevil/mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second
#define endl '\n'
 
 
ll const mod=1e9+7;
ll const N=1e5+5;
ll fact[N];
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return (y>0?y:1); else return gcd(y%x,x);}
ll powmod(ll x,ll y){ll res=1;while(y>0){if(y%2==1)res=(res*x)%mod;y>>=1;if(y<=0)break;x=(x*x)%mod;}return res;}
ll factorial () { fact[0]=1; fact[1]=1; for(int i=2;i<N;i++) fact[i]=(fact[i-1]*i)%mod;}ll
 
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
    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);}
};
struct compare {
    bool operator()(const pair<ll, ll>& value,  const ll& key){ return (value.first < key); }
    bool operator()(const ll& key, const pair<ll, ll>& value) { return (key < value.first); }
};
 
bool compare1(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   
    if(a.f==b.f)
    {
        if(a.s<=0 && b.s<=0) return (a.s>b.s);
        return (a.s<b.s);
    }
    else if(a.f<=0 && b.f<=0 ) return (a.f > b.f);
    else return (a.f<b.f);
}


int main()
{

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

  

        ll A,B;
        cin>>A>>B;

        ll x=ceil((ld)B/0.1);
        ll y=ceil((ld)A/0.08);

        y=max(x,y);
        ld ma=y;

        x=(ld)y*0.08;
        y=(ld)y*0.1;

        //cout<<x<<" "<<y<<endl;

    
        if(y==B && x==A )
            cout<<ma<<endl;
        else
            cout<<-1<<endl;



}

Measured memory_bytes: 256
#include <cstdio>

int main (int argc, char const* argv[])
{
	int a=0,b,i;
	for(i=0;i<4;i++){
		scanf("%d",&b);
		a+=b;	
	}
	printf("%d\n%d\n",a/60,a%60);
	
	
	return 0;
}

Measured memory_bytes: 1024
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

H, W, N = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

hist = set()


def count(h, w):
    ret = 0
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        ret += (h + dh, w + dw) in hist
    return ret


def ok(a=1, b=1):
    return 1 < a < H and 1 < b < W


ans = [0] * 10
ans[0] = (H - 2) * (W - 2)
for a, b in AB:
    hist.add((a, b))
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        if not ok(a + dh, b + dw):
            continue
        c = count(a + dh, b + dw)
        ans[c] += 1
        ans[c - 1] -= 1
print('\n'.join(map(str, ans)))


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  bool yymm1 = false;
  bool yymm2 = false;
  bool mmyy1 = false;
  bool mmyy2 = false;

  int a = stoi(S.substr(0, 2));
  if (1 <= a && a <= 12) {
    mmyy1 = true;
    yymm1 = true;
  } else {
    yymm1 = true;
  }

  int b = stoi(S.substr(2, 2));
  if (1 <= b && b <= 12) {
    yymm2 = true;
    mmyy2 = true;
  } else {
    mmyy2 = true;
  }

  if (yymm1 && yymm2) {
    if (mmyy1 && mmyy2) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  } else if (mmyy1 && mmyy2) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n=int(input())
table=list(map(int,input().split()))

def insertsort(a,n):
	for i in range(n):
		v=a[i]
		j=i-1
		while j>=0 and a[j]>v:
			a[j+1]=a[j]
			j-=1
		a[j+1]=v
		print(*a)

insertsort(table,n)


Measured memory_bytes: 5976
MOD = 10 ** 9 + 7


def power_expo(x, y):
    """Returns x^y.

    <https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6>

    結局, 組み込み関数の `pow()` のほうが速そう. 第3引数でmodもできる.
    """
    if y == 0:
        return 1
    elif y % 2 == 0:
        return power_expo(x, y // 2) ** 2 % MOD
    else:
        return power_expo(x, y // 2) ** 2 * x % MOD


def main():
    x, y = [int(x) for x in input().split()]
    if (x + y) % 3 != 0:
        return 0
    summ = (x + y) // 3     # d + r
    diff = x - y  # d - r
    if summ % 2 != diff % 2:
        return 0
    d = (summ + diff) // 2  # Down
    r = (summ - diff) // 2  # Right
    if d < 0 or r < 0:
        return 0
    chosen = min(d, r)

    patterns = 1

    for i, j in zip(range(summ - chosen + 1, summ + 1), range(1, summ + 1)):
        patterns = patterns % MOD * i % MOD * pow(j, MOD - 2, MOD) % MOD

    return patterns


if __name__ == '__main__':
    print(main())

# やはり難しい，再び解説。割り算のときは mod 10^9+7 が厄介。
# とりあえず，割る方は 10^9+5 乗して掛ければいいらしい。


Measured memory_bytes: 38768
N, x = (int(i) for i in input().split())
ai = list(map(int, input().split()))
ai = sorted(ai)
count = 0
for a in ai:
    x-=a
    if x < 0:
        break
    count += 1
if x >0:
    print(count-1)
elif x == 0:
    print(count)
else:
    print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll lp[100001];
vector<ll> pr;

void prime()
{
    repf(i,1,100001) lp[i]=i;
    repf(i,2,100001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<100001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    repf(i,2,100001) if(lp[i]==i) pr.pb(i);
}


void solve(ll tt) {
    ll s;cin>>s;
    ll fac[1000001];
    fac[0]=fac[1]=1;
    ll ans=0;
    repf(i,2,1000001) fac[i]=(fac[i-1]*i)%mod;
    for(ll i=1;i<=s/3;i++) {
        ll num=fac[s-2*i-1];
        ll den=fac[s-3*i];
        den=(den*fac[i-1])%mod;
        den=power(den,mod-2,mod);
        ll val=(num*den)%mod;
        ans=(ans+val)%mod;
        // cout<<val<<endl;
    }
    cout<<ans<<endl;
} 


int main()
{
    IOS;
    prime();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

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

using namespace std;

int main(void) {
	char n[3];

	cin >> n;

	if (n[0] == '9' || n[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
dins = -1
suger = 0
ans = 0

for i in range(f//(a*100)+1):
  for j in range(f//(b*100)+1):
    if 100*(i*a+j*b)>f:
      continue
    else:
      water = 100*(i*a+j*b) 
      maxsuger = e*(i*a+j*b)
      for k in range(maxsuger//c+1):
        for l in range(maxsuger//d+1):
          su = k*c+l*d
          if su>maxsuger or (water+su)>f:
            continue
          else:
            if (water+su) != 0:
                nowd = (su/(water+su))*100
                if nowd>dins:
                  suger = su
                  ans = (water+su)
                  dins = nowd
print(ans,suger)
      

Measured memory_bytes: 9112
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>//文字列の代入に使う
#include <bits/stdc++.h>//piの利用で必要(M_PI)
#include <algorithm>


int main() {
  
  int N, K;
  
  std::cin >> N >> K;
  int value = log(N) / log(K);
  std::cout << value + 1 << std::endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

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

    ll n, k, q; cin >> n >> k >> q;
    vector<ll> imos(n+5, 0);
    rep(i, q){
        int a; cin >> a;
        imos[1]--; imos[a]++;
        imos[a+1]--; imos[n+1]++;
    }

    repr(i, 1, n+1) imos[i]+=imos[i-1];
    repr(i, 1, n+1){
        if(imos[i]+k>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = 0; int t = 0;
        for (int i = 0; i < n; i++) {
            String a = sc.next(); String b = sc.next();
            if (a.compareTo(b) > 0) {
                t+=3;
            }else if(a.compareTo(b) < 0){
                h+=3;
            }else{
                t++;
                h++;
            }
            
        }
        System.out.printf("%d %d\n", t , h);
    }
}


Measured memory_bytes: 30372
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s;
		String[] temp = new String[2];
		HashMap<Integer,Integer> map = new HashMap<>();
		ArrayList<Integer> key = new ArrayList<>();
		int a,b;
		
		while (true) {
			s = sc.next();
			if (s.equals("0,0")) {break;}
			temp = s.split(",");
			a = Integer.parseInt(temp[0]);
			b = Integer.parseInt(temp[1]);
			
			map.put(a,b);
			if (!key.contains(b)) {key.add(b);}
		}
		
		int n;
		key.sort(Comparator.reverseOrder());
		
		while (sc.hasNext()) {
			out.println(key.indexOf(map.get(sc.nextInt()))+1);
		}
	}
}


Measured memory_bytes: 26072
#include<stdio.h>

int main() {
  int i;

  char s_val[4];
  scanf("%s", s_val);
  for(i = 0; i < 4; i++) s_val[i] -= '0';

  int first = 10 * s_val[0] + s_val[1];
  int last  = 10 * s_val[2] + s_val[3];

  int yymm = 0;
  int mmyy = 0;

  if(1 <= first && first <= 12) mmyy = 1;
  if(1 <= last  && last  <= 12) yymm = 1;

  if(yymm == 1 && mmyy == 0)      printf("YYMM\n");
  else if(yymm == 0 && mmyy == 1) printf("MMYY\n");
  else if(yymm == 1 && mmyy == 1) printf("AMBIGUOUS\n");
  else                            printf("NA\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>

int main()
{
	std::string str;
	std::cin >> str;
		
	std::set<char> s;
	bool isdup = false;
	for( int i = 0; i < str.size(); i++ ) {
		auto r = s.insert( str[ i ] );
		isdup = !r.second;
		if( isdup ) {
			break;
		}
	}

	std::cout << ( !isdup ? "yes" : "no" ) << std::endl;
	return 0;
}


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

int isPrime(int n) {
  int i;
  if (n == 2)
    return 1;
  else if(n % 2 == 0 || n < 2)
    return 0;
  else {
    for (i = 3; i <= sqrt(n); i++)
      if (n % i == 0)
	return 0;
    return 1;
  }
}

int main(void) {
  int n, a, count = 0;

  scanf("%d", &n);
  while (n--) {
    scanf("%d", &a);
    if (isPrime(a)) count++;
  }

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

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top = 0;
#define N 100
//void judge(void);

int main(){

  int n[N];
  char s[N];

  while(scanf("%s",s) != EOF){

    if(s[0] == '+'){
      n[top - 1] += n[top];
      top--;
      //judge();
    }
    else if(s[0] == '-'){
      n[top - 1] -= n[top];
      top--;
      //judge();
    }
    else if(s[0] == '*'){
      n[top - 1] *= n[top];
      top--;
      //judge();
    }
    else {
      n[++top] = atoi(s);
      //judge();
    }

  }
  printf("%d\n", n[top]);

  return 0;
}

/*void judge() {
  if(top == -1) {
    printf("Stack is empty\n");
    exit(1);
  }
  else if(top == 100) {
    printf("Stack is overflow\n");
    exit(2);
  }
}*/



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

using namespace std;

int n, a[601];

int ret = 0;

int main(){
	scanf("%d", &n);
n *= 2;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a+ n + 1);
	int y = 1; if (n % 2)y++;
	for (; y <= n; y += 2){
		ret += a[y];
	}
	
	cout << ret << endl;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  cin >> a >> b;
  cout << 6- a - b << endl;
}

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

int main() {
  string A, B, C; cin >> A >> B >> C;
  if (A.back() == B.at(0) && B.back() == C.at(0)) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
using namespace std;
typedef long long ll;
int D;
int v=27;
vector<int> c(v,0);
vector<vector<int>> s;
vector<int> t;
vector<int> last(v,0);

void init(){
    cin >> D;
    s.resize(D+1);
    t.resize(D+1);
    for(int i=0;i<D+1;i++){
        s[i].resize(v);
    }

    for(int i=1;i<27;i++){
        cin >> c.at(i);
    }
    for(int i=1;i<D+1;i++){
        for(int j=1;j<27;j++){
            cin >> s.at(i).at(j);
        }
    }

    for(int i=1;i<D+1;i++){
        cin >> t.at(i);
    }

}

void init_last(){
  for(int i=0;i<v;i++){
    last.at(i) = 0;
  }
}

ll calc(){
    ll ans=0;
    init_last();
    for(int i=1;i<D+1;i++){
        ans += s.at(i).at(t.at(i));
        last.at(t.at(i)) = i;
        for(int j=1;j<v;j++){
            ans -= c.at(j) * (i - last.at(j));
        }
    }
    return ans;
}

int main(){
    init();
    /*
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
      	ll ans=0;
        int d,q;
        cin >> d >> q;
        t.at(d) = q;
      	init_last();
        cout << calc() << endl;
    }
    */

    //int D=50;

    std::random_device rd;

    std::mt19937 mt(rd());

    for(int i=1;i<D+1;i++){
        std::cout << mt()%26+1 << std::endl;
    }
  
  	return(0);
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int a, b, c;

        Scanner input = new Scanner(System.in);

        a = input.nextInt();
        b = input.nextInt();
        c = input.nextInt();

        int total1 = b - a;
        int total2 = c - b;

        if (a >= 1 && a <= 100 && b >= 1 && b <= 100 && c >= 1 && c <= 100) {
           
            if (total1 == total2) {

                System.out.println("YES");
            } else {

                System.out.println("NO");
            }
        }
    }
}


Measured memory_bytes: 21204
n,m=map(int,input().split())
dic =[0]*1234567
for _ in range(m):
	dic[int(input())]+=1

mod=10**9+7
if n==1:
	print(1)
	exit()
dp = [0]*(n+1)
dp[0]=1
dp[1]=1 if dic[1]!=1 else 0

for i in range(2,n+1):
	if dic[i]:
		continue
	dp[i] = dp[i-2]+dp[i-1]
	dp[i]%=mod
print(dp[n])


Measured memory_bytes: 16628
#include <iostream>

using namespace std;

#define MAX_A_NUM 2000
#define MAX_M_NUM 2000

bool check(int n, int a[], int m, int i) {
  if(i == n) {
    if(m == 0) {
      return true;
    } else {
      return false;
    }
  }

  return check(n, a, m, i+1) || check(n, a, m - a[i], i+1);
}

int main() {
  int n, q, m;
  int a[MAX_A_NUM];
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> m;
    if(check(n, a, m, 0)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {}//連結成分サイズの配列。最初はみんな根。

    //木の根を求める
    int root(int x){
        if(par[x] < 0){
            return x;//根
        }else{
            return root(par[x]);//経路圧縮(O(logn)になる)
        }
    }

    //xとyの属する集合を併合。小さい方をくっつける。
    void unite(int x, int y){
        //先に経路圧縮。根どうしを結合する。
        x = root(x);
        y = root(y);
        if(x == y) return ;
        if(par[x] > par[y]){//xの方が小さくする(連結成分サイズで見るとxの方が大きい)
            swap(x, y);
        }
        par[x] += par[y];//根となるxのサイズを大きくする。
        par[y] = x;//yの根はxに。葉はrootの値が正になる。
        return ;
    }

    //xとyが同じ集合に属するか判定
    bool same(int x, int y){ return root(x) == root(y);}

    //集合のサイズを返す
    int size(int x) { return -par[root(x)];}
};

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, a, b;
    int ans = 0;
    cin >> n >> m;
    ans = 0;
    vll friends(n, 0);//初期化忘れない
    UnionFind uf(n);
    REP(i, m){
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }
    REP(i, n){
        ans = max(ans, uf.size(i));
    }
    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 5556
#include<iostream>
#include<map>
#include<math.h>
#include<string.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
const int maxn = 200+10;
char str[maxn];
int main(){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    double aa = h/12.0+m/720.0,bb = h+m/60.0,cc = fabs(aa-bb);
    while(cc>1) cc--;
    printf("%.9f\n",sqrt(a*a+b*b-2*a*b*cos(cc*2*pi)));
    return 0;
}



Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
cnt=Counter(a)
mos=cnt.most_common()
"""print(mos)
print(mos[0][0])"""
ans=0
if len(cnt)>=k:
    for i in range(len(cnt)-k):
        ans+=mos[-i-1][1]
print(max(0,ans))


Measured memory_bytes: 96712
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) puts("YES"); else puts("NO");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N;
  cin >> N;
  double root = sqrt(N);
  int rootInt = floor(root);
  int result = rootInt * rootInt;
  cout << result << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n;
double ans,bit=380000.0;
string y;
double x;

void input(){
	cin>>n;
	return;
}

void solve(){
	for(int i=0;i<n;i++){
        cin>>x>>y;
        if(y=="JPY")ans+=x;
        else ans+=x*bit;
    }
    cout<<setprecision(20)<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int i;
    for(i = sy; i < ty; i ++)
    	cout << "U";
    for(i = sx; i < tx; i ++)
    	cout << "R";
    for(i = ty; i > sy; i --)
    	cout << "D";
    for(i = tx; i > sx; i --)
    	cout << "L";

    int currX = sx - 1;
    int currY = sy;
    cout << "L";
    for(i = currY; i <= ty; i ++)
    	cout << "U";
    currY = i;
    for(i = currX; i < tx; i ++)
    	cout << "R";
    currX = i;
    cout << "D";
    cout << "R";
    currY --;
    currX ++;
    // cout << currX << " " << currY << endl;
    for(i = currY; i >= sy; i --)
    	cout << "D";
    for(i = currX; i > sx; i --)
    	cout << "L";		
    cout << "U";
}

Measured memory_bytes: 256
import sys
import collections

Gem = collections.namedtuple('Gem', 'x y')

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    gem = set()
    for i in xrange(n):
        x, y = map(int, sys.stdin.readline().split())
        gem.add(Gem(x, y))
    M = int(sys.stdin.readline())
    cur_x = cur_y = 10
    check = set()
    for i in xrange(M):
        d, l = sys.stdin.readline().split()
        l = int(l)
        if d == 'N':
            for g in gem:
                if cur_x == g.x and cur_y <= g.y <= cur_y + l:
                    check.add(g)
            cur_y += l
        elif d == 'S':
            for g in gem:
                if cur_x == g.x and cur_y - l <= g.y <= cur_y:
                    check.add(g)
            cur_y -= l
        elif d == 'E':
            for g in gem:
                if cur_x <= g.x <= cur_x + l and cur_y == g.y:
                    check.add(g)
            cur_x += l
        elif d == 'W':
            for g in gem:
                if cur_x - l <= g.x <= cur_x and cur_y == g.y:
                    check.add(g)
            cur_x -= l
    if len(check) == len(gem):
        print 'Yes'
    else:
        print 'No'

Measured memory_bytes: 4724
import java.util.Scanner;

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

        int sum = 0;
        for (int i = 0; i < N; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            sum += b - a + 1;
        }

        System.out.println(sum);
        scanner.close();
    }
}

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

int main( ) {
  string S;
  cin >> S;
  
  int price = 700;
  for(int i = 0; i < 3; i++){
    if(S[i]=='o'){
      price += 100;
    }
  }
  
  cout << price << endl;
  
  return 0;
}

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

int main(){
  string S;
  cin>>S;
  int flag=0;
  for(int i=0;i<S.length();i++){
    if(S.at(i)=='C'){
      flag=1;
      continue;
    }
    if(S.at(i)=='F' && flag==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;
using Float = double;

int main()
{
  Int A, B;
  cin >> A >> B;
  
  for(Int p=0; ; p++) {
    if (p*8/100 == A && p*10/100 == B) {
      cout << p << endl;
      exit(0);
    }
    if (p*8/100 > A && p*10/100 > B) {
      cout << -1 << endl;
      exit(0);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 200000
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
struct D{int x,y; D(){} D(int _x, int _y){x=_x,y=_y;}}A[MAXN+5], S[MAXN+5]; int f[MAXN+5], s[MAXN+5], n, l = INF, r;
inline bool cmpx(D a, D b){return a.x^b.x?a.x<b.x:a.y<b.y;} inline bool cmpy(D a, D b){return a.y^b.y?a.y<b.y:a.x<b.x;}
int main()
{
	n = read(); for(rint i = 1; i <= n; A[i].x = read(), A[i].y = read(), i++);
	sort(A+1,A+n+1,cmpy); for(rint i = 1; i <= n; A[i].y = i, i++); sort(A+1,A+n+1,cmpx); for(rint i = 1; i <= n; A[i].x = i, i++);
	for(rint i = 1, w = 0; i <= n; S[i].y = w = max(w,A[i].y), i++); for(rint i = n, w = INF; i; S[i].x = w = min(w,A[i].y), i--); sort(S+1,S+n+1,cmpy); S[n+1].x = S[n+1].y = n+1, f[0] = s[0] = 1;
	for(rint i = 1, j = 0; i <= n+1; f[i] = s[i-1]+MOD-(j?s[j-1]:0), f[i]<MOD?:f[i]-=MOD, s[i] = s[i-1]+f[i], s[i]<MOD?:s[i]-=MOD, i++) for(; j<i&&S[j].y<S[i].x-1; j++); printf("%d\n",f[n+1]); return 0;
}

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

#define int         long long
#define mp          make_pair
#define pb          push_back
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define mii         map<pair<int,int>,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define hellhsh     444440583533
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i];
#define si(x)       cin>>x;
#define sii(x,y)    cin>>x>>y;
#define ahell   998244353
#define p(x)   printf("%I64d",x)
#define aut(x,u) for(auto x:u)
#define pri     queue<pii>
#define forn(k) for(int i=0;i<k;i++)
#define N 200007
#define fl 1.0000000000
#define ms(a,n) memset(a,n,sizeof(a))
#define INF 10000000000007
using namespace std;
int x,y,m,k;
int n;
vii list[1006];
void solve()
{
int q=0,i,j;
int x,y=0,ct=0;
cin>>x;
cout<<2*(x/500)*500+((x%500)/5)*5;
}
main()
{
ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int i,j,k,test=1;
    
  //cin>>test;
  while(test--)
  {
      solve();
      //cout<<"\n";
 }

}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int N = 5005;

int n, a, b;
int arr[N], p[N];
ll res[N][N];

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> a >> b;
    FOR(i,1,n){
        cin >> arr[i];
        p[arr[i]] = i;
    }

    memset(res[n+1], 0, sizeof res[n+1]);
    RFOR(i, n, 1) {
        ll minB[p[i]], minA[n+1];
        minB[p[i]-1] = res[i+1][p[i]-1];
        RFOR(y, p[i]-2, 0) minB[y] = min(minB[y+1], res[i+1][y]);

        minA[n] = res[i+1][n];
        RFOR(y, n-1, 0) minA[y] = min(minA[y+1], res[i+1][y]);


        FOR(x, 0, n) {
            res[i][x] = 1e18;

            //res[i][x] = min(minB[p[i]-1] + b, minA[p[i]] + a);
            res[i][x] = minA[max(x, p[i])] + a;
            if (x < p[i]) res[i][x] = min(res[i][x], minB[x] + b);
            //FOR(y,x,n){
            //    if (y < p[i]) res[i][x] = min(res[i][x], res[i+1][y] + b);
            //    else res[i][x] = min(res[i][x], res[i+1][y] + a);
            //}
            if (p[i] > x) res[i][x] = min(res[i][x], res[i+1][p[i]]);
            //cout << i << " " << x << " :: " << res[i][x] << '\n';
        }
    }
    cout << res[1][0] << '\n';
}

Measured memory_bytes: 195968
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;

ll ds(ll digit) {
	ll res = 0;
	while (digit != 0) {
		res += digit % 10;
		digit /= 10;
	}
	return res;
}
ll MOD = 1000000007;
int main() {
	ll N, K;
  	ll x=1;
	cin >> N >> K;
  	for(ll i=1; i<N; i++){
      x*=(K-1);
    }
        
	cout << K * x << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d, g, ans=100000000;
  cin >> d >> g;
  int p[10]={0}, c[10]={0};
  for(int i=0; i<d; i++)
    cin >> p[i] >> c[i];
  for(int tmp=0; tmp<(1<<10); tmp++){
    bitset<10> s(tmp);
    int num=0, sum=0;
    for(int i=0; i<d; i++){
      if(s[i]==1){
	num +=p[i];
	sum += c[i]+100*(i+1)*p[i];
      }
    }
    if(sum>=g){
      if(num<ans) ans = num;
      continue;
    }
    for(int i=d-1; i>=0; i--){
      if(s[i]==0){
	if(sum+100*(i+1)*p[i]>=g){
	  num+=ceil((g-sum)*1.0/(100*(i+1)));
	  if(num<ans) ans = num;
	  break;
	}
	else{
	  sum+=100*(i+1)*p[i];
	  num+=p[i];
	}
      }
    }
  }
  cout << ans;
  return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

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

  vi h(n);
  rep(i, 0, n) cin >> h[i];

  sort(h.rbegin(), h.rend());

  int ans = 0;
  rep(i, k, n) ans += h[i];
  
  cout << ans << endl;

  return 0;
}


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

using namespace std;

long long k = 1000000007L;

long long fact(long n) {
  long ret = 1;
  for (long i = 1; i <= n; i++) {
    ret = (ret * i) % k;
  }
  return ret;
}

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

  long n, m;
  cin >> n >> m;

  if (n > m) {
    swap(n, m);
  }
  
  if (m - n > 1) {
    cout << 0 << endl;
    return 0;
  }

  long long ans;

  if (n == m) {
    ans = 2;
  } else {
    ans = m;
  }
  for (int i = 1; i <= n; i++) {
    ans = (((ans * i) % k) * i) % k;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256