akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A = 0, N = 0, a = 0;
  cin >> N >> A;

  a = N % 500;

  if(a <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>

#define fst first
#define snd second

using namespace std;
typedef pair<int,int> pt;
typedef pair<pt,pt> state;
typedef pair<int,state> que;

char cmap[100][100];
int w,h;


bool valid(pt p) {
    int x = p.fst, y = p.snd;
    return (0<=x) && (x<w) && (0<=y) && (y<h);
}

void pushone(priority_queue<que> &q, state st, char c, int d) {
    if(valid(st.fst) && valid(st.snd) && c != 'X') {
        if(c == 'T' || c == 'S')
            q.push(que(-d, st));
        else
            q.push(que(-(d+c), st));
    }
}

void push(priority_queue<que> &q, state st, int d) {
    const int dx[] = {1,2,3,1,2,1,1,2,1};
    const int dy[] = {0,0,0,-1,-1,-2,1,1,2};

    for(int i=0; i<9; i++) {
        if(valid(pt(st.fst.fst+dx[i], st.fst.snd+dy[i])))
            pushone(q, state(st.fst, pt(st.fst.fst+dx[i], st.fst.snd+dy[i])), cmap[st.fst.fst+dx[i]][st.fst.snd+dy[i]], d);
        if(valid(pt(st.snd.fst-dx[i], st.snd.snd+dy[i])))
            pushone(q, state(pt(st.snd.fst-dx[i], st.snd.snd+dy[i]), st.snd), cmap[st.snd.fst-dx[i]][st.snd.snd+dy[i]], d);
    }
}


int main(void) {
    while(1) {
        scanf("%d%d",&w,&h);
        if(!w) break;

        priority_queue<que> q;
        map<state,int> dmap;
        memset(cmap, 0, sizeof(cmap));

        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++) {
                char s[5];
                scanf("%s",s);
                switch(s[0]) {
                    case 'S':
                        cmap[j][i] = 'S';
                        break;
                    case 'T':
                        cmap[j][i] = 'T';
                        break;
                    case 'X':
                        cmap[j][i] = 'X';
                        break;
                    default:
                        cmap[j][i] = s[0]-'0';
                        break;
                }
            }

        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                if(cmap[j][i] == 'S')
                    push(q, state(pt(j,i),pt(-100,-100)), 0), push(q, state(pt(-100,-100),pt(j,i)), 0);


        int res=-1;
        while(q.size()) {
            que now = q.top(); q.pop();
            state st = now.snd;
            int d = -now.fst;

            if(dmap.find(st) != dmap.end()) continue;
            dmap[st] = d;

            if(cmap[st.fst.fst][st.fst.snd] == 'T' || cmap[st.snd.fst][st.snd.snd] == 'T') {
                res = d;
                break;
            }

            push(q, st, d);
        }
        printf("%d\n",res);
    }
}

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

namespace AtCoder
{
    class Abc168A
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            switch (n % 10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                default:
                    Console.WriteLine("bon");
                    break;
            }
        }
    }
}


Measured memory_bytes: 27372
K, A, B = map(int,input().split())
if B-A <=2:
    ans = K + 1
elif K <= A:
    ans = K +1
else:
    # A-1回たたく
    time = K - (A-1)
    ans = A 
    # n回 A枚をBに交換する 2*n回数分の操作
    n = time // 2
    mod = time % 2
    ans += n*(-A + B)
    ans += mod

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int N,T;
vector<pair<int, int>> AB;
int dp[3010][3010];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> T;
  REP(i,N){
    int a,b;
    cin >> a >> b;
    AB.push_back(make_pair(a,b));
  }
  sort(ALL(AB));
  int ans = 0;
  dp[0][0] = 0;
  FOR(i,1,N+1){
    REP(j,T){
      dp[i][j] = dp[i-1][j];
      ans = max(ans, dp[i][j]+AB[i-1].second);
      if(j-AB[i-1].first>=0){
        dp[i][j] = max(dp[i][j], dp[i-1][j-AB[i-1].first] + AB[i-1].second);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			final int n = Integer.parseInt(sc.nextLine());
			while (sc.hasNext()) {
				BigDecimal x = new BigDecimal(sc.nextLine());
				BigDecimal y = new BigDecimal(sc.nextLine());
				BigDecimal z = x.add(y);
				System.out.println((z.precision() > 80) ? "overflow" : z);
			}
		}
	}
}

Measured memory_bytes: 26096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        // String str2 = scan.nextLine();
        String[] s = str.split(" ");
        String s1 = s[1] + s[0];

        System.out.println(s1);
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

struct intint{
  int num;
  int count;
};

bool asc(const intint& f, const intint& s) {
  return f.count == s.count ? f.num < s.num : f.count > s.count; 
}

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

  int i,j,n,m;
  int go;
  while(1){
  cin >> n >> m;
  if (n == 0 && m == 0) return 0;
  vector <intint> count(m);
  //int *count = new int[m];
  for (i = 0; i < n; i++) {  //?????????
    for(j = 0; j < m; j++) {  //????????????????????????
      if (i == 0) {
        //count????????????
        count[j].num = j;
        count[j].count = 0;
      }
      cin >> go;
      if (go == 1) {
        count[j].count++;//count[j]++;
      }
    }
  }
  sort(count.begin(),count.end(),asc);
  for (j = 0; j < m-1; j++) {
    cout << (count[j].num + 1) << " "; //<< ":" << count[j].count << endl;
  }
  cout << count[m-1].num + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
/*************************************************************************
    > File Name: e.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月03日 星期四 12时21分07秒
 ************************************************************************/

#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn = 100005;

int a[maxn];
long long s[maxn];

int main(){
    int n;
    long long m;
    scanf("%d%lld", &n, &m);
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(&a[1], &a[n+1]);
    for(int i = 1; i <= n; i++)
        s[i] = s[i-1]+a[i];
    for(int i = 0; i <= n; i++)
        s[i] = s[n]-s[i];

    register int cl = 2*a[1], cr = 2*a[n];
    register long long ans, cnt;
    while(cl <= cr){
        ans = cnt = 0;
        register int cm = (cl+cr)>>1;
        for(int i = 1; i <= n; i++){
            register int tl = 1, tr = n+1, cnum = cm-a[i];
            while(tl < tr){
                register int tm = (tl+tr)>>1;
                if(a[tm] <= cnum)
                    tl = tm+1;
                else
                    tr = tm;
            }
            tl--;
            tr = n-tl;
            cnt += tr;
            ans += (long long)tr*a[i]+s[tl];
        }
        if(cnt > m)
            cl = cm+1;
        else if(cnt < m)
            cr = cm-1;
        else
            break;
    }
    if(cnt != m)
        ans += cl*(m-cnt);
    printf("%lld\n", ans);
}



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> ok(n, true);
    rep(i,n) cin >> h[i];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        if (h[a] <= h[b]) ok[a] = false;
        if (h[b] <= h[a]) ok[b] = false;
    }
    int ans = 0;
    rep(i,n) if (ok[i]) ans++;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 4016
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        bool[][] b = Enumerable.Repeat(0, nm[0]).Select(x => new bool[2]).ToArray();
        b[0][0] = true;
        b[b.Length - 1][1] = true;
        for (int i = 0; i < nm[1]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            if (ab[0] == 1) b[ab[1] - 1][0] = true;
            if (ab[1] == nm[0]) b[ab[0] - 1][1] = true;
        }
        Console.WriteLine(b.Any(x => x[0] && x[1]) ? "POSSIBLE" : "IMPOSSIBLE");
    }
}

Measured memory_bytes: 28636
function main(input) {

        const bottom = input % 100;
        const top = (input - bottom) / 100;

        const isMonth = m => (1 <= m) && (m <= 12);
        const isBottomInMonth = isMonth(bottom);
        const isTopInMonth = isMonth(top);

        if ((!isBottomInMonth) && (!isTopInMonth)) {
                console.log('NA');
        }
        else if ((isBottomInMonth) && (isTopInMonth)) {
                console.log('AMBIGUOUS');
        }
        else if (isBottomInMonth) {
                console.log('YYMM');
        }
        else {
                console.log('MMYY');
        }
}

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


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  bool check = false;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) check = true;
  }
  if (check) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3636
import math,sys
n = input()
a = map(int, raw_input().split())
if len(set(a)) == 1:
    print 0
    sys.exit()
res = []
for af in range(-100,101):
    ans = 0
    for i in a:
        ans += (i-af)**2
    res.append(ans)
print min(res)

Measured memory_bytes: 2692
#include<stdio.h>
#include<math.h>
#define ll long long
int main()
{
    ll h;
    ll ans=0;
    ll i=0;
    scanf("%lld",&h);
    if(h==1)
    {
        ans=1;
    }
    else
    {
        while(h!=1)
        {
            h=h/2;
            ans=ans+pow(2,i);
            i++;
        }
        ans=ans+pow(2,i);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    
    sort(H.rbegin(), H.rend());
    long long ans = 0;
    for (int i = K; i < N; i++) ans += H[i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n = ARGF.gets.strip.to_i
a_integers = ARGF.gets.split(/\s+/).collect{|i| i.strip.to_i}

(0..).each do |number_of_operations|
  if a_integers.all?{|i| i.even?}
    a_integers.collect!{|i| i >> 1}
  else
    puts number_of_operations
    break
  end
end


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

long long int memo[12][2];

long long int calc(char s[12], int p[12], int n){

	long long int ret = 0;
	int i;
	long long int buff;

	buff = 0;

	for(i=0;i<n;i++){
		if(p[i] == 1){
			ret += buff;
			buff = 0;
		}
		buff = buff * 10 + s[i] - '0';
	}

	ret += buff;

	return ret;
}


long long int make_str(char s[12], int p[12], int l, int i,int f){

	long long int ret;
	int j;


	ret = 0;
//	if(memo[i][f] == -1){
		if(l==i){
			ret = calc(s,p,l);
//			printf("%s = %lld\n",s,ret);
//			for(j=0;j<l;j++){printf("%d",p[j]);}
//			printf("\n");
		}else{
			if(i!=0){
				p[i] = 1;
				ret += make_str(s ,p, l, i+1, 1);
			}
				p[i] = 0;
			ret += make_str(s ,p , l, i+1, 0);
		}
//		memo[i][f] = ret;
//	}else{
//		ret = memo[i][f];
//	}

	return ret;
}




int main(void){

	char s[12];
	int p[12] = {};
	int l;
	int i;

	scanf("%s",s);

	l = strlen(s);

	for(i=0;i<l;i++){
		memo[i][0] = -1;
		memo[i][1] = -1;
	}

	printf("%lld\n",make_str(s, p, l, 0, 0));

	return 0;
}

Measured memory_bytes: 128
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int k;
	cin >> k;
	cout << A[k - 1] << endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt()-1;
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[a[i]] == i) cnt++;
        }
        System.out.println(cnt/2);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 9892
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
class card {
public:
	char suit; int number;
	card() : suit('?'), number(-1) {};
	card(char suit_, int number_) : suit(suit_), number(number_) {};
	bool operator==(const card& c) const {
		return suit == c.suit && number == c.number;
	}
};
void quicksort(std::vector<card> &A, int l, int r) {
	if(r - l <= 1) return;
	int ptr = l;
	for(int i = l; i < r - 1; ++i) {
		if(A[i].number <= A[r - 1].number) {
			std::swap(A[i], A[ptr++]);
		}
	}
	std::swap(A[ptr], A[r - 1]);
	quicksort(A, l, ptr);
	quicksort(A, ptr + 1, r);
}
int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	int N;
	std::cin >> N;
	std::vector<card> A(N);
	for(int i = 0; i < N; ++i) {
		std::string str;
		std::cin >> str >> A[i].number;
		A[i].suit = str[0];
	}
	std::vector<card> B(A);
	std::stable_sort(B.begin(), B.end(), [](const card& c1, const card& c2) { return c1.number < c2.number; });
	quicksort(A, 0, N);
	std::cout << (A == B ? "Stable" : "Not stable") << '\n';
	for(int i = 0; i < N; ++i) {
		std::cout << A[i].suit << ' ' << A[i].number << '\n';
	}
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    n%=10;
    if(n==2 || n==4 || n==5 || n==7 || n==9) {
        cout<<"hon"<<endl;
    }
    else if(n==3){
        cout<<"bon"<<endl;
    }
    else
    cout<<"pon"<<endl;
	return 0;
}


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

int main() {
    int64_t X;
    cin >> X;

    int64_t count = 0;
    int64_t A = 100;
    while (A < X) {
        
        A = A + A/100;
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

#define PATTERN_COUNT 4
#define CARD_COUNT 13
#define ARR_LIMIT 52
#define PatternChecking(pattern) 	\
		(	(pattern) == 'S' || 	\
			(pattern) == 'H' || 	\
			(pattern) == 'C' || 	\
			(pattern) == 'D' 		\
		)
#define NumberChecking(number)		\
		(							\
			(number) >= 1 	&&		\
			(number) <= CARD_COUNT	\
		)

typedef struct {
	char pattern;
	int numbers[CARD_COUNT];
} CARD;

typedef struct {
	char pattern;
	int number;
} CARD_ONE;

const char PATTERNS[4] = { 'S', 'H', 'C', 'D' };

void GetCards(CARD* cards);
void InputNumber(int* number, int limitLow, int limitHigh);
void InputCard(CARD_ONE* input, int count);
void Finding(CARD* cards, CARD_ONE* inputs, int length);
CARD* FindingCard(CARD* cards, char pattern);
void Writing(CARD* cards);

int main(void) {
	int n;
	CARD_ONE inputs[ARR_LIMIT];
	CARD cards[PATTERN_COUNT];

	GetCards(cards);

	InputNumber(&n, 0, ARR_LIMIT);

	InputCard(inputs, n);

	Finding(cards, inputs, n);

	Writing(cards);

	return 0;
}


void GetCards(CARD* cards) {
	int idx;
	int idn;
	for (idx = 0; idx < PATTERN_COUNT; idx++) {
		cards[idx].pattern = PATTERNS[idx];
		for (idn = 0; idn < CARD_COUNT; idn++) {
			cards[idx].numbers[idn] = 0;
		}
	}
}

void InputNumber(int* number, int limitLow, int limitHigh) {
	int x;
	do {
		scanf("%d", &x);
	} while (x < limitLow || x > limitHigh);
	*number = x;
}

void InputCard(CARD_ONE* input, int count) {
	char pattern;
	int number;
	int idx;
	for (idx = 0; idx < count; idx++) {
		do {
			scanf(" %c", &pattern);
			scanf("%d", &number);
		} while (!NumberChecking(number) || !(PatternChecking(pattern)));
		input->pattern = pattern;
		input->number = number;
		input++;
	}
}

void Finding(CARD* cards, CARD_ONE* inputs, int length) {
	int idi;

	for (idi = 0; idi < length; idi++) {
		CARD_ONE input = *(inputs + idi);
		char pattern = input.pattern;
		int number = input.number;

		CARD* card = FindingCard(cards, pattern);
		card->numbers[number - 1] = 1;
	}
}

CARD* FindingCard(CARD* cards, char pattern) {
	int idP;
	CARD* result;
	for (idP = 0; idP < PATTERN_COUNT; idP++) {
		CARD* card = cards + idP;
		if (card->pattern == pattern) {
			result = card;
			break;
		}
	}
	return result;
}

void Writing(CARD* cards) {
	int idP;
	int idN;

	for (idP = 0; idP < PATTERN_COUNT; idP++) {
		CARD card = *(cards + idP);
		char pattern = card.pattern;

		for (idN = 0; idN < CARD_COUNT; idN++) {
			int* numbers = card.numbers;

			if (*(numbers + idN) == 0) {
				printf("%c %d\n", pattern, idN + 1);
			}
		}
	}
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  map<string, bool> mp;
  string bef = "$";
  rep(i, 0, n) {
    string w;
    cin >> w;
    if (mp.count(w) || (i != 0 && bef[bef.size() - 1] != w[0])) {
      cout << "No" << endl;
      return 0;
    }
    mp[w] = true;
    bef = w;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3672
#include<stdio.h>

int max(int a, int b){
  if(a < b) return b;
  else return a;
}

int min(int a, int b){
  if(a > b) return b;
  else return a;
}

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  int left = 1;
  int right = n;
  for(int i = 0; i < m; i++){
    int l, r;
    scanf("%d %d", &l, &r);
    left = max(l, left);
    right = min(r, right);
  }
  
  printf("%d", max(0, right - left + 1));
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll s[102][202000],b[102][202000],n,k,ans;      //第几位  第几位是多少
int main(){
	cin>>n>>k;
	int d=sqrt(n);
	s[0][1]=1; //前缀和  因此只有赋值s[0][1];
	for(int i=1;i<=k;i++){
		for(int j=1;j<=d;j++) s[i-1][j]=(s[i-1][j-1]+s[i-1][j])%mod;         //预处理前i-1的和
		for(int j=1;j<=d;j++) b[i-1][j]=(b[i-1][j-1]+b[i-1][j])%mod;
		for(int j=1;j<=d;j++){
			b[i][j]=((n/j-n/(j+1))*s[i-1][j])%mod;
			s[i][j]=(s[i-1][d]+b[i-1][d]-b[i-1][j-1]+mod)%mod;
			if(j==n/j) b[i][j]=0;
		}
 }
 for(int i=1;i<=d;i++) ans=(ans+s[k][i]+b[k][i])%mod;
 cout<<ans<<'\n';
}


Measured memory_bytes: 318208
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string c1, c2;
    cin >> c1 >> c2;

    if (c1[0] == c2[2] && c1[1] == c2[1]  && c1[2] == c2[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

int main()
{
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a == b) {
        cout << c << "\n";
    } else if(b == c) {
        cout << a << "\n";
    } else {
        cout << b << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;

void main()
{
    auto nw = readln.split.to!(int[]);
    auto N = nw[0];
    auto W = nw[1];
    int[] vs, ws;
    foreach (_; 0..N) {
        auto vw = readln.split.to!(int[]);
        vs ~= vw[0];
        ws ~= vw[1];
    }

    auto DP = new int[][](N+1, W+1);
    foreach (i; 0..N) {
        foreach (j; 0..W+1) {
            auto w = j-ws[i];
            if (w >= 0) {
                DP[i+1][w] = max(DP[i+1][w], DP[i][j] + vs[i]);
            }
            DP[i+1][j] = max(DP[i+1][j], DP[i][j]);
        }
    }
    int r = -1;
    foreach (dp; DP[N]) r = max(r, dp);
    writeln(r);
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n' 

int it[1000001];
int n;
int ans[1000001];
int dp[1000001][2];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<(1<<n);i++){
		cin>>it[i];
	}
	for(int j=0;j<n;j++){
		for(int k=0;k<(1<<n);k++){
			dp[k][0]=-1e9;
			dp[k][1]=-1e9;
		}
		for(int k=0;k<(1<<n);k++){
			for(int i=0;i<n;i++){
				if((k&(1<<i))){
					dp[k][0]=max(dp[k][0],dp[k-(1<<i)][0]);
					dp[k][1]=max(dp[k][1],dp[k-(1<<i)][1]);
				}
			}
			if(k&(1<<j)){
				dp[k][0]=max(dp[k][0],it[k]);
			}
			else{
				dp[k][1]=max(dp[k][1],it[k]);
			}
			
			
			ans[k]=max(ans[k],dp[k][0]+dp[k][1]);
		}
	}
	int cur=0;
	for(int i=1;i<(1<<n);i++){
		cur=max(cur,ans[i]);
		cout<<cur<<endl;
	}

	









	return 0;
}

Measured memory_bytes: 7720
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
    ll n, t, prev;
    cin >> n >> t >> prev;
    ll now, cnt = t;
    for (ll i = 1; i < n; ++i) {
        cin >> now;
        if (now < prev + t) cnt += (now - prev);
        else cnt += t;
        prev = now;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int m = 0;
	int f = 0;
	int r = 0;

	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) { break; }

		if (m == -1 || f == -1) {
			printf("F\n");
		}
		else if (80 <= m + f) {
			printf("A\n");
		}
		else if (65 <= m + f) {
			printf("B\n");
		}
		else if (50 <= m + f) {
			printf("C\n");
		}
		else if (30 <= m + f) {
			if (50 <= r) {
				printf("C\n");
			}
			else {
				printf("D\n");
			}
		}
		else {
			printf("F\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1748
d,g = map(int, input().split())
l = []
for i in range(d):
    l.append(list(map(int,input().split())))
from itertools import *
ans=10**9
for tmp in list(product([True,False], repeat=d)):
    nokori=g
    rest=[]

    solved=0
    for comp in range(d):
        if tmp[comp]:
            nokori -= l[comp][1]
            solved += l[comp][0]
            nokori -= l[comp][0]*100*(comp+1)
        else:
            for i in range(l[comp][0]):
                rest.append((comp+1) * 100)
    if nokori > 0:
        rest.sort()
        rest.reverse()

        for i in range(len(rest)):
            nokori-=rest[i]
            solved+=1
            if nokori <=0:
                break
    if ans > solved:
        ans=solved
print(ans)

Measured memory_bytes: 44140
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main (){
    int a[7];
    int b[7];
    for(int i = 0 ;i < 7;i++){
        cin >> a[i];
        cin >> b[i];

    }
    for(int i = 0 ;i < 7;i++){
      cout << a[i]-b[i]<<endl;

    }
    
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n;

int main(){
	cin >> n;
	
	if(n % 100 <= n/100 * 5){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
S = input().rstrip()
T = input().rstrip()
from collections import defaultdict
s2t = defaultdict(int)
t2s = defaultdict(int)
for s,t in zip(S,T):
    if (s2t[s] != 0 and s2t[s] != t) or (t2s[t] != 0 and t2s[t] != s):
        print('No')
        exit()
    s2t[s] = t
    t2s[t] = s
print('Yes')

Measured memory_bytes: 42060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector <long long> a(n);
  for (int i = 0; i < n; i++) {
	  cin >> a[i];
	}
  vector <long long> b(n + 1, 0);
  for (int i = 1; i <= n; i++) {
	  b[i] = b[i - 1] + a[i - 1];
	}
  long long ans = 1e18;
  for (int i = 1; i <= n - 1; i++) {
	  ans = min(ans, abs(b[n] - 2 * b[i]));
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;

int n;
char c[maxn];
int R,W;

int main(){
	cin>>n;
	cin>>c+1;
	for(int i=1;i<=n;i++)if(c[i]=='R')R++;else W++;
	int ans=min(R,W);
	int cnt=0;
	for(int i=1;i<=R;i++)if(c[i]=='W')cnt++;
	ans=min(ans,cnt);
	cout<<ans;
}

Measured memory_bytes: 3828
#include<iostream>
#include<stdio.h>
int main(){
	double a,b,c,d,e,f;
	double x,y;
	while(std::cin>>a>>b>>c>>d>>e>>f){
	y=(a*f-d*c)/(a*e-b*d);
	x=(c-b*y)/a;
	printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1236
import math

n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

for p in range(1, 4):
    if p == 1:
        print('{0:f}'.format(sum([abs(a - b) for a, b in zip(x, y)])))
    else:
        print('{0:f}'.format(math.pow(sum([math.pow(abs(a - b), p) for a, b in zip(x, y)]), 1 / p)))

print('{0:f}'.format(max(abs(a - b) for a, b in zip(x, y))))

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

typedef long long ll;

int main() {
    
    ll L, R;
    cin >> L >> R;
    ll result = 2020;
    for (ll i = L; i < min(R, L + 2019); ++i) {
        for (ll j = i + 1; j <= min(R, L + 2019); ++j) {
            result = min(result, (i * j) % 2019);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
# source: http://drken1215.hatenablog.com/entry/2019/04/27/224100_1
# verify: https://atcoder.jp/contests/abc125/tasks/abc125_c
class SegmentTree
  def initialize(n, unity, &func)
    @size_r = 1
    while @size_r < n
      @size_r <<= 2
    end
    @func = func
    @unity = unity
    @dat = Array.new(@size_r * 2, @unity)
  end

  # set, a is 0-indexed
  def set(a, v)
    @dat[a + @size_r] = v
  end

  def build
    (@size_r - 1).downto(1) do |k|
      @dat[k] = @func.call(@dat[k * 2], @dat[k * 2 + 1])
    end
  end

  # get [a, b), a and b are 0-indexed
  def get(a, b)
    vleft = vright = @unity
    left = a + @size_r
    right = b + @size_r
    while (left < right)
      if (left & 1) == 1
        vleft = @func.call(vleft, @dat[left])
        left += 1
      end
      if (right & 1) == 1
        right -= 1
        vright = @func.call(@dat[right], vright)
      end
      left >>= 1
      right >>= 1
    end
    return @func.call(vleft, vright)
  end
end

N = gets.to_i
a = gets.split.map(&:to_i)

seg = SegmentTree.new(N, 0) { |x, y| x.gcd(y) }

N.times do |i|
  seg.set(i, a[i])
end
seg.build
ans = 0
N.times do |i|
  left = seg.get(0, i)
  right = seg.get(i + 1, N)
  ans = [ans, left.gcd(right)].max
end

puts ans


Measured memory_bytes: 16908
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll w[300000];
ll s[3000000];
int main() {
	int A, B, C, D, F;
	double E;
	cin >> A >> B >> C >> D >> E >> F;
	int c = 0;
	REP(i, F) {
		
		REP(j, F) {
			ll y = 100 * A*i + 100 * B*j;
			if (y > F)break;
			if (y <= F) {
				w[c] = y;
				c++;
			}
		}
	}
	int cnt = 0;
	REP(i, F) {
		REP(j, F) {
			ll y2 = C*i + D*j;
			if (y2 <= F) {
				s[cnt] = y2;
				cnt++;
			}
		}
	}

	double con = 0;
	ll wat = 0, sug = 0;
	REP(i, c) {
		REP(j, cnt) {
			ll sum = w[i] + s[j];
			double conc = double(s[j] * 100) / double(w[i]);
			if (conc >= con&&conc <= E && sum <= F) {
				con = conc;
				wat = w[i]; sug = s[j];
			}
		}
	}
	cout << (wat + sug) << " " << sug << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main()
{
    int m,N;
    cin>>N;
    m=N%10;
    if(m==2||m==4||m==5||m==7||m==9)
    {
        cout<<"hon";
    }
     else if(m==0||m==1||m==6||m==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"bon";
    }
}

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


int main(){

  int n;
  int i,j;
  int *A;
  int count=0;
  int key;


  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);


  for(i=0;i<n-1;i++){
    for(j=n-2;j>=i;j--){
      if(A[j+1] < A[j]){
        key=A[j+1];
        A[j+1]=A[j];
        A[j]=key;
        count+=1;
      }
    }
  }
  
  printf("%d",A[0]);
  for(i=1;i<n;i++) printf(" %d",A[i]);
  printf("\n%d\n",count);
  return 0;
}
  
    

  


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

int main(void){
    int N,M;
    cin >> N >> M;
    map<int,vector<int>> mp;
    int a,b;
    
    for(int i = 0; i < M;i++){
        cin >> a >> b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }
    
    
    vector<int> v;
    for(int i = 1;i <= N;i++) v.push_back(i);
    
    
    int cont = 0;
    bool lflag;
    int fcont = 0;
    do {
        
        if(v[0]==1){
            // for(auto u:v){
            //     cout <<right << setw(2)<<u;
            // }
            // cout <<endl;
            
            
            lflag = true;
            for(int i = 0; i < v.size() - 1; i++){
                fcont = 0;
                for(auto u:mp[v[i]]){
                   
                    if(u == v[i+1]) fcont++;
                    //  cout <<"i:"<<i<< v[i]<< v[i+1] << endl;
                    //  cout <<"fcont:"<<fcont<<endl;
                }
            
                if(fcont == 0)lflag = false;
            }
        
        
            if(lflag){
                cont++;

            }
        }    
    } while (next_permutation(v.begin(), v.end()));

    cout << cont << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<max(0,C-A+B)<<endl;
  return 0;
}


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

int main() {
	int n; cin >> n;
	vector<long long> v(n, 0);
	bool fail = false;
	int tmp;
	cin >> tmp;
	if (tmp != 0) fail = true;
	for (int i = 1; i < n; i++) {
		cin >> tmp;
		if (tmp == 0) fail = true;
		v[tmp]++;
	}
	if (fail) cout << 0 << endl;
	else {
		long long ans = 1;
		for (int i = 1; i < n-1; i++) {
			for (int j = 0; j < v[i+1]; j++) {
				ans *= v[i];
				ans %= 998244353;
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 1024
from sys import stdin
h,w = map(int,stdin.readline().split())
arr = [list(stdin.readline()) for _ in range(h)]
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
mod = 10**9+7
for i in range(h):
    for j in range(w):
        if arr[i][j] == '.':
            dp[i][j] += (0 if i==0 else dp[i-1][j])+(0 if j==0 else dp[i][j-1])
            dp[i][j] %= mod
print(dp[-1][-1])

Measured memory_bytes: 121148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	Int x, y;
	cin >> x >> y;

	if ((x + y) % 3 != 0) {
		cout << 0 << "\n";
	}
	else if (y < (x + 1) / 2 || y>2 * x) {
		cout << 0 << "\n";
	}
	else {
		mint ans = 1;
		Int a = (x + y)/3;
		Int b = min(x, y) - a;
		Int c = a - b;

		while (a) {
			ans *= a;
				a--;
		}
		while (b) {
			ans /= b;
				b--;
		}
		while (c) {
			ans /= c;
				c--;
		}
		cout << ans << "\n";
	}
}


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

int main(void) {

  long h,w,d,q;
  scanf("%ld %ld %ld", &h, &w, &d);
  long a[h][w];
  for (long i = 0; i < h; i++) {
    for (long j = 0; j < w; j++) {
      scanf("%ld", &a[i][j]);
    }
  }
  scanf("%ld", &q);
  long l[q],r[q];
  for (int i = 0; i < q; i++) {
    scanf("%ld %ld", &l[i], &r[i]);
  }
  long x[h*w+1],y[h*w+1];
  for (long i = 0; i < h; i++) {
    for (long j = 0; j < w; j++) {
      x[a[i][j]] = i;
      y[a[i][j]] = j;
    }
  }
  long magic[h*w+1];
  for (long i = 1; i <= d; i++) {
    magic[i] = 0;
  }
  for (long i = d+1; i <= h*w; i++) {
    magic[i] = magic[i-d]+labs(x[i]-x[i-d])+labs(y[i]-y[i-d]);
  }
  for (long i = 0; i < q; i++) {
    printf("%ld\n", magic[r[i]]-magic[l[i]]);
  }

  return 0;
}

Measured memory_bytes: 5376
# input
S = input()

week = [
    "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"
]

if S == "SUN":
    print(7)
else:
    sun_ind = week.index("SUN")
    today_ind = week.index(S)
    
    print(sun_ind - today_ind)


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

int main(){
  int n,m,a;
  set<int> s;
  cin >> n;
  while(n--){
    cin >> a;
    s.insert(a);
  }
  cin >> m;
  while(m--){
    cin >> a;
    s.insert(a);
  }
  for(auto it=s.begin(); it!=s.end(); it++){
    cout << *it<<endl;
  }
}


Measured memory_bytes: 21848
LL = list(map(int,input().split()))
LL.sort()
import numpy as np
LL = np.array(LL)
c = 0
if(sum(LL%2) == 2):
    LL = LL + LL%2
    c += 1
elif(sum(LL%2) == 1):
    LL = LL - LL%2
    c += 1
c += int((LL[2]-LL[1])/2)
c += int((LL[2]-LL[0])/2)
print(c)

Measured memory_bytes: 21408
N, M = map(int, input().split())

A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

DP = [-1]*(N+1)
DP[0] = 0 

for i in range(N):
    for j in A:
        if i+B[j] <= N:
            DP[i+B[j]] = max(DP[i]*10+j, DP[i+B[j]])

print(DP[N]) 

Measured memory_bytes: 14692
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    vector<int> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    int t = 10, ans = 0;
    for(int i = 0; i < 5; i++){
        if(a[i] % 10 != 0){
            t = min(t, a[i] % 10);
        }
        ans += a[i];
        ans += 9;
        ans = ans - ans % 10;
    }
    if(t != 10){
        ans += t - 10;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N, C = map(int, input().split())
sushi = [[int(x) for x in input().split()] for _ in range(N)]


def solve():
    """
    O(N)
    Bを固定したときの最適なAを事前に計算
    """
    V = [0] * (N + 1)
    for i in range(N):
        V[i + 1] = V[i] + sushi[i][1]

    f1 = [0] + [V[a + 1] - sushi[a][0] for a in range(N)]
    f2 = [0] + [V[a + 1] - 2 * sushi[a][0] for a in range(N)]

    g1 = [x for x in accumulate(f1, max)]
    g2 = [x for x in accumulate(f2, max)]

    ans = 0
    for j in range(N + 1):
        # OA
        if j == 0:
            i = N
        else:
            i = j - 1

        # OB
        if j == 0:
            ob_x = 0
        else:
            ob_x = C - sushi[j - 1][0]
        ob_v = V[N] - V[j - 1]

        # 2OA + OB
        ans = max(ans, g2[i] + ob_v - ob_x)

        # OA + 2OB
        ans = max(ans, g1[i] + ob_v - 2 * ob_x)
    print(ans)


solve()

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

using namespace std;

// 頂点数、変数
int v, e;
const int MAX_N = 100100;
// 隣接リスト
vector<int> g[MAX_N], b[MAX_N];
int dp[MAX_N];
bool used[MAX_N];
// トポロジカルソートされた数列
vector<int> ans;

void dfs(int u) {
  if(used[u]) return;
  used[u] = true;
  for(auto i: g[u]) dfs(i);
  // 帰りがけ順で追加
  ans.push_back(u);
}

void tsort() {
  for(int i=1; i<=v; ++i) dfs(i);
  reverse(ans.begin(), ans.end());
}

signed main(void)
{
  cin >> v >> e;
  for(int i=0; i<e; ++i) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
    b[t].push_back(s);
    dp[i] = 0;
  }
  // 先にトポロジカルソートを行い，dpの一次元の順序を決定する．
  tsort();
  
  // dp開始
  int ANS = 0;
  for (int i = 1; i < ans.size(); i++) {
    int j = ans[i];
    // jへの道
    for (auto l : b[j]) {
      dp[j] = max(dp[j], dp[l] + 1);
      ANS = max(ANS, dp[j]);  
    }    
  }
  cout << ANS << endl;

  return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.length();
  int Min = 1000;
  for(int i = 0; i <= N - 3; i++){
    int x = S[i] - '0';
    int y = S[i+1] - '0';
    int z = S[i+2] - '0';
    int ans = x * 100 + y * 10 + z;
    Min = min(Min,abs(ans - 753));
  }
  cout << Min << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mods[] = {998244353, 1000000007, 1000000009};
const ll bases[] = {997, 1009, 1013};
// const ll mod = mods[0];
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll a,b,x;

int main(){
  cin >> a >> b >> x;
  if(a == 0)  cout << (b/x+1)<< endl;
  else cout << (b/x+1)-((a-1)/x+1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char s[13];
    int i;
    scanf("%s",s);
    
    for(i = 0;i < 4;i++){
        printf("%c",s[i]);
    }
    printf(" ");
    for(i = 4;i < 12;i++){
        printf("%c",s[i]);
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;
deque<char> s;
string tmp;
bool tag;//0:正序，1:倒序 
int q;
int main() {
	cin >> tmp;
	for (int i = 0; i < (int)tmp.length(); i++) {
		s.push_back(tmp[i]);
	}
	cin >> q;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			tag = !tag;
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (tag == 0) {
				if (f == 1) s.push_front(c);
				else s.push_back(c);
			} else {
				if (f == 2) s.push_front(c);
				else s.push_back(c);
			}
		}
	}
	if (tag == 0) {
		while (!s.empty()) {
			cout << s.front();
			s.pop_front();
		} cout << endl;
	} else {
		while (!s.empty()) {
			cout << s.back();
			s.pop_back();
		} cout << endl;
	}
	return 0;
}

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

int main() {
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, l; cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  bool easy = true;
  
  for (int i = 0; i < s.size(); ++i) {
    if ((i % 2) == 0) {
      if (s[i] == 'L') {
        easy = false;
        break;
      }
    } else {
      if (s[i] == 'R') {
        easy = false;
        break;
      }
    }
  }
  
  cout << (easy ? "Yes" : "No") << endl;
  return 0;
}

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

constexpr int REVERSE   = 0;
constexpr int INCREMENT = 1;
constexpr int HALF      = 2;

bool cover(int l, int r, int x)
{
    return l <= x && x <= r;
}

int reverse(int l, int r, int x)
{
    return r + l - x;
}

int main()
{
    int N, a, d, M;
    std::cin >> N >> a >> d >> M;

    std::vector<int> x(M), y(M), z(M);
    for (int i = 0; i < M; i++) {
        std::cin >> x[i] >> y[i] >> z[i];
    }

    int K;
    std::cin >> K;

    for (int i = M - 1; i >= 0; i--) {
        if (x[i] == REVERSE && cover(y[i], z[i], K)) {
            K = reverse(y[i], z[i], K);
        }
    }

    int val = a + (K - 1) * d;
    for (int i = 0; i < M; i++) {
        if (!cover(y[i], z[i], K)) {
            continue;
        }
        
        switch (x[i]) {
            case REVERSE:
                K = reverse(y[i], z[i], K);
                break;
                
            case INCREMENT:
                val++;
                break;

            case HALF:
                val /= 2;
                break;
        }
    }

    std::cout << val << std::endl;
    
    return 0;
}

Measured memory_bytes: 4928
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
int main(){
    int num[3];
    int five=0; int seven=0;
        for(int i=0; i< 3; i++){
        cin >> num[i];
        if(num[i] == 5){
            five++;
        }else if(num[i]==7){
            seven++;
        }
    }
    if(five == 2 && seven == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
def func():
    D, G = map(int, input().split())
    p = [0] * D 
    bonus = [0] * D
    for i in range(D):
        p[i], bonus[i] = map(int, input().split())
    
    ans = 10000
    for i in range(2 ** D):
        chosen = []
        for j in range(D):
            if ((i >> j) & 1) == 1:
                chosen.append(j)
        
        pointSum = 0
        Nsolved = 0
        for idx in chosen:
            pointSum += (idx + 1) * 100 * p[idx] + bonus[idx]
            Nsolved += p[idx]
        
        if pointSum >= G:
            ans = min(ans, Nsolved)
        else:
            notChosen = list(filter(lambda x: x not in chosen, list(range(D))))
            highestDimIdx = notChosen[-1]
            # if pointSum + (highestDimIdx + 1) * 100 * (p[highestDimIdx]-1) >= G:
            #     rest = G - pointSum
            #     Nsolved += -(-(rest // ((highestDimIdx + 1) * 100)))
            #     ans = min(ans, Nsolved)

            Nsolved += min(p[highestDimIdx] - 1, -(-(G - pointSum) // ((highestDimIdx + 1) * 100)))
            pointSum += min(p[highestDimIdx] - 1, -(-(G - pointSum) // (highestDimIdx + 1 * 100))) * (highestDimIdx + 1) * 100
            
            if pointSum >= G:
                ans = min(ans, Nsolved)
            

    print(ans)
        
if __name__ == '__main__':
    func()


Measured memory_bytes: 42076